diff --git a/appcheck/firebase-appcheck-debug/src/test/java/com/google/firebase/appcheck/debug/internal/DebugAppCheckProviderTest.java b/appcheck/firebase-appcheck-debug/src/test/java/com/google/firebase/appcheck/debug/internal/DebugAppCheckProviderTest.java index c3a6e3535af..3d53b398fd2 100644 --- a/appcheck/firebase-appcheck-debug/src/test/java/com/google/firebase/appcheck/debug/internal/DebugAppCheckProviderTest.java +++ b/appcheck/firebase-appcheck-debug/src/test/java/com/google/firebase/appcheck/debug/internal/DebugAppCheckProviderTest.java @@ -43,10 +43,12 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; /** Tests for {@link DebugAppCheckProvider}. */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) +@LooperMode(LooperMode.Mode.LEGACY) public class DebugAppCheckProviderTest { private static final String DEBUG_SECRET = "debugSecret"; diff --git a/appcheck/firebase-appcheck-playintegrity/src/test/java/com/google/firebase/appcheck/playintegrity/internal/PlayIntegrityAppCheckProviderTest.java b/appcheck/firebase-appcheck-playintegrity/src/test/java/com/google/firebase/appcheck/playintegrity/internal/PlayIntegrityAppCheckProviderTest.java index 1cbcd153bb3..4d748b7d78f 100644 --- a/appcheck/firebase-appcheck-playintegrity/src/test/java/com/google/firebase/appcheck/playintegrity/internal/PlayIntegrityAppCheckProviderTest.java +++ b/appcheck/firebase-appcheck-playintegrity/src/test/java/com/google/firebase/appcheck/playintegrity/internal/PlayIntegrityAppCheckProviderTest.java @@ -47,10 +47,12 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; /** Tests for {@link PlayIntegrityAppCheckProvider}. */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) +@LooperMode(LooperMode.Mode.LEGACY) public class PlayIntegrityAppCheckProviderTest { private static final String PROJECT_NUMBER = "123456"; diff --git a/appcheck/firebase-appcheck-safetynet/src/test/java/com/google/firebase/appcheck/safetynet/internal/SafetyNetAppCheckProviderTest.java b/appcheck/firebase-appcheck-safetynet/src/test/java/com/google/firebase/appcheck/safetynet/internal/SafetyNetAppCheckProviderTest.java index d53fdba566e..6072e3693f1 100644 --- a/appcheck/firebase-appcheck-safetynet/src/test/java/com/google/firebase/appcheck/safetynet/internal/SafetyNetAppCheckProviderTest.java +++ b/appcheck/firebase-appcheck-safetynet/src/test/java/com/google/firebase/appcheck/safetynet/internal/SafetyNetAppCheckProviderTest.java @@ -46,10 +46,12 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; /** Tests for {@link SafetyNetAppCheckProvider}. */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) +@LooperMode(LooperMode.Mode.LEGACY) public class SafetyNetAppCheckProviderTest { private static final String API_KEY = "apiKey"; diff --git a/appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultFirebaseAppCheckTest.java b/appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultFirebaseAppCheckTest.java index 95330db0ed4..7b065e4a827 100644 --- a/appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultFirebaseAppCheckTest.java +++ b/appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultFirebaseAppCheckTest.java @@ -41,10 +41,12 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; /** Tests for {@link DefaultFirebaseAppCheck}. */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) +@LooperMode(LooperMode.Mode.LEGACY) public class DefaultFirebaseAppCheckTest { private static final String EXCEPTION_TEXT = "exceptionText"; diff --git a/appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultTokenRefresherTest.java b/appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultTokenRefresherTest.java index 67b7fd5805b..44805aca22b 100644 --- a/appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultTokenRefresherTest.java +++ b/appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultTokenRefresherTest.java @@ -33,8 +33,10 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.LooperMode; @RunWith(RobolectricTestRunner.class) +@LooperMode(LooperMode.Mode.LEGACY) public class DefaultTokenRefresherTest { private static final long TIME_TO_REFRESH_MILLIS = 1000L; diff --git a/build.gradle b/build.gradle index 30208819267..c52b79c8f04 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ ext { supportAnnotationsVersion = '28.0.0' googleTruthVersion = '1.1.2' grpcVersion = '1.48.1' - robolectricVersion = '4.3.1' + robolectricVersion = '4.9' protocVersion = '3.17.3' javaliteVersion = '3.17.3' } diff --git a/firebase-appdistribution-api/src/test/java/com/google/firebase/appdistribution/internal/FirebaseAppDistributionProxyTest.java b/firebase-appdistribution-api/src/test/java/com/google/firebase/appdistribution/internal/FirebaseAppDistributionProxyTest.java index 6c391a87752..3c0a207e250 100644 --- a/firebase-appdistribution-api/src/test/java/com/google/firebase/appdistribution/internal/FirebaseAppDistributionProxyTest.java +++ b/firebase-appdistribution-api/src/test/java/com/google/firebase/appdistribution/internal/FirebaseAppDistributionProxyTest.java @@ -33,8 +33,10 @@ import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.LooperMode; @RunWith(RobolectricTestRunner.class) +@LooperMode(LooperMode.Mode.LEGACY) public class FirebaseAppDistributionProxyTest { private FirebaseAppDistribution firebaseAppDistribution; diff --git a/firebase-appdistribution/firebase-appdistribution.gradle b/firebase-appdistribution/firebase-appdistribution.gradle index da605f2f04c..4348e9e478c 100644 --- a/firebase-appdistribution/firebase-appdistribution.gradle +++ b/firebase-appdistribution/firebase-appdistribution.gradle @@ -51,7 +51,7 @@ dependencies { runtimeOnly project(':firebase-installations') testImplementation 'junit:junit:4.13.2' - testImplementation "org.robolectric:robolectric:4.8.1" + testImplementation "org.robolectric:robolectric:$robolectricVersion" testImplementation "com.google.truth:truth:$googleTruthVersion" testImplementation 'org.mockito:mockito-inline:3.4.0' androidTestImplementation "org.mockito:mockito-android:3.4.0" diff --git a/firebase-common/data-collection-tests/src/test/java/com/google/firebase/DataCollectionPostNDefaultDisabledTest.java b/firebase-common/data-collection-tests/src/test/java/com/google/firebase/DataCollectionPostNDefaultDisabledTest.java index 72c091a5e2f..75b66ad6183 100644 --- a/firebase-common/data-collection-tests/src/test/java/com/google/firebase/DataCollectionPostNDefaultDisabledTest.java +++ b/firebase-common/data-collection-tests/src/test/java/com/google/firebase/DataCollectionPostNDefaultDisabledTest.java @@ -27,9 +27,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; @RunWith(AndroidJUnit4.class) @Config(sdk = 25) +@LooperMode(LooperMode.Mode.LEGACY) public class DataCollectionPostNDefaultDisabledTest { @Test diff --git a/firebase-common/data-collection-tests/src/test/java/com/google/firebase/DataCollectionPreNDefaultDisabledTest.java b/firebase-common/data-collection-tests/src/test/java/com/google/firebase/DataCollectionPreNDefaultDisabledTest.java index 75896f168fb..95199d0ce50 100644 --- a/firebase-common/data-collection-tests/src/test/java/com/google/firebase/DataCollectionPreNDefaultDisabledTest.java +++ b/firebase-common/data-collection-tests/src/test/java/com/google/firebase/DataCollectionPreNDefaultDisabledTest.java @@ -25,6 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; @RunWith(AndroidJUnit4.class) @Config(sdk = 19) @@ -81,6 +82,7 @@ public void setDataCollectionDefaultEnabledTrue_shouldUpdateSharedPrefs() { } @Test + @LooperMode(LooperMode.Mode.LEGACY) public void setDataCollectionDefaultEnabledTrue_shouldEmitEvents() { withApp( app -> { diff --git a/firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java b/firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java index 52517a5438b..2d68c26e693 100644 --- a/firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java +++ b/firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java @@ -82,6 +82,7 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; import org.skyscreamer.jsonassert.JSONAssert; /** @@ -93,6 +94,7 @@ @Config( manifest = Config.NONE, shadows = {ShadowPreconditions.class}) +@LooperMode(LooperMode.Mode.LEGACY) public final class FirebaseRemoteConfigTest { private static final String APP_ID = "1:14368190084:android:09cb977358c6f241"; private static final String API_KEY = "AIzaSyabcdefghijklmnopqrstuvwxyz1234567"; diff --git a/firebase-config/src/test/java/com/google/firebase/remoteconfig/RemoteConfigComponentTest.java b/firebase-config/src/test/java/com/google/firebase/remoteconfig/RemoteConfigComponentTest.java index 52b8c5300c9..36e35daac35 100644 --- a/firebase-config/src/test/java/com/google/firebase/remoteconfig/RemoteConfigComponentTest.java +++ b/firebase-config/src/test/java/com/google/firebase/remoteconfig/RemoteConfigComponentTest.java @@ -48,6 +48,7 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; /** * Unit tests for the Firebase Remote Config Component. @@ -92,6 +93,7 @@ public void setUp() { } @Test + @LooperMode(LooperMode.Mode.LEGACY) public void frc2p_doesNotCallAbt() throws Exception { FirebaseRemoteConfig fireperfFrc = @@ -106,6 +108,7 @@ public void frc2p_doesNotCallAbt() throws Exception { } @Test + @LooperMode(LooperMode.Mode.LEGACY) public void frcNonMainFirebaseApp_doesNotCallAbt() throws Exception { when(mockFirebaseApp.getName()).thenReturn("secondary"); diff --git a/firebase-config/src/test/java/com/google/firebase/remoteconfig/internal/ConfigFetchHandlerTest.java b/firebase-config/src/test/java/com/google/firebase/remoteconfig/internal/ConfigFetchHandlerTest.java index 320c616deb9..b51839663ab 100644 --- a/firebase-config/src/test/java/com/google/firebase/remoteconfig/internal/ConfigFetchHandlerTest.java +++ b/firebase-config/src/test/java/com/google/firebase/remoteconfig/internal/ConfigFetchHandlerTest.java @@ -90,6 +90,7 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; import org.skyscreamer.jsonassert.JSONAssert; /** @@ -99,6 +100,7 @@ */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) +@LooperMode(LooperMode.Mode.LEGACY) public class ConfigFetchHandlerTest { private static final String INSTALLATION_ID = "'fL71_VyL3uo9jNMWu1L60S"; private static final String INSTALLATION_AUTH_TOKEN = diff --git a/firebase-crashlytics/firebase-crashlytics.gradle b/firebase-crashlytics/firebase-crashlytics.gradle index d2c1796d35b..a63495c83c7 100644 --- a/firebase-crashlytics/firebase-crashlytics.gradle +++ b/firebase-crashlytics/firebase-crashlytics.gradle @@ -79,7 +79,7 @@ dependencies { testImplementation 'androidx.test:runner:1.4.0' testImplementation 'androidx.test:core:1.4.0' - testImplementation "org.robolectric:robolectric:4.5" + testImplementation "org.robolectric:robolectric:$robolectricVersion" testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-core:3.4.3' diff --git a/firebase-database/firebase-database.gradle b/firebase-database/firebase-database.gradle index f19c95f4d3f..37231be536e 100644 --- a/firebase-database/firebase-database.gradle +++ b/firebase-database/firebase-database.gradle @@ -100,6 +100,7 @@ dependencies { testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.25.0' + testImplementation 'org.codehaus.plexus:plexus-utils:3.4.2' testImplementation "org.robolectric:robolectric:$robolectricVersion" testImplementation 'com.firebase:firebase-token-generator:2.0.0' testImplementation 'com.fasterxml.jackson.core:jackson-core:2.9.8' diff --git a/firebase-firestore/firebase-firestore.gradle b/firebase-firestore/firebase-firestore.gradle index 804331a3b17..dd113dc1812 100644 --- a/firebase-firestore/firebase-firestore.gradle +++ b/firebase-firestore/firebase-firestore.gradle @@ -150,9 +150,7 @@ dependencies { testImplementation 'androidx.test:core:1.2.0' testImplementation "org.hamcrest:hamcrest-junit:2.0.0.0" testImplementation 'org.mockito:mockito-core:2.25.0' - testImplementation ("org.robolectric:robolectric:4.8.2") { - exclude group: 'com.google.protobuf', module: 'protobuf-java' - } + testImplementation "org.robolectric:robolectric:$robolectricVersion" testImplementation "com.google.truth:truth:$googleTruthVersion" testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8' testImplementation 'com.google.guava:guava-testlib:12.0-rc2' diff --git a/firebase-firestore/ktx/ktx.gradle b/firebase-firestore/ktx/ktx.gradle index 04e58cf4d5c..f778db02c98 100644 --- a/firebase-firestore/ktx/ktx.gradle +++ b/firebase-firestore/ktx/ktx.gradle @@ -59,6 +59,7 @@ dependencies { implementation 'androidx.annotation:annotation:1.1.0' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" implementation 'com.google.android.gms:play-services-basement:18.1.0' + testCompileOnly "com.google.protobuf:protobuf-java:$protocVersion" testImplementation project(':firebase-database-collection') testImplementation 'org.mockito:mockito-core:2.25.0' testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8' diff --git a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplayTest.java b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplayTest.java index 692bbc43db8..8537144a18c 100644 --- a/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplayTest.java +++ b/firebase-inappmessaging-display/src/test/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplayTest.java @@ -87,11 +87,13 @@ import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; import org.robolectric.shadows.ShadowActivity; import org.robolectric.shadows.ShadowPackageManager; @RunWith(RobolectricTestRunner.class) @Config(sdk = 21, qualifiers = "port") +@LooperMode(LooperMode.Mode.LEGACY) public class FirebaseInAppMessagingDisplayTest { private com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay fiamUI; diff --git a/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/InAppMessageStreamManagerTest.java b/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/InAppMessageStreamManagerTest.java index 47235113be7..8675e959981 100644 --- a/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/InAppMessageStreamManagerTest.java +++ b/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/InAppMessageStreamManagerTest.java @@ -71,10 +71,12 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; // TODO: Refactor and clean this logic @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) +@LooperMode(LooperMode.Mode.LEGACY) public class InAppMessageStreamManagerTest { private static final long PAST = 1000000; private static final long NOW = PAST + 100000; diff --git a/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/MetricsLoggerClientTest.java b/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/MetricsLoggerClientTest.java index ca074a008e7..921018e98ea 100644 --- a/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/MetricsLoggerClientTest.java +++ b/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/MetricsLoggerClientTest.java @@ -55,9 +55,11 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.annotation.LooperMode; @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) +@LooperMode(LooperMode.Mode.LEGACY) public class MetricsLoggerClientTest { private static final long PAST = 1000000; private static final long NOW = PAST + 100000; diff --git a/firebase-installations/src/test/java/com/google/firebase/installations/FirebaseInstallationsTest.java b/firebase-installations/src/test/java/com/google/firebase/installations/FirebaseInstallationsTest.java index d50f5628796..56fdd7af9bd 100644 --- a/firebase-installations/src/test/java/com/google/firebase/installations/FirebaseInstallationsTest.java +++ b/firebase-installations/src/test/java/com/google/firebase/installations/FirebaseInstallationsTest.java @@ -14,12 +14,11 @@ package com.google.firebase.installations; +import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; -import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; @@ -207,7 +206,7 @@ public void testGetId_noNetwork_noIid() throws Exception { String fid = onCompleteListener.await(); assertWithMessage("getId Task failed.").that(fid).isEqualTo(TEST_FID_1); PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_FID_1); // Waiting for Task that registers FID on the FIS Servers executor.awaitTermination(500, TimeUnit.MILLISECONDS); @@ -215,7 +214,7 @@ public void testGetId_noNetwork_noIid() throws Exception { // The storage should still have the same ID and the status should indicate that the // fid is registered. entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_FID_1); assertTrue("the entry isn't unregistered: " + entry, entry.isUnregistered()); } @@ -242,7 +241,7 @@ public void testGetId_noNetwork_iidPresent() throws Exception { String fid = onCompleteListener.await(); assertWithMessage("getId Task failed.").that(fid).isEqualTo(TEST_INSTANCE_ID_1); PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_INSTANCE_ID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_INSTANCE_ID_1); // Waiting for Task that registers FID on the FIS Servers executor.awaitTermination(500, TimeUnit.MILLISECONDS); @@ -250,7 +249,7 @@ public void testGetId_noNetwork_iidPresent() throws Exception { // The storage should still have the same ID and the status should indicate that the // fid is registered. entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_INSTANCE_ID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_INSTANCE_ID_1); assertTrue("the entry doesn't have an uregistered fid: " + entry, entry.isUnregistered()); } @@ -279,7 +278,7 @@ public void testGetId_noNetwork_fidAlreadyGenerated() throws Exception { // The storage should still have the same ID and the status should indicate that the // fid is registered. PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo("generatedFid")); + assertThat(entry.getFirebaseInstallationId()).isEqualTo("generatedFid"); assertTrue("the entry doesn't have an uregistered fid: " + entry, entry.isUnregistered()); } @@ -313,7 +312,7 @@ public void testGetId_ValidIdAndToken_NoBackendCalls() throws Exception { // check that the fid is still the expected one and is registered PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_FID_1); assertTrue("the entry doesn't have a registered fid: " + entry, entry.isRegistered()); } @@ -350,7 +349,7 @@ public void testGetId_UnRegisteredId_IssueCreateIdCall() throws Exception { // check that the fid is still the expected one and is registered PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_FID_1); assertTrue("the entry doesn't have a registered fid: " + entry, entry.isRegistered()); } @@ -368,7 +367,7 @@ public void testReadToken_wildcard() { .commit(); IidStore iidStore = new IidStore(prefs, "123"); - assertThat(iidStore.readToken(), equalTo("tokenWILDCARD")); + assertThat(iidStore.readToken()).isEqualTo("tokenWILDCARD"); } @Test @@ -385,7 +384,7 @@ public void testReadToken_fcm() { .commit(); IidStore iidStore = new IidStore(prefs, "123"); - assertThat(iidStore.readToken(), equalTo("tokenFCM")); + assertThat(iidStore.readToken()).isEqualTo("tokenFCM"); } @Test @@ -402,7 +401,7 @@ public void testReadToken_gcm() { .commit(); IidStore iidStore = new IidStore(prefs, "123"); - assertThat(iidStore.readToken(), equalTo("tokenGCM")); + assertThat(iidStore.readToken()).isEqualTo("tokenGCM"); } @Test @@ -419,7 +418,7 @@ public void testReadToken_empty() { .commit(); IidStore iidStore = new IidStore(prefs, "123"); - assertThat(iidStore.readToken(), equalTo("tokenEMPTY")); + assertThat(iidStore.readToken()).isEqualTo("tokenEMPTY"); } @Test @@ -453,7 +452,7 @@ public void testReadToken_withJsonformatting() { .commit(); IidStore iidStore = new IidStore(prefs, "123"); - assertThat(iidStore.readToken(), equalTo("thetoken")); + assertThat(iidStore.readToken()).isEqualTo("thetoken"); } @Test @@ -490,10 +489,10 @@ public void testFidListener_fidChanged_successful() throws Exception { // Waiting for Task that registers FID on the FIS Servers executor.awaitTermination(500, TimeUnit.MILLISECONDS); PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_2)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_FID_2); // Verify FidListener receives fid changes. - assertThat(fidListener.getLatestFid(), equalTo(TEST_FID_2)); + assertThat(fidListener.getLatestFid()).isEqualTo(TEST_FID_2); assertNull(fidListener2.getLatestFid()); } @@ -513,7 +512,7 @@ public void testGetId_migrateIid_successful() throws Exception { String fid = onCompleteListener.await(); assertWithMessage("getId Task failed.").that(fid).isEqualTo(TEST_INSTANCE_ID_1); PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_INSTANCE_ID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_INSTANCE_ID_1); // Waiting for Task that registers FID on the FIS Servers executor.awaitTermination(500, TimeUnit.MILLISECONDS); @@ -521,7 +520,7 @@ public void testGetId_migrateIid_successful() throws Exception { // The storage should still have the same ID and the status should indicate that the // fid si registered. entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_INSTANCE_ID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_INSTANCE_ID_1); assertTrue("the entry doesn't have a registered fid: " + entry, entry.isRegistered()); } @@ -555,7 +554,7 @@ public void testGetId_multipleCalls_sameFIDReturned() throws Exception { verify(mockBackend, times(1)) .createFirebaseInstallation(TEST_API_KEY, TEST_FID_1, TEST_PROJECT_ID, TEST_APP_ID_1, null); PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_FID_1); assertTrue("the entry isn't doesn't have a registered fid: " + entry, entry.isRegistered()); } @@ -592,7 +591,7 @@ public void testGetId_expiredAuthTokenThrowsException_statusUpdated() throws Exc // Validate that registration status is still REGISTER PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_FID_1); assertTrue("the entry doesn't have a registered fid: " + entry, entry.isRegistered()); } @@ -713,7 +712,7 @@ public void testGetId_ServerError_UnregisteredFID() throws Exception { // There is nothing more we can do. PersistedInstallationEntry updatedInstallationEntry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(updatedInstallationEntry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); + assertThat(updatedInstallationEntry.getFirebaseInstallationId()).isEqualTo(TEST_FID_1); assertTrue( "the entry doesn't have an error fid: " + updatedInstallationEntry, updatedInstallationEntry.isErrored()); @@ -744,7 +743,7 @@ public void testGetId_fidRegistrationFailed_statusNotUpdated() throws Exception // We expect that the IOException will cause the request to fail, but it will not // cause the FID to be put into the error state because we expect this to eventually succeed. PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getFirebaseInstallationId(), equalTo(TEST_FID_1)); + assertThat(entry.getFirebaseInstallationId()).isEqualTo(TEST_FID_1); assertTrue("the entry doesn't have an unregistered fid: " + entry, entry.isUnregistered()); } @@ -761,7 +760,7 @@ public void testGetAuthToken_fidDoesNotExist_successful() throws Exception { onCompleteListener.await(); PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getAuthToken(), equalTo(TEST_AUTH_TOKEN)); + assertThat(entry.getAuthToken()).isEqualTo(TEST_AUTH_TOKEN); } @Test @@ -1019,7 +1018,7 @@ public void testGetAuthToken_multipleCallsForceRefresh_fetchedNewTokenTwice() th verify(mockBackend, times(1)) .generateAuthToken(TEST_API_KEY, TEST_FID_1, TEST_PROJECT_ID, TEST_REFRESH_TOKEN); PersistedInstallationEntry entry = persistedInstallation.readPersistedInstallationEntryValue(); - assertThat(entry.getAuthToken(), equalTo(TEST_AUTH_TOKEN_3)); + assertThat(entry.getAuthToken()).isEqualTo(TEST_AUTH_TOKEN_3); } @Test diff --git a/firebase-messaging/firebase-messaging.gradle b/firebase-messaging/firebase-messaging.gradle index 8058419fc09..a220aae3c1f 100644 --- a/firebase-messaging/firebase-messaging.gradle +++ b/firebase-messaging/firebase-messaging.gradle @@ -113,7 +113,7 @@ dependencies { testImplementation 'com.google.android.gms:play-services-cloud-messaging:17.0.1' testImplementation 'androidx.test:rules:1.2.0' testImplementation 'androidx.test:runner:1.2.0' - testImplementation "org.robolectric:robolectric:4.6.1" + testImplementation "org.robolectric:robolectric:$robolectricVersion" testImplementation 'junit:junit:4.13-beta-2' testImplementation 'org.mockito:mockito-core:2.25.0' testImplementation "com.google.truth:truth:$googleTruthVersion" diff --git a/firebase-ml-modeldownloader/src/test/java/com/google/firebase/ml/modeldownloader/internal/ModelFileDownloadServiceTest.java b/firebase-ml-modeldownloader/src/test/java/com/google/firebase/ml/modeldownloader/internal/ModelFileDownloadServiceTest.java index f431ebbeb70..90e6eed211c 100644 --- a/firebase-ml-modeldownloader/src/test/java/com/google/firebase/ml/modeldownloader/internal/ModelFileDownloadServiceTest.java +++ b/firebase-ml-modeldownloader/src/test/java/com/google/firebase/ml/modeldownloader/internal/ModelFileDownloadServiceTest.java @@ -61,8 +61,10 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.LooperMode; @RunWith(RobolectricTestRunner.class) +@LooperMode(LooperMode.Mode.LEGACY) public class ModelFileDownloadServiceTest { private static final String TEST_PROJECT_ID = "777777777777"; diff --git a/firebase-perf/firebase-perf.gradle b/firebase-perf/firebase-perf.gradle index fb5938575ea..62107170b8e 100644 --- a/firebase-perf/firebase-perf.gradle +++ b/firebase-perf/firebase-perf.gradle @@ -119,9 +119,7 @@ dependencies { testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.28.2' testImplementation 'org.mockito:mockito-inline:2.13.0' - testImplementation ("org.robolectric:robolectric:$robolectricVersion") { - exclude group: 'com.google.protobuf', module: 'protobuf-java' - } + testImplementation "org.robolectric:robolectric:$robolectricVersion" testImplementation "com.google.truth:truth:$googleTruthVersion" testImplementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6' testImplementation 'androidx.test:core:1.2.0' diff --git a/firebase-perf/ktx/ktx.gradle b/firebase-perf/ktx/ktx.gradle index 98cf5e5a454..74bbabc2308 100644 --- a/firebase-perf/ktx/ktx.gradle +++ b/firebase-perf/ktx/ktx.gradle @@ -50,6 +50,7 @@ dependencies { implementation project(':firebase-perf') implementation 'androidx.annotation:annotation:1.1.0' + testCompileOnly "com.google.protobuf:protobuf-java:$protocVersion" testImplementation "org.robolectric:robolectric:$robolectricVersion" testImplementation 'junit:junit:4.12' testImplementation "com.google.truth:truth:$googleTruthVersion" diff --git a/transport/transport-backend-cct/transport-backend-cct.gradle b/transport/transport-backend-cct/transport-backend-cct.gradle index c5973dde1a5..c86de2da62c 100644 --- a/transport/transport-backend-cct/transport-backend-cct.gradle +++ b/transport/transport-backend-cct/transport-backend-cct.gradle @@ -65,14 +65,14 @@ dependencies { testImplementation 'com.google.protobuf:protobuf-java-util:3.11.0' testImplementation 'androidx.test:core:1.2.0' - testImplementation 'junit:junit:4.12' testImplementation "com.google.truth:truth:$googleTruthVersion" testImplementation 'com.google.truth.extensions:truth-proto-extension:1.0' testImplementation 'com.github.tomakehurst:wiremock:2.26.3' //Android compatible version of Apache httpclient. testImplementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1' - testImplementation "org.robolectric:robolectric:$robolectricVersion" - testImplementation 'junit:junit:4.13-beta-2' + // Keep Robolectric to 4.3.1 for httpclient and TelephonyManager compatibility. + testImplementation "org.robolectric:robolectric:4.3.1" + testImplementation 'junit:junit:4.13.1' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'