Skip to content

Commit

Permalink
[Cronet] Migrate to truth assertFalse
Browse files Browse the repository at this point in the history
Bug: b/280423217
Change-Id: Ic71751c3feca4b80b0b379dc27debfcc90d2d681
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4578844
Reviewed-by: Stefano Duo <stefanoduo@google.com>
Commit-Queue: Chidera Olibie <colibie@google.com>
Cr-Commit-Position: refs/heads/main@{#1153733}
  • Loading branch information
colibie authored and Chromium LUCI CQ committed Jun 6, 2023
1 parent a983470 commit 3d8c7d4
Show file tree
Hide file tree
Showing 17 changed files with 152 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -123,16 +122,21 @@ public void run() {
@Test
@SmallTest
public void testCronetLoggingManifestMetadataNotSet() {
Assert.assertFalse(CronetManifest.isAppOptedInForTelemetry(
InstrumentationRegistry.getTargetContext(), null));
Assert.assertFalse(
assertThat(CronetManifest.isAppOptedInForTelemetry(
InstrumentationRegistry.getTargetContext(), null))
.isFalse();
assertThat(
CronetManifest.isAppOptedInForTelemetry(InstrumentationRegistry.getTargetContext(),
CronetSource.CRONET_SOURCE_STATICALLY_LINKED));
Assert.assertFalse(
CronetSource.CRONET_SOURCE_STATICALLY_LINKED))
.isFalse();
assertThat(
CronetManifest.isAppOptedInForTelemetry(InstrumentationRegistry.getTargetContext(),
CronetSource.CRONET_SOURCE_PLAY_SERVICES));
Assert.assertFalse(CronetManifest.isAppOptedInForTelemetry(
InstrumentationRegistry.getTargetContext(), CronetSource.CRONET_SOURCE_FALLBACK));
CronetSource.CRONET_SOURCE_PLAY_SERVICES))
.isFalse();
assertThat(
CronetManifest.isAppOptedInForTelemetry(InstrumentationRegistry.getTargetContext(),
CronetSource.CRONET_SOURCE_FALLBACK))
.isFalse();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -80,7 +79,7 @@ private static void checkResponseInfo(UrlResponseInfo responseInfo, String expec
assertThat(responseInfo.getUrlChain()).containsExactly(expectedUrl);
assertThat(responseInfo.getHttpStatusCode()).isEqualTo(expectedHttpStatusCode);
assertThat(responseInfo.getHttpStatusText()).isEqualTo(expectedHttpStatusText);
assertFalse(responseInfo.wasCached());
assertThat(responseInfo.wasCached()).isFalse();
assertThat(responseInfo.toString()).isNotEmpty();
}

Expand Down Expand Up @@ -1145,7 +1144,7 @@ public void testEchoStreamStepByStep() throws Exception {
callback.startNextRead(stream, readBuffer);
callback.waitForNextReadStep();
assertThat(readBuffer.position()).isEqualTo(expected.length());
assertFalse(stream.isDone());
assertThat(stream.isDone()).isFalse();
}

callback.setAutoAdvance(true);
Expand Down Expand Up @@ -1175,7 +1174,7 @@ public void testSimpleGetBufferUpdates() throws Exception {
callback.waitForNextReadStep();

assertThat(callback.mError).isNull();
assertFalse(callback.isDone());
assertThat(callback.isDone()).isFalse();
assertThat(callback.mResponseStep)
.isEqualTo(TestBidirectionalStreamCallback.ResponseStep.ON_RESPONSE_STARTED);

Expand All @@ -1187,7 +1186,7 @@ public void testSimpleGetBufferUpdates() throws Exception {
// possible to need one read per character, though in practice,
// shouldn't happen.
while (callback.mResponseAsString.length() < 2) {
assertFalse(callback.isDone());
assertThat(callback.isDone()).isFalse();
callback.startNextRead(stream, readBuffer);
callback.waitForNextReadStep();
}
Expand Down Expand Up @@ -1273,7 +1272,7 @@ public void testBadBuffers() throws Exception {
callback.waitForNextReadStep();

assertThat(callback.mError).isNull();
assertFalse(callback.isDone());
assertThat(callback.isDone()).isFalse();
assertThat(callback.mResponseStep)
.isEqualTo(TestBidirectionalStreamCallback.ResponseStep.ON_RESPONSE_STARTED);

Expand Down Expand Up @@ -1407,7 +1406,7 @@ public void testThrowOnSucceeded() {
assertThat(callback.mResponseInfo).isNotNull();
// Check that error thrown from 'onSucceeded' callback is not reported.
assertThat(callback.mError).isNull();
assertFalse(callback.mOnErrorCalled);
assertThat(callback.mOnErrorCalled).isFalse();
}

@Test
Expand All @@ -1423,8 +1422,8 @@ public void testExecutorShutdownBeforeStreamIsDone() {
(CronetBidirectionalStream) builder.setHttpMethod("GET").build();
stream.start();
callback.waitForNextReadStep();
assertFalse(callback.isDone());
assertFalse(stream.isDone());
assertThat(callback.isDone()).isFalse();
assertThat(stream.isDone()).isFalse();

final ConditionVariable streamDestroyed = new ConditionVariable(false);
stream.setOnDestroyedCallbackForTesting(new Runnable() {
Expand All @@ -1442,7 +1441,7 @@ public void run() {
// but stream will be destroyed from network thread.
streamDestroyed.block();

assertFalse(callback.isDone());
assertThat(callback.isDone()).isFalse();
assertTrue(stream.isDone());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -71,12 +70,12 @@ public void testRequiresMinApiMustRun() {
@SmallTest
public void testRunBothImplsMustRun() {
if (mTestRule.testingJavaImpl()) {
assertFalse(mTestWasRun);
assertThat(mTestWasRun).isFalse();
mTestWasRun = true;
assertThat(mTestRule.getTestFramework().getEngine())
.isInstanceOf(JavaCronetEngine.class);
} else {
assertFalse(mTestWasRun);
assertThat(mTestWasRun).isFalse();
mTestWasRun = true;
assertThat(mTestRule.getTestFramework().getEngine())
.isInstanceOf(CronetUrlRequestContext.class);
Expand All @@ -87,8 +86,8 @@ public void testRunBothImplsMustRun() {
@SmallTest
@OnlyRunNativeCronet
public void testRunOnlyNativeMustRun() {
assertFalse(mTestRule.testingJavaImpl());
assertFalse(mTestWasRun);
assertThat(mTestRule.testingJavaImpl()).isFalse();
assertThat(mTestWasRun).isFalse();
mTestWasRun = true;
assertThat(mTestRule.getTestFramework().getEngine())
.isInstanceOf(CronetUrlRequestContext.class);
Expand All @@ -99,7 +98,7 @@ public void testRunOnlyNativeMustRun() {
@OnlyRunJavaCronet
public void testRunOnlyJavaMustRun() {
assertTrue(mTestRule.testingJavaImpl());
assertFalse(mTestWasRun);
assertThat(mTestWasRun).isFalse();
mTestWasRun = true;
assertThat(mTestRule.getTestFramework().getEngine()).isInstanceOf(JavaCronetEngine.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import static org.chromium.net.CronetTestRule.getContext;
Expand Down Expand Up @@ -91,13 +90,13 @@ public void testInitTriggersRewindAndInitBeforeRewindCompletes() throws Exceptio
// Reset and then init, which should trigger a rewind.
mHandler.reset();
assertThat(mHandler.getData()).isEmpty();
assertFalse(mHandler.init());
assertThat(mHandler.init()).isFalse();
mDataProvider.waitForRewindRequest();
mHandler.checkInitCallbackNotInvoked();

// Before rewind completes, reset and init should block.
mHandler.reset();
assertFalse(mHandler.init());
assertThat(mHandler.init()).isFalse();

// Signal rewind completes, and wait for init to complete.
mHandler.checkInitCallbackNotInvoked();
Expand Down Expand Up @@ -140,7 +139,7 @@ public void testInitTriggersRewindAndInitAfterRewindCompletes() throws Exception
// Reset and then init, which should trigger a rewind.
mHandler.reset();
assertThat(mHandler.getData()).isEmpty();
assertFalse(mHandler.init());
assertThat(mHandler.init()).isFalse();
mDataProvider.waitForRewindRequest();
mHandler.checkInitCallbackNotInvoked();

Expand Down Expand Up @@ -180,7 +179,7 @@ public void testReadCompleteTriggerRewind() throws Exception {
mHandler.checkReadCallbackNotInvoked();
mHandler.reset();
// Init should return asynchronously, since there is a pending read.
assertFalse(mHandler.init());
assertThat(mHandler.init()).isFalse();
mDataProvider.assertRewindNotPending();
mHandler.checkInitCallbackNotInvoked();
assertThat(mDataProvider.getNumRewindCalls()).isEqualTo(0);
Expand Down Expand Up @@ -239,7 +238,7 @@ public void testResetBeforeReadCompleteAndInitTriggerRewind() throws Exception {
assertThat(mHandler.getData()).isEmpty();

// Init should trigger a rewind.
assertFalse(mHandler.init());
assertThat(mHandler.init()).isFalse();
mDataProvider.waitForRewindRequest();
mHandler.checkInitCallbackNotInvoked();
mDataProvider.onRewindSucceeded(mUploadDataStream);
Expand Down Expand Up @@ -307,7 +306,7 @@ public void testDestroyNativeStreamBeforeRewindComplete() throws Exception {
// Reset and then init, which should trigger a rewind.
mHandler.reset();
assertThat(mHandler.getData()).isEmpty();
assertFalse(mHandler.init());
assertThat(mHandler.init()).isFalse();
mDataProvider.waitForRewindRequest();
mHandler.checkInitCallbackNotInvoked();

Expand Down

0 comments on commit 3d8c7d4

Please sign in to comment.