From 667bf89a8fe8eb5eb8d1abe606a14370d7a7793b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Tue, 22 Aug 2023 01:30:00 +0000 Subject: [PATCH 01/21] Fix a variety of dev platform-specific issues. These issues were found after I started using a new development environment. --- .../ProfileAndDeviceIdFragmentTest.kt | 855 +++++++++--------- .../DeveloperOptionsFragmentTest.kt | 4 +- .../app/parser/StringToRatioParserTest.kt | 2 +- .../AppLanguageLocaleHandlerTest.kt | 8 +- .../AppLanguageResourceHandlerTest.kt | 14 +- .../LoggingIdentifierController.kt | 14 +- .../domain/audio/AudioPlayerControllerTest.kt | 8 +- .../AnswerClassificationControllerTest.kt | 4 +- ...tXAtPositionYRuleClassifierProviderTest.kt | 12 +- ...eforeElementYRuleClassifierProviderTest.kt | 12 +- ...IsEqualToOrderingClassifierProviderTest.kt | 2 +- ...IncorrectPositionClassifierProviderTest.kt | 4 +- ...inatorEqualToRuleClassifierProviderTest.kt | 4 +- ...xactlyEqualToRuleClassifierProviderTest.kt | 4 +- ...erPartEqualToRuleClassifierProviderTest.kt | 4 +- ...eratorEqualToRuleClassifierProviderTest.kt | 4 +- ...nSimplestFormRuleClassifierProviderTest.kt | 6 +- ...sEquivalentToRuleClassifierProviderTest.kt | 2 +- ...xactlyEqualToRuleClassifierProviderTest.kt | 4 +- ...IsGreaterThanRuleClassifierProviderTest.kt | 4 +- ...putIsLessThanRuleClassifierProviderTest.kt | 4 +- ...putIsInRegionRuleClassifierProviderTest.kt | 4 +- ...nAtLeastOneOfRuleClassifierProviderTest.kt | 6 +- ...onInputEqualsRuleClassifierProviderTest.kt | 2 +- ...roperSubsetOfRuleClassifierProviderTest.kt | 6 +- ...ceInputEqualsRuleClassifierProviderTest.kt | 6 +- ...nitsIsEqualToRuleClassifierProviderTest.kt | 2 +- ...sEquivalentToRuleClassifierProviderTest.kt | 4 +- ...icInputEqualsRuleClassifierProviderTest.kt | 4 +- ...ThanOrEqualToRuleClassifierProviderTest.kt | 4 +- ...IsGreaterThanRuleClassifierProviderTest.kt | 4 +- ...sivelyBetweenRuleClassifierProviderTest.kt | 16 +- ...ThanOrEqualToRuleClassifierProviderTest.kt | 8 +- ...putIsLessThanRuleClassifierProviderTest.kt | 8 +- ...thinToleranceRuleClassifierProviderTest.kt | 20 +- ...ioInputEqualsRuleClassifierProviderTest.kt | 4 +- ...berOfTermsEqualToClassifierProviderTest.kt | 4 +- ...icTermEqualToRuleClassifierProviderTest.kt | 10 +- ...tIsEquivalentRuleClassifierProviderTest.kt | 4 +- ...InputContainsRuleClassifierProviderTest.kt | 4 +- ...xtInputEqualsRuleClassifierProviderTest.kt | 4 +- ...utFuzzyEqualsRuleClassifierProviderTest.kt | 2 +- ...putStartsWithRuleClassifierProviderTest.kt | 4 +- .../ExplorationActiveTimeControllerTest.kt | 2 +- .../ExplorationProgressControllerTest.kt | 2 +- .../testing/FakeExplorationRetrieverTest.kt | 10 +- .../HintHandlerProdImplTest.kt | 18 +- .../domain/locale/LocaleControllerTest.kt | 2 +- .../LoggingIdentifierControllerTest.kt | 38 +- .../CpuPerformanceSnapshotterTest.kt | 2 +- .../analytics/LearnerAnalyticsLoggerTest.kt | 2 +- .../ProfileManagementControllerTest.kt | 8 +- ...uestionAssessmentProgressControllerTest.kt | 2 +- model/src/main/proto/BUILD.bazel | 5 +- .../scripts/testing/TestGitRepository.kt | 64 +- .../build/FilterPerLanguageResourcesTest.kt | 12 +- .../build/TransformAndroidManifestTest.kt | 30 +- .../org/oppia/android/scripts/ci/BUILD.bazel | 2 +- .../scripts/ci/ComputeAffectedTestsTest.kt | 18 +- .../scripts/ci/RetrieveAffectedTestsTest.kt | 8 +- .../oppia/android/scripts/common/BUILD.bazel | 1 + .../android/scripts/common/BazelClientTest.kt | 4 +- .../scripts/common/CommandExecutorImplTest.kt | 6 +- .../android/scripts/common/GitClientTest.kt | 6 +- .../scripts/common/ProtoStringEncoderTest.kt | 4 +- .../scripts/docs/KdocValidityCheckTest.kt | 36 +- .../label/AccessibilityLabelCheckTest.kt | 12 +- .../scripts/license/LicenseTextsCheckTest.kt | 8 +- .../license/MavenDependenciesListCheckTest.kt | 22 +- .../GenerateMavenDependenciesListTest.kt | 20 +- .../scripts/maven/RetrieveLicenseTextsTest.kt | 10 +- .../regex/RegexPatternValidationCheckTest.kt | 186 ++-- .../scripts/testfile/TestFileCheckTest.kt | 6 +- .../scripts/testing/TestBazelWorkspaceTest.kt | 16 +- .../scripts/testing/TestGitRepositoryTest.kt | 52 +- .../scripts/todo/TodoIssueCommentCheckTest.kt | 6 +- .../todo/TodoIssueResolvedCheckTest.kt | 6 +- .../android/scripts/todo/TodoOpenCheckTest.kt | 14 +- .../xml/StringLanguageTranslationCheckTest.kt | 4 +- .../scripts/xml/StringResourceParserTest.kt | 18 +- .../xml/StringResourceValidationCheckTest.kt | 14 +- .../android/scripts/xml/XmlSyntaxCheckTest.kt | 6 +- .../oppia/android/testing/AssertionHelpers.kt | 39 +- .../testing/FakeAnalyticsEventLoggerTest.kt | 10 +- .../testing/FakeExceptionLoggerTest.kt | 4 +- .../FakePerformanceMetricsEventLoggerTest.kt | 10 +- .../data/DataProviderTestMonitorTest.kt | 77 +- ...InitializeDefaultLocaleRuleOmissionTest.kt | 2 +- .../threading/CoroutineExecutorServiceTest.kt | 34 +- .../testing/time/FakeOppiaClockTest.kt | 8 +- .../testing/TestNoOpAssetRepositoryTest.kt | 12 +- .../data/AsyncDataSubscriptionManagerTest.kt | 6 +- .../util/data/InMemoryBlockingCacheTest.kt | 8 +- .../util/locale/AndroidLocaleFactoryTest.kt | 14 +- .../util/locale/DisplayLocaleImplTest.kt | 16 +- .../testing/TestOppiaBidiFormatterTest.kt | 2 +- .../util/logging/SyncStatusManagerTestBase.kt | 2 +- .../util/math/FractionExtensionsTest.kt | 10 +- .../android/util/math/FractionParserTest.kt | 4 +- .../android/util/math/PeekableIteratorTest.kt | 2 +- .../android/util/math/RealExtensionsTest.kt | 24 +- 101 files changed, 1075 insertions(+), 996 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index 632098510b5..f1caf58e449 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -9,6 +9,7 @@ import android.view.View import androidx.annotation.IdRes import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.RecyclerView +import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction @@ -23,7 +24,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isEnabled import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText -import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.truth.content.IntentSubject.assertThat import androidx.work.Configuration @@ -62,6 +62,7 @@ import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.atPositi import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.hasItemCount import org.oppia.android.app.shim.ViewBindingShimModule import org.oppia.android.app.testing.activity.TestActivity +import org.oppia.android.app.testing.activity.TestActivity.Companion.createIntent import org.oppia.android.app.translation.testing.ActivityRecreatorTestModule import org.oppia.android.app.utility.OrientationChangeAction.Companion.orientationLandscape import org.oppia.android.data.backends.gae.NetworkConfigProdModule @@ -147,12 +148,6 @@ import javax.inject.Singleton class ProfileAndDeviceIdFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @get:Rule val oppiaTestRule = OppiaTestRule() - @get:Rule - var activityRule = - ActivityScenarioRule( - TestActivity.createIntent(ApplicationProvider.getApplicationContext()) - ) - @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var context: Context @@ -193,559 +188,587 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_withOnlyAdminProfile_hasThreeItems() { - initializeActivityAndAddFragment() - - // There should be three items: a header, a profile, and the sync status. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) + runInTestActivityAndAddFragment { + // There should be three items: a header, a profile, and the sync status. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) + } } @Test fun testFragment_withOnlyAdminProfile_hasDeviceIdHeader() { - initializeActivityAndAddFragment() - - onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) + runInTestActivityAndAddFragment { + onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) + } } @Test fun testFragment_hasDeviceId() { - initializeActivityAndAddFragment() - - onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("0347439ebe8b")))) + runInTestActivityAndAddFragment { + onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) + } } @Test fun testFragment_deviceId_hasCopyButton() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) + runInTestActivityAndAddFragment { + onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) + } } @Test fun testFragment_deviceId_clickCopyButton_copiesDeviceIdToClipboard() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() - - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("0347439ebe8b") + runInTestActivityAndAddFragment { + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("113e04cc09a3") + } } @Test fun testFragment_withOnlyAdminProfile_hasOneProfileListed() { - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(isDisplayed())) + runInTestActivityAndAddFragment { + onProfileNameAt(position = 1).check(matches(isDisplayed())) + } } @Test fun testFragment_profileEntry_hasProfileName() { - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(withText("Admin"))) + runInTestActivityAndAddFragment { + onProfileNameAt(position = 1).check(matches(withText("Admin"))) + } } @Test fun testFragment_profileEntry_hasLearnerId() { - initializeActivityAndAddFragment() - - onLearnerIdAt(position = 1).check(matches(withText("a9fe66ab"))) + runInTestActivityAndAddFragment { + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + } } @Test fun testFragment_profileEntry_hasCopyButton() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) + } } @Test fun testFragment_profileEntry_clickFirstCopyButton_copiesAdminLearnerIdToClipboard() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() - - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("a9fe66ab") + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("8dcbbd21") + } } @Test fun testFragment_multipleProfiles_listsAllProfiles() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // Header + admin + 5 new profiles + sync status = 8 items. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + runInTestActivityAndAddFragment { + // Header + admin + 5 new profiles + sync status = 8 items. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + } } @Test fun testFragment_multipleProfiles_adminIsFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(withText("Admin"))) + runInTestActivityAndAddFragment { + onProfileNameAt(position = 1).check(matches(withText("Admin"))) + } } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentName() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // The second entry is not the admin. - onProfileNameAt(position = 2).check(matches(withText("A"))) + runInTestActivityAndAddFragment { + // The second entry is not the admin. + onProfileNameAt(position = 2).check(matches(withText("A"))) + } } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // The second profile has a different learner ID. - onLearnerIdAt(position = 1).check(matches(withText("a9fe66ab"))) - onLearnerIdAt(position = 2).check(matches(withText("6e563e2f"))) + runInTestActivityAndAddFragment { + // The second profile has a different learner ID. + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) + } } @Test fun testFragment_multipleProfiles_copySecondEntry_copiesDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 2).perform(click()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 2).perform(click()) + testCoroutineDispatchers.runCurrent() - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("A's learner ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("6e563e2f") + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("A's learner ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("208663b0") + } } @Test fun testFragment_initialState_deviceIdCopyButtonHasCopyLabel() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + runInTestActivityAndAddFragment { + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_initialState_learnerIdCopyButtonHasCopyLabel() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickDeviceIdCopyButton_deviceIdIsCopiedButNotLearnerId() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_learnerIdIsCopiedButNotDeviceId() { - initializeActivityAndAddFragment() + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() - - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_copyInOtherApp_nothingIsCopied() { - initializeActivityAndAddFragment() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - updateClipDataAsThoughFromAnotherApp() + updateClipDataAsThoughFromAnotherApp() - // Changing the clipboard in a different app should reset the labels. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + // Changing the clipboard in a different app should reset the labels. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_rotate_learnerIdStillCopied() { - initializeActivityAndAddFragment() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - // The button label should be restored after a rotation. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + // The button label should be restored after a rotation. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + } } @Test fun testFragment_multipleProfiles_rotate_profilesStillPresent() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + } } @Test fun testFragment_firstEntry_noAdminEvents_hasZeroAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_adminEvents_notUploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_adminEvents_uploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + } } @Test fun testFragment_firstEntry_noGenericEvents_hasZeroGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_genericEvents_notUploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events off of the admin profile. - logTwoAnalyticsEvents(profileId = null) + // Log a couple of events off of the admin profile. + logTwoAnalyticsEvents(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_genericEvents_uploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event, off of the admin profile. - logTwoAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) + // Log a couple of events, upload them, then log one more event, off of the admin profile. + logTwoAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + } } @Test fun testFragment_firstEntry_mixOfAdminAndGenericEvents_someUploaded_reportsAllEvents() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log & upload a mix of events with and without the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logThreeAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - - // Event counts should be represented in the correct places. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Log & upload a mix of events with and without the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logThreeAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + + // Event counts should be represented in the correct places. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) + } } @Test fun testFragment_secondEntry_noLearnerEvents_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_learnerEvents_notUploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_learnerEvents_uploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + } } @Test fun testFragment_secondEntry_learnerEvents_hasZeroAdminOrGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events, upload them, then log one more event, for a learner profile. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - - // The admin profile's event counts shouldn't change since the only logged events were for a - // specific learner profile. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events, upload them, then log one more event, for a learner profile. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + + // The admin profile's event counts shouldn't change since the only logged events were for a + // specific learner profile. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_adminAndGenericEvents_uploaded_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events generically and for the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - - // No events should be reported for the learner since it didn't have any events uploaded. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events generically and for the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + + // No events should be reported for the learner since it didn't have any events uploaded. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_initialState_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + runInTestActivityAndAddFragment { + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_initialState_wait_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() + runInTestActivityAndAddFragment { + testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) - testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_indicatorTextMentionsWaiting() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. Note - // that the extra event log is a slight hack to force a refresh of the status indicator (since - // network changes are polled when there are other changes to represent rather than being - // actively "pushed" by the system). - logAnalyticsEvent() - connectNetwork() - logAnalyticsEvent() - - // The status indicator is suggesting that events can be uploaded (and there are some available - // to upload), they just haven't been scheduled yet. - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. + // Note that the extra event log is a slight hack to force a refresh of the status indicator + // (since network changes are polled when there are other changes to represent rather than + // being actively "pushed" by the system). + logAnalyticsEvent() + connectNetwork() + logAnalyticsEvent() + + // The status indicator is suggesting that events can be uploaded (and there are some + // available to upload), they just haven't been scheduled yet. + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_uploadStarted_profileDataIsCurrentlyUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to - // produce the same situation to ensure the label is correct. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to + // produce the same situation to ensure the label is correct. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) + } } @Test fun testFragment_noConnectivity_indicatorTextMentionsDataCannotBeUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Enqueue an event but don't reconnect to the network. - logAnalyticsEvent() - - // The status indicator is suggesting that internet connectivity needs to resume in order to - // upload events. - onSyncStatusAt(position = 2) - .check( - matches( - withText( - containsString( - "Please connect to a WiFi or Cellular network in order to upload profile data" + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Enqueue an event but don't reconnect to the network. + logAnalyticsEvent() + + // The status indicator is suggesting that internet connectivity needs to resume in order to + // upload events. + onSyncStatusAt(position = 2) + .check( + matches( + withText( + containsString( + "Please connect to a WiFi or Cellular network in order to upload profile data" + ) ) ) ) - ) + } } @Test fun testFragment_eventLogged_waitForUpload_profileDataIsUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_eventLogged_uploadError_profileDataHasError() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() - // An upload error can currently only be simulated by directly influencing the sync manager. - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() + // An upload error can currently only be simulated by directly influencing the sync manager. + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Something went wrong when trying to upload events")))) + onSyncStatusAt(position = 2) + .check( + matches(withText(containsString("Something went wrong when trying to upload events"))) + ) + } } @Test fun testFragment_eventLogged_uploadError_anotherLogged_wait_profileDataIsUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.reportUploadError() - testCoroutineDispatchers.runCurrent() - - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.reportUploadError() + testCoroutineDispatchers.runCurrent() + + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_rotate_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_rotate_profileDataIsCurrentlyUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) + } } @Test fun testFragment_eventLogged_waitForUpload_rotate_profileDataIsUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_eventsLogged_uploadError_rotate_profileDataHasError() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Something went wrong when trying to upload events")))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() + + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() + + onSyncStatusAt(position = 2) + .check( + matches(withText(containsString("Something went wrong when trying to upload events"))) + ) + } } @Test @@ -753,129 +776,141 @@ class ProfileAndDeviceIdFragmentTest { // Use fake time so that the generated event logs are consistent across runs. fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) profileTestHelper.addMoreProfiles(numProfiles = 2) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log & upload some events, then enqueue others. - logThreeAnalyticsEvents(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - - onShareIdsAndEventsButtonAt(position = 5).perform(click()) - testCoroutineDispatchers.runCurrent() - - val expectedShareText = - """ - Oppia app installation ID: 932459768f39 - - Profile name: Admin, learner ID: a9fe66ab - - Uploading learner events: 3 - - Uploaded learner events: 2 - - Uploading uncategorized events: 1 - - Uploaded uncategorized events: 4 - - Profile name: A, learner ID: 6e563e2f - - Uploading learner events: 2 - - Uploaded learner events: 1 - - Profile name: B, learner ID: 5c0710a2 - - Uploading learner events: 1 - - Uploaded learner events: 2 - Current sync status: Waiting to schedule data uploading worker…. - Event log encoding integrity checks: - - First 40 chars of encoded string: H4sIAAAAAAAAAOPSlGBUUj3FqMTFX5JaXBKfk5pY - - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - - SHA-1 hash (unwrapped event string): 76f7a26348b4034787982f9505c6b5697efc6567 - - Total event string length (unwrapped): 140 - Encoded event logs: - H4sIAAAAAAAAAOPSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ - gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - """.trimIndent() - val intents = getIntents() - assertThat(intents).hasSize(1) - assertThat(intents.single()).hasAction(Intent.ACTION_SEND) - assertThat(intents.single()).hasType("text/plain") - assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) - assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Log & upload some events, then enqueue others. + logThreeAnalyticsEvents(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + + onShareIdsAndEventsButtonAt(position = 5).perform(click()) + testCoroutineDispatchers.runCurrent() + + val expectedShareText = + """ + Oppia app installation ID: 113e04cc09a3 + - Profile name: Admin, learner ID: 8dcbbd21 + - Uploading learner events: 3 + - Uploaded learner events: 2 + - Uploading uncategorized events: 1 + - Uploaded uncategorized events: 4 + - Profile name: A, learner ID: 208663b0 + - Uploading learner events: 2 + - Uploaded learner events: 1 + - Profile name: B, learner ID: 92d0c6e2 + - Uploading learner events: 1 + - Uploaded learner events: 2 + Current sync status: Waiting to schedule data uploading worker…. + Event log encoding integrity checks: + - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY + - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 + - Total event string length (unwrapped): 140 + Encoded event logs: + H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ + gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + """.trimIndent() + val intents = getIntents() + assertThat(intents).hasSize(1) + assertThat(intents.single()).hasAction(Intent.ACTION_SEND) + assertThat(intents.single()).hasType("text/plain") + assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) + assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + } } @Test fun testFragment_noEventsPending_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // The upload button should be disabled when there are no events to upload. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + // The upload button should be disabled when there are no events to upload. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + } } @Test fun testFragment_multipleEventsPending_noConnection_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // The button is still disabled since there's no internet connection. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + // The button is still disabled since there's no internet connection. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + } } @Test fun testFragment_multipleEventsPending_uploadLogsButtonEnabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - // With events pending & connectivity, the upload button should now be available to press. - onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) + // With events pending & connectivity, the upload button should now be available to press. + onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) + } } @Test fun testFragment_multipleEventsPending_clickUploadLogs_wait_uploadsEventLogs() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - fakeAnalyticsEventLogger.clearAllEvents() - - // Click the 'upload logs' button and wait. - onUploadLogsButtonAt(position = 4).perform(click()) - testCoroutineDispatchers.runCurrent() - - // The events should be uploaded. - assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + fakeAnalyticsEventLogger.clearAllEvents() + + // Click the 'upload logs' button and wait. + onUploadLogsButtonAt(position = 4).perform(click()) + testCoroutineDispatchers.runCurrent() + + // The events should be uploaded. + assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + } } - private fun initializeActivityAndAddFragment() { - activityRule.scenario.onActivity { activity -> - activity.setContentView(R.layout.test_activity) + private fun runInTestActivityAndAddFragment(testBlock: () -> Unit) { + launchActivityAndAddFragment().use { scenario -> + scenario.onActivity { activity -> + activity.setContentView(R.layout.test_activity) + + activity.supportFragmentManager.beginTransaction() + .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) + .commitNow() + } + connectNetwork() // Start with internet connectivity. + testCoroutineDispatchers.runCurrent() - activity.supportFragmentManager.beginTransaction() - .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) - .commitNow() + testBlock() } - connectNetwork() // Start with internet connectivity. - testCoroutineDispatchers.runCurrent() } + private fun launchActivityAndAddFragment() = + ActivityScenario.launch(createIntent(ApplicationProvider.getApplicationContext())) + private fun scrollTo(position: Int) { onView(withId(R.id.profile_and_device_id_recycler_view)) .perform(actionOnItemAtPosition(position, scrollTo())) diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt index e0340041713..9833c9b75c4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt @@ -417,7 +417,7 @@ class DeveloperOptionsFragmentTest { createDeveloperOptionsTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - val exception = assertThrows(RuntimeException::class) { + val exception = assertThrows() { scrollToPosition(position = 2) onView(withId(R.id.force_crash_text_view)).perform(click()) } @@ -432,7 +432,7 @@ class DeveloperOptionsFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(isRoot()).perform(orientationLandscape()) - val exception = assertThrows(RuntimeException::class) { + val exception = assertThrows() { scrollToPosition(position = 2) onView(withId(R.id.force_crash_text_view)).perform(click()) } diff --git a/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt b/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt index 2b9845c78b8..2b8b3ae2296 100644 --- a/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt @@ -231,7 +231,7 @@ class StringToRatioParserTest { @Test fun testParser_parseRatioOrThrow_ratioWithInvalidRatio_throwsException() { - val exception = assertThrows(IllegalArgumentException::class) { + val exception = assertThrows() { stringToRatioParser.parseRatioOrThrow("a:b:c") } assertThat(exception) diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageLocaleHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageLocaleHandlerTest.kt index 942fb06d5b6..67846ded7ad 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageLocaleHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageLocaleHandlerTest.kt @@ -73,7 +73,7 @@ class AppLanguageLocaleHandlerTest { @Test fun testGetDisplayLocale_initialState_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.getDisplayLocale() } @@ -103,7 +103,7 @@ class AppLanguageLocaleHandlerTest { fun testInitializeLocale_twice_throwsException() { appLanguageLocaleHandler.initializeLocale(computeNewAppLanguageLocale(ENGLISH)) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.initializeLocale(retrieveAppLanguageLocale()) } @@ -117,7 +117,7 @@ class AppLanguageLocaleHandlerTest { fun testUpdateLocale_uninitialized_throwsException() { setAppLanguage(ENGLISH) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.updateLocale(retrieveAppLanguageLocale()) } @@ -186,7 +186,7 @@ class AppLanguageLocaleHandlerTest { fun testInitializeLocaleForActivity_uninitialized_throwsException() { val configuration = Configuration() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.initializeLocaleForActivity(configuration) } diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt index 95db3cf4cd7..6206712d72d 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt @@ -241,7 +241,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { handler.getStringInLocale(-1) } + assertThrows() { handler.getStringInLocale(-1) } } @Test @@ -278,7 +278,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { handler.getStringInLocaleWithWrapping(-1) } + assertThrows() { handler.getStringInLocaleWithWrapping(-1) } } @Test @@ -315,7 +315,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { + assertThrows() { handler.getStringInLocaleWithoutWrapping(-1) } } @@ -335,7 +335,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { handler.getStringArrayInLocale(-1) } + assertThrows() { handler.getStringArrayInLocale(-1) } } @Test @@ -365,7 +365,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { handler.getQuantityStringInLocale(-1, 0) } + assertThrows() { handler.getQuantityStringInLocale(-1, 0) } } @Test @@ -396,7 +396,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { + assertThrows() { handler.getQuantityStringInLocaleWithWrapping(-1, 0) } } @@ -431,7 +431,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { + assertThrows() { handler.getQuantityStringInLocaleWithoutWrapping(-1, 0) } } diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt index 5ce84fc4bcf..f0e35b7d079 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt @@ -28,7 +28,15 @@ class LoggingIdentifierController @Inject constructor( private val persistentCacheStoreFactory: PersistentCacheStore.Factory, private val oppiaLogger: OppiaLogger ) { - private val learnerIdRandom by lazy { Random(applicationIdSeed) } + // Use a base random to compute the per-ID random IDs in order so that test behaviors are + // consistent and deterministic when fixing the application ID seed. + private val baseRandom = Random(applicationIdSeed) + private val installationRandomSeed = baseRandom.nextLong() + private val sessionRandomSeed = baseRandom.nextLong() + private val learnerRandomSeed = baseRandom.nextLong() + private val installationIdRandom by lazy { Random(installationRandomSeed) } + private val sessionIdRandom by lazy { Random(sessionRandomSeed) } + private val learnerIdRandom by lazy { Random(learnerRandomSeed) } private val sessionId by lazy { MutableStateFlow(computeSessionId()) } private val sessionIdDataProvider by lazy { @@ -113,12 +121,12 @@ class LoggingIdentifierController @Inject constructor( sessionId.value = computeSessionId() } - private fun computeSessionId(): String = learnerIdRandom.randomUuid().toString() + private fun computeSessionId(): String = sessionIdRandom.randomUuid().toString() private fun computeInstallationId(): String { return machineLocale.run { MessageDigest.getInstance("SHA-1") - .digest(learnerIdRandom.randomUuid().toString().toByteArray()) + .digest(installationIdRandom.randomUuid().toString().toByteArray()) .joinToString("") { "%02x".formatForMachines(it) } .substring(startIndex = 0, endIndex = 12) } diff --git a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt index 1730f091d1b..960cfb995e3 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt @@ -433,7 +433,7 @@ class AudioPlayerControllerTest { @Test fun testController_notInitialized_releasePlayer_fails() { setUpMediaReadyApplication() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { audioPlayerController.releaseMediaPlayer() } @@ -444,7 +444,7 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokePlay_fails() { setUpMediaReadyApplication() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) } @@ -454,7 +454,7 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokePause_fails() { setUpMediaReadyApplication() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { audioPlayerController.pause(isFromExplicitUserAction = true) } @@ -464,7 +464,7 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokeSeekTo_fails() { setUpMediaReadyApplication() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { audioPlayerController.seekTo(500) } diff --git a/domain/src/test/java/org/oppia/android/domain/classify/AnswerClassificationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/AnswerClassificationControllerTest.kt index 712ad585e86..8553d8d1f99 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/AnswerClassificationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/AnswerClassificationControllerTest.kt @@ -152,7 +152,7 @@ class AnswerClassificationControllerTest { fun testClassify_forUnknownInteraction_throwsException() { val interaction = Interaction.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { answerClassificationController.classify( interaction, TEST_STRING_0, @@ -170,7 +170,7 @@ class AnswerClassificationControllerTest { .addAnswerGroups(AnswerGroup.newBuilder().addRuleSpecs(RuleSpec.getDefaultInstance())) .build() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { answerClassificationController.classify( interaction, TEST_STRING_0, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt index 53be477a285..c7d224753c4 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt @@ -55,7 +55,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { // Reverse the x and y parameters to ensure both have the incorrect type. val inputs = mapOf("x" to NON_NEGATIVE_VALUE_1, "y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -75,7 +75,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { "y" to NON_NEGATIVE_VALUE_1 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -92,7 +92,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_testString_yInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to VALID_CONTENT_ID_2, "y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -109,7 +109,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { fun testAnswer_testString_missingInputX_throwsException() { val inputs = mapOf("y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -126,7 +126,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_missingInputY_throwsException() { val inputs = mapOf("x" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -143,7 +143,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { fun testAnswer_bothInputsMissing_throwsException() { val inputs = mapOf("z" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt index c706db71f64..a40e47d06f4 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt @@ -56,7 +56,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { "y" to NON_NEGATIVE_VALUE_1 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -73,7 +73,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_testString_xInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_1, "y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -90,7 +90,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_testString_yInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to VALID_CONTENT_ID_2, "y" to NON_NEGATIVE_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -107,7 +107,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_testString_missingInputX_throwsException() { val inputs = mapOf("y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -124,7 +124,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_missingInputY_throwsException() { val inputs = mapOf("x" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -141,7 +141,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_bothInputsMissing_throwsException() { val inputs = mapOf("z" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt index 2c65122884d..c6783f37ca1 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt @@ -137,7 +137,7 @@ class DragDropSortInputIsEqualToOrderingClassifierProviderTest { fun testAnswer_testLisOfSetsOfHtmlString_incorrectInputMap_throwsException() { val inputs = mapOf("y" to LIST_OF_SETS_12_3_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEqualToOrderingClassifierProvider.matches( answer = LIST_OF_SETS_12_3_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest.kt index d62690db395..9da1c50711e 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest.kt @@ -69,7 +69,7 @@ class DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifier fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEqualToOrderingWithOneItemIncorrectClassifier.matches( answer = LIST_OF_SETS_12_4_5, inputs = inputs, @@ -144,7 +144,7 @@ class DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifier fun testAnswer_testLisOfSetsOfHtmlString_incorrectInputMap_throwsException() { val inputs = mapOf("y" to LIST_OF_SETS_12_4_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEqualToOrderingWithOneItemIncorrectClassifier.matches( answer = LIST_OF_SETS_12_4_5, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProviderTest.kt index a4641cc64ad..c0be3182da6 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProviderTest.kt @@ -124,7 +124,7 @@ class FractionInputHasDenominatorEqualToRuleClassifierProviderTest { fun testDenominatorEquals_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to FRACTION_VALUE_TEST_2_OVER_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { denominatorIsEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, @@ -143,7 +143,7 @@ class FractionInputHasDenominatorEqualToRuleClassifierProviderTest { fun testDenominatorEquals_missingInputF_throwsException() { val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { denominatorIsEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest.kt index 56212d736d9..d5d95ca9253 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest.kt @@ -208,7 +208,7 @@ class FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest { fun testFractionalEquals_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("f" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fractionalPartIsExactlyEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, @@ -227,7 +227,7 @@ class FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest { fun testFractionalEquals_missingInputF_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_2_OVER_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fractionalPartIsExactlyEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProviderTest.kt index 3d58861f475..c1212a3a082 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProviderTest.kt @@ -405,7 +405,7 @@ class FractionInputHasIntegerPartEqualToRuleClassifierProviderTest { fun testAnswer1Over2_inputMissing_throwsException() { val inputs = mapOf("y" to WHOLE_NUMBER_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputHasIntegerPartEqualToRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, @@ -423,7 +423,7 @@ class FractionInputHasIntegerPartEqualToRuleClassifierProviderTest { fun testAnswer1Over2_inputString_throwsException() { val inputs = mapOf("x" to STRING_VALUE_TEST_LOWERCASE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputHasIntegerPartEqualToRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProviderTest.kt index 647d37cbdd3..bc4bb343c03 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProviderTest.kt @@ -145,7 +145,7 @@ class FractionInputHasNumeratorEqualToRuleClassifierProviderTest { fun testNumeratorEquals_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { numeratorIsEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, @@ -164,7 +164,7 @@ class FractionInputHasNumeratorEqualToRuleClassifierProviderTest { fun testNumeratorEquals_missingInputF_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_2_OVER_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { numeratorIsEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest.kt index 1afbb516319..8a2d65bf340 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest.kt @@ -288,7 +288,7 @@ class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest { val inputs = mapOf("y" to FRACTION_VALUE_TEST_1_OVER_2) val answer = FRACTION_VALUE_TEST_1_OVER_2 - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsEquivalentToAndInSimplestFormRuleClassifier.matches( answer = answer, inputs = inputs, @@ -306,7 +306,7 @@ class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest { val inputs = mapOf("f" to FRACTION_VALUE_TEST_1_OVER_2) val answer = STRING_VALUE_TEST - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsEquivalentToAndInSimplestFormRuleClassifier.matches( answer = answer, inputs = inputs, @@ -324,7 +324,7 @@ class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest { val inputs = mapOf("f" to STRING_VALUE_TEST) val answer = FRACTION_VALUE_TEST_1_OVER_2 - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsEquivalentToAndInSimplestFormRuleClassifier.matches( answer = answer, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProviderTest.kt index a61d6a03b41..4788fa0e9d9 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProviderTest.kt @@ -250,7 +250,7 @@ class FractionInputIsEquivalentToRuleClassifierProviderTest { fun testEquivalence_missingInput_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_2_OVER_8) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsEquivalentToRuleClassifier.matches( answer = FRACTION_VALUE_TEST_2_OVER_8, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProviderTest.kt index 5280da48f8a..67f4cdba623 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProviderTest.kt @@ -235,7 +235,7 @@ class FractionInputIsExactlyEqualToRuleClassifierProviderTest { fun testEquals_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("f" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isExactlyEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, @@ -254,7 +254,7 @@ class FractionInputIsExactlyEqualToRuleClassifierProviderTest { fun testEquals_missingInputF_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_2_OVER_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isExactlyEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProviderTest.kt index b14d9993e06..aecd631ac68 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProviderTest.kt @@ -409,7 +409,7 @@ class FractionInputIsGreaterThanRuleClassifierProviderTest { fun testFractionalAnswer_missingInput_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_1_OVER_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputGreaterThanRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, @@ -427,7 +427,7 @@ class FractionInputIsGreaterThanRuleClassifierProviderTest { fun testFractionalAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE_TEST_LOWERCASE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputGreaterThanRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProviderTest.kt index 1dda20b3d7c..03a00646b82 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProviderTest.kt @@ -409,7 +409,7 @@ class FractionInputIsLessThanRuleClassifierProviderTest { fun testAnswer1Over2_inputMissing_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_1_OVER_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputLessThanRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, @@ -427,7 +427,7 @@ class FractionInputIsLessThanRuleClassifierProviderTest { fun testAnswer1Over2_inputString_throwsException() { val inputs = mapOf("x" to STRING_VALUE_TEST_LOWERCASE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputLessThanRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProviderTest.kt index 0694388d0c9..565da313100 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProviderTest.kt @@ -89,7 +89,7 @@ class ImageClickInputIsInRegionRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isInRegionClassifierProvider.matches( answer = IMAGE_REGION_ABC_POSITION_1, inputs = inputs, @@ -108,7 +108,7 @@ class ImageClickInputIsInRegionRuleClassifierProviderTest { fun testAnswer_testString_missingInputX_throwsException() { val inputs = mapOf("y" to createString(ITEM_REGION_A)) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isInRegionClassifierProvider.matches( answer = IMAGE_REGION_ABC_POSITION_1, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt index 99be995d0bc..b6eedff3056 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt @@ -156,7 +156,7 @@ class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest { fun testItemSet_inputIsMissing_throwsException() { val inputs = mapOf("y" to ITEM_SET_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputDoesNotContainAtLeastOneOfRuleClassifier.matches( answer = ITEM_SET_12345, inputs = inputs, @@ -173,7 +173,7 @@ class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest { fun testItemSet_inputHasTheWrongType_throwsException() { val inputs = mapOf("x" to DIFFERENT_INTERACTION_OBJECT_TYPE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputDoesNotContainAtLeastOneOfRuleClassifier.matches( answer = ITEM_SET_12345, inputs = inputs, @@ -190,7 +190,7 @@ class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest { fun testItemSet_answerHasTheWrongType_throwsException() { val inputs = mapOf("x" to ITEM_SET_12345) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputDoesNotContainAtLeastOneOfRuleClassifier.matches( answer = DIFFERENT_INTERACTION_OBJECT_TYPE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProviderTest.kt index 927dcdc5f3f..a3c467dcbdc 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProviderTest.kt @@ -162,7 +162,7 @@ class ItemSelectionInputEqualsRuleClassifierProviderTest { fun testLowercaseAnswer_missingInput_throwsException() { val inputs = mapOf("y" to TEST_HTML_STRING_SET_LOWERCASE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifierProvider.matches( answer = TEST_HTML_STRING_SET_LOWERCASE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest.kt index 8997d85c434..a4d3a9fadb4 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest.kt @@ -169,7 +169,7 @@ class ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest() { fun testIsProperSubset_withInvalidInput_forAnswer12345_throwsException() { val inputs = mapOf("x" to ITEM_SELECTION_INVAILD) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsAtLeastOneOfRuleClassifier.matches( answer = ITEM_SELECTION_12345, inputs = inputs, @@ -186,7 +186,7 @@ class ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest() { fun testIsProperSubset_withInput12345_forInvalidAnswer_throwsException() { val inputs = mapOf("x" to ITEM_SELECTION_12345) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsAtLeastOneOfRuleClassifier.matches( answer = ITEM_SELECTION_INVAILD, inputs = inputs, @@ -203,7 +203,7 @@ class ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest() { fun testIsProperSubset_missingInputX_throwsException() { val inputs = mapOf("a" to ITEM_SELECTION_12345) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsAtLeastOneOfRuleClassifier.matches( answer = ITEM_SELECTION_12345, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt index d193f4c795b..c66ab000848 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt @@ -72,7 +72,7 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { fun testNonNegativeAnswer_missingInput_throwsException() { val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = NON_NEGATIVE_VALUE_TEST_0, inputs = inputs, @@ -89,7 +89,7 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { fun testUnexpectedStringAnswer_nonNegativeIntInput_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = STRING_VALUE_TEST, inputs = inputs, @@ -106,7 +106,7 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { fun testNonNegativeAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE_TEST) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = NON_NEGATIVE_VALUE_TEST_0, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProviderTest.kt index 048e5574066..ee150667497 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProviderTest.kt @@ -185,7 +185,7 @@ class NumberWithUnitsIsEqualToRuleClassifierProviderTest { fun testWholeNumberInputValue_withRealAnswerNumWithUnits_throwsException() { val inputs = mapOf("f" to WHOLE_NUMBER_VALUE_9) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { unitsIsEqualsRuleClassifier.matches( answer = DOUBLE_VALUE_TEST_DIFFERENT_TYPE, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProviderTest.kt index d53553b9d79..4e6ed68a7e7 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProviderTest.kt @@ -179,7 +179,7 @@ class NumberWithUnitsIsEquivalentToRuleClassifierProviderTest { fun testInputNumberWithUnits_testAnswer_inputWithIncorrectType_verifyThrowsException() { val inputs = mapOf("f" to INPUT_TEST_NUMBER_WITH_UNITS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { unitIsEquivalentRuleClassifier.matches( answer = DOUBLE_VALUE_TEST_DIFFERENT_TYPE, inputs = inputs, @@ -198,7 +198,7 @@ class NumberWithUnitsIsEquivalentToRuleClassifierProviderTest { fun testInputNumberWithUnits_testAnswerNumberWithUnits_withXMapping_verifyThrowsException() { val inputs = mapOf("x" to INPUT_TEST_NUMBER_WITH_UNITS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { unitIsEquivalentRuleClassifier.matches( answer = ANSWER_TEST_NUMBER_WITH_UNITS, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProviderTest.kt index 1a4c4c8b07a..daa27f53145 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProviderTest.kt @@ -144,7 +144,7 @@ class NumericInputEqualsRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -161,7 +161,7 @@ class NumericInputEqualsRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest.kt index b7298602e46..95bab873ae0 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest.kt @@ -199,7 +199,7 @@ class NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsGreaterThanOrEqualToRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -216,7 +216,7 @@ class NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsGreaterThanOrEqualToRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProviderTest.kt index aa4f78a021d..d488eba6b5a 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProviderTest.kt @@ -200,7 +200,7 @@ class NumericInputIsGreaterThanRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsGreaterThanRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -217,7 +217,7 @@ class NumericInputIsGreaterThanRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsGreaterThanRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProviderTest.kt index 504117c488e..948327a4ec9 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProviderTest.kt @@ -231,7 +231,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "c" to NEGATIVE_REAL_VALUE_3_5, "b" to POSITIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -250,7 +250,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to NEGATIVE_REAL_VALUE_3_5, "c" to POSITIVE_REAL_VALUE_1_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -269,7 +269,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to STRING_VALUE_1, "b" to NEGATIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -288,7 +288,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to POSITIVE_REAL_VALUE_1_5, "b" to STRING_VALUE_2 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -307,7 +307,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "c" to POSITIVE_INT_VALUE_1, "b" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -326,7 +326,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to POSITIVE_INT_VALUE_1, "c" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -345,7 +345,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to STRING_VALUE_1, "b" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_INT_VALUE_1, inputs = inputs, @@ -364,7 +364,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to NEGATIVE_INT_VALUE_3, "b" to STRING_VALUE_2 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProviderTest.kt index 1bcc688f8c3..90cba1612af 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProviderTest.kt @@ -199,7 +199,7 @@ class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanOrEqualToRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -216,7 +216,7 @@ class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanOrEqualToRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -233,7 +233,7 @@ class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { fun testIntAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_INT_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanOrEqualToRuleClassifier.matches( answer = POSITIVE_INT_VALUE_1, inputs = inputs, @@ -250,7 +250,7 @@ class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { fun testIntAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanOrEqualToRuleClassifier.matches( answer = POSITIVE_INT_VALUE_1, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProviderTest.kt index 97d152ce3e4..e1819859a89 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProviderTest.kt @@ -199,7 +199,7 @@ class NumericInputIsLessThanRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -216,7 +216,7 @@ class NumericInputIsLessThanRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -233,7 +233,7 @@ class NumericInputIsLessThanRuleClassifierProviderTest { fun testIntAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_INT_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanRuleClassifier.matches( answer = POSITIVE_INT_VALUE_3, inputs = inputs, @@ -250,7 +250,7 @@ class NumericInputIsLessThanRuleClassifierProviderTest { fun testIntAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanRuleClassifier.matches( answer = NEGATIVE_INT_VALUE_1, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProviderTest.kt index d5481c0ac89..710210dcc39 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProviderTest.kt @@ -393,7 +393,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { val inputs = mapOf( "tol" to POSITIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -411,7 +411,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { val inputs = mapOf( "x" to NEGATIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -430,7 +430,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "c" to NEGATIVE_REAL_VALUE_3_5, "tol" to POSITIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -449,7 +449,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "x" to NEGATIVE_REAL_VALUE_3_5, "c" to POSITIVE_REAL_VALUE_1_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -468,7 +468,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "x" to STRING_VALUE_1, "tol" to NEGATIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -486,7 +486,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { val inputs = mapOf( "tol" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -504,7 +504,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { val inputs = mapOf( "x" to POSITIVE_INT_VALUE_1 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -523,7 +523,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "c" to POSITIVE_INT_VALUE_1, "tol" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -542,7 +542,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "x" to POSITIVE_INT_VALUE_1, "c" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -561,7 +561,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "x" to STRING_VALUE_1, "tol" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_1, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt index 244cb981571..07945a20691 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt @@ -100,7 +100,7 @@ class RatioInputEqualsRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { equalsClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -119,7 +119,7 @@ class RatioInputEqualsRuleClassifierProviderTest { fun testAnswer_testRatio_missingInputX_throwsException() { val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { equalsClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt index 2cbb3b324a4..a8c1b27243c 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt @@ -82,7 +82,7 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasNumberOfTermsEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -101,7 +101,7 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { fun testAnswer_testRatio_missingInputY_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasNumberOfTermsEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasSpecificTermEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasSpecificTermEqualToRuleClassifierProviderTest.kt index 81968647149..14101f1d79e 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasSpecificTermEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasSpecificTermEqualToRuleClassifierProviderTest.kt @@ -198,7 +198,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { fun testAnswer_threeTerms_indexInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to STRING_VALUE, "y" to NON_NEGATIVE_VALUE_TEST_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -215,7 +215,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { fun testAnswer_threeTerms_valueInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_4, "y" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -232,7 +232,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { fun testAnswer_threeTerms_missingIndexInput_throwsException() { val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -249,7 +249,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { fun testAnswer_threeTerms_missingValueInput_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -264,7 +264,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { @Test fun testAnswer_threeTerms_missingBothInputs_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = mapOf(), diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt index c93b44f8dc2..09fdeb952bb 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt @@ -146,7 +146,7 @@ class RatioInputIsEquivalentRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEquivalentClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -165,7 +165,7 @@ class RatioInputIsEquivalentRuleClassifierProviderTest { fun testAnswer_testRatio_missingInputX_throwsException() { val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEquivalentClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputContainsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputContainsRuleClassifierProviderTest.kt index 6f4fc9013b1..1c258aec94e 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputContainsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputContainsRuleClassifierProviderTest.kt @@ -268,7 +268,7 @@ class TextInputContainsRuleClassifierProviderTest { fun testStringAnswer_missingInput_throwsException() { val inputs = mapOf("y" to STRING_VALUE_TEST_ANSWER_INPUT_SET) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsRuleClassifier.matches( answer = STRING_VALUE_TEST_ANSWER, inputs = inputs, @@ -285,7 +285,7 @@ class TextInputContainsRuleClassifierProviderTest { fun testStringAnswer_nonNegativeIntInput_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsRuleClassifier.matches( answer = STRING_VALUE_TEST_ANSWER, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt index 3b658cca5df..6c5c53471c2 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt @@ -210,7 +210,7 @@ class TextInputEqualsRuleClassifierProviderTest { fun testStringAnswer_missingInput_throwsException() { val inputs = mapOf("y" to STRING_VALUE_TEST_LOWERCASE_INPUT_SET) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = STRING_VALUE_TEST_LOWERCASE, inputs = inputs, @@ -227,7 +227,7 @@ class TextInputEqualsRuleClassifierProviderTest { fun testStringAnswer_nonNegativeIntInput_throwsException() { val inputs = mapOf("x" to INT_VALUE_TEST_NON_NEGATIVE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = STRING_VALUE_TEST_UPPERCASE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProviderTest.kt index 67c7874d515..3bb592d1499 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProviderTest.kt @@ -267,7 +267,7 @@ class TextInputFuzzyEqualsRuleClassifierProviderTest { fun testStringAnswer_nonNegativeIntInput_verifyThrowsException() { val inputs = mapOf("x" to NON_NEGATIVE_TEST_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputFuzzyEqualsRuleClassifier.matches( answer = STRING_VALUE_TEST_ANSWER_UPPERCASE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProviderTest.kt index c88983ed5fc..60ea011ad34 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProviderTest.kt @@ -292,7 +292,7 @@ class TextInputStartsWithRuleClassifierProviderTest { fun testStringAns_missingInput_throwsException() { val inputs = mapOf("y" to STRING_VALUE_TEST_STRING_LOWERCASE_INPUT_SET) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputStartsWithRuleClassifier.matches( answer = STRING_VALUE_TEST_STRING_LOWERCASE, inputs = inputs, @@ -309,7 +309,7 @@ class TextInputStartsWithRuleClassifierProviderTest { fun testStringAns_nonNegativeIntInput_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_TEST_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputStartsWithRuleClassifier.matches( answer = STRING_VALUE_TEST_STRING_LOWERCASE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt index 39414c42791..867da17b125 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt @@ -223,7 +223,7 @@ class ExplorationActiveTimeControllerTest { fun testStopTimer_beforeStarting_isFailure() { setUpTestApplicationComponent() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { stopExploration() } assertThat(exception) diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt index ed37c3bc9b8..fc2985ec84e 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt @@ -165,7 +165,7 @@ class ExplorationProgressControllerTest { @Test fun testGetCurrentState_noExploration_throwsException() { // Can't retrieve the current state until the play session is started. - assertThrows(UninitializedPropertyAccessException::class) { + assertThrows() { explorationProgressController.getCurrentState() } } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/testing/FakeExplorationRetrieverTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/testing/FakeExplorationRetrieverTest.kt index ae53ac8a2e0..6d8ed9c82fa 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/testing/FakeExplorationRetrieverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/testing/FakeExplorationRetrieverTest.kt @@ -58,7 +58,7 @@ class FakeExplorationRetrieverTest { @Test fun testLoadExploration_noProxySet_fakeExpId_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration("fake_id") } } @@ -83,7 +83,7 @@ class FakeExplorationRetrieverTest { expIdToLoad = TEST_EXPLORATION_ID_2, expIdToLoadInstead = "fake_id" ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration(TEST_EXPLORATION_ID_2) } } @@ -120,7 +120,7 @@ class FakeExplorationRetrieverTest { expIdToLoad = "fake_id", expIdToLoadInstead = "other_fake_id" ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration("fake_id") } } @@ -133,7 +133,7 @@ class FakeExplorationRetrieverTest { expIdToLoad = TEST_EXPLORATION_ID_2, expIdToLoadInstead = TEST_EXPLORATION_ID_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration("fake_id") } } @@ -175,7 +175,7 @@ class FakeExplorationRetrieverTest { ) fakeExplorationRetriever.clearExplorationProxy("fake_id") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration("fake_id") } } diff --git a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImplTest.kt b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImplTest.kt index faa4e98c9f2..c66cc01efe6 100644 --- a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImplTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImplTest.kt @@ -976,7 +976,7 @@ class HintHandlerProdImplTest { val state = expWithHintsAndSolution.getInitialState() hintHandler.startWatchingForHintsInNewStateSync(state) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewHintSync(hintIndex = 0) } @@ -1157,7 +1157,7 @@ class HintHandlerProdImplTest { hintHandler.startWatchingForHintsInNewStateSync(state) triggerAndRevealFirstHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewHintSync(hintIndex = 0) } @@ -1172,7 +1172,7 @@ class HintHandlerProdImplTest { triggerAndRevealFirstHint() triggerAndRevealSecondHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewHintSync(hintIndex = 0) } @@ -1188,7 +1188,7 @@ class HintHandlerProdImplTest { triggerAndRevealSecondHint() triggerAndRevealSolution() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewHintSync(hintIndex = 0) } @@ -1203,7 +1203,7 @@ class HintHandlerProdImplTest { val state = expWithHintsAndSolution.getInitialState() hintHandler.startWatchingForHintsInNewStateSync(state) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } @@ -1217,7 +1217,7 @@ class HintHandlerProdImplTest { hintHandler.startWatchingForHintsInNewStateSync(state) triggerFirstHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } @@ -1231,7 +1231,7 @@ class HintHandlerProdImplTest { hintHandler.startWatchingForHintsInNewStateSync(state) triggerAndRevealFirstHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } @@ -1247,7 +1247,7 @@ class HintHandlerProdImplTest { triggerAndRevealFirstHint() triggerAndRevealSecondHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } @@ -1344,7 +1344,7 @@ class HintHandlerProdImplTest { triggerAndRevealSecondHint() triggerAndRevealSolution() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } diff --git a/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt index 098fcde27de..30467ee6263 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt @@ -775,7 +775,7 @@ class LocaleControllerTest { @Test fun testSetAsDefault_customLocaleImpl_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { localeController.setAsDefault(mockDisplayLocale, Configuration()) } diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt index 6c30c8200d5..9e2178fc924 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt @@ -54,7 +54,6 @@ import org.robolectric.annotation.LooperMode import java.io.File import java.io.FileOutputStream import java.lang.IllegalStateException -import java.util.Random import javax.inject.Inject import javax.inject.Singleton @@ -79,17 +78,6 @@ class LoggingIdentifierControllerTest { setUpTestApplicationComponent() } - @Test - fun testCreateLearnerId_verifyCreatesCorrectRandomValue() { - val randomLearnerId = loggingIdentifierController.createLearnerId() - - val testLearnerId = machineLocale.run { - "%08x".formatForMachines(Random(TestLoggingIdentifierModule.applicationIdSeed).nextInt()) - } - assertThat(randomLearnerId).isEqualTo(testLearnerId) - assertThat(randomLearnerId.length).isEqualTo(8) - } - @Test fun testCreateLearnerId_twice_bothAreDifferent() { val learnerId1 = loggingIdentifierController.createLearnerId() @@ -106,7 +94,7 @@ class LoggingIdentifierControllerTest { val installationId = monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getInstallationId()) - assertThat(installationId).isEqualTo("bc1f80ab5d8c") + assertThat(installationId).isEqualTo("1d079efe67ee") assertThat(installationId.length).isEqualTo(12) } @@ -119,7 +107,7 @@ class LoggingIdentifierControllerTest { monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getInstallationId()) // The same value should return for the second instance of the controller. - assertThat(installationId).isEqualTo("bc1f80ab5d8c") + assertThat(installationId).isEqualTo("1d079efe67ee") } @Test @@ -137,7 +125,7 @@ class LoggingIdentifierControllerTest { fun testFetchInstallationId_initialAppState_returnsNewInstallationIdValue() { val installationId = fetchSuccessfulAsyncValue(loggingIdentifierController::fetchInstallationId) - assertThat(installationId).isEqualTo("bc1f80ab5d8c") + assertThat(installationId).isEqualTo("1d079efe67ee") assertThat(installationId?.length).isEqualTo(12) } @@ -149,7 +137,7 @@ class LoggingIdentifierControllerTest { val installationId = fetchSuccessfulAsyncValue(loggingIdentifierController::fetchInstallationId) // The same value should return for the second instance of the controller. - assertThat(installationId).isEqualTo("bc1f80ab5d8c") + assertThat(installationId).isEqualTo("1d079efe67ee") } @Test @@ -167,7 +155,7 @@ class LoggingIdentifierControllerTest { val sessionIdProvider = loggingIdentifierController.getSessionId() val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) - assertThat(sessionId).isEqualTo("1c46e9d5-5902-311a-bbba-a75973c3ccd2") + assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } @Test @@ -178,7 +166,7 @@ class LoggingIdentifierControllerTest { // The second call should return the same ID (since the ID doesn't automatically change). val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) - assertThat(sessionId).isEqualTo("1c46e9d5-5902-311a-bbba-a75973c3ccd2") + assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } @Test @@ -186,7 +174,7 @@ class LoggingIdentifierControllerTest { val sessionIdFlow = loggingIdentifierController.getSessionIdFlow() val sessionId = sessionIdFlow.waitForLatestValue() - assertThat(sessionId).isEqualTo("1c46e9d5-5902-311a-bbba-a75973c3ccd2") + assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } @Test @@ -197,7 +185,7 @@ class LoggingIdentifierControllerTest { // The second call should return the same ID (since the ID doesn't automatically change). val sessionId = sessionIdFlow.waitForLatestValue() - assertThat(sessionId).isEqualTo("1c46e9d5-5902-311a-bbba-a75973c3ccd2") + assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } @Test @@ -209,7 +197,7 @@ class LoggingIdentifierControllerTest { // The session ID should be changed since updateSessionId() was called. val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) - assertThat(sessionId).isEqualTo("8808493e-6576-3e26-9cbf-d1008051b253") + assertThat(sessionId).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } @Test @@ -223,7 +211,7 @@ class LoggingIdentifierControllerTest { // The existing provider should've been notified of the changed session ID. val sessionId = monitor.ensureNextResultIsSuccess() - assertThat(sessionId).isEqualTo("8808493e-6576-3e26-9cbf-d1008051b253") + assertThat(sessionId).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } @Test @@ -238,7 +226,7 @@ class LoggingIdentifierControllerTest { // The session ID should be changed yet again due to updateSessionId() being called twice. val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) - assertThat(sessionId).isEqualTo("8aeabb00-af70-39e4-89b3-c47c9900ec4f") + assertThat(sessionId).isEqualTo("8cbd31f7-bb52-3129-9fac-78dcb5cb857a") } @Test @@ -250,7 +238,7 @@ class LoggingIdentifierControllerTest { // The session ID should be changed since updateSessionId() was called. val sessionId = sessionIdFlow.waitForLatestValue() - assertThat(sessionId).isEqualTo("8808493e-6576-3e26-9cbf-d1008051b253") + assertThat(sessionId).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } @Test @@ -262,7 +250,7 @@ class LoggingIdentifierControllerTest { testCoroutineDispatchers.runCurrent() // The current value of the exist flow should be changed now since the session ID was updated. - assertThat(sessionIdFlow.value).isEqualTo("8808493e-6576-3e26-9cbf-d1008051b253") + assertThat(sessionIdFlow.value).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } private fun writeFileCache(cacheName: String, value: T) { diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterTest.kt index 1641eb00223..adf3376b77d 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterTest.kt @@ -426,7 +426,7 @@ class CpuPerformanceSnapshotterTest { @Test fun testSnapshotter_initializeOnce_initializeAgain_throwsErrorOnReinitialization() { cpuPerformanceSnapshotter.initialiseSnapshotter() - val exception = assertThrows(IllegalArgumentException::class) { + val exception = assertThrows() { cpuPerformanceSnapshotter.initialiseSnapshotter() } diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt index 462dd3f04ad..3cc8a0e848a 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt @@ -86,7 +86,7 @@ class LearnerAnalyticsLoggerTest { private const val TEST_STORY_ID = "test_story_id" private const val TEST_EXP_5_STATE_THREE_NAME = "NumericExpressionInput.IsEquivalentTo" private const val TEST_EXP_5_STATE_FOUR_NAME = "AlgebraicExpressionInput.MatchesExactlyWith" - private const val DEFAULT_INITIAL_SESSION_ID = "e6eacc69-e636-3c90-ba29-32bf3dd17161" + private const val DEFAULT_INITIAL_SESSION_ID = "ab4532d6-476c-3727-bc5a-ad84e5dae60f" } @Inject diff --git a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt index 62733f8119c..6d782dbc3bc 100644 --- a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt @@ -156,7 +156,7 @@ class ProfileManagementControllerTest { val profileDatabase = readProfileDatabase() val profile = profileDatabase.profilesMap[0]!! - assertThat(profile.learnerId).isEqualTo("bb1ad573") + assertThat(profile.learnerId).isEqualTo("26504347") } @Test @@ -255,7 +255,7 @@ class ProfileManagementControllerTest { val profileProvider = profileManagementController.getProfile(profileId) val profile = monitorFactory.waitForNextSuccessfulResult(profileProvider) - assertThat(profile.learnerId).isEqualTo("68fb0e6f") + assertThat(profile.learnerId).isEqualTo("a625db55") } @Test @@ -430,7 +430,7 @@ class ProfileManagementControllerTest { val learnerId = fetchSuccessfulAsyncValue(profileManagementController::fetchCurrentLearnerId) - assertThat(learnerId).isEqualTo("19b89cd8") + assertThat(learnerId).isEqualTo("02308fa0") } @Test @@ -465,7 +465,7 @@ class ProfileManagementControllerTest { profileManagementController.fetchLearnerId(PROFILE_ID_2) } - assertThat(learnerId).isEqualTo("68fb0e6f") + assertThat(learnerId).isEqualTo("a625db55") } @Test diff --git a/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt index f5aad0432a1..0c686230064 100644 --- a/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt @@ -134,7 +134,7 @@ class QuestionAssessmentProgressControllerTest { setUpTestApplicationWithSeed(questionSeed = 0) // Can't retrieve the current question until the training session is started. - assertThrows(UninitializedPropertyAccessException::class) { + assertThrows() { questionAssessmentProgressController.getCurrentQuestion() } } diff --git a/model/src/main/proto/BUILD.bazel b/model/src/main/proto/BUILD.bazel index a168e981191..e512512b10f 100644 --- a/model/src/main/proto/BUILD.bazel +++ b/model/src/main/proto/BUILD.bazel @@ -273,7 +273,10 @@ java_lite_proto_library( oppia_proto_library( name = "feedback_reporting_proto", srcs = ["feedback_reporting.proto"], - deps = [":profile_proto"], + deps = [ + ":languages_proto", + ":profile_proto", + ], ) java_lite_proto_library( diff --git a/scripts/src/java/org/oppia/android/scripts/testing/TestGitRepository.kt b/scripts/src/java/org/oppia/android/scripts/testing/TestGitRepository.kt index 61d5c055992..2de94e3fc1f 100644 --- a/scripts/src/java/org/oppia/android/scripts/testing/TestGitRepository.kt +++ b/scripts/src/java/org/oppia/android/scripts/testing/TestGitRepository.kt @@ -19,20 +19,29 @@ class TestGitRepository( private val commandExecutor: CommandExecutor ) { private val rootDirectory by lazy { temporaryRootFolder.root } + private val gitDirectory: File get() = File(rootDirectory, ".git") + private val userEmail: String? + get() = maybeExecuteGitCommand("config", "--local", "--get", "user.email")?.joinOutput()?.trim() + private val userName: String? + get() = maybeExecuteGitCommand("config", "--local", "--get", "user.name")?.joinOutput()?.trim() /** Creates the repository using git init. */ fun init() { + verifyNotInGitRepository() executeSuccessfulGitCommand("init") } /** Sets the user's [email] and [name] using git config. */ fun setUser(email: String, name: String) { - executeSuccessfulGitCommand("config", "user.email", email) - executeSuccessfulGitCommand("config", "user.name", name) + verifyInGitRepository() + verifyUserIsNotSet() + executeSuccessfulGitCommand("config", "--local", "user.email", email) + executeSuccessfulGitCommand("config", "--local", "user.name", name) } /** Creates a new branch with the specified name, and switches to it. */ fun checkoutNewBranch(branchName: String) { + verifyInGitRepository() executeSuccessfulGitCommand("checkout", "-b", branchName) } @@ -42,6 +51,7 @@ class TestGitRepository( * This does not perform a commit. See [commit] for actually committing the change. */ fun stageFileForCommit(file: File) { + verifyInGitRepository() executeSuccessfulGitCommand("add", file.toRelativeString(rootDirectory)) } @@ -57,6 +67,7 @@ class TestGitRepository( * This does not perform a commit. See [commit] for actually committing the change. */ fun removeFileForCommit(file: File) { + verifyInGitRepository() executeSuccessfulGitCommand("rm", file.toRelativeString(rootDirectory)) } @@ -67,6 +78,7 @@ class TestGitRepository( * This does not perform a commit. See [commit] for actually committing the change. */ fun moveFileForCommit(oldFile: File, newFile: File) { + verifyInGitRepository() executeSuccessfulGitCommand( "mv", oldFile.toRelativeString(rootDirectory), @@ -81,25 +93,59 @@ class TestGitRepository( * @param allowEmpty whether to allow empty commits (i.e. committing with no staged files) */ fun commit(message: String, allowEmpty: Boolean = false) { + verifyInGitRepository() + verifyUserIsSet() val arguments = mutableListOf("commit", "-m", message) if (allowEmpty) arguments += "--allow-empty" executeSuccessfulGitCommand(*arguments.toTypedArray()) } /** Returns the result of git status. */ - fun status(): String { - return commandExecutor.executeCommand(rootDirectory, "git", "status").output.joinOutputString() + fun status(checkForGitRepository: Boolean = true): String { + if (checkForGitRepository) verifyInGitRepository() + return executeGitCommand("status").joinOutput() } - private fun executeSuccessfulGitCommand(vararg arguments: String) { - verifySuccessfulCommand(commandExecutor.executeCommand(rootDirectory, "git", *arguments)) - } + private fun executeGitCommand(vararg arguments: String): CommandResult = + commandExecutor.executeCommand(rootDirectory, "git", *arguments) + + private fun maybeExecuteGitCommand(vararg arguments: String): CommandResult? = + executeGitCommand(*arguments).takeIf { it.exitCode == 0 } + + private fun executeSuccessfulGitCommand(vararg arguments: String) = + verifySuccessfulCommand(executeGitCommand(*arguments)) private fun verifySuccessfulCommand(result: CommandResult) { - assertWithMessage("Output: ${result.output.joinOutputString()}") + assertWithMessage("Output: ${result.joinOutput()}") .that(result.exitCode) .isEqualTo(0) } - private fun List.joinOutputString(): String = joinToString(separator = "\n") { " $it" } + private fun verifyInGitRepository() { + failUnless(gitDirectory.exists()) { "Not operating in an initialized Git repository." } + } + + private fun verifyNotInGitRepository() { + failUnless(!gitDirectory.exists()) { "Git repository is already initialized." } + } + + private fun verifyUserIsNotSet() { + verifyIsNotSet(name = "User email", userEmail) + verifyIsNotSet(name = "User name", userName) + } + + private fun verifyUserIsSet() { + failUnless(userEmail != null) { "User email has not yet been set." } + failUnless(userName != null) { "User name has not yet been set." } + } + + private fun verifyIsNotSet(name: String, value: String?) { + failUnless(value == null) { "$name has already been set: $value." } + } + + private fun failUnless(condition: Boolean, lazyMessage: () -> String) { + if (!condition) throw AssertionError(lazyMessage()) + } + + private fun CommandResult.joinOutput(): String = output.joinToString(separator = "\n") { " $it" } } diff --git a/scripts/src/javatests/org/oppia/android/scripts/build/FilterPerLanguageResourcesTest.kt b/scripts/src/javatests/org/oppia/android/scripts/build/FilterPerLanguageResourcesTest.kt index 8c217740d10..511b07f37e9 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/build/FilterPerLanguageResourcesTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/build/FilterPerLanguageResourcesTest.kt @@ -86,21 +86,21 @@ class FilterPerLanguageResourcesTest { @Test fun testUtility_noArgs_failsWithUsageString() { - val error = assertThrows(IllegalArgumentException::class) { runScript() } + val error = assertThrows() { runScript() } assertThat(error).hasMessageThat().contains(USAGE_STRING) } @Test fun testUtility_oneArg_failsWithUsageString() { - val error = assertThrows(IllegalArgumentException::class) { runScript("first_file.zip") } + val error = assertThrows() { runScript("first_file.zip") } assertThat(error).hasMessageThat().contains(USAGE_STRING) } @Test fun testUtility_threeArgs_failsWithUsageString() { - val error = assertThrows(IllegalArgumentException::class) { + val error = assertThrows() { runScript( tempFolder.getFilePath("input.zip"), tempFolder.getFilePath("output.zip"), "extra_param" ) @@ -114,7 +114,7 @@ class FilterPerLanguageResourcesTest { // Create an empty zip file. ZipOutputStream(File(tempFolder.root, "input.zip").outputStream()).close() - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { runScript(tempFolder.getFilePath("input.zip"), tempFolder.getFilePath("output.zip")) } @@ -129,7 +129,7 @@ class FilterPerLanguageResourcesTest { ResourceTable.getDefaultInstance().writeTo(outputStream) } - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { runScript(tempFolder.getFilePath("input.zip"), tempFolder.getFilePath("output.zip")) } @@ -147,7 +147,7 @@ class FilterPerLanguageResourcesTest { supportedLanguages = SUPPORTED_LANGUAGES_EN ) - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { runScript(tempFolder.getFilePath("input.zip"), tempFolder.getFilePath("output.zip")) } diff --git a/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt b/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt index 424d22b661f..5d197b04615 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt @@ -70,7 +70,7 @@ class TransformAndroidManifestTest { fun testUtility_noArgs_failsWithUsageString() { initializeEmptyGitRepository() - val exception = assertThrows(IllegalStateException::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(USAGE_STRING) } @@ -79,7 +79,7 @@ class TransformAndroidManifestTest { fun testUtility_oneArg_failsWithUsageString() { initializeEmptyGitRepository() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } @@ -91,7 +91,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript(tempFolder.root.absolutePath, manifestFile.absolutePath) } @@ -103,7 +103,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -119,7 +119,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -136,7 +136,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -154,7 +154,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -173,7 +173,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -193,7 +193,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -214,7 +214,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -236,7 +236,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -258,7 +258,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -280,7 +280,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( "nowhere", manifestFile.absolutePath, @@ -301,7 +301,7 @@ class TransformAndroidManifestTest { fun testUtility_allArgs_manifestDoesNotExist_failsWithError() { initializeEmptyGitRepository() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, "fake_manifest_file", @@ -325,7 +325,7 @@ class TransformAndroidManifestTest { writeText(TEST_MANIFEST_CONTENT_WITHOUT_VERSIONS_AND_APPLICATION) } - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel index cb9eafb6d21..3160447f15f 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel @@ -8,7 +8,7 @@ kt_jvm_test( name = "ComputeAffectedTestsTest", size = "large", srcs = ["ComputeAffectedTestsTest.kt"], - shard_count = 4, + shard_count = 8, deps = [ "//scripts/src/java/org/oppia/android/scripts/ci:compute_affected_tests_lib", "//scripts/src/java/org/oppia/android/scripts/common:proto_string_encoder", diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt index 654e42425c8..5bbdc432d62 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt @@ -57,12 +57,12 @@ class ComputeAffectedTestsTest { // Print the status of the git repository to help with debugging in the cases of test failures // and to help manually verify the expect git state at the end of each test. println("git status (at end of test):") - println(testGitRepository.status()) + println(testGitRepository.status(checkForGitRepository = false)) } @Test fun testUtility_noArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { main(arrayOf()) } + val exception = assertThrows() { main(arrayOf()) } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -72,7 +72,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_oneArgument_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { main(arrayOf("first")) } + val exception = assertThrows() { main(arrayOf("first")) } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -82,7 +82,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_twoArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { main(arrayOf("first", "second")) } + val exception = assertThrows() { main(arrayOf("first", "second")) } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -92,7 +92,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_threeArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { + val exception = assertThrows() { main(arrayOf("first", "second", "third")) } @@ -104,7 +104,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_directoryRootDoesNotExist_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { main(arrayOf("fake", "alsofake", "andstillfake", "compute_all_tests=false")) } @@ -113,7 +113,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_invalid_lastArgument_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { main(arrayOf("fake", "alsofake", "andstillfake", "compute_all_testss=false")) } @@ -123,7 +123,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_invalid_lastArgumentValue_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { main(arrayOf("fake", "alsofake", "andstillfake", "compute_all_tests=blah")) } @@ -133,7 +133,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_emptyDirectory_throwsException() { - val exception = assertThrows(IllegalStateException::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains("run from the workspace's root directory") } diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/RetrieveAffectedTestsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/ci/RetrieveAffectedTestsTest.kt index d43a7055f51..e449b856a6f 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/RetrieveAffectedTestsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/RetrieveAffectedTestsTest.kt @@ -45,7 +45,7 @@ class RetrieveAffectedTestsTest { @Test fun testUtility_noArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { runScript() } + val exception = assertThrows() { runScript() } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -55,7 +55,7 @@ class RetrieveAffectedTestsTest { @Test fun testUtility_oneArgument_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { runScript("arg1") } + val exception = assertThrows() { runScript("arg1") } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -65,7 +65,7 @@ class RetrieveAffectedTestsTest { @Test fun testUtility_twoArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { runScript("arg1", "arg2") } + val exception = assertThrows() { runScript("arg1", "arg2") } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -75,7 +75,7 @@ class RetrieveAffectedTestsTest { @Test fun testUtility_invalidBase64_throwsException() { - assertThrows(IllegalArgumentException::class) { runScript("badbase64", "file1", "file2") } + assertThrows() { runScript("badbase64", "file1", "file2") } } @Test diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel index e47fc741ab6..bceb5cfe864 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel @@ -8,6 +8,7 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_test") kt_jvm_test( name = "BazelClientTest", srcs = ["BazelClientTest.kt"], + shard_count = 4, deps = [ "//scripts/src/java/org/oppia/android/scripts/common:bazel_client", "//scripts/src/java/org/oppia/android/scripts/testing:test_bazel_workspace", diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt index f2e7914682c..07aa4d4134c 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt @@ -48,7 +48,7 @@ class BazelClientTest { fun testRetrieveTestTargets_emptyFolder_fails() { val bazelClient = BazelClient(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { bazelClient.retrieveAllTestTargets() } @@ -62,7 +62,7 @@ class BazelClientTest { val bazelClient = BazelClient(tempFolder.root) testBazelWorkspace.initEmptyWorkspace() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { bazelClient.retrieveAllTestTargets() } diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt index e04c0954b85..78dc945dff6 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt @@ -37,7 +37,7 @@ class CommandExecutorImplTest { fun testExecute_echo_invalidDirectory_throwsException() { val commandExecutor = CommandExecutorImpl() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { commandExecutor.executeCommand(File("invaliddirectory"), "echo", "value") } @@ -53,7 +53,7 @@ class CommandExecutorImplTest { // Produce a large output so that echo takes a bit longer to reduce the likelihood of this test // flaking on faster machines. val largeOutput = "a".repeat(100_000) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { commandExecutor.executeCommand(tempFolder.root, "echo", largeOutput) } @@ -65,7 +65,7 @@ class CommandExecutorImplTest { fun testExecute_nonexistentCommand_throwsException() { val commandExecutor = CommandExecutorImpl() - val exception = assertThrows(IOException::class) { + val exception = assertThrows() { commandExecutor.executeCommand(tempFolder.root, "commanddoesnotexist") } diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt index 9362d7dd006..5cbda509373 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt @@ -37,14 +37,14 @@ class GitClientTest { // Print the status of the git repository to help with debugging in the cases of test failures // and to help manually verify the expect git state at the end of each test. println("git status (at end of test):") - println(testGitRepository.status()) + println(testGitRepository.status(checkForGitRepository = false)) } @Test fun testCurrentCommit_forNonRepository_throwsException() { val gitClient = GitClient(tempFolder.root, "develop") - val exception = assertThrows(IllegalStateException::class) { gitClient.currentCommit } + val exception = assertThrows() { gitClient.currentCommit } assertThat(exception).hasMessageThat().contains("Expected non-zero exit code") assertThat(exception).hasMessageThat().ignoringCase().contains("not a git repository") @@ -80,7 +80,7 @@ class GitClientTest { fun testCurrentBranch_forNonRepository_throwsException() { val gitClient = GitClient(tempFolder.root, "develop") - val exception = assertThrows(IllegalStateException::class) { gitClient.currentBranch } + val exception = assertThrows() { gitClient.currentBranch } assertThat(exception).hasMessageThat().contains("Expected non-zero exit code") assertThat(exception).hasMessageThat().ignoringCase().contains("not a git repository") diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/ProtoStringEncoderTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/ProtoStringEncoderTest.kt index b03c106500a..bed9db19a1b 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/ProtoStringEncoderTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/ProtoStringEncoderTest.kt @@ -34,14 +34,14 @@ class ProtoStringEncoderTest { @Test fun testDecode_emptyString_throwsException() { - assertThrows(EOFException::class) { + assertThrows() { TestMessage.getDefaultInstance().mergeFromCompressedBase64(base64 = "") } } @Test fun testDecode_badString_throwsException() { - assertThrows(ZipException::class) { + assertThrows() { TestMessage.getDefaultInstance().mergeFromCompressedBase64(base64 = "asdf") } } diff --git a/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt index 9a7b61faa6a..58b99cf4db5 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt @@ -281,7 +281,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -357,7 +357,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -387,7 +387,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -416,7 +416,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -442,7 +442,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -468,7 +468,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -495,7 +495,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -522,7 +522,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -550,7 +550,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -577,7 +577,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -604,7 +604,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -632,7 +632,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -668,7 +668,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -709,7 +709,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -755,7 +755,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -800,7 +800,7 @@ class KdocValidityCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -879,7 +879,7 @@ class KdocValidityCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -913,7 +913,7 @@ class KdocValidityCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } diff --git a/scripts/src/javatests/org/oppia/android/scripts/label/AccessibilityLabelCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/label/AccessibilityLabelCheckTest.kt index a1410b3ead2..900140e93f7 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/label/AccessibilityLabelCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/label/AccessibilityLabelCheckTest.kt @@ -92,7 +92,7 @@ class AccessibilityLabelCheckTest { val manifestFile = tempFolder.newFile("testfiles/$tempFileRelativePath") manifestFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -134,7 +134,7 @@ class AccessibilityLabelCheckTest { val manifestFile = tempFolder.newFile("testfiles/$tempFileRelativePath") manifestFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -244,7 +244,7 @@ class AccessibilityLabelCheckTest { appManifestFile.writeText(testContent1) splashManifestFile.writeText(testContent2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -308,7 +308,7 @@ class AccessibilityLabelCheckTest { appManifestFile.writeText(testContent1) splashManifestFile.writeText(testContent2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -393,7 +393,7 @@ class AccessibilityLabelCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -436,7 +436,7 @@ class AccessibilityLabelCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/LicenseTextsCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/license/LicenseTextsCheckTest.kt index 8a70436c6c7..baf034a9095 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/LicenseTextsCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/license/LicenseTextsCheckTest.kt @@ -41,7 +41,7 @@ class LicenseTextsCheckTest { val thirdPartyDepsXmlFile = tempFolder.newFile("values/third_party_dependencies.xml") thirdPartyDepsXmlFile.writeText(WARNING_COMMENT) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(arrayOf()) } @@ -53,7 +53,7 @@ class LicenseTextsCheckTest { val thirdPartyDepsXmlFile = tempFolder.newFile("values/third_party_dependencies.xml") thirdPartyDepsXmlFile.writeText("") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(arrayOf("${tempFolder.root}/values/third_party_dependencies.xml")) } @@ -72,7 +72,7 @@ class LicenseTextsCheckTest { """.trimIndent() ) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(arrayOf("${tempFolder.root}/values/third_party_dependencies.xml")) } @@ -110,7 +110,7 @@ class LicenseTextsCheckTest { @Test fun testLicenseTexsCheck_xmlFileNotPresent_checkFailsWithFileNotFoundException() { val pathToThirdPartyDepsXml = "${tempFolder.root}/values/third_party_dependencies.xml" - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(arrayOf("${tempFolder.root}/values/third_party_dependencies.xml")) } diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt index f30b261f53a..5fdc807e3db 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt @@ -110,7 +110,7 @@ class MavenDependenciesListCheckTest { val coordsList = listOf(DATA_BINDING_DEP, FIREBASE_ANALYTICS_DEP) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -186,7 +186,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -250,7 +250,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -326,7 +326,7 @@ class MavenDependenciesListCheckTest { val coordsList = listOf(GLIDE_DEP) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -405,7 +405,7 @@ class MavenDependenciesListCheckTest { val coordsList = listOf(GLIDE_DEP) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -481,7 +481,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -559,7 +559,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironmentWithUpdatedFirebaseDependency(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -637,7 +637,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -770,7 +770,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -819,7 +819,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -874,7 +874,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt b/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt index 6d63a6e9c6d..4507d76a5dc 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt @@ -96,7 +96,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_SCRAPABLE_LICENSE, DEP_WITH_DIRECT_LINK_ONLY_LICENSE) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -180,7 +180,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -204,7 +204,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_DIRECT_LINK_ONLY_LICENSE) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -246,7 +246,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_SCRAPABLE_AND_EXTRACTED_COPY_LICENSES) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -313,7 +313,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_INVALID_LINKS) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -355,7 +355,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_NO_LICENSE) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -614,7 +614,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -790,7 +790,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -915,7 +915,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -1028,7 +1028,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/RetrieveLicenseTextsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/maven/RetrieveLicenseTextsTest.kt index 6be3f9c0d71..d889d6ede2b 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/RetrieveLicenseTextsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/RetrieveLicenseTextsTest.kt @@ -63,7 +63,7 @@ class RetrieveLicenseTextsTest { @Test fun testScript_oneArgument_printsUsageStringAndThrowsException() { - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main(arrayOf()) } @@ -73,7 +73,7 @@ class RetrieveLicenseTextsTest { @Test fun testScript_oneArguments_printsUsageStringAndThrowsException() { - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main( arrayOf( "${tempFolder.root}/values" @@ -92,7 +92,7 @@ class RetrieveLicenseTextsTest { val pbFile = tempFolder.newFile("scripts/assets/maven_dependencies.pb") pbFile.outputStream().use { mavenDependencyList.writeTo(it) } - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main( arrayOf( "${tempFolder.root}/values", @@ -111,7 +111,7 @@ class RetrieveLicenseTextsTest { val pbFile = tempFolder.newFile("scripts/assets/maven_dependencies.pb") pbFile.outputStream().use { mavenDependencyList.writeTo(it) } - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main( arrayOf( "${tempFolder.root}/values", @@ -141,7 +141,7 @@ class RetrieveLicenseTextsTest { val pbFile = tempFolder.newFile("scripts/assets/maven_dependencies.pb") pbFile.outputStream().use { mavenDependencyList.writeTo(it) } - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main( arrayOf( "${tempFolder.root}/values", diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index ae1d4fa60ff..39550f0f8ae 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -257,7 +257,7 @@ class RegexPatternValidationCheckTest { val tempFile = tempFolder.newFile("testfiles/data/src/main/TestActivity.kt") tempFile.writeText(requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -287,7 +287,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFolder("testfiles", "app", "src", "main", "res", "values", "subdir") tempFolder.newFile("testfiles/app/src/main/res/values/subdir/strings.xml") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -307,7 +307,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFolder("testfiles", "domain", "src", "main", "res", "drawable", "subdir") tempFolder.newFile("testfiles/domain/src/main/res/drawable/subdir/example.png") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -337,7 +337,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -357,7 +357,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -377,7 +377,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -397,7 +397,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -417,7 +417,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -437,7 +437,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -457,7 +457,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -477,7 +477,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -497,7 +497,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -517,7 +517,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -537,7 +537,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -557,7 +557,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -577,7 +577,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -597,7 +597,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -617,7 +617,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -637,7 +637,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -657,7 +657,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -677,7 +677,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -697,7 +697,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -717,7 +717,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -737,7 +737,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -757,7 +757,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -777,7 +777,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -797,7 +797,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -817,7 +817,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -837,7 +837,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -857,7 +857,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -877,7 +877,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -897,7 +897,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -917,7 +917,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -937,7 +937,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -957,7 +957,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -977,7 +977,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -997,7 +997,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1018,7 +1018,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1039,7 +1039,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1072,7 +1072,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/untranslated_strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1093,7 +1093,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/untranslated_strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1114,7 +1114,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1135,7 +1135,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1207,7 +1207,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1250,7 +1250,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.java" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1285,7 +1285,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1317,7 +1317,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1345,7 +1345,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1370,7 +1370,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1400,7 +1400,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1443,7 +1443,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1465,7 +1465,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1487,7 +1487,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1508,7 +1508,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeDialogFragment.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1541,7 +1541,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1571,7 +1571,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1601,7 +1601,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1622,7 +1622,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1643,7 +1643,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1669,7 +1669,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1692,7 +1692,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1713,7 +1713,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1745,7 +1745,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = "test_layout.xml" tempFolder.newFile("testfiles/$fileContainsSupportLibraryImport").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1774,7 +1774,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/test/SomeTest.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1796,7 +1796,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1817,7 +1817,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/BUILD" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1838,7 +1838,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/BUILD.bazel" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1859,7 +1859,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1881,7 +1881,7 @@ class RegexPatternValidationCheckTest { val prohibitedFile = tempFolder.newFile("testfiles/data/src/main/TestActivity.kt") prohibitedFile.writeText(prohibitedContent + requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1914,7 +1914,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1964,7 +1964,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2012,7 +2012,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2059,7 +2059,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2123,7 +2123,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2171,7 +2171,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2218,7 +2218,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2263,7 +2263,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2311,7 +2311,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/layout/test_layout.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2381,7 +2381,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFile("testfiles/$stringFilePath5").writeText(prohibitedContent) tempFolder.newFile("testfiles/$stringFilePath6").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2438,7 +2438,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2460,7 +2460,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/activity/HomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2492,7 +2492,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/activity/HomeActivityTest.kt" tempFolder.newFile("testfiles/$stringFilePath") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2528,7 +2528,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/SomeInitializer.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2553,7 +2553,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2578,7 +2578,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2603,7 +2603,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2633,7 +2633,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2657,7 +2657,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2682,7 +2682,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2720,7 +2720,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } // Two patterns are combined in this check because they slightly overlap in affected cases (e.g. // line 2 fails due to three different checks), and one pattern is subequently needed for the @@ -2752,7 +2752,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2782,7 +2782,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2807,7 +2807,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } // 'Punctuation' currently assumes a period. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) diff --git a/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt index a0fc700b720..3c22ca1ac31 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt @@ -52,7 +52,7 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile1Test.kt") tempFolder.newFile("testfiles/ProdFile2.kt") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -73,7 +73,7 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile2.kt") tempFolder.newFile("testfiles/ProdFile3.kt") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -95,7 +95,7 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile3.kt") tempFolder.newFile("testfiles/ProdFile2.kt") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } diff --git a/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt index 9bec557f4ac..00cbba1f19c 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt @@ -59,7 +59,7 @@ class TestBazelWorkspaceTest { // Verify that when initializing an empty workspace fails, an AssertionError is thrown (which // would fail for calling tests). - assertThrows(AssertionError::class) { testBazelWorkspace.initEmptyWorkspace() } + assertThrows() { testBazelWorkspace.initEmptyWorkspace() } } @Test @@ -215,7 +215,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTestOther.kt") @@ -492,7 +492,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.createTest(testName = "FirstTest") } @@ -786,7 +786,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "FirstLib") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.createLibrary(dependencyName = "FirstLib") } @@ -822,7 +822,7 @@ class TestBazelWorkspaceTest { val testBazelWorkspace = TestBazelWorkspace(tempFolder) // A non-existent test file cannot be retrieved. - assertThrows(NoSuchElementException::class) { + assertThrows() { testBazelWorkspace.retrieveTestFile(testName = "Invalid") } } @@ -844,7 +844,7 @@ class TestBazelWorkspaceTest { val testBazelWorkspace = TestBazelWorkspace(tempFolder) // A non-existent library file cannot be retrieved. - assertThrows(NoSuchElementException::class) { + assertThrows() { testBazelWorkspace.retrieveLibraryFile(dependencyName = "Invalid") } } @@ -865,7 +865,7 @@ class TestBazelWorkspaceTest { fun testRetrieveTestDependencyFile_noTest_throwsExceptionWithHelpfulMessage() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.retrieveTestDependencyFile(testName = "Invalid") } @@ -878,7 +878,7 @@ class TestBazelWorkspaceTest { val testBazelWorkspace = TestBazelWorkspace(tempFolder) testBazelWorkspace.createTest("ValidWithoutDep") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.retrieveTestDependencyFile(testName = "ValidWithoutDep") } diff --git a/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt index 59aa28bdc84..453f17da044 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt @@ -59,11 +59,11 @@ class TestGitRepositoryTest { fun testSetUser_noGitRepository_throwsAssertionError() { val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.setUser(email = "test@oppia.org", name = "Test User") } - assertThat(error).hasMessageThat().contains("not in a git directory") + assertThat(error).hasMessageThat().contains("Not operating in an initialized Git repository.") } @Test @@ -92,11 +92,11 @@ class TestGitRepositoryTest { fun testCheckOutNewBranch_notGitRepository_throwsAssertionError() { val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.checkoutNewBranch("develop") } - assertThat(error).hasMessageThat().ignoringCase().contains("not a git repository") + assertThat(error).hasMessageThat().contains("Not operating in an initialized Git repository.") } @Test @@ -116,7 +116,7 @@ class TestGitRepositoryTest { testGitRepository.init() testGitRepository.checkoutNewBranch("develop") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.stageFileForCommit(File(tempFolder.root, "fake_file")) } @@ -188,7 +188,7 @@ class TestGitRepositoryTest { testGitRepository.init() testGitRepository.checkoutNewBranch("develop") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.stageFilesForCommit( listOf( tempFolder.newFile("new_file1"), @@ -207,7 +207,7 @@ class TestGitRepositoryTest { testGitRepository.init() testGitRepository.checkoutNewBranch("develop") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.removeFileForCommit(File(tempFolder.root, "nonexistent_file")) } @@ -221,7 +221,7 @@ class TestGitRepositoryTest { testGitRepository.checkoutNewBranch("develop") tempFolder.newFile("untracked_file") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.removeFileForCommit(File(tempFolder.root, "untracked_file")) } @@ -250,7 +250,7 @@ class TestGitRepositoryTest { testGitRepository.init() testGitRepository.checkoutNewBranch("develop") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.moveFileForCommit( File(tempFolder.root, "nonexistent_file"), File(tempFolder.root, "new_file") ) @@ -266,7 +266,7 @@ class TestGitRepositoryTest { testGitRepository.checkoutNewBranch("develop") tempFolder.newFile("untracked_file") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.moveFileForCommit( File(tempFolder.root, "untracked_file"), File(tempFolder.root, "new_file") ) @@ -304,11 +304,9 @@ class TestGitRepositoryTest { testGitRepository.checkoutNewBranch("develop") testGitRepository.stageFileForCommit(tempFolder.newFile("file_to_be_committed")) - val error = assertThrows(AssertionError::class) { - testGitRepository.commit("Commit new file.") - } + val error = assertThrows { testGitRepository.commit("Commit new file.") } - assertThat(error).hasMessageThat().contains("Please tell me who you are") + assertThat(error).hasMessageThat().contains("User email has not yet been set.") } @Test @@ -318,7 +316,7 @@ class TestGitRepositoryTest { testGitRepository.checkoutNewBranch("develop") testGitRepository.setUser(email = "test@oppia.org", name = "Test User") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.commit("Attempting empty commit.", allowEmpty = false) } @@ -357,14 +355,34 @@ class TestGitRepositoryTest { } @Test - fun testStatus_noGitRepository_hasStatusWithError() { + fun testStatus_noGitRepository_doNotCheckForRepository_hasStatusWithError() { val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) - val status = testGitRepository.status() + val status = testGitRepository.status(checkForGitRepository = false) assertThat(status).ignoringCase().contains("not a git repository") } + @Test + fun testStatus_noGitRepository_checkForRepository_throwsAssertionError() { + val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) + + val error = assertThrows() { + testGitRepository.status(checkForGitRepository = true) + } + + assertThat(error).hasMessageThat().contains("Not operating in an initialized Git repository.") + } + + @Test + fun testStatus_noGitRepository_defaultCheckForRepository_throwsAssertionError() { + val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) + + val error = assertThrows() { testGitRepository.status() } + + assertThat(error).hasMessageThat().contains("Not operating in an initialized Git repository.") + } + @Test fun testStatus_onBranch_nothingStaged_statusEmpty() { val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueCommentCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueCommentCheckTest.kt index 6c4d5fb8a8c..2d33e0e2a60 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueCommentCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueCommentCheckTest.kt @@ -51,7 +51,7 @@ class TodoIssueCommentCheckTest { latestCommentFile.writeText(latestCommentContent) scriptFailureCommentFile.writeText(scriptFailureCommentContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(tempFolder.root.toString(), "latest_comment.txt", "script_failures.txt") } assertThat(exception).hasMessageThat().contains("NEW COMMENT SHOULD BE POSTED") @@ -80,7 +80,7 @@ class TodoIssueCommentCheckTest { latestCommentFile.writeText(latestCommentContent) scriptFailureCommentFile.writeText(scriptFailureCommentContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(tempFolder.root.toString(), "latest_comment.txt", "script_failures.txt") } assertThat(exception).hasMessageThat().contains("NEW COMMENT SHOULD BE POSTED") @@ -109,7 +109,7 @@ class TodoIssueCommentCheckTest { latestCommentFile.writeText(latestCommentContent) scriptFailureCommentFile.writeText(scriptFailureCommentContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(tempFolder.root.toString(), "latest_comment.txt", "script_failures.txt") } assertThat(exception).hasMessageThat().contains("NEW COMMENT SHOULD BE POSTED") diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueResolvedCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueResolvedCheckTest.kt index ae273159b92..4880c092ec5 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueResolvedCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueResolvedCheckTest.kt @@ -105,7 +105,7 @@ class TodoIssueResolvedCheckTest { tempFile1.writeText(testContent1) tempFile2.writeText(testContent2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(retrieveTestFilesDirectoryPath(), "169877", "abmzuyt") } @@ -149,7 +149,7 @@ class TodoIssueResolvedCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(retrieveTestFilesDirectoryPath(), "169877", "abmzuyt") } @@ -195,7 +195,7 @@ class TodoIssueResolvedCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(retrieveTestFilesDirectoryPath(), "169877", "abmzuyt") } val fileContentList = diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt index 23f42c53f2c..68b162340ac 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt @@ -43,7 +43,7 @@ class TodoOpenCheckTest { @Test fun testTodoCheck_noJsonFilePresent_checkShouldFail() { - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -103,7 +103,7 @@ class TodoOpenCheckTest { """.trimIndent() tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -141,7 +141,7 @@ class TodoOpenCheckTest { """.trimIndent() tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -185,7 +185,7 @@ class TodoOpenCheckTest { tempFile1.writeText(testContent1) tempFile2.writeText(testContent2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -239,7 +239,7 @@ class TodoOpenCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -340,7 +340,7 @@ class TodoOpenCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -391,7 +391,7 @@ class TodoOpenCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/StringLanguageTranslationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/StringLanguageTranslationCheckTest.kt index 00916b400e4..bbe2c2ca818 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/StringLanguageTranslationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/StringLanguageTranslationCheckTest.kt @@ -65,7 +65,7 @@ class StringLanguageTranslationCheckTest { @Test fun testScript_missingPath_throwsException() { - val exception = assertThrows(IllegalArgumentException::class) { runScript(/* With no path. */) } + val exception = assertThrows() { runScript(/* With no path. */) } assertThat(exception) .hasMessageThat() @@ -74,7 +74,7 @@ class StringLanguageTranslationCheckTest { @Test fun testScript_validPath_noStringFiles_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceParserTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceParserTest.kt index 0e1edd3fa30..0bbe198f040 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceParserTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceParserTest.kt @@ -70,7 +70,7 @@ class StringResourceParserTest { fun testRetrieveBaseStringFile_noStrings_throwsException() { val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -88,7 +88,7 @@ class StringResourceParserTest { populateNigerianPidginTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -103,7 +103,7 @@ class StringResourceParserTest { populateNigerianPidginTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -118,7 +118,7 @@ class StringResourceParserTest { populateNigerianPidginTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -133,7 +133,7 @@ class StringResourceParserTest { populateNigerianPidginTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -148,7 +148,7 @@ class StringResourceParserTest { populateSwahiliTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -161,7 +161,7 @@ class StringResourceParserTest { populateTranslations(appResources, "values-fake", mapOf()) val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -180,7 +180,7 @@ class StringResourceParserTest { populateTranslations(utilityResources, "values", mapOf()) val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } // An exception is still thrown since resources outside the app directory are ignored. assertThat(exception) @@ -197,7 +197,7 @@ class StringResourceParserTest { writeTranslationsFile(appResources, "values", "") val parser = StringResourceParser(tempFolder.root) - assertThrows(SAXParseException::class) { parser.retrieveBaseStringFile() } + assertThrows() { parser.retrieveBaseStringFile() } } @Test diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceValidationCheckTest.kt index e2152950a99..424a0adb8c3 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceValidationCheckTest.kt @@ -64,7 +64,7 @@ class StringResourceValidationCheckTest { @Test fun testScript_missingPath_throwsException() { - val exception = assertThrows(IllegalArgumentException::class) { runScript(/* With no path. */) } + val exception = assertThrows() { runScript(/* With no path. */) } assertThat(exception) .hasMessageThat() @@ -73,7 +73,7 @@ class StringResourceValidationCheckTest { @Test fun testScript_validPath_noStringFiles_fails() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } @@ -105,7 +105,7 @@ class StringResourceValidationCheckTest { populateSwahiliTranslations(mapOf("str1" to SW_STRING_ONE_NEWLINE)) populateNigerianPidginTranslations(mapOf("str1" to PCM_STRING_ONE_NEWLINE)) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. @@ -133,7 +133,7 @@ class StringResourceValidationCheckTest { populateSwahiliTranslations(mapOf("str1" to SW_STRING_ONE_NEWLINE)) populateNigerianPidginTranslations(mapOf("str1" to PCM_STRING_ONE_NEWLINE)) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. @@ -161,7 +161,7 @@ class StringResourceValidationCheckTest { ) populateNigerianPidginTranslations(mapOf("str1" to PCM_STRING_ONE_NEWLINE)) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. @@ -189,7 +189,7 @@ class StringResourceValidationCheckTest { mapOf("str1" to PCM_STRING_NO_NEWLINES, "str2" to PCM_STRING_TWO_NEWLINES) ) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. @@ -223,7 +223,7 @@ class StringResourceValidationCheckTest { mapOf("str1" to PCM_STRING_NO_NEWLINES, "str2" to PCM_STRING_TWO_NEWLINES) ) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt index 2e988cf0663..293cca1e47e 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt @@ -73,7 +73,7 @@ class XmlSyntaxCheckTest { val tempFile = tempFolder.newFile("testfiles/TestFile.xml") tempFile.writeText(invalidXml) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -112,7 +112,7 @@ class XmlSyntaxCheckTest { tempFile1.writeText(invalidXmlForFile1) tempFile2.writeText(invalidXmlForFile2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -163,7 +163,7 @@ class XmlSyntaxCheckTest { tempFile2.writeText(invalidXmlForFile2) tempFile3.writeText(invalidXmlForFile3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } diff --git a/testing/src/main/java/org/oppia/android/testing/AssertionHelpers.kt b/testing/src/main/java/org/oppia/android/testing/AssertionHelpers.kt index e40d985dad7..7927cd7b79b 100644 --- a/testing/src/main/java/org/oppia/android/testing/AssertionHelpers.kt +++ b/testing/src/main/java/org/oppia/android/testing/AssertionHelpers.kt @@ -1,42 +1,37 @@ package org.oppia.android.testing -import org.junit.Assert.fail -import kotlin.reflect.KClass -import kotlin.reflect.full.cast - /* This file contains generic assertion helpers which are meant to be usable in any test. Not for methods which are specific to a certain test or part of the codebase. */ /** * A replacement to JUnit5's assertThrows() that asserts an execution of the supplied operation - * throws an exception of the supplied type + * throws an exception of the indicated type. * * An example of this might be: * - * val exception = assertThrows(IllegalArgumentException::class) { + * ```kotlin + * val exception = assertThrows() { * stringToRatioParser.parseRatioOrThrow("a:b:c") * } - * assertThat(exception) - * .hasMessageThat() - * .contains("Incorrectly formatted ratio: a:b:c") + * assertThat(exception).hasMessageThat().contains("Incorrectly formatted ratio: a:b:c") + * ``` * - * @param type the type of exception to be thrown * @param operation the operation being run * @return the exception being thrown * @throws AssertionError if the specified exception is not thrown */ -fun assertThrows(type: KClass, operation: () -> Unit): T { - try { - operation() - fail("Expected to encounter exception of $type") - } catch (t: Throwable) { - if (type.isInstance(t)) { - return type.cast(t) +inline fun assertThrows(noinline operation: () -> Unit): T { + return when (val result = try { operation() } catch (t: Throwable) { t }) { + is T -> result + is Throwable -> { + throw AssertionError( + "Expected exception of type: ${T::class.java}, not: ${result::class.java}.", result + ) + } + else -> { + throw AssertionError( + "Expected exception of type: ${T::class.java}. No exception was thrown." + ) } - // Unexpected exception; throw it. - throw t } - throw AssertionError( - "Reached an impossible state when verifying that an exception was thrown." - ) } diff --git a/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt b/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt index c3d4b258494..b6b3870763a 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt @@ -75,7 +75,7 @@ class FakeAnalyticsEventLoggerTest { @Test fun testFakeEventLogger_logNothing_getMostRecent_returnsFailure() { - assertThrows(NoSuchElementException::class) { fakeAnalyticsEventLogger.getMostRecentEvent() } + assertThrows() { fakeAnalyticsEventLogger.getMostRecentEvent() } } @Test @@ -83,7 +83,7 @@ class FakeAnalyticsEventLoggerTest { analyticsEventLogger.logEvent(eventLog1) fakeAnalyticsEventLogger.clearAllEvents() - val eventException = assertThrows(NoSuchElementException::class) { + val eventException = assertThrows() { fakeAnalyticsEventLogger.getMostRecentEvent() } @@ -141,7 +141,7 @@ class FakeAnalyticsEventLoggerTest { @Test fun testGetOldestEvent_noEventsLogged_throwsException() { - assertThrows(NoSuchElementException::class) { fakeAnalyticsEventLogger.getOldestEvent() } + assertThrows() { fakeAnalyticsEventLogger.getOldestEvent() } } @Test @@ -169,7 +169,7 @@ class FakeAnalyticsEventLoggerTest { analyticsEventLogger.logEvent(eventLog1) fakeAnalyticsEventLogger.clearAllEvents() - assertThrows(NoSuchElementException::class) { fakeAnalyticsEventLogger.getOldestEvent() } + assertThrows() { fakeAnalyticsEventLogger.getOldestEvent() } } @Test @@ -234,7 +234,7 @@ class FakeAnalyticsEventLoggerTest { analyticsEventLogger.logEvent(eventLog2) analyticsEventLogger.logEvent(eventLog1) - assertThrows(IllegalArgumentException::class) { + assertThrows() { fakeAnalyticsEventLogger.getMostRecentEvents(count = -1) } } diff --git a/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt b/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt index baa7483b27e..433731da58c 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt @@ -69,7 +69,7 @@ class FakeExceptionLoggerTest { @Test fun testFakeExceptionLogger_logNothing_getMostRecent_returnsFailure() { - val exception = assertThrows(NoSuchElementException::class) { + val exception = assertThrows() { fakeExceptionLogger.getMostRecentException() } @@ -81,7 +81,7 @@ class FakeExceptionLoggerTest { exceptionLogger.logException(IllegalStateException("Test Exception")) fakeExceptionLogger.clearAllExceptions() - val exception = assertThrows(NoSuchElementException::class) { + val exception = assertThrows() { fakeExceptionLogger.getMostRecentException() } diff --git a/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt b/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt index 63afc482661..7f7b55a2d17 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt @@ -78,7 +78,7 @@ class FakePerformanceMetricsEventLoggerTest { @Test fun testFakeMetricsEventLogger_logNothing_getMostRecent_returnsFailure() { - assertThrows(NoSuchElementException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getMostRecentPerformanceMetricsEvent() } } @@ -88,7 +88,7 @@ class FakePerformanceMetricsEventLoggerTest { performanceMetricsEventLogger.logPerformanceMetric(metricLog1) fakePerformanceMetricsEventLogger.clearAllPerformanceMetricsEvents() - assertThrows(NoSuchElementException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getMostRecentPerformanceMetricsEvent() } } @@ -148,7 +148,7 @@ class FakePerformanceMetricsEventLoggerTest { @Test fun testGetOldestEvent_noEventsLogged_throwsException() { - assertThrows(NoSuchElementException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getOldestPerformanceMetricsEvent() } } @@ -178,7 +178,7 @@ class FakePerformanceMetricsEventLoggerTest { performanceMetricsEventLogger.logPerformanceMetric(metricLog1) fakePerformanceMetricsEventLogger.clearAllPerformanceMetricsEvents() - assertThrows(NoSuchElementException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getOldestPerformanceMetricsEvent() } } @@ -255,7 +255,7 @@ class FakePerformanceMetricsEventLoggerTest { performanceMetricsEventLogger.logPerformanceMetric(metricLog2) performanceMetricsEventLogger.logPerformanceMetric(metricLog1) - assertThrows(IllegalArgumentException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getMostRecentPerformanceMetricsEvents(count = -1) } } diff --git a/testing/src/test/java/org/oppia/android/testing/data/DataProviderTestMonitorTest.kt b/testing/src/test/java/org/oppia/android/testing/data/DataProviderTestMonitorTest.kt index 9df6e5257d3..aaa3f578c02 100644 --- a/testing/src/test/java/org/oppia/android/testing/data/DataProviderTestMonitorTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/data/DataProviderTestMonitorTest.kt @@ -167,7 +167,7 @@ class DataProviderTestMonitorTest { } val monitor = monitorFactory.createMonitor(dataProvider) - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextSuccessResult() } + val failure = assertThrows() { monitor.waitForNextSuccessResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -179,7 +179,7 @@ class DataProviderTestMonitorTest { } val monitor = monitorFactory.createMonitor(dataProvider) - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextSuccessResult() } + val failure = assertThrows() { monitor.waitForNextSuccessResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -221,7 +221,7 @@ class DataProviderTestMonitorTest { monitor.waitForNextResult() // Wait for the first result. asyncDataSubscriptionManager.notifyChangeAsync("test") - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextSuccessResult() } + val failure = assertThrows() { monitor.waitForNextSuccessResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -251,7 +251,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Internal expectation failure since the operation hasn't completed. - assertThrows(AssertionError::class) { monitor.ensureNextResultIsSuccess() } + assertThrows() { monitor.ensureNextResultIsSuccess() } } @Test @@ -275,7 +275,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsSuccess() } + val failure = assertThrows() { monitor.ensureNextResultIsSuccess() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -288,26 +288,11 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsSuccess() } + val failure = assertThrows() { monitor.ensureNextResultIsSuccess() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } - @Test - fun testEnsureNextResultIsSuccess_failureThenSuccess_notified_throwsException() { - val dataProvider = - createDataProviderWithResultsQueue( - "test", AsyncResult.Failure(Exception("Failure")), AsyncResult.Success("str value") - ) - val monitor = monitorFactory.createMonitor(dataProvider) - monitor.waitForNextResult() // Wait for the first result. - - asyncDataSubscriptionManager.notifyChangeAsync("test") - testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - // Internal expectation failure since the operation hasn't completed. - assertThrows(AssertionError::class) { monitor.ensureNextResultIsSuccess() } - } - @Test fun testEnsureNextResultIsSuccess_failureThenSuccess_notified_wait_returnsLatest() { val dataProvider = @@ -335,7 +320,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsSuccess() } + val failure = assertThrows() { monitor.ensureNextResultIsSuccess() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -365,7 +350,7 @@ class DataProviderTestMonitorTest { } val monitor = monitorFactory.createMonitor(dataProvider) - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextFailingResult() } + val failure = assertThrows() { monitor.waitForNextFailingResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -389,7 +374,7 @@ class DataProviderTestMonitorTest { } val monitor = monitorFactory.createMonitor(dataProvider) - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextFailingResult() } + val failure = assertThrows() { monitor.waitForNextFailingResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -419,7 +404,7 @@ class DataProviderTestMonitorTest { monitor.waitForNextResult() // Wait for the first result. asyncDataSubscriptionManager.notifyChangeAsync("test") - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextFailingResult() } + val failure = assertThrows() { monitor.waitForNextFailingResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -449,7 +434,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Internal expectation failure since the operation hasn't completed. - assertThrows(AssertionError::class) { monitor.ensureNextResultIsSuccess() } + assertThrows() { monitor.ensureNextResultIsSuccess() } } @Test @@ -473,7 +458,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsFailing() } + val failure = assertThrows() { monitor.ensureNextResultIsFailing() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -486,7 +471,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsFailing() } + val failure = assertThrows() { monitor.ensureNextResultIsFailing() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -502,7 +487,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") // Internal expectation failure since the operation hasn't completed. - assertThrows(AssertionError::class) { monitor.ensureNextResultIsFailing() } + assertThrows() { monitor.ensureNextResultIsFailing() } } @Test @@ -532,7 +517,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsFailing() } + val failure = assertThrows() { monitor.ensureNextResultIsFailing() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -563,7 +548,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -574,7 +559,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -585,7 +570,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -599,7 +584,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -615,7 +600,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -630,7 +615,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -657,7 +642,7 @@ class DataProviderTestMonitorTest { } val failure = - assertThrows(AssertionError::class) { + assertThrows() { monitorFactory.ensureDataProviderExecutes(dataProvider) } @@ -673,7 +658,7 @@ class DataProviderTestMonitorTest { } val failure = - assertThrows(AssertionError::class) { + assertThrows() { monitorFactory.ensureDataProviderExecutes(dataProvider) } @@ -688,7 +673,7 @@ class DataProviderTestMonitorTest { AsyncResult.Failure(Exception("Failure")) } - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -727,7 +712,7 @@ class DataProviderTestMonitorTest { ) monitorFactory.waitForNextSuccessfulResult(dataProvider) - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -770,7 +755,7 @@ class DataProviderTestMonitorTest { } val failure = - assertThrows(IllegalStateException::class) { + assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -783,7 +768,7 @@ class DataProviderTestMonitorTest { AsyncResult.Failure(Exception("Failure")) } - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -822,7 +807,7 @@ class DataProviderTestMonitorTest { ) monitorFactory.waitForNextSuccessfulResult(dataProvider) - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -864,7 +849,7 @@ class DataProviderTestMonitorTest { AsyncResult.Pending() } - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextFailureResult(dataProvider) } @@ -888,7 +873,7 @@ class DataProviderTestMonitorTest { AsyncResult.Success("str value") } - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextFailureResult(dataProvider) } @@ -916,7 +901,7 @@ class DataProviderTestMonitorTest { ) monitorFactory.waitForNextFailureResult(dataProvider) - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextFailureResult(dataProvider) } diff --git a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt index f2f2b2c89f0..e4719190051 100644 --- a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt @@ -105,7 +105,7 @@ class InitializeDefaultLocaleRuleOmissionTest { @Test fun testSuite_withoutRule_doesNotInitializeLocaleHandlerWithDefaultContext() { // Not including the rule should result in a helpful exception being thrown. - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.getDisplayLocale() } assertThat(exception) diff --git a/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt b/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt index 2e158ee93a1..3af786359ca 100644 --- a/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt @@ -136,7 +136,7 @@ class CoroutineExecutorServiceTest { fun testExecute_nullParameter_throwsException() { val executorService = createExecutorService() - assertThrows(NullPointerException::class) { executorService.execute(/* command= */ null) } + assertThrows() { executorService.execute(/* command= */ null) } } @Test @@ -144,7 +144,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdown() - assertThrows(RejectedExecutionException::class) { executorService.execute(mockRunnable) } + assertThrows() { executorService.execute(mockRunnable) } } @Test @@ -152,7 +152,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdownNow() - assertThrows(RejectedExecutionException::class) { executorService.execute(mockRunnable) } + assertThrows() { executorService.execute(mockRunnable) } } @Test @@ -179,7 +179,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() val nullRunnable: Runnable? = null - assertThrows(NullPointerException::class) { executorService.submit(nullRunnable) } + assertThrows() { executorService.submit(nullRunnable) } } @Test @@ -187,7 +187,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdown() - assertThrows(RejectedExecutionException::class) { executorService.submit(mockRunnable) } + assertThrows() { executorService.submit(mockRunnable) } } @Test @@ -195,7 +195,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdownNow() - assertThrows(RejectedExecutionException::class) { executorService.submit(mockRunnable) } + assertThrows() { executorService.submit(mockRunnable) } } @Test @@ -222,7 +222,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() val nullCallable: Callable? = null - assertThrows(NullPointerException::class) { executorService.submit(nullCallable) } + assertThrows() { executorService.submit(nullCallable) } } @Test @@ -230,7 +230,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdown() - assertThrows(RejectedExecutionException::class) { executorService.submit(mockCallable) } + assertThrows() { executorService.submit(mockCallable) } } @Test @@ -238,7 +238,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdownNow() - assertThrows(RejectedExecutionException::class) { executorService.submit(mockCallable) } + assertThrows() { executorService.submit(mockCallable) } } @Test @@ -271,7 +271,7 @@ class CoroutineExecutorServiceTest { testCoroutineDispatchers.runCurrent() assertThat(callableFuture.isDone).isTrue() - val exception = assertThrows(ExecutionException::class) { callableFuture.get() } + val exception = assertThrows() { callableFuture.get() } assertThat(exception).hasCauseThat().isInstanceOf(Exception::class.java) assertThat(exception).hasCauseThat().hasMessageThat().contains("Task failed") } @@ -420,7 +420,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() val nullRunnable: Runnable? = null - assertThrows(NullPointerException::class) { + assertThrows() { executorService.submit(nullRunnable, /* result= */ "Task") } } @@ -430,7 +430,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdown() - assertThrows(RejectedExecutionException::class) { + assertThrows() { executorService.submit(mockRunnable, /* result= */ "Task") } } @@ -440,7 +440,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdownNow() - assertThrows(RejectedExecutionException::class) { + assertThrows() { executorService.submit(mockRunnable, /* result= */ "Task") } } @@ -645,7 +645,7 @@ class CoroutineExecutorServiceTest { // Note that this is not documented in the ExecutorService documentation, it seems necessary // since it doesn't make sense to return false (per the documentation) or block unless a // shutdown request was actually initiated. - assertThrows(IllegalStateException::class) { + assertThrows() { executorService.awaitTermination(/* timeout= */ 1, TimeUnit.SECONDS) } } @@ -746,7 +746,7 @@ class CoroutineExecutorServiceTest { fun testInvokeAll_nullTasks_throwsException() { val executorService = createExecutorService() - assertThrows(NullPointerException::class) { executorService.invokeAll(/* tasks= */ null) } + assertThrows() { executorService.invokeAll(/* tasks= */ null) } } @Test @@ -807,7 +807,7 @@ class CoroutineExecutorServiceTest { val (future1, future2) = deferred.getCompleted() assertThat(future1.isDone).isTrue() assertThat(future2.isDone).isTrue() - assertThrows(ExecutionException::class) { future1.get() } + assertThrows() { future1.get() } assertThat(future2.get()).isEqualTo("Task 2") } @@ -906,7 +906,7 @@ class CoroutineExecutorServiceTest { fun testInvokeAny_nullTasks_throwsException() { val executorService = createExecutorService() - assertThrows(NullPointerException::class) { executorService.invokeAny(/* tasks= */ null) } + assertThrows() { executorService.invokeAny(/* tasks= */ null) } } @Test diff --git a/testing/src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt b/testing/src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt index 5b534916126..aabaee20ebc 100644 --- a/testing/src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt @@ -110,7 +110,7 @@ class FakeOppiaClockTest { fun testSetCurrentTimeMs_wallClockMode_throwsException() { fakeOppiaClock.setFakeTimeMode(MODE_WALL_CLOCK_TIME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fakeOppiaClock.setCurrentTimeMs(0) } assertThat(exception).hasMessageThat().contains("MODE_FIXED_FAKE_TIME") @@ -128,7 +128,7 @@ class FakeOppiaClockTest { fun testSetCurrentTimeMs_uptimeMillisMode_throwsException() { fakeOppiaClock.setFakeTimeMode(MODE_UPTIME_MILLIS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fakeOppiaClock.setCurrentTimeMs(0) } assertThat(exception).hasMessageThat().contains("MODE_FIXED_FAKE_TIME") @@ -226,7 +226,7 @@ class FakeOppiaClockTest { fun testSetCurrentTimeToSameDateTime_wallClockMode_throwsException() { fakeOppiaClock.setFakeTimeMode(MODE_UPTIME_MILLIS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fakeOppiaClock.setCurrentTimeToSameDateTime(0) } assertThat(exception).hasMessageThat().contains("MODE_FIXED_FAKE_TIME") @@ -258,7 +258,7 @@ class FakeOppiaClockTest { fun testSetCurrentTimeToSameDateTime_uptimeMillisMode_throwsException() { fakeOppiaClock.setFakeTimeMode(MODE_UPTIME_MILLIS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fakeOppiaClock.setCurrentTimeToSameDateTime(0) } assertThat(exception).hasMessageThat().contains("MODE_FIXED_FAKE_TIME") diff --git a/utility/src/test/java/org/oppia/android/util/caching/testing/TestNoOpAssetRepositoryTest.kt b/utility/src/test/java/org/oppia/android/util/caching/testing/TestNoOpAssetRepositoryTest.kt index 2cb1a10f433..ea5346c2490 100644 --- a/utility/src/test/java/org/oppia/android/util/caching/testing/TestNoOpAssetRepositoryTest.kt +++ b/utility/src/test/java/org/oppia/android/util/caching/testing/TestNoOpAssetRepositoryTest.kt @@ -38,7 +38,7 @@ class TestNoOpAssetRepositoryTest { @Test fun testLoadTextFileFromLocalAssets_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadTextFileFromLocalAssets("asset.json") } @@ -57,7 +57,7 @@ class TestNoOpAssetRepositoryTest { assetRepository.primeTextFileFromLocalAssets("asset.json") // Priming doesn't do anything, so the exception is still thrown. - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadTextFileFromLocalAssets("asset.json") } @@ -66,7 +66,7 @@ class TestNoOpAssetRepositoryTest { @Test fun testLoadProtoFromLocalAssets_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadProtoFromLocalAssets("test", TestMessage.getDefaultInstance()) } @@ -107,7 +107,7 @@ class TestNoOpAssetRepositoryTest { @Test fun testLoadRemoteBinaryAsset_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadRemoteBinaryAsset("https://example.com/test.pb") } @@ -117,7 +117,7 @@ class TestNoOpAssetRepositoryTest { @Test fun testLoadImageAssetFromLocalAssets_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadImageAssetFromLocalAssets("https://example.com/test.png") } @@ -137,7 +137,7 @@ class TestNoOpAssetRepositoryTest { assetRepository.primeRemoteBinaryAsset("https://example.com/test.pb") // Priming doesn't do anything, so the exception is still thrown. - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadRemoteBinaryAsset("https://example.com/test.pb") } diff --git a/utility/src/test/java/org/oppia/android/util/data/AsyncDataSubscriptionManagerTest.kt b/utility/src/test/java/org/oppia/android/util/data/AsyncDataSubscriptionManagerTest.kt index 8a9c0b627d9..0926b2fd323 100644 --- a/utility/src/test/java/org/oppia/android/util/data/AsyncDataSubscriptionManagerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/data/AsyncDataSubscriptionManagerTest.kt @@ -258,7 +258,7 @@ class AsyncDataSubscriptionManagerTest { @Test fun testAssociateIds_sameId_throwsException() { - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { asyncDataSubscriptionManager.associateIds("same_id", "same_id") } @@ -430,7 +430,7 @@ class AsyncDataSubscriptionManagerTest { asyncDataSubscriptionManager.subscribe("child_id", mockSubscriptionCallback2.toAsyncChange()) asyncDataSubscriptionManager.associateIds("child_id", "parent_id") - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { asyncDataSubscriptionManager.associateIds("parent_id", "child_id") } @@ -446,7 +446,7 @@ class AsyncDataSubscriptionManagerTest { asyncDataSubscriptionManager.associateIds("child_id1", "parent_id") asyncDataSubscriptionManager.associateIds("child_id2", "child_id1") - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { asyncDataSubscriptionManager.associateIds("parent_id", "child_id1") } diff --git a/utility/src/test/java/org/oppia/android/util/data/InMemoryBlockingCacheTest.kt b/utility/src/test/java/org/oppia/android/util/data/InMemoryBlockingCacheTest.kt index e5e2a69b59b..4dc2cc0fc5a 100644 --- a/utility/src/test/java/org/oppia/android/util/data/InMemoryBlockingCacheTest.kt +++ b/utility/src/test/java/org/oppia/android/util/data/InMemoryBlockingCacheTest.kt @@ -207,7 +207,7 @@ class InMemoryBlockingCacheTest { val deferredRead = cache.readIfPresentAsync() val exception = - assertThrows(IllegalStateException::class) { awaitCompletion(deferredRead) } + assertThrows() { awaitCompletion(deferredRead) } assertThat(exception).hasMessageThat() .contains("Expected to read the cache only after it's been created") } @@ -302,7 +302,7 @@ class InMemoryBlockingCacheTest { // The operation should fail since the method expects the cache to be initialized. val exception = - assertThrows(IllegalStateException::class) { awaitCompletion(deferredUpdate) } + assertThrows() { awaitCompletion(deferredUpdate) } assertThat(exception).hasMessageThat() .contains("Expected to update the cache only after it's been created") } @@ -422,7 +422,7 @@ class InMemoryBlockingCacheTest { // Deleting the cache should result in readIfPresent()'s expectations to fail. val exception = - assertThrows(IllegalStateException::class) { awaitCompletion(deferredRead) } + assertThrows() { awaitCompletion(deferredRead) } assertThat(exception).hasMessageThat() .contains("Expected to read the cache only after it's been created") } @@ -456,7 +456,7 @@ class InMemoryBlockingCacheTest { // The operation should fail since the method expects the cache to be initialized. val exception = - assertThrows(IllegalStateException::class) { awaitCompletion(deferredUpdate) } + assertThrows() { awaitCompletion(deferredUpdate) } assertThat(exception).hasMessageThat() .contains("Expected to update the cache only after it's been created") } diff --git a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt index c0b45f7e9fd..c009baad4e0 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt @@ -51,7 +51,7 @@ class AndroidLocaleFactoryTest { @Test fun testCreateLocale_default_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(OppiaLocaleContext.getDefaultInstance()) } @@ -513,7 +513,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -566,7 +566,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -945,7 +945,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -998,7 +998,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -1377,7 +1377,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -1430,7 +1430,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } diff --git a/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt b/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt index 8786f31948b..e300a47d6fa 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt @@ -354,7 +354,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getStringInLocale(-1) } } } @@ -397,7 +397,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getStringInLocaleWithWrapping(-1) } } } @@ -440,7 +440,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getStringInLocaleWithoutWrapping(-1) } } } @@ -460,7 +460,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getStringArrayInLocale(-1) } } } @@ -496,7 +496,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getQuantityStringInLocale(-1, 0) } } } @@ -535,7 +535,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getQuantityStringInLocaleWithWrapping(-1, 0) } } } @@ -574,7 +574,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getQuantityStringInLocaleWithoutWrapping(-1, 0) } } } @@ -610,7 +610,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getQuantityTextInLocale(-1, 0) } } } diff --git a/utility/src/test/java/org/oppia/android/util/locale/testing/TestOppiaBidiFormatterTest.kt b/utility/src/test/java/org/oppia/android/util/locale/testing/TestOppiaBidiFormatterTest.kt index d56be1961ae..91eefeac704 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/testing/TestOppiaBidiFormatterTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/testing/TestOppiaBidiFormatterTest.kt @@ -92,7 +92,7 @@ class TestOppiaBidiFormatterTest { val wrappedStr = formatter.wrapText("test str") // Try to wrap the string again. - val exception = assertThrows(IllegalStateException::class) { formatter.wrapText(wrappedStr) } + val exception = assertThrows() { formatter.wrapText(wrappedStr) } assertThat(exception).hasMessageThat() .contains("Error: encountered string that's already been wrapped: test str") diff --git a/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt b/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt index c19dcfa6d3d..8690cc70ae8 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt @@ -56,7 +56,7 @@ abstract class SyncStatusManagerTestBase { fun testInitializeEventLogStore_twice_throwsException() { impl.initializeEventLogStore(logsCacheStore) - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { impl.initializeEventLogStore(logsCacheStore) } diff --git a/utility/src/test/java/org/oppia/android/util/math/FractionExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/FractionExtensionsTest.kt index 3913e7b6dda..f44bc197f98 100644 --- a/utility/src/test/java/org/oppia/android/util/math/FractionExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/FractionExtensionsTest.kt @@ -444,7 +444,7 @@ class FractionExtensionsTest { val zeroDenominatorFraction = Fraction.getDefaultInstance() // Converting to simplest form results in a divide by zero in this case. - assertThrows(ArithmeticException::class) { zeroDenominatorFraction.toSimplestForm() } + assertThrows() { zeroDenominatorFraction.toSimplestForm() } } @Test @@ -518,7 +518,7 @@ class FractionExtensionsTest { val zeroDenominatorFraction = Fraction.getDefaultInstance() // Converting to simplest form results in a divide by zero in this case. - assertThrows(ArithmeticException::class) { zeroDenominatorFraction.toProperForm() } + assertThrows() { zeroDenominatorFraction.toProperForm() } } @Test @@ -1062,7 +1062,7 @@ class FractionExtensionsTest { val lhsFraction = ZERO_FRACTION val rhsFraction = ZERO_FRACTION - assertThrows(Exception::class) { lhsFraction / rhsFraction } + assertThrows() { lhsFraction / rhsFraction } } @Test @@ -1070,7 +1070,7 @@ class FractionExtensionsTest { val lhsFraction = ONE_FRACTION val rhsFraction = ZERO_FRACTION - assertThrows(Exception::class) { lhsFraction / rhsFraction } + assertThrows() { lhsFraction / rhsFraction } } @Test @@ -1078,7 +1078,7 @@ class FractionExtensionsTest { val lhsFraction = TWO_FRACTION val rhsFraction = ZERO_FRACTION - assertThrows(Exception::class) { lhsFraction / rhsFraction } + assertThrows() { lhsFraction / rhsFraction } } @Test diff --git a/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt index 864a429f753..fa00cf23485 100644 --- a/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt @@ -173,7 +173,7 @@ class FractionParserTest { val parseFraction = fractionParser.parseFraction("7 1/2 4/5") assertThat(parseFraction).isEqualTo(null) - val exception = assertThrows(IllegalArgumentException::class) { + val exception = assertThrows() { fractionParser.parseFractionFromString("7 1/2 4/5") } assertThat(exception).hasMessageThat().contains("Incorrectly formatted fraction: 7 1/2 4/5") @@ -184,7 +184,7 @@ class FractionParserTest { val parseFraction = fractionParser.parseFraction("abc") assertThat(parseFraction).isEqualTo(null) - val exception = assertThrows(IllegalArgumentException::class) { + val exception = assertThrows() { fractionParser.parseFractionFromString("abc") } assertThat(exception).hasMessageThat().contains("Incorrectly formatted fraction: abc") diff --git a/utility/src/test/java/org/oppia/android/util/math/PeekableIteratorTest.kt b/utility/src/test/java/org/oppia/android/util/math/PeekableIteratorTest.kt index 0b6cddc7dbe..e342081aab0 100644 --- a/utility/src/test/java/org/oppia/android/util/math/PeekableIteratorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/PeekableIteratorTest.kt @@ -55,7 +55,7 @@ class PeekableIteratorTest { val sequence = sequenceOf() val iterator = sequence.toPeekableIterator() - assertThrows(NoSuchElementException::class) { iterator.next() } + assertThrows() { iterator.next() } } @Test diff --git a/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt index fee8d4e00e7..bfcb4dba53d 100644 --- a/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt @@ -252,7 +252,7 @@ class RealExtensionsTest { fun testIsNegative_default_throwsException() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { defaultReal.isNegative() } + val exception = assertThrows() { defaultReal.isNegative() } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -309,7 +309,7 @@ class RealExtensionsTest { val first = Real.getDefaultInstance() val second = TWO_REAL - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { first.isApproximatelyEqualTo(second) } @@ -321,7 +321,7 @@ class RealExtensionsTest { val first = TWO_REAL val second = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { first.isApproximatelyEqualTo(second) } @@ -659,7 +659,7 @@ class RealExtensionsTest { fun testIsApproximatelyZero_default_throwsException() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { defaultReal.isApproximatelyZero() } + val exception = assertThrows() { defaultReal.isApproximatelyZero() } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -732,7 +732,7 @@ class RealExtensionsTest { fun testToDouble_default_returnsZeroDouble() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { defaultReal.toDouble() } + val exception = assertThrows() { defaultReal.toDouble() } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -783,7 +783,7 @@ class RealExtensionsTest { fun testAsWholeNumber_default_throwsException() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { defaultReal.asWholeNumber() } + val exception = assertThrows() { defaultReal.asWholeNumber() } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -925,7 +925,7 @@ class RealExtensionsTest { fun testUnaryMinus_default_throwsException() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { -defaultReal } + val exception = assertThrows() { -defaultReal } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -1782,7 +1782,7 @@ class RealExtensionsTest { val lhsReal = createIntegerReal(2) val rhsReal = createIntegerReal(0) - assertThrows(ArithmeticException::class) { lhsReal / rhsReal } + assertThrows() { lhsReal / rhsReal } } @Test @@ -1790,7 +1790,7 @@ class RealExtensionsTest { val lhsReal = createIntegerReal(2) val rhsReal = createRationalReal(ZERO_FRACTION) - assertThrows(ArithmeticException::class) { lhsReal / rhsReal } + assertThrows() { lhsReal / rhsReal } } @Test @@ -1808,7 +1808,7 @@ class RealExtensionsTest { val lhsReal = ONE_AND_ONE_HALF_REAL val rhsReal = createIntegerReal(0) - assertThrows(ArithmeticException::class) { lhsReal / rhsReal } + assertThrows() { lhsReal / rhsReal } } @Test @@ -1816,7 +1816,7 @@ class RealExtensionsTest { val lhsReal = ONE_AND_ONE_HALF_REAL val rhsReal = createRationalReal(ZERO_FRACTION) - assertThrows(ArithmeticException::class) { lhsReal / rhsReal } + assertThrows() { lhsReal / rhsReal } } @Test @@ -2188,7 +2188,7 @@ class RealExtensionsTest { fun testSqrt_defaultReal_throwsException() { val real = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { sqrt(real) } + val exception = assertThrows() { sqrt(real) } assertThat(exception).hasMessageThat().contains("Invalid real") } From fb59232b23e8c0a7a3c1c840c13b325f0f9fdd11 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 28 Aug 2023 21:35:39 +0000 Subject: [PATCH 02/21] Tidy some things up, and revert fragment test. ProfileAndDeviceIdFragmentTest had been updated to use a newer fragment initialization pattern, but that's no longer needed and seems to be causing what appears to be timing discrepancies between local dev and CI. --- .../ProfileAndDeviceIdFragmentTest.kt | 855 +++++++++--------- .../scripts/docs/KdocValidityCheckTest.kt | 152 ++-- .../regex/RegexPatternValidationCheckTest.kt | 348 ++----- .../scripts/testfile/TestFileCheckTest.kt | 18 +- .../android/scripts/todo/TodoOpenCheckTest.kt | 46 +- .../android/scripts/xml/XmlSyntaxCheckTest.kt | 18 +- testing/BUILD.bazel | 5 +- 7 files changed, 585 insertions(+), 857 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index f1caf58e449..74c37f0e6da 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -9,7 +9,6 @@ import android.view.View import androidx.annotation.IdRes import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.RecyclerView -import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction @@ -24,6 +23,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isEnabled import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.truth.content.IntentSubject.assertThat import androidx.work.Configuration @@ -62,7 +62,6 @@ import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.atPositi import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.hasItemCount import org.oppia.android.app.shim.ViewBindingShimModule import org.oppia.android.app.testing.activity.TestActivity -import org.oppia.android.app.testing.activity.TestActivity.Companion.createIntent import org.oppia.android.app.translation.testing.ActivityRecreatorTestModule import org.oppia.android.app.utility.OrientationChangeAction.Companion.orientationLandscape import org.oppia.android.data.backends.gae.NetworkConfigProdModule @@ -148,6 +147,12 @@ import javax.inject.Singleton class ProfileAndDeviceIdFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @get:Rule val oppiaTestRule = OppiaTestRule() + @get:Rule + var activityRule = + ActivityScenarioRule( + TestActivity.createIntent(ApplicationProvider.getApplicationContext()) + ) + @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var context: Context @@ -188,587 +193,559 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_withOnlyAdminProfile_hasThreeItems() { - runInTestActivityAndAddFragment { - // There should be three items: a header, a profile, and the sync status. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) - } + initializeActivityAndAddFragment() + + // There should be three items: a header, a profile, and the sync status. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) } @Test fun testFragment_withOnlyAdminProfile_hasDeviceIdHeader() { - runInTestActivityAndAddFragment { - onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) - } + initializeActivityAndAddFragment() + + onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) } @Test fun testFragment_hasDeviceId() { - runInTestActivityAndAddFragment { - onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) - } + initializeActivityAndAddFragment() + + onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) } @Test fun testFragment_deviceId_hasCopyButton() { - runInTestActivityAndAddFragment { - onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) - } + initializeActivityAndAddFragment() + + onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) } @Test fun testFragment_deviceId_clickCopyButton_copiesDeviceIdToClipboard() { - runInTestActivityAndAddFragment { - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() - - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("113e04cc09a3") - } + initializeActivityAndAddFragment() + + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("113e04cc09a3") } @Test fun testFragment_withOnlyAdminProfile_hasOneProfileListed() { - runInTestActivityAndAddFragment { - onProfileNameAt(position = 1).check(matches(isDisplayed())) - } + initializeActivityAndAddFragment() + + onProfileNameAt(position = 1).check(matches(isDisplayed())) } @Test fun testFragment_profileEntry_hasProfileName() { - runInTestActivityAndAddFragment { - onProfileNameAt(position = 1).check(matches(withText("Admin"))) - } + initializeActivityAndAddFragment() + + onProfileNameAt(position = 1).check(matches(withText("Admin"))) } @Test fun testFragment_profileEntry_hasLearnerId() { - runInTestActivityAndAddFragment { - onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) - } + initializeActivityAndAddFragment() + + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) } @Test fun testFragment_profileEntry_hasCopyButton() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) - } + initializeActivityAndAddFragment() + + onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) } @Test fun testFragment_profileEntry_clickFirstCopyButton_copiesAdminLearnerIdToClipboard() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() - - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("8dcbbd21") - } + initializeActivityAndAddFragment() + + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("8dcbbd21") } @Test fun testFragment_multipleProfiles_listsAllProfiles() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - // Header + admin + 5 new profiles + sync status = 8 items. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) - } + initializeActivityAndAddFragment() + + // Header + admin + 5 new profiles + sync status = 8 items. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) } @Test fun testFragment_multipleProfiles_adminIsFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - onProfileNameAt(position = 1).check(matches(withText("Admin"))) - } + initializeActivityAndAddFragment() + + onProfileNameAt(position = 1).check(matches(withText("Admin"))) } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentName() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - // The second entry is not the admin. - onProfileNameAt(position = 2).check(matches(withText("A"))) - } + initializeActivityAndAddFragment() + + // The second entry is not the admin. + onProfileNameAt(position = 2).check(matches(withText("A"))) } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - // The second profile has a different learner ID. - onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) - onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) - } + initializeActivityAndAddFragment() + + // The second profile has a different learner ID. + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) } @Test fun testFragment_multipleProfiles_copySecondEntry_copiesDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 2).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("A's learner ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("208663b0") - } + onLearnerIdCopyButtonAt(position = 2).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("A's learner ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("208663b0") } @Test fun testFragment_initialState_deviceIdCopyButtonHasCopyLabel() { - runInTestActivityAndAddFragment { - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - } + initializeActivityAndAddFragment() + + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) } @Test fun testFragment_adminProfile_initialState_learnerIdCopyButtonHasCopyLabel() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) - } + initializeActivityAndAddFragment() + + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) } @Test fun testFragment_adminProfile_clickDeviceIdCopyButton_deviceIdIsCopiedButNotLearnerId() { - runInTestActivityAndAddFragment { - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) - } + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() + + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_learnerIdIsCopiedButNotDeviceId() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) - } + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() + + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_copyInOtherApp_nothingIsCopied() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - updateClipDataAsThoughFromAnotherApp() + updateClipDataAsThoughFromAnotherApp() - // Changing the clipboard in a different app should reset the labels. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) - } + // Changing the clipboard in a different app should reset the labels. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_rotate_learnerIdStillCopied() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - // The button label should be restored after a rotation. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) - } + // The button label should be restored after a rotation. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) } @Test fun testFragment_multipleProfiles_rotate_profilesStillPresent() { profileTestHelper.addMoreProfiles(numProfiles = 5) + initializeActivityAndAddFragment() - runInTestActivityAndAddFragment { - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) - } + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) } @Test fun testFragment_firstEntry_noAdminEvents_hasZeroAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) + initializeActivityAndAddFragment() - runInTestActivityAndAddFragment { - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - } + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_firstEntry_adminEvents_notUploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - } + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_firstEntry_adminEvents_uploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - } + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) } @Test fun testFragment_firstEntry_noGenericEvents_hasZeroGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) + initializeActivityAndAddFragment() - runInTestActivityAndAddFragment { - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - } + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_firstEntry_genericEvents_notUploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events off of the admin profile. - logTwoAnalyticsEvents(profileId = null) + // Log a couple of events off of the admin profile. + logTwoAnalyticsEvents(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - } + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_firstEntry_genericEvents_uploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event, off of the admin profile. - logTwoAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) + // Log a couple of events, upload them, then log one more event, off of the admin profile. + logTwoAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) - } + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) } @Test fun testFragment_firstEntry_mixOfAdminAndGenericEvents_someUploaded_reportsAllEvents() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Log & upload a mix of events with and without the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logThreeAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - - // Event counts should be represented in the correct places. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Log & upload a mix of events with and without the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logThreeAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + + // Event counts should be represented in the correct places. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) } @Test fun testFragment_secondEntry_noLearnerEvents_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) + initializeActivityAndAddFragment() - runInTestActivityAndAddFragment { - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - } + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) } @Test fun testFragment_secondEntry_learnerEvents_notUploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - } + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) } @Test fun testFragment_secondEntry_learnerEvents_uploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) - } + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) } @Test fun testFragment_secondEntry_learnerEvents_hasZeroAdminOrGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events, upload them, then log one more event, for a learner profile. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - - // The admin profile's event counts shouldn't change since the only logged events were for a - // specific learner profile. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events, upload them, then log one more event, for a learner profile. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + + // The admin profile's event counts shouldn't change since the only logged events were for a + // specific learner profile. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_secondEntry_adminAndGenericEvents_uploaded_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events generically and for the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - - // No events should be reported for the learner since it didn't have any events uploaded. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events generically and for the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + + // No events should be reported for the learner since it didn't have any events uploaded. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) } @Test fun testFragment_initialState_profileDataHasYetToBeCollected() { - runInTestActivityAndAddFragment { - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) - } + initializeActivityAndAddFragment() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) } @Test fun testFragment_initialState_wait_profileDataHasYetToBeCollected() { - runInTestActivityAndAddFragment { - testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) + initializeActivityAndAddFragment() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) - } + testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) } @Test fun testFragment_eventLogged_waitingForUpload_indicatorTextMentionsWaiting() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. - // Note that the extra event log is a slight hack to force a refresh of the status indicator - // (since network changes are polled when there are other changes to represent rather than - // being actively "pushed" by the system). - logAnalyticsEvent() - connectNetwork() - logAnalyticsEvent() - - // The status indicator is suggesting that events can be uploaded (and there are some - // available to upload), they just haven't been scheduled yet. - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. Note + // that the extra event log is a slight hack to force a refresh of the status indicator (since + // network changes are polled when there are other changes to represent rather than being + // actively "pushed" by the system). + logAnalyticsEvent() + connectNetwork() + logAnalyticsEvent() + + // The status indicator is suggesting that events can be uploaded (and there are some available + // to upload), they just haven't been scheduled yet. + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) } @Test fun testFragment_eventLogged_waitingForUpload_uploadStarted_profileDataIsCurrentlyUploading() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to - // produce the same situation to ensure the label is correct. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to + // produce the same situation to ensure the label is correct. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) } @Test fun testFragment_noConnectivity_indicatorTextMentionsDataCannotBeUploaded() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Enqueue an event but don't reconnect to the network. - logAnalyticsEvent() - - // The status indicator is suggesting that internet connectivity needs to resume in order to - // upload events. - onSyncStatusAt(position = 2) - .check( - matches( - withText( - containsString( - "Please connect to a WiFi or Cellular network in order to upload profile data" - ) + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Enqueue an event but don't reconnect to the network. + logAnalyticsEvent() + + // The status indicator is suggesting that internet connectivity needs to resume in order to + // upload events. + onSyncStatusAt(position = 2) + .check( + matches( + withText( + containsString( + "Please connect to a WiFi or Cellular network in order to upload profile data" ) ) ) - } + ) } @Test fun testFragment_eventLogged_waitForUpload_profileDataIsUploaded() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) } @Test fun testFragment_eventLogged_uploadError_profileDataHasError() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() - // An upload error can currently only be simulated by directly influencing the sync manager. - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() + // An upload error can currently only be simulated by directly influencing the sync manager. + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check( - matches(withText(containsString("Something went wrong when trying to upload events"))) - ) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Something went wrong when trying to upload events")))) } @Test fun testFragment_eventLogged_uploadError_anotherLogged_wait_profileDataIsUploading() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.reportUploadError() - testCoroutineDispatchers.runCurrent() - - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.reportUploadError() + testCoroutineDispatchers.runCurrent() + + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) } @Test fun testFragment_rotate_profileDataHasYetToBeCollected() { - runInTestActivityAndAddFragment { - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) - } + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) } @Test fun testFragment_eventLogged_waitingForUpload_rotate_profileDataIsCurrentlyUploading() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) } @Test fun testFragment_eventLogged_waitForUpload_rotate_profileDataIsUploaded() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) } @Test fun testFragment_eventsLogged_uploadError_rotate_profileDataHasError() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() - - onSyncStatusAt(position = 2) - .check( - matches(withText(containsString("Something went wrong when trying to upload events"))) - ) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() + + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Something went wrong when trying to upload events")))) } @Test @@ -776,141 +753,129 @@ class ProfileAndDeviceIdFragmentTest { // Use fake time so that the generated event logs are consistent across runs. fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) profileTestHelper.addMoreProfiles(numProfiles = 2) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Log & upload some events, then enqueue others. - logThreeAnalyticsEvents(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - - onShareIdsAndEventsButtonAt(position = 5).perform(click()) - testCoroutineDispatchers.runCurrent() - - val expectedShareText = - """ - Oppia app installation ID: 113e04cc09a3 - - Profile name: Admin, learner ID: 8dcbbd21 - - Uploading learner events: 3 - - Uploaded learner events: 2 - - Uploading uncategorized events: 1 - - Uploaded uncategorized events: 4 - - Profile name: A, learner ID: 208663b0 - - Uploading learner events: 2 - - Uploaded learner events: 1 - - Profile name: B, learner ID: 92d0c6e2 - - Uploading learner events: 1 - - Uploaded learner events: 2 - Current sync status: Waiting to schedule data uploading worker…. - Event log encoding integrity checks: - - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY - - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 - - Total event string length (unwrapped): 140 - Encoded event logs: - H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ - gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - """.trimIndent() - val intents = getIntents() - assertThat(intents).hasSize(1) - assertThat(intents.single()).hasAction(Intent.ACTION_SEND) - assertThat(intents.single()).hasType("text/plain") - assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) - assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Log & upload some events, then enqueue others. + logThreeAnalyticsEvents(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + + onShareIdsAndEventsButtonAt(position = 5).perform(click()) + testCoroutineDispatchers.runCurrent() + + val expectedShareText = + """ + Oppia app installation ID: 113e04cc09a3 + - Profile name: Admin, learner ID: 8dcbbd21 + - Uploading learner events: 3 + - Uploaded learner events: 2 + - Uploading uncategorized events: 1 + - Uploaded uncategorized events: 4 + - Profile name: A, learner ID: 208663b0 + - Uploading learner events: 2 + - Uploaded learner events: 1 + - Profile name: B, learner ID: 92d0c6e2 + - Uploading learner events: 1 + - Uploaded learner events: 2 + Current sync status: Waiting to schedule data uploading worker…. + Event log encoding integrity checks: + - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY + - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 + - Total event string length (unwrapped): 140 + Encoded event logs: + H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ + gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + """.trimIndent() + val intents = getIntents() + assertThat(intents).hasSize(1) + assertThat(intents.single()).hasAction(Intent.ACTION_SEND) + assertThat(intents.single()).hasType("text/plain") + assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) + assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) } @Test fun testFragment_noEventsPending_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // The upload button should be disabled when there are no events to upload. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) - } + // The upload button should be disabled when there are no events to upload. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) } @Test fun testFragment_multipleEventsPending_noConnection_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // The button is still disabled since there's no internet connection. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) - } + // The button is still disabled since there's no internet connection. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) } @Test fun testFragment_multipleEventsPending_uploadLogsButtonEnabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - // With events pending & connectivity, the upload button should now be available to press. - onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) - } + // With events pending & connectivity, the upload button should now be available to press. + onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) } @Test fun testFragment_multipleEventsPending_clickUploadLogs_wait_uploadsEventLogs() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - fakeAnalyticsEventLogger.clearAllEvents() - - // Click the 'upload logs' button and wait. - onUploadLogsButtonAt(position = 4).perform(click()) - testCoroutineDispatchers.runCurrent() - - // The events should be uploaded. - assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) - } - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + fakeAnalyticsEventLogger.clearAllEvents() + + // Click the 'upload logs' button and wait. + onUploadLogsButtonAt(position = 4).perform(click()) + testCoroutineDispatchers.runCurrent() - private fun runInTestActivityAndAddFragment(testBlock: () -> Unit) { - launchActivityAndAddFragment().use { scenario -> - scenario.onActivity { activity -> - activity.setContentView(R.layout.test_activity) + // The events should be uploaded. + assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + } - activity.supportFragmentManager.beginTransaction() - .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) - .commitNow() - } - connectNetwork() // Start with internet connectivity. - testCoroutineDispatchers.runCurrent() + private fun initializeActivityAndAddFragment() { + activityRule.scenario.onActivity { activity -> + activity.setContentView(R.layout.test_activity) - testBlock() + activity.supportFragmentManager.beginTransaction() + .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) + .commitNow() } + connectNetwork() // Start with internet connectivity. + testCoroutineDispatchers.runCurrent() } - private fun launchActivityAndAddFragment() = - ActivityScenario.launch(createIntent(ApplicationProvider.getApplicationContext())) - private fun scrollTo(position: Int) { onView(withId(R.id.profile_and_device_id_recycler_view)) .perform(actionOnItemAtPosition(position, scrollTo())) diff --git a/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt index 58b99cf4db5..6850c951041 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt @@ -46,7 +46,7 @@ class KdocValidityCheckTest { val testContent = """ /** - * Returns the string corresponding to this error's string resources, or null if there + * Returns the string corresponding to this error's string resources, or null if there * is none. */ fun getErrorMessageFromStringRes(context: Context): String? { @@ -260,7 +260,7 @@ class KdocValidityCheckTest { val testContent = """ val testVal = "testContent" - + fun provideContext(application: Application): Context """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFileTest.kt") @@ -281,16 +281,14 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -352,21 +350,19 @@ class KdocValidityCheckTest { fun testKdoc_class_withoutKdoc_checkShouldFail() { val testContent = """ - class TestClass {} + class TestClass {} """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -382,21 +378,19 @@ class KdocValidityCheckTest { class NestedClass { class NestedLevel2Class {} } - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:5 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -409,16 +403,14 @@ class KdocValidityCheckTest { /** Test KDoc 1. */ class TestClass { val testVal = "test" - + fun testFunc(){} - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -426,7 +418,7 @@ class KdocValidityCheckTest { KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:5 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -442,9 +434,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -452,7 +442,7 @@ class KdocValidityCheckTest { KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -468,16 +458,14 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -495,16 +483,14 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:4 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -522,9 +508,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -533,7 +517,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -544,15 +528,13 @@ class KdocValidityCheckTest { val testContent = """ const val TABLE_USER_ATTRIBUTE_EMPID = "_id" - + const val TABLE_USER_ATTRIBUTE_DATA = "data" """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -560,7 +542,7 @@ class KdocValidityCheckTest { KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -572,21 +554,19 @@ class KdocValidityCheckTest { """ fun getErrorMessageFromStringRes(context: Context): String? { return error?.let(context::getString) - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -604,16 +584,14 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -627,14 +605,12 @@ class KdocValidityCheckTest { WELCOME(0), TOPIC_LIST(1), FINAL(2) - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -644,7 +620,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:4 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -655,22 +631,20 @@ class KdocValidityCheckTest { val testContent = """ interface ChapterSelector { - + fun chapterSelected(chapterIndex: Int, nextStoryIndex: Int, explorationId: String) - + fun chapterUnselected(chapterIndex: Int, nextStoryIndex: Int) - + interface ChildInterface { fun testFunction() } - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -681,7 +655,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:5 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:7 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:8 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -695,11 +669,11 @@ class KdocValidityCheckTest { class TestClass { companion object { val pos = 1 - + fun incrementedPosition(position: Int): Int { return position+1 } - + fun decrementedPosition(position: Int): Int { return position-1 } @@ -709,9 +683,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -720,7 +692,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:4 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:6 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:10 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -748,23 +720,21 @@ class KdocValidityCheckTest { val testContent = """ import javax.inject.Qualifier - + @Qualifier annotation class DelayShowAdditionalHintsFromWrongAnswerMillis """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:4 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -775,7 +745,7 @@ class KdocValidityCheckTest { val testContent1 = """ import javax.inject.Qualifier - + @Qualifier annotation class DelayShowAdditionalHintsFromWrongAnswerMillis """.trimIndent() @@ -783,9 +753,9 @@ class KdocValidityCheckTest { """ class TestClass { fun testFunc(){} - + private val testVal = "test" - + val testVal2 = "test2" } """.trimIndent() @@ -800,9 +770,7 @@ class KdocValidityCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -813,7 +781,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:6 - ${retrieveTestFilesDirectoryPath()}/TempFile3.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -825,9 +793,9 @@ class KdocValidityCheckTest { """ /** test kdoc. */ val testVal1 = "test content" - + val testVal2 = "test content" - + fun getErrorMessageFromStringRes(context: Context): String? { return error?.let(context::getString) } @@ -858,7 +826,7 @@ class KdocValidityCheckTest { """ /** test Kdoc1. */ val testVal = "test content" - + /** test Kdoc2. */ fun getErrorMessageFromStringRes(context: Context): String? { return error?.let(context::getString) @@ -879,9 +847,7 @@ class KdocValidityCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -913,9 +879,7 @@ class KdocValidityCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -923,10 +887,10 @@ class KdocValidityCheckTest { Redundant exemptions: - app/src/main/java/org/oppia/android/app/splash/SplashActivity.kt Please remove them from scripts/assets/kdoc_validity_exemptions.textproto - + KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/HomeActivity.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index 39550f0f8ae..c555f4cba76 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -257,9 +257,7 @@ class RegexPatternValidationCheckTest { val tempFile = tempFolder.newFile("testfiles/data/src/main/TestActivity.kt") tempFile.writeText(requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()).isEqualTo( @@ -287,9 +285,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFolder("testfiles", "app", "src", "main", "res", "values", "subdir") tempFolder.newFile("testfiles/app/src/main/res/values/subdir/strings.xml") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()).isEqualTo( @@ -307,16 +303,14 @@ class RegexPatternValidationCheckTest { tempFolder.newFolder("testfiles", "domain", "src", "main", "res", "drawable", "subdir") tempFolder.newFile("testfiles/domain/src/main/res/drawable/subdir/example.png") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()).isEqualTo( """ File name/path violation: $nestedResourceSubdirectoryErrorMessage - domain/src/main/res/drawable/subdir/example.png - + $wikiReferenceNote """.trimIndent() ) @@ -337,9 +331,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -357,9 +349,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -377,9 +367,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -397,9 +385,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -417,9 +403,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -437,9 +421,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -457,9 +439,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -477,9 +457,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -497,9 +475,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -517,9 +493,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -537,9 +511,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -557,9 +529,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -577,9 +547,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -597,9 +565,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -617,9 +583,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -637,9 +601,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -657,9 +619,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -677,9 +637,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -697,9 +655,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -717,9 +673,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -737,9 +691,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -757,9 +709,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -777,9 +727,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -797,9 +745,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -817,9 +763,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -837,9 +781,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -857,9 +799,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -877,9 +817,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -897,9 +835,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -917,9 +853,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -937,9 +871,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -957,9 +889,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -977,9 +907,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -997,9 +925,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1018,9 +944,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1039,9 +963,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1072,9 +994,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/untranslated_strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1093,9 +1013,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/untranslated_strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1114,9 +1032,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1135,9 +1051,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1207,9 +1121,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1250,9 +1162,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.java" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1285,9 +1195,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1317,9 +1225,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1345,9 +1251,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1370,9 +1274,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1400,9 +1302,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1443,9 +1343,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1465,9 +1363,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1487,9 +1383,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1508,9 +1402,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeDialogFragment.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1541,9 +1433,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1571,9 +1461,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1601,9 +1489,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1622,9 +1508,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1643,9 +1527,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1669,9 +1551,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1692,9 +1572,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1713,9 +1591,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1745,9 +1621,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = "test_layout.xml" tempFolder.newFile("testfiles/$fileContainsSupportLibraryImport").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1774,9 +1648,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/test/SomeTest.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1796,9 +1668,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1817,9 +1687,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/BUILD" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1838,9 +1706,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/BUILD.bazel" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1859,9 +1725,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1881,9 +1745,7 @@ class RegexPatternValidationCheckTest { val prohibitedFile = tempFolder.newFile("testfiles/data/src/main/TestActivity.kt") prohibitedFile.writeText(prohibitedContent + requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()).isEqualTo( @@ -1914,9 +1776,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1964,9 +1824,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2012,9 +1870,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2059,9 +1915,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2123,9 +1977,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2171,9 +2023,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2218,9 +2068,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2263,9 +2111,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2311,9 +2157,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/layout/test_layout.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2381,9 +2225,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFile("testfiles/$stringFilePath5").writeText(prohibitedContent) tempFolder.newFile("testfiles/$stringFilePath6").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2438,9 +2280,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2460,9 +2300,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/activity/HomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2492,9 +2330,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/activity/HomeActivityTest.kt" tempFolder.newFile("testfiles/$stringFilePath") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2528,9 +2364,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/SomeInitializer.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2553,9 +2387,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2578,9 +2410,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2603,9 +2433,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2702,7 +2530,7 @@ class RegexPatternValidationCheckTest { /** Content here.*/ /** Content here. **/ /** Correct KDoc. */ - + /* * Incorrect block comment. **/ diff --git a/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt index 3c22ca1ac31..1b6ded9633a 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt @@ -52,15 +52,13 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile1Test.kt") tempFolder.newFile("testfiles/ProdFile2.kt") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TEST_FILE_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ File ${retrieveTestFilesDirectoryPath()}/ProdFile2.kt $errorMessage - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -73,16 +71,14 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile2.kt") tempFolder.newFile("testfiles/ProdFile3.kt") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TEST_FILE_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ File ${retrieveTestFilesDirectoryPath()}/ProdFile2.kt does not have a corresponding test file. File ${retrieveTestFilesDirectoryPath()}/ProdFile3.kt does not have a corresponding test file. - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -95,16 +91,14 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile3.kt") tempFolder.newFile("testfiles/ProdFile2.kt") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TEST_FILE_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ File ${retrieveTestFilesDirectoryPath()}/ProdFile2.kt does not have a corresponding test file. File ${retrieveTestFilesDirectoryPath()}/ProdFile3.kt does not have a corresponding test file. - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt index 68b162340ac..6df3902ba9a 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt @@ -43,9 +43,7 @@ class TodoOpenCheckTest { @Test fun testTodoCheck_noJsonFilePresent_checkShouldFail() { - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains( "${retrieveTestFilesDirectoryPath()}/open_issues.json: No such file exists" @@ -103,9 +101,7 @@ class TodoOpenCheckTest { """.trimIndent() tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -116,7 +112,7 @@ class TodoOpenCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:3 - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:4 - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:5 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -141,9 +137,7 @@ class TodoOpenCheckTest { """.trimIndent() tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -152,7 +146,7 @@ class TodoOpenCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:5 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -185,9 +179,7 @@ class TodoOpenCheckTest { tempFile1.writeText(testContent1) tempFile2.writeText(testContent2) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -195,11 +187,11 @@ class TodoOpenCheckTest { TODOs not in correct format: - ${retrieveTestFilesDirectoryPath()}/TempFile1.kt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:1 - + TODOs not corresponding to open issues on GitHub: - ${retrieveTestFilesDirectoryPath()}/TempFile1.kt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -239,9 +231,7 @@ class TodoOpenCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -250,11 +240,11 @@ class TodoOpenCheckTest { - ${retrieveTestFilesDirectoryPath()}/Activity.kt:2 - ${retrieveTestFilesDirectoryPath()}/Fragment.kt:1 - ${retrieveTestFilesDirectoryPath()}/Presenter.kt:2 - + TODOs not corresponding to open issues on GitHub: - ${retrieveTestFilesDirectoryPath()}/Fragment.kt:3 - ${retrieveTestFilesDirectoryPath()}/Presenter.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -340,9 +330,7 @@ class TodoOpenCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -391,9 +379,7 @@ class TodoOpenCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -401,13 +387,13 @@ class TodoOpenCheckTest { Redundant exemptions (there are no TODOs corresponding to these lines): - TempFile1.kt:2 Please remove them from scripts/assets/todo_exemptions.textproto - + TODOs not in correct format: - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:1 - + TODOs not corresponding to open issues on GitHub: - ${retrieveTestFilesDirectoryPath()}/TempFile1.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt index 293cca1e47e..bc78d44296e 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt @@ -73,15 +73,13 @@ class XmlSyntaxCheckTest { val tempFile = tempFolder.newFile("testfiles/TestFile.xml") tempFile.writeText(invalidXml) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(XML_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ ${retrieveTestFilesDirectoryPath()}/TestFile.xml:6:8: $syntaxFailureMessage1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -112,16 +110,14 @@ class XmlSyntaxCheckTest { tempFile1.writeText(invalidXmlForFile1) tempFile2.writeText(invalidXmlForFile2) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(XML_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ ${retrieveTestFilesDirectoryPath()}/TestFile1.xml:4:4: $syntaxFailureMessage2 ${retrieveTestFilesDirectoryPath()}/TestFile2.xml:6:8: $syntaxFailureMessage1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -163,9 +159,7 @@ class XmlSyntaxCheckTest { tempFile2.writeText(invalidXmlForFile2) tempFile3.writeText(invalidXmlForFile3) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(XML_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -173,7 +167,7 @@ class XmlSyntaxCheckTest { ${retrieveTestFilesDirectoryPath()}/TestFile1.xml:4:4: $syntaxFailureMessage2 ${retrieveTestFilesDirectoryPath()}/TestFile2.xml:6:8: $syntaxFailureMessage1 ${retrieveTestFilesDirectoryPath()}/TestFile3.xml:6:8: $syntaxFailureMessage1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 9bed8754f08..5c6cf0abf63 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -153,10 +153,7 @@ kt_android_library( testonly = True, srcs = ["src/main/java/org/oppia/android/testing/AssertionHelpers.kt"], visibility = ["//visibility:public"], - deps = [ - "//third_party:junit_junit", - "//third_party:org_jetbrains_kotlin_kotlin-reflect", - ], + deps = ["//third_party:junit_junit"], ) filegroup( From 2551d4b908fea3f867fc2c94bdd472c468351fda Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 11 Sep 2023 23:39:38 +0000 Subject: [PATCH 03/21] Fix test behavior inconsistency in test. The issue ultimately arose from test parameters being initialized after they're needed in the launched UI. This type of change was tried earlier in the branch, but reverted since it didn't seem necessary. It is, however, necessary when there are environment differences (e.g. local vs. CI) or when running certain tests individually. Due to the difficulty in finding this issue, ActivityScenarioRule has been added as a prohibited pattern in the static regex checks (along with ActivityTestRule since that's deprecated and discouraged, anyway). --- .../ProfileAndDeviceIdFragmentTest.kt | 825 +++++++++--------- .../file_content_validation_checks.textproto | 87 ++ .../regex/RegexPatternValidationCheckTest.kt | 51 ++ 3 files changed, 567 insertions(+), 396 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index 74c37f0e6da..b7e883989f8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -9,6 +9,7 @@ import android.view.View import androidx.annotation.IdRes import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.RecyclerView +import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction @@ -23,7 +24,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isEnabled import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText -import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.truth.content.IntentSubject.assertThat import androidx.work.Configuration @@ -147,11 +147,6 @@ import javax.inject.Singleton class ProfileAndDeviceIdFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @get:Rule val oppiaTestRule = OppiaTestRule() - @get:Rule - var activityRule = - ActivityScenarioRule( - TestActivity.createIntent(ApplicationProvider.getApplicationContext()) - ) @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @@ -193,39 +188,39 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_withOnlyAdminProfile_hasThreeItems() { - initializeActivityAndAddFragment() - - // There should be three items: a header, a profile, and the sync status. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) + runWithLaunchedActivityAndAddedFragment { + // There should be three items: a header, a profile, and the sync status. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) + } } @Test fun testFragment_withOnlyAdminProfile_hasDeviceIdHeader() { - initializeActivityAndAddFragment() - - onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) + runWithLaunchedActivityAndAddedFragment { + onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) + } } @Test fun testFragment_hasDeviceId() { - initializeActivityAndAddFragment() - - onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) + runWithLaunchedActivityAndAddedFragment { + onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) + } } @Test fun testFragment_deviceId_hasCopyButton() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) + runWithLaunchedActivityAndAddedFragment { + onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) + } } @Test fun testFragment_deviceId_clickCopyButton_copiesDeviceIdToClipboard() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() + } val clipData = getCurrentClipData() assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") @@ -235,38 +230,38 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_withOnlyAdminProfile_hasOneProfileListed() { - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(isDisplayed())) + runWithLaunchedActivityAndAddedFragment { + onProfileNameAt(position = 1).check(matches(isDisplayed())) + } } @Test fun testFragment_profileEntry_hasProfileName() { - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(withText("Admin"))) + runWithLaunchedActivityAndAddedFragment { + onProfileNameAt(position = 1).check(matches(withText("Admin"))) + } } @Test fun testFragment_profileEntry_hasLearnerId() { - initializeActivityAndAddFragment() - - onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + runWithLaunchedActivityAndAddedFragment { + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + } } @Test fun testFragment_profileEntry_hasCopyButton() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) + } } @Test fun testFragment_profileEntry_clickFirstCopyButton_copiesAdminLearnerIdToClipboard() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() + } val clipData = getCurrentClipData() assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") @@ -278,50 +273,50 @@ class ProfileAndDeviceIdFragmentTest { fun testFragment_multipleProfiles_listsAllProfiles() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // Header + admin + 5 new profiles + sync status = 8 items. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + runWithLaunchedActivityAndAddedFragment { + // Header + admin + 5 new profiles + sync status = 8 items. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + } } @Test fun testFragment_multipleProfiles_adminIsFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(withText("Admin"))) + runWithLaunchedActivityAndAddedFragment { + onProfileNameAt(position = 1).check(matches(withText("Admin"))) + } } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentName() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // The second entry is not the admin. - onProfileNameAt(position = 2).check(matches(withText("A"))) + runWithLaunchedActivityAndAddedFragment { + // The second entry is not the admin. + onProfileNameAt(position = 2).check(matches(withText("A"))) + } } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // The second profile has a different learner ID. - onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) - onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) + runWithLaunchedActivityAndAddedFragment { + // The second profile has a different learner ID. + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) + } } @Test fun testFragment_multipleProfiles_copySecondEntry_copiesDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 2).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 2).perform(click()) + testCoroutineDispatchers.runCurrent() + } val clipData = getCurrentClipData() assertThat(clipData?.description?.label).isEqualTo("A's learner ID") @@ -331,421 +326,449 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_initialState_deviceIdCopyButtonHasCopyLabel() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + runWithLaunchedActivityAndAddedFragment { + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_initialState_learnerIdCopyButtonHasCopyLabel() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickDeviceIdCopyButton_deviceIdIsCopiedButNotLearnerId() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_learnerIdIsCopiedButNotDeviceId() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_copyInOtherApp_nothingIsCopied() { - initializeActivityAndAddFragment() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - updateClipDataAsThoughFromAnotherApp() + updateClipDataAsThoughFromAnotherApp() - // Changing the clipboard in a different app should reset the labels. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + // Changing the clipboard in a different app should reset the labels. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_rotate_learnerIdStillCopied() { - initializeActivityAndAddFragment() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - // The button label should be restored after a rotation. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + // The button label should be restored after a rotation. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + } } @Test fun testFragment_multipleProfiles_rotate_profilesStillPresent() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + } } @Test fun testFragment_firstEntry_noAdminEvents_hasZeroAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_adminEvents_notUploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_adminEvents_uploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + } } @Test fun testFragment_firstEntry_noGenericEvents_hasZeroGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_genericEvents_notUploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events off of the admin profile. - logTwoAnalyticsEvents(profileId = null) + // Log a couple of events off of the admin profile. + logTwoAnalyticsEvents(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_genericEvents_uploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event, off of the admin profile. - logTwoAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) + // Log a couple of events, upload them, then log one more event, off of the admin profile. + logTwoAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + } } @Test fun testFragment_firstEntry_mixOfAdminAndGenericEvents_someUploaded_reportsAllEvents() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log & upload a mix of events with and without the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logThreeAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - - // Event counts should be represented in the correct places. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Log & upload a mix of events with and without the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logThreeAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + + // Event counts should be represented in the correct places. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) + } } @Test fun testFragment_secondEntry_noLearnerEvents_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_learnerEvents_notUploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_learnerEvents_uploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + } } @Test fun testFragment_secondEntry_learnerEvents_hasZeroAdminOrGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events, upload them, then log one more event, for a learner profile. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - - // The admin profile's event counts shouldn't change since the only logged events were for a - // specific learner profile. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events, upload them, then log one more event, for a learner profile. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + + // The admin profile's event counts shouldn't change since the only logged events were for a + // specific learner profile. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_adminAndGenericEvents_uploaded_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events generically and for the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - - // No events should be reported for the learner since it didn't have any events uploaded. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events generically and for the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + + // No events should be reported for the learner since it didn't have any events uploaded. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_initialState_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + runWithLaunchedActivityAndAddedFragment { + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_initialState_wait_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) + runWithLaunchedActivityAndAddedFragment { + testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_indicatorTextMentionsWaiting() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. Note - // that the extra event log is a slight hack to force a refresh of the status indicator (since - // network changes are polled when there are other changes to represent rather than being - // actively "pushed" by the system). - logAnalyticsEvent() - connectNetwork() - logAnalyticsEvent() - - // The status indicator is suggesting that events can be uploaded (and there are some available - // to upload), they just haven't been scheduled yet. - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. + // Note that the extra event log is a slight hack to force a refresh of the status indicator + // (since network changes are polled when there are other changes to represent rather than + // being actively "pushed" by the system). + logAnalyticsEvent() + connectNetwork() + logAnalyticsEvent() + + // The status indicator is suggesting that events can be uploaded (and there are some + // available to upload), they just haven't been scheduled yet. + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_uploadStarted_profileDataIsCurrentlyUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to - // produce the same situation to ensure the label is correct. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to + // produce the same situation to ensure the label is correct. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) + } } @Test fun testFragment_noConnectivity_indicatorTextMentionsDataCannotBeUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Enqueue an event but don't reconnect to the network. - logAnalyticsEvent() - - // The status indicator is suggesting that internet connectivity needs to resume in order to - // upload events. - onSyncStatusAt(position = 2) - .check( - matches( - withText( - containsString( - "Please connect to a WiFi or Cellular network in order to upload profile data" + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Enqueue an event but don't reconnect to the network. + logAnalyticsEvent() + + // The status indicator is suggesting that internet connectivity needs to resume in order to + // upload events. + onSyncStatusAt(position = 2) + .check( + matches( + withText( + containsString( + "Please connect to a WiFi or Cellular network in order to upload profile data" + ) ) ) ) - ) + } } @Test fun testFragment_eventLogged_waitForUpload_profileDataIsUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_eventLogged_uploadError_profileDataHasError() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() - // An upload error can currently only be simulated by directly influencing the sync manager. - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() + // An upload error can currently only be simulated by directly influencing the sync manager. + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Something went wrong when trying to upload events")))) + onSyncStatusAt(position = 2) + .check( + matches(withText(containsString("Something went wrong when trying to upload events"))) + ) + } } @Test fun testFragment_eventLogged_uploadError_anotherLogged_wait_profileDataIsUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.reportUploadError() - testCoroutineDispatchers.runCurrent() - - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.reportUploadError() + testCoroutineDispatchers.runCurrent() + + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_rotate_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_rotate_profileDataIsCurrentlyUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) + } } @Test fun testFragment_eventLogged_waitForUpload_rotate_profileDataIsUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_eventsLogged_uploadError_rotate_profileDataHasError() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Something went wrong when trying to upload events")))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() + + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() + + onSyncStatusAt(position = 2) + .check( + matches(withText(containsString("Something went wrong when trying to upload events"))) + ) + } } @Test @@ -753,127 +776,137 @@ class ProfileAndDeviceIdFragmentTest { // Use fake time so that the generated event logs are consistent across runs. fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) profileTestHelper.addMoreProfiles(numProfiles = 2) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log & upload some events, then enqueue others. - logThreeAnalyticsEvents(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - - onShareIdsAndEventsButtonAt(position = 5).perform(click()) - testCoroutineDispatchers.runCurrent() - - val expectedShareText = - """ - Oppia app installation ID: 113e04cc09a3 - - Profile name: Admin, learner ID: 8dcbbd21 - - Uploading learner events: 3 - - Uploaded learner events: 2 - - Uploading uncategorized events: 1 - - Uploaded uncategorized events: 4 - - Profile name: A, learner ID: 208663b0 - - Uploading learner events: 2 - - Uploaded learner events: 1 - - Profile name: B, learner ID: 92d0c6e2 - - Uploading learner events: 1 - - Uploaded learner events: 2 - Current sync status: Waiting to schedule data uploading worker…. - Event log encoding integrity checks: - - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY - - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 - - Total event string length (unwrapped): 140 - Encoded event logs: - H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ - gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - """.trimIndent() - val intents = getIntents() - assertThat(intents).hasSize(1) - assertThat(intents.single()).hasAction(Intent.ACTION_SEND) - assertThat(intents.single()).hasType("text/plain") - assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) - assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Log & upload some events, then enqueue others. + logThreeAnalyticsEvents(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + + onShareIdsAndEventsButtonAt(position = 5).perform(click()) + testCoroutineDispatchers.runCurrent() + + val expectedShareText = + """ + Oppia app installation ID: 113e04cc09a3 + - Profile name: Admin, learner ID: 8dcbbd21 + - Uploading learner events: 3 + - Uploaded learner events: 2 + - Uploading uncategorized events: 1 + - Uploaded uncategorized events: 4 + - Profile name: A, learner ID: 208663b0 + - Uploading learner events: 2 + - Uploaded learner events: 1 + - Profile name: B, learner ID: 92d0c6e2 + - Uploading learner events: 1 + - Uploaded learner events: 2 + Current sync status: Waiting to schedule data uploading worker…. + Event log encoding integrity checks: + - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY + - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 + - Total event string length (unwrapped): 140 + Encoded event logs: + H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ + gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + """.trimIndent() + val intents = getIntents() + assertThat(intents).hasSize(1) + assertThat(intents.single()).hasAction(Intent.ACTION_SEND) + assertThat(intents.single()).hasType("text/plain") + assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) + assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + } } @Test fun testFragment_noEventsPending_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // The upload button should be disabled when there are no events to upload. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + // The upload button should be disabled when there are no events to upload. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + } } @Test fun testFragment_multipleEventsPending_noConnection_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // The button is still disabled since there's no internet connection. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + // The button is still disabled since there's no internet connection. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + } } @Test fun testFragment_multipleEventsPending_uploadLogsButtonEnabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - // With events pending & connectivity, the upload button should now be available to press. - onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) + // With events pending & connectivity, the upload button should now be available to press. + onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) + } } @Test fun testFragment_multipleEventsPending_clickUploadLogs_wait_uploadsEventLogs() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - fakeAnalyticsEventLogger.clearAllEvents() - - // Click the 'upload logs' button and wait. - onUploadLogsButtonAt(position = 4).perform(click()) - testCoroutineDispatchers.runCurrent() - - // The events should be uploaded. - assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + fakeAnalyticsEventLogger.clearAllEvents() + + // Click the 'upload logs' button and wait. + onUploadLogsButtonAt(position = 4).perform(click()) + testCoroutineDispatchers.runCurrent() + + // The events should be uploaded. + assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + } } - private fun initializeActivityAndAddFragment() { - activityRule.scenario.onActivity { activity -> - activity.setContentView(R.layout.test_activity) - - activity.supportFragmentManager.beginTransaction() - .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) - .commitNow() + private fun runWithLaunchedActivityAndAddedFragment( + testBlock: ActivityScenario.() -> Unit + ) { + ActivityScenario.launch(TestActivity.createIntent(context)).use { scenario -> + scenario.onActivity { activity -> + activity.setContentView(R.layout.test_activity) + + activity.supportFragmentManager.beginTransaction() + .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) + .commitNow() + } + connectNetwork() // Start with internet connectivity. + testCoroutineDispatchers.runCurrent() + scenario.testBlock() } - connectNetwork() // Start with internet connectivity. - testCoroutineDispatchers.runCurrent() } private fun scrollTo(position: Int) { diff --git a/scripts/assets/file_content_validation_checks.textproto b/scripts/assets/file_content_validation_checks.textproto index 677e7ebcb9e..817a9a5e7ee 100644 --- a/scripts/assets/file_content_validation_checks.textproto +++ b/scripts/assets/file_content_validation_checks.textproto @@ -498,3 +498,90 @@ file_content_checks { failure_message: "Badly formatted KDoc. Single-line KDocs should end with punctuation." exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" } +file_content_checks { + file_path_regex: ".+?Test\\.kt" + prohibited_content_regex: "androidx.test.rule.ActivityTestRule" + failure_message: "ActivityTestRule is deprecated since it operates test activities in sometimes unsafe situations. Use ActivityScenario, instead." + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt" + exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" +} +file_content_checks { + file_path_regex: ".+?Test\\.kt" + prohibited_content_regex: "androidx.test.ext.junit.rules.ActivityScenarioRule" + failure_message: "ActivityScenarioRule can result in order dependence when static state leaks across tests (such as static module variables), and can make staging much more difficult for platform parameters. Use ActivityScenario directly, instead." + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt" + exempted_file_name: "domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt" + exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" + exempted_file_name: "testing/src/test/java/org/oppia/android/testing/espresso/TextInputActionTest.kt" +} diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index c555f4cba76..707a2cf7e2a 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -209,6 +209,13 @@ class RegexPatternValidationCheckTest { " should immediately follow the at-clause without any additional linking with brackets." private val badSingleLineKdocShouldEndWithPunctuation = "Badly formatted KDoc. Single-line KDocs should end with punctuation." + private val activityTestRuleShouldNotBeUsed = + "ActivityTestRule is deprecated since it operates test activities in sometimes unsafe" + + " situations. Use ActivityScenario, instead." + private val activityScenarioRuleShouldNotBeUsed = + "ActivityScenarioRule can result in order dependence when static state leaks across tests" + + " (such as static module variables), and can make staging much more difficult for platform" + + " parameters. Use ActivityScenario directly, instead." private val wikiReferenceNote = "Refer to https://github.com/oppia/oppia-android/wiki/Static-Analysis-Checks" + "#regexpatternvalidation-check for more details on how to fix this." @@ -2649,6 +2656,50 @@ class RegexPatternValidationCheckTest { ) } + @Test + fun testFileContent_referencesActivityTestRule_fileContentIsNotCorrect() { + val prohibitedContent = + """ + import androidx.test.rule.ActivityTestRule + """.trimIndent() + tempFolder.newFolder("testfiles", "app", "src", "test", "java", "org", "oppia", "android") + val stringFilePath = "app/src/test/java/org/oppia/android/PresenterTest.kt" + tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) + + val exception = assertThrows() { runScript() } + + assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) + assertThat(outContent.toString().trim()) + .isEqualTo( + """ + $stringFilePath:1: $activityTestRuleShouldNotBeUsed + $wikiReferenceNote + """.trimIndent() + ) + } + + @Test + fun testFileContent_referencesActivityScenarioRule_fileContentIsNotCorrect() { + val prohibitedContent = + """ + import androidx.test.ext.junit.rules.ActivityScenarioRule + """.trimIndent() + tempFolder.newFolder("testfiles", "app", "src", "test", "java", "org", "oppia", "android") + val stringFilePath = "app/src/test/java/org/oppia/android/PresenterTest.kt" + tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) + + val exception = assertThrows() { runScript() } + + assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) + assertThat(outContent.toString().trim()) + .isEqualTo( + """ + $stringFilePath:1: $activityScenarioRuleShouldNotBeUsed + $wikiReferenceNote + """.trimIndent() + ) + } + /** Runs the regex_pattern_validation_check. */ private fun runScript() { main(File(tempFolder.root, "testfiles").absolutePath) From 7488b9f8d0dd90bddc471679949a735221d6e667 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 13 Sep 2023 23:59:47 +0000 Subject: [PATCH 04/21] Fix broken ProfileAndDeviceIdFragmentTest test. The test was suffering from some proto encoding inconsistencies that seem to occur between some development machines vs. on CI. The fix improves the test's robustness by extracting the raw encoded string, verifying that the other outputs in the intent message correctly correspond to that string, and that the string (as a parsed proto) contains the correct values. As a result, the test no longer depends on a hardcoded encoding value to be present for verification. This does result in a bit more logic than is generally good to have in a test (and it lengthened the test code quite a bit), but it seems necessary in this particular case. --- .../learneranalytics/BUILD.bazel | 1 + .../ProfileAndDeviceIdFragmentTest.kt | 104 ++++++++++++++++-- scripts/assets/todo_open_exemptions.textproto | 48 ++++---- .../testing/logging/EventLogSubject.kt | 7 ++ 4 files changed, 125 insertions(+), 35 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel index f98a384b911..da61bfc0e69 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel @@ -51,6 +51,7 @@ app_test( "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:initialize_default_locale_rule", + "//testing/src/main/java/org/oppia/android/testing/logging:event_log_subject", "//testing/src/main/java/org/oppia/android/testing/logging:sync_status_test_module", "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index b7e883989f8..ae4e10ff244 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -56,6 +56,7 @@ import org.oppia.android.app.application.ApplicationStartupListenerModule import org.oppia.android.app.application.testing.TestingBuildFlavorModule import org.oppia.android.app.devoptions.DeveloperOptionsModule import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule +import org.oppia.android.app.model.OppiaEventLogs import org.oppia.android.app.model.ProfileId import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.atPositionOnView @@ -103,6 +104,9 @@ import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule +import org.oppia.android.testing.logging.EventLogSubject +import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat +import org.oppia.android.testing.logging.EventLogSubject.LearnerDetailsContextSubject import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.logging.TestSyncStatusManager import org.oppia.android.testing.platformparameter.TestPlatformParameterModule @@ -117,6 +121,7 @@ import org.oppia.android.util.caching.AssetModule import org.oppia.android.util.caching.testing.CachingTestModule import org.oppia.android.util.gcsresource.GcsResourceModule import org.oppia.android.util.locale.LocaleProdModule +import org.oppia.android.util.locale.OppiaLocale import org.oppia.android.util.logging.EventLoggingConfigurationModule import org.oppia.android.util.logging.LoggerModule import org.oppia.android.util.logging.SyncStatusManager.SyncStatus @@ -130,7 +135,10 @@ import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode +import java.security.MessageDigest +import java.util.Base64 import java.util.concurrent.TimeUnit +import java.util.zip.GZIPInputStream import javax.inject.Inject import javax.inject.Singleton @@ -158,6 +166,7 @@ class ProfileAndDeviceIdFragmentTest { @Inject lateinit var syncStatusManager: TestSyncStatusManager @Inject lateinit var learnerAnalyticsLogger: LearnerAnalyticsLogger @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger + @Inject lateinit var machineLocale: OppiaLocale.MachineLocale private val clipboardManager by lazy { context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager @@ -795,7 +804,7 @@ class ProfileAndDeviceIdFragmentTest { onShareIdsAndEventsButtonAt(position = 5).perform(click()) testCoroutineDispatchers.runCurrent() - val expectedShareText = + val expectedShareTextPattern = """ Oppia app installation ID: 113e04cc09a3 - Profile name: Admin, learner ID: 8dcbbd21 @@ -811,20 +820,49 @@ class ProfileAndDeviceIdFragmentTest { - Uploaded learner events: 2 Current sync status: Waiting to schedule data uploading worker…. Event log encoding integrity checks: - - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY - - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 - - Total event string length (unwrapped): 140 - Encoded event logs: - H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ - gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - """.trimIndent() + - First 40 chars of encoded string: ([\p{Alnum}/\\+=]+) + - Last 40 chars of encoded string: ([\p{Alnum}/\\+=]+) + - SHA-1 hash \(unwrapped event string\): (\p{XDigit}+) + - Total event string length \(unwrapped\): (\p{Digit}+) + Encoded event logs:([\p{Alnum}/+=\p{Space}]+) + """.trimIndent().toRegex() val intents = getIntents() + val extraText = intents.singleOrNull()?.getStringExtra(Intent.EXTRA_TEXT) assertThat(intents).hasSize(1) assertThat(intents.single()).hasAction(Intent.ACTION_SEND) assertThat(intents.single()).hasType("text/plain") assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) - assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + assertThat(extraText).matches(expectedShareTextPattern.toPattern()) + val (encodingPrefix, encodingSuffix, shaHash, encodingLength, rawEncodedLogs) = + extraText?.let { expectedShareTextPattern.matchEntire(it) }?.destructured!! + val unwrappedEncodedLogs = rawEncodedLogs.trim().replace(" ", "").replace("\n", "") + // Verify that the correct _values_ are being outputted, even if the specific values might + // differ slightly (depending on the running platform). + assertThat(encodingPrefix).isEqualTo(unwrappedEncodedLogs.take(40)) + assertThat(encodingSuffix).isEqualTo(unwrappedEncodedLogs.takeLast(40)) + assertThat(shaHash).isEqualTo(unwrappedEncodedLogs.computeSha1Hash()) + assertThat(encodingLength.toInt()).isEqualTo(unwrappedEncodedLogs.length) + // Verify the encoded events themselves are correct by decoding them and analyzing the loaded + // proto (since the string can vary somewhat). + val eventLogs = decodeEventLogString(unwrappedEncodedLogs) + assertThat(eventLogs.eventLogsToUploadCount).isEqualTo(7) + assertThat(eventLogs.uploadedEventLogsCount).isEqualTo(9) + assertThat(eventLogs.eventLogsToUploadList[0]).hasCommonPropsWithNoProfileId() + assertThat(eventLogs.eventLogsToUploadList[1]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.eventLogsToUploadList[2]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.eventLogsToUploadList[3]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.eventLogsToUploadList[4]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_0) + assertThat(eventLogs.eventLogsToUploadList[5]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_0) + assertThat(eventLogs.eventLogsToUploadList[6]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_1) + assertThat(eventLogs.uploadedEventLogsList[0]).hasCommonPropsWithNoProfileId() + assertThat(eventLogs.uploadedEventLogsList[1]).hasCommonPropsWithNoProfileId() + assertThat(eventLogs.uploadedEventLogsList[2]).hasCommonPropsWithNoProfileId() + assertThat(eventLogs.uploadedEventLogsList[3]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.uploadedEventLogsList[4]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.uploadedEventLogsList[5]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_0) + assertThat(eventLogs.uploadedEventLogsList[6]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_1) + assertThat(eventLogs.uploadedEventLogsList[7]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_1) + assertThat(eventLogs.uploadedEventLogsList[8]).hasCommonPropsWithNoProfileId() } } @@ -976,7 +1014,7 @@ class ProfileAndDeviceIdFragmentTest { private fun logAnalyticsEvent(profileId: ProfileId? = null) { learnerAnalyticsLogger.logAppInForeground( - installationId = "test_install_id", profileId, learnerId = "test_learner_id" + installationId = TEST_INSTALLATION_ID, profileId, learnerId = TEST_LEARNER_ID ) testCoroutineDispatchers.runCurrent() } @@ -1017,6 +1055,48 @@ class ProfileAndDeviceIdFragmentTest { disconnectNetwork() } + private fun String.computeSha1Hash(): String { + return machineLocale.run { + MessageDigest.getInstance("SHA-1") + .digest(this@computeSha1Hash.toByteArray()) + .joinToString("") { "%02x".formatForMachines(it) } + } + } + + private fun decodeEventLogString(encodedEventLogs: String): OppiaEventLogs { + return GZIPInputStream(Base64.getDecoder().decode(encodedEventLogs).inputStream()).use { inps -> + OppiaEventLogs.newBuilder().mergeFrom(inps).build() + } + } + + private fun EventLogSubject.hasCommonProperties() { + hasNoLanguageInformation() + hasTimestampThat().isEqualTo(0) + isEssentialPriority() + hasAppInForegroundContextThat().hasDefaultIds() + } + + private fun EventLogSubject.hasCommonPropsWithNoProfileId() { + hasCommonProperties() + hasNoProfileId() + } + + private fun EventLogSubject.hasCommonPropsWithProfile(profileId: ProfileId) { + hasCommonProperties() + hasProfileIdThat().isEqualTo(profileId) + } + + private fun EventLogSubject.hasNoLanguageInformation() { + hasAppLanguageSelectionThat().isEqualToDefaultInstance() + hasWrittenTranslationLanguageSelectionThat().isEqualToDefaultInstance() + hasAudioTranslationLanguageSelectionThat().isEqualToDefaultInstance() + } + + private fun LearnerDetailsContextSubject.hasDefaultIds() { + hasLearnerIdThat().isEqualTo(TEST_LEARNER_ID) + hasInstallationIdThat().isEqualTo(TEST_INSTALLATION_ID) + } + private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) } @@ -1091,6 +1171,8 @@ class ProfileAndDeviceIdFragmentTest { private companion object { private const val DEFAULT_APPLICATION_ID = 123456789L + private const val TEST_LEARNER_ID = "test_learner_id" + private const val TEST_INSTALLATION_ID = "test_install_id" private val ADMIN_PROFILE_ID = createProfileId(internalProfileId = 0) private val LEARNER_PROFILE_ID_0 = createProfileId(internalProfileId = 1) diff --git a/scripts/assets/todo_open_exemptions.textproto b/scripts/assets/todo_open_exemptions.textproto index 0fa81fd297d..51af8ca27ee 100644 --- a/scripts/assets/todo_open_exemptions.textproto +++ b/scripts/assets/todo_open_exemptions.textproto @@ -1,37 +1,37 @@ todo_open_exemption { exempted_file_path: "scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt" - line_number: 67 - line_number: 68 + line_number: 65 + line_number: 66 + line_number: 72 line_number: 74 - line_number: 76 + line_number: 96 + line_number: 97 line_number: 98 line_number: 99 line_number: 100 - line_number: 101 - line_number: 102 + line_number: 132 + line_number: 133 line_number: 136 - line_number: 137 - line_number: 140 - line_number: 173 + line_number: 167 + line_number: 168 + line_number: 169 line_number: 174 - line_number: 175 - line_number: 180 - line_number: 182 - line_number: 221 + line_number: 176 + line_number: 213 + line_number: 214 + line_number: 215 + line_number: 220 line_number: 222 - line_number: 223 line_number: 228 - line_number: 230 - line_number: 236 - line_number: 275 - line_number: 279 - line_number: 317 - line_number: 318 - line_number: 322 - line_number: 371 - line_number: 372 - line_number: 373 - line_number: 377 + line_number: 265 + line_number: 269 + line_number: 307 + line_number: 308 + line_number: 312 + line_number: 359 + line_number: 360 + line_number: 361 + line_number: 365 } todo_open_exemption { exempted_file_path: "scripts/src/javatests/org/oppia/android/scripts/todo/TodoCollectorTest.kt" diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index cbd7163ce19..fd8b539e06c 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -96,6 +96,13 @@ class EventLogSubject private constructor( assertThat(actual.priority).isEqualTo(EventLog.Priority.OPTIONAL) } + /** + * Verifies that the [EventLog] under test has no profile ID defined per [EventLog.getProfileId]. + */ + fun hasNoProfileId() { + assertThat(actual.hasProfileId()).isFalse() + } + /** * Returns an [LiteProtoSubject] to verify the under-test [EventLog]'s [EventLog.getProfileId] * field. From 5671673175891d0491280b901d3f8b53802d3e7d Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 26 Oct 2023 18:40:57 +0000 Subject: [PATCH 05/21] Post-merge fix. --- .../android/scripts/regex/RegexPatternValidationCheckTest.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index a862d2f5114..a3eb9c825d9 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -2209,9 +2209,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/drawable/test_layout.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) From 4689609b34aec358da24518cef575b7b2f66337b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 27 Dec 2023 17:17:25 -0800 Subject: [PATCH 06/21] Fix API 21-23 (incl.) crash. The main problem was the use of computeIfAbsent() which is a Java 8 API that does NOT desugar during building, and Java 8 APIs are only available on SDK 24+. The actual fix introduced a lot of complexity when working with locale profiles since the utilization of memoized locale profiles now requires using a coroutine to ensure thread safety (i.e. by leveraging a blocking dispatcher). This introduced some complexity in the process for creating locales since a livelock was possible when trying to use the blocking dispatcher for the system locale (since a blocking dispatcher is used farther up in its call chain). Due to these changes, a refactor of AndroidLocaleProfile has been included to largely simplify a lot of the previous complexity around the different states the class could take (these are now explicitly defined as separate subclasses to the now sealed class AndroidLocaleProfile). DataProviders.transformAsync() has also been updated to handle caught exceptions in much the same way as transform(). This helped during debugging the original crash, so it seems like a good idea to include. --- .../android/domain/locale/LocaleController.kt | 46 +- .../domain/locale/LocaleControllerTest.kt | 29 +- .../file_content_validation_checks.textproto | 7 + .../regex/RegexPatternValidationCheckTest.kt | 25 + .../oppia/android/util/data/DataProviders.kt | 8 +- .../util/locale/AndroidLocaleFactory.kt | 190 ++--- .../util/locale/AndroidLocaleProfile.kt | 207 +++++- .../org/oppia/android/util/locale/BUILD.bazel | 3 + .../android/util/locale/DisplayLocaleImpl.kt | 12 +- .../android/util/data/DataProvidersTest.kt | 34 + .../util/locale/AndroidLocaleFactoryTest.kt | 231 +++--- .../util/locale/AndroidLocaleProfileTest.kt | 656 ++++++++++++++---- .../org/oppia/android/util/locale/BUILD.bazel | 4 + .../util/locale/DisplayLocaleImplTest.kt | 24 +- .../html/CustomHtmlContentHandlerTest.kt | 6 +- .../util/parser/html/LiTagHandlerTest.kt | 6 +- 16 files changed, 1096 insertions(+), 392 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/locale/LocaleController.kt b/domain/src/main/java/org/oppia/android/domain/locale/LocaleController.kt index 51be2481321..0eeb999c8fe 100644 --- a/domain/src/main/java/org/oppia/android/domain/locale/LocaleController.kt +++ b/domain/src/main/java/org/oppia/android/domain/locale/LocaleController.kt @@ -62,7 +62,8 @@ class LocaleController @Inject constructor( private val asyncDataSubscriptionManager: AsyncDataSubscriptionManager, private val machineLocale: MachineLocale, private val androidLocaleFactory: AndroidLocaleFactory, - private val formatterFactory: OppiaBidiFormatter.Factory + private val formatterFactory: OppiaBidiFormatter.Factory, + private val androidLocaleProfileFactory: AndroidLocaleProfile.Factory ) { private val definitionsLock = ReentrantLock() private lateinit var supportedLanguages: SupportedLanguages @@ -115,9 +116,8 @@ class LocaleController @Inject constructor( * for cases in which the user changed their selected language). */ fun reconstituteDisplayLocale(oppiaLocaleContext: OppiaLocaleContext): DisplayLocale { - return DisplayLocaleImpl( - oppiaLocaleContext, machineLocale, androidLocaleFactory, formatterFactory - ) + val formattingLocale = androidLocaleFactory.createOneOffAndroidLocale(oppiaLocaleContext) + return DisplayLocaleImpl(oppiaLocaleContext, formattingLocale, machineLocale, formatterFactory) } /** @@ -257,7 +257,7 @@ class LocaleController @Inject constructor( private fun getSystemLocaleProfile(): DataProvider { return dataProviders.createInMemoryDataProvider(ANDROID_SYSTEM_LOCALE_DATA_PROVIDER_ID) { - AndroidLocaleProfile.createFrom(getSystemLocale()) + androidLocaleProfileFactory.createFrom(getSystemLocale()) } } @@ -293,7 +293,7 @@ class LocaleController @Inject constructor( @Suppress("DEPRECATION") // Old API is needed for SDK versions < N. private fun getDefaultLocale(configuration: Configuration): Locale = configuration.locale - private suspend fun computeLocaleResult( + private suspend inline fun computeLocaleResult( language: OppiaLanguage, systemLocaleProfile: AndroidLocaleProfile, usageMode: LanguageUsageMode @@ -302,7 +302,6 @@ class LocaleController @Inject constructor( // internal weirdness that would lead to a wrong type being produced from the generic helpers. // This shouldn't actually ever happen in practice, but this code gracefully fails to a null // (and thus a failure). - @Suppress("UNCHECKED_CAST") // as? should always be a safe cast, even if unchecked. val locale = computeLocale(language, systemLocaleProfile, usageMode) as? T return locale?.let { AsyncResult.Success(it) @@ -324,7 +323,13 @@ class LocaleController @Inject constructor( retrieveLanguageDefinition(languageDefinition.fallbackMacroLanguage)?.let { fallbackLanguageDefinition = it } - regionDefinition = retrieveRegionDefinition(systemLocaleProfile.regionCode) + val regionCode = when (systemLocaleProfile) { + is AndroidLocaleProfile.LanguageAndRegionProfile -> systemLocaleProfile.regionCode + is AndroidLocaleProfile.RegionOnlyProfile -> systemLocaleProfile.regionCode + is AndroidLocaleProfile.LanguageAndWildcardRegionProfile, + is AndroidLocaleProfile.LanguageOnlyProfile, is AndroidLocaleProfile.RootProfile -> "" + } + regionDefinition = retrieveRegionDefinition(regionCode) this.usageMode = usageMode }.build() @@ -343,8 +348,10 @@ class LocaleController @Inject constructor( } return when (usageMode) { - APP_STRINGS -> - DisplayLocaleImpl(localeContext, machineLocale, androidLocaleFactory, formatterFactory) + APP_STRINGS -> { + val formattingLocale = androidLocaleFactory.createAndroidLocaleAsync(localeContext).await() + DisplayLocaleImpl(localeContext, formattingLocale, machineLocale, formatterFactory) + } CONTENT_STRINGS, AUDIO_TRANSLATIONS -> ContentLocaleImpl(localeContext) USAGE_MODE_UNSPECIFIED, UNRECOGNIZED -> null } @@ -413,9 +420,7 @@ class LocaleController @Inject constructor( return@mapNotNull definition.retrieveAppLanguageProfile()?.let { profile -> profile to definition } - }.find { (profile, _) -> - localeProfile.matches(machineLocale, profile) - }?.let { (_, definition) -> definition } + }.find { (profile, _) -> localeProfile.matches(profile) }?.let { (_, definition) -> definition } } private suspend fun retrieveRegionDefinition(countryCode: String): RegionSupportDefinition { @@ -431,7 +436,7 @@ class LocaleController @Inject constructor( } ?: RegionSupportDefinition.newBuilder().apply { region = OppiaRegion.REGION_UNSPECIFIED regionId = RegionSupportDefinition.IetfBcp47RegionId.newBuilder().apply { - ietfRegionTag = countryCode + ietfRegionTag = machineLocale.run { countryCode.toMachineUpperCase() } }.build() }.build() } @@ -455,10 +460,10 @@ class LocaleController @Inject constructor( private fun LanguageSupportDefinition.retrieveAppLanguageProfile(): AndroidLocaleProfile? { return when (appStringId.languageTypeCase) { LanguageSupportDefinition.LanguageId.LanguageTypeCase.IETF_BCP47_ID -> - AndroidLocaleProfile.createFromIetfDefinitions(appStringId, regionDefinition = null) + androidLocaleProfileFactory.createFromIetfDefinitions(appStringId, regionDefinition = null) LanguageSupportDefinition.LanguageId.LanguageTypeCase.MACARONIC_ID -> { // Likely won't match against system languages. - AndroidLocaleProfile.createFromMacaronicLanguage(appStringId) + androidLocaleProfileFactory.createFromMacaronicLanguage(appStringId) } LanguageSupportDefinition.LanguageId.LanguageTypeCase.LANGUAGETYPE_NOT_SET, null -> null } @@ -473,9 +478,12 @@ class LocaleController @Inject constructor( // must be part of the language definitions. Support for app strings is exposed so that a locale // can be constructed from it. appStringId = LanguageSupportDefinition.LanguageId.newBuilder().apply { - ietfBcp47Id = LanguageSupportDefinition.IetfBcp47LanguageId.newBuilder().apply { - ietfLanguageTag = systemLocaleProfile.computeIetfLanguageTag() - }.build() + // The root profile is assumed if there is no specific language ID to use. + if (systemLocaleProfile !is AndroidLocaleProfile.RootProfile) { + ietfBcp47Id = LanguageSupportDefinition.IetfBcp47LanguageId.newBuilder().apply { + ietfLanguageTag = systemLocaleProfile.ietfLanguageTag + }.build() + } }.build() }.build() diff --git a/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt index 098fcde27de..d1f2dc8c8b4 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt @@ -114,12 +114,16 @@ class LocaleControllerTest { } @Test - fun testReconstituteDisplayLocale_defaultContext_returnsDisplayLocaleForContext() { + fun testReconstituteDisplayLocale_defaultContext_throwsException() { val context = OppiaLocaleContext.getDefaultInstance() - val locale = localeController.reconstituteDisplayLocale(context) + val exception = assertThrows(IllegalStateException::class) { + localeController.reconstituteDisplayLocale(context) + } - assertThat(locale.localeContext).isEqualToDefaultInstance() + // A default locale context isn't valid by itself (though it can represent the root locale when + // at least the app strings context is present & default). + assertThat(exception).hasMessageThat().contains("Invalid language case") } @Test @@ -243,6 +247,25 @@ class LocaleControllerTest { assertThat(context.regionDefinition.regionId.ietfRegionTag).isEqualTo("MC") } + @Test + fun testAppStringLocale_rootLocale_defaultLang_returnsRootLocale() { + forceDefaultLocale(Locale.ROOT) + + val localeProvider = localeController.retrieveAppStringDisplayLocale(LANGUAGE_UNSPECIFIED) + + // The locale will be forced to the root locale. The root locale also should never provide an + // IETF BCP-47 ID. + val locale = monitorFactory.waitForNextSuccessfulResult(localeProvider) + val context = locale.localeContext + val languageDefinition = context.languageDefinition + assertThat(languageDefinition.language).isEqualTo(LANGUAGE_UNSPECIFIED) + assertThat(languageDefinition.fallbackMacroLanguage).isEqualTo(LANGUAGE_UNSPECIFIED) + assertThat(languageDefinition.appStringId.hasIetfBcp47Id()).isFalse() + assertThat(context.hasFallbackLanguageDefinition()).isFalse() + assertThat(context.regionDefinition.region).isEqualTo(REGION_UNSPECIFIED) + assertThat(context.regionDefinition.regionId.ietfRegionTag).isEmpty() + } + @Test fun testAppStringLocale_newSystemLocale_doesNotNotifyProvider() { forceDefaultLocale(Locale.US) diff --git a/scripts/assets/file_content_validation_checks.textproto b/scripts/assets/file_content_validation_checks.textproto index a53a46416f4..f820f478f57 100644 --- a/scripts/assets/file_content_validation_checks.textproto +++ b/scripts/assets/file_content_validation_checks.textproto @@ -511,3 +511,10 @@ file_content_checks { failure_message: "Badly formatted KDoc. Single-line KDocs should end with punctuation." exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" } +file_content_checks { + file_path_regex: ".+?\\.kt" + prohibited_content_regex: "computeIfAbsent\\(" + failure_message: "computeIfAbsent won't desugar and requires Java 8 support (SDK 24+). Suggest using an atomic Kotlin-specific solution, instead." + exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" + exempted_file_name: "utility/src/main/java/org/oppia/android/util/caching/testing/FakeAssetRepository.kt" +} diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index 20fd219f857..cdbc3dffc16 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -211,6 +211,9 @@ class RegexPatternValidationCheckTest { " should immediately follow the at-clause without any additional linking with brackets." private val badSingleLineKdocShouldEndWithPunctuation = "Badly formatted KDoc. Single-line KDocs should end with punctuation." + private val referenceComputeIfAbsent = + "computeIfAbsent won't desugar and requires Java 8 support (SDK 24+). Suggest using an atomic" + + " Kotlin-specific solution, instead." private val wikiReferenceNote = "Refer to https://github.com/oppia/oppia-android/wiki/Static-Analysis-Checks" + "#regexpatternvalidation-check for more details on how to fix this." @@ -2851,6 +2854,28 @@ class RegexPatternValidationCheckTest { ) } + @Test + fun testFileContent_includesReferenceToComputeIfAbsent_fileContentIsNotCorrect() { + val prohibitedContent = + """ + someMap.computeIfAbsent(key) { createOtherValue() } + """.trimIndent() + tempFolder.newFolder("testfiles", "app", "src", "main", "java", "org", "oppia", "android") + val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" + tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) + + val exception = assertThrows(Exception::class) { runScript() } + + assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) + assertThat(outContent.toString().trim()) + .isEqualTo( + """ + $stringFilePath:1: $referenceComputeIfAbsent + $wikiReferenceNote + """.trimIndent() + ) + } + /** Runs the regex_pattern_validation_check. */ private fun runScript() { main(File(tempFolder.root, "testfiles").absolutePath) diff --git a/utility/src/main/java/org/oppia/android/util/data/DataProviders.kt b/utility/src/main/java/org/oppia/android/util/data/DataProviders.kt index 93049848c3c..4c11876168e 100644 --- a/utility/src/main/java/org/oppia/android/util/data/DataProviders.kt +++ b/utility/src/main/java/org/oppia/android/util/data/DataProviders.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.transform import kotlinx.coroutines.launch +import org.oppia.android.util.data.DataProviders.Companion.transform import org.oppia.android.util.logging.ExceptionLogger import org.oppia.android.util.threading.BackgroundDispatcher import java.util.concurrent.atomic.AtomicBoolean @@ -74,7 +75,12 @@ class DataProviders @Inject constructor( override fun getId(): Any = newId override suspend fun retrieveData(): AsyncResult { - return this@transformAsync.retrieveData().transformAsync(function) + return try { + this@transformAsync.retrieveData().transformAsync(function) + } catch (e: Exception) { + dataProviders.exceptionLogger.logException(e) + AsyncResult.Failure(e) + } } } } diff --git a/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt b/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt index ffe3e186646..cdca0c68136 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt @@ -1,6 +1,10 @@ package org.oppia.android.util.locale import android.os.Build +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.async import org.oppia.android.app.model.LanguageSupportDefinition import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId.LanguageTypeCase.IETF_BCP47_ID @@ -9,8 +13,8 @@ import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId.Language import org.oppia.android.app.model.OppiaLocaleContext import org.oppia.android.app.model.OppiaLocaleContext.LanguageUsageMode import org.oppia.android.app.model.OppiaLocaleContext.LanguageUsageMode.APP_STRINGS +import org.oppia.android.util.threading.BlockingDispatcher import java.util.Locale -import java.util.concurrent.ConcurrentHashMap import javax.inject.Inject import javax.inject.Singleton @@ -20,9 +24,28 @@ import javax.inject.Singleton */ @Singleton class AndroidLocaleFactory @Inject constructor( - private val profileChooserSelector: ProposalChooser.Selector + private val profileChooserSelector: ProposalChooser.Selector, + @BlockingDispatcher private val blockingDispatcher: CoroutineDispatcher, + private val androidLocaleProfileFactory: AndroidLocaleProfile.Factory ) { - private val memoizedLocales by lazy { ConcurrentHashMap() } + private val memoizedLocales = mutableMapOf() + + /** + * Creates and returns a new [Locale] that matches the given [OppiaLocaleContext]. + * + * See [createAndroidLocaleAsync] for specifics. Note that this function, unlike the async + * version, does **not** cache or try to load a pre-created [Locale] for the given context. + * Creating new [Locale]s can be expensive, so it's always preferred to use + * [createAndroidLocaleAsync] except in cases where that isn't an option. + */ + fun createOneOffAndroidLocale(localeContext: OppiaLocaleContext): Locale { + val chooser = profileChooserSelector.findBestChooser(localeContext) + val primaryLocaleSource = + LocaleSource.createFromPrimary(localeContext, androidLocaleProfileFactory) + val fallbackLocaleSource = + LocaleSource.createFromFallback(localeContext, androidLocaleProfileFactory) + return chooser.findBestProposal(primaryLocaleSource, fallbackLocaleSource).computedLocale + } /** * Creates a new [Locale] that matches the given [OppiaLocaleContext]. @@ -50,18 +73,17 @@ class AndroidLocaleFactory @Inject constructor( * - For other locale-based operations, the forced [Locale] will behave like the system's * [Locale.ROOT]. * + * Note that the returned [Locale] may be cached within the factory for performance reasons, so + * the returned value use a [Deferred] to ensure that this method can guarantee thread-safe + * access. + * * @param localeContext the [OppiaLocaleContext] to use as a basis for finding a similar [Locale] * @return the best [Locale] to match the provided [localeContext] */ - fun createAndroidLocale(localeContext: OppiaLocaleContext): Locale { - // Note: computeIfAbsent is used here instead of getOrPut to ensure atomicity across multiple - // threads calling into this create function. - return memoizedLocales.computeIfAbsent(localeContext) { - val chooser = profileChooserSelector.findBestChooser(localeContext) - val primaryLocaleSource = LocaleSource.createFromPrimary(localeContext) - val fallbackLocaleSource = LocaleSource.createFromFallback(localeContext) - val proposal = chooser.findBestProposal(primaryLocaleSource, fallbackLocaleSource) - return@computeIfAbsent proposal.computedLocale + fun createAndroidLocaleAsync(localeContext: OppiaLocaleContext): Deferred { + // A blocking dispatcher is used to ensure thread safety when updating the locales map. + return CoroutineScope(blockingDispatcher).async { + memoizedLocales.getOrPut(localeContext) { createOneOffAndroidLocale(localeContext) } } } @@ -76,21 +98,17 @@ class AndroidLocaleFactory @Inject constructor( /** * A computed [Locale] that most closely represents the [AndroidLocaleProfile] of this proposal. */ - val computedLocale: Locale - get() = Locale(profile.languageCode, profile.getNonWildcardRegionCode()) + val computedLocale: Locale by lazy { profile.computeAndroidLocale() } /** * Determines whether the [AndroidLocaleProfile] of this proposal is a viable choice for using * to compute a [Locale] (e.g. via [computedLocale]). * - * @param machineLocale the app's [OppiaLocale.MachineLocale] - * @param systemProfiles [AndroidLocaleProfile]s representing the system's available locales + * @param localeProfileRepository the [LocaleProfileRepository]s representing the system's + * available locales * @return whether this proposal has a viable profile for creating a [Locale] */ - abstract fun isViable( - machineLocale: OppiaLocale.MachineLocale, - systemProfiles: List - ): Boolean + abstract fun isViable(localeProfileRepository: LocaleProfileRepository): Boolean /** * A [LocaleProfileProposal] that is only viable if its [profile] is among the available system @@ -101,10 +119,9 @@ class AndroidLocaleFactory @Inject constructor( val minAndroidSdkVersion: Int ) : LocaleProfileProposal() { override fun isViable( - machineLocale: OppiaLocale.MachineLocale, - systemProfiles: List + localeProfileRepository: LocaleProfileRepository ): Boolean { - return systemProfiles.any { it.matches(machineLocale, profile) } && + return localeProfileRepository.availableLocaleProfiles.any { it.matches(profile) } && minAndroidSdkVersion <= Build.VERSION.SDK_INT } } @@ -119,15 +136,8 @@ class AndroidLocaleFactory @Inject constructor( override val profile: AndroidLocaleProfile, val minAndroidSdkVersion: Int ) : LocaleProfileProposal() { - override fun isViable( - machineLocale: OppiaLocale.MachineLocale, - systemProfiles: List - ): Boolean = minAndroidSdkVersion <= Build.VERSION.SDK_INT - } - - private companion object { - private fun AndroidLocaleProfile.getNonWildcardRegionCode(): String = - regionCode.takeIf { it != AndroidLocaleProfile.REGION_WILDCARD } ?: "" + override fun isViable(localeProfileRepository: LocaleProfileRepository): Boolean = + minAndroidSdkVersion <= Build.VERSION.SDK_INT } } @@ -143,7 +153,8 @@ class AndroidLocaleFactory @Inject constructor( class LocaleSource private constructor( private val localeContext: OppiaLocaleContext, private val definition: LanguageSupportDefinition, - private val languageId: LanguageId + private val languageId: LanguageId, + private val androidLocaleProfileFactory: AndroidLocaleProfile.Factory ) { private val regionDefinition by lazy { localeContext.regionDefinition.takeIf { localeContext.hasRegionDefinition() } @@ -156,7 +167,7 @@ class AndroidLocaleFactory @Inject constructor( */ fun computeSystemMatchingProposals(): List { return listOfNotNull( - computeLocaleProfileFromAndroidId()?.toSystemProposal(), + createAndroidResourcesProfile()?.toSystemProposal(), createIetfProfile()?.toSystemProposal(), createMacaronicProfile()?.toSystemProposal() ) @@ -169,7 +180,7 @@ class AndroidLocaleFactory @Inject constructor( * configured for this source's context. */ fun computeForcedAndroidProposal(): LocaleProfileProposal? = - computeLocaleProfileFromAndroidId()?.toForcedProposal() + createAndroidResourcesProfile()?.toForcedProposal() /** * Returns a [LocaleProfileProposal] representing a [LocaleProfileProposal.ForcedProposal] that @@ -177,37 +188,33 @@ class AndroidLocaleFactory @Inject constructor( * * Note that the returned proposal will prioritize its Android ID configuration over * alternatives (such as IETF BCP 47 or a macaronic language configuration). + * + * @param allowRootProfile whether to return a [AndroidLocaleProfile.RootProfile] for cases when + * a valid proposal cannot be determined rather than throwing an exception */ - fun computeForcedProposal(): LocaleProfileProposal = - computeForcedAndroidProposal() ?: languageId.toForcedProposal() - - private fun computeLocaleProfileFromAndroidId(): AndroidLocaleProfile? { - return languageId.androidResourcesLanguageId.takeIf { - languageId.hasAndroidResourcesLanguageId() && it.languageCode.isNotEmpty() - }?.let { - // Empty region codes are allowed for Android resource IDs since they should always be used - // verbatim to ensure the correct Android resource string can be computed (such as for macro - // languages). - AndroidLocaleProfile( - it.languageCode, - regionCode = it.regionCode.ifEmpty { AndroidLocaleProfile.REGION_WILDCARD } - ) - } - } + fun computeForcedProposal(allowRootProfile: Boolean): LocaleProfileProposal = + computeForcedAndroidProposal() ?: toForcedProposal(allowRootProfile) - private fun LanguageId.toForcedProposal(): LocaleProfileProposal { - return when (languageId.languageTypeCase) { + private fun toForcedProposal(allowRootProfile: Boolean): LocaleProfileProposal { + return when (val languageTypeCase = languageId.languageTypeCase) { IETF_BCP47_ID -> createIetfProfile().expectedProfile() MACARONIC_ID -> createMacaronicProfile().expectedProfile() - LANGUAGETYPE_NOT_SET, null -> error("Invalid language case: $languageTypeCase.") + LANGUAGETYPE_NOT_SET, null -> { + if (allowRootProfile) { + AndroidLocaleProfile.RootProfile + } else error("Invalid language case: $languageTypeCase.") + } }.toForcedProposal() } private fun createIetfProfile(): AndroidLocaleProfile? = - AndroidLocaleProfile.createFromIetfDefinitions(languageId, regionDefinition) + androidLocaleProfileFactory.createFromIetfDefinitions(languageId, regionDefinition) private fun createMacaronicProfile(): AndroidLocaleProfile? = - AndroidLocaleProfile.createFromMacaronicLanguage(languageId) + androidLocaleProfileFactory.createFromMacaronicLanguage(languageId) + + private fun createAndroidResourcesProfile(): AndroidLocaleProfile? = + androidLocaleProfileFactory.createFromAndroidResourcesLanguageId(languageId) private fun AndroidLocaleProfile?.expectedProfile() = this ?: error("Invalid ID: $languageId.") @@ -222,18 +229,31 @@ class AndroidLocaleFactory @Inject constructor( * Return a new [LocaleSource] that maps to [localeContext]'s primary language configuration * (i.e. fallback language details will be ignored). */ - fun createFromPrimary(localeContext: OppiaLocaleContext): LocaleSource = - LocaleSource(localeContext, localeContext.languageDefinition, localeContext.getLanguageId()) + fun createFromPrimary( + localeContext: OppiaLocaleContext, + androidLocaleProfileFactory: AndroidLocaleProfile.Factory + ): LocaleSource { + return LocaleSource( + localeContext, + localeContext.languageDefinition, + localeContext.getLanguageId(), + androidLocaleProfileFactory + ) + } /** * Return a new [LocaleSource] that maps to [localeContext]'s fallback (secondary) language * configuration (i.e. primary language details will be ignored). */ - fun createFromFallback(localeContext: OppiaLocaleContext): LocaleSource { + fun createFromFallback( + localeContext: OppiaLocaleContext, + androidLocaleProfileFactory: AndroidLocaleProfile.Factory + ): LocaleSource { return LocaleSource( localeContext, localeContext.fallbackLanguageDefinition, - localeContext.getFallbackLanguageId() + localeContext.getFallbackLanguageId(), + androidLocaleProfileFactory ) } } @@ -288,15 +308,15 @@ class AndroidLocaleFactory @Inject constructor( * system locales. */ class MatchedLocalePreferredChooser @Inject constructor( - private val machineLocale: OppiaLocale.MachineLocale + private val localeProfileRepository: LocaleProfileRepository ) : ProposalChooser { override fun findBestProposal( primarySource: LocaleSource, fallbackSource: LocaleSource ): LocaleProfileProposal { - return primarySource.computeSystemMatchingProposals().findFirstViable(machineLocale) - ?: fallbackSource.computeSystemMatchingProposals().findFirstViable(machineLocale) - ?: primarySource.computeForcedProposal() + return primarySource.computeSystemMatchingProposals().findFirstViable(localeProfileRepository) + ?: fallbackSource.computeSystemMatchingProposals().findFirstViable(localeProfileRepository) + ?: primarySource.computeForcedProposal(allowRootProfile = false) } } @@ -308,31 +328,43 @@ class AndroidLocaleFactory @Inject constructor( * [Locale]s produced by such profiles in order to correctly produce app UI strings. */ class AndroidResourceCompatibilityPreferredChooser @Inject constructor( - private val machineLocale: OppiaLocale.MachineLocale + private val localeProfileRepository: LocaleProfileRepository ) : ProposalChooser { override fun findBestProposal( primarySource: LocaleSource, fallbackSource: LocaleSource ): LocaleProfileProposal { - return primarySource.computeSystemMatchingProposals().findFirstViable(machineLocale) - ?: primarySource.computeForcedAndroidProposal()?.takeOnlyIfViable(machineLocale) - ?: fallbackSource.computeSystemMatchingProposals().findFirstViable(machineLocale) - ?: fallbackSource.computeForcedAndroidProposal()?.takeOnlyIfViable(machineLocale) - ?: primarySource.computeForcedProposal() + // Note that defaulting to the root locale only makes sense for app strings (since app strings + // are picked based on the configured system locale). + return primarySource.computeSystemMatchingProposals().findFirstViable(localeProfileRepository) + ?: primarySource.computeForcedAndroidProposal()?.takeOnlyIfViable(localeProfileRepository) + ?: fallbackSource.computeSystemMatchingProposals().findFirstViable(localeProfileRepository) + ?: fallbackSource.computeForcedAndroidProposal()?.takeOnlyIfViable(localeProfileRepository) + ?: primarySource.computeForcedProposal(allowRootProfile = true) } } - private companion object { - private val availableLocaleProfiles by lazy { - Locale.getAvailableLocales().map(AndroidLocaleProfile::createFrom) + /** + * An application-injectable repository storing all possible [AndroidLocaleProfile]s available to + * use on the local system for the lifetime of the current app instance. + */ + @Singleton + class LocaleProfileRepository @Inject constructor( + private val androidLocaleProfileFactory: AndroidLocaleProfile.Factory + ) { + /** + * All available [AndroidLocaleProfile]s that represent locales on the current running system. + */ + val availableLocaleProfiles: List by lazy { + Locale.getAvailableLocales().map { androidLocaleProfileFactory.createFrom(it) } } + } - private fun List.findFirstViable( - machineLocale: OppiaLocale.MachineLocale - ) = firstOrNull { it.isViable(machineLocale, availableLocaleProfiles) } + private companion object { + private fun List.findFirstViable(repository: LocaleProfileRepository) = + firstOrNull { it.isViable(repository) } - private fun LocaleProfileProposal.takeOnlyIfViable( - machineLocale: OppiaLocale.MachineLocale - ): LocaleProfileProposal? = takeIf { isViable(machineLocale, availableLocaleProfiles) } + private fun LocaleProfileProposal.takeOnlyIfViable(repository: LocaleProfileRepository) = + takeIf { isViable(repository) } } } diff --git a/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleProfile.kt b/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleProfile.kt index a410c2b06b6..9c96ec0f8fc 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleProfile.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleProfile.kt @@ -3,50 +3,156 @@ package org.oppia.android.util.locale import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId import org.oppia.android.app.model.RegionSupportDefinition import java.util.Locale +import javax.inject.Inject /** * A profile to represent an Android [Locale] object which can be used to easily compare different * locales (based on the properties the app cares about), or reconstruct a [Locale] object. * - * @property languageCode the IETF BCP 47 or ISO 639-2/3 language code - * @property regionCode the IETF BCP 47 or ISO 3166 alpha-2 region code + * Subclasses of this sealed class operate on a language code and/or region code. The language code + * is an IETF BCP 47 or ISO 639-2/3 language code, or empty if unknown or not specified. The region + * code is an IETF BCP 47 or ISO 3166 alpha-2 region code, or empty if unknown or not specified. + * + * New instances should be created using [Factory]. */ -data class AndroidLocaleProfile(val languageCode: String, val regionCode: String) { +sealed class AndroidLocaleProfile { + /** + * An IETF BCP 47-esque language tag that represents this locale profile. For profiles that have + * valid IETF BCP 47 language & region codes, the returned tag should be a valid IETF BCP 47 + * language tag. + */ + abstract val ietfLanguageTag: String + /** Returns whether this profile matches the specified [otherProfile] for the given locale. */ - fun matches( - machineLocale: OppiaLocale.MachineLocale, - otherProfile: AndroidLocaleProfile, - ): Boolean { - return machineLocale.run { - languageCode.equalsIgnoreCase(otherProfile.languageCode) - } && machineLocale.run { - val regionsAreEqual = regionCode.equalsIgnoreCase(otherProfile.regionCode) - val eitherRegionIsWildcard = - regionCode == REGION_WILDCARD || otherProfile.regionCode == REGION_WILDCARD - return@run regionsAreEqual || eitherRegionIsWildcard + abstract fun matches(otherProfile: AndroidLocaleProfile): Boolean + + /** Returns an Android [Locale] compatible with this profile. */ + abstract fun computeAndroidLocale(): Locale + + /** + * An [AndroidLocaleProfile] that provides both a non-empty language and region code. + * + * Note that, generally, this should never need to be created directly. Instead, [Factory] should + * be used to create new instances of profiles. + * + * @property languageCode the lowercase two-letter language code in this profile + * @property regionCode the lowercase two-letter region code in this profile + * @property regionCodeUpperCase the uppercase version of [regionCode] + */ + data class LanguageAndRegionProfile( + val languageCode: String, + val regionCode: String, + private val regionCodeUpperCase: String + ) : AndroidLocaleProfile() { + // The region code is usually uppercase in IETF BCP-47 tags when extending a language code. + override val ietfLanguageTag = "$languageCode-$regionCodeUpperCase" + + override fun matches(otherProfile: AndroidLocaleProfile): Boolean { + return when (otherProfile) { + is LanguageAndRegionProfile -> + languageCode == otherProfile.languageCode && regionCode == otherProfile.regionCode + is LanguageAndWildcardRegionProfile -> languageCode == otherProfile.languageCode + is LanguageOnlyProfile, is RegionOnlyProfile, is RootProfile -> false + } } + + override fun computeAndroidLocale(): Locale = Locale(languageCode, regionCode) } /** - * Returns an IETF BCP 47-esque language tag that represents this locale profile. For profiles - * that have valid IETF BCP 47 language & region codes, the returned tag should be a valid IETF - * BCP 47 language tag. + * An [AndroidLocaleProfile] that provides only a non-empty region code. + * + * Note that, generally, this should never need to be created directly. Instead, [Factory] should + * be used to create new instances of profiles. + * + * @property regionCode the lowercase two-letter region code in this profile */ - fun computeIetfLanguageTag(): String { - return when { - languageCode.isNotEmpty() && regionCode.isNotEmptyOrWildcard() -> "$languageCode-$regionCode" - regionCode.isNotEmptyOrWildcard() -> regionCode - else -> languageCode + data class RegionOnlyProfile(val regionCode: String) : AndroidLocaleProfile() { + override val ietfLanguageTag = regionCode + + override fun matches(otherProfile: AndroidLocaleProfile): Boolean = + otherProfile is RegionOnlyProfile && regionCode == otherProfile.regionCode + + override fun computeAndroidLocale(): Locale = Locale(/* language = */ "", regionCode) + } + + /** + * An [AndroidLocaleProfile] that provides only a non-empty language code. + * + * Note that, generally, this should never need to be created directly. Instead, [Factory] should + * be used to create new instances of profiles. + * + * @property languageCode the lowercase two-letter language code in this profile + */ + data class LanguageOnlyProfile(val languageCode: String) : AndroidLocaleProfile() { + override val ietfLanguageTag = languageCode + + override fun matches(otherProfile: AndroidLocaleProfile): Boolean { + return when (otherProfile) { + is LanguageOnlyProfile -> languageCode == otherProfile.languageCode + is LanguageAndWildcardRegionProfile -> languageCode == otherProfile.languageCode + is LanguageAndRegionProfile, is RegionOnlyProfile, is RootProfile -> false + } + } + + override fun computeAndroidLocale(): Locale = Locale(languageCode) + } + + /** + * An [AndroidLocaleProfile] that provides only a non-empty language code, but matches (e.g. via + * [matches]) with any profile that has the same language code. + * + * Note that, generally, this should never need to be created directly. Instead, [Factory] should + * be used to create new instances of profiles. + * + * @property languageCode the lowercase two-letter language code in this profile + */ + data class LanguageAndWildcardRegionProfile(val languageCode: String) : AndroidLocaleProfile() { + override val ietfLanguageTag = languageCode + + override fun matches(otherProfile: AndroidLocaleProfile): Boolean { + return when (otherProfile) { + is LanguageAndRegionProfile -> languageCode == otherProfile.languageCode + is LanguageAndWildcardRegionProfile -> languageCode == otherProfile.languageCode + is LanguageOnlyProfile -> languageCode == otherProfile.languageCode + is RegionOnlyProfile, is RootProfile -> false + } } + + override fun computeAndroidLocale(): Locale = Locale(languageCode) } - companion object { - /** A wildcard that will match against any region when provided. */ - const val REGION_WILDCARD = "*" + /** + * An [AndroidLocaleProfile] that provides the system's root locale ([Locale.ROOT]). + * + * Note that, generally, this should never need to be used directly. Instead, [Factory] should be + * used to create new instances of profiles. + */ + object RootProfile : AndroidLocaleProfile() { + override val ietfLanguageTag = "" + + override fun matches(otherProfile: AndroidLocaleProfile): Boolean = otherProfile is RootProfile + override fun computeAndroidLocale(): Locale = Locale.ROOT + } + + /** An application-injectable factory for creating new [AndroidLocaleProfile]s. */ + class Factory @Inject constructor(private val machineLocale: OppiaLocale.MachineLocale) { /** Returns a new [AndroidLocaleProfile] that represents the specified Android [Locale]. */ - fun createFrom(androidLocale: Locale): AndroidLocaleProfile = - AndroidLocaleProfile(androidLocale.language, androidLocale.country) + fun createFrom(androidLocale: Locale): AndroidLocaleProfile { + val languageCode = androidLocale.language + val regionCode = androidLocale.country + return when { + languageCode.isNotEmpty() && regionCode.isNotEmpty() -> { + LanguageAndRegionProfile( + languageCode.asLowerCase(), regionCode.asLowerCase(), regionCode.asUpperCase() + ) + } + regionCode.isNotEmpty() -> RegionOnlyProfile(regionCode.asLowerCase()) + languageCode.isNotEmpty() -> LanguageOnlyProfile(languageCode.asLowerCase()) + else -> RootProfile + } + } /** * Returns a new [AndroidLocaleProfile] using the IETF BCP 47 tag in the provided [LanguageId]. @@ -100,17 +206,48 @@ data class AndroidLocaleProfile(val languageCode: String, val regionCode: String return maybeConstructProfile(languageCode, regionCode) } + /** + * Returns a new [AndroidLocaleProfile] using the provided [languageId]'s + * [LanguageId.getAndroidResourcesLanguageId] as the basis of the profile, or null if none can + * be created. + * + * This is meant to be used in cases when an [AndroidLocaleProfile] is needed to match a + * specific Android-compatible [Locale] (e.g. via [AndroidLocaleProfile.computeAndroidLocale]) + * that can correctly match to specific Android app strings. + */ + fun createFromAndroidResourcesLanguageId(languageId: LanguageId): AndroidLocaleProfile? { + val languageCode = languageId.androidResourcesLanguageId.languageCode + val regionCode = languageId.androidResourcesLanguageId.regionCode + return when { + !languageId.hasAndroidResourcesLanguageId() -> null + languageCode.isEmpty() -> null + // Empty region codes are allowed for Android resource IDs since they should always be used + // verbatim to ensure the correct Android resource string can be computed (such as for macro + // languages). + regionCode.isEmpty() -> LanguageAndWildcardRegionProfile(languageCode.asLowerCase()) + else -> { + LanguageAndRegionProfile( + languageCode.asLowerCase(), regionCode.asLowerCase(), regionCode.asUpperCase() + ) + } + } + } + private fun maybeConstructProfile( languageCode: String, regionCode: String, emptyRegionAsWildcard: Boolean = false ): AndroidLocaleProfile? { - return if (languageCode.isNotEmpty() && (regionCode.isNotEmpty() || emptyRegionAsWildcard)) { - val adjustedRegionCode = if (emptyRegionAsWildcard && regionCode.isEmpty()) { - REGION_WILDCARD - } else regionCode - AndroidLocaleProfile(languageCode, adjustedRegionCode) - } else null + return when { + languageCode.isEmpty() -> null + regionCode.isNotEmpty() -> { + LanguageAndRegionProfile( + languageCode.asLowerCase(), regionCode.asLowerCase(), regionCode.asUpperCase() + ) + } + emptyRegionAsWildcard -> LanguageAndWildcardRegionProfile(languageCode.asLowerCase()) + else -> null + } } private fun String.divide(delimiter: String): Pair? { @@ -120,6 +257,8 @@ data class AndroidLocaleProfile(val languageCode: String, val regionCode: String } else null } - private fun String.isNotEmptyOrWildcard() = isNotEmpty() && this != REGION_WILDCARD + private fun String.asLowerCase() = machineLocale.run { toMachineLowerCase() } + + private fun String.asUpperCase() = machineLocale.run { toMachineUpperCase() } } } diff --git a/utility/src/main/java/org/oppia/android/util/locale/BUILD.bazel b/utility/src/main/java/org/oppia/android/util/locale/BUILD.bazel index dcec5fbc2c9..9635257d80e 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/BUILD.bazel +++ b/utility/src/main/java/org/oppia/android/util/locale/BUILD.bazel @@ -12,6 +12,7 @@ kt_android_library( ], visibility = ["//:oppia_api_visibility"], deps = [ + ":dagger", ":oppia_locale", ], ) @@ -75,6 +76,8 @@ kt_android_library( deps = [ ":android_locale_profile", ":dagger", + "//third_party:org_jetbrains_kotlinx_kotlinx-coroutines-core", + "//utility/src/main/java/org/oppia/android/util/threading:annotations", ], ) diff --git a/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt b/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt index 838c8b192f7..70d23fba22f 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt @@ -13,16 +13,18 @@ import java.util.Locale import java.util.Objects // TODO(#3766): Restrict to be 'internal'. -/** Implementation of [OppiaLocale.DisplayLocale]. */ +// TODO(#3766): Restrict formattingLocale to be 'internal'. +/** + * Implementation of [OppiaLocale.DisplayLocale]. + * + * @property formattingLocale the [Locale] used for user-facing string formatting + */ class DisplayLocaleImpl( localeContext: OppiaLocaleContext, + val formattingLocale: Locale, private val machineLocale: MachineLocale, - private val androidLocaleFactory: AndroidLocaleFactory, private val formatterFactory: OppiaBidiFormatter.Factory ) : OppiaLocale.DisplayLocale(localeContext) { - // TODO(#3766): Restrict to be 'internal'. - /** The [Locale] used for user-facing string formatting in this display locale. */ - val formattingLocale: Locale by lazy { androidLocaleFactory.createAndroidLocale(localeContext) } private val dateFormat by lazy { DateFormat.getDateInstance(DATE_FORMAT_LENGTH, formattingLocale) } diff --git a/utility/src/test/java/org/oppia/android/util/data/DataProvidersTest.kt b/utility/src/test/java/org/oppia/android/util/data/DataProvidersTest.kt index d4697e891b7..596b43e2334 100644 --- a/utility/src/test/java/org/oppia/android/util/data/DataProvidersTest.kt +++ b/utility/src/test/java/org/oppia/android/util/data/DataProvidersTest.kt @@ -972,6 +972,40 @@ class DataProvidersTest { } } + @Test + fun testTransformAsync_toLiveData_throwsException_deliversFailure() { + val baseProvider = createSuccessfulDataProvider(BASE_PROVIDER_ID_0, STR_VALUE_0) + val dataProvider = baseProvider.transformAsync(TRANSFORMED_PROVIDER_ID) { + throw IllegalStateException("Transform failure") + } + + dataProvider.toLiveData().observeForever(mockIntLiveDataObserver) + testCoroutineDispatchers.advanceUntilIdle() + + // Note that the exception type here is not chained since the failure occurred in the transform + // function. + verify(mockIntLiveDataObserver).onChanged(intResultCaptor.capture()) + assertThat(intResultCaptor.value).isFailureThat().apply { + isInstanceOf(IllegalStateException::class.java) + hasMessageThat().contains("Transform failure") + } + } + + @Test + fun testTransformAsync_toLiveData_throwsException_deliversFailure_logsException() { + val baseProvider = createSuccessfulDataProvider(BASE_PROVIDER_ID_0, STR_VALUE_0) + val dataProvider = baseProvider.transformAsync(TRANSFORMED_PROVIDER_ID) { + throw IllegalStateException("Transform failure") + } + + dataProvider.toLiveData().observeForever(mockIntLiveDataObserver) + testCoroutineDispatchers.advanceUntilIdle() + val exception = fakeExceptionLogger.getMostRecentException() + + assertThat(exception).isInstanceOf(IllegalStateException::class.java) + assertThat(exception).hasMessageThat().contains("Transform failure") + } + @Test fun testTransformAsync_toLiveData_basePending_deliversPending() { val baseProvider = createPendingDataProvider(BASE_PROVIDER_ID_0) diff --git a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt index c0b45f7e9fd..a73d4d5950b 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt @@ -9,6 +9,10 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -22,9 +26,14 @@ import org.oppia.android.app.model.OppiaLocaleContext import org.oppia.android.app.model.OppiaRegion import org.oppia.android.app.model.RegionSupportDefinition import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.robolectric.RobolectricModule +import org.oppia.android.testing.threading.TestCoroutineDispatchers +import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule +import org.oppia.android.util.threading.BackgroundDispatcher import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode +import java.util.Locale import javax.inject.Inject import javax.inject.Singleton @@ -41,18 +50,63 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AndroidLocaleFactoryTest { - @Inject - lateinit var androidLocaleFactory: AndroidLocaleFactory + @Inject lateinit var androidLocaleFactory: AndroidLocaleFactory + @field:[Inject BackgroundDispatcher] lateinit var backgroundDispatcher: CoroutineDispatcher + @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Before fun setUp() { setUpTestApplicationComponent() } + /* Basic tests for one-off Locale creation (latter functions indirectly test in more detail. */ + + @Test + fun testCreateOneOffAndroidLocale_default_throwsException() { + val exception = assertThrows(IllegalStateException::class) { + androidLocaleFactory.createOneOffAndroidLocale(OppiaLocaleContext.getDefaultInstance()) + } + + // The operation should fail since there's no language type defined. + assertThat(exception).hasMessageThat().contains("Invalid language case") + } + + @Test + fun testCreateOneOffAndroidLocale_appStrings_defaultLanguage_returnsRootLocale() { + val context = + createAppStringsContext( + language = OppiaLanguage.LANGUAGE_UNSPECIFIED, + appStringId = LanguageId.getDefaultInstance(), + regionDefinition = RegionSupportDefinition.getDefaultInstance() + ) + + val locale = androidLocaleFactory.createOneOffAndroidLocale(context) + + assertThat(locale).isEqualTo(Locale.ROOT) + } + + @Test + fun testCreateOneOffAndroidLocale_appStrings_withAndroidId_compatible_returnsAndroidIdLocale() { + val context = + createAppStringsContext( + language = OppiaLanguage.BRAZILIAN_PORTUGUESE, + appStringId = createLanguageId(androidLanguageId = PT_BR_ANDROID_LANGUAGE_ID), + regionDefinition = REGION_BRAZIL + ) + + val locale = androidLocaleFactory.createOneOffAndroidLocale(context) + + // The context should be matched to a valid locale. + assertThat(locale.language).isEqualTo("pt") + assertThat(locale.country).isEqualTo("BR") + } + + /* Begin createAndroidLocaleAsync tests. */ + @Test fun testCreateLocale_default_throwsException() { val exception = assertThrows(IllegalStateException::class) { - androidLocaleFactory.createAndroidLocale(OppiaLocaleContext.getDefaultInstance()) + androidLocaleFactory.createAndroidLocaleBlocking(OppiaLocaleContext.getDefaultInstance()) } // The operation should fail since there's no language type defined. @@ -70,7 +124,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -86,7 +140,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -102,7 +156,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_US ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. Note that BR is matched since the IETF // language tag includes the region. @@ -119,7 +173,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -138,7 +192,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Android is preferred when both are present. Note no region is provided since the Android // language is missing a region definition. @@ -158,7 +212,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Android is preferred when both are present. Note no region is provided since the Android // language is missing a region definition. @@ -176,7 +230,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' is picked because it's an Android ID for app strings, so it's always taken as a forced // locale over any fallback options. @@ -194,7 +248,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale, and it's not // an Android ID that would take precedence. @@ -212,7 +266,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -229,7 +283,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language's region doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -246,7 +300,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_ZZ ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the supplied region doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -263,7 +317,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -280,7 +334,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language is invalid. assertThat(locale.language).isEqualTo("pt") @@ -298,7 +352,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language isn't compatible with the current SDK. assertThat(locale.language).isEqualTo("pt") @@ -318,7 +372,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' is picked because it's an Android ID for app strings, so it's always taken as a forced // locale over any fallback options. @@ -339,7 +393,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale, and it's not // an Android ID that would take precedence. Beyond that, the fallback's Android ID should take @@ -361,7 +415,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' is picked because it's an Android ID for app strings, so it's always taken as a forced // locale over any fallback options. @@ -382,7 +436,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked since Android IDs take precedence among multiple fallback options, and // none of the primary options are viable. @@ -400,7 +454,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' is picked over the primary language because it's an Android ID and the primary language // doesn't match any locales. @@ -418,7 +472,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' is the exact locale being requested. assertThat(locale.language).isEqualTo("qq") @@ -438,7 +492,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' takes precedence over the IETF language since Android IDs are picked first when // creating a forced locale. @@ -459,7 +513,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' takes precedence over the macaronic language since Android IDs are picked first when // creating a forced locale. @@ -477,7 +531,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The IETF language ID is used for the forced locale (note that fallback languages are ignored // when computing the forced locale). @@ -495,7 +549,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Hinglish macaronic language ID is used for the forced locale (note that fallback // languages are ignored when computing the forced locale). @@ -514,7 +568,7 @@ class AndroidLocaleFactoryTest { ) val exception = assertThrows(IllegalStateException::class) { - androidLocaleFactory.createAndroidLocale(context) + androidLocaleFactory.createAndroidLocaleBlocking(context) } assertThat(exception).hasMessageThat().contains("Invalid ID") @@ -532,7 +586,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The 'qq' language should be matched as a forced profile since both language IDs are // SDK-incompatible (despite the fallback being a matchable language). @@ -549,7 +603,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // Simple macro languages may not match any internal locales due to missing regions. They should // still become a valid locale (due to wildcard matching internally). @@ -558,7 +612,7 @@ class AndroidLocaleFactoryTest { } @Test - fun testCreateLocale_appStrings_allIncompat_invalidLangType_throwsException() { + fun testCreateLocale_appStrings_allIncompat_invalidLangType_returnsRootLocale() { val context = createAppStringsContext( language = OppiaLanguage.ENGLISH, @@ -566,11 +620,9 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { - androidLocaleFactory.createAndroidLocale(context) - } + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) - assertThat(exception).hasMessageThat().contains("Invalid language case") + assertThat(locale).isEqualTo(Locale.ROOT) } /* Tests for written content strings. */ @@ -584,7 +636,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -600,7 +652,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -616,7 +668,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_US ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. Note that BR is matched since the IETF // language tag includes the region. @@ -633,7 +685,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -652,7 +704,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Android is preferred when both are present. Note no region is provided since the Android // language is missing a region definition. @@ -672,7 +724,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Android is preferred when both are present. Note no region is provided since the Android // language is missing a region definition. @@ -690,7 +742,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -707,7 +759,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -724,7 +776,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language's region doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -741,7 +793,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_ZZ ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the supplied region doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -758,7 +810,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -775,7 +827,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language is invalid. assertThat(locale.language).isEqualTo("pt") @@ -793,7 +845,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language isn't compatible with the current SDK. assertThat(locale.language).isEqualTo("pt") @@ -813,7 +865,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked since Android IDs take precedence among multiple fallback options. assertThat(locale.language).isEqualTo("pt") @@ -833,7 +885,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked since Android IDs take precedence among multiple fallback options. assertThat(locale.language).isEqualTo("pt") @@ -850,7 +902,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' is the exact locale being requested. assertThat(locale.language).isEqualTo("qq") @@ -870,7 +922,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' takes precedence over the IETF language since Android IDs are picked first when // creating a forced locale. @@ -891,7 +943,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' takes precedence over the macaronic language since Android IDs are picked first when // creating a forced locale. @@ -909,7 +961,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The IETF language ID is used for the forced locale (note that fallback languages are ignored // when computing the forced locale). @@ -927,7 +979,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Hinglish macaronic language ID is used for the forced locale (note that fallback // languages are ignored when computing the forced locale). @@ -946,7 +998,7 @@ class AndroidLocaleFactoryTest { ) val exception = assertThrows(IllegalStateException::class) { - androidLocaleFactory.createAndroidLocale(context) + androidLocaleFactory.createAndroidLocaleBlocking(context) } assertThat(exception).hasMessageThat().contains("Invalid ID") @@ -964,7 +1016,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The 'qq' language should be matched as a forced profile since both language IDs are // SDK-incompatible (despite the fallback being a matchable language). @@ -981,7 +1033,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // Simple macro languages may not match any internal locales due to missing regions. They should // still become a valid locale (due to wildcard matching internally). @@ -999,7 +1051,7 @@ class AndroidLocaleFactoryTest { ) val exception = assertThrows(IllegalStateException::class) { - androidLocaleFactory.createAndroidLocale(context) + androidLocaleFactory.createAndroidLocaleBlocking(context) } assertThat(exception).hasMessageThat().contains("Invalid language case") @@ -1016,7 +1068,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -1032,7 +1084,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -1048,7 +1100,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_US ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. Note that BR is matched since the IETF // language tag includes the region. @@ -1065,7 +1117,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The context should be matched to a valid locale. assertThat(locale.language).isEqualTo("pt") @@ -1084,7 +1136,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Android is preferred when both are present. Note no region is provided since the Android // language is missing a region definition. @@ -1104,7 +1156,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Android is preferred when both are present. Note no region is provided since the Android // language is missing a region definition. @@ -1122,7 +1174,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -1139,7 +1191,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -1156,7 +1208,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language's region doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -1173,7 +1225,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_ZZ ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the supplied region doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -1190,7 +1242,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language doesn't match a real locale. assertThat(locale.language).isEqualTo("pt") @@ -1207,7 +1259,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language is invalid. assertThat(locale.language).isEqualTo("pt") @@ -1225,7 +1277,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_BRAZIL ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked because the primary language isn't compatible with the current SDK. assertThat(locale.language).isEqualTo("pt") @@ -1245,7 +1297,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked since Android IDs take precedence among multiple fallback options. assertThat(locale.language).isEqualTo("pt") @@ -1265,7 +1317,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // pt-BR should be picked since Android IDs take precedence among multiple fallback options. assertThat(locale.language).isEqualTo("pt") @@ -1282,7 +1334,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' is the exact locale being requested. assertThat(locale.language).isEqualTo("qq") @@ -1302,7 +1354,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' takes precedence over the IETF language since Android IDs are picked first when // creating a forced locale. @@ -1323,7 +1375,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // 'qq' takes precedence over the macaronic language since Android IDs are picked first when // creating a forced locale. @@ -1341,7 +1393,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The IETF language ID is used for the forced locale (note that fallback languages are ignored // when computing the forced locale). @@ -1359,7 +1411,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The Hinglish macaronic language ID is used for the forced locale (note that fallback // languages are ignored when computing the forced locale). @@ -1378,7 +1430,7 @@ class AndroidLocaleFactoryTest { ) val exception = assertThrows(IllegalStateException::class) { - androidLocaleFactory.createAndroidLocale(context) + androidLocaleFactory.createAndroidLocaleBlocking(context) } assertThat(exception).hasMessageThat().contains("Invalid ID") @@ -1396,7 +1448,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // The 'qq' language should be matched as a forced profile since both language IDs are // SDK-incompatible (despite the fallback being a matchable language). @@ -1413,7 +1465,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val locale = androidLocaleFactory.createAndroidLocale(context) + val locale = androidLocaleFactory.createAndroidLocaleBlocking(context) // Simple macro languages may not match any internal locales due to missing regions. They should // still become a valid locale (due to wildcard matching internally). @@ -1431,12 +1483,22 @@ class AndroidLocaleFactoryTest { ) val exception = assertThrows(IllegalStateException::class) { - androidLocaleFactory.createAndroidLocale(context) + androidLocaleFactory.createAndroidLocaleBlocking(context) } assertThat(exception).hasMessageThat().contains("Invalid language case") } + private fun AndroidLocaleFactory.createAndroidLocaleBlocking( + context: OppiaLocaleContext + ): Locale { + val deferred = + CoroutineScope(backgroundDispatcher).async { createAndroidLocaleAsync(context).await() } + testCoroutineDispatchers.runCurrent() + assertThat(deferred.isCompleted).isTrue() + return runBlocking { deferred.await() } + } + private fun createLanguageId(androidLanguageId: AndroidLanguageId): LanguageId { return LanguageId.newBuilder().apply { androidResourcesLanguageId = androidLanguageId @@ -1602,7 +1664,8 @@ class AndroidLocaleFactoryTest { @Singleton @Component( modules = [ - TestModule::class, LocaleProdModule::class, FakeOppiaClockModule::class + TestModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, + TestDispatcherModule::class, RobolectricModule::class ] ) interface TestApplicationComponent { diff --git a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleProfileTest.kt b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleProfileTest.kt index 42384c8531a..391a5decddc 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleProfileTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleProfileTest.kt @@ -12,6 +12,7 @@ import dagger.Provides import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.app.model.LanguageSupportDefinition.AndroidLanguageId import org.oppia.android.app.model.LanguageSupportDefinition.IetfBcp47LanguageId import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId import org.oppia.android.app.model.LanguageSupportDefinition.MacaronicLanguageId @@ -19,6 +20,11 @@ import org.oppia.android.app.model.OppiaRegion import org.oppia.android.app.model.RegionSupportDefinition import org.oppia.android.app.model.RegionSupportDefinition.IetfBcp47RegionId import org.oppia.android.testing.time.FakeOppiaClockModule +import org.oppia.android.util.locale.AndroidLocaleProfile.LanguageAndRegionProfile +import org.oppia.android.util.locale.AndroidLocaleProfile.LanguageAndWildcardRegionProfile +import org.oppia.android.util.locale.AndroidLocaleProfile.LanguageOnlyProfile +import org.oppia.android.util.locale.AndroidLocaleProfile.RegionOnlyProfile +import org.oppia.android.util.locale.AndroidLocaleProfile.RootProfile import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.util.Locale @@ -32,11 +38,10 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AndroidLocaleProfileTest { - @Inject - lateinit var machineLocale: OppiaLocale.MachineLocale + @Inject lateinit var androidLocaleProfileFactory: AndroidLocaleProfile.Factory - private val portugueseLocale by lazy { Locale("pt") } private val brazilianPortugueseLocale by lazy { Locale("pt", "BR") } + private val kenyaOnlyLocale by lazy { Locale(/* language = */ "", "KE") } @Before fun setUp() { @@ -46,27 +51,38 @@ class AndroidLocaleProfileTest { /* Tests for createFrom */ @Test - fun testCreateProfile_fromRootLocale_returnsProfileWithoutLanguageAndRegionCode() { - val profile = AndroidLocaleProfile.createFrom(Locale.ROOT) + fun testCreateProfile_fromRootLocale_returnsRootProfile() { + val profile = androidLocaleProfileFactory.createFrom(Locale.ROOT) - assertThat(profile.languageCode).isEmpty() - assertThat(profile.regionCode).isEmpty() + assertThat(profile).isEqualTo(RootProfile) } @Test - fun testCreateProfile_fromEnglishLocale_returnsProfileWithLanguageAndWithoutRegion() { - val profile = AndroidLocaleProfile.createFrom(Locale.ENGLISH) + fun testCreateProfile_fromEnglishLocale_returnsLanguageOnlyProfile() { + val profile = androidLocaleProfileFactory.createFrom(Locale.ENGLISH) - assertThat(profile.languageCode).isEqualTo("en") - assertThat(profile.regionCode).isEmpty() + val languageOnlyProfile = profile as? LanguageOnlyProfile + assertThat(profile).isInstanceOf(LanguageOnlyProfile::class.java) + assertThat(languageOnlyProfile?.languageCode).isEqualTo("en") } @Test fun testCreateProfile_fromBrazilianPortuguese_returnsProfileWithLanguageAndRegion() { - val profile = AndroidLocaleProfile.createFrom(brazilianPortugueseLocale) + val profile = androidLocaleProfileFactory.createFrom(brazilianPortugueseLocale) - assertThat(profile.languageCode).isEqualTo("pt") - assertThat(profile.regionCode).isEqualTo("BR") + val languageAndRegionProfile = profile as? LanguageAndRegionProfile + assertThat(profile).isInstanceOf(LanguageAndRegionProfile::class.java) + assertThat(languageAndRegionProfile?.languageCode).isEqualTo("pt") + assertThat(languageAndRegionProfile?.regionCode).isEqualTo("br") + } + + @Test + fun testCreateProfile_fromKenyaLocale_returnsRegionOnlyProfile() { + val profile = androidLocaleProfileFactory.createFrom(kenyaOnlyLocale) + + val regionOnlyProfile = profile as? RegionOnlyProfile + assertThat(profile).isInstanceOf(RegionOnlyProfile::class.java) + assertThat(regionOnlyProfile?.regionCode).isEqualTo("ke") } /* Tests for createFromIetfDefinitions */ @@ -74,7 +90,7 @@ class AndroidLocaleProfileTest { @Test fun testCreateProfileFromIetf_defaultLanguageId_nullRegion_returnsNull() { val profile = - AndroidLocaleProfile.createFromIetfDefinitions( + androidLocaleProfileFactory.createFromIetfDefinitions( languageId = LanguageId.getDefaultInstance(), regionDefinition = null ) @@ -89,7 +105,8 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = AndroidLocaleProfile.createFromIetfDefinitions(languageWithoutIetf, REGION_INDIA) + val profile = + androidLocaleProfileFactory.createFromIetfDefinitions(languageWithoutIetf, REGION_INDIA) // The language ID needs to have an IETF BCP 47 ID defined. assertThat(profile).isNull() @@ -103,7 +120,8 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = AndroidLocaleProfile.createFromIetfDefinitions(languageWithIetf, REGION_INDIA) + val profile = + androidLocaleProfileFactory.createFromIetfDefinitions(languageWithIetf, REGION_INDIA) // The language ID needs to have an IETF BCP 47 ID defined. assertThat(profile).isNull() @@ -117,7 +135,8 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = AndroidLocaleProfile.createFromIetfDefinitions(languageWithIetf, REGION_INDIA) + val profile = + androidLocaleProfileFactory.createFromIetfDefinitions(languageWithIetf, REGION_INDIA) // The language ID needs to have a well-formed IETF BCP 47 ID defined. assertThat(profile).isNull() @@ -131,12 +150,15 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = AndroidLocaleProfile.createFromIetfDefinitions(languageWithIetf, REGION_INDIA) + val profile = + androidLocaleProfileFactory.createFromIetfDefinitions(languageWithIetf, REGION_INDIA) // The constituent language code should come from the language ID, and the region code from the // provided region definition. - assertThat(profile?.languageCode).isEqualTo("pt") - assertThat(profile?.regionCode).isEqualTo("IN") + val languageAndRegionProfile = profile as? LanguageAndRegionProfile + assertThat(profile).isInstanceOf(LanguageAndRegionProfile::class.java) + assertThat(languageAndRegionProfile?.languageCode).isEqualTo("pt") + assertThat(languageAndRegionProfile?.regionCode).isEqualTo("in") } @Test @@ -147,11 +169,14 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = AndroidLocaleProfile.createFromIetfDefinitions(languageWithIetf, REGION_INDIA) + val profile = + androidLocaleProfileFactory.createFromIetfDefinitions(languageWithIetf, REGION_INDIA) // In this case, the region comes from the IETF language tag since it's included. - assertThat(profile?.languageCode).isEqualTo("pt") - assertThat(profile?.regionCode).isEqualTo("BR") + val languageAndRegionProfile = profile as? LanguageAndRegionProfile + assertThat(profile).isInstanceOf(LanguageAndRegionProfile::class.java) + assertThat(languageAndRegionProfile?.languageCode).isEqualTo("pt") + assertThat(languageAndRegionProfile?.regionCode).isEqualTo("br") } @Test @@ -163,7 +188,7 @@ class AndroidLocaleProfileTest { }.build() val profile = - AndroidLocaleProfile.createFromIetfDefinitions( + androidLocaleProfileFactory.createFromIetfDefinitions( languageWithIetf, regionDefinition = RegionSupportDefinition.getDefaultInstance() ) @@ -180,7 +205,7 @@ class AndroidLocaleProfileTest { }.build() val profile = - AndroidLocaleProfile.createFromIetfDefinitions( + androidLocaleProfileFactory.createFromIetfDefinitions( languageWithIetf, regionDefinition = RegionSupportDefinition.getDefaultInstance() ) @@ -197,11 +222,14 @@ class AndroidLocaleProfileTest { }.build() val profile = - AndroidLocaleProfile.createFromIetfDefinitions(languageWithIetf, regionDefinition = null) + androidLocaleProfileFactory.createFromIetfDefinitions( + languageWithIetf, regionDefinition = null + ) // A null region specifically means to use a wildcard match for regions. - assertThat(profile?.languageCode).isEqualTo("pt") - assertThat(profile?.regionCode).isEqualTo(AndroidLocaleProfile.REGION_WILDCARD) + val languageAndWildcardRegionProfile = profile as? LanguageAndWildcardRegionProfile + assertThat(profile).isInstanceOf(LanguageAndWildcardRegionProfile::class.java) + assertThat(languageAndWildcardRegionProfile?.languageCode).isEqualTo("pt") } /* Tests for createFromMacaronicLanguage */ @@ -209,7 +237,9 @@ class AndroidLocaleProfileTest { @Test fun testCreateProfileFromMacaronic_defaultLanguageId_returnsNull() { val profile = - AndroidLocaleProfile.createFromMacaronicLanguage(languageId = LanguageId.getDefaultInstance()) + androidLocaleProfileFactory.createFromMacaronicLanguage( + languageId = LanguageId.getDefaultInstance() + ) assertThat(profile).isNull() } @@ -222,8 +252,7 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = - AndroidLocaleProfile.createFromMacaronicLanguage(languageWithoutMacaronic) + val profile = androidLocaleProfileFactory.createFromMacaronicLanguage(languageWithoutMacaronic) // The provided language ID must have a macaronic ID defined. assertThat(profile).isNull() @@ -237,8 +266,7 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = - AndroidLocaleProfile.createFromMacaronicLanguage(languageWithMacaronic) + val profile = androidLocaleProfileFactory.createFromMacaronicLanguage(languageWithMacaronic) // The provided language ID must have a macaronic ID defined. assertThat(profile).isNull() @@ -252,8 +280,7 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = - AndroidLocaleProfile.createFromMacaronicLanguage(languageWithMacaronic) + val profile = androidLocaleProfileFactory.createFromMacaronicLanguage(languageWithMacaronic) // The provided language ID must have a well-formed macaronic ID defined. assertThat(profile).isNull() @@ -267,8 +294,7 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = - AndroidLocaleProfile.createFromMacaronicLanguage(languageWithMacaronic) + val profile = androidLocaleProfileFactory.createFromMacaronicLanguage(languageWithMacaronic) // The provided language ID must have a well-formed macaronic ID defined, that is, it must have // two language parts defined. @@ -283,8 +309,7 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = - AndroidLocaleProfile.createFromMacaronicLanguage(languageWithMacaronic) + val profile = androidLocaleProfileFactory.createFromMacaronicLanguage(languageWithMacaronic) // The macaronic ID has two parts as expected, but the second language ID must be filled in. assertThat(profile).isNull() @@ -298,262 +323,593 @@ class AndroidLocaleProfileTest { }.build() }.build() - val profile = - AndroidLocaleProfile.createFromMacaronicLanguage(languageWithMacaronic) + val profile = androidLocaleProfileFactory.createFromMacaronicLanguage(languageWithMacaronic) // The macaronic ID was valid. Verify that both language IDs correctly populate the profile. - assertThat(profile?.languageCode).isEqualTo("hi") - assertThat(profile?.regionCode).isEqualTo("en") + val languageAndRegionProfile = profile as? LanguageAndRegionProfile + assertThat(profile).isInstanceOf(LanguageAndRegionProfile::class.java) + assertThat(languageAndRegionProfile?.languageCode).isEqualTo("hi") + assertThat(languageAndRegionProfile?.regionCode).isEqualTo("en") + } + + /* Tests for createFromAndroidResourcesLanguageId(). */ + + @Test + fun testCreateFromAndroidResourcesLanguageId_defaultLanguageId_returnsNull() { + val profile = + androidLocaleProfileFactory.createFromAndroidResourcesLanguageId( + languageId = LanguageId.getDefaultInstance() + ) + + assertThat(profile).isNull() + } + + @Test + fun testCreateFromAndroidResourcesLanguageId_ietfBcp47LanguageId_returnsNull() { + val profile = + androidLocaleProfileFactory.createFromAndroidResourcesLanguageId( + languageId = LanguageId.newBuilder().apply { + ietfBcp47Id = IetfBcp47LanguageId.newBuilder().apply { + ietfLanguageTag = "pt-BR" + }.build() + }.build() + ) + + // This method can only be create a method via a valid Android resources language ID. + assertThat(profile).isNull() + } + + @Test + fun testCreateFromAndroidResourcesLanguageId_macaronicLanguageId_returnsNull() { + val profile = + androidLocaleProfileFactory.createFromAndroidResourcesLanguageId( + languageId = LanguageId.newBuilder().apply { + macaronicId = MacaronicLanguageId.newBuilder().apply { + combinedLanguageCode = "hi-en" + }.build() + }.build() + ) + + // This method can only be create a method via a valid Android resources language ID. + assertThat(profile).isNull() + } + + @Test + fun testCreateFromAndroidResourcesLanguageId_defaultAndroidLanguageId_returnsNull() { + val profile = + androidLocaleProfileFactory.createFromAndroidResourcesLanguageId( + languageId = LanguageId.newBuilder().apply { + androidResourcesLanguageId = AndroidLanguageId.getDefaultInstance() + }.build() + ) + + // This method can only be create a method via a valid Android resources language ID. + assertThat(profile).isNull() + } + + @Test + fun testCreateFromAndroidResourcesLanguageId_androidLanguageId_regionOnly_returnsNull() { + val profile = + androidLocaleProfileFactory.createFromAndroidResourcesLanguageId( + languageId = LanguageId.newBuilder().apply { + androidResourcesLanguageId = AndroidLanguageId.newBuilder().apply { + regionCode = "BR" + }.build() + }.build() + ) + + // A valid Android language ID must include at least a language code. + assertThat(profile).isNull() + } + + @Test + fun testCreateFromAndroidResourcesLanguageId_androidLanguageId_langOnly_returnsLangWildcard() { + val profile = + androidLocaleProfileFactory.createFromAndroidResourcesLanguageId( + languageId = LanguageId.newBuilder().apply { + androidResourcesLanguageId = AndroidLanguageId.newBuilder().apply { + languageCode = "pt" + }.build() + }.build() + ) + + // If no region is provided, match against all regions. + val languageAndWildcardRegionProfile = profile as? LanguageAndWildcardRegionProfile + assertThat(profile).isInstanceOf(LanguageAndWildcardRegionProfile::class.java) + assertThat(languageAndWildcardRegionProfile?.languageCode).isEqualTo("pt") + } + + @Test + fun testCreateFromAndroidResourcesLanguageId_androidLanguageId_returnsLangAndRegionProfile() { + val profile = + androidLocaleProfileFactory.createFromAndroidResourcesLanguageId( + languageId = LanguageId.newBuilder().apply { + androidResourcesLanguageId = AndroidLanguageId.newBuilder().apply { + languageCode = "pt" + regionCode = "BR" + }.build() + }.build() + ) + + // Both the language & region codes should be represented in the profile. + val languageAndRegionProfile = profile as? LanguageAndRegionProfile + assertThat(profile).isInstanceOf(LanguageAndRegionProfile::class.java) + assertThat(languageAndRegionProfile?.languageCode).isEqualTo("pt") + assertThat(languageAndRegionProfile?.regionCode).isEqualTo("br") } /* Tests for matches() */ @Test - fun testMatchProfile_rootProfile_withItself_match() { - val profile = AndroidLocaleProfile.createFrom(Locale.ROOT) + fun testMatchProfile_rootProfile_andRootProfile_matches() { + val profile1 = RootProfile + val profile2 = RootProfile - val matches = profile.matches(machineLocale, profile) + val matches = profile1.matches(profile2) assertThat(matches).isTrue() } @Test - fun testMatchProfile_englishProfile_withItself_match() { - val profile = AndroidLocaleProfile.createFrom(Locale.ENGLISH) + fun testMatchProfile_rootProfile_andPtLanguageOnly_doNotMatch() { + val profile1 = RootProfile + val profile2 = LanguageOnlyProfile(languageCode = "pt") - val matches = profile.matches(machineLocale, profile) + val matches = profile1.matches(profile2) - assertThat(matches).isTrue() + assertThat(matches).isFalse() } @Test - fun testMatchProfile_brazilianPortuguese_withItself_match() { - val profile = AndroidLocaleProfile.createFrom(brazilianPortugueseLocale) + fun testMatchProfile_rootProfile_andBrRegionOnly_doNotMatch() { + val profile1 = RootProfile + val profile2 = RegionOnlyProfile(regionCode = "br") - val matches = profile.matches(machineLocale, profile) + val matches = profile1.matches(profile2) - assertThat(matches).isTrue() + assertThat(matches).isFalse() } @Test - fun testMatchProfile_englishProfile_withItselfInDifferentCase_match() { - val englishProfileLowercase = AndroidLocaleProfile(languageCode = "en", regionCode = "") - val englishProfileUppercase = AndroidLocaleProfile(languageCode = "EN", regionCode = "") + fun testMatchProfile_rootProfile_andPtBrProfile_doNotMatch() { + val profile1 = RootProfile + val profile2 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") - val matches = englishProfileLowercase.matches(machineLocale, englishProfileUppercase) + val matches = profile1.matches(profile2) - assertThat(matches).isTrue() + assertThat(matches).isFalse() } @Test - fun testMatchProfile_englishProfile_withItselfInDifferentCase_reversed_match() { - val englishProfileLowercase = AndroidLocaleProfile(languageCode = "en", regionCode = "") - val englishProfileUppercase = AndroidLocaleProfile(languageCode = "EN", regionCode = "") + fun testMatchProfile_rootProfile_andPtWildcardProfile_doNotMatch() { + val profile1 = RootProfile + val profile2 = LanguageAndWildcardRegionProfile(languageCode = "pt") - val matches = englishProfileUppercase.matches(machineLocale, englishProfileLowercase) + val matches = profile1.matches(profile2) - assertThat(matches).isTrue() + assertThat(matches).isFalse() } @Test - fun testMatchProfile_brazilianPortuguese_withItselfInDifferentCase_match() { - val brazilianPortugueseProfileLowercase = - AndroidLocaleProfile(languageCode = "pt", regionCode = "br") - val brazilianPortugueseProfileUppercase = - AndroidLocaleProfile(languageCode = "PT", regionCode = "BR") + fun testMatchProfile_ptLanguageOnly_andRootProfile_doNotMatch() { + val profile1 = LanguageOnlyProfile(languageCode = "pt") + val profile2 = RootProfile - val matches = - brazilianPortugueseProfileLowercase.matches( - machineLocale, brazilianPortugueseProfileUppercase - ) + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptLanguageOnly_andPtLanguageOnly_matches() { + val profile1 = LanguageOnlyProfile(languageCode = "pt") + val profile2 = LanguageOnlyProfile(languageCode = "pt") + + val matches = profile1.matches(profile2) assertThat(matches).isTrue() } - fun testMatchProfile_brazilianPortuguese_withItselfInDifferentCase_reversed_match() { - val brazilianPortugueseProfileLowercase = - AndroidLocaleProfile(languageCode = "pt", regionCode = "br") - val brazilianPortugueseProfileUppercase = - AndroidLocaleProfile(languageCode = "PT", regionCode = "BR") + @Test + fun testMatchProfile_ptLanguageOnly_andSwLanguageOnly_doNotMatch() { + val profile1 = LanguageOnlyProfile(languageCode = "pt") + val profile2 = LanguageOnlyProfile(languageCode = "sw") - val matches = - brazilianPortugueseProfileUppercase.matches( - machineLocale, brazilianPortugueseProfileLowercase - ) + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptLanguageOnly_andBrRegionOnly_doNotMatch() { + val profile1 = LanguageOnlyProfile(languageCode = "pt") + val profile2 = RegionOnlyProfile(regionCode = "br") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptLanguageOnly_andPtBrProfile_doNotMatch() { + val profile1 = LanguageOnlyProfile(languageCode = "pt") + val profile2 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptLanguageOnly_andSwWildcardProfile_doNotMatch() { + val profile1 = LanguageOnlyProfile(languageCode = "pt") + val profile2 = LanguageAndWildcardRegionProfile(languageCode = "sw") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_brRegionOnly_andRootProfile_doNotMatch() { + val profile1 = RegionOnlyProfile(regionCode = "br") + val profile2 = RootProfile + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_brRegionOnly_andPtLanguageOnly_doNotMatch() { + val profile1 = RegionOnlyProfile(regionCode = "br") + val profile2 = LanguageOnlyProfile(languageCode = "pt") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_brRegionOnly_andBrRegionOnly_matches() { + val profile1 = RegionOnlyProfile(regionCode = "br") + val profile2 = RegionOnlyProfile(regionCode = "br") + + val matches = profile1.matches(profile2) assertThat(matches).isTrue() } @Test - fun testMatchProfile_rootProfile_english_doNotMatch() { - val rootProfile = AndroidLocaleProfile.createFrom(Locale.ROOT) - val englishProfile = AndroidLocaleProfile.createFrom(Locale.ENGLISH) + fun testMatchProfile_brRegionOnly_andKeRegionOnly_doNotMatch() { + val profile1 = RegionOnlyProfile(regionCode = "br") + val profile2 = RegionOnlyProfile(regionCode = "ke") - val matches = rootProfile.matches(machineLocale, englishProfile) + val matches = profile1.matches(profile2) assertThat(matches).isFalse() } @Test - fun testMatchProfile_rootProfile_brazilianPortuguese_doNotMatch() { - val rootProfile = AndroidLocaleProfile.createFrom(Locale.ROOT) - val brazilianPortugueseProfile = AndroidLocaleProfile.createFrom(brazilianPortugueseLocale) + fun testMatchProfile_brRegionOnly_andPtBrProfile_doNotMatch() { + val profile1 = RegionOnlyProfile(regionCode = "br") + val profile2 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") - val matches = rootProfile.matches(machineLocale, brazilianPortugueseProfile) + val matches = profile1.matches(profile2) assertThat(matches).isFalse() } @Test - fun testMatchProfile_english_brazilianPortuguese_doNotMatch() { - val englishProfile = AndroidLocaleProfile.createFrom(Locale.ENGLISH) - val brazilianPortugueseProfile = AndroidLocaleProfile.createFrom(brazilianPortugueseLocale) + fun testMatchProfile_brRegionOnly_andPtWildcardProfile_doNotMatch() { + val profile1 = RegionOnlyProfile(regionCode = "br") + val profile2 = LanguageAndWildcardRegionProfile(languageCode = "pt") - val matches = englishProfile.matches(machineLocale, brazilianPortugueseProfile) + val matches = profile1.matches(profile2) assertThat(matches).isFalse() } @Test - fun testMatchProfile_rootProfile_englishWithWildcard_doNotMatch() { - val rootProfile = AndroidLocaleProfile.createFrom(Locale.ROOT) - val englishWithWildcardProfile = createProfileWithWildcard(languageCode = "en") + fun testMatchProfile_ptBrProfile_andRootProfile_doNotMatch() { + val profile1 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + val profile2 = RootProfile - val matches = rootProfile.matches(machineLocale, englishWithWildcardProfile) + val matches = profile1.matches(profile2) assertThat(matches).isFalse() } @Test - fun testMatchProfile_rootProfile_rootProfileWithWildcard_match() { - val rootProfile = AndroidLocaleProfile.createFrom(Locale.ROOT) - val rootProfileWithWildcardProfile = createProfileWithWildcard(languageCode = "") + fun testMatchProfile_ptBrProfile_andPtLanguageOnly_doNotMatch() { + val profile1 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + val profile2 = LanguageOnlyProfile(languageCode = "pt") - val matches = rootProfile.matches(machineLocale, rootProfileWithWildcardProfile) + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptBrProfile_andBrRegionOnly_doNotMatch() { + val profile1 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + val profile2 = RegionOnlyProfile(regionCode = "br") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptBrProfile_andPtBrProfile_matches() { + val profile1 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + val profile2 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + + val matches = profile1.matches(profile2) assertThat(matches).isTrue() } @Test - fun testMatchProfile_rootProfileWithWildcard_rootProfile_match() { - val rootProfile = AndroidLocaleProfile.createFrom(Locale.ROOT) - val rootProfileWithWildcardProfile = createProfileWithWildcard(languageCode = "") + fun testMatchProfile_ptBrProfile_andSwBrProfile_doNotMatch() { + val profile1 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + val profile2 = + LanguageAndRegionProfile(languageCode = "sw", regionCode = "br", regionCodeUpperCase = "BR") - val matches = rootProfileWithWildcardProfile.matches(machineLocale, rootProfile) + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptBrProfile_andPtKeProfile_doNotMatch() { + val profile1 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + val profile2 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "ke", regionCodeUpperCase = "KE") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptBrProfile_andSwKeProfile_doNotMatch() { + val profile1 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + val profile2 = + LanguageAndRegionProfile(languageCode = "sw", regionCode = "ke", regionCodeUpperCase = "KE") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptBrProfile_andSwWildcardProfile_doNotMatch() { + val profile1 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + val profile2 = LanguageAndWildcardRegionProfile(languageCode = "sw") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptWildcardProfile_andRootProfile_doNotMatch() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = RootProfile + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptWildcardProfile_andPtLanguageOnly_matches() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = LanguageOnlyProfile(languageCode = "pt") + + val matches = profile1.matches(profile2) assertThat(matches).isTrue() } @Test - fun testMatchProfile_englishProfile_rootProfileWithWildcard_doNotMatch() { - val englishProfile = AndroidLocaleProfile.createFrom(Locale.ENGLISH) - val rootProfileWithWildcardProfile = createProfileWithWildcard(languageCode = "") + fun testMatchProfile_ptWildcardProfile_andSwLanguageOnly_doNotMatch() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = LanguageOnlyProfile(languageCode = "sw") - val matches = englishProfile.matches(machineLocale, rootProfileWithWildcardProfile) + val matches = profile1.matches(profile2) assertThat(matches).isFalse() } @Test - fun testMatchProfile_englishWithWildcard_brazilianPortuguese_doNotMatch() { - val englishWithWildcardProfile = createProfileWithWildcard(languageCode = "en") - val brazilianPortugueseProfile = AndroidLocaleProfile.createFrom(brazilianPortugueseLocale) + fun testMatchProfile_ptWildcardProfile_andBrRegionOnly_doNotMatch() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = RegionOnlyProfile(regionCode = "br") - val matches = englishWithWildcardProfile.matches(machineLocale, brazilianPortugueseProfile) + val matches = profile1.matches(profile2) assertThat(matches).isFalse() } @Test - fun testMatchProfile_brazilianPortuguese_portuguese_doNotMatch() { - val portugueseProfile = AndroidLocaleProfile.createFrom(portugueseLocale) - val brazilianPortugueseProfile = AndroidLocaleProfile.createFrom(brazilianPortugueseLocale) + fun testMatchProfile_ptWildcardProfile_andPtBrProfile_matches() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + + val matches = profile1.matches(profile2) + + assertThat(matches).isTrue() + } + + @Test + fun testMatchProfile_ptWildcardProfile_andSwBrProfile_doNotMatch() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = + LanguageAndRegionProfile(languageCode = "sw", regionCode = "br", regionCodeUpperCase = "BR") - val matches = portugueseProfile.matches(machineLocale, brazilianPortugueseProfile) + val matches = profile1.matches(profile2) assertThat(matches).isFalse() } @Test - fun testMatchProfile_brazilianPortuguese_portugueseWithWildcard_match() { - val portugueseWithWildcardProfile = createProfileWithWildcard(languageCode = "pt") - val brazilianPortugueseProfile = AndroidLocaleProfile.createFrom(brazilianPortugueseLocale) + fun testMatchProfile_ptWildcardProfile_andPtKeProfile_matches() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "ke", regionCodeUpperCase = "KE") - val matches = brazilianPortugueseProfile.matches(machineLocale, portugueseWithWildcardProfile) + val matches = profile1.matches(profile2) assertThat(matches).isTrue() } @Test - fun testMatchProfile_portugueseWithWildcard_brazilianPortuguese_match() { - val portugueseWithWildcardProfile = createProfileWithWildcard(languageCode = "pt") - val brazilianPortugueseProfile = AndroidLocaleProfile.createFrom(brazilianPortugueseLocale) + fun testMatchProfile_ptWildcardProfile_andSwKeProfile_doNotMatch() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = + LanguageAndRegionProfile(languageCode = "sw", regionCode = "ke", regionCodeUpperCase = "KE") - val matches = portugueseWithWildcardProfile.matches(machineLocale, brazilianPortugueseProfile) + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + + @Test + fun testMatchProfile_ptWildcardProfile_andPtWildcardProfile_matches() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = LanguageAndWildcardRegionProfile(languageCode = "pt") + + val matches = profile1.matches(profile2) assertThat(matches).isTrue() } + @Test + fun testMatchProfile_ptWildcardProfile_andSwWildcardProfile_doNotMatch() { + val profile1 = LanguageAndWildcardRegionProfile(languageCode = "pt") + val profile2 = LanguageAndWildcardRegionProfile(languageCode = "sw") + + val matches = profile1.matches(profile2) + + assertThat(matches).isFalse() + } + /* Tests for computeIetfLanguageTag */ @Test - fun testComputeIetfLanguageTag_noLanguageCode_noRegionCode_returnsEmptyString() { - val emptyProfile = AndroidLocaleProfile(languageCode = "", regionCode = "") + fun testIetfLanguageTag_rootProfile_isEmptyString() { + val profile = RootProfile - val ietfLanguageTag = emptyProfile.computeIetfLanguageTag() + val ietfLanguageTag = profile.ietfLanguageTag assertThat(ietfLanguageTag).isEmpty() } @Test - fun testComputeIetfLanguageTag_languageCode_noRegionCode_returnsLanguageCode() { - val portugueseProfile = AndroidLocaleProfile(languageCode = "pt", regionCode = "") + fun testIetfLanguageTag_languageOnlyProfile_isLanguageCode() { + val profile = LanguageOnlyProfile(languageCode = "pt") - val ietfLanguageTag = portugueseProfile.computeIetfLanguageTag() + val ietfLanguageTag = profile.ietfLanguageTag assertThat(ietfLanguageTag).isEqualTo("pt") } @Test - fun testComputeIetfLanguageTag_languageCode_wildcardRegionCode_returnsLanguageCode() { - val portugueseAndRegionProfile = createProfileWithWildcard(languageCode = "pt") + fun testIetfLanguageTag_regionOnlyProfile_isRegionCode() { + val profile = RegionOnlyProfile(regionCode = "br") - val ietfLanguageTag = portugueseAndRegionProfile.computeIetfLanguageTag() + val ietfLanguageTag = profile.ietfLanguageTag + + assertThat(ietfLanguageTag).isEqualTo("br") + } + + @Test + fun testIetfLanguageTag_languageWithRegionProfile_isIetfBcp47CombinedLanguageTag() { + val profile = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + + val ietfLanguageTag = profile.ietfLanguageTag + + assertThat(ietfLanguageTag).isEqualTo("pt-BR") + } + + @Test + fun testIetfLanguageTag_languageWithWildcardProfile_isLanguageCode() { + val profile = LanguageAndWildcardRegionProfile(languageCode = "pt") + + val ietfLanguageTag = profile.ietfLanguageTag // The wildcard shouldn't be part of the IETF BCP 47 tag since that standard doesn't define such // a concept. assertThat(ietfLanguageTag).isEqualTo("pt") } + /* Tests for computeAndroidLocale() */ + @Test - fun testComputeIetfLanguageTag_noLanguageCode_regionCode_returnsRegionCode() { - val brazilianProfile = AndroidLocaleProfile(languageCode = "", regionCode = "BR") + fun testComputeAndroidLocale_rootProfile_returnsRootLocale() { + val profile = RootProfile - val ietfLanguageTag = brazilianProfile.computeIetfLanguageTag() + val locale = profile.computeAndroidLocale() - assertThat(ietfLanguageTag).isEqualTo("BR") + assertThat(locale).isEqualTo(Locale.ROOT) } @Test - fun testComputeIetfLanguageTag_noLanguageCode_wildcardRegionCode_returnsEmptyString() { - val matchNothingProfile = createProfileWithWildcard(languageCode = "") + fun testComputeAndroidLocale_languageOnlyProfile_returnsLocaleWithLanguageAndEmptyCountry() { + val profile = LanguageOnlyProfile(languageCode = "pt") - val ietfLanguageTag = matchNothingProfile.computeIetfLanguageTag() + val locale = profile.computeAndroidLocale() - assertThat(ietfLanguageTag).isEmpty() + assertThat(locale.language).ignoringCase().isEqualTo("pt") + assertThat(locale.country).isEmpty() } @Test - fun testComputeIetfLanguageTag_languageCode_regionCode_returnsIetfBcp47CombinedLanguageTag() { - val brazilianPortugueseProfile = AndroidLocaleProfile(languageCode = "pt", regionCode = "BR") + fun testComputeAndroidLocale_regionOnlyProfile_returnsLocaleWithCountryAndEmptyLanguage() { + val profile = RegionOnlyProfile(regionCode = "br") - val ietfLanguageTag = brazilianPortugueseProfile.computeIetfLanguageTag() + val locale = profile.computeAndroidLocale() - assertThat(ietfLanguageTag).isEqualTo("pt-BR") + assertThat(locale.country).ignoringCase().isEqualTo("br") + assertThat(locale.language).isEmpty() + } + + @Test + fun testComputeAndroidLocale_languageWithWildcardProfile_returnsLocaleWithLangAndEmptyCountry() { + val profile = LanguageAndWildcardRegionProfile(languageCode = "pt") + + val locale = profile.computeAndroidLocale() + + assertThat(locale.language).ignoringCase().isEqualTo("pt") + assertThat(locale.country).isEmpty() } - private fun createProfileWithWildcard(languageCode: String): AndroidLocaleProfile = - AndroidLocaleProfile(languageCode, regionCode = AndroidLocaleProfile.REGION_WILDCARD) + @Test + fun testComputeAndroidLocale_languageAndRegionProfile_returnsLocaleWithLanguageAndCountry() { + val profile = + LanguageAndRegionProfile(languageCode = "pt", regionCode = "br", regionCodeUpperCase = "BR") + + val locale = profile.computeAndroidLocale() + + assertThat(locale.language).ignoringCase().isEqualTo("pt") + assertThat(locale.country).ignoringCase().isEqualTo("br") + } private fun setUpTestApplicationComponent() { DaggerAndroidLocaleProfileTest_TestApplicationComponent.builder() diff --git a/utility/src/test/java/org/oppia/android/util/locale/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/locale/BUILD.bazel index 850e0d05370..d1bc33a3988 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/locale/BUILD.bazel @@ -14,6 +14,8 @@ oppia_android_test( deps = [ ":dagger", "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", @@ -72,6 +74,8 @@ oppia_android_test( ":dagger", "//model/src/main/proto:languages_java_proto_lite", "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", diff --git a/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt b/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt index 8786f31948b..b0bf15310ab 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt @@ -21,6 +21,8 @@ import org.oppia.android.app.model.OppiaLocaleContext import org.oppia.android.app.model.OppiaRegion import org.oppia.android.app.model.RegionSupportDefinition import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.robolectric.RobolectricModule +import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.locale.testing.LocaleTestModule import org.oppia.android.util.locale.testing.TestOppiaBidiFormatter @@ -56,13 +58,6 @@ class DisplayLocaleImplTest { setUpTestApplicationComponent() } - @Test - fun testCreateDisplayLocaleImpl_defaultInstance_hasDefaultInstanceContext() { - val impl = createDisplayLocaleImpl(OppiaLocaleContext.getDefaultInstance()) - - assertThat(impl.localeContext).isEqualToDefaultInstance() - } - @Test fun testCreateDisplayLocaleImpl_forProvidedContext_hasCorrectInstanceContext() { val impl = createDisplayLocaleImpl(EGYPT_ARABIC_CONTEXT) @@ -72,7 +67,7 @@ class DisplayLocaleImplTest { @Test fun testToString_returnsNonDefaultString() { - val impl = createDisplayLocaleImpl(OppiaLocaleContext.getDefaultInstance()) + val impl = createDisplayLocaleImpl(EGYPT_ARABIC_CONTEXT) val str = impl.toString() @@ -83,14 +78,14 @@ class DisplayLocaleImplTest { @Test fun testEquals_withNullValue_returnsFalse() { - val impl = createDisplayLocaleImpl(OppiaLocaleContext.getDefaultInstance()) + val impl = createDisplayLocaleImpl(EGYPT_ARABIC_CONTEXT) assertThat(impl).isNotEqualTo(null) } @Test fun testEquals_withSameObject_returnsTrue() { - val impl = createDisplayLocaleImpl(OppiaLocaleContext.getDefaultInstance()) + val impl = createDisplayLocaleImpl(EGYPT_ARABIC_CONTEXT) assertThat(impl).isEqualTo(impl) } @@ -615,8 +610,10 @@ class DisplayLocaleImplTest { } } - private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl = - DisplayLocaleImpl(context, machineLocale, androidLocaleFactory, formatterFactory) + private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl { + val formattingLocale = androidLocaleFactory.createOneOffAndroidLocale(context) + return DisplayLocaleImpl(context, formattingLocale, machineLocale, formatterFactory) + } private fun setUpTestApplicationComponent() { DaggerDisplayLocaleImplTest_TestApplicationComponent.builder() @@ -639,7 +636,8 @@ class DisplayLocaleImplTest { @Singleton @Component( modules = [ - TestModule::class, LocaleTestModule::class, FakeOppiaClockModule::class + TestModule::class, LocaleTestModule::class, FakeOppiaClockModule::class, + TestDispatcherModule::class, RobolectricModule::class ] ) interface TestApplicationComponent { diff --git a/utility/src/test/java/org/oppia/android/util/parser/html/CustomHtmlContentHandlerTest.kt b/utility/src/test/java/org/oppia/android/util/parser/html/CustomHtmlContentHandlerTest.kt index 5cba77e357d..2042ef72ec8 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/html/CustomHtmlContentHandlerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/html/CustomHtmlContentHandlerTest.kt @@ -311,8 +311,10 @@ class CustomHtmlContentHandlerTest { ) } - private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl = - DisplayLocaleImpl(context, machineLocale, androidLocaleFactory, formatterFactory) + private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl { + val formattingLocale = androidLocaleFactory.createOneOffAndroidLocale(context) + return DisplayLocaleImpl(context, formattingLocale, machineLocale, formatterFactory) + } private class FakeTagHandler : CustomHtmlContentHandler.CustomTagHandler { var handleTagCalled = false diff --git a/utility/src/test/java/org/oppia/android/util/parser/html/LiTagHandlerTest.kt b/utility/src/test/java/org/oppia/android/util/parser/html/LiTagHandlerTest.kt index 46e4ca83387..1341bc68776 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/html/LiTagHandlerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/html/LiTagHandlerTest.kt @@ -137,8 +137,10 @@ class LiTagHandlerTest { .hasLength(4) } - private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl = - DisplayLocaleImpl(context, machineLocale, androidLocaleFactory, formatterFactory) + private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl { + val formattingLocale = androidLocaleFactory.createOneOffAndroidLocale(context) + return DisplayLocaleImpl(context, formattingLocale, machineLocale, formatterFactory) + } private fun Spannable.getSpansFromWholeString(spanClass: KClass): Array = getSpans(/* start= */ 0, /* end= */ length, spanClass.javaObjectType) From 79878cd134857d2581b7c42f20fafd6060c0d316 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 19 Jan 2024 21:27:12 +0000 Subject: [PATCH 07/21] Some more robustness fixes. The main change here is ensuring that Bazel 4.0.0 is used & bzlmod disabled in newer versions of Bazel when running operations in a test Bazel environment. This commit also introduces some more timing tweaks on CommandExecutor for some tests, though these only affect very specific tests (as many script tests directly call a script's main() function and thus don't overwrite its executor behavior). This commit attempted to introduce "--batch" mode to runs, but the isolation didn't actually seem to improve stability and, instead, substantially slowed down some of the tests. --- .../scripts/ci/ComputeAffectedTests.kt | 11 +++-- .../scripts/testing/TestBazelWorkspace.kt | 29 +++++++++--- .../org/oppia/android/scripts/ci/BUILD.bazel | 2 +- .../scripts/ci/ComputeAffectedTestsTest.kt | 15 ++++--- .../android/scripts/common/BazelClientTest.kt | 44 ++++++++----------- .../oppia/android/scripts/license/BUILD.bazel | 1 + .../oppia/android/scripts/maven/BUILD.bazel | 1 + 7 files changed, 63 insertions(+), 40 deletions(-) diff --git a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt index f7cc482c72a..5437874f191 100644 --- a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt +++ b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt @@ -1,6 +1,8 @@ package org.oppia.android.scripts.ci import org.oppia.android.scripts.common.BazelClient +import org.oppia.android.scripts.common.CommandExecutor +import org.oppia.android.scripts.common.CommandExecutorImpl import org.oppia.android.scripts.common.GitClient import org.oppia.android.scripts.common.ProtoStringEncoder.Companion.toCompressedBase64 import org.oppia.android.scripts.proto.AffectedTestsBucket @@ -73,9 +75,10 @@ private fun String.toBooleanStrictOrNull(): Boolean? { /** Utility used to compute affected test targets. */ class ComputeAffectedTests( - val maxTestCountPerLargeShard: Int = MAX_TEST_COUNT_PER_LARGE_SHARD, - val maxTestCountPerMediumShard: Int = MAX_TEST_COUNT_PER_MEDIUM_SHARD, - val maxTestCountPerSmallShard: Int = MAX_TEST_COUNT_PER_SMALL_SHARD + private val maxTestCountPerLargeShard: Int = MAX_TEST_COUNT_PER_LARGE_SHARD, + private val maxTestCountPerMediumShard: Int = MAX_TEST_COUNT_PER_MEDIUM_SHARD, + private val maxTestCountPerSmallShard: Int = MAX_TEST_COUNT_PER_SMALL_SHARD, + private val commandExecutor: CommandExecutor = CommandExecutorImpl() ) { private companion object { private const val GENERIC_TEST_BUCKET_NAME = "generic" @@ -106,7 +109,7 @@ class ComputeAffectedTests( println("Running from directory root: $rootDirectory") val gitClient = GitClient(rootDirectory, baseDevelopBranchReference) - val bazelClient = BazelClient(rootDirectory) + val bazelClient = BazelClient(rootDirectory, commandExecutor) println("Current branch: ${gitClient.currentBranch}") println("Most recent common commit: ${gitClient.branchMergeBase}") diff --git a/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt b/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt index 68487b6062b..f1230c0f63d 100644 --- a/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt +++ b/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt @@ -4,6 +4,9 @@ import com.google.common.truth.Truth.assertThat import org.junit.rules.TemporaryFolder import java.io.File +/** The version of Bazel to use in tests that set up Bazel workspaces. */ +const val BAZEL_VERSION = "4.0.0" + /** * Test utility for generating various test & library targets in the specified [TemporaryFolder]. * This is meant to be used to arrange the local test filesystem for use with a real Bazel @@ -23,6 +26,13 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { */ val rootBuildFile: File by lazy { temporaryRootFolder.newFile("BUILD.bazel") } + private val bazelVersionFile by lazy { + temporaryRootFolder.newFile(".bazelversion").also { it.writeText(BAZEL_VERSION) } + } + private val bazelRcFile by lazy { + temporaryRootFolder.newFile(".bazelrc").also { it.writeText("--noenable_bzlmod") } + } + private val testFileMap = mutableMapOf() private val libraryFileMap = mutableMapOf() private val testDependencyNameMap = mutableMapOf() @@ -33,9 +43,11 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { /** Initializes the local Bazel workspace by introducing a new, empty WORKSPACE file. */ fun initEmptyWorkspace() { - // Sanity check, but in reality this is just initializing workspaceFile to ensure that it + // Sanity checks, but in reality this is just initializing workspaceFile to ensure that it // exists. assertThat(workspaceFile.exists()).isTrue() + assertThat(bazelVersionFile.exists()).isTrue() + assertThat(bazelRcFile.exists()).isTrue() } /** @@ -61,6 +73,8 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { withExtraDependency: String? = null, subpackage: String? = null ): Iterable { + initEmptyWorkspace() // Ensure the workspace is at least initialized. + check(testName !in testFileMap) { "Test '$testName' already set up" } val prereqFiles = ensureWorkspaceIsConfiguredForKotlin() val (dependencyTargetName, libPrereqFiles) = if (withGeneratedDependency) { @@ -109,6 +123,8 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { withExtraDependency: String? = null, subpackage: String? = null ): Iterable { + initEmptyWorkspace() // Ensure the workspace is at least initialized. + check(testName !in testFileMap) { "Test '$testName' already exists" } val testFile = if (subpackage != null) { if (!File(temporaryRootFolder.root, subpackage.replace(".", "/")).exists()) { @@ -137,6 +153,8 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { * iterable of files that were changed as part of generating this library */ fun createLibrary(dependencyName: String): Pair> { + initEmptyWorkspace() // Ensure the workspace is at least initialized. + val libTargetName = "${dependencyName}_lib" check("//:$libTargetName" !in libraryFileMap) { "Library '$dependencyName' already exists" } val prereqFiles = ensureWorkspaceIsConfiguredForKotlin() @@ -187,6 +205,7 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { /** Appends rules_jvm_external configuration to the WORKSPACE file if not done already. */ fun setUpWorkspaceForRulesJvmExternal(depsList: List) { if (!isConfiguredForRulesJvmExternal) { + initEmptyWorkspace() workspaceFile.appendText("artifactsList = [") for (dep in depsList) { workspaceFile.appendText("\"$dep\",\n") @@ -198,23 +217,23 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { RULES_JVM_EXTERNAL_TAG = "4.0" RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169" - + http_archive( name = "rules_jvm_external", strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, sha256 = RULES_JVM_EXTERNAL_SHA, url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, ) - + load("@rules_jvm_external//:defs.bzl", "maven_install") - + maven_install( artifacts = artifactsList, repositories = [ "https://maven.google.com", "https://repo1.maven.org/maven2", ], - ) + ) """.trimIndent() + "\n" ) diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel index 3160447f15f..fcdb77f2f1d 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel @@ -8,7 +8,7 @@ kt_jvm_test( name = "ComputeAffectedTestsTest", size = "large", srcs = ["ComputeAffectedTestsTest.kt"], - shard_count = 8, + shard_count = 24, deps = [ "//scripts/src/java/org/oppia/android/scripts/ci:compute_affected_tests_lib", "//scripts/src/java/org/oppia/android/scripts/common:proto_string_encoder", diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt index 5bbdc432d62..2bf59212f66 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt @@ -16,6 +16,7 @@ import java.io.ByteArrayOutputStream import java.io.File import java.io.OutputStream import java.io.PrintStream +import java.util.concurrent.TimeUnit /** * Tests for the compute_affected_tests utility. @@ -28,13 +29,12 @@ import java.io.PrintStream // Function name: test names are conventionally named with underscores. @Suppress("SameParameterValue", "FunctionName") class ComputeAffectedTestsTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + + private val commandExecutor by lazy { initiazeCommandExecutorWithLongProcessWaitTime() } private lateinit var testBazelWorkspace: TestBazelWorkspace private lateinit var testGitRepository: TestGitRepository - private lateinit var pendingOutputStream: ByteArrayOutputStream private lateinit var originalStandardOutputStream: OutputStream @@ -724,7 +724,8 @@ class ComputeAffectedTestsTest { ComputeAffectedTests( maxTestCountPerLargeShard = maxTestCountPerLargeShard, maxTestCountPerMediumShard = maxTestCountPerMediumShard, - maxTestCountPerSmallShard = maxTestCountPerSmallShard + maxTestCountPerSmallShard = maxTestCountPerSmallShard, + commandExecutor = commandExecutor ).compute( pathToRoot = tempFolder.root.absolutePath, pathToOutputFile = outputLog.absolutePath, @@ -862,4 +863,8 @@ class ComputeAffectedTestsTest { testGitRepository.stageFileForCommit(libFile) testGitRepository.commit(message = "Modified library $name") } + + private fun initiazeCommandExecutorWithLongProcessWaitTime(): CommandExecutorImpl { + return CommandExecutorImpl(processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES) + } } diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt index 07aa4d4134c..2109155025f 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt @@ -25,20 +25,14 @@ import java.util.concurrent.TimeUnit // Function name: test names are conventionally named with underscores. @Suppress("SameParameterValue", "FunctionName") class BazelClientTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() - @Rule - @JvmField - val mockitoRule: MockitoRule = MockitoJUnit.rule() + @Mock lateinit var mockCommandExecutor: CommandExecutor private val commandExecutor by lazy { initiazeCommandExecutorWithLongProcessWaitTime() } private lateinit var testBazelWorkspace: TestBazelWorkspace - @Mock - lateinit var mockCommandExecutor: CommandExecutor - @Before fun setUp() { testBazelWorkspace = TestBazelWorkspace(tempFolder) @@ -46,7 +40,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_emptyFolder_fails() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) val exception = assertThrows() { bazelClient.retrieveAllTestTargets() @@ -59,7 +53,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_emptyWorkspace_fails() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() val exception = assertThrows() { @@ -73,7 +67,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_workspaceWithTest_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("ExampleTest") @@ -84,7 +78,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_workspaceWithMultipleTests_returnsTestTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest") @@ -106,7 +100,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forFileNotInBuildGraph_returnsEmptyList() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() tempFolder.newFile("filenotingraph") @@ -117,7 +111,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forTestFile_returnsBazelTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") @@ -128,7 +122,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forMultipleMixedFiles_returnsBazelTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", withGeneratedDependency = true) @@ -157,7 +151,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forTargetWithNoTestDependency_returnsNoTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary("SomeDependency") testBazelWorkspace.createTest("FirstTest") @@ -170,7 +164,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forTestFileTarget_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") @@ -181,7 +175,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forDependentFileTarget_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest", withGeneratedDependency = true) @@ -192,7 +186,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forMixedFileTargets_returnsRelatedTestTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary("ExtraDep") testBazelWorkspace.createTest("FirstTest", withExtraDependency = "//:ExtraDep_lib") @@ -227,7 +221,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forNoFiles_returnsEmptyList() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() val testTargets = bazelClient.retrieveTransitiveTestTargets(listOf()) @@ -238,7 +232,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forBuildFile_returnsAllTestsInThatBuildFile() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest") @@ -253,7 +247,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forMultipleBuildFiles_returnsAllRelatedTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", subpackage = "two") @@ -269,7 +263,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forBzlFile_returnsRelatedTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() // Generate tests. testBazelWorkspace.createTest("FirstTest") @@ -298,7 +292,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forWorkspace_returnsAllTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", subpackage = "two") diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel index 707ec3e8081..e4499086079 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel @@ -18,6 +18,7 @@ kt_jvm_test( kt_jvm_test( name = "MavenDependenciesListCheckTest", size = "large", + shard_count = 4, srcs = ["MavenDependenciesListCheckTest.kt"], deps = [ "//scripts/src/java/org/oppia/android/scripts/license:maven_dependencies_list_check_lib", diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel index a46ee7ad500..da5af646bc2 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel @@ -8,6 +8,7 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_test") kt_jvm_test( name = "GenerateMavenDependenciesListTest", size = "large", + shard_count = 4, srcs = ["GenerateMavenDependenciesListTest.kt"], deps = [ "//scripts/src/java/org/oppia/android/scripts/common:command_executor", From bd97611f1d54f956bede86fa0379da726c9e3542 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Sat, 20 Jan 2024 01:39:52 +0000 Subject: [PATCH 08/21] Fix BUILD file lint issue. --- .../src/javatests/org/oppia/android/scripts/license/BUILD.bazel | 2 +- .../src/javatests/org/oppia/android/scripts/maven/BUILD.bazel | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel index e4499086079..ab6b739a3b8 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel @@ -18,8 +18,8 @@ kt_jvm_test( kt_jvm_test( name = "MavenDependenciesListCheckTest", size = "large", - shard_count = 4, srcs = ["MavenDependenciesListCheckTest.kt"], + shard_count = 4, deps = [ "//scripts/src/java/org/oppia/android/scripts/license:maven_dependencies_list_check_lib", "//scripts/src/java/org/oppia/android/scripts/testing:test_bazel_workspace", diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel index da5af646bc2..68b0d6fad28 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel @@ -8,8 +8,8 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_test") kt_jvm_test( name = "GenerateMavenDependenciesListTest", size = "large", - shard_count = 4, srcs = ["GenerateMavenDependenciesListTest.kt"], + shard_count = 4, deps = [ "//scripts/src/java/org/oppia/android/scripts/common:command_executor", "//scripts/src/java/org/oppia/android/scripts/maven:generate_maven_dependencies_list_lib", From 1a666a9ceb1c2f8809a26e564f793a6299053ce5 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Tue, 6 Feb 2024 23:43:51 +0000 Subject: [PATCH 09/21] Post-merge fixes. --- .../android/testing/FakeFirestoreEventLoggerTest.kt | 10 +++++----- .../firebase/DebugFirestoreEventLoggerImplTest.kt | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt b/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt index 41ce667b82f..b04b5d13890 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt @@ -78,7 +78,7 @@ class FakeFirestoreEventLoggerTest { @Test fun testfakeEventLogger_logNothing_getMostRecent_returnsFailure() { - assertThrows(NoSuchElementException::class) { fakeEventLogger.getMostRecentEvent() } + assertThrows() { fakeEventLogger.getMostRecentEvent() } } @Test @@ -86,7 +86,7 @@ class FakeFirestoreEventLoggerTest { eventLogger.uploadEvent(eventLog1) fakeEventLogger.clearAllEvents() - val eventException = assertThrows(NoSuchElementException::class) { + val eventException = assertThrows() { fakeEventLogger.getMostRecentEvent() } @@ -144,7 +144,7 @@ class FakeFirestoreEventLoggerTest { @Test fun testGetOldestEvent_noEventsLogged_throwsException() { - assertThrows(NoSuchElementException::class) { fakeEventLogger.getOldestEvent() } + assertThrows() { fakeEventLogger.getOldestEvent() } } @Test @@ -172,7 +172,7 @@ class FakeFirestoreEventLoggerTest { eventLogger.uploadEvent(eventLog1) fakeEventLogger.clearAllEvents() - assertThrows(NoSuchElementException::class) { fakeEventLogger.getOldestEvent() } + assertThrows() { fakeEventLogger.getOldestEvent() } } @Test @@ -237,7 +237,7 @@ class FakeFirestoreEventLoggerTest { eventLogger.uploadEvent(eventLog2) eventLogger.uploadEvent(eventLog1) - assertThrows(IllegalArgumentException::class) { + assertThrows() { fakeEventLogger.getMostRecentEvents(count = -1) } } diff --git a/utility/src/test/java/org/oppia/android/util/logging/firebase/DebugFirestoreEventLoggerImplTest.kt b/utility/src/test/java/org/oppia/android/util/logging/firebase/DebugFirestoreEventLoggerImplTest.kt index 011eb532a09..32d83a0d91c 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/firebase/DebugFirestoreEventLoggerImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/firebase/DebugFirestoreEventLoggerImplTest.kt @@ -79,7 +79,7 @@ class DebugFirestoreEventLoggerImplTest { @Test fun testDebugFirestoreEventLogger_logNothing_getMostRecent_returnsFailure() { - assertThrows(NoSuchElementException::class) { debugFirestoreLoggerImpl.getMostRecentEvent() } + assertThrows() { debugFirestoreLoggerImpl.getMostRecentEvent() } } @Test @@ -87,7 +87,7 @@ class DebugFirestoreEventLoggerImplTest { eventLogger.uploadEvent(eventLog1) debugFirestoreLoggerImpl.clearAllEvents() - val eventException = assertThrows(NoSuchElementException::class) { + val eventException = assertThrows() { debugFirestoreLoggerImpl.getMostRecentEvent() } From a2ee5d31d47ed2392847bf0298d22c41bd829dde Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 21:50:42 +0000 Subject: [PATCH 10/21] Add smoke tests for instr. binaries & tests. --- instrumentation/BUILD.bazel | 7 +++++++ instrumentation/oppia_instrumentation_test.bzl | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/instrumentation/BUILD.bazel b/instrumentation/BUILD.bazel index 03c56337516..eeb4f436d50 100644 --- a/instrumentation/BUILD.bazel +++ b/instrumentation/BUILD.bazel @@ -8,6 +8,8 @@ Note that: exports_files(["src/javatests/AndroidManifest.xml"]) +load("@bazel_skylib//rules:build_test.bzl", "build_test") + # Used for end-to-end tests android_binary( name = "oppia_test", @@ -29,3 +31,8 @@ android_binary( "//instrumentation/src/java/org/oppia/android/instrumentation/application:oppia_test_application", ], ) + +build_test( + name = "oppia_test_binary_smoke_test", + targets = [":oppia_test"], +) diff --git a/instrumentation/oppia_instrumentation_test.bzl b/instrumentation/oppia_instrumentation_test.bzl index 63d8413cd2c..7196865c93c 100644 --- a/instrumentation/oppia_instrumentation_test.bzl +++ b/instrumentation/oppia_instrumentation_test.bzl @@ -3,6 +3,7 @@ Instrumentation macros to define up end-to-end tests. """ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +load("@bazel_skylib//rules:build_test.bzl", "build_test") def oppia_instrumentation_test( name, @@ -39,3 +40,8 @@ def oppia_instrumentation_test( test_app = ":%sBinary" % name, tags = ["manual"], ) + + build_test( + name = "%s_smoke_test" % name, + targets = [name, "%sBinary" % name], + ) From d5b90128f7bb1eb5f1dc5e6de02b3b01d2c02751 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 21:53:36 +0000 Subject: [PATCH 11/21] Some minor refactoring for readability. --- instrumentation/oppia_instrumentation_test.bzl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/instrumentation/oppia_instrumentation_test.bzl b/instrumentation/oppia_instrumentation_test.bzl index 7196865c93c..8a3f74b64ce 100644 --- a/instrumentation/oppia_instrumentation_test.bzl +++ b/instrumentation/oppia_instrumentation_test.bzl @@ -17,31 +17,34 @@ def oppia_instrumentation_test( srcs: list of str. List of test files corresponding to this test suite. deps: list of str. The list of dependencies needed to build and run the test. """ + test_lib_name = "%s_lib" % name + test_binary_name = "%sBinary" % name + kt_android_library( - name = "%s_lib" % name, + name = test_lib_name, testonly = True, srcs = srcs, deps = deps, ) native.android_binary( - name = "%sBinary" % name, + name = test_binary_name, testonly = True, custom_package = "org.oppia.android", instruments = "//instrumentation:oppia_test", manifest = "//instrumentation:src/javatests/AndroidManifest.xml", - deps = [":%s_lib" % name], + deps = [test_lib_name], ) # TODO(#3617): Target isn't supported yet. Remove the manual tag once fixed. native.android_instrumentation_test( name = name, target_device = "@android_test_support//tools/android/emulated_devices/generic_phone:android_23_x86_qemu2", - test_app = ":%sBinary" % name, + test_app = test_binary_name, tags = ["manual"], ) build_test( name = "%s_smoke_test" % name, - targets = [name, "%sBinary" % name], + targets = [name, test_binary_name], ) From e6ec869dccfc7fdddd431585e8344e61bbd53467 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 22:48:22 +0000 Subject: [PATCH 12/21] Fixed broken instrumentation builds. This was done by removing the //testing dependency and, instead, having instrumentation targets depend on the direct module within //testing that they need to build. This module & its corresponding implementation binding (and tests) needed to be moved out of //testing and into their own /firebase package. --- .../AdministratorControlsActivityTest.kt | 2 +- .../AdministratorControlsFragmentTest.kt | 2 +- .../AppVersionActivityTest.kt | 2 +- .../ProfileAndDeviceIdActivityTest.kt | 2 +- .../ProfileAndDeviceIdFragmentTest.kt | 2 +- .../CompletedStoryListActivityTest.kt | 2 +- .../LessonThumbnailImageViewTest.kt | 2 +- .../MathExpressionInteractionsViewTest.kt | 2 +- .../AppCompatCheckBoxBindingAdaptersTest.kt | 2 +- .../CircularProgressIndicatorAdaptersTest.kt | 2 +- .../DrawableBindingAdaptersTest.kt | 2 +- .../ImageViewBindingAdaptersTest.kt | 2 +- .../databinding/MarginBindingAdaptersTest.kt | 2 +- ...StateAssemblerMarginBindingAdaptersTest.kt | 2 +- ...tateAssemblerPaddingBindingAdaptersTest.kt | 2 +- .../TextViewBindingAdaptersTest.kt | 2 +- .../databinding/ViewBindingAdaptersTest.kt | 2 +- .../DeveloperOptionsActivityTest.kt | 2 +- .../DeveloperOptionsFragmentTest.kt | 2 +- .../MarkChaptersCompletedActivityTest.kt | 2 +- .../MarkChaptersCompletedFragmentTest.kt | 2 +- .../MarkStoriesCompletedActivityTest.kt | 2 +- .../MarkStoriesCompletedFragmentTest.kt | 2 +- .../MarkTopicsCompletedActivityTest.kt | 2 +- .../MarkTopicsCompletedFragmentTest.kt | 2 +- .../devoptions/ViewEventLogsActivityTest.kt | 2 +- .../devoptions/ViewEventLogsFragmentTest.kt | 2 +- .../ForceNetworkTypeActivityTest.kt | 2 +- .../ForceNetworkTypeFragmentTest.kt | 2 +- .../MathExpressionParserActivityTest.kt | 2 +- .../MathExpressionParserFragmentTest.kt | 2 +- .../android/app/faq/FAQListFragmentTest.kt | 2 +- .../android/app/faq/FAQSingleActivityTest.kt | 2 +- .../android/app/faq/FaqListActivityTest.kt | 2 +- .../android/app/help/HelpActivityTest.kt | 2 +- .../android/app/help/HelpFragmentTest.kt | 2 +- .../android/app/home/HomeActivityTest.kt | 2 +- .../app/home/RecentlyPlayedFragmentTest.kt | 2 +- .../app/home/TopicSummaryViewModelTest.kt | 2 +- .../android/app/home/WelcomeViewModelTest.kt | 2 +- .../PromotedStoryListViewModelTest.kt | 2 +- .../PromotedStoryViewModelTest.kt | 2 +- .../mydownloads/MyDownloadsActivityTest.kt | 2 +- .../mydownloads/MyDownloadsFragmentTest.kt | 2 +- .../notice/BetaNoticeDialogFragmentTest.kt | 2 +- ...dAppDeprecationNoticeDialogFragmentTest.kt | 2 +- ...labilityUpgradeNoticeDialogFragmentTest.kt | 2 +- ...lAppDeprecationNoticeDialogFragmentTest.kt | 2 +- .../OsDeprecationNoticeDialogFragmentTest.kt | 2 +- .../app/onboarding/OnboardingActivityTest.kt | 2 +- .../app/onboarding/OnboardingFragmentTest.kt | 2 +- .../OngoingTopicListActivityTest.kt | 2 +- .../app/options/AppLanguageActivityTest.kt | 2 +- .../app/options/AppLanguageFragmentTest.kt | 2 +- .../app/options/AudioLanguageActivityTest.kt | 2 +- .../app/options/AudioLanguageFragmentTest.kt | 2 +- .../app/options/OptionsActivityTest.kt | 2 +- .../app/options/OptionsFragmentTest.kt | 2 +- .../options/ReadingTextSizeActivityTest.kt | 2 +- .../options/ReadingTextSizeFragmentTest.kt | 2 +- .../android/app/parser/HtmlParserTest.kt | 2 +- .../app/player/audio/AudioFragmentTest.kt | 2 +- .../exploration/BottomSheetOptionsMenuTest.kt | 2 +- .../exploration/ExplorationActivityTest.kt | 2 +- .../app/player/state/StateFragmentTest.kt | 2 +- .../app/policies/PoliciesActivityTest.kt | 2 +- .../app/policies/PoliciesFragmentTest.kt | 2 +- .../app/profile/AddProfileActivityTest.kt | 2 +- .../app/profile/AdminAuthActivityTest.kt | 2 +- .../app/profile/AdminPinActivityTest.kt | 2 +- .../app/profile/PinPasswordActivityTest.kt | 2 +- .../app/profile/ProfileChooserActivityTest.kt | 2 +- .../app/profile/ProfileChooserFragmentTest.kt | 2 +- .../ProfilePictureActivityTest.kt | 2 +- .../ProfileProgressActivityTest.kt | 2 +- .../ProfileProgressFragmentTest.kt | 2 +- .../app/recyclerview/BindableAdapterTest.kt | 2 +- .../resumelesson/ResumeLessonActivityTest.kt | 2 +- .../resumelesson/ResumeLessonFragmentTest.kt | 2 +- .../profile/ProfileEditActivityTest.kt | 2 +- .../profile/ProfileEditFragmentTest.kt | 2 +- .../profile/ProfileListActivityTest.kt | 2 +- .../profile/ProfileListFragmentTest.kt | 2 +- .../profile/ProfileRenameActivityTest.kt | 2 +- .../profile/ProfileRenameFragmentTest.kt | 2 +- .../profile/ProfileResetPinActivityTest.kt | 2 +- .../profile/ProfileResetPinFragmentTest.kt | 2 +- .../android/app/splash/SplashActivityTest.kt | 2 +- .../app/spotlight/SpotlightFragmentTest.kt | 2 +- .../android/app/story/StoryActivityTest.kt | 2 +- .../android/app/story/StoryFragmentTest.kt | 2 +- .../android/app/survey/SurveyActivityTest.kt | 2 +- .../android/app/survey/SurveyFragmentTest.kt | 2 +- .../app/testing/DragDropTestActivityTest.kt | 2 +- ...ionInputInteractionViewTestActivityTest.kt | 2 +- ...ImageRegionSelectionInteractionViewTest.kt | 2 +- .../InputInteractionViewTestActivityTest.kt | 2 +- .../NavigationDrawerActivityDebugTest.kt | 2 +- .../NavigationDrawerActivityProdTest.kt | 2 +- ...tioInputInteractionViewTestActivityTest.kt | 2 +- ...tFontScaleConfigurationUtilActivityTest.kt | 2 +- .../testing/TopicTestActivityForStoryTest.kt | 2 +- .../app/thirdparty/LicenseListActivityTest.kt | 2 +- .../app/thirdparty/LicenseListFragmentTest.kt | 2 +- .../LicenseTextViewerActivityTest.kt | 2 +- .../LicenseTextViewerFragmentTest.kt | 2 +- .../ThirdPartyDependencyListActivityTest.kt | 2 +- .../ThirdPartyDependencyListFragmentTest.kt | 2 +- .../android/app/topic/TopicActivityTest.kt | 2 +- .../android/app/topic/TopicFragmentTest.kt | 2 +- .../conceptcard/ConceptCardFragmentTest.kt | 2 +- .../app/topic/info/TopicInfoFragmentTest.kt | 2 +- .../topic/lessons/TopicLessonsFragmentTest.kt | 2 +- .../practice/TopicPracticeFragmentTest.kt | 2 +- .../QuestionPlayerActivityTest.kt | 2 +- .../revision/TopicRevisionFragmentTest.kt | 2 +- .../revisioncard/RevisionCardActivityTest.kt | 2 +- .../revisioncard/RevisionCardFragmentTest.kt | 2 +- .../app/utility/RatioExtensionsTest.kt | 2 +- .../walkthrough/WalkthroughActivityTest.kt | 2 +- .../WalkthroughFinalFragmentTest.kt | 2 +- .../WalkthroughTopicListFragmentTest.kt | 2 +- .../WalkthroughWelcomeFragmentTest.kt | 2 +- .../activity/ActivityIntentFactoriesTest.kt | 2 +- .../route/ActivityRouterModuleTest.kt | 2 +- .../app/activity/route/ActivityRouterTest.kt | 2 +- .../android/app/home/HomeActivityLocalTest.kt | 2 +- .../app/parser/FractionParsingUiErrorTest.kt | 2 +- .../parser/ListItemLeadingMarginSpanTest.kt | 2 +- .../app/parser/StringToRatioParserTest.kt | 2 +- .../ExplorationActivityLocalTest.kt | 2 +- .../player/state/StateFragmentLocalTest.kt | 2 +- .../ProfileChooserFragmentLocalTest.kt | 2 +- .../app/story/StoryActivityLocalTest.kt | 2 +- .../app/testing/CompletedStoryListSpanTest.kt | 2 +- .../oppia/android/app/testing/HomeSpanTest.kt | 2 +- .../app/testing/OngoingTopicListSpanTest.kt | 2 +- .../PlatformParameterIntegrationTest.kt | 2 +- .../app/testing/ProfileChooserSpanTest.kt | 2 +- .../testing/ProfileProgressSpanCountTest.kt | 2 +- .../app/testing/RecentlyPlayedSpanTest.kt | 2 +- .../app/testing/TopicRevisionSpanTest.kt | 2 +- .../app/testing/activity/TestActivityTest.kt | 2 +- .../AdministratorControlsFragmentTest.kt | 2 +- .../testing/options/OptionsFragmentTest.kt | 2 +- .../player/split/PlayerSplitScreenTest.kt | 2 +- .../state/StateFragmentAccessibilityTest.kt | 2 +- .../topic/info/TopicInfoFragmentLocalTest.kt | 2 +- .../lessons/TopicLessonsFragmentLocalTest.kt | 2 +- .../QuestionPlayerActivityLocalTest.kt | 2 +- .../RevisionCardActivityLocalTest.kt | 2 +- .../ActivityLanguageLocaleHandlerTest.kt | 2 +- .../AppLanguageResourceHandlerTest.kt | 2 +- .../AppLanguageWatcherMixinTest.kt | 2 +- .../app/utility/datetime/DateTimeUtilTest.kt | 2 +- .../MathExpressionAccessibilityUtilTest.kt | 2 +- .../domain/audio/AudioPlayerControllerTest.kt | 2 +- .../auth/AuthenticationControllerTest.kt | 4 +- .../ExplorationDataControllerTest.kt | 2 +- .../ExplorationProgressControllerTest.kt | 2 +- .../ExplorationCheckpointControllerTest.kt | 2 +- .../analytics/FirestoreDataControllerTest.kt | 2 +- .../analytics/LearnerAnalyticsLoggerTest.kt | 2 +- .../analytics/SurveyEventsLoggerTest.kt | 2 +- .../LogReportWorkManagerInitializerTest.kt | 2 +- .../loguploader/LogUploadWorkerTest.kt | 2 +- .../domain/survey/SurveyControllerTest.kt | 2 +- .../survey/SurveyProgressControllerTest.kt | 2 +- instrumentation/BUILD.bazel | 4 +- .../oppia_instrumentation_test.bzl | 2 +- .../instrumentation/application/BUILD.bazel | 2 +- .../application/TestApplicationComponent.kt | 2 +- testing/BUILD.bazel | 1 + .../android/testing/firebase/BUILD.bazel | 22 +++++++++ .../FakeFirebaseAuthWrapperImpl.kt | 2 +- .../TestAuthenticationModule.kt | 2 +- .../android/testing/firebase/BUILD.bazel | 48 +++++++++++++++++++ .../FakeFirebaseAuthWrapperImplTest.kt | 5 +- .../TestAuthenticationModuleTest.kt | 2 +- ...alizeDefaultLocaleRuleCustomContextTest.kt | 2 +- ...InitializeDefaultLocaleRuleOmissionTest.kt | 2 +- .../junit/InitializeDefaultLocaleRuleTest.kt | 2 +- 182 files changed, 254 insertions(+), 182 deletions(-) create mode 100644 testing/src/main/java/org/oppia/android/testing/firebase/BUILD.bazel rename testing/src/main/java/org/oppia/android/testing/{ => firebase}/FakeFirebaseAuthWrapperImpl.kt (97%) rename testing/src/main/java/org/oppia/android/testing/{ => firebase}/TestAuthenticationModule.kt (90%) create mode 100644 testing/src/test/java/org/oppia/android/testing/firebase/BUILD.bazel rename testing/src/test/java/org/oppia/android/testing/{ => firebase}/FakeFirebaseAuthWrapperImplTest.kt (95%) rename testing/src/test/java/org/oppia/android/testing/{ => firebase}/TestAuthenticationModuleTest.kt (98%) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt index 7d0dbf96afc..4a340d416ca 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt @@ -103,8 +103,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentTest.kt index ff5cba27e23..b50d9c099f2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentTest.kt @@ -91,8 +91,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt index cbe287cfaa9..82bc4bd09d3 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt @@ -81,8 +81,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt index 2710157c685..4a76dfd4479 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt @@ -72,8 +72,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index 9bd43e39012..925535d3433 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -101,8 +101,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.logging.TestSyncStatusManager diff --git a/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt index 17f0c3d6f73..60c1d8e03c9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt @@ -84,8 +84,8 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt b/app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt index 29a4743fe20..7eb357dd46a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt @@ -64,9 +64,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt b/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt index 768ba9a67a0..2b8ea2dc02d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt @@ -78,9 +78,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt index 7ea576a3ebb..ade4a20211d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt @@ -65,9 +65,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt index c84c6fc96b2..426294f59cf 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt @@ -68,10 +68,10 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt index 5a81aa9f654..9817db99f6a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt @@ -69,9 +69,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt index 72f19842249..d5690443bad 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt index 7bdc00ef976..b720fc78a5d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt @@ -78,9 +78,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt index 9e8a843ee06..0e7f32257a7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt @@ -77,9 +77,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt index 073add10f38..104b314ef64 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt @@ -75,9 +75,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt index ca6a286febb..235498e6ef2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt @@ -67,9 +67,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt index 9db806e5f0e..716820377d4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt @@ -72,9 +72,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt index 55bbad1e323..e2c0034aad8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt @@ -91,8 +91,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt index 8247b045e36..29ea1a94163 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt @@ -86,9 +86,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt index 59415795065..0c666f19607 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt index 6125413e6f6..af03c3a086e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt @@ -82,9 +82,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.topic.StoryProgressController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt index 8d8204d9684..e36a5e93b11 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt @@ -68,8 +68,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt index e67d776813a..489691717d9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt index 5a575360d80..5e9cfb3fdc4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt @@ -68,8 +68,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt index 78214587b28..47e4e0c33a0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt index 94dab9dd41d..a3a48b24828 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt @@ -69,7 +69,7 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt index 6ec2a227ec1..c42f916f8fa 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt @@ -83,7 +83,7 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeFirestoreInstanceWrapperImpl import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt index 7bc720e4ae0..c163e91f5e0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt @@ -69,8 +69,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeFragmentTest.kt index 25cccdd0bd1..596ce0b7623 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeFragmentTest.kt @@ -73,8 +73,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserActivityTest.kt index 517da7ca48a..c8c71821bc8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserActivityTest.kt @@ -65,8 +65,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt index cac62ddb6b4..b5d32fa77ee 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt @@ -74,10 +74,10 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt index 41fefe4329b..48da829d39e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt @@ -79,8 +79,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt index 90d49553c6c..9bfd477a36b 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt @@ -75,8 +75,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt index 680afbdeb44..9b25a1320d4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt index f00931977eb..f48c81b20ee 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt index 73cfb22be58..74fbc2f0e70 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt @@ -93,9 +93,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt index f5e058dfb62..7bcd6a4a196 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt @@ -121,10 +121,10 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt index 0aca510567f..e03c49a7ca7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt @@ -108,9 +108,9 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_STORY_0_EXPLORATION_0_CURRENT_VERSION diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/TopicSummaryViewModelTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/TopicSummaryViewModelTest.kt index 97fc6eb4f8c..19d874cc4a9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/TopicSummaryViewModelTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/TopicSummaryViewModelTest.kt @@ -66,8 +66,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/WelcomeViewModelTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/WelcomeViewModelTest.kt index 9ede16565ca..59ec6348510 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/WelcomeViewModelTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/WelcomeViewModelTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModelTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModelTest.kt index 99cd9dcd48e..5fd5a452779 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModelTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModelTest.kt @@ -66,8 +66,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModelTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModelTest.kt index ac309882dd1..0ac61cb1caa 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModelTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModelTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsActivityTest.kt index c42a30b0d55..ff6d31f06d7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsActivityTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt index 2441f617b3d..447b3d33ed1 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt @@ -71,8 +71,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/BetaNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/BetaNoticeDialogFragmentTest.kt index b98726e61f3..423822f8d19 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/BetaNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/BetaNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentTest.kt index 675426fe1eb..1af22c3a018 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/GeneralAvailabilityUpgradeNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/GeneralAvailabilityUpgradeNoticeDialogFragmentTest.kt index 29c1cde2351..171e62cd76c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/GeneralAvailabilityUpgradeNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/GeneralAvailabilityUpgradeNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentTest.kt index b981373f23d..db82579e4e9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/OsDeprecationNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/OsDeprecationNoticeDialogFragmentTest.kt index 1a522d1242d..51afc4b45e2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/OsDeprecationNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/OsDeprecationNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt index 23704d8ef36..10a388f6f4a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingFragmentTest.kt index e1227d6396f..43dc8c7cef0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingFragmentTest.kt @@ -88,8 +88,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt index bf37a173a38..d19b037818d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt @@ -82,8 +82,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt index 52e8a3cc154..3a2e401d0c5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageFragmentTest.kt index 07df1432348..cdb12ba202c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageFragmentTest.kt @@ -75,9 +75,9 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt index a87d648e98e..52be8c16782 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt index 9511978a74b..c7b5bfe0d86 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt @@ -74,8 +74,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt index 7aff373149c..dd9d85926e2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt index da8a49d42a3..8788ead2ab6 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt @@ -90,9 +90,9 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt index 6c54efd52c8..ee07540d885 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt index 56933de3067..df07900e97a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt index a655da4b9e0..571ba12ee85 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt @@ -102,10 +102,10 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.mockito.capture diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt index 173b024aa5f..4f3fb329a19 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt @@ -87,9 +87,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.IsOnRobolectric diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BottomSheetOptionsMenuTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BottomSheetOptionsMenuTest.kt index e390e6eea1a..e378c5285bd 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BottomSheetOptionsMenuTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BottomSheetOptionsMenuTest.kt @@ -70,9 +70,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt index 6245681585e..800916c4391 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt @@ -130,11 +130,11 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt index 0ee896da96d..f295bd9c3e5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt @@ -151,13 +151,13 @@ import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat diff --git a/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesActivityTest.kt index 95dd5e209d2..d8d95d2bab1 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesActivityTest.kt @@ -79,9 +79,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt index 2a318c9324a..07790dc33d8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt @@ -91,9 +91,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt index 175b0a62bf9..34dfb5f3b18 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt @@ -96,12 +96,12 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasHelperText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt index cb49cff5daa..cfabe083384 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt @@ -82,10 +82,10 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt index ea44c5d0d1c..b6fdce97344 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt @@ -91,11 +91,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt index f65a6f5f45a..90c78003600 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt @@ -87,11 +87,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt index 3442c182a7d..74d2f607988 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt index 0418a1339a8..5fff9c4006b 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt @@ -84,8 +84,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfilePictureActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfilePictureActivityTest.kt index 57d8180ed22..deb1c56251e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfilePictureActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfilePictureActivityTest.kt @@ -70,8 +70,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt index fc6c676d227..1cad2587804 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt index a4c5187cf25..2f83eb95f5d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt @@ -108,8 +108,8 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt b/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt index 1d48ecfcf71..c85a4d1c524 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt @@ -98,8 +98,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt index 988cbe99df3..e1e8707c853 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt @@ -82,9 +82,9 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt index 7bbc505d9dc..cf138d0d1f3 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt @@ -84,9 +84,9 @@ import org.oppia.android.domain.topic.RATIOS_STORY_ID_0 import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditActivityTest.kt index ab1aa374f27..1b3a285f095 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditActivityTest.kt @@ -79,8 +79,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt index a6f02aa8d7c..72346233590 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt @@ -84,10 +84,10 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt index fe93ebd5339..ec65e61024a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListFragmentTest.kt index 5e571de6a91..d94a0d75a11 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListFragmentTest.kt @@ -76,8 +76,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt index dc8534a913f..8aff6c18532 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt @@ -63,9 +63,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt index e95194f1de1..77f2aa4d7d0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt @@ -78,11 +78,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt index 0a0d8c22316..1e473a5e4a9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt @@ -64,9 +64,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt index ce23631d2a0..a78db5e7ce2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt @@ -79,11 +79,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt index 2ccef97076a..5fa6d2d41eb 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt @@ -95,10 +95,10 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter diff --git a/app/src/sharedTest/java/org/oppia/android/app/spotlight/SpotlightFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/spotlight/SpotlightFragmentTest.kt index 36f978df8c1..35df5325f0e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/spotlight/SpotlightFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/spotlight/SpotlightFragmentTest.kt @@ -72,9 +72,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt index c4a1776e814..1dda62f55f4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt @@ -85,9 +85,9 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt index 1e30882456e..3a9760cec83 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt @@ -116,8 +116,8 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.mockito.anyOrNull import org.oppia.android.testing.mockito.capture diff --git a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt index 4af4459dfef..61ace850d0e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt @@ -66,8 +66,8 @@ import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_2 import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt index f1398787462..cf4de9db27c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt @@ -89,8 +89,8 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.logging.EventLogSubject import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/DragDropTestActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/DragDropTestActivityTest.kt index 966ada83745..9e7aa64cd7e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/DragDropTestActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/DragDropTestActivityTest.kt @@ -72,8 +72,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/FractionInputInteractionViewTestActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/FractionInputInteractionViewTestActivityTest.kt index 7f5c52581a6..fb4b7a677f4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/FractionInputInteractionViewTestActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/FractionInputInteractionViewTestActivityTest.kt @@ -72,9 +72,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt index 11088d08c32..a2097b83928 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt @@ -83,10 +83,10 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.mockito.capture import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/InputInteractionViewTestActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/InputInteractionViewTestActivityTest.kt index 9041d7fa64d..2ce962ee356 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/InputInteractionViewTestActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/InputInteractionViewTestActivityTest.kt @@ -72,9 +72,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt index 0fac18cd543..6ede2fb1889 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt @@ -99,9 +99,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt index 9ec9f47ee79..2ac71b84993 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt @@ -107,9 +107,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/RatioInputInteractionViewTestActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/RatioInputInteractionViewTestActivityTest.kt index 57b3c1b0604..3968ee5bda7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/RatioInputInteractionViewTestActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/RatioInputInteractionViewTestActivityTest.kt @@ -79,9 +79,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivityTest.kt index 5815a6f0971..906d24f97a1 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivityTest.kt @@ -67,8 +67,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/TopicTestActivityForStoryTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/TopicTestActivityForStoryTest.kt index 03c8b40c315..f59711ead38 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/TopicTestActivityForStoryTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/TopicTestActivityForStoryTest.kt @@ -71,8 +71,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt index cc6d13cc284..b73ce7a0773 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListFragmentTest.kt index b50e60a6cfa..a8dd3ae36fd 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListFragmentTest.kt @@ -78,8 +78,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt index e1545f34c32..fb424fd2440 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt @@ -71,8 +71,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerFragmentTest.kt index 03d9b1c666a..07bb62e85c9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerFragmentTest.kt @@ -68,8 +68,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt index da5a3be066d..0a2fd1f4fa4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListFragmentTest.kt index 7691445e8a2..419fa4515ef 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListFragmentTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt index 8cf06d4dfb4..a82efa5f8cb 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt @@ -82,9 +82,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt index 0b42029e742..875d5936cb5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt @@ -94,8 +94,8 @@ import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt index 846884c529d..ac0c6ab72aa 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt @@ -103,11 +103,11 @@ import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RichTextViewMatcher.Companion.containsRichText import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt index a8ea6bf7896..9cfb0cd31d6 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt @@ -88,11 +88,11 @@ import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.espresso.ImageViewMatcher.Companion.hasScaleType +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt index 45abdc11143..ed64716a398 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt @@ -110,8 +110,8 @@ import org.oppia.android.domain.topic.RATIOS_STORY_ID_0 import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_STORY_0_EXPLORATION_0_CURRENT_VERSION diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt index 3f8b7eae213..c4ec0d84a88 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt @@ -88,8 +88,8 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt index 9bd58c51e8c..03423d24c83 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt @@ -126,11 +126,11 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt index 2daf1860e6b..de936dccb21 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt @@ -89,10 +89,10 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.ImageViewMatcher.Companion.hasScaleType +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt index 278c43c94d8..d570e4ec204 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt @@ -82,10 +82,10 @@ import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt index 7422990cea4..5831cc043b5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt @@ -104,11 +104,11 @@ import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt b/app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt index f8e1dedfdb9..fa2d84e008c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt index e289674673e..b583e012dc7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt @@ -74,8 +74,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughFinalFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughFinalFragmentTest.kt index 79e0caf8e70..2b6ab7d39bc 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughFinalFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughFinalFragmentTest.kt @@ -76,8 +76,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughTopicListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughTopicListFragmentTest.kt index d90dca2bb15..ee17909aa1d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughTopicListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughTopicListFragmentTest.kt @@ -77,11 +77,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.espresso.GenericViewMatchers.Companion.withOpaqueBackground +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt index 0634f55de2b..288fa127272 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt @@ -72,8 +72,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt b/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt index 47a343b0316..5d0844289a3 100644 --- a/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt index 104ee920e47..d90f9471261 100644 --- a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt index bea5d205bc5..f644125b802 100644 --- a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt @@ -74,8 +74,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt index 5c86e2b542c..d9eb01477ec 100644 --- a/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt b/app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt index 1b5dbb6b44a..d22af58e95b 100644 --- a/app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt @@ -58,8 +58,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt b/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt index 7aa3bba8f81..d993ffd3de8 100644 --- a/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt @@ -84,10 +84,10 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt b/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt index 794be78f7bc..acbf5c9fec8 100644 --- a/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt @@ -59,9 +59,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt index 9ba1741236e..edc6c0a91e3 100644 --- a/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt @@ -70,8 +70,8 @@ import org.oppia.android.domain.topic.TEST_STORY_ID_0 import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index 1d278a6a9da..c5442bff54e 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -138,7 +138,6 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor @@ -146,6 +145,7 @@ import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.KonfettiViewMatcher.Companion.hasActiveConfetti import org.oppia.android.testing.espresso.KonfettiViewMatcher.Companion.hasExpectedNumberOfActiveSystems +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/app/src/test/java/org/oppia/android/app/profile/ProfileChooserFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/profile/ProfileChooserFragmentLocalTest.kt index 35dd0310c63..9ac373f8edd 100644 --- a/app/src/test/java/org/oppia/android/app/profile/ProfileChooserFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/profile/ProfileChooserFragmentLocalTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/story/StoryActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/story/StoryActivityLocalTest.kt index ee383f8ec5b..2b60ef54096 100644 --- a/app/src/test/java/org/oppia/android/app/story/StoryActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/story/StoryActivityLocalTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/testing/CompletedStoryListSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/CompletedStoryListSpanTest.kt index 5ecdfdcf3cc..b837db394bf 100644 --- a/app/src/test/java/org/oppia/android/app/testing/CompletedStoryListSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/CompletedStoryListSpanTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt index 7ef9b806b93..1ed839774da 100644 --- a/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/OngoingTopicListSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/OngoingTopicListSpanTest.kt index b38e93506fd..6f4ecf14c9a 100644 --- a/app/src/test/java/org/oppia/android/app/testing/OngoingTopicListSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/OngoingTopicListSpanTest.kt @@ -65,8 +65,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/PlatformParameterIntegrationTest.kt b/app/src/test/java/org/oppia/android/app/testing/PlatformParameterIntegrationTest.kt index 0941c35c37c..68f5e78c518 100644 --- a/app/src/test/java/org/oppia/android/app/testing/PlatformParameterIntegrationTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/PlatformParameterIntegrationTest.kt @@ -81,8 +81,8 @@ import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUp import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.network.MockPlatformParameterService import org.oppia.android.testing.network.RetrofitTestModule diff --git a/app/src/test/java/org/oppia/android/app/testing/ProfileChooserSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/ProfileChooserSpanTest.kt index bfea9b66185..e0f11812c55 100644 --- a/app/src/test/java/org/oppia/android/app/testing/ProfileChooserSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/ProfileChooserSpanTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/testing/ProfileProgressSpanCountTest.kt b/app/src/test/java/org/oppia/android/app/testing/ProfileProgressSpanCountTest.kt index 83608031b85..4dd699158b9 100644 --- a/app/src/test/java/org/oppia/android/app/testing/ProfileProgressSpanCountTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/ProfileProgressSpanCountTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt index fed517d1912..8d05adc7ebf 100644 --- a/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt @@ -67,8 +67,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/test/java/org/oppia/android/app/testing/TopicRevisionSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/TopicRevisionSpanTest.kt index 5fe8a3fb3c8..55574573642 100644 --- a/app/src/test/java/org/oppia/android/app/testing/TopicRevisionSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/TopicRevisionSpanTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/activity/TestActivityTest.kt b/app/src/test/java/org/oppia/android/app/testing/activity/TestActivityTest.kt index f23ffd3dd6b..23e0211298b 100644 --- a/app/src/test/java/org/oppia/android/app/testing/activity/TestActivityTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/activity/TestActivityTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt b/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt index e6d2a7f4812..c9d01ffbce5 100644 --- a/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt @@ -70,8 +70,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt b/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt index bd942c2b0e4..462d087efd6 100644 --- a/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt @@ -66,8 +66,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/test/java/org/oppia/android/app/testing/player/split/PlayerSplitScreenTest.kt b/app/src/test/java/org/oppia/android/app/testing/player/split/PlayerSplitScreenTest.kt index 649ad5306b8..9e3c3edc499 100644 --- a/app/src/test/java/org/oppia/android/app/testing/player/split/PlayerSplitScreenTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/player/split/PlayerSplitScreenTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt b/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt index 7b33b32cad0..fd39ae0660e 100644 --- a/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt @@ -70,8 +70,8 @@ import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_4 import org.oppia.android.domain.topic.TEST_STORY_ID_0 import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt index cda806ffed1..f4e4081e436 100644 --- a/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentLocalTest.kt index b5ef86c5597..d48ad3f170c 100644 --- a/app/src/test/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentLocalTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt index b388ade740a..c5cfcca74d3 100644 --- a/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt @@ -87,10 +87,10 @@ import org.oppia.android.domain.question.WrongAnswerScorePenalty import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.topic.TEST_SKILL_ID_1 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.KonfettiViewMatcher.Companion.hasActiveConfetti +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityLocalTest.kt index 42b14d83075..8667a942f21 100644 --- a/app/src/test/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityLocalTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.topic.SUBTOPIC_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt index b234a2ae58a..408d7df55fa 100644 --- a/app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt @@ -73,9 +73,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt index 9ce6d2ce22c..5689577c68c 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt @@ -66,10 +66,10 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageWatcherMixinTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageWatcherMixinTest.kt index 95f05fa2ebb..f3231f3ac7e 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageWatcherMixinTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageWatcherMixinTest.kt @@ -71,9 +71,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt b/app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt index 5cd6e77f8cf..ea9a9d89a34 100644 --- a/app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt +++ b/app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt b/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt index 64800e1d5e8..97bff878691 100644 --- a/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt +++ b/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt @@ -78,8 +78,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration diff --git a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt index dbf2d829fe1..f7652a7e08b 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt @@ -53,11 +53,11 @@ import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_5 import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt index ca80f6e297d..4208244c46e 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt @@ -14,10 +14,10 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule -import org.oppia.android.testing.FakeFirebaseAuthWrapperImpl -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImpl +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.data.DataProvidersInjector diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt index 8aab3fe63ad..deee65f9f9a 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt @@ -50,10 +50,10 @@ import org.oppia.android.domain.topic.TEST_STORY_ID_2 import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.topic.TEST_TOPIC_ID_1 import org.oppia.android.testing.FakeExceptionLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt index f70c336f8bc..af38311d4b5 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt @@ -83,11 +83,11 @@ import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt index 6256ff55290..bfef2cedd25 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt @@ -49,10 +49,10 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_0 import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_1 -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_EXPLORATION_0_TITLE import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_STORY_0_EXPLORATION_0_CURRENT_VERSION diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt index 02b49b292a9..2de079ee3c0 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt @@ -27,9 +27,9 @@ import org.oppia.android.domain.oppialogger.FirestoreLogStorageCacheSize import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeFirestoreEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt index 74ab58fe35e..a036c2a304d 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt @@ -43,9 +43,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_2 import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_5 import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt index f82ab30c03d..a8962bb0af4 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt @@ -23,8 +23,8 @@ import org.oppia.android.domain.oppialogger.survey.SurveyEventsLogger import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeFirestoreEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkManagerInitializerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkManagerInitializerTest.kt index 50450041a09..9f9443e1708 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkManagerInitializerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkManagerInitializerTest.kt @@ -38,8 +38,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.testing.oppialogger.loguploader.FakeLogUploader import org.oppia.android.testing.FakeExceptionLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt index 1b715670f33..6ecf7a83e28 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt @@ -44,8 +44,8 @@ import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.FakeFirestoreEventLogger import org.oppia.android.testing.FakePerformanceMetricsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.logging.TestSyncStatusManager import org.oppia.android.testing.mockito.anyOrNull diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt index 4517b0b6504..8ea319426f5 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt @@ -19,9 +19,9 @@ import org.oppia.android.domain.oppialogger.ApplicationIdSeed import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.testing.FakeExceptionLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt index e0e8e1deade..ea336df027a 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt @@ -25,9 +25,9 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.FakeFirestoreEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/instrumentation/BUILD.bazel b/instrumentation/BUILD.bazel index eeb4f436d50..f6ffffcdc8a 100644 --- a/instrumentation/BUILD.bazel +++ b/instrumentation/BUILD.bazel @@ -6,10 +6,10 @@ Note that: of the test suite. """ -exports_files(["src/javatests/AndroidManifest.xml"]) - load("@bazel_skylib//rules:build_test.bzl", "build_test") +exports_files(["src/javatests/AndroidManifest.xml"]) + # Used for end-to-end tests android_binary( name = "oppia_test", diff --git a/instrumentation/oppia_instrumentation_test.bzl b/instrumentation/oppia_instrumentation_test.bzl index 8a3f74b64ce..6319bbf0ba3 100644 --- a/instrumentation/oppia_instrumentation_test.bzl +++ b/instrumentation/oppia_instrumentation_test.bzl @@ -2,8 +2,8 @@ Instrumentation macros to define up end-to-end tests. """ -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") def oppia_instrumentation_test( name, diff --git a/instrumentation/src/java/org/oppia/android/instrumentation/application/BUILD.bazel b/instrumentation/src/java/org/oppia/android/instrumentation/application/BUILD.bazel index 5d9fe4ac612..5e9c6382d77 100644 --- a/instrumentation/src/java/org/oppia/android/instrumentation/application/BUILD.bazel +++ b/instrumentation/src/java/org/oppia/android/instrumentation/application/BUILD.bazel @@ -25,7 +25,7 @@ kt_android_library( "//app/src/main/java/org/oppia/android/app/application/testing:testing_build_flavor_module", "//data/src/main/java/org/oppia/android/data/backends/gae:network_config_annotations", "//domain", - "//testing", + "//testing/src/main/java/org/oppia/android/testing/firebase:test_authentication_module", "//utility", "//utility/src/main/java/org/oppia/android/util/logging:standard_event_logging_configuration_module", "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", diff --git a/instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt b/instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt index fbf99ee8103..fe588b21105 100644 --- a/instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt +++ b/instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt @@ -45,7 +45,7 @@ import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUp import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.util.accessibility.AccessibilityProdModule import org.oppia.android.util.caching.AssetModule import org.oppia.android.util.caching.CachingModule diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 9bed8754f08..95a90957cfd 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -40,6 +40,7 @@ kt_android_library( "//model/src/main/proto:performance_metrics_event_logger_java_proto_lite", "//testing/src/main/java/org/oppia/android/testing/data:async_result_subject", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", + "//testing/src/main/java/org/oppia/android/testing/firebase:test_authentication_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/time:fake_oppia_clock", "//third_party:androidx_core_core-ktx", diff --git a/testing/src/main/java/org/oppia/android/testing/firebase/BUILD.bazel b/testing/src/main/java/org/oppia/android/testing/firebase/BUILD.bazel new file mode 100644 index 00000000000..78b9c0ffb82 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/firebase/BUILD.bazel @@ -0,0 +1,22 @@ +""" +Package for test-only Firebase utilities. +""" + +load("@dagger//:workspace_defs.bzl", "dagger_rules") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") + +kt_android_library( + name = "test_authentication_module", + testonly = True, + srcs = [ + "FakeFirebaseAuthWrapperImpl.kt", + "TestAuthenticationModule.kt", + ], + visibility = ["//:oppia_testing_visibility"], + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/auth:firebase_auth_wrapper", + ], +) + +dagger_rules() diff --git a/testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImpl.kt b/testing/src/main/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImpl.kt similarity index 97% rename from testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImpl.kt rename to testing/src/main/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImpl.kt index 8f8a9d54b53..616448ce4a2 100644 --- a/testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImpl.kt +++ b/testing/src/main/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImpl.kt @@ -1,4 +1,4 @@ -package org.oppia.android.testing +package org.oppia.android.testing.firebase import org.oppia.android.domain.auth.FirebaseAuthWrapper import org.oppia.android.domain.auth.FirebaseUserWrapper diff --git a/testing/src/main/java/org/oppia/android/testing/TestAuthenticationModule.kt b/testing/src/main/java/org/oppia/android/testing/firebase/TestAuthenticationModule.kt similarity index 90% rename from testing/src/main/java/org/oppia/android/testing/TestAuthenticationModule.kt rename to testing/src/main/java/org/oppia/android/testing/firebase/TestAuthenticationModule.kt index ed973730f5a..649f684b064 100644 --- a/testing/src/main/java/org/oppia/android/testing/TestAuthenticationModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/firebase/TestAuthenticationModule.kt @@ -1,4 +1,4 @@ -package org.oppia.android.testing +package org.oppia.android.testing.firebase import dagger.Module import dagger.Provides diff --git a/testing/src/test/java/org/oppia/android/testing/firebase/BUILD.bazel b/testing/src/test/java/org/oppia/android/testing/firebase/BUILD.bazel new file mode 100644 index 00000000000..c6d5f002b6d --- /dev/null +++ b/testing/src/test/java/org/oppia/android/testing/firebase/BUILD.bazel @@ -0,0 +1,48 @@ +""" +Tests for test-only Firebase utilities. +""" + +load("@dagger//:workspace_defs.bzl", "dagger_rules") +load("//:oppia_android_test.bzl", "oppia_android_test") + +oppia_android_test( + name = "FakeFirebaseAuthWrapperImplTest", + srcs = ["FakeFirebaseAuthWrapperImplTest.kt"], + custom_package = "org.oppia.android.testing.firebase", + test_class = "org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImplTest", + test_manifest = "//testing:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + ], +) + +oppia_android_test( + name = "TestAuthenticationModuleTest", + srcs = ["TestAuthenticationModuleTest.kt"], + custom_package = "org.oppia.android.testing.firebase", + test_class = "org.oppia.android.testing.firebase.TestAuthenticationModuleTest", + test_manifest = "//testing:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + ], +) + +dagger_rules() diff --git a/testing/src/test/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImplTest.kt b/testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt similarity index 95% rename from testing/src/test/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImplTest.kt rename to testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt index 3da520b2da4..d26d56c8480 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImplTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt @@ -1,4 +1,4 @@ -package org.oppia.android.testing +package org.oppia.android.testing.firebase import android.app.Application import android.content.Context @@ -14,7 +14,8 @@ import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.auth.FirebaseUserWrapper import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule -import org.oppia.android.testing.FakeFirebaseAuthWrapperImpl.FakeAuthState +import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImpl.FakeAuthState import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule diff --git a/testing/src/test/java/org/oppia/android/testing/TestAuthenticationModuleTest.kt b/testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt similarity index 98% rename from testing/src/test/java/org/oppia/android/testing/TestAuthenticationModuleTest.kt rename to testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt index e9a9a5f9b23..284f0b27bc4 100644 --- a/testing/src/test/java/org/oppia/android/testing/TestAuthenticationModuleTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt @@ -1,4 +1,4 @@ -package org.oppia.android.testing +package org.oppia.android.testing.firebase import android.app.Application import android.content.Context diff --git a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleCustomContextTest.kt b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleCustomContextTest.kt index 71f53946331..b5076ee912e 100644 --- a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleCustomContextTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleCustomContextTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule diff --git a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt index 385742c3a2c..5463cb0e542 100644 --- a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt @@ -57,9 +57,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule diff --git a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleTest.kt b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleTest.kt index 896afc9b13e..3a8f7eaf441 100644 --- a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule From 8dbf4dc04a95d95f394c25ab75755f945702b0d7 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 23:42:43 +0000 Subject: [PATCH 13/21] Add missing CODEOWNERS line. --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 00aff7fcea9..fb5866d071e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -110,6 +110,7 @@ /testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers +/testing/src/*/java/org/oppia/android/testing/firebase/ @oppia/android-app-infrastructure-reviewers /testing/src/*/java/org/oppia/android/testing/lightweightcheckpointing/ @oppia/android-app-infrastructure-reviewers /testing/src/*/java/org/oppia/android/testing/logging/ @oppia/android-app-infrastructure-reviewers /testing/src/*/java/org/oppia/android/testing/math/ @oppia/android-app-infrastructure-reviewers From 9c3805711833cb1b315f63abadd6ea0c8b5fd4f3 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 23:44:20 +0000 Subject: [PATCH 14/21] Remove old files from CODEOWNERS. --- .github/CODEOWNERS | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fb5866d071e..b4a1de1c04a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -94,18 +94,14 @@ /testing/src/main/java/org/oppia/android/testing/FakeAnalyticsEventLogger.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakeExceptionLogger.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthInstanceWrapperImpl.kt @oppia/android-app-infrastructure-reviewers -/testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImpl.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakeFirestoreEventLogger.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakeFirestoreInstanceWrapperImpl.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakePerformanceMetricAssessor.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakePerformanceMetricsEventLogger.kt @oppia/android-app-infrastructure-reviewers -/testing/src/main/java/org/oppia/android/testing/TestAuthenticationModule.kt @oppia/android-app-infrastructure-reviewers -/testing/src/test/java/org/oppia/android/testing/TestAuthenticationModuleTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/TestImageLoaderModule.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/TestLogReportingModule.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt @oppia/android-app-infrastructure-reviewers -/testing/src/test/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImplTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers From fad48ede88b6cdd4fc81dfa387e8b9bd0a6f8659 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 8 Feb 2024 00:46:30 +0000 Subject: [PATCH 15/21] Add missing tests for TestBlazeWorkspace changes. Also includes some minor clean-ups within TestBazelWorkspaceTest. --- .../scripts/testing/TestBazelWorkspace.kt | 3 +- .../scripts/testing/TestBazelWorkspaceTest.kt | 217 ++++++++++++------ 2 files changed, 148 insertions(+), 72 deletions(-) diff --git a/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt b/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt index f1230c0f63d..7bec4b85889 100644 --- a/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt +++ b/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt @@ -123,7 +123,8 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { withExtraDependency: String? = null, subpackage: String? = null ): Iterable { - initEmptyWorkspace() // Ensure the workspace is at least initialized. + // Note that the workspace doesn't need to be explicitly initialized here since the call below + // to addTestToBuildFile() will initialize it. check(testName !in testFileMap) { "Test '$testName' already exists" } val testFile = if (subpackage != null) { diff --git a/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt index 00cbba1f19c..e20b633bbc9 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt @@ -23,9 +23,7 @@ import java.lang.IllegalStateException // Function name: test names are conventionally named with underscores. @Suppress("FunctionName") class TestBazelWorkspaceTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() @Test fun testCreateTestUtility_doesNotImmediatelyCreateAnyFiles() { @@ -37,7 +35,7 @@ class TestBazelWorkspaceTest { } @Test - fun testInitEmptyWorkspace_emptyDirectory_createsEmptyWorkspace() { + fun testInitEmptyWorkspace_emptyDirectory_createsEmptyWorkspaceFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) testBazelWorkspace.initEmptyWorkspace() @@ -48,6 +46,30 @@ class TestBazelWorkspaceTest { assertThat(workspaceFile.readLines()).isEmpty() } + @Test + fun testInitEmptyWorkspace_emptyDirectory_createsBazelVersionFile() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.initEmptyWorkspace() + + // A .bazelversion file should now exist with the correct version. + val bazelVersionFile = File(tempFolder.root, ".bazelversion") + assertThat(bazelVersionFile.exists()).isTrue() + assertThat(bazelVersionFile.readText().trim()).isEqualTo("4.0.0") + } + + @Test + fun testInitEmptyWorkspace_emptyDirectory_createsBazelRcFile() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.initEmptyWorkspace() + + // A .bazelversion file should now exist with the correct flags. + val bazelRcFile = File(tempFolder.root, ".bazelrc") + assertThat(bazelRcFile.exists()).isTrue() + assertThat(bazelRcFile.readText().trim()).isEqualTo("--noenable_bzlmod") + } + @Test fun testInitEmptyWorkspace_fileCreationFails_throwsAssertionError() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) @@ -85,11 +107,34 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() - + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains("com.android.support:support-annotations:28.0.0") } + @Test + fun testSetupWorkspaceForRulesJvmExternal_withOneDep_setsUpBazelVersion() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.setUpWorkspaceForRulesJvmExternal( + listOf("com.android.support:support-annotations:28.0.0") + ) + + val bazelVersionContent = tempFolder.getBazelVersionFile().readText().trim() + assertThat(bazelVersionContent).isEqualTo("4.0.0") + } + + @Test + fun testSetupWorkspaceForRulesJvmExternal_withOneDep_setsUpBazelRc() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.setUpWorkspaceForRulesJvmExternal( + listOf("com.android.support:support-annotations:28.0.0") + ) + + val bazelRcContent = tempFolder.getBazelRcFile().readText().trim() + assertThat(bazelRcContent).isEqualTo("--noenable_bzlmod") + } + @Test fun testSetupWorkspaceForRulesJvmExternal_withTwoDeps_containsCorrectList() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) @@ -102,7 +147,7 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains("com.android.support:support-annotations:28.0.0") assertThat(workspaceContent).contains("io.fabric.sdk.android:fabric:1.4.7") @@ -122,7 +167,7 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains("com.android.support:support-annotations:28.0.0") assertThat(workspaceContent).contains("io.fabric.sdk.android:fabric:1.4.7") @@ -143,7 +188,7 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains("com.android.support:support-annotations:28.0.0") assertThat(workspaceContent).doesNotContain("io.fabric.sdk.android:fabric:1.4.7") @@ -158,7 +203,7 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains( """ @@ -212,7 +257,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_reusedTestName_throwsException() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") val exception = assertThrows() { @@ -228,21 +272,45 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_firstTest_setsUpWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") ) - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() assertThat(workspaceContent).contains("kt_register_toolchains()") } + @Test + fun testAddTestToBuildFile_firstTest_setsUpBazelVersion() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.addTestToBuildFile( + testName = "FirstTest", + testFile = tempFolder.newFile("FirstTest.kt") + ) + + val bazelVersionContent = tempFolder.getBazelVersionFile().readText().trim() + assertThat(bazelVersionContent).isEqualTo("4.0.0") + } + + @Test + fun testAddTestToBuildFile_firstTest_setsUpBazelRc() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.addTestToBuildFile( + testName = "FirstTest", + testFile = tempFolder.newFile("FirstTest.kt") + ) + + val bazelRcContent = tempFolder.getBazelRcFile().readText().trim() + assertThat(bazelRcContent).isEqualTo("--noenable_bzlmod") + } + @Test fun testAddTestToBuildFile_firstTest_returnsTestBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -255,7 +323,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_secondTest_doesNotChangeWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") @@ -275,14 +342,13 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_firstTest_initializesBuildFileOnlyForTests() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") ) - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_test")).isEqualTo(1) assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(0) } @@ -290,7 +356,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_secondTest_doesNotReinitializeBuildFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") @@ -302,14 +367,13 @@ class TestBazelWorkspaceTest { ) // The load line should only exist once in the file. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_test")).isEqualTo(1) } @Test fun testAddTestToBuildFile_unusedTestName_appendsBasicTest() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -317,7 +381,7 @@ class TestBazelWorkspaceTest { ) // There should be 1 test in the file with empty deps and correct source. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = []") @@ -326,7 +390,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withGeneratedDep_configuresBuildFileForLibraries() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -335,14 +398,13 @@ class TestBazelWorkspaceTest { ) // The build file should now be initialized for libraries. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(1) } @Test fun testAddTestToBuildFile_unusedTestName_withGeneratedDep_appendsLibraryAndTestWithDep() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -351,7 +413,7 @@ class TestBazelWorkspaceTest { ) // Ensure the test is arranged correctly. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = [\"//:FirstTestDependency_lib\",]") @@ -363,7 +425,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_firstTest_withGeneratedDep_returnsTestDepBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -378,7 +439,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_secondTest_withGeneratedDep_returnsTestDepBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") @@ -397,7 +457,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withExtraDep_appendsTestWithDep() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -406,7 +465,7 @@ class TestBazelWorkspaceTest { ) // Ensure the test is arranged correctly. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = [\"//:ExtraDep\",]") @@ -415,7 +474,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withSubpackage_appendsToSubpackageBuildFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() tempFolder.newFolder("subpackage") testBazelWorkspace.addTestToBuildFile( @@ -437,7 +495,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withSubpackage_returnsNewBuildAndTestFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() tempFolder.newFolder("subpackage") val files = testBazelWorkspace.addTestToBuildFile( @@ -453,7 +510,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withMultipleSubpackages_returnsNewBuildAndTestFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val subpackage = "subpackage.first.second" tempFolder.newFolder(*(subpackage.split(".")).toTypedArray()) val files = testBazelWorkspace.addTestToBuildFile( @@ -471,7 +527,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withGeneratedAndExtraDeps_includesBothInTestDeps() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -481,7 +536,7 @@ class TestBazelWorkspaceTest { ) // Both dependencies should be included in the test's deps. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("deps = [\"//:FirstTestDependency_lib\",\"//:ExtraDep\",]") } @@ -489,7 +544,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_reusedTestName_throwsException() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") val exception = assertThrows() { @@ -502,18 +556,36 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_firstTest_setsUpWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() assertThat(workspaceContent).contains("kt_register_toolchains()") } + @Test + fun testCreateTest_firstTest_setsUpBazelVersion() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.createTest(testName = "FirstTest") + + val bazelVersionContent = tempFolder.getBazelVersionFile().readText().trim() + assertThat(bazelVersionContent).isEqualTo("4.0.0") + } + + @Test + fun testCreateTest_firstTest_setsUpBazelRc() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.createTest(testName = "FirstTest") + + val bazelRcContent = tempFolder.getBazelRcFile().readText().trim() + assertThat(bazelRcContent).isEqualTo("--noenable_bzlmod") + } + @Test fun testCreateTest_firstTest_returnsTestBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.createTest(testName = "FirstTest") @@ -523,7 +595,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_secondTest_doesNotChangeWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") val workspaceSize = tempFolder.getWorkspaceFile().length() @@ -537,11 +608,10 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_firstTest_initializesBuildFileOnlyForTests() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_test")).isEqualTo(1) assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(0) } @@ -549,25 +619,23 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_secondTest_doesNotReinitializeBuildFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") testBazelWorkspace.createTest(testName = "SecondTest") // The load line should only exist once in the file. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_test")).isEqualTo(1) } @Test fun testCreateTest_unusedTestName_appendsBasicTest() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") // There should be 1 test in the file with empty deps and correct source. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = []") @@ -576,7 +644,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withGeneratedDep_configuresBuildFileForLibraries() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest( testName = "FirstTest", @@ -584,14 +651,13 @@ class TestBazelWorkspaceTest { ) // The build file should now be initialized for libraries. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(1) } @Test fun testCreateTest_unusedTestName_withGeneratedDep_appendsLibraryAndTestWithDep() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest( testName = "FirstTest", @@ -599,7 +665,7 @@ class TestBazelWorkspaceTest { ) // Ensure the test is arranged correctly. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = [\"//:FirstTestDependency_lib\",]") @@ -611,7 +677,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_firstTest_withGeneratedDep_returnsTestDepBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.createTest( testName = "FirstTest", @@ -625,7 +690,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_secondTest_withGeneratedDep_returnsTestDepBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") val files = testBazelWorkspace.createTest( @@ -640,12 +704,11 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withExtraDep_appendsTestWithDep() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest", withExtraDependency = "//:ExtraDep") // Ensure the test is arranged correctly. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = [\"//:ExtraDep\",]") @@ -654,7 +717,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withSubpackage_appendsToSubpackageBuildFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest", subpackage = "subpackage") @@ -671,7 +733,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withSubpackage_returnsNewBuildAndTestFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.createTest(testName = "FirstTest", subpackage = "subpackage") @@ -682,7 +743,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withMultipleSubpackages_returnsNewBuildAndTestFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.createTest( testName = "FirstTest", @@ -698,7 +758,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withGeneratedAndExtraDeps_includesBothInTestDeps() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest( testName = "FirstTest", @@ -707,7 +766,7 @@ class TestBazelWorkspaceTest { ) // Both dependencies should be included in the test's deps. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("deps = [\"//:FirstTestDependency_lib\",\"//:ExtraDep\",]") } @@ -715,24 +774,42 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_firstLib_unusedName_configuresWorkspaceAndBuild() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(workspaceContent).contains("kt_register_toolchains()") assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(1) } + @Test + fun testCreateLibrary_firstLib_unusedName_setsUpBazelVersion() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") + + val bazelVersionContent = tempFolder.getBazelVersionFile().readText().trim() + assertThat(bazelVersionContent).isEqualTo("4.0.0") + } + + @Test + fun testCreateLibrary_firstLib_unusedName_setsUpBazelRc() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") + + val bazelRcContent = tempFolder.getBazelRcFile().readText().trim() + assertThat(bazelRcContent).isEqualTo("--noenable_bzlmod") + } + @Test fun testCreateLibrary_firstLib_unusedName_appendsJvmLibraryDeclaration() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_library\\(")).isEqualTo(1) assertThat(buildContent).contains("name = \"ExampleDep_lib\"") assertThat(buildContent).contains("srcs = [\"ExampleDep.kt\"]") @@ -741,7 +818,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_firstLib_unusedName_returnsBuildLibAndWorkspaceFilesWithTargetName() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val (targetName, files) = testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") @@ -752,7 +828,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_secondLib_unusedName_doesNotChangeWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "FirstLib") val workspaceSize = tempFolder.getWorkspaceFile().length() @@ -765,13 +840,12 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_secondLib_unusedName_appendsJvmLibraryDeclaration() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "FirstLib") testBazelWorkspace.createLibrary(dependencyName = "SecondLib") // The kt_jvm_library declaration should only exist once, and both libraries should exist. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(1) assertThat(buildContent.countMatches("kt_jvm_library\\(")).isEqualTo(2) assertThat(buildContent).contains("name = \"FirstLib_lib\"") @@ -783,7 +857,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_secondLib_reusedName_throwsException() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "FirstLib") val exception = assertThrows() { @@ -801,7 +874,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.createTest(testName = "FirstTest") // The workspace should only be configured once (due to the library initialization). - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() assertThat(workspaceContent.countMatches("http_archive\\(")).isEqualTo(1) } @@ -813,7 +886,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.createLibrary(dependencyName = "FirstLib") // The workspace should only be configured once (due to the test initialization). - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() assertThat(workspaceContent.countMatches("http_archive\\(")).isEqualTo(1) } @@ -901,7 +974,9 @@ class TestBazelWorkspaceTest { private fun TemporaryFolder.getWorkspaceFile(): File = File(root, "WORKSPACE") - private fun File.readAsJoinedString(): String = readLines().joinToString(separator = "\n") + private fun TemporaryFolder.getBazelVersionFile(): File = File(root, ".bazelversion") + + private fun TemporaryFolder.getBazelRcFile(): File = File(root, ".bazelrc") private fun File.isRelativeTo(base: File): Boolean = relativeToOrNull(base) != null From e1802c8242eaa7877360c8301177a1e8980f722b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 8 Feb 2024 01:14:07 +0000 Subject: [PATCH 16/21] Add missing Firebase auth tests. --- .../org/oppia/android/domain/auth/BUILD.bazel | 46 +++++++++++++++++++ .../auth/FirebaseAuthWrapperImplTest.kt | 1 - 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/domain/src/test/java/org/oppia/android/domain/auth/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/auth/BUILD.bazel index 61f22c5ed07..7b549aa2c45 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/auth/BUILD.bazel @@ -5,6 +5,29 @@ Tests for libraries providing authentication with Firebase functionality. load("@dagger//:workspace_defs.bzl", "dagger_rules") load("//:oppia_android_test.bzl", "oppia_android_test") +oppia_android_test( + name = "AuthenticationControllerTest", + srcs = ["AuthenticationControllerTest.kt"], + custom_package = "org.oppia.android.domain.auth", + test_class = "org.oppia.android.domain.auth.AuthenticationControllerTest", + test_manifest = "//domain:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/auth:auth_module", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:androidx_test_ext_junit", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_mockito_mockito-core", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + ], +) + oppia_android_test( name = "AuthenticationModuleTest", srcs = ["AuthenticationModuleTest.kt"], @@ -27,4 +50,27 @@ oppia_android_test( ], ) +oppia_android_test( + name = "FirebaseAuthWrapperImplTest", + srcs = ["FirebaseAuthWrapperImplTest.kt"], + custom_package = "org.oppia.android.domain.auth", + test_class = "org.oppia.android.domain.auth.FirebaseAuthWrapperImplTest", + test_manifest = "//domain:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/auth:auth_module", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:androidx_test_ext_junit", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_mockito_mockito-core", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + ], +) + dagger_rules() diff --git a/domain/src/test/java/org/oppia/android/domain/auth/FirebaseAuthWrapperImplTest.kt b/domain/src/test/java/org/oppia/android/domain/auth/FirebaseAuthWrapperImplTest.kt index 28a07b49b39..8983ae92125 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/FirebaseAuthWrapperImplTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/auth/FirebaseAuthWrapperImplTest.kt @@ -31,7 +31,6 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FirebaseAuthWrapperImplTest.TestApplication::class) - class FirebaseAuthWrapperImplTest { @Inject From d3cbd9356aadd3197101ca446d904863245f76af Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 8 Feb 2024 01:34:40 +0000 Subject: [PATCH 17/21] Post-merge fixes for previously missed tests. --- .../auth/AuthenticationControllerTest.kt | 78 +++++++++++-------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt index 4208244c46e..2b69a7e7c76 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt @@ -11,13 +11,21 @@ import dagger.Module import dagger.Provides import kotlinx.coroutines.CoroutineDispatcher import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mock +import org.mockito.Mockito.verify +import org.mockito.Mockito.verifyNoInteractions +import org.mockito.junit.MockitoJUnit +import org.mockito.junit.MockitoRule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.testing.TestLogReportingModule -import org.oppia.android.testing.assertThrows import org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImpl import org.oppia.android.testing.firebase.TestAuthenticationModule +import org.oppia.android.testing.mockito.capture import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.data.DataProvidersInjector @@ -36,17 +44,16 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AuthenticationControllerTest.TestApplication::class) class AuthenticationControllerTest { - @Inject - lateinit var firebaseAuthWrapper: FirebaseAuthWrapper + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() - @Inject - lateinit var fakeFirebaseAuthWrapperImpl: FakeFirebaseAuthWrapperImpl + @Inject lateinit var firebaseAuthWrapper: FirebaseAuthWrapper + @Inject lateinit var fakeFirebaseAuthWrapperImpl: FakeFirebaseAuthWrapperImpl + @Inject lateinit var authenticationController: AuthenticationController + @field:[Inject BackgroundDispatcher] lateinit var backgroundDispatcher: CoroutineDispatcher - @Inject - lateinit var authenticationController: AuthenticationController - - @field:[Inject BackgroundDispatcher] - lateinit var backgroundDispatcher: CoroutineDispatcher + @Mock lateinit var mockFakeSuccessCallback: FakeSuccessCallback + @Mock lateinit var mockFakeFailureCallback: FakeFailureCallback + @Captor lateinit var throwableCaptor: ArgumentCaptor @Before fun setUp() { @@ -54,48 +61,49 @@ class AuthenticationControllerTest { } @Test - fun testAuthentication_getCurrentUser_userSignedIn_returnsInstanceOfFirebaseUserWrapper() { + fun testAuthentication_signInAnonymously_onlyOnSuccessCalled() { fakeFirebaseAuthWrapperImpl.simulateSignInSuccess() firebaseAuthWrapper.signInAnonymously( - onSuccess = {}, - onFailure = {} + onSuccess = mockFakeSuccessCallback::onSuccess, + onFailure = mockFakeFailureCallback::onFailure ) - val user = authenticationController.currentFirebaseUser - - assertThat(user).isInstanceOf(FirebaseUserWrapper::class.java) + // onSuccess should be called. + verify(mockFakeSuccessCallback).onSuccess() + verifyNoInteractions(mockFakeFailureCallback) } @Test - fun testAuthentication_signInAnonymously_succeeds() { - fakeFirebaseAuthWrapperImpl.simulateSignInSuccess() + fun testAuthentication_signInAnonymously_onlyOnFailureCalled() { + fakeFirebaseAuthWrapperImpl.simulateSignInFailure() firebaseAuthWrapper.signInAnonymously( - onSuccess = {}, - onFailure = {} + onSuccess = mockFakeSuccessCallback::onSuccess, + onFailure = mockFakeFailureCallback::onFailure ) - val user = authenticationController.currentFirebaseUser - - assertThat(user).isInstanceOf(FirebaseUserWrapper::class.java) + // onFailure should be called with the failure details. + verify(mockFakeFailureCallback).onFailure(capture(throwableCaptor)) + verifyNoInteractions(mockFakeSuccessCallback) + assertThat(throwableCaptor.value).hasMessageThat().contains("Sign-in failure") } @Test - fun testAuthentication_signInAnonymously_failure_returnsException() { - fakeFirebaseAuthWrapperImpl.simulateSignInFailure() + fun testAuthentication_getCurrentUser_userSignedIn_returnsInstanceOfFirebaseUserWrapper() { + fakeFirebaseAuthWrapperImpl.simulateSignInSuccess() + firebaseAuthWrapper.signInAnonymously( + onSuccess = mockFakeSuccessCallback::onSuccess, + onFailure = mockFakeFailureCallback::onFailure + ) - assertThrows(Throwable::class) { - firebaseAuthWrapper.signInAnonymously( - onSuccess = {}, - onFailure = {} - ) - } + val user = authenticationController.currentFirebaseUser + + assertThat(user).isInstanceOf(FirebaseUserWrapper::class.java) } private fun setUpTestApplicationComponent() { - ApplicationProvider.getApplicationContext() - .inject(this) + ApplicationProvider.getApplicationContext().inject(this) } @Module @@ -141,4 +149,8 @@ class AuthenticationControllerTest { override fun getDataProvidersInjector(): DataProvidersInjector = component } + + interface FakeSuccessCallback { fun onSuccess() } + + interface FakeFailureCallback { fun onFailure(failure: Throwable) } } From 9b85cd311a7385cc631555a0aa8dcd1d90946c8b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 8 Feb 2024 01:55:10 +0000 Subject: [PATCH 18/21] Fix some broken tests. Note that the test coverage is not yet complete for this PR. --- .../org/oppia/android/app/parser/HtmlParserTest.kt | 6 ++++-- .../app/parser/ListItemLeadingMarginSpanTest.kt | 6 ++++-- .../android/domain/locale/LocaleControllerTest.kt | 2 +- .../domain/translation/TranslationControllerTest.kt | 11 ++++------- .../scripts/regex/RegexPatternValidationCheckTest.kt | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt index 571ba12ee85..1ac4f3d429b 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt @@ -852,8 +852,10 @@ class HtmlParserTest { } } - private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl = - DisplayLocaleImpl(context, machineLocale, androidLocaleFactory, formatterFactory) + private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl { + val formattingLocale = androidLocaleFactory.createOneOffAndroidLocale(context) + return DisplayLocaleImpl(context, formattingLocale, machineLocale, formatterFactory) + } private fun ActivityScenario.getDimensionPixelSize( @DimenRes dimenResId: Int diff --git a/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt b/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt index d993ffd3de8..a7904d0d1cf 100644 --- a/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt @@ -1044,8 +1044,10 @@ class ListItemLeadingMarginSpanTest { return valueCaptor.value } - private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl = - DisplayLocaleImpl(context, machineLocale, androidLocaleFactory, formatterFactory) + private fun createDisplayLocaleImpl(context: OppiaLocaleContext): DisplayLocaleImpl { + val formattingLocale = androidLocaleFactory.createOneOffAndroidLocale(context) + return DisplayLocaleImpl(context, formattingLocale, machineLocale, formatterFactory) + } private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) diff --git a/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt index 186bfad7f24..9a5eb36e8cc 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt @@ -117,7 +117,7 @@ class LocaleControllerTest { fun testReconstituteDisplayLocale_defaultContext_throwsException() { val context = OppiaLocaleContext.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { localeController.reconstituteDisplayLocale(context) } diff --git a/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt index 195a53887db..0b810aeead5 100644 --- a/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt @@ -18,7 +18,7 @@ import org.oppia.android.app.model.AppLanguageSelection import org.oppia.android.app.model.AppLanguageSelection.SelectionTypeCase.USE_SYSTEM_LANGUAGE_OR_APP_DEFAULT import org.oppia.android.app.model.AudioTranslationLanguageSelection import org.oppia.android.app.model.HtmlTranslationList -import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId.LanguageTypeCase.IETF_BCP47_ID +import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId.LanguageTypeCase.LANGUAGETYPE_NOT_SET import org.oppia.android.app.model.OppiaLanguage import org.oppia.android.app.model.OppiaLanguage.ARABIC import org.oppia.android.app.model.OppiaLanguage.BRAZILIAN_PORTUGUESE @@ -112,9 +112,8 @@ class TranslationControllerTest { val appStringId = context.languageDefinition.appStringId assertThat(context.usageMode).isEqualTo(APP_STRINGS) assertThat(context.languageDefinition.language).isEqualTo(LANGUAGE_UNSPECIFIED) - assertThat(appStringId.languageTypeCase).isEqualTo(IETF_BCP47_ID) - assertThat(appStringId.ietfBcp47Id.ietfLanguageTag).isEmpty() - assertThat(appStringId.androidResourcesLanguageId.languageCode).isEmpty() + // TODO: Add tests for IETF_BCP47_ID type cases? + assertThat(appStringId.languageTypeCase).isEqualTo(LANGUAGETYPE_NOT_SET) assertThat(context.regionDefinition.region).isEqualTo(REGION_UNSPECIFIED) } @@ -290,9 +289,7 @@ class TranslationControllerTest { val appStringId = context.languageDefinition.appStringId assertThat(context.usageMode).isEqualTo(APP_STRINGS) assertThat(context.languageDefinition.language).isEqualTo(LANGUAGE_UNSPECIFIED) - assertThat(appStringId.languageTypeCase).isEqualTo(IETF_BCP47_ID) - assertThat(appStringId.ietfBcp47Id.ietfLanguageTag).isEmpty() - assertThat(appStringId.androidResourcesLanguageId.languageCode).isEmpty() + assertThat(appStringId.languageTypeCase).isEqualTo(LANGUAGETYPE_NOT_SET) assertThat(context.regionDefinition.region).isEqualTo(REGION_UNSPECIFIED) } diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index 7696c718d97..f2b8b214649 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -2741,7 +2741,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) From a6cd25e64bf80f80c1daa944f2851eacbbf9a351 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 9 Feb 2024 20:09:45 +0000 Subject: [PATCH 19/21] Follow-up doc and readability improvements. --- .../translation/TranslationControllerTest.kt | 21 ++++++++++++++++++- .../util/locale/AndroidLocaleFactory.kt | 16 +++++++------- .../android/util/locale/DisplayLocaleImpl.kt | 3 +++ .../util/locale/AndroidLocaleProfileTest.kt | 6 +++--- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt index 0b810aeead5..b3b501ff94c 100644 --- a/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/translation/TranslationControllerTest.kt @@ -18,6 +18,7 @@ import org.oppia.android.app.model.AppLanguageSelection import org.oppia.android.app.model.AppLanguageSelection.SelectionTypeCase.USE_SYSTEM_LANGUAGE_OR_APP_DEFAULT import org.oppia.android.app.model.AudioTranslationLanguageSelection import org.oppia.android.app.model.HtmlTranslationList +import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId.LanguageTypeCase.IETF_BCP47_ID import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId.LanguageTypeCase.LANGUAGETYPE_NOT_SET import org.oppia.android.app.model.OppiaLanguage import org.oppia.android.app.model.OppiaLanguage.ARABIC @@ -112,7 +113,6 @@ class TranslationControllerTest { val appStringId = context.languageDefinition.appStringId assertThat(context.usageMode).isEqualTo(APP_STRINGS) assertThat(context.languageDefinition.language).isEqualTo(LANGUAGE_UNSPECIFIED) - // TODO: Add tests for IETF_BCP47_ID type cases? assertThat(appStringId.languageTypeCase).isEqualTo(LANGUAGETYPE_NOT_SET) assertThat(context.regionDefinition.region).isEqualTo(REGION_UNSPECIFIED) } @@ -293,6 +293,24 @@ class TranslationControllerTest { assertThat(context.regionDefinition.region).isEqualTo(REGION_UNSPECIFIED) } + @Test + fun testGetAppLanguageLocale_ptBrDefLocale_returnsLocaleWithIetfAndAndroidResourcesLangIds() { + forceDefaultLocale(BRAZIL_PORTUGUESE_LOCALE) + + val localeProvider = translationController.getAppLanguageLocale(PROFILE_ID_0) + + val locale = monitorFactory.waitForNextSuccessfulResult(localeProvider) + val context = locale.localeContext + val appStringId = context.languageDefinition.appStringId + assertThat(context.usageMode).isEqualTo(APP_STRINGS) + assertThat(context.languageDefinition.language).isEqualTo(BRAZILIAN_PORTUGUESE) + assertThat(appStringId.languageTypeCase).isEqualTo(IETF_BCP47_ID) + assertThat(appStringId.ietfBcp47Id.ietfLanguageTag).isEqualTo("pt-BR") + assertThat(appStringId.androidResourcesLanguageId.languageCode).isEqualTo("pt") + assertThat(appStringId.androidResourcesLanguageId.regionCode).isEqualTo("BR") + assertThat(context.regionDefinition.region).isEqualTo(BRAZIL) + } + @Test fun testGetAppLanguageLocale_updateLanguageToEnglish_returnsEnglishLocale() { forceDefaultLocale(Locale.ROOT) @@ -1934,6 +1952,7 @@ class TranslationControllerTest { private companion object { private val BRAZIL_ENGLISH_LOCALE = Locale("en", "BR") + private val BRAZIL_PORTUGUESE_LOCALE = Locale("pt", "BR") private val INDIA_HINDI_LOCALE = Locale("hi", "IN") private val KENYA_KISWAHILI_LOCALE = Locale("sw", "KE") diff --git a/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt b/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt index cdca0c68136..3396a135f17 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt @@ -189,18 +189,18 @@ class AndroidLocaleFactory @Inject constructor( * Note that the returned proposal will prioritize its Android ID configuration over * alternatives (such as IETF BCP 47 or a macaronic language configuration). * - * @param allowRootProfile whether to return a [AndroidLocaleProfile.RootProfile] for cases when - * a valid proposal cannot be determined rather than throwing an exception + * @param fallBackToRootProfile whether to return a [AndroidLocaleProfile.RootProfile] for cases + * when a valid proposal cannot be determined rather than throwing an exception */ - fun computeForcedProposal(allowRootProfile: Boolean): LocaleProfileProposal = - computeForcedAndroidProposal() ?: toForcedProposal(allowRootProfile) + fun computeForcedProposal(fallBackToRootProfile: Boolean): LocaleProfileProposal = + computeForcedAndroidProposal() ?: toForcedProposal(fallBackToRootProfile) - private fun toForcedProposal(allowRootProfile: Boolean): LocaleProfileProposal { + private fun toForcedProposal(fallBackToRootProfile: Boolean): LocaleProfileProposal { return when (val languageTypeCase = languageId.languageTypeCase) { IETF_BCP47_ID -> createIetfProfile().expectedProfile() MACARONIC_ID -> createMacaronicProfile().expectedProfile() LANGUAGETYPE_NOT_SET, null -> { - if (allowRootProfile) { + if (fallBackToRootProfile) { AndroidLocaleProfile.RootProfile } else error("Invalid language case: $languageTypeCase.") } @@ -316,7 +316,7 @@ class AndroidLocaleFactory @Inject constructor( ): LocaleProfileProposal { return primarySource.computeSystemMatchingProposals().findFirstViable(localeProfileRepository) ?: fallbackSource.computeSystemMatchingProposals().findFirstViable(localeProfileRepository) - ?: primarySource.computeForcedProposal(allowRootProfile = false) + ?: primarySource.computeForcedProposal(fallBackToRootProfile = false) } } @@ -340,7 +340,7 @@ class AndroidLocaleFactory @Inject constructor( ?: primarySource.computeForcedAndroidProposal()?.takeOnlyIfViable(localeProfileRepository) ?: fallbackSource.computeSystemMatchingProposals().findFirstViable(localeProfileRepository) ?: fallbackSource.computeForcedAndroidProposal()?.takeOnlyIfViable(localeProfileRepository) - ?: primarySource.computeForcedProposal(allowRootProfile = true) + ?: primarySource.computeForcedProposal(fallBackToRootProfile = true) } } diff --git a/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt b/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt index 70d23fba22f..06279bb2404 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt @@ -17,7 +17,10 @@ import java.util.Objects /** * Implementation of [OppiaLocale.DisplayLocale]. * + * @property localeContext the [OppiaLocaleContext] that this locale is representing * @property formattingLocale the [Locale] used for user-facing string formatting + * @property machineLocale the application-wide [MachineLocale] used for string formatting + * @property formatterFactory the application-wide factory for creating a new [OppiaBidiFormatter] */ class DisplayLocaleImpl( localeContext: OppiaLocaleContext, diff --git a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleProfileTest.kt b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleProfileTest.kt index 391a5decddc..d686a5aaea9 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleProfileTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleProfileTest.kt @@ -355,7 +355,7 @@ class AndroidLocaleProfileTest { }.build() ) - // This method can only be create a method via a valid Android resources language ID. + // This method only creates a profile when provided with a valid Android resources language ID. assertThat(profile).isNull() } @@ -370,7 +370,7 @@ class AndroidLocaleProfileTest { }.build() ) - // This method can only be create a method via a valid Android resources language ID. + // This method only creates a profile when provided with a valid Android resources language ID. assertThat(profile).isNull() } @@ -383,7 +383,7 @@ class AndroidLocaleProfileTest { }.build() ) - // This method can only be create a method via a valid Android resources language ID. + // This method only creates a profile when provided with a valid Android resources language ID. assertThat(profile).isNull() } From 2916770e765507917c24844f88830f591fcd7b4f Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 14 Feb 2024 12:24:01 -0800 Subject: [PATCH 20/21] Update scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com> --- .../javatests/org/oppia/android/scripts/common/GitClientTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt index 5cbda509373..c3126339eca 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt @@ -35,7 +35,7 @@ class GitClientTest { @After fun tearDown() { // Print the status of the git repository to help with debugging in the cases of test failures - // and to help manually verify the expect git state at the end of each test. + // and to help manually verify the expected git state at the end of each test. println("git status (at end of test):") println(testGitRepository.status(checkForGitRepository = false)) } From bef917cb29d0cd80d7c58205b5ce4b045bed3559 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 1 Mar 2024 00:48:44 +0000 Subject: [PATCH 21/21] Address review comments. --- .../java/org/oppia/android/util/locale/AndroidLocaleFactory.kt | 2 +- .../java/org/oppia/android/util/locale/DisplayLocaleImpl.kt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt b/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt index 3396a135f17..e871355442b 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/AndroidLocaleFactory.kt @@ -74,7 +74,7 @@ class AndroidLocaleFactory @Inject constructor( * [Locale.ROOT]. * * Note that the returned [Locale] may be cached within the factory for performance reasons, so - * the returned value use a [Deferred] to ensure that this method can guarantee thread-safe + * the returned value uses a [Deferred] to ensure that this method can guarantee thread-safe * access. * * @param localeContext the [OppiaLocaleContext] to use as a basis for finding a similar [Locale] diff --git a/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt b/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt index 06279bb2404..f8bff8b2b06 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt @@ -12,8 +12,7 @@ import java.util.Date import java.util.Locale import java.util.Objects -// TODO(#3766): Restrict to be 'internal'. -// TODO(#3766): Restrict formattingLocale to be 'internal'. +// TODO(#3766): Restrict DisplayLocaleImpl and formattingLocale to be 'internal'. /** * Implementation of [OppiaLocale.DisplayLocale]. *