diff --git a/app/BUILD.bazel b/app/BUILD.bazel index 7405410cf3e..925b2382ffa 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -906,7 +906,6 @@ TEST_DEPS = [ "//testing/src/main/java/org/oppia/android/testing/mockito", "//testing/src/main/java/org/oppia/android/testing/network", "//testing/src/main/java/org/oppia/android/testing/network:test_module", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:is_on_robolectric", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:coroutine_executor_service", 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 ed5e44231c5..1ab717e315d 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 @@ -101,14 +101,16 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -128,6 +130,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -140,6 +143,7 @@ import javax.inject.Singleton application = AdministratorControlsActivityTest.TestApplication::class, qualifiers = "port-xxhdpi" ) +@EnableFeatureFlag(FeatureFlag.EDIT_ACCOUNTS_OPTIONS_UI) class AdministratorControlsActivityTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -181,7 +185,6 @@ class AdministratorControlsActivityTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableEditAccountsOptionsUi(true) Intents.init() setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() @@ -234,8 +237,8 @@ class AdministratorControlsActivityTest { } @Test + @DisableFeatureFlag(FeatureFlag.EDIT_ACCOUNTS_OPTIONS_UI) fun testAdministratorControlsFragment_editAccountOptionsDisabled_generalOptionsIsNotDisplayed() { - TestPlatformParameterModule.forceEnableEditAccountsOptionsUi(false) launch( createAdministratorControlsActivityIntent( @@ -618,8 +621,8 @@ class AdministratorControlsActivityTest { @Test @Config(qualifiers = "sw600dp") + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testAdminControls_selectAdmin_tabletConfigChange_downloadsEnabled_hasNoDownloadSettings() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) launch( createAdministratorControlsActivityIntent( profileId = profileId @@ -637,8 +640,8 @@ class AdministratorControlsActivityTest { @Test @Config(qualifiers = "sw600dp") + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testAdminControls_selectUser_tabletConfigChange_downloadsEnabled_hasDownloadSettings() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) launch( createAdministratorControlsActivityIntent( profileId = profileId @@ -657,8 +660,8 @@ class AdministratorControlsActivityTest { @Test @Config(qualifiers = "sw600dp") + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testAdminControls_selectAdmin_tabletConfigChange_downloadsDisabled_hasNoDownloadSettings() { - TestPlatformParameterModule.forceEnableDownloadsSupport(false) launch( createAdministratorControlsActivityIntent( profileId = profileId @@ -678,8 +681,8 @@ class AdministratorControlsActivityTest { @Test @Config(qualifiers = "sw600dp") + @DisableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testAdminControls_selectUser_tabletConfigChange_downloadsDisabled_hasNoDownloadSettings() { - TestPlatformParameterModule.forceEnableDownloadsSupport(false) launch( createAdministratorControlsActivityIntent( profileId = profileId @@ -905,7 +908,7 @@ class AdministratorControlsActivityTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 6d543ac59af..92459d615d0 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 @@ -82,14 +82,16 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -108,6 +110,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -119,6 +122,8 @@ import javax.inject.Singleton application = AdministratorControlsFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi" ) +@EnableFeatureFlag(FeatureFlag.EDIT_ACCOUNTS_OPTIONS_UI) +@EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) class AdministratorControlsFragmentTest { @get:Rule @@ -142,8 +147,6 @@ class AdministratorControlsFragmentTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableEditAccountsOptionsUi(true) - TestPlatformParameterModule.forceEnableDownloadsSupport(true) Intents.init() setUpTestApplicationComponent() profileTestHelper.initializeProfiles() @@ -223,8 +226,8 @@ class AdministratorControlsFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testAdministratorControlsFragment_downloadPermissionsAndSettings_autoUpdateIsNotDisplayed() { - TestPlatformParameterModule.forceEnableDownloadsSupport(false) launch( createAdministratorControlsFragmentTestActivityIntent( profileId = internalProfileId @@ -593,7 +596,7 @@ class AdministratorControlsFragmentTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 1c98702393b..5fa719f173c 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,7 +51,6 @@ app_test( "//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", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", "//testing/src/main/java/org/oppia/android/testing/time: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 890275fa0a6..1cab94e0265 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 @@ -96,9 +96,11 @@ import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModul import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorker import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerFactory +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule @@ -109,7 +111,6 @@ 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 import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -132,6 +133,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.security.MessageDigest @@ -151,6 +153,9 @@ import javax.inject.Singleton application = ProfileAndDeviceIdFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi" ) +@EnableFeatureFlag(FeatureFlag.EDIT_ACCOUNTS_OPTIONS_UI) +@EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) +@EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) class ProfileAndDeviceIdFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @get:Rule val oppiaTestRule = OppiaTestRule() @@ -173,9 +178,6 @@ class ProfileAndDeviceIdFragmentTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableEditAccountsOptionsUi(true) - TestPlatformParameterModule.forceEnableLearnerStudyAnalytics(true) - TestPlatformParameterModule.forceEnableLoggingLearnerStudyIds(true) setUpTestApplicationComponent() Intents.init() testCoroutineDispatchers.registerIdlingResource() @@ -1116,7 +1118,7 @@ class ProfileAndDeviceIdFragmentTest { @Singleton @Component( modules = [ - TestPlatformParameterModule::class, + PlatformParameterModule::class, TestModule::class, RobolectricModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, diff --git a/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListFragmentTest.kt index 45fde0ccbfd..acb69b995b2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/classroom/ClassroomListFragmentTest.kt @@ -24,6 +24,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import dagger.Component import org.junit.After +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -92,6 +93,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0 @@ -99,6 +101,8 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID 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.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule @@ -106,7 +110,6 @@ 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper @@ -127,6 +130,7 @@ import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -189,16 +193,20 @@ class ClassroomListFragmentTest { private val internalProfileId: Int = 0 private val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() + @Before + fun setUp() { + setUpTestApplicationComponent() + } + @After fun tearDown() { - TestPlatformParameterModule.reset() testCoroutineDispatchers.unregisterIdlingResource() scenario.close() } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV1Enabled_onLaunch_logsOpenHomeEvent() { - setUpTestApplicationComponent(onboardingV2Enabled = false) scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() val event = fakeAnalyticsEventLogger.getOldestEvent() @@ -208,8 +216,8 @@ class ClassroomListFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2Enabled_onLaunch_logsOpenHomeEvent() { - setUpTestApplicationComponent(onboardingV2Enabled = true) scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() @@ -220,8 +228,8 @@ class ClassroomListFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_soleLearner_onInitialLaunch_logsEndProfileOnboardingEvent() { - setUpTestApplicationComponent(onboardingV2Enabled = true) scenario = ActivityScenario.launch(ClassroomListActivity::class.java) profileTestHelper.addOnlyAdminProfileWithoutPin() @@ -237,8 +245,8 @@ class ClassroomListFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_supervisorProfile_onInitialLaunch_logsEndProfileOnboardingEvent() { - setUpTestApplicationComponent(onboardingV2Enabled = true) scenario = ActivityScenario.launch(ClassroomListActivity::class.java) profileTestHelper.addOnlyAdminProfileWithoutPin() @@ -254,8 +262,8 @@ class ClassroomListFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_nonAdminProfile_onInitialLaunch_logsEndProfileOnboardingEvent() { - setUpTestApplicationComponent(onboardingV2Enabled = true) scenario = ActivityScenario.launch(ClassroomListActivity::class.java) profileTestHelper.addOnlyAdminProfileWithoutPin() @@ -271,9 +279,8 @@ class ClassroomListFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_soleLearner_onInitialLaunch_logsAppOnboardingEvent() { - setUpTestApplicationComponent(onboardingV2Enabled = true) - profileTestHelper.addOnlyAdminProfileWithoutPin() profileTestHelper.updateProfileType( profileId = profileId, profileType = ProfileType.SOLE_LEARNER @@ -292,9 +299,8 @@ class ClassroomListFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_supervisorProfile_onInitialLaunch_logsAppOnboardingEvent() { - setUpTestApplicationComponent(onboardingV2Enabled = true) - profileTestHelper.addOnlyAdminProfileWithoutPin() profileTestHelper.updateProfileType( profileId = profileId, profileType = ProfileType.SUPERVISOR @@ -313,9 +319,8 @@ class ClassroomListFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_nonAdmin_onInitialLaunch_doesNotLogAppOnboardingEvent() { - setUpTestApplicationComponent(onboardingV2Enabled = true) - profileTestHelper.addOnlyAdminProfileWithoutPin() profileTestHelper.updateProfileType( profileId = profileId, profileType = ProfileType.ADDITIONAL_LEARNER @@ -335,7 +340,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_allComponentsAreDisplayed() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() @@ -347,7 +351,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_loginTwice_allComponentsAreDisplayed() { - setUpTestApplicationComponent() logIntoAdminTwice() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() @@ -366,7 +369,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_withAdminProfile_configChange_profileNameIsDisplayed() { - setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(EVENING_TIMESTAMP) @@ -385,7 +387,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_morningTimestamp_goodMorningMessageIsDisplayed_withAdminProfileName() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(MORNING_TIMESTAMP) @@ -400,7 +401,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_afternoonTimestamp_goodAfternoonMessageIsDisplayed_withAdminProfileName() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(AFTERNOON_TIMESTAMP) @@ -415,7 +415,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_eveningTimestamp_goodEveningMessageIsDisplayed_withAdminProfileName() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(EVENING_TIMESTAMP) @@ -430,7 +429,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_logUserInFirstTime_checkPromotedStoriesIsNotDisplayed() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) composeRule.onNodeWithTag(PROMOTED_STORY_LIST_HEADER_TEST_TAG).assertDoesNotExist() composeRule.onNodeWithTag(PROMOTED_STORY_LIST_TEST_TAG).assertDoesNotExist() @@ -438,7 +436,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_recentlyPlayedStoriesTextIsDisplayed() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -458,7 +455,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_viewAllTextIsDisplayed() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -484,7 +480,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_storiesPlayedOneWeekAgo_displaysLastPlayedStoriesText() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -505,7 +500,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markStory0DoneForFraction_displaysRecommendedStories() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -535,7 +529,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markCompletedRatiosStory0_recommendsFractions() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -557,7 +550,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_noTopicProgress_initialRecommendationFractionsAndRatiosIsCorrect() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() @@ -582,7 +574,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_forPromotedActivityList_hideViewAll() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( @@ -599,7 +590,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markStory0DoneForRatiosAndFirstTestTopic_displaysSuggestedStories() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -643,7 +633,6 @@ class ClassroomListFragmentTest { */ @Test fun testFragment_markStory0DonePlayStory1FirstTestTopic_playFractionsTopic_orderIsCorrect() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -688,7 +677,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markStory0DoneFirstTestTopic_suggestedStoriesIsCorrect() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -710,7 +698,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markStory0DoneForFractions_recommendedStoriesIsCorrect() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -741,7 +728,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_clickViewAll_opensRecentlyPlayedActivity() { Intents.init() - setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( @@ -771,7 +757,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markFullProgressForFractions_playRatios_displaysRecommendedStories() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedRatiosStory0Exp0( @@ -807,7 +792,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markAtLeastOneStoryCompletedForAllTopics_displaysComingSoonTopicsList() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -841,7 +825,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markFullProgressForSecondTestTopic_displaysComingSoonTopicsText() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -863,7 +846,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_markStory0OfRatiosAndTestTopics0And1Done_playTestTopicStory0_noPromotions() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -899,7 +881,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_clickPromotedStory_opensTopicActivity() { Intents.init() - setUpTestApplicationComponent() logIntoAdminTwice() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( @@ -929,7 +910,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_clickTopicSummary_opensTopicActivityThroughPlayIntent() { Intents.init() - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() @@ -955,7 +935,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_scrollToBottom_classroomListSticks_classroomListIsVisible() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() @@ -965,7 +944,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_scrollToBottom_classroomListCollapsesAndSticks_classroomListIsVisible() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() @@ -984,7 +962,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_switchClassroom_topicListUpdatesCorrectly() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() @@ -1019,7 +996,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_clickOnTopicCard_returnBack_classroomSelectionIsRetained() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) testCoroutineDispatchers.runCurrent() @@ -1049,7 +1025,6 @@ class ClassroomListFragmentTest { @Test fun testFragment_switchClassrooms_topicListUpdatesCorrectly() { - setUpTestApplicationComponent() scenario = ActivityScenario.launch(ClassroomListActivity::class.java) profileTestHelper.logIntoAdmin() testCoroutineDispatchers.runCurrent() @@ -1103,8 +1078,7 @@ class ClassroomListFragmentTest { logIntoAdmin() } - private fun setUpTestApplicationComponent(onboardingV2Enabled: Boolean = false) { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(onboardingV2Enabled) + private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() @@ -1115,7 +1089,7 @@ class ClassroomListFragmentTest { @Singleton @Component( modules = [ - TestPlatformParameterModule::class, RobolectricModule::class, + PlatformParameterModule::class, RobolectricModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 8c276551e21..5d657195add 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 @@ -79,6 +79,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -130,6 +131,9 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class MathExpressionInteractionsViewTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 10bf38da63b..f5fbdda9db0 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 @@ -64,6 +64,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -95,6 +96,8 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class AppCompatCheckBoxBindingAdaptersTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 cfa195714fa..55d0ad9981c 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 @@ -68,6 +68,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -99,6 +100,8 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class DrawableBindingAdaptersTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/TextInputLayoutBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/TextInputLayoutBindingAdaptersTest.kt index 953d52cf8de..7d12ff98470 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/TextInputLayoutBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/TextInputLayoutBindingAdaptersTest.kt @@ -13,6 +13,7 @@ import com.google.common.truth.Truth.assertThat import dagger.Component import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.R @@ -63,6 +64,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction @@ -96,6 +98,9 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class TextInputLayoutBindingAdaptersTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context 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 9bb4cab6bb1..19766fbde7f 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 @@ -66,6 +66,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -102,6 +103,9 @@ private const val TIMESTAMP = 1556094120000 qualifiers = "port-xxhdpi" ) class TextViewBindingAdaptersTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 3070fd11dd2..f4d48b8a24d 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 @@ -64,6 +64,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -100,6 +101,9 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class MathExpressionParserActivityTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 36b378e0a2d..9a6c9283862 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 @@ -73,6 +73,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction @@ -119,6 +120,9 @@ class MathExpressionParserFragmentTest { ) } + @get:Rule + val oppiaTestRule = OppiaTestRule() + // Note that the locale rule must be initialized first since the scenario rule can depend on the // locale being initialized. @get:Rule 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 f0943148df3..08a503c347b 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 @@ -114,6 +114,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.spotlight.SpotlightStateController @@ -123,6 +124,7 @@ 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.BuildEnvironment +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn import org.oppia.android.testing.TestLogReportingModule @@ -131,7 +133,6 @@ 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 import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper @@ -153,6 +154,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.util.Locale @@ -227,6 +229,7 @@ class HomeActivityTest { fun setUp() { Intents.init() setUpTestApplicationComponent() + profileTestHelper.initializeProfiles() profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() profileId1 = ProfileId.newBuilder().setInternalId(internalProfileId1).build() testCoroutineDispatchers.registerIdlingResource() @@ -263,7 +266,6 @@ class HomeActivityTest { @Test fun testHomeActivity_loadingItemsSuccess_checkProgressbarIsNotDisplayed() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() @@ -289,7 +291,6 @@ class HomeActivityTest { @Test fun testHomeActivity_withAdminProfile_configChange_profileNameIsDisplayed() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(EVENING_TIMESTAMP) launch(createHomeActivityIntent(internalProfileId)).use { @@ -306,7 +307,6 @@ class HomeActivityTest { @Test fun testHomeActivity_morningTimestamp_goodMorningMessageIsDisplayed_withAdminProfileName() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(MORNING_TIMESTAMP) launch(createHomeActivityIntent(internalProfileId)).use { @@ -322,7 +322,6 @@ class HomeActivityTest { @Test fun testHomeActivity_afternoonTimestamp_goodAfternoonMessageIsDisplayed_withAdminProfileName() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(AFTERNOON_TIMESTAMP) launch(createHomeActivityIntent(internalProfileId)).use { @@ -338,7 +337,6 @@ class HomeActivityTest { @Test fun testHomeActivity_eveningTimestamp_goodEveningMessageIsDisplayed_withAdminProfileName() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(EVENING_TIMESTAMP) launch(createHomeActivityIntent(internalProfileId)).use { @@ -361,8 +359,8 @@ class HomeActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testPromotedStorySpotlight_setToShowOnSecondLogin_notSeenBefore_checkSpotlightShown() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() @@ -372,8 +370,8 @@ class HomeActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testPromotedStoriesSpotlight_setToShowOnSecondLogin_pressDone_checkSpotlightNotShown() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() @@ -398,7 +396,6 @@ class HomeActivityTest { @Test fun testHomeActivity_recentlyPlayedStoriesTextIsDisplayed() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -422,7 +419,6 @@ class HomeActivityTest { @Test fun testHomeActivity_viewAllTextIsDisplayed() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -447,7 +443,6 @@ class HomeActivityTest { @Test fun testHomeActivity_storiesPlayedOneWeekAgo_displaysLastPlayedStoriesText() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -472,7 +467,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markStory0DoneForFraction_displaysRecommendedStories() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedFractionsTopic( profileId = profileId1, @@ -505,7 +499,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markCompletedRatiosStory0_recommendsFractions() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedRatiosStory0( profileId = profileId1, @@ -531,7 +524,6 @@ class HomeActivityTest { @Test fun testHomeActivity_noTopicProgress_initialRecommendationFractionsAndRatiosIsCorrect() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() @@ -558,7 +550,6 @@ class HomeActivityTest { @Test fun testHomeActivity_forPromotedActivityList_hideViewAll() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -579,7 +570,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markStory0DoneForRatiosAndFirstTestTopic_displaysRecommendedStories() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedTestTopic0Story0( profileId = profileId1, @@ -609,7 +599,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markAtLeastOneStoryCompletedForAllTopics_displaysComingSoonTopicsList() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedFractionsTopic( profileId = profileId1, @@ -647,7 +636,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markFullProgressForSecondTestTopic_displaysComingSoonTopicsText() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedTestTopic1( profileId = profileId1, @@ -690,7 +678,6 @@ class HomeActivityTest { */ @Test fun testHomeActivity_markStory0DonePlayStory1FirstTestTopic_playFractionsTopic_orderIsCorrect() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedTestTopic0Story0( profileId = profileId1, @@ -736,7 +723,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markStory0OfRatiosAndTestTopics0And1Done_playTestTopicStory0_noPromotions() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedRatiosStory0( profileId = profileId1, @@ -774,7 +760,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markStory0DoneFirstTestTopic_recommendedStoriesIsCorrect() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedTestTopic0Story0( profileId = profileId1, @@ -800,7 +785,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markStory0DoneForFrac_recommendedStoriesIsCorrect() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedFractionsStory0( profileId = profileId1, @@ -832,7 +816,6 @@ class HomeActivityTest { @Test fun testHomeActivity_clickViewAll_opensRecentlyPlayedActivity() { - setUpTestWithOnboardingV2Disabled() markSpotlightSeen(profileId1) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( @@ -864,7 +847,6 @@ class HomeActivityTest { @Test fun testHomeActivity_promotedCard_chapterNameIsCorrect() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -884,7 +866,6 @@ class HomeActivityTest { @Test fun testHomeActivity_promotedCard_storyNameIsCorrect() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -904,7 +885,6 @@ class HomeActivityTest { @Test fun testHomeActivity_configChange_promotedCard_storyNameIsCorrect() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -929,7 +909,6 @@ class HomeActivityTest { @Test fun testHomeActivity_markFullProgressForFractions_playRatios_displaysRecommendedStories() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedRatiosStory0Exp0( profileId = profileId1, @@ -965,7 +944,6 @@ class HomeActivityTest { @Test fun testHomeActivity_clickPromotedStory_opensTopicActivity() { - setUpTestWithOnboardingV2Disabled() markSpotlightSeen(profileId1) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( @@ -997,7 +975,6 @@ class HomeActivityTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#4700): Make this test work on Espresso. fun testHomeActivity_promotedStoryHasScalableWidth() { - setUpTestWithOnboardingV2Disabled() fontScaleConfigurationUtil.adjustFontScale(context, ReadingTextSize.EXTRA_LARGE_TEXT_SIZE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( @@ -1030,7 +1007,6 @@ class HomeActivityTest { @Test fun testHomeActivity_promotedCard_topicNameIsCorrect() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -1054,7 +1030,6 @@ class HomeActivityTest { @Test fun testHomeActivity_firstTestTopic_topicSummary_opensTopicActivityThroughPlayIntent() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() markSpotlightSeen(profileId1) launch(createHomeActivityIntent(internalProfileId1)).use { @@ -1080,7 +1055,6 @@ class HomeActivityTest { @Test fun testHomeActivity_firstTestTopic_topicSummary_topicNameIsCorrect() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() @@ -1095,7 +1069,6 @@ class HomeActivityTest { @Test fun testHomeActivity_fiveLessons_topicSummary_lessonCountIsCorrect() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() @@ -1110,7 +1083,6 @@ class HomeActivityTest { @Test fun testHomeActivity_secondTestTopic_topicSummary_allTopics_topicNameIsCorrect() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId1, @@ -1130,7 +1102,6 @@ class HomeActivityTest { @Test fun testHomeActivity_oneLesson_topicSummary_lessonCountIsCorrect() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() @@ -1148,7 +1119,6 @@ class HomeActivityTest { @Config(qualifiers = "+port-mdpi") @Test fun testHomeActivity_longProfileName_welcomeMessageIsDisplayed() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(longNameInternalProfileId)).use { testCoroutineDispatchers.runCurrent() scrollToPosition(0) @@ -1167,7 +1137,6 @@ class HomeActivityTest { @Config(qualifiers = "+land-mdpi") @Test fun testHomeActivity_configChange_longProfileName_welcomeMessageIsDisplayed() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(longNameInternalProfileId)).use { onView(isRoot()).perform(orientationLandscape()) testCoroutineDispatchers.runCurrent() @@ -1187,7 +1156,6 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-port") @Test fun testHomeActivity_longProfileName_tabletPortraitWelcomeMessageIsDisplayed() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(longNameInternalProfileId)).use { testCoroutineDispatchers.runCurrent() scrollToPosition(0) @@ -1206,7 +1174,6 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-land") @Test fun testHomeActivity_longProfileName_tabletLandscapeWelcomeMessageIsDisplayed() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(longNameInternalProfileId)).use { onView(isRoot()).perform(orientationLandscape()) testCoroutineDispatchers.runCurrent() @@ -1223,7 +1190,6 @@ class HomeActivityTest { @Test fun testHomeActivity_oneLesson_topicSummary_configChange_lessonCountIsCorrect() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() @@ -1239,7 +1205,6 @@ class HomeActivityTest { @Test fun testHomeActivity_clickTopicSummary_opensTopicActivity() { - setUpTestWithOnboardingV2Disabled() logIntoUserTwice() markSpotlightSeen(profileId1) launch(createHomeActivityIntent(internalProfileId1)).use { @@ -1259,7 +1224,6 @@ class HomeActivityTest { @Test fun testHomeActivity_onBackPressed_exitToProfileChooserDialogIsDisplayed() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() pressBack() @@ -1271,7 +1235,6 @@ class HomeActivityTest { @Test fun testHomeActivity_onBackPressed_configChange_exitToProfileChooserDialogIsDisplayed() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() @@ -1285,7 +1248,6 @@ class HomeActivityTest { @Test fun testHomeActivity_onBackPressed_clickExit_opensProfileActivity() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() pressBack() @@ -1298,7 +1260,6 @@ class HomeActivityTest { @Test fun testHomeActivity_checkSpanForItem0_spanSizeIsTwoOrThree() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() if (context.resources.getBoolean(R.bool.isTablet)) { @@ -1311,7 +1272,6 @@ class HomeActivityTest { @Test fun testHomeActivity_checkSpanForItem4_spanSizeIsOne() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.home_recycler_view)).check(hasGridItemCount(1, 4)) @@ -1320,7 +1280,6 @@ class HomeActivityTest { @Test fun testHomeActivity_configChange_checkSpanForItem4_spanSizeIsOne() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(internalProfileId1)).use { testCoroutineDispatchers.runCurrent() onView(isRoot()).perform(orientationLandscape()) @@ -1330,7 +1289,6 @@ class HomeActivityTest { @Test fun testHomeActivity_allTopicsCompleted_hidesPromotedStories() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = createProfileId(internalProfileId), @@ -1352,7 +1310,6 @@ class HomeActivityTest { @Test fun testHomeActivity_partialProgressForFractionsAndRatios_showsRecentlyPlayedStories() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markCompletedFractionsStory0Exp0( profileId = profileId, @@ -1380,7 +1337,6 @@ class HomeActivityTest { @Test fun testHomeActivity_allTopicsCompleted_displaysAllTopicsHeader() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = createProfileId(internalProfileId), @@ -1401,7 +1357,6 @@ class HomeActivityTest { @Config(qualifiers = "+port") @Test fun testHomeActivity_allTopicsCompleted_mobilePortrait_displaysAllTopicCardsIn2Columns() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1418,7 +1373,6 @@ class HomeActivityTest { @Config(qualifiers = "+land") @Test fun testHomeActivity_allTopicsCompleted_mobileLandscape_displaysAllTopicCardsIn3Columns() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1435,7 +1389,6 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-port") @Test fun testHomeActivity_allTopicsCompleted_tabletPortrait_displaysAllTopicCardsIn3Columns() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1452,7 +1405,6 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-land") @Test fun testHomeActivity_allTopicsCompleted_tabletLandscape_displaysAllTopicCardsIn4Columns() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markAllTopicsAsCompleted( profileId = profileId, @@ -1468,7 +1420,6 @@ class HomeActivityTest { @Test fun testHomeActivity_noTopicsCompleted_displaysAllTopicsHeader() { - setUpTestWithOnboardingV2Disabled() // Only new users will have no progress for any topics. logIntoAdminTwice() launch(createHomeActivityIntent(internalProfileId)).use { @@ -1485,7 +1436,6 @@ class HomeActivityTest { @Config(qualifiers = "+port") @Test fun testHomeActivity_noTopicsStarted_mobilePortraitDisplaysTopicsIn2Columns() { - setUpTestWithOnboardingV2Disabled() // Only new users will have no progress for any topics. logIntoAdminTwice() launch(createHomeActivityIntent(internalProfileId)).use { @@ -1505,7 +1455,6 @@ class HomeActivityTest { @Config(qualifiers = "+land") @Test fun testHomeActivity_noTopicsStarted_mobileLandscapeDisplaysTopicsIn3Columns() { - setUpTestWithOnboardingV2Disabled() // Only new users will have no progress for any topics. logIntoAdminTwice() launch(createHomeActivityIntent(internalProfileId)).use { @@ -1526,7 +1475,6 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-port") @Test fun testHomeActivity_noTopicsStarted_tabletPortraitDisplaysTopicsIn3Columns() { - setUpTestWithOnboardingV2Disabled() // Only new users will have no progress for any topics. logIntoAdminTwice() markSpotlightSeen(profileId) @@ -1543,7 +1491,6 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-land") @Test fun testHomeActivity_noTopicsStarted_tabletLandscapeDisplaysTopicsIn4Columns() { - setUpTestWithOnboardingV2Disabled() // Only new users will have no progress for any topics. logIntoAdminTwice() markSpotlightSeen(profileId) @@ -1560,7 +1507,6 @@ class HomeActivityTest { @Test fun testHomeActivity_multipleRecentlyPlayedStories_mobileShows3PromotedStories() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedTestTopic0Story0Exp0( profileId = profileId, @@ -1598,7 +1544,6 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-port") @Test fun testHomeActivity_multipleRecentlyPlayedStories_tabletPortraitShows3PromotedStories() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedTestTopic0Story0Exp0( profileId = profileId, @@ -1637,7 +1582,6 @@ class HomeActivityTest { @Config(qualifiers = "+sw600dp-land") @Test fun testHomeActivity_multipleRecentlyPlayedStories_tabletLandscapeShows4PromotedStories() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedTestTopic0Story0Exp0( profileId = profileId, @@ -1675,7 +1619,6 @@ class HomeActivityTest { @Test fun testHomeActivity_onScrollDown_promotedStoryListViewStillShows() { - setUpTestWithOnboardingV2Disabled() // This test is to catch a bug introduced and then fixed in #2246 // (see https://github.com/oppia/oppia-android/pull/2246#pullrequestreview-565964462) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -1704,7 +1647,6 @@ class HomeActivityTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3840): Make this test work on Espresso. fun testHomeActivity_defaultState_displaysStringsInEnglish() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(MORNING_TIMESTAMP) launch(createHomeActivityIntent(internalProfileId)).use { @@ -1723,7 +1665,6 @@ class HomeActivityTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3840): Make this test work on Espresso. fun testHomeActivity_defaultState_hasEnglishAndroidLocale() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() @@ -1737,7 +1678,6 @@ class HomeActivityTest { @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) fun testHomeActivity_defaultState_hasEnglishDisplayLocale() { - setUpTestWithOnboardingV2Disabled() launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() @@ -1752,7 +1692,6 @@ class HomeActivityTest { @Test @Ignore("Current language switching mechanism doesn't work correctly in Robolectric") fun testHomeActivity_changeSystemLocaleAndConfigChange_recreatesActivity() { - setUpTestWithOnboardingV2Disabled() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeToSameDateTime(MORNING_TIMESTAMP) launch(createHomeActivityIntent(internalProfileId)).use { scenario -> @@ -1796,7 +1735,6 @@ class HomeActivityTest { ) @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3840): Make this test work on Espresso & Robolectric. fun testHomeActivity_initialArabicContext_displaysStringsInArabic() { - setUpTestWithOnboardingV2Disabled() // Ensure the system locale matches the initial locale context. forceDefaultLocale(EGYPT_ARABIC_LOCALE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1822,7 +1760,6 @@ class HomeActivityTest { ) @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3840): Make this test work on Espresso & Robolectric. fun testHomeActivity_initialArabicContext_isInRtlLayout() { - setUpTestWithOnboardingV2Disabled() // Ensure the system locale matches the initial locale context. forceDefaultLocale(EGYPT_ARABIC_LOCALE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1845,7 +1782,6 @@ class HomeActivityTest { ) @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) fun testHomeActivity_initialArabicContext_hasArabicDisplayLocale() { - setUpTestWithOnboardingV2Disabled() // Ensure the system locale matches the initial locale context. forceDefaultLocale(EGYPT_ARABIC_LOCALE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1869,7 +1805,6 @@ class HomeActivityTest { ) @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3840): Make this test work on Espresso & Robolectric. fun testHomeActivity_initialBrazilianPortugueseContext_displayStringsInPortuguese() { - setUpTestWithOnboardingV2Disabled() // Ensure the system locale matches the initial locale context. forceDefaultLocale(BRAZIL_PORTUGUESE_LOCALE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1896,7 +1831,6 @@ class HomeActivityTest { ) @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3840): Make this test work on Espresso & Robolectric. fun testHomeActivity_initialBrazilianPortugueseContext_isInLtrLayout() { - setUpTestWithOnboardingV2Disabled() // Ensure the system locale matches the initial locale context. forceDefaultLocale(BRAZIL_PORTUGUESE_LOCALE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1920,7 +1854,6 @@ class HomeActivityTest { ) @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) fun testHomeActivity_initialBrazilianPortugueseContext_hasPortugueseDisplayLocale() { - setUpTestWithOnboardingV2Disabled() // Ensure the system locale matches the initial locale context. forceDefaultLocale(BRAZIL_PORTUGUESE_LOCALE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1944,7 +1877,6 @@ class HomeActivityTest { ) @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3840): Make this test work on Espresso & Robolectric. fun testHomeActivity_initialNigerianPidginContext_isInLtrLayout() { - setUpTestWithOnboardingV2Disabled() // Ensure the system locale matches the initial locale context. forceDefaultLocale(NIGERIA_NAIJA_LOCALE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1968,7 +1900,6 @@ class HomeActivityTest { ) @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) fun testHomeActivity_initialNigerianPidginContext_hasNaijaDisplayLocale() { - setUpTestWithOnboardingV2Disabled() // Ensure the system locale matches the initial locale context. forceDefaultLocale(NIGERIA_NAIJA_LOCALE) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1985,7 +1916,6 @@ class HomeActivityTest { @Test fun testHomeActivity_onBackPressed_soleLearnerProfile_exitsApp() { - setUpTestWithOnboardingV2Enabled() profileTestHelper.addOnlyAdminProfileWithoutPin() markSpotlightSeen(profileId) launch(createHomeActivityIntent(internalProfileId)).use { scenario -> @@ -2000,8 +1930,6 @@ class HomeActivityTest { @Test fun testHomeActivity_onBackPressed_nonSoleLearner_exitToProfileChooserDialogIsDisplayed() { - setUpTestWithOnboardingV2Enabled() - profileTestHelper.initializeProfiles() markSpotlightSeen(profileId) launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() @@ -2014,8 +1942,6 @@ class HomeActivityTest { @Test fun testActivity_onBackPressed_nonSoleLearner_configChange_exitToProfileDialogIsDisplayed() { - setUpTestWithOnboardingV2Enabled() - profileTestHelper.initializeProfiles() markSpotlightSeen(profileId) launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() @@ -2029,8 +1955,6 @@ class HomeActivityTest { @Test fun testHomeActivity_onBackPressed_clickExitOnDialog_opensProfileActivity() { - setUpTestWithOnboardingV2Enabled() - profileTestHelper.initializeProfiles() markSpotlightSeen(profileId) launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() @@ -2044,8 +1968,6 @@ class HomeActivityTest { @Test fun testHomeActivityV1_onBackPressed_clickExitOnDialog_opensProfileActivity() { - setUpTestWithOnboardingV2Disabled() - profileTestHelper.initializeProfiles() markSpotlightSeen(profileId) launch(createHomeActivityIntent(internalProfileId)).use { testCoroutineDispatchers.runCurrent() @@ -2057,17 +1979,6 @@ class HomeActivityTest { } } - private fun setUpTestWithOnboardingV2Enabled() { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(true) - setUpTestApplicationComponent() - } - - private fun setUpTestWithOnboardingV2Disabled() { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(true) - setUpTestApplicationComponent() - profileTestHelper.initializeProfiles() - } - private fun markSpotlightSeen(profileId: ProfileId) { spotlightStateController.markSpotlightViewed(profileId, Spotlight.FeatureCase.PROMOTED_STORIES) testCoroutineDispatchers.runCurrent() @@ -2199,7 +2110,7 @@ class HomeActivityTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 0916c25d749..a5124cde933 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 @@ -97,12 +97,15 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_0 import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0 import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule @@ -110,7 +113,6 @@ 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 -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper @@ -131,6 +133,7 @@ import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -457,8 +460,8 @@ class RecentlyPlayedFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testRecentlyPlayedTestActivity_disableClassrooms_recommendedSection_classroomNameIsNotDisplayed() { // ktlint-disable max-line-length - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId, @@ -486,8 +489,8 @@ class RecentlyPlayedFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testRecentlyPlayedTestActivity_enableClassrooms_recommendedSection_classroomNameIsCorrect() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId, @@ -834,8 +837,8 @@ class RecentlyPlayedFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testRecentlyPlayedTestActivity_disableClassrooms_classroomNameIsNotDisplayed() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId, @@ -867,8 +870,8 @@ class RecentlyPlayedFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testRecentlyPlayedTestActivity_enableClassrooms_classroomNameIsCorrect() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId, @@ -1384,8 +1387,8 @@ class RecentlyPlayedFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testRecentlyPlayedTestActivity_disableClassrooms_configChange_classroomNameIsNotDisplayed() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId, @@ -1418,8 +1421,8 @@ class RecentlyPlayedFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testRecentlyPlayedTestActivity_enableClassrooms_configChange_classroomNameIsCorrect() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) storyProgressTestHelper.markInProgressSavedFractionsStory0Exp0( profileId = profileId, @@ -1661,7 +1664,7 @@ class RecentlyPlayedFragmentTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 289fdb8386e..5c268da65a5 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 @@ -63,16 +63,17 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn 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 import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -90,6 +91,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.profile.PROFILE_ID_INTENT_DECORATOR import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -161,8 +163,8 @@ class MyDownloadsActivityTest { @Test @RunOn(TestPlatform.ESPRESSO) + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testMyDownloadsActivity_classroomsFlagEnabled_pressBack_opensClassroomListActivity() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) ActivityScenario.launch(MyDownloadsActivity::class.java).use { pressBack() intended(hasComponent(ClassroomListActivity::class.java.name)) @@ -174,7 +176,7 @@ class MyDownloadsActivityTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, diff --git a/app/src/sharedTest/java/org/oppia/android/app/onboarding/CreateProfileFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/onboarding/CreateProfileFragmentTest.kt index f45cebfb42f..f33f9bc344b 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/onboarding/CreateProfileFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/onboarding/CreateProfileFragmentTest.kt @@ -86,6 +86,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule @@ -96,7 +97,6 @@ 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.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -662,7 +662,7 @@ class CreateProfileFragmentTest { @Singleton @Component( modules = [ - TestPlatformParameterModule::class, RobolectricModule::class, + PlatformParameterModule::class, RobolectricModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, diff --git a/app/src/sharedTest/java/org/oppia/android/app/onboarding/IntroFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/onboarding/IntroFragmentTest.kt index fdc6ba55566..b260ea14ced 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/onboarding/IntroFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/onboarding/IntroFragmentTest.kt @@ -70,6 +70,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule @@ -79,7 +80,6 @@ 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 import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -253,7 +253,7 @@ class IntroFragmentTest { @Singleton @Component( modules = [ - TestPlatformParameterModule::class, RobolectricModule::class, + PlatformParameterModule::class, RobolectricModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 c985ce11ab4..92dce9c9a97 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 @@ -90,10 +90,13 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn import org.oppia.android.testing.TestLogReportingModule @@ -101,7 +104,6 @@ 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.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -119,6 +121,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.profile.PROFILE_ID_INTENT_DECORATOR import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -160,8 +163,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkDefaultSlideTitle_isCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView( allOf( @@ -173,8 +177,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkDefaultSlideDescription_isCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView( allOf( @@ -186,8 +191,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkDefaultSlide_index0DotIsActive_otherDotsAreInactive() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView( allOf( @@ -217,24 +223,27 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkDefaultSlide_skipButtonIsVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.skip_text_view)).check(matches(isDisplayed())) } } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkDefaultSlide_getStartedButtonIsNotVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.get_started_button)).check(doesNotExist()) } } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_swipeRight_doesNotWork() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(swipeRight()) onView( @@ -247,8 +256,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide1Title_isCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) testCoroutineDispatchers.runCurrent() @@ -262,8 +272,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide1Description_isCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) testCoroutineDispatchers.runCurrent() @@ -277,8 +288,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide1_index1DotIsActive_otherDotsAreInactive() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) onView( @@ -309,8 +321,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide1_skipButtonIsVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) testCoroutineDispatchers.runCurrent() @@ -319,8 +332,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide1_clickSkipButton_shiftsToLastSlide() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) @@ -337,8 +351,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide1_getStartedButtonIsNotVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) onView(withId(R.id.get_started_button)).check(doesNotExist()) @@ -346,8 +361,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_swipeLeftThenSwipeRight_isWorking() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 0)) @@ -362,8 +378,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide2Title_isCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 2)) testCoroutineDispatchers.runCurrent() @@ -377,8 +394,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide2Description_isCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 2)) testCoroutineDispatchers.runCurrent() @@ -392,8 +410,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide2_index2DotIsActive_otherDotsAreInactive() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 2)) onView( @@ -424,8 +443,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide2_skipButtonIsVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 2)) testCoroutineDispatchers.runCurrent() @@ -434,8 +454,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide2_clickSkipButton_shiftsToLastSlide() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 2)) @@ -452,8 +473,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide2_getStartedButtonIsNotVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 2)) onView(withId(R.id.get_started_button)).check(doesNotExist()) @@ -461,8 +483,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide3Title_isCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 3)) testCoroutineDispatchers.runCurrent() @@ -476,8 +499,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide3Description_isCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 3)) testCoroutineDispatchers.runCurrent() @@ -491,8 +515,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide3_skipButtonIsNotVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 3)) testCoroutineDispatchers.runCurrent() @@ -501,8 +526,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide3_getStartedButtonIsVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 3)) testCoroutineDispatchers.runCurrent() @@ -511,8 +537,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide3_clickGetStartedButton_opensProfileActivity() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 3)) @@ -524,8 +551,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_swipeLeftOnLastSlide_doesNotWork() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 3)) testCoroutineDispatchers.runCurrent() @@ -540,8 +568,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_slide0Title_changeOrientation_titleIsCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(isRoot()).perform(orientationLandscape()) onView( @@ -554,8 +583,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_moveToSlide1_changeOrientation_titleIsCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) testCoroutineDispatchers.runCurrent() @@ -570,8 +600,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_clickOnSkip_changeOrientation_titleIsCorrect() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.skip_text_view)).perform(click()) @@ -587,8 +618,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_nextArrowIcon_hasCorrectContentDescription() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_fragment_next_image_view)).check( matches( @@ -601,8 +633,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_configChange_nextArrowIcon_hasCorrectContentDescription() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(isRoot()).perform(orientationLandscape()) onView(withId(R.id.onboarding_fragment_next_image_view)).check( @@ -616,8 +649,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_moveToSlide1_bottomDots_hasCorrectContentDescription() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) testCoroutineDispatchers.runCurrent() @@ -632,8 +666,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_configChange_moveToSlide1_bottomDots_hasCorrectContentDescription() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 1)) testCoroutineDispatchers.runCurrent() @@ -649,8 +684,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_moveToSlide2_bottomDots_hasCorrectContentDescription() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 2)) testCoroutineDispatchers.runCurrent() @@ -665,8 +701,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_configChange_moveToSlide2_bottomDots_hasCorrectContentDescription() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { onView(withId(R.id.onboarding_slide_view_pager)).perform(scrollToPosition(position = 2)) testCoroutineDispatchers.runCurrent() @@ -682,8 +719,9 @@ class OnboardingFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_checkSlide3_policiesLinkIsVisible() { - setUpTestWithOnboardingV2Disabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() onView(withId(R.id.skip_text_view)).perform(click()) @@ -700,8 +738,9 @@ class OnboardingFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_screenIsCorrectlyDisplayed() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -723,8 +762,9 @@ class OnboardingFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_configChange_screenIsCorrectlyDisplayed() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { onView(isRoot()).perform(orientationLandscape()) @@ -748,8 +788,9 @@ class OnboardingFragmentTest { @Config(qualifiers = "sw600dp-port") @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_tabletPortrait_screenIsCorrectlyDisplayed() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { onView(isRoot()).perform(orientationLandscape()) @@ -773,8 +814,9 @@ class OnboardingFragmentTest { @Config(qualifiers = "sw600dp-land") @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_tabletLandscape_screenIsCorrectlyDisplayed() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { onView(isRoot()).perform(orientationLandscape()) @@ -798,8 +840,9 @@ class OnboardingFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_englishLocale_englishIsPreselected() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -817,8 +860,9 @@ class OnboardingFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_englishLocale_layoutIsLtr() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -835,8 +879,9 @@ class OnboardingFragmentTest { appStringAndroidLanguageId = "ar" ) @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_arabicLocale_arabicIsPreselected() { - setUpTestWithOnboardingV2Enabled() + setUp() forceDefaultLocale(EGYPT_ARABIC_LOCALE) launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -860,8 +905,9 @@ class OnboardingFragmentTest { appStringAndroidLanguageId = "ar" ) @RunOn(TestPlatform.ROBOLECTRIC) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_arabicLocale_layoutIsRtl() { - setUpTestWithOnboardingV2Enabled() + setUp() forceDefaultLocale(EGYPT_ARABIC_LOCALE) launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -880,8 +926,9 @@ class OnboardingFragmentTest { appStringAndroidRegionId = "BR" ) @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_portugueseLocale_portugueseIsPreselected() { - setUpTestWithOnboardingV2Enabled() + setUp() forceDefaultLocale(BRAZIL_PORTUGUESE_LOCALE) launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -906,8 +953,9 @@ class OnboardingFragmentTest { appStringAndroidRegionId = "BR" ) @RunOn(TestPlatform.ROBOLECTRIC) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_portugueseLocale_layoutIsLtr() { - setUpTestWithOnboardingV2Enabled() + setUp() forceDefaultLocale(BRAZIL_PORTUGUESE_LOCALE) launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -926,8 +974,9 @@ class OnboardingFragmentTest { appStringAndroidRegionId = "NG" ) @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_nigeriaLocale_naijaIsPreselected() { - setUpTestWithOnboardingV2Enabled() + setUp() forceDefaultLocale(NIGERIA_NAIJA_LOCALE) launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -952,8 +1001,9 @@ class OnboardingFragmentTest { appStringAndroidRegionId = "NG" ) @RunOn(TestPlatform.ROBOLECTRIC) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_nigeriaLocale_layoutIsLtr() { - setUpTestWithOnboardingV2Enabled() + setUp() forceDefaultLocale(NIGERIA_NAIJA_LOCALE) launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -972,8 +1022,9 @@ class OnboardingFragmentTest { appStringAndroidRegionId = "CA" ) @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOnboardingFragment_onboardingV2Enabled_unsupportedLocale_englishIsPreselected() { - setUpTestWithOnboardingV2Enabled() + setUp() forceDefaultLocale(CANADA_FRENCH_LOCALE) launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -991,8 +1042,9 @@ class OnboardingFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2Enabled_clickLetsGoButton_launchesProfileTypeScreen() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { testCoroutineDispatchers.runCurrent() // Verifies that the default language selection is set if the user does not make a selection. @@ -1005,8 +1057,9 @@ class OnboardingFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_languageSelectionChanged_languageIsUpdated() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { scenario -> testCoroutineDispatchers.runCurrent() @@ -1033,8 +1086,9 @@ class OnboardingFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_languageSelectionChanged_configChange_languageIsUpdated() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { scenario -> testCoroutineDispatchers.runCurrent() @@ -1060,8 +1114,9 @@ class OnboardingFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_onboardingV2_orientationChange_languageSelectionIsRestored() { - setUpTestWithOnboardingV2Enabled() + setUp() launch(OnboardingActivity::class.java).use { scenario -> testCoroutineDispatchers.runCurrent() @@ -1089,16 +1144,6 @@ class OnboardingFragmentTest { Locale.setDefault(locale) } - private fun setUpTestWithOnboardingV2Disabled() { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(false) - setUp() - } - - private fun setUpTestWithOnboardingV2Enabled() { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(true) - setUp() - } - private fun setUp() { Intents.init() setUpTestApplicationComponent() @@ -1134,7 +1179,7 @@ class OnboardingFragmentTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, diff --git a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingProfileTypeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingProfileTypeFragmentTest.kt index 1077e1a3afc..014a02bc7ce 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingProfileTypeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingProfileTypeFragmentTest.kt @@ -74,6 +74,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule @@ -83,7 +84,6 @@ 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 import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -371,7 +371,7 @@ class OnboardingProfileTypeFragmentTest { @Singleton @Component( modules = [ - TestPlatformParameterModule::class, RobolectricModule::class, + PlatformParameterModule::class, RobolectricModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 703b2c7cf94..6083453dff6 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 @@ -29,6 +29,7 @@ import org.hamcrest.CoreMatchers.instanceOf import org.hamcrest.CoreMatchers.not import org.hamcrest.core.AllOf.allOf import org.junit.After +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -83,17 +84,19 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -112,6 +115,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -143,40 +147,44 @@ class AudioLanguageFragmentTest { @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers + @Before + fun setUp() { + initializeTestApplicationComponent() + } + @After fun tearDown() { testCoroutineDispatchers.unregisterIdlingResource() - TestPlatformParameterModule.reset() Intents.release() } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOpenFragment_withEnglish_selectedLanguageIsEnglish() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { verifyEnglishIsSelected() } } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOpenFragment_withPortuguese_selectedLanguageIsPortuguese() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(BRAZILIAN_PORTUGUESE_LANGUAGE).use { verifyPortugueseIsSelected() } } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testOpenFragment_withNigerianPidgin_selectedLanguageIsNaija() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(NIGERIAN_PIDGIN_LANGUAGE).use { verifyNigerianPidginIsSelected() } } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAudioLanguage_configChange_selectedLanguageIsEnglish() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { rotateToLandscape() @@ -186,8 +194,8 @@ class AudioLanguageFragmentTest { @Test @Config(qualifiers = "sw600dp") + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAudioLanguage_tabletConfig_selectedLanguageIsEnglish() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { testCoroutineDispatchers.runCurrent() @@ -196,8 +204,8 @@ class AudioLanguageFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAudioLanguage_changeLanguageToPortuguese_selectedLanguageIsPortuguese() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { selectPortuguese() @@ -206,8 +214,8 @@ class AudioLanguageFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAudioLanguage_changeLanguageToPortuguese_configChange_selectedLanguageIsPortuguese() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { selectPortuguese() @@ -219,8 +227,8 @@ class AudioLanguageFragmentTest { @Test @Config(qualifiers = "sw600dp") + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAudioLanguage_configChange_changeLanguageToPortuguese_selectedLanguageIsPortuguese() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { rotateToLandscape() @@ -231,8 +239,8 @@ class AudioLanguageFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAudioLanguage_selectPortuguese_thenEnglish_selectedLanguageIsPortuguese() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = false) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { selectPortuguese() @@ -243,8 +251,8 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAudioLanguage_onboardingV2Enabled_allViewsAreDisplayed() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { onView(withId(R.id.audio_language_text)).check( matches(withText("In Oppia, you can listen to lessons!")) @@ -265,8 +273,8 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAudioLanguage_onboardingV2Enabled_configChange_allViewsAreDisplayed() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launchActivityWithLanguage(ENGLISH_AUDIO_LANGUAGE).use { onView(isRoot()).perform(orientationLandscape()) testCoroutineDispatchers.runCurrent() @@ -289,8 +297,8 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_portraitMode_backButtonPressed_currentScreenIsDestroyed() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { scenario -> @@ -303,8 +311,8 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_landscapeMode_backButtonPressed_currentScreenIsDestroyed() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { scenario -> @@ -319,9 +327,9 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testFragment_portraitMode_continueButtonClicked_launchesHomeScreen() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { @@ -336,9 +344,9 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testFragment_landscapeMode_continueButtonClicked_launchesHomeScreen() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { @@ -353,9 +361,9 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testFragment_multipleClassroomsEnabled_continueButtonClicked_launchesClassroomScreen() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { @@ -370,9 +378,9 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testFragment_landscapeMode_multipleClassroomsEnabled_continueButtonLaunchesClassroomScreen() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { @@ -388,9 +396,9 @@ class AudioLanguageFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testFragment_languageSelectionChanged_selectionIsUpdated() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { scenario -> @@ -418,9 +426,9 @@ class AudioLanguageFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testFragment_languageSelectionChanged_configChange_selectionIsUpdated() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { scenario -> @@ -454,8 +462,8 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_fragmentLoaded_verifyCorrectArgumentsPassed() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { scenario -> @@ -472,8 +480,8 @@ class AudioLanguageFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testFragment_saveInstanceState_verifyCorrectStateRestored() { - initializeTestApplicationComponent(enableOnboardingFlowV2 = true) launch( createDefaultAudioActivityIntent(ENGLISH_AUDIO_LANGUAGE) ).use { scenario -> @@ -563,8 +571,7 @@ class AudioLanguageFragmentTest { ).check(matches(withText(expectedLanguageName))) } - private fun initializeTestApplicationComponent(enableOnboardingFlowV2: Boolean) { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(enableOnboardingFlowV2) + private fun initializeTestApplicationComponent() { Intents.init() setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() @@ -579,7 +586,7 @@ class AudioLanguageFragmentTest { @Singleton @Component( modules = [ - TestDispatcherModule::class, TestPlatformParameterModule::class, ApplicationModule::class, + TestDispatcherModule::class, PlatformParameterModule::class, ApplicationModule::class, RobolectricModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 f7abd23fcc6..6704caf0acf 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 @@ -80,6 +80,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule @@ -90,7 +91,6 @@ 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -595,7 +595,7 @@ class OptionsFragmentTest { @Singleton @Component( modules = [ - TestPlatformParameterModule::class, + PlatformParameterModule::class, RobolectricModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, 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 9b3b36f2d6a..a1fb8b2d441 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 @@ -100,6 +100,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule 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.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule @@ -195,6 +196,9 @@ class HtmlParserTest { @field:DefaultResourceBucketName lateinit var resourceBucketName: String + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule var activityScenarioRule: ActivityScenarioRule = ActivityScenarioRule( diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BUILD.bazel index 64a22de135b..2f52e46bdf0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BUILD.bazel @@ -63,7 +63,6 @@ app_test( "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", "//testing/src/main/java/org/oppia/android/testing/espresso:edit_text_input_action", "//testing/src/main/java/org/oppia/android/testing/junit:initialize_default_locale_rule", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:coroutine_executor_service", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", 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 d5adce598af..2fedff8cdef 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 @@ -118,6 +118,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.spotlight.SpotlightStateController @@ -134,6 +135,7 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn @@ -146,7 +148,6 @@ 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 import org.oppia.android.testing.lightweightcheckpointing.RATIOS_STORY_0_EXPLORATION_0_CURRENT_VERSION -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.IsOnRobolectric import org.oppia.android.testing.robolectric.RobolectricModule @@ -171,6 +172,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.io.IOException @@ -472,6 +474,7 @@ class ExplorationActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testVoiceoverLangIconSpotlight_setToShowOnIconClick_notSeen_checkSpotlightIsShown() { setUpAudioForFractionLesson() markSpotlightSeen(Spotlight.FeatureCase.LESSONS_BACK_BUTTON) @@ -503,6 +506,7 @@ class ExplorationActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testVoiceoverLangIconSpotlight_setToShowOnIconClick_alreadySeen_checkSpotlightIsNotShown() { setUpAudioForFractionLesson() markSpotlightSeen(Spotlight.FeatureCase.LESSONS_BACK_BUTTON) @@ -557,6 +561,7 @@ class ExplorationActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testBackButtonSpotlight_setToShowOnFirstLogin_notSeen_checkSpotlightIsShown() { setUpAudioForFractionLesson() launch( @@ -584,6 +589,7 @@ class ExplorationActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testBackButtonSpotlight_setToShowOnFirstLogin_alreadySeen_checkSpotlightIsNotShown() { markSpotlightSeen(Spotlight.FeatureCase.VOICEOVER_PLAY_ICON) setUpAudioForFractionLesson() @@ -633,6 +639,7 @@ class ExplorationActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testVoiceoverIconSpotlight_setToShowAfter3rdLogin_notSeen_checkSpotlightShown() { logIntoAdminThrice() setUpAudioForFractionLesson() @@ -662,6 +669,7 @@ class ExplorationActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testVoiceoverIconSpotlight_setToShowAfter3rdLogin_alreadySeen_checkSpotlightNotShown() { logIntoAdminThrice() setUpAudioForFractionLesson() @@ -2880,7 +2888,7 @@ class ExplorationActivityTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/state/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/player/state/BUILD.bazel index 9bdb9a1acc1..acb5b527517 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/state/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/player/state/BUILD.bazel @@ -28,7 +28,6 @@ app_test( "//testing/src/main/java/org/oppia/android/testing/espresso:edit_text_input_action", "//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/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:coroutine_executor_service", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", 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 09baf65b707..4fdc3c991fa 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 @@ -62,6 +62,7 @@ import org.hamcrest.Description import org.hamcrest.Matcher import org.hamcrest.TypeSafeMatcher import org.junit.After +import org.junit.Before import org.junit.Ignore import org.junit.Rule import org.junit.Test @@ -138,6 +139,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.question.QuestionModule @@ -152,8 +154,11 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule +import org.oppia.android.testing.OverrideBoolParameter import org.oppia.android.testing.RunOn import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule @@ -165,7 +170,6 @@ 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 -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.IsOnRobolectric import org.oppia.android.testing.robolectric.RobolectricModule @@ -188,6 +192,8 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.ImageParsingModule import org.oppia.android.util.parser.image.TestGlideImageLoader +import org.oppia.android.util.platformparameter.FeatureFlag +import org.oppia.android.util.platformparameter.PlatformParameter import org.oppia.android.util.threading.BackgroundDispatcher import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -222,6 +228,11 @@ class StateFragmentTest { private val profileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + @Before + fun setUp() { + setUpTest() + } + @After fun tearDown() { testCoroutineDispatchers.unregisterIdlingResource() @@ -254,8 +265,8 @@ class StateFragmentTest { // config changes. @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_explorationLoads() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -265,8 +276,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_explorationLoads_changeConfiguration_buttonIsNotVisible() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -278,8 +289,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_explorationHasContinueButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -290,8 +301,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_changeConfiguration_explorationHasContinueButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -303,8 +314,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_secondState_hasSubmitButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -318,8 +329,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_changeConfiguration_secondState_hasSubmitButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -334,8 +345,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_secondState_submitAnswer_submitButtonIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -348,8 +359,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_secondState_submitAnswer_clickSubmit_continueButtonIsVisible() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -365,8 +376,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_landscape_secondState_submitAnswer_submitButtonIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -380,8 +391,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_land_secondState_submitAnswer_clickSubmit_continueIsVisible() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -398,8 +409,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_secondState_submitInvalidAnswer_disablesSubmitAndShowsError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -415,8 +426,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_land_secondState_submitInvalidAnswer_disablesSubmitAndShowsError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -433,8 +444,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_secondState_invalidAnswer_submitAnswerIsNotEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -448,8 +459,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // Robolectric tests don't rotate like this to recreate activity + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_invalidAnswer_changeConfiguration_submitButtonIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -465,8 +476,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_secondState_invalidAnswer_updated_submitAnswerIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -483,8 +494,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_land_secondState_invalidAnswer_submitAnswerIsNotEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -498,8 +509,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_land_secondState_invalidAnswer_updated_submitAnswerIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -517,8 +528,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_secondState_submitWrongAnswer_contentDescriptionIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -539,8 +550,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_secondState_submitCorrectAnswer_contentDescriptionIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -561,8 +572,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_thirdState_hasEnabledSubmitButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -577,8 +588,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_changeConfiguration_thirdState_hasEnabledSubmitButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -595,8 +606,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_thirdState_submitWithoutAnswer_showsErrorMessage() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -615,8 +626,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_thirdState_selectAnswer_submitButtonIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -630,8 +641,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_thirdState_selectAnswer_clickSubmit_continueButtonIsVisible() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -648,8 +659,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_landscape_thirdState_selectAnswer_submitButtonIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -664,8 +675,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_land_thirdState_selectAnswer_clickSubmit_continueIsVisible() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -682,8 +693,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_fractionInput_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -694,8 +705,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_numericInput_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -710,8 +721,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_ratioInput_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -727,8 +738,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_textInput_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -745,8 +756,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_selectMultipleChoiceOption_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -779,8 +790,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_selectItemSelectionCheckbox_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -838,8 +849,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() typeNumericExpression("1+2") @@ -849,8 +860,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -863,8 +874,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -877,8 +888,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_differentSelectionInteractions_doesNotShareSavedInputState() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -943,8 +954,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_sameSelectionInteractions_doesNotShareSavedInputState() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -987,8 +998,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_textBasedInteractions_doesNotShareSavedInputState() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() typeNumericExpression("1+2") @@ -1002,8 +1013,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_thirdState_submitInvalidAnswer_submitButtonIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -1021,8 +1032,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_land_thirdState_submitInvalidAnswer_submitButtonIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -1040,8 +1051,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_thirdState_invalidAnswer_updated_submitAnswerIsEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -1059,8 +1070,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_firstState_previousAndNextButtonIsNotDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1070,8 +1081,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_submitWithoutArranging_showsErrorMessage() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() clickSubmitAnswerButton() @@ -1087,8 +1098,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_withGrouping_submitWithoutArranging_showsErrorMessage_dragItem_errorMessageIsReset() { // ktlint-disable max-line-length - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1119,8 +1130,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_groupingItemsEnablesSubmitButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() clickSubmitAnswerButton() @@ -1132,8 +1143,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() dragAndDropItem(fromPosition = 0, toPosition = 1) @@ -1151,8 +1162,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeItems_dragAndDrop_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() mergeDragAndDropItems(position = 0) @@ -1177,8 +1188,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_submitTimeError_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() onView(withId(R.id.submit_answer_button)).check(matches(isEnabled())) @@ -1191,8 +1202,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() mergeDragAndDropItems(position = 0) @@ -1209,8 +1220,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_withoutGrouping_submitWithoutArranging_showsErrorMessage_dragItem_errorMessageIsReset() { // ktlint-disable max-line-length - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -1250,8 +1261,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_worksCorrectly() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1269,8 +1280,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_invalidAnswer_correctItemCount() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1290,8 +1301,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_wrongAnswer_contentDescriptionIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1311,8 +1322,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_correctAnswer_contentDescriptionIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -1341,8 +1352,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_wrongAnswer_retainsLatestState() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -1379,8 +1390,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_wrongAnswer_unArrangedRetainState_causeSubmitTimeError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -1414,8 +1425,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_wrongAnswer_retainsLatestStateCount() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1435,8 +1446,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_wrongAnswer_retainsLatestStateText() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1462,8 +1473,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeUnlinkFirstTwoItems_wrongAnswer_retainsLatestState() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1485,8 +1496,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeItems_dragItem_wrongAnswer_retainsLatestState() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1506,8 +1517,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeItems_unArrangedRetainState_causeSubmitTimeError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1532,11 +1543,11 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_dragItem_worksCorrectly() { // Note to self: current setup allows the user to drag the view without issues (now that // event interception isn't a problem), however the view is going partly offscreen which // is triggering an infinite animation loop in ItemTouchHelper). - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1555,8 +1566,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_unlinkFirstItem_worksCorrectly() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_4, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1575,8 +1586,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_clickRegion6_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1595,8 +1606,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_submitTimeError_retainStateOnConfigurationChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1612,8 +1623,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_clickRegion6_submitButtonEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1628,8 +1639,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_clickRegion6_clickSubmit_receivesCorrectFeedback() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1649,8 +1660,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_submitButtonDisabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1664,8 +1675,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_defaultRegionClick_defRegionClicked_submitButtonDisabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1679,8 +1690,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_clickedRegion6_region6Clicked_submitButtonEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1695,8 +1706,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_clickedRegion6_region6Clicked_correctFeedback() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1716,8 +1727,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_clickedRegion6_region6Clicked_correctAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1737,8 +1748,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_clickedRegion6_region6Clicked_continueButtonIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1754,8 +1765,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. @Ignore("Flaky test") // TODO(#3171): Fix ImageRegion failing test cases. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadImageRegion_clickRegion6_clickedRegion5_clickRegion5_correctFeedback() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_13, shouldSavePartialProgress = false).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -1774,8 +1785,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_changeConfiguration_firstState_prevAndNextButtonIsNotDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1787,8 +1798,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_submitAnswer_clickContinueButton_previousButtonIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1799,8 +1810,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_changeConfig_submitAnswer_clickContinue_prevButtonIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -1812,8 +1823,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_submitAnswer_clickContinueThenPrevious_onlyNextButtonIsShown() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -1828,8 +1839,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_changeConfig_submit_clickContinueThenPrev_onlyNextButtonShown() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -1845,8 +1856,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_submitAnswer_clickContinueThenPrevThenNext_prevAndSubmitShown() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() clickContinueInteractionButton() @@ -1864,8 +1875,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_land_submit_clickContinueThenPrevThenNext_prevAndSubmitShown() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -1885,8 +1896,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_continueToEndExploration_hasReturnToTopicButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1902,8 +1913,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_changeConfiguration_continueToEnd_hasReturnToTopicButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -1920,8 +1931,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_continueToEndExploration_clickReturnToTopic_destroysActivity() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeExploration() @@ -1935,8 +1946,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_changeConfig_continueToEnd_clickReturnToTopic_destroysActivity() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() rotateToLandscape() @@ -1950,8 +1961,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testContentCard_forPrototypeExploration_withCustomOppiaTags_displaysParsedHtml() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1962,8 +1973,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testContentCard_forPrototypeExploration_changeConfig_withCustomTags_displaysParsedHtml() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -1974,8 +1985,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_inputRatio_correctAnswerSubmitted_correctAnswerIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -1994,8 +2005,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_forHintsAndSolution_incorrectInputTwice_hintBulbContainerIsVisible() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(FRACTIONS_EXPLORATION_ID_1, shouldSavePartialProgress = false).use { startPlayingExploration() selectMultipleChoiceOption( @@ -2017,8 +2028,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_forMisconception_showsLinkTextForConceptCard() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(FRACTIONS_EXPLORATION_ID_1, shouldSavePartialProgress = false).use { startPlayingExploration() selectMultipleChoiceOption( @@ -2042,8 +2053,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_landscape_forMisconception_showsLinkTextForConceptCard() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(FRACTIONS_EXPLORATION_ID_1, shouldSavePartialProgress = false).use { rotateToLandscape() startPlayingExploration() @@ -2068,8 +2079,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_forMisconception_clickLinkText_opensConceptCard() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(FRACTIONS_EXPLORATION_ID_1, shouldSavePartialProgress = false).use { startPlayingExploration() selectMultipleChoiceOption( @@ -2092,8 +2103,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_landscape_forMisconception_clickLinkText_opensConceptCard() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(FRACTIONS_EXPLORATION_ID_1, shouldSavePartialProgress = false).use { rotateToLandscape() startPlayingExploration() @@ -2117,8 +2128,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_initialStateIsContinueInteraction() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -2129,8 +2140,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_continueInteraction_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -2144,8 +2155,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_fractionInteraction_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2160,8 +2171,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_multipleChoiceInteraction_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2177,8 +2188,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_radioItemSelection_hasCorrectAccessibilityAttributes() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2194,8 +2205,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_radioItemSelection_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2212,8 +2223,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_checkboxItemSelection_hasCorrectAccessibilityAttributes() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2228,8 +2239,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_checkboxItemSelection_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2247,8 +2258,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_numericInputInteraction_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2267,8 +2278,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_numericInputInteraction_hasCorrectHint() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2285,8 +2296,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_ratioInputInteraction_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2306,8 +2317,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_textInputInteraction_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2329,8 +2340,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_dragAndDropNoGrouping_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2353,8 +2364,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_dragAndDropWithGrouping_canSuccessfullySubmitAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -2376,8 +2387,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_fractionInput_textViewHasTextInputType() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { scenario -> startPlayingExploration() @@ -2394,8 +2405,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_ratioInput_textViewHasTextInputType() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { scenario -> startPlayingExploration() playThroughPrototypeState1() @@ -2418,8 +2429,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_loadExp_saveProg_continueToEndExp_clickReturnToTopic_partialProgDeleted() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeExploration() @@ -2437,8 +2448,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_englishContentLang_content_isInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2450,8 +2461,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabicContentLang_content_isInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2463,8 +2474,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabicContentLang_thenEnglish_content_isInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2477,8 +2488,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_continueInteraction_buttonIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2490,8 +2501,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_continueInteraction_buttonIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2503,8 +2514,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_fractionInput_placeholderIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2518,8 +2529,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_fractionInput_submitAnswer_answerMatchesSubmission() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2536,8 +2547,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_fractionInput_placeholderIsInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2551,8 +2562,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_fractionInput_submitAnswer_answerMatchesSubmission() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2570,8 +2581,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_englishContentLang_feedback_isInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2588,8 +2599,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabicContentLang_feedback_isInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2607,8 +2618,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabicContentLang_thenEnglish_feedback_isInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2626,8 +2637,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_multipleChoice_optionsAreInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2648,8 +2659,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_multipleChoice_submittedAnswer_answerIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2666,8 +2677,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_multipleChoice_optionsAreInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2689,8 +2700,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_multipleChoice_submittedAnswer_answerIsInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2708,8 +2719,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_multipleChoice_submittedAnswer_switchToEnglish_answerIsInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2728,8 +2739,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_itemSelection_optionsAreInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2752,8 +2763,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_itemSelection_submittedAnswer_answerIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() @@ -2775,8 +2786,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_itemSelection_optionsAreInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2800,8 +2811,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_itemSelection_submittedAnswer_answerIsInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2823,8 +2834,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_itemSelection_submittedAnswer_switchToEnglish_answerIsInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2847,8 +2858,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_numericInput_submitAnswer_answerMatchesSubmission() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2869,8 +2880,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_numericInput_submitAnswer_answerMatchesSubmission() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2891,8 +2902,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_ratioInput_placeholderIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2910,8 +2921,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_ratioInput_submitAnswer_answerMatchesSubmission() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2933,8 +2944,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_ratioInput_placeholderIsInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2953,8 +2964,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_ratioInput_submitAnswer_answerMatchesSubmission() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2976,8 +2987,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_textInput_placeholderIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -2996,8 +3007,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_textInput_submitAnswer_answerMatchesSubmission() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3020,8 +3031,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_textInput_placeholderIsInArabic() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3041,8 +3052,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_textInput_submitAnswer_answerMatchesSubmission() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3065,8 +3076,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_arabic_textInput_submitAnswer_switchToEnglish_answerDoesNotChange() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3090,8 +3101,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_dragAndDrop_optionsAreInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3119,8 +3130,8 @@ class StateFragmentTest { // TODO(#1612): Enable for Robolectric. @Test @RunOn(TestPlatform.ESPRESSO, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_english_dragAndDrop_submittedAnswer_answerIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3150,8 +3161,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ESPRESSO, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_portuguese_dragAndDrop_optionsAreInPortuguese() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3179,8 +3190,8 @@ class StateFragmentTest { // TODO(#1612): Enable for Robolectric. @Test @RunOn(TestPlatform.ESPRESSO, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_portuguese_dragAndDrop_submittedAnswer_answerIsInPortuguese() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3210,8 +3221,8 @@ class StateFragmentTest { // TODO(#1612): Enable for Robolectric. @Test @RunOn(TestPlatform.ESPRESSO, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_portuguese_dragAndDrop_submittedAnswer_switchToEnglish_answerIsInPt() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = true).use { startPlayingExploration() playThroughPrototypeState1() @@ -3243,8 +3254,8 @@ class StateFragmentTest { // TODO(#1612): Enable for Robolectric. @Test @RunOn(TestPlatform.ESPRESSO, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_playWholeLesson_inArabic_hasReturnToTopicButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3260,8 +3271,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_studyOff_inEnglish_doesNotHaveSwitchToSwahiliButton() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3273,8 +3284,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_studyOn_inEnglish_lessonWithoutSwahili_doesNotHaveSwitchToSwahiliButton() { - setUpTestWithLanguageSwitchingFeatureOn() launchForExploration(FRACTIONS_EXPLORATION_ID_1, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3287,8 +3298,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_studyOn_inEnglish_notEnabledForProfile_doesNotHaveSwitchToSwahiliButton() { - setUpTestWithLanguageSwitchingFeatureOn() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3301,8 +3312,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_studyOn_enabledForProfile_inEnglish_hasSwitchToSwahiliButton() { - setUpTestWithLanguageSwitchingFeatureOn() enableInLessonLanguageSwitching() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3318,8 +3329,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_studyOn_enabledForProfile_inSwahili_hasSwitchToEnglishButton() { - setUpTestWithLanguageSwitchingFeatureOn() enableInLessonLanguageSwitching() updateContentLanguage(profileId, OppiaLanguage.SWAHILI) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { @@ -3336,8 +3347,8 @@ class StateFragmentTest { // TODO(#1612): Enable for Robolectric. @Test @RunOn(TestPlatform.ESPRESSO, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_inEnglish_clickSwitchToSwahili_contentIsInSwahili() { - setUpTestWithLanguageSwitchingFeatureOn() enableInLessonLanguageSwitching() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3355,8 +3366,8 @@ class StateFragmentTest { // TODO(#1612): Enable for Robolectric. @Test @RunOn(TestPlatform.ESPRESSO, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_inSwahili_clickSwitchToEnglish_contentIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOn() enableInLessonLanguageSwitching() updateContentLanguage(profileId, OppiaLanguage.SWAHILI) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { @@ -3375,8 +3386,8 @@ class StateFragmentTest { // TODO(#1612): Enable for Robolectric. @Test @RunOn(TestPlatform.ESPRESSO, buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_inEnglish_clickSwitchToSwahili_thenBackToEnglish_contentIsInEnglish() { - setUpTestWithLanguageSwitchingFeatureOn() enableInLessonLanguageSwitching() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3396,8 +3407,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_inEnglish_clickSwitchToSwahili_logsSwitchLanguageEvent() { - setUpTestWithLanguageSwitchingFeatureOn() enableInLessonLanguageSwitching() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { @@ -3418,8 +3429,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_inSwahili_clickSwitchToEnglish_logsSwitchLanguageEvent() { - setUpTestWithLanguageSwitchingFeatureOn() enableInLessonLanguageSwitching() updateContentLanguage(profileId, OppiaLanguage.SWAHILI) launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { @@ -3439,8 +3450,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_matchesExactly_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3455,8 +3466,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_matchesExactly_diffOrder_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3471,8 +3482,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_matchesExactly_diffElems_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3487,8 +3498,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_matchesExactly_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3503,8 +3514,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_matchesUpTo_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughMathInteractionExplorationState1() @@ -3520,8 +3531,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_matchesUpTo_diffOrder_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughMathInteractionExplorationState1() @@ -3538,8 +3549,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_matchesUpTo_diffElems_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughMathInteractionExplorationState1() @@ -3555,8 +3566,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_matchesUpTo_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughMathInteractionExplorationState1() @@ -3572,8 +3583,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_equivalence_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState2() @@ -3589,8 +3600,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_equivalence_diffOrder_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState2() @@ -3607,8 +3618,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_equivalence_diffElems_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState2() @@ -3625,8 +3636,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_equivalence_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState2() @@ -3642,8 +3653,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_answerWithDivideByZero_displaysError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3655,8 +3666,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_answerWithVariable_displaysError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3672,8 +3683,9 @@ class StateFragmentTest { } @Test + @OverrideBoolParameter(PlatformParameter.CACHE_LATEX_RENDERING, true) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_validAns_submissionDisplaysLatex() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { scenario -> startPlayingExploration() playThroughMathInteractionExplorationState1() @@ -3696,8 +3708,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_validAns_divAsFrac_submissionDisplaysLatex() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { scenario -> startPlayingExploration() @@ -3721,8 +3733,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_validAns_english_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughMathInteractionExplorationState1() @@ -3739,8 +3751,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_validAns_divAsFrac_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3756,8 +3768,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_numericExp_validAns_arabic_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -3775,8 +3787,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_matchesExactly_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -3792,8 +3804,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_matchesExactly_diffOrder_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -3809,8 +3821,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_matchesExactly_diffElems_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -3826,8 +3838,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_matchesExactly_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -3843,8 +3855,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_matchesUpTo_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState4() @@ -3860,8 +3872,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_matchesUpTo_diffOrder_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState4() @@ -3878,8 +3890,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_matchesUpTo_diffElems_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState4() @@ -3895,8 +3907,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_matchesUpTo_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState4() @@ -3912,8 +3924,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_equivalence_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState5() @@ -3929,8 +3941,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_equivalence_diffOrder_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState5() @@ -3947,8 +3959,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_equivalence_diffElems_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState5() @@ -3965,8 +3977,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_equivalence_diffElems_andVals_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState5() @@ -3983,8 +3995,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_equivalence_diffOperations_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState5() @@ -4002,8 +4014,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_equivalence_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState5() @@ -4019,8 +4031,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_answerWithVariablePower_displaysError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -4036,8 +4048,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_answerWithUnknownVars_displaysError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -4051,8 +4063,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_validAns_submissionDisplaysLatex() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { scenario -> startPlayingExploration() playUpThroughMathInteractionExplorationState4() @@ -4075,8 +4087,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_validAns_divAsFrac_submissionDisplaysLatex() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { scenario -> startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -4101,8 +4113,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_validAns_english_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState4() @@ -4123,8 +4135,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_validAns_divAsFrac_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState3() @@ -4146,8 +4158,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_algExp_validAns_arabic_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -4165,8 +4177,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesExactly_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4182,8 +4194,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesExactly_flipped_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4200,8 +4212,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesExactly_diffOrder_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4217,8 +4229,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesExactly_diffElems_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4234,8 +4246,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesExactly_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4251,8 +4263,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesUpTo_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState7() @@ -4268,8 +4280,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesUpTo_flipped_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState7() @@ -4286,8 +4298,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesUpTo_diffOrder_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState7() @@ -4304,8 +4316,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesUpTo_diffElems_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState7() @@ -4321,8 +4333,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_matchesUpTo_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState7() @@ -4338,8 +4350,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_canSubmitCorrectAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4357,8 +4369,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_flipped_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4377,8 +4389,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_diffOrder_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4397,8 +4409,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_diffElems_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4417,8 +4429,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_diffElems_andVals_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4435,8 +4447,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_diffOperations_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4456,8 +4468,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_rearranged_answerIsCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4476,8 +4488,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_multiple_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4494,8 +4506,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_equivalence_diffValue_answerIsWrong() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState8() @@ -4511,8 +4523,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_answerWithDoubleMult_displaysError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4525,8 +4537,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_missingEquals_displaysError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4540,8 +4552,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_answerWithUnknownVars_displaysError() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4557,8 +4569,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_validAns_submissionDisplaysLatex() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { scenario -> startPlayingExploration() playUpThroughMathInteractionExplorationState7() @@ -4581,8 +4593,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_validAns_divAsFrac_submissionDisplaysLatex() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { scenario -> startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4607,8 +4619,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_validAns_english_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState7() @@ -4630,8 +4642,8 @@ class StateFragmentTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_validAns_divAsFrac_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() playUpThroughMathInteractionExplorationState6() @@ -4655,8 +4667,8 @@ class StateFragmentTest { // TODO(#3858): Enable for Espresso. @Test @RunOn(TestPlatform.ROBOLECTRIC, buildEnvironments = [BuildEnvironment.BAZEL]) + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_mathInteractions_mathEq_validAns_arabic_submissionHasA11yAnswer() { - setUpTestWithLanguageSwitchingFeatureOff() updateContentLanguage(profileId, OppiaLanguage.ARABIC) launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -4677,8 +4689,8 @@ class StateFragmentTest { // answers submit normally & with no special behaviors. @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_clickContinue_returnToState_doesNotHaveFeedbackBox() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4692,8 +4704,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_clickContinue_finishNextState_returnToContinue_doesNotHaveFeedbackBox() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4710,8 +4722,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_noRadioItemSelected_defaultSelectionTextIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4726,8 +4738,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_oneRadioItemSelected_selectionTextIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4744,8 +4756,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_twoRadioItemSelected_selectionTextIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4763,8 +4775,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_maxRadioItemSelected_selectionTextIsDisplayed() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4783,8 +4795,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_maxRadioItemSelected_nonSelectedCheckboxesAreDisabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4824,8 +4836,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_maxItemSelected_deselectingReturnsYouMaySelectMoreChoices() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4845,8 +4857,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_someItemSelected_deselectingReturnsPleaseSelectAllCorrect() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4866,8 +4878,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_notSelectingMaxRadioItem_return_allOtherCheckBoxesEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4914,8 +4926,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_interactions_SelectingMaxItemAndOneBelow_returnNoOtherCheckBoxesEnabled() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { startPlayingExploration() playThroughPrototypeState1() @@ -4957,8 +4969,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testFinishChapter_lateNight_isPastGracePeriod_minimumAggregateTimeMet_noSurveyPopup() { - setUpTestWithSurveyFeatureOn() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(LATE_NIGHT_UTC_TIMESTAMP_MILLIS) @@ -4987,8 +4999,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testFinishChapter_earlyMorning_isPastGracePeriod_minimumAggregateTimeMet_noSurveyPopup() { - setUpTestWithSurveyFeatureOn() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(EARLY_MORNING_UTC_TIMESTAMP_MILLIS) @@ -5017,8 +5029,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testFinishChapter_midMorning_isPastGracePeriod_minimumAggregateTimeMet_surveyPopupShown() { - setUpTestWithSurveyFeatureOn() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(MID_MORNING_UTC_TIMESTAMP_MILLIS) @@ -5045,8 +5057,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testFinishChapter_afternoon_isPastGracePeriod_minimumAggregateTimeMet_surveyPopupShown() { - setUpTestWithSurveyFeatureOn() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(AFTERNOON_UTC_TIMESTAMP_MILLIS) @@ -5073,8 +5085,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testFinishChapter_evening_isPastGracePeriod_minimumAggregateTimeMet_surveyPopupShown() { - setUpTestWithSurveyFeatureOn() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(EVENING_UTC_TIMESTAMP_MILLIS) @@ -5101,8 +5113,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testFinishChapter_allGatingConditionsMet_surveyDismissed_popupDoesNotShowAgain() { - setUpTestWithSurveyFeatureOn() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(EVENING_UTC_TIMESTAMP_MILLIS) @@ -5135,6 +5147,7 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @DisableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testFinishChapter_surveyFeatureOff_allGatingConditionsMet_noSurveyPopup() { // Survey Gating conditions are: isPastGracePeriod, has achieved minimum aggregate exploration // time of 5min in a topic, and is within the hours of 9am and 10pm in the user's local time. @@ -5143,7 +5156,6 @@ class StateFragmentTest { // more than the grace period days in the past, so no need to explicitly define // surveyLastShownTimestamp for computing the grace period. - setUpTestWithSurveyFeatureOff() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(AFTERNOON_UTC_TIMESTAMP_MILLIS) @@ -5172,8 +5184,8 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric. + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testFinishChapter_updateGatingProvider_surveyGatingCriteriaMetEarlier_doesntUpdateUI() { - setUpTestWithSurveyFeatureOn() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(AFTERNOON_UTC_TIMESTAMP_MILLIS) @@ -5208,8 +5220,8 @@ class StateFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testStateFragment_contentDescription_replaceUnderscoresWithBlank() { - setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(RATIOS_EXPLORATION_ID_0, shouldSavePartialProgress = false).use { startPlayingExploration() @@ -5851,26 +5863,6 @@ class StateFragmentTest { return onView(isRoot()).perform(waitForMatch(viewMatcher, 30000L)) } - private fun setUpTestWithLanguageSwitchingFeatureOn() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(true) - setUpTest() - } - - private fun setUpTestWithLanguageSwitchingFeatureOff() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(false) - setUpTest() - } - - private fun setUpTestWithSurveyFeatureOn() { - TestPlatformParameterModule.forceEnableNpsSurvey(true) - setUpTest() - } - - private fun setUpTestWithSurveyFeatureOff() { - TestPlatformParameterModule.forceEnableNpsSurvey(false) - setUpTest() - } - private fun setUpTest() { Intents.init() setUpTestApplicationComponent() @@ -6056,7 +6048,7 @@ class StateFragmentTest { @Singleton @Component( modules = [ - TestModule::class, RobolectricModule::class, TestPlatformParameterModule::class, + TestModule::class, RobolectricModule::class, PlatformParameterModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, 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 ff1e8c493c5..ead7fdbf75f 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 @@ -78,6 +78,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -115,6 +116,9 @@ import kotlin.reflect.KClass qualifiers = "port-xxhdpi" ) class PoliciesActivityTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 3db8bca24cd..ec6315f8610 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 @@ -90,6 +90,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -155,6 +156,9 @@ class PoliciesFragmentTest { @Inject lateinit var appLanguageLocaleHandler: AppLanguageLocaleHandler + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule var activityScenarioRule: ActivityScenarioRule = ActivityScenarioRule( 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 b9aa2114cd6..e306fde5f11 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 @@ -92,6 +92,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule @@ -103,7 +104,6 @@ import org.oppia.android.testing.espresso.TextInputAction.Companion.hasHelperTex 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -1783,7 +1783,7 @@ class AddProfileActivityTest { @Component( modules = [ RobolectricModule::class, TestDispatcherModule::class, ApplicationModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 198b2890f6d..4f67a10fa13 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 @@ -83,9 +83,12 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction @@ -93,7 +96,6 @@ 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.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -114,6 +116,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.profile.PROFILE_ID_INTENT_DECORATOR import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -215,8 +218,8 @@ class PinPasswordActivityTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testPinPassword_withAdmin_inputCorrectPin_opensHomeActivity() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) ActivityScenario.launch( PinPasswordActivity.createPinPasswordActivityIntent( context = context, @@ -233,8 +236,8 @@ class PinPasswordActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testPinPassword_enableClassrooms_withAdmin_inputCorrectPin_opensClassroomListActivity() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) ActivityScenario.launch( PinPasswordActivity.createPinPasswordActivityIntent( context = context, @@ -252,8 +255,8 @@ class PinPasswordActivityTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testPinPassword_withUser_inputCorrectPin_opensHomeActivity() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) ActivityScenario.launch( PinPasswordActivity.createPinPasswordActivityIntent( context = context, @@ -270,8 +273,8 @@ class PinPasswordActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testPinPassword_enableClassrooms_withUser_inputCorrectPin_opensClassroomListActivity() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) ActivityScenario.launch( PinPasswordActivity.createPinPasswordActivityIntent( context = context, @@ -540,8 +543,8 @@ class PinPasswordActivityTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testPinPassword_withUser_forgot_inputAdminPinAndNewPin_opensHomeActivity() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) ActivityScenario.launch( PinPasswordActivity.createPinPasswordActivityIntent( context = context, @@ -1237,7 +1240,7 @@ class PinPasswordActivityTest { @Singleton @Component( modules = [ - RobolectricModule::class, TestPlatformParameterModule::class, TestDispatcherModule::class, + RobolectricModule::class, PlatformParameterModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 c851c309879..36fa2ceff83 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 @@ -82,17 +82,19 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -111,6 +113,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId import org.oppia.android.util.profile.PROFILE_ID_INTENT_DECORATOR import org.robolectric.annotation.Config @@ -158,7 +161,6 @@ class ProfileChooserFragmentTest { @After fun tearDown() { testCoroutineDispatchers.unregisterIdlingResource() - TestPlatformParameterModule.reset() Intents.release() } @@ -328,8 +330,8 @@ class ProfileChooserFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileChooserFragment_onboardingV1_clickAdminProfile_checkOpensPinPasswordActivity() { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(false) profileTestHelper.initializeProfiles(autoLogIn = false) launch(ProfileChooserActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -344,8 +346,8 @@ class ProfileChooserFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testMigrateProfiles_onboardingV2_clickAdminProfile_checkOpensPinPasswordActivity() { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(true) profileTestHelper.initializeProfiles(autoLogIn = true) val adminProfileId = ProfileId.newBuilder().setInternalId(0).build() profileTestHelper.updateProfileType( @@ -366,9 +368,9 @@ class ProfileChooserFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testMigrateProfiles_onboardingV2_clickLearnerWithPin_checkOpensIntroActivity() { profileTestHelper.initializeProfiles(autoLogIn = true) - TestPlatformParameterModule.forceEnableOnboardingFlowV2(true) launch(ProfileChooserActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -383,9 +385,9 @@ class ProfileChooserFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testMigrateProfiles_onboardingV2_clickAdminWithoutPin_checkOpensIntroActivity() { profileTestHelper.addOnlyAdminProfileWithoutPin() - TestPlatformParameterModule.forceEnableOnboardingFlowV2(true) launch(ProfileChooserActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -400,6 +402,7 @@ class ProfileChooserFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testMigrateProfiles_onboardingV2_clickLearnerWithoutPin_checkOpensIntroActivity() { profileTestHelper.addOnlyAdminProfile() profileManagementController.addProfile( @@ -410,7 +413,6 @@ class ProfileChooserFragmentTest { colorRgb = -10710042, isAdmin = false ) - TestPlatformParameterModule.forceEnableOnboardingFlowV2(true) launch(ProfileChooserActivity::class.java).use { testCoroutineDispatchers.runCurrent() @@ -572,8 +574,8 @@ class ProfileChooserFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testProfileChooserFragment_enableClassrooms_clickProfile_opensClassroomListActivity() { - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) profileManagementController.addProfile( name = "Admin", pin = "", @@ -628,7 +630,7 @@ class ProfileChooserFragmentTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 326627850b7..90e0e599b9b 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 @@ -82,17 +82,19 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -113,6 +115,7 @@ import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -152,7 +155,6 @@ class ProfileEditFragmentTest { setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() - TestPlatformParameterModule.reset() } @After @@ -217,8 +219,8 @@ class ProfileEditFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_startWithUserHasDownloadAccess_downloadsDisabled_switchIsNotDisplayed() { - TestPlatformParameterModule.forceEnableDownloadsSupport(false) profileManagementController .addProfile( name = "James", @@ -234,16 +236,16 @@ class ProfileEditFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_userDoesNotHaveDownloadAccess_downloadDisabled_switchIsNotDisplayed() { - TestPlatformParameterModule.forceEnableDownloadsSupport(false) launchFragmentTestActivity(internalProfileId = 0).use { onView(withId(R.id.profile_edit_allow_download_container)).check(matches(not(isDisplayed()))) } } @Test + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_startWithUserHasDownloadAccess_downloadsEnabled_checkSwitchIsChecked() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) profileManagementController .addProfile( name = "James", @@ -260,8 +262,8 @@ class ProfileEditFragmentTest { @Test @Config(qualifiers = "land") + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_configChange_userHasDownloadAccess_downloadsEnabled_checkSwitchIsChecked() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) val addProfileProvider = profileManagementController.addProfile( name = "James", @@ -279,8 +281,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_userHasDownloadAccess_downloadsEnabled_clickAllowDownloads_checkChanged() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) profileManagementController .addProfile( name = "James", @@ -298,8 +300,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_userDoesNotHaveDownloadAccess_downloadsEnabled_switchIsNotClickable() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) profileManagementController .addProfile( name = "James", @@ -315,8 +317,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_userHasDownloadAccess_downloadsEnabled_switchContainerIsFocusable() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) profileManagementController .addProfile( name = "James", @@ -332,8 +334,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_startWithUserHasDownloadAccess_downloadsEnabled_switchContainerIsDisplayed() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) profileManagementController .addProfile( name = "James", @@ -349,16 +351,16 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT) fun testProfileEdit_userDoesNotHaveDownloadAccess_downloadsEnabled_switchIsNotDisplayed() { - TestPlatformParameterModule.forceEnableDownloadsSupport(true) launchFragmentTestActivity(internalProfileId = 0).use { onView(withId(R.id.profile_edit_allow_download_container)).check(matches(not(isDisplayed()))) } } @Test + @DisableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testProfileEdit_studyOff_doesNotHaveMarkChaptersCompletedButton() { - TestPlatformParameterModule.forceEnableLearnerStudyAnalytics(false) launchFragmentTestActivity(internalProfileId = 0).use { onView(withId(R.id.profile_mark_chapters_for_completion_button)) .check(matches(not(isDisplayed()))) @@ -366,8 +368,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testProfileEdit_studyOn_hasMarkChaptersCompletedButton() { - TestPlatformParameterModule.forceEnableLearnerStudyAnalytics(true) launchFragmentTestActivity(internalProfileId = 0).use { onView(withId(R.id.profile_mark_chapters_for_completion_button)).check(matches(isDisplayed())) } @@ -375,8 +377,8 @@ class ProfileEditFragmentTest { @Test @Config(qualifiers = "land") + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testProfileEdit_studyOn_landscape_hasMarkChaptersCompletedButton() { - TestPlatformParameterModule.forceEnableLearnerStudyAnalytics(true) launchFragmentTestActivity(internalProfileId = 0).use { onView(isRoot()).perform(orientationLandscape()) onView(withId(R.id.profile_mark_chapters_for_completion_button)).check(matches(isDisplayed())) @@ -384,8 +386,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testProfileEdit_studyOn_clickMarkChapsCompleted_opensMarkCompleteActivityForProfile() { - TestPlatformParameterModule.forceEnableLearnerStudyAnalytics(true) launchFragmentTestActivity(internalProfileId = 0).use { onView(withId(R.id.profile_mark_chapters_for_completion_button)).perform(click()) @@ -402,8 +404,8 @@ class ProfileEditFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testProfileEdit_featureOff_doesNotHaveEnableQuickSwitchingSwitch() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(false) // Without the study feature enabled, the switch should not be visible. launchFragmentTestActivity(internalProfileId = 0).use { @@ -413,8 +415,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testProfileEdit_featureOn_hasEnableQuickSwitchingSwitch() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(true) launchFragmentTestActivity(internalProfileId = 0).use { onView(withId(R.id.profile_edit_enable_in_lesson_language_switching_container)) @@ -424,8 +426,8 @@ class ProfileEditFragmentTest { @Test @Config(qualifiers = "land") + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testProfileEdit_featureOn_landscape_hasEnableQuickSwitchingSwitch() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(true) launchFragmentTestActivity(internalProfileId = 0).use { onView(isRoot()).perform(orientationLandscape()) @@ -440,8 +442,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testProfileEdit_featureOn_doNotHaveSwitchingPermission_enableLanguageSwitchingIsOff() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(true) // Without the permission to switch languages, the setting should be off by default. launchFragmentTestActivity(internalProfileId = 0).use { @@ -451,8 +453,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testProfileEdit_featureOn_hasSwitchingPermission_enableLanguageSwitchingIsOn() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(true) val updateLangProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -469,8 +471,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testProfileEdit_featureOn_doNotClickEnableLanguageSwitching_doesNotHaveSwitchingPermission() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(true) // Open the UI, but don't interact with it. launchFragmentTestActivity(internalProfileId = 0).use {} @@ -485,8 +487,8 @@ class ProfileEditFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON) fun testProfileEdit_studyOn_clickEnableLanguageSwitching_hasSwitchingPermission() { - TestPlatformParameterModule.forceEnableFastLanguageSwitchingInLesson(true) // Enable language switching in the UI. launchFragmentTestActivity(internalProfileId = 0).use { @@ -546,7 +548,7 @@ class ProfileEditFragmentTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, diff --git a/app/src/sharedTest/java/org/oppia/android/app/splash/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/splash/BUILD.bazel index 304619542b8..be9324b4937 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/splash/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/splash/BUILD.bazel @@ -29,7 +29,6 @@ app_test( "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_auto_android_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:coroutine_executor_service", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", 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 12e51153159..500ac4a1c0d 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 @@ -94,10 +94,13 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn import org.oppia.android.testing.TestLogReportingModule @@ -109,7 +112,6 @@ import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedAutoAndroidTestRunner -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -129,6 +131,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.profile.PROFILE_ID_INTENT_DECORATOR import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -188,7 +191,6 @@ class SplashActivityTest { @After fun tearDown() { - TestPlatformParameterModule.reset() testCoroutineDispatchers.unregisterIdlingResource() Intents.release() } @@ -1061,17 +1063,18 @@ class SplashActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testSplashActivity_initialOpen_onboardingV2Enabled_routesToOnboardingActivity() { - initializeTestApplication(onboardingV2Enabled = true) - + initializeTestApplication() launchSplashActivityPartially { intended(hasComponent(OnboardingActivity::class.java.name)) } } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testSplashActivity_onboardingV2Enabled_profilePartiallyOnboarded_routesToIntroActivity() { - initializeTestApplication(onboardingV2Enabled = true) + initializeTestApplication() profileTestHelper.addOnlyAdminProfileWithoutPin() val profileId = ProfileId.newBuilder().setInternalId(0).build() profileTestHelper.updateProfileType(profileId, ProfileType.SOLE_LEARNER) @@ -1088,10 +1091,11 @@ class SplashActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) + @DisableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testSplashActivity_onboardingV2Enabled_onboardedSoleLearnerProfile_routesToHomeActivity() { simulateAppAlreadyOnboarded() - TestPlatformParameterModule.forceEnableMultipleClassrooms(false) - initializeTestApplication(onboardingV2Enabled = true) + initializeTestApplication() profileTestHelper.addOnlyAdminProfileWithoutPin() testCoroutineDispatchers.runCurrent() @@ -1114,10 +1118,11 @@ class SplashActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) + @EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) fun testSplashActivity_onboardingV2_onboardedSoleLearnerProfile_routesToClassroomListActivity() { simulateAppAlreadyOnboarded() - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) - initializeTestApplication(onboardingV2Enabled = true) + initializeTestApplication() testCoroutineDispatchers.unregisterIdlingResource() profileTestHelper.addOnlyAdminProfileWithoutPin() testCoroutineDispatchers.runCurrent() @@ -1141,9 +1146,10 @@ class SplashActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testSplashActivity_onboardingV2_onboardedAdminProfile_routesToProfileChooserActivity() { simulateAppAlreadyOnboarded() - initializeTestApplication(onboardingV2Enabled = true) + initializeTestApplication() profileTestHelper.addOnlyAdminProfile() launchSplashActivityPartially { @@ -1152,9 +1158,10 @@ class SplashActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testActivity_onboardingV2Enabled_existingMultipleProfiles_routesToProfileChooserActivity() { simulateAppAlreadyOnboarded() - initializeTestApplication(onboardingV2Enabled = true) + initializeTestApplication() profileTestHelper.addMoreProfiles(5) launchSplashActivityPartially { @@ -1227,9 +1234,8 @@ class SplashActivityTest { simulateAppAlreadyOnboarded() } - private fun initializeTestApplication(onboardingV2Enabled: Boolean = false) { + private fun initializeTestApplication() { ApplicationProvider.getApplicationContext().inject(this) - TestPlatformParameterModule.forceEnableOnboardingFlowV2(onboardingV2Enabled) testCoroutineDispatchers.registerIdlingResource() setAutoAppExpirationEnabled(enabled = false) // Default to disabled. } @@ -1317,7 +1323,7 @@ class SplashActivityTest { @Component( modules = [ TestModule::class, RobolectricModule::class, - TestDispatcherModule::class, ApplicationModule::class, TestPlatformParameterModule::class, + TestDispatcherModule::class, ApplicationModule::class, PlatformParameterModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 0609053aeec..84b3fc00eff 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 @@ -69,13 +69,16 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag +import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.threading.TestDispatcherModule @@ -93,6 +96,7 @@ import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -110,6 +114,9 @@ class SpotlightFragmentTest { @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @@ -140,8 +147,8 @@ class SpotlightFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testSpotlightFragment_disableSpotlights_requestSpotlight_shouldNotShowSpotlight() { - TestPlatformParameterModule.forceEnableSpotlightUi(false) launch( createSpotlightFragmentTestActivity(context) ).use { @@ -162,8 +169,8 @@ class SpotlightFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testSpotlightFragment_requestSpotlight_shouldShowSpotlight() { - TestPlatformParameterModule.forceEnableSpotlightUi(true) launch( createSpotlightFragmentTestActivity(context) ).use { @@ -184,8 +191,8 @@ class SpotlightFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testSpotlightFragment_requestDelayedSpotlight_shouldShowSpotlight() { - TestPlatformParameterModule.forceEnableSpotlightUi(true) launch(createSpotlightFragmentTestActivity(context)).use { testCoroutineDispatchers.runCurrent() it.onActivity { activity -> @@ -206,8 +213,8 @@ class SpotlightFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testSpotlightFragment_markSpotlightSeen_checkSpotlightIsNotShowAgain() { - TestPlatformParameterModule.forceEnableSpotlightUi(true) launch(createSpotlightFragmentTestActivity(context)).use { it.onActivity { activity -> val spotlightTarget = SpotlightTarget( @@ -242,8 +249,8 @@ class SpotlightFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testSpotlightFragment_exitSpotlightWithoutClickingDone_checkSpotlightIsShowAgain() { - TestPlatformParameterModule.forceEnableSpotlightUi(true) launch(createSpotlightFragmentTestActivity(context)).use { it.onActivity { activity -> val spotlightTarget = SpotlightTarget( @@ -277,8 +284,8 @@ class SpotlightFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testSpotlightQueuing_requestTwoSpotlights_checkFirstSpotlightShown() { - TestPlatformParameterModule.forceEnableSpotlightUi(true) launch( createSpotlightFragmentTestActivity(context) ).use { @@ -308,8 +315,8 @@ class SpotlightFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testSpotlightQueuing_requestTwoSpotlights_pressDone_checkSecondSpotlightShown() { - TestPlatformParameterModule.forceEnableSpotlightUi(true) launch( createSpotlightFragmentTestActivity(context) ).use { @@ -341,8 +348,8 @@ class SpotlightFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) fun testFragment_fragmentLoaded_verifyCorrectArgumentsPassed() { - TestPlatformParameterModule.forceEnableSpotlightUi(true) launch( createSpotlightFragmentTestActivity(context) ).use { scenario -> @@ -368,7 +375,7 @@ class SpotlightFragmentTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 e2258bdc5d6..90cceeb66e1 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 @@ -59,6 +59,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_2 @@ -68,7 +69,6 @@ import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -169,7 +169,7 @@ class SurveyActivityTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 358679a2b35..9e127f20557 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 @@ -81,6 +81,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.survey.SurveyController @@ -93,7 +94,6 @@ 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -623,7 +623,7 @@ class SurveyFragmentTest { @Singleton @Component( modules = [ - TestPlatformParameterModule::class, RobolectricModule::class, + PlatformParameterModule::class, RobolectricModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 3585996ccf3..4f97e0ddddc 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 @@ -66,14 +66,15 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -92,6 +93,7 @@ import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -105,6 +107,7 @@ import javax.inject.Singleton application = TopicTestActivityForStoryTest.TestApplication::class, qualifiers = "port-xxhdpi" ) +@EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) class TopicTestActivityForStoryTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -120,7 +123,6 @@ class TopicTestActivityForStoryTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() } @@ -189,7 +191,7 @@ class TopicTestActivityForStoryTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 38a5fe20e2f..7cc2d304857 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 @@ -74,19 +74,20 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.spotlight.SpotlightStateController import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0 import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn 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 import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -105,6 +106,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.profile.PROFILE_ID_INTENT_DECORATOR import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -168,8 +170,8 @@ class TopicActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicActivity_hasCorrectActivityLabel() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) launchTopicActivity( profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID ).use { scenario -> @@ -184,8 +186,8 @@ class TopicActivityTest { @Test @RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso. + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicActivity_startPracticeSession_questionActivityStartedWithProfileId() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) launchTopicActivity(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { // Open the practice tab and select a skill. onView(withText("Practice")).perform(click()) @@ -233,7 +235,7 @@ class TopicActivityTest { @Component( modules = [ RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 3d2ed2bb238..21c825d450b 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 @@ -84,6 +84,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.spotlight.SpotlightStateController @@ -92,13 +93,14 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID 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.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -120,6 +122,7 @@ import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -183,7 +186,6 @@ class TopicFragmentTest { @Before fun setUp() { Intents.init() - TestPlatformParameterModule.reset() } @After @@ -193,8 +195,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_toolbarTitle_isDisplayedSuccessfully() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent( profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID ).use { @@ -204,8 +207,10 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testLessonsTabSpotlight_spotlightAlreadySeen_checkSpotlightNotShown() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(FIRST_CHAPTER) launch( createTopicActivityIntent( @@ -228,8 +233,10 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicLessonTabSpotlight_spotlightNotSeenBefore_checkSpotlightIsShown() { - initializeApplicationComponent(false) + initializeApplicationComponent() activityTestRule.launchActivity( createTopicActivityIntent( profileId, @@ -242,8 +249,10 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testFirstChapterSpotlight_setToShowOnFirstLogin_checkSpotlightShown() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(TOPIC_LESSON_TAB) activityTestRule.launchActivity( createTopicPlayStoryActivityIntent( @@ -258,8 +267,10 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testFirstChapterSpotlight_setToShowOnFirstLogin_alreadySeen_checkSpotlightNotShown() { - initializeApplicationComponent(false) + initializeApplicationComponent() launch( createTopicPlayStoryActivityIntent( profileId, @@ -289,8 +300,10 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testRevisionTabSpotlight_setToShowAfterAtleast3ChaptersCompleted_notSeenBefore_checkShown() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(FIRST_CHAPTER) markSpotlightSeen(TOPIC_LESSON_TAB) storyProgressTestHelper.markCompletedFractionsStory0Exp0(profileId, false) @@ -309,8 +322,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testRevisionTabSpotlight_setToShowAfterAtleast3ChaptersCompleted_notComplete_checkNotShown() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(TOPIC_LESSON_TAB) markSpotlightSeen(FIRST_CHAPTER) launch( @@ -324,8 +338,10 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.SPOTLIGHT_UI) + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testRevisionTabSpotlight_setToShowAfterAtleast3ChaptersCompleted_alreadySeen_checkNotShown() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(TOPIC_LESSON_TAB) markSpotlightSeen(FIRST_CHAPTER) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -353,8 +369,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_toolbarTitle_readerOff_marqueeInRtl_isDisplayedCorrectly() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(TOPIC_LESSON_TAB) fakeAccessibilityService.setScreenReaderEnabled(false) activityTestRule.launchActivity( @@ -376,8 +393,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_toolbarTitle_readerOn_marqueeInRtl_isDisplayedCorrectly() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(TOPIC_LESSON_TAB) fakeAccessibilityService.setScreenReaderEnabled(true) activityTestRule.launchActivity( @@ -399,8 +417,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_toolbarTitle_readerOff_marqueeInLtr_isDisplayedCorrectly() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(TOPIC_LESSON_TAB) fakeAccessibilityService.setScreenReaderEnabled(false) activityTestRule.launchActivity( @@ -421,8 +440,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_toolbarTitle_readerOn_marqueeInLtr_isDisplayedCorrectly() { - initializeApplicationComponent(false) + initializeApplicationComponent() markSpotlightSeen(TOPIC_LESSON_TAB) fakeAccessibilityService.setScreenReaderEnabled(true) activityTestRule.launchActivity( @@ -443,8 +463,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnToolbarNavigationButton_closeActivity() { - initializeApplicationComponent(false) + initializeApplicationComponent() activityTestRule.launchActivity( createTopicActivityIntent( profileId, @@ -457,16 +478,18 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_showsTopicFragmentWithMultipleTabs() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { onView(withId(R.id.topic_tabs_container)).perform(click()).check(matches(isDisplayed())) } } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_swipePage_hasSwipedPage() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { onView(withId(R.id.topic_tabs_viewpager)).check(matches(isDisplayed())) onView(withId(R.id.topic_tabs_viewpager)).perform(swipeLeft()) @@ -475,8 +498,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_infoTopicTab_isDisplayedInTabLayout() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { onView( withText( @@ -490,8 +514,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_infoTopicTab_isNotDisplayedInTabLayout() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { onView(withText(TopicTab.getTabForPosition(position = INFO_TAB_POSITION, true).name)) .check(doesNotExist()) @@ -499,8 +524,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_defaultTabIsLessons() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicPlayStoryActivityIntent( profileId, TEST_CLASSROOM_ID_1, @@ -512,8 +538,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_defaultTabIsLessons() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicPlayStoryActivityIntent( profileId, TEST_CLASSROOM_ID_1, @@ -525,8 +552,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_clickOnLessonsTab_showsPlayTabSelected() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { clickTabAtPosition(position = LESSON_TAB_POSITION_EXTRA_TABS_DISABLED) verifyTabTitleAtPosition(position = LESSON_TAB_POSITION_EXTRA_TABS_DISABLED) @@ -534,8 +562,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnLessonsTab_showsPlayTabWithContentMatched() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -551,8 +580,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_practiceTabEnabled_practiceTopicTabIsDisplayedInTabLayout() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { val practiceTab = TopicTab.getTabForPosition(position = PRACTICE_TAB_POSITION, enableExtraTopicTabsUi.value) @@ -569,8 +599,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_practiceTopicTabIsNotDisplayedInTabLayout() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { // Unconditionally retrieve the practice tab name since this test is verifying that it's not // enabled. @@ -581,8 +612,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_configChange_practiceTopicTabIsNotDisplayed() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { onView(isRoot()).perform(orientationLandscape()) testCoroutineDispatchers.runCurrent() @@ -597,8 +629,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_clickOnPracticeTab_showsPracticeTabSelected() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { clickTabAtPosition(position = PRACTICE_TAB_POSITION) verifyTabTitleAtPosition(position = PRACTICE_TAB_POSITION) @@ -606,8 +639,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_clickOnPracticeTab_showsPracticeTabWithContentMatched() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -623,8 +657,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnReviewTab_showsReviewTabSelected() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { clickTabAtPosition(position = REVISION_TAB_POSITION_EXTRA_TABS_DISABLED) verifyTabTitleAtPosition(position = REVISION_TAB_POSITION_EXTRA_TABS_DISABLED) @@ -632,8 +667,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnReviewTab_showsReviewTabWithContentMatched() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -649,8 +685,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_clickOnReviewTab_thenInfoTab_showsInfoTab() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { clickTabAtPosition(position = REVISION_TAB_POSITION) clickTabAtPosition(position = INFO_TAB_POSITION) @@ -659,8 +696,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun enableExtraTabs_clickOnReviewTab_thenInfoTab_showsInfoTabWithContentMatched() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() clickTabAtPosition(position = REVISION_TAB_POSITION) @@ -676,8 +714,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnLessonsTab_configChange_showsSameTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() clickTabAtPosition(position = LESSON_TAB_POSITION_EXTRA_TABS_DISABLED) @@ -694,8 +733,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun enableExtraTabs_clickOnPracticeTab_configChange_showsSameTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -720,8 +760,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnReviewTab_configChange_showsSameTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -739,8 +780,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_configChange_showsDefaultTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicPlayStoryActivityIntent( profileId, TEST_CLASSROOM_ID_1, @@ -760,8 +802,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_configChange_showsDefaultTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicPlayStoryActivityIntent( profileId, TEST_CLASSROOM_ID_1, @@ -781,8 +824,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun enableExtraTabs_withStoryId_clickOnPracticeTab_configChange_showsSameTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( profileId, @@ -811,8 +855,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_lessonsTabDefaulted_logsLessonsTabOpen() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( profileId, @@ -828,8 +873,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_lessonsTabDefaulted_switchToRevisionTab_logsRevisionTabOpen() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( profileId, @@ -848,8 +894,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_lessonsTabDefaulted_switchToRevisionTabThenBack_logsLessonsTabOpenAgain() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( profileId, @@ -870,8 +917,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_extraTabs_openInfoTab_logsInfoTabOpen() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( profileId, @@ -890,8 +938,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_extraTabs_openQuestionsTab_logsInfoQuestionsOpen() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( profileId, @@ -1026,8 +1075,7 @@ class TopicFragmentTest { testCoroutineDispatchers.runCurrent() } - private fun initializeApplicationComponent(enableExtraTabsUi: Boolean) { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(enableExtraTabsUi) + private fun initializeApplicationComponent() { setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) @@ -1041,7 +1089,7 @@ class TopicFragmentTest { @Singleton @Component( modules = [ - TestPlatformParameterModule::class, RobolectricModule::class, + PlatformParameterModule::class, RobolectricModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 6af4d3d4a4f..4a9e0f513d9 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 @@ -82,10 +82,12 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn import org.oppia.android.testing.TestImageLoaderModule @@ -94,7 +96,6 @@ 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 import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -111,6 +112,7 @@ import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -141,6 +143,7 @@ private const val DUMMY_TOPIC_DESCRIPTION_LONG = application = TopicInfoFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi" ) +@EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) class TopicInfoFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -164,7 +167,6 @@ class TopicInfoFragmentTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() } @@ -492,7 +494,7 @@ class TopicInfoFragmentTest { @Singleton @Component( modules = [ - RobolectricModule::class, TestPlatformParameterModule::class, + RobolectricModule::class, PlatformParameterModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 9ceba1db737..45c3d62b78b 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 @@ -98,6 +98,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.spotlight.SpotlightStateController @@ -107,13 +108,13 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID 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.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule 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 -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -135,6 +136,7 @@ import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -148,6 +150,7 @@ import javax.inject.Singleton application = TopicLessonsFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi" ) +@EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) class TopicLessonsFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -183,7 +186,6 @@ class TopicLessonsFragmentTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) Intents.init() setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() @@ -1334,7 +1336,7 @@ class TopicLessonsFragmentTest { @Singleton @Component( modules = [ - RobolectricModule::class, TestPlatformParameterModule::class, + RobolectricModule::class, PlatformParameterModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 94fa885b5f3..10372e65c06 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 @@ -83,16 +83,17 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.spotlight.SpotlightStateController import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -111,6 +112,7 @@ import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -124,6 +126,7 @@ import javax.inject.Singleton application = TopicPracticeFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi" ) +@EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) class TopicPracticeFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -146,7 +149,6 @@ class TopicPracticeFragmentTest { @Before fun setUp() { Intents.init() - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() skillIdList.add("5RM9KPfQxobH") @@ -441,7 +443,7 @@ class TopicPracticeFragmentTest { @Singleton @Component( modules = [ - RobolectricModule::class, TestPlatformParameterModule::class, + RobolectricModule::class, PlatformParameterModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, 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 2b86bba92c9..a25e65d7340 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 @@ -83,18 +83,19 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.spotlight.SpotlightStateController import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -112,6 +113,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.ImageParsingModule import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -125,6 +127,7 @@ import javax.inject.Singleton application = TopicRevisionFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi" ) +@EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) class TopicRevisionFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -150,7 +153,6 @@ class TopicRevisionFragmentTest { @Before fun setUp() { Intents.init() - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() markAllSpotlightsSeen() @@ -349,7 +351,7 @@ class TopicRevisionFragmentTest { @Singleton @Component( modules = [ - RobolectricModule::class, TestPlatformParameterModule::class, + RobolectricModule::class, PlatformParameterModule::class, TestDispatcherModule::class, ApplicationModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, diff --git a/app/src/test/java/org/oppia/android/app/accessibility/FakeAccessibilityServiceTest.kt b/app/src/test/java/org/oppia/android/app/accessibility/FakeAccessibilityServiceTest.kt index e77ded760d9..3ce34d9997c 100644 --- a/app/src/test/java/org/oppia/android/app/accessibility/FakeAccessibilityServiceTest.kt +++ b/app/src/test/java/org/oppia/android/app/accessibility/FakeAccessibilityServiceTest.kt @@ -8,9 +8,11 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.mock +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.accessibility.AccessibilityTestModule import org.oppia.android.util.accessibility.FakeAccessibilityService import org.robolectric.annotation.Config @@ -23,6 +25,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FakeAccessibilityServiceTest.TestApplication::class) class FakeAccessibilityServiceTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var accessibilityService: FakeAccessibilityService 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 554cbeff236..700ca2f5719 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 @@ -64,6 +64,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -96,6 +97,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ActivityIntentFactoriesTest.TestApplication::class) class ActivityIntentFactoriesTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 3aa92beb124..9f3d14ff75f 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 @@ -63,6 +63,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -94,6 +95,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ActivityRouterModuleTest.TestApplication::class) class ActivityRouterModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 d1f06461035..66d15768433 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 @@ -69,6 +69,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -102,6 +103,9 @@ private const val internalProfileId = 1 @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ActivityRouterTest.TestApplication::class) class ActivityRouterTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() diff --git a/app/src/test/java/org/oppia/android/app/application/alpha/AlphaBuildFlavorModuleTest.kt b/app/src/test/java/org/oppia/android/app/application/alpha/AlphaBuildFlavorModuleTest.kt index f40c984f7b4..d620637adae 100644 --- a/app/src/test/java/org/oppia/android/app/application/alpha/AlphaBuildFlavorModuleTest.kt +++ b/app/src/test/java/org/oppia/android/app/application/alpha/AlphaBuildFlavorModuleTest.kt @@ -10,9 +10,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.BuildFlavor +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AlphaBuildFlavorModuleTest.TestApplication::class) class AlphaBuildFlavorModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var buildFlavor: BuildFlavor diff --git a/app/src/test/java/org/oppia/android/app/application/alpha/BUILD.bazel b/app/src/test/java/org/oppia/android/app/application/alpha/BUILD.bazel index e8cc91483e3..955e2952677 100644 --- a/app/src/test/java/org/oppia/android/app/application/alpha/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/application/alpha/BUILD.bazel @@ -14,6 +14,7 @@ oppia_android_test( "//:dagger", "//app/src/main/java/org/oppia/android/app/application/alpha:alpha_build_flavor_module", "//model/src/main/proto:version_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", diff --git a/app/src/test/java/org/oppia/android/app/application/beta/BUILD.bazel b/app/src/test/java/org/oppia/android/app/application/beta/BUILD.bazel index 16a2e88e15c..865a962490b 100644 --- a/app/src/test/java/org/oppia/android/app/application/beta/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/application/beta/BUILD.bazel @@ -14,6 +14,7 @@ oppia_android_test( "//:dagger", "//app/src/main/java/org/oppia/android/app/application/beta:beta_application", "//model/src/main/proto:version_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", diff --git a/app/src/test/java/org/oppia/android/app/application/beta/BetaBuildFlavorModuleTest.kt b/app/src/test/java/org/oppia/android/app/application/beta/BetaBuildFlavorModuleTest.kt index efbe6eab3e7..a5868cda55b 100644 --- a/app/src/test/java/org/oppia/android/app/application/beta/BetaBuildFlavorModuleTest.kt +++ b/app/src/test/java/org/oppia/android/app/application/beta/BetaBuildFlavorModuleTest.kt @@ -10,9 +10,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.BuildFlavor +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = BetaBuildFlavorModuleTest.TestApplication::class) class BetaBuildFlavorModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var buildFlavor: BuildFlavor diff --git a/app/src/test/java/org/oppia/android/app/application/dev/BUILD.bazel b/app/src/test/java/org/oppia/android/app/application/dev/BUILD.bazel index 47e7ca2b31b..e0c6ec80c1e 100644 --- a/app/src/test/java/org/oppia/android/app/application/dev/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/application/dev/BUILD.bazel @@ -14,6 +14,7 @@ oppia_android_test( "//:dagger", "//app/src/main/java/org/oppia/android/app/application/dev:developer_application", "//model/src/main/proto:version_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", diff --git a/app/src/test/java/org/oppia/android/app/application/dev/DeveloperBuildFlavorModuleTest.kt b/app/src/test/java/org/oppia/android/app/application/dev/DeveloperBuildFlavorModuleTest.kt index 9f5a1c6e7ee..75c68cc98ef 100644 --- a/app/src/test/java/org/oppia/android/app/application/dev/DeveloperBuildFlavorModuleTest.kt +++ b/app/src/test/java/org/oppia/android/app/application/dev/DeveloperBuildFlavorModuleTest.kt @@ -10,9 +10,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.BuildFlavor +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = DeveloperBuildFlavorModuleTest.TestApplication::class) class DeveloperBuildFlavorModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var buildFlavor: BuildFlavor diff --git a/app/src/test/java/org/oppia/android/app/application/ga/BUILD.bazel b/app/src/test/java/org/oppia/android/app/application/ga/BUILD.bazel index a15268016f6..3649028078a 100644 --- a/app/src/test/java/org/oppia/android/app/application/ga/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/application/ga/BUILD.bazel @@ -14,6 +14,7 @@ oppia_android_test( "//:dagger", "//app/src/main/java/org/oppia/android/app/application/ga:general_availability_application", "//model/src/main/proto:version_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", diff --git a/app/src/test/java/org/oppia/android/app/application/ga/GaBuildFlavorModuleTest.kt b/app/src/test/java/org/oppia/android/app/application/ga/GaBuildFlavorModuleTest.kt index b8a848a432e..bf9e251145c 100644 --- a/app/src/test/java/org/oppia/android/app/application/ga/GaBuildFlavorModuleTest.kt +++ b/app/src/test/java/org/oppia/android/app/application/ga/GaBuildFlavorModuleTest.kt @@ -10,9 +10,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.BuildFlavor +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = GaBuildFlavorModuleTest.TestApplication::class) class GaBuildFlavorModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var buildFlavor: BuildFlavor diff --git a/app/src/test/java/org/oppia/android/app/application/testing/BUILD.bazel b/app/src/test/java/org/oppia/android/app/application/testing/BUILD.bazel index 20c624701ff..7c0df7f6a26 100644 --- a/app/src/test/java/org/oppia/android/app/application/testing/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/application/testing/BUILD.bazel @@ -14,6 +14,7 @@ oppia_android_test( "//:dagger", "//app/src/main/java/org/oppia/android/app/application/testing:testing_build_flavor_module", "//model/src/main/proto:version_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", diff --git a/app/src/test/java/org/oppia/android/app/application/testing/TestingBuildFlavorModuleTest.kt b/app/src/test/java/org/oppia/android/app/application/testing/TestingBuildFlavorModuleTest.kt index f1b3136ccb0..af061a90dcb 100644 --- a/app/src/test/java/org/oppia/android/app/application/testing/TestingBuildFlavorModuleTest.kt +++ b/app/src/test/java/org/oppia/android/app/application/testing/TestingBuildFlavorModuleTest.kt @@ -10,9 +10,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.BuildFlavor +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = TestingBuildFlavorModuleTest.TestApplication::class) class TestingBuildFlavorModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var buildFlavor: BuildFlavor diff --git a/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/BUILD.bazel b/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/BUILD.bazel index c2648795ecd..3376386d46f 100644 --- a/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/BUILD.bazel +++ b/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/BUILD.bazel @@ -17,6 +17,7 @@ oppia_android_test( "//app/src/main/java/org/oppia/android/app/application:application_injector", "//app/src/main/java/org/oppia/android/app/application:application_injector_provider", "//app/src/main/java/org/oppia/android/app/application:common_application_modules", + "//testing", "//third_party:junit_junit", "//third_party:org_mockito_mockito-core", "//third_party:org_robolectric_robolectric", diff --git a/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/DeveloperOptionsTestParsersViewModelTest.kt b/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/DeveloperOptionsTestParsersViewModelTest.kt index 6516a0d68ae..9d98fc02a80 100644 --- a/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/DeveloperOptionsTestParsersViewModelTest.kt +++ b/app/src/test/java/org/oppia/android/app/devoptions/devoptionsitemviewmodel/DeveloperOptionsTestParsersViewModelTest.kt @@ -8,11 +8,15 @@ import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule import org.oppia.android.app.devoptions.RouteToMathExpressionParserTestListener +import org.oppia.android.testing.OppiaTestRule /** Tests for [DeveloperOptionsTestParsersViewModel]. */ // FunctionName: test names are conventionally named with underscores. @Suppress("FunctionName") class DeveloperOptionsTestParsersViewModelTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() 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 54f277718e8..aee631c9026 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,15 +64,18 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -91,6 +94,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -103,6 +107,9 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class HomeActivityLocalTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -132,13 +139,13 @@ class HomeActivityLocalTest { @After fun tearDown() { - TestPlatformParameterModule.reset() Intents.release() } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testHomeActivity_onLaunch_logsOpenHomeEvent() { - setUpTestWithOnboardingV2Enabled(false) + setUpTestApplicationComponent() launch(createHomeActivityIntent(profileId)).use { testCoroutineDispatchers.runCurrent() @@ -150,8 +157,9 @@ class HomeActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testActivity_onboardingV2_soleProfile_onInitialLaunch_logsCompleteAppOnboardingEvent() { - setUpTestWithOnboardingV2Enabled(true) + setUpTestApplicationComponent() profileTestHelper.addOnlyAdminProfileWithoutPin() profileTestHelper.updateProfileType( profileId = profileId, @@ -168,8 +176,9 @@ class HomeActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testActivity_onboardingV2_supervisorProfile_onInitialLaunch_logsCompleteAppOnboardingEvent() { - setUpTestWithOnboardingV2Enabled(true) + setUpTestApplicationComponent() profileTestHelper.addOnlyAdminProfileWithoutPin() profileTestHelper.updateProfileType( profileId = profileId, @@ -186,8 +195,9 @@ class HomeActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testActivity_onboardingV2_nonAdminProfile_onInitialLaunch_doesNotLogAppOnboardingEvent() { - setUpTestWithOnboardingV2Enabled(true) + setUpTestApplicationComponent() profileTestHelper.addOnlyAdminProfile() profileTestHelper.addMoreProfiles(1) val profileId1 = ProfileId.newBuilder().setInternalId(1).build() @@ -209,6 +219,7 @@ class HomeActivityLocalTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testActivity_onboardingV2_adminProfile_onSubsequentLaunch_doesNotLogAppOnboardingEvent() { executeInPreviousAppInstance { testComponent -> testComponent.getProfileTestHelper().updateProfileType(profileId, ProfileType.SOLE_LEARNER) @@ -218,7 +229,7 @@ class HomeActivityLocalTest { testComponent.getTestCoroutineDispatchers().runCurrent() } - setUpTestWithOnboardingV2Enabled(false) + setUpTestApplicationComponent() launch(createHomeActivityIntent(profileId)).use { testCoroutineDispatchers.runCurrent() val eventCount = fakeAnalyticsEventLogger.getEventListCount() @@ -231,13 +242,14 @@ class HomeActivityLocalTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testHomeActivity_onSubsequentLaunch_doesNotLogCompletedAppOnboardingEvent() { executeInPreviousAppInstance { testComponent -> testComponent.getAppStartupStateController().markOnboardingFlowCompleted() testComponent.getTestCoroutineDispatchers().runCurrent() } - setUpTestWithOnboardingV2Enabled(false) + setUpTestApplicationComponent() launch(createHomeActivityIntent(profileId)).use { testCoroutineDispatchers.runCurrent() val eventCount = fakeAnalyticsEventLogger.getEventListCount() @@ -250,8 +262,9 @@ class HomeActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testHomeActivity_onboardingV2Enabled_onInitialLaunch_logsEndProfileOnboardingEvent() { - setUpTestWithOnboardingV2Enabled(true) + setUpTestApplicationComponent() profileTestHelper.addOnlyAdminProfileWithoutPin() launch(createHomeActivityIntent(profileId)).use { testCoroutineDispatchers.runCurrent() @@ -264,6 +277,7 @@ class HomeActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testHomeActivity_onboardingV2_revisitApp_doesNotLogEndProfileOnboardingEvent() { executeInPreviousAppInstance { testComponent -> testComponent.getAppStartupStateController().markOnboardingFlowCompleted() @@ -271,7 +285,7 @@ class HomeActivityLocalTest { testComponent.getTestCoroutineDispatchers().runCurrent() } - setUpTestWithOnboardingV2Enabled(true) + setUpTestApplicationComponent() launch(createHomeActivityIntent(profileId)).use { testCoroutineDispatchers.runCurrent() @@ -280,11 +294,6 @@ class HomeActivityLocalTest { } } - private fun setUpTestWithOnboardingV2Enabled(enableOnboardingFlowV2: Boolean) { - TestPlatformParameterModule.forceEnableOnboardingFlowV2(enableOnboardingFlowV2) - setUpTestApplicationComponent() - } - /** * Creates a separate test application component and executes the specified block. This should be * called before [setUpTestApplicationComponent] to avoid undefined behavior in production code. @@ -319,7 +328,7 @@ class HomeActivityLocalTest { @Component( modules = [ TestDispatcherModule::class, ApplicationModule::class, RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 df806df9225..4c3cd7a0a7a 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 @@ -57,6 +57,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -87,6 +88,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FractionParsingUiErrorTest.TestApplication::class, qualifiers = "port-xxhdpi") class FractionParsingUiErrorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 e97850dc3a3..4a645f04a78 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 @@ -82,6 +82,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule 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.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule @@ -150,6 +151,9 @@ class ListItemLeadingMarginSpanTest { @field:DefaultResourceBucketName lateinit var resourceBucketName: String + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule var activityScenarioRule: ActivityScenarioRule = ActivityScenarioRule( 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 dbdffdca5db..51b8bebe3bb 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 @@ -58,6 +58,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -87,6 +88,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = StringToRatioParserTest.TestApplication::class, qualifiers = "port-xxhdpi") class StringToRatioParserTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 b5059c0892e..cd0261cb193 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 @@ -71,6 +71,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.question.QuestionModule @@ -79,11 +80,12 @@ import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_2 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.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -103,6 +105,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -115,6 +118,9 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class ExplorationActivityLocalTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -174,8 +180,9 @@ class ExplorationActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testExplorationActivity_closeExploration_surveyGatingCriteriaMet_showsSurveyPopup() { - setUpTestWithNpsEnabled() + setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeMs(afternoonUtcTimestampMillis) @@ -227,8 +234,9 @@ class ExplorationActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testExplorationActivity_closeExploration_surveyGatingCriteriaNotMet_noSurveyPopup() { - setUpTestWithNpsEnabled() + setUpTestApplicationComponent() getApplicationDependencies( internalProfileId, TEST_CLASSROOM_ID_0, @@ -273,8 +281,9 @@ class ExplorationActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testExplorationActivity_updateGatingProvider_surveyGatingCriteriaMet_keepsSurveyDialog() { - setUpTestWithNpsEnabled() + setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) fakeOppiaClock.setCurrentTimeMs(afternoonUtcTimestampMillis) @@ -337,11 +346,6 @@ class ExplorationActivityLocalTest { } } - private fun setUpTestWithNpsEnabled() { - TestPlatformParameterModule.forceEnableNpsSurvey(true) - setUpTestApplicationComponent() - } - private fun markAllSpotlightsSeen() { markSpotlightSeen(Spotlight.FeatureCase.LESSONS_BACK_BUTTON) markSpotlightSeen(Spotlight.FeatureCase.VOICEOVER_PLAY_ICON) @@ -405,7 +409,7 @@ class ExplorationActivityLocalTest { @Component( modules = [ TestDispatcherModule::class, ApplicationModule::class, RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 4af5ec06d22..246ecc0ea0a 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 @@ -126,6 +126,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_1 @@ -148,7 +149,6 @@ import org.oppia.android.testing.espresso.KonfettiViewMatcher.Companion.hasExpec 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 import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.CoroutineExecutorService @@ -2913,7 +2913,7 @@ class StateFragmentLocalTest { @Component( modules = [ TestModule::class, TestDispatcherModule::class, ApplicationModule::class, - RobolectricModule::class, TestPlatformParameterModule::class, + RobolectricModule::class, PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 128361f5d7b..57b7b2635a8 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 @@ -60,6 +60,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -92,6 +93,7 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class ProfileChooserFragmentLocalTest { + @get:Rule val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger 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 b973bf5ef81..91d6b97df8c 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 @@ -62,6 +62,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -98,6 +99,7 @@ private const val TEST_STORY_ID = "GJ2rLXRKD5hw" qualifiers = "port-xxhdpi" ) class StoryActivityLocalTest { + @get:Rule val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger 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 ea6b365c212..2565c3d6f97 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 @@ -63,6 +63,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -90,6 +91,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = CompletedStoryListSpanTest.TestApplication::class) class CompletedStoryListSpanTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 84ff4b75285..8a34d5fcf9f 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,6 +64,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -92,6 +93,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = HomeSpanTest.TestApplication::class) class HomeSpanTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 3e8eba9a4a9..2ff7fdc1497 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 @@ -64,6 +64,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -91,6 +92,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = OngoingTopicListSpanTest.TestApplication::class) class OngoingTopicListSpanTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 55923caadbc..bc166187d6c 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 @@ -80,6 +80,7 @@ import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUp import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUpWorkerFactory import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -121,6 +122,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PlatformParameterIntegrationTest.TestApplication::class) class PlatformParameterIntegrationTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 e5e783cd8b3..9a752557092 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 @@ -62,6 +62,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -97,6 +98,9 @@ private const val TAG_PROFILE_CHOOSER_FRAGMENT_RECYCLER_VIEW = "profile_recycler @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ProfileChooserSpanTest.TestApplication::class) class ProfileChooserSpanTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 451e9aa249d..ed31b65d5ef 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 @@ -63,6 +63,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -90,6 +91,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ProfileProgressSpanCountTest.TestApplication::class) class ProfileProgressSpanCountTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 538f31e64b9..498a7e90f4c 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 @@ -66,6 +66,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -97,6 +98,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = RecentlyPlayedSpanTest.TestApplication::class) class RecentlyPlayedSpanTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 8fae80c1dcb..ce33b80fca5 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 @@ -62,6 +62,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -89,6 +90,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = TopicRevisionSpanTest.TestApplication::class) class TopicRevisionSpanTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 bbb6dd15f15..5b7e3ed1bfb 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 @@ -59,6 +59,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -90,6 +91,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = TestActivityTest.TestApplication::class) class TestActivityTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 2b2ee89f742..8b2f8b37c39 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,6 +70,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -100,6 +101,9 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class AdministratorControlsFragmentTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 54178d81774..47a19140e41 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 @@ -63,13 +63,14 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -88,7 +89,6 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule -import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -98,6 +98,9 @@ import javax.inject.Singleton @Config(application = OptionsFragmentTest.TestApplication::class, qualifiers = "sw600dp") @LooperMode(LooperMode.Mode.PAUSED) class OptionsFragmentTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @@ -109,9 +112,6 @@ class OptionsFragmentTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableEditAccountsOptionsUi( - ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE - ) setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() @@ -219,7 +219,7 @@ class OptionsFragmentTest { @Component( modules = [ TestDispatcherModule::class, ApplicationModule::class, RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 e0b55eb5de7..28a0b253117 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 @@ -60,6 +60,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -86,6 +87,9 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @Config(application = PlayerSplitScreenTest.TestApplication::class) class PlayerSplitScreenTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 157dac70478..cf6720809eb 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,6 +70,7 @@ 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -102,6 +103,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = StateFragmentAccessibilityTest.TestApplication::class) class StateFragmentAccessibilityTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 c93092cb3dc..2a8c863182d 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 @@ -56,14 +56,16 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -81,6 +83,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -97,6 +100,7 @@ private const val TEST_TOPIC_ID = "GJ2rLXRKD5hw" ) class TopicInfoFragmentLocalTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() + @get:Rule val oppiaTestRule = OppiaTestRule() @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @@ -109,9 +113,9 @@ class TopicInfoFragmentLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicInfoFragment_onLaunch_logsEvent() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) - launchTopicActivityIntent(profileId = profileId, TEST_CLASSROOM_ID, TEST_TOPIC_ID).use { + launchTopicActivityIntent(profileId, TEST_CLASSROOM_ID, TEST_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() val event = fakeAnalyticsEventLogger.getMostRecentEvent() @@ -145,7 +149,7 @@ class TopicInfoFragmentLocalTest { @Component( modules = [ TestDispatcherModule::class, ApplicationModule::class, RobolectricModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggerModule::class, ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class, 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 b4c1c468a71..1b4d9a9b0be 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,6 +60,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -96,6 +97,7 @@ private const val TEST_STORY_ID = "GJ2rLXRKD5hw" qualifiers = "port-xxhdpi" ) class TopicLessonsFragmentLocalTest { + @get:Rule val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger 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 53794b37cce..094e92f3605 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 @@ -86,6 +86,7 @@ import org.oppia.android.domain.question.WrongAnswerMasteryPenalty import org.oppia.android.domain.question.WrongAnswerScorePenalty import org.oppia.android.domain.topic.TEST_SKILL_ID_1 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.KonfettiViewMatcher.Companion.hasActiveConfetti @@ -126,6 +127,9 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class QuestionPlayerActivityLocalTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 5fcc57e032f..cb893497d20 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,6 +62,7 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -94,6 +95,7 @@ import javax.inject.Singleton qualifiers = "port-xxhdpi" ) class RevisionCardActivityLocalTest { + @get:Rule val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger 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 aa12b2be77a..26b454e1845 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 @@ -72,6 +72,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule 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.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -115,6 +116,8 @@ import javax.inject.Singleton regionIetfTag = "US" ) class ActivityLanguageLocaleHandlerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 67846ded7ad..06484e5ec75 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 @@ -12,6 +12,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AppLanguageSelection @@ -26,6 +27,7 @@ import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterM import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.translation.TranslationController +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.DataProviderTestMonitor @@ -54,6 +56,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AppLanguageLocaleHandlerTest.TestApplication::class) class AppLanguageLocaleHandlerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context 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 39c27aa8d92..def10bb790b 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 @@ -65,6 +65,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule 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.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.DataProviderTestMonitor @@ -112,6 +113,7 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AppLanguageResourceHandlerTest.TestApplication::class) class AppLanguageResourceHandlerTest { + @get:Rule val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @get:Rule 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 49c522e6963..82d0e8018e4 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 @@ -70,6 +70,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule 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.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -126,6 +127,7 @@ class AppLanguageWatcherMixinTest { // cases when the locale isn't initialized (such as process death) prints an error & default // initializes the locale handler. + @get:Rule val oppiaTestRule = OppiaTestRule() @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @Inject lateinit var context: Context diff --git a/app/src/test/java/org/oppia/android/app/translation/testing/TestActivityRecreatorTest.kt b/app/src/test/java/org/oppia/android/app/translation/testing/TestActivityRecreatorTest.kt index 55cc471be7d..c36b6045513 100644 --- a/app/src/test/java/org/oppia/android/app/translation/testing/TestActivityRecreatorTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/testing/TestActivityRecreatorTest.kt @@ -11,8 +11,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -30,6 +32,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = TestActivityRecreatorTest.TestApplication::class) class TestActivityRecreatorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var testActivityRecreator: TestActivityRecreator 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 e3ec6648bca..d4e4b216051 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 @@ -60,6 +60,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -107,6 +108,9 @@ private const val AFTERNOON_TIMESTAMP = 1556029320000 @LooperMode(LooperMode.Mode.PAUSED) @Config(application = DateTimeUtilTest.TestApplication::class) class DateTimeUtilTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 2b286fc6a0b..9b57e2c5174 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 @@ -77,6 +77,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -130,6 +131,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = MathExpressionAccessibilityUtilTest.TestApplication::class) class MathExpressionAccessibilityUtilTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() diff --git a/data/BUILD.bazel b/data/BUILD.bazel index 9e61d1f5786..081312ba70c 100644 --- a/data/BUILD.bazel +++ b/data/BUILD.bazel @@ -26,7 +26,6 @@ TEST_DEPS = [ "//testing/src/main/java/org/oppia/android/testing/network", "//testing/src/main/java/org/oppia/android/testing/network:test_module", "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_constants", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:oppia_shadow_activity_manager", "//testing/src/main/java/org/oppia/android/testing/robolectric:oppia_shadow_traffic_stats", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", diff --git a/data/src/test/java/org/oppia/android/data/backends/gae/JsonPrefixNetworkInterceptorTest.kt b/data/src/test/java/org/oppia/android/data/backends/gae/JsonPrefixNetworkInterceptorTest.kt index 6a9b2858427..2bf63fd5eb0 100755 --- a/data/src/test/java/org/oppia/android/data/backends/gae/JsonPrefixNetworkInterceptorTest.kt +++ b/data/src/test/java/org/oppia/android/data/backends/gae/JsonPrefixNetworkInterceptorTest.kt @@ -8,8 +8,10 @@ import dagger.BindsInstance import dagger.Component import org.json.JSONObject import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.network.ApiMockLoader import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -19,6 +21,8 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class JsonPrefixNetworkInterceptorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var jsonPrefixNetworkInterceptor: JsonPrefixNetworkInterceptor diff --git a/data/src/test/java/org/oppia/android/data/backends/gae/NetworkConfigProdModuleTest.kt b/data/src/test/java/org/oppia/android/data/backends/gae/NetworkConfigProdModuleTest.kt index 023a5a3713e..12e9e78face 100644 --- a/data/src/test/java/org/oppia/android/data/backends/gae/NetworkConfigProdModuleTest.kt +++ b/data/src/test/java/org/oppia/android/data/backends/gae/NetworkConfigProdModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = NetworkConfigProdModuleTest.TestApplication::class) class NetworkConfigProdModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @field:[Inject BaseUrl] lateinit var baseUrl: String diff --git a/data/src/test/java/org/oppia/android/data/backends/gae/NetworkLoggingInterceptorTest.kt b/data/src/test/java/org/oppia/android/data/backends/gae/NetworkLoggingInterceptorTest.kt index 6b82cb460fb..2bf7b5d48f6 100644 --- a/data/src/test/java/org/oppia/android/data/backends/gae/NetworkLoggingInterceptorTest.kt +++ b/data/src/test/java/org/oppia/android/data/backends/gae/NetworkLoggingInterceptorTest.kt @@ -21,8 +21,10 @@ import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.BackgroundTestDispatcher @@ -54,6 +56,9 @@ class NetworkLoggingInterceptorTest { private const val headerString = "$testApiKey: $testApiKeyValue" } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var networkLoggingInterceptor: NetworkLoggingInterceptor @Inject diff --git a/data/src/test/java/org/oppia/android/data/backends/gae/NetworkModuleTest.kt b/data/src/test/java/org/oppia/android/data/backends/gae/NetworkModuleTest.kt index e30664000e8..ecf4ffd63e8 100644 --- a/data/src/test/java/org/oppia/android/data/backends/gae/NetworkModuleTest.kt +++ b/data/src/test/java/org/oppia/android/data/backends/gae/NetworkModuleTest.kt @@ -12,10 +12,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.data.backends.gae.api.FeedbackReportingService import org.oppia.android.data.backends.gae.api.PlatformParameterService +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.robolectric.annotation.Config @@ -29,6 +31,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = NetworkModuleTest.TestApplication::class) class NetworkModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Inject NetworkApiKey] lateinit var networkApiKey: String diff --git a/data/src/test/java/org/oppia/android/data/backends/gae/RemoteAuthNetworkInterceptorTest.kt b/data/src/test/java/org/oppia/android/data/backends/gae/RemoteAuthNetworkInterceptorTest.kt index 3713a60610f..e303a02778f 100644 --- a/data/src/test/java/org/oppia/android/data/backends/gae/RemoteAuthNetworkInterceptorTest.kt +++ b/data/src/test/java/org/oppia/android/data/backends/gae/RemoteAuthNetworkInterceptorTest.kt @@ -18,9 +18,11 @@ import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.data.backends.gae.api.PlatformParameterService +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.BackgroundTestDispatcher @@ -41,6 +43,8 @@ import javax.inject.Singleton @Config(application = RemoteAuthNetworkInterceptorTest.TestApplication::class) @LooperMode(LooperMode.Mode.PAUSED) class RemoteAuthNetworkInterceptorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var remoteAuthNetworkInterceptor: RemoteAuthNetworkInterceptor diff --git a/data/src/test/java/org/oppia/android/data/backends/gae/api/FeedbackReportingServiceTest.kt b/data/src/test/java/org/oppia/android/data/backends/gae/api/FeedbackReportingServiceTest.kt index ae1cde5cbed..1e264748b3d 100644 --- a/data/src/test/java/org/oppia/android/data/backends/gae/api/FeedbackReportingServiceTest.kt +++ b/data/src/test/java/org/oppia/android/data/backends/gae/api/FeedbackReportingServiceTest.kt @@ -12,11 +12,13 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.data.backends.gae.NetworkConfigProdModule import org.oppia.android.data.backends.gae.NetworkModule import org.oppia.android.data.backends.gae.model.GaeFeedbackReport +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.network.ApiMockLoader import org.oppia.android.testing.network.MockFeedbackReportingService import org.oppia.android.testing.network.RetrofitTestModule @@ -31,6 +33,8 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class FeedbackReportingServiceTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var mockRetrofit: MockRetrofit diff --git a/data/src/test/java/org/oppia/android/data/backends/gae/api/PlatformParameterServiceTest.kt b/data/src/test/java/org/oppia/android/data/backends/gae/api/PlatformParameterServiceTest.kt index 9678682fb96..e60af67807c 100644 --- a/data/src/test/java/org/oppia/android/data/backends/gae/api/PlatformParameterServiceTest.kt +++ b/data/src/test/java/org/oppia/android/data/backends/gae/api/PlatformParameterServiceTest.kt @@ -13,10 +13,12 @@ import okhttp3.OkHttpClient import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.data.backends.gae.NetworkConfigProdModule import org.oppia.android.data.backends.gae.NetworkModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.network.MockPlatformParameterService import org.oppia.android.testing.network.MockPlatformParameterService.Companion.appVersionForCorrectResponse import org.oppia.android.testing.network.RetrofitTestModule @@ -43,6 +45,8 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class PlatformParameterServiceTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @field:[Inject MockPlatformParameterService] lateinit var mockPlatformParameterService: PlatformParameterService diff --git a/data/src/test/java/org/oppia/android/data/persistence/PersistentCacheStoreTest.kt b/data/src/test/java/org/oppia/android/data/persistence/PersistentCacheStoreTest.kt index d655e11bcb9..226f147966f 100644 --- a/data/src/test/java/org/oppia/android/data/persistence/PersistentCacheStoreTest.kt +++ b/data/src/test/java/org/oppia/android/data/persistence/PersistentCacheStoreTest.kt @@ -33,6 +33,7 @@ import org.oppia.android.data.persistence.PersistentCacheStore.PublishMode.PUBLI import org.oppia.android.data.persistence.PersistentCacheStore.UpdateMode.UPDATE_ALWAYS import org.oppia.android.data.persistence.PersistentCacheStore.UpdateMode.UPDATE_IF_NEW_CACHE import org.oppia.android.data.persistence.PersistentCacheStoreTest.SubscriptionCallback.Companion.toAsyncChange +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat import org.oppia.android.testing.data.DataProviderTestMonitor @@ -91,6 +92,9 @@ class PersistentCacheStoreTest { }.build() } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 69a5a4a35c9..9a1c3d1b030 100755 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -228,7 +228,7 @@ TEST_DEPS = [ "//testing/src/main/java/org/oppia/android/testing/logging:test_sync_status_manager", "//testing/src/main/java/org/oppia/android/testing/network:network", "//testing/src/main/java/org/oppia/android/testing/network:test_module", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", + "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_constants_module", "//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", diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 2bafaedf87d..b69fa17c4c9 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -5,6 +5,9 @@ import dagger.Module import dagger.Provides import org.oppia.android.util.extensions.getVersionCode import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION +import org.oppia.android.util.platformparameter.AUTOMATIC_UPDATE_TOPIC_SETTING +import org.oppia.android.util.platformparameter.AUTOMATIC_UPDATE_TOPIC_SETTING_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.AutomaticUpdateTopicSetting import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering @@ -41,6 +44,7 @@ import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS @@ -67,6 +71,7 @@ import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_U import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionHighFrequencyTimeIntervalInMinutes import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionLowFrequencyTimeIntervalInMinutes import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionUploadTimeIntervalInMinutes +import org.oppia.android.util.platformparameter.PlatformParameter import org.oppia.android.util.platformparameter.PlatformParameterSingleton import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG @@ -80,12 +85,15 @@ import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours /** Dagger module that provides bindings for platform parameters. */ @Module class PlatformParameterModule { + @Provides @EnableDownloadsSupport fun provideEnableDownloadsSupport( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) + return overriddenFeatureFlags[FeatureFlag.DOWNLOADS_SUPPORT]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) ?: PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) } @@ -94,7 +102,9 @@ class PlatformParameterModule { fun provideSplashScreenWelcomeMsgParam( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(SPLASH_SCREEN_WELCOME_MSG) + return overriddenPlatformParameters[PlatformParameter.SPLASH_SCREEN_WELCOME_MSG]?.let { + PlatformParameterValue.createDefaultParameter(it as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(SPLASH_SCREEN_WELCOME_MSG) ?: PlatformParameterValue.createDefaultParameter(SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE) } @@ -103,11 +113,16 @@ class PlatformParameterModule { fun provideSyncUpWorkerTimePeriod( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( + return overriddenPlatformParameters[ + PlatformParameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS + ]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter( SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS - ) ?: PlatformParameterValue.createDefaultParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE ) + ?: PlatformParameterValue.createDefaultParameter( + SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE + ) } @Provides @@ -115,11 +130,12 @@ class PlatformParameterModule { fun provideEnableEditAccountsOptionsUi( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - EDIT_ACCOUNTS_OPTIONS_UI - ) ?: PlatformParameterValue.createDefaultParameter( - ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE - ) + return overriddenFeatureFlags[FeatureFlag.EDIT_ACCOUNTS_OPTIONS_UI]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(EDIT_ACCOUNTS_OPTIONS_UI) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE + ) } @Provides @@ -127,7 +143,9 @@ class PlatformParameterModule { fun provideLearnerStudyAnalytics( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(LEARNER_STUDY_ANALYTICS) + return overriddenFeatureFlags[FeatureFlag.LEARNER_STUDY_ANALYTICS]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(LEARNER_STUDY_ANALYTICS) ?: PlatformParameterValue.createDefaultParameter(LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE) } @@ -136,7 +154,9 @@ class PlatformParameterModule { fun provideFastInLessonLanguageSwitching( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(FAST_LANGUAGE_SWITCHING_IN_LESSON) + return overriddenFeatureFlags[FeatureFlag.FAST_LANGUAGE_SWITCHING_IN_LESSON]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(FAST_LANGUAGE_SWITCHING_IN_LESSON) ?: PlatformParameterValue.createDefaultParameter( FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE ) @@ -147,7 +167,9 @@ class PlatformParameterModule { fun provideLoggingLearnerStudyIds( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(LOGGING_LEARNER_STUDY_IDS) + return overriddenFeatureFlags[FeatureFlag.LOGGING_LEARNER_STUDY_IDS]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(LOGGING_LEARNER_STUDY_IDS) ?: PlatformParameterValue.createDefaultParameter(LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE) } @@ -156,20 +178,36 @@ class PlatformParameterModule { fun provideCacheLatexRendering( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(CACHE_LATEX_RENDERING) + return overriddenPlatformParameters[PlatformParameter.CACHE_LATEX_RENDERING]?.let { + PlatformParameterValue.createDefaultParameter(it as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(CACHE_LATEX_RENDERING) ?: PlatformParameterValue.createDefaultParameter(CACHE_LATEX_RENDERING_DEFAULT_VALUE) } + @Provides + @AutomaticUpdateTopicSetting + fun provideAutomaticUpdateTopicSetting( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return overriddenPlatformParameters[PlatformParameter.AUTOMATIC_UPDATE_TOPIC_SETTING]?.let { + PlatformParameterValue.createDefaultParameter(it as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(AUTOMATIC_UPDATE_TOPIC_SETTING) + ?: PlatformParameterValue.createDefaultParameter(AUTOMATIC_UPDATE_TOPIC_SETTING_DEFAULT_VALUE) + } + @Provides @EnablePerformanceMetricsCollection fun provideEnablePerformanceMetricCollection( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( + return overriddenFeatureFlags[FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter( ENABLE_PERFORMANCE_METRICS_COLLECTION - ) ?: PlatformParameterValue.createDefaultParameter( - ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE ) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE + ) } @Provides @@ -177,11 +215,16 @@ class PlatformParameterModule { fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( + return overriddenPlatformParameters[ + PlatformParameter.PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES + ]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter( PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL ) + ?: PlatformParameterValue.createDefaultParameter( + PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL + ) } @Provides @@ -189,11 +232,16 @@ class PlatformParameterModule { fun providePerformanceMetricsCollectionHighFrequencyTimeIntervalInMinutes( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( + return overriddenPlatformParameters[ + PlatformParameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES + ]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter( PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL ) + ?: PlatformParameterValue.createDefaultParameter( + PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL + ) } @Provides @@ -201,11 +249,16 @@ class PlatformParameterModule { fun providePerformanceMetricsCollectionLowFrequencyTimeIntervalInMinutes( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( + return overriddenPlatformParameters[ + PlatformParameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES + ]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter( PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL ) + ?: PlatformParameterValue.createDefaultParameter( + PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL + ) } @Provides @@ -213,7 +266,9 @@ class PlatformParameterModule { fun provideEnableSpotlightUi( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) + return overriddenFeatureFlags[FeatureFlag.SPOTLIGHT_UI]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) ?: PlatformParameterValue.createDefaultParameter(ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE) } @@ -222,11 +277,10 @@ class PlatformParameterModule { fun provideEnableExtraTopicTabsUi( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - EXTRA_TOPIC_TABS_UI - ) ?: PlatformParameterValue.createDefaultParameter( - ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE - ) + return overriddenFeatureFlags[FeatureFlag.EXTRA_TOPIC_TABS_UI]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(EXTRA_TOPIC_TABS_UI) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE) } @Provides @@ -234,11 +288,14 @@ class PlatformParameterModule { fun provideEnableInteractionConfigChangeStateRetention( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( + return overriddenFeatureFlags[FeatureFlag.INTERACTION_CONFIG_CHANGE_STATE_RETENTION]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter( INTERACTION_CONFIG_CHANGE_STATE_RETENTION - ) ?: PlatformParameterValue.createDefaultParameter( - ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE ) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE + ) } @Provides @@ -246,10 +303,10 @@ class PlatformParameterModule { fun provideEnableAppAndOsDeprecation( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(APP_AND_OS_DEPRECATION) - ?: PlatformParameterValue.createDefaultParameter( - ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE - ) + return overriddenFeatureFlags[FeatureFlag.APP_AND_OS_DEPRECATION]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(APP_AND_OS_DEPRECATION) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE) } @Provides @@ -258,11 +315,10 @@ class PlatformParameterModule { platformParameterSingleton: PlatformParameterSingleton, context: Context ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - OPTIONAL_APP_UPDATE_VERSION_CODE - ) ?: PlatformParameterValue.createDefaultParameter( - context.getVersionCode() - ) + return overriddenPlatformParameters[PlatformParameter.OPTIONAL_APP_UPDATE_VERSION_CODE]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter(OPTIONAL_APP_UPDATE_VERSION_CODE) + ?: PlatformParameterValue.createDefaultParameter(context.getVersionCode()) } @Provides @@ -271,11 +327,10 @@ class PlatformParameterModule { platformParameterSingleton: PlatformParameterSingleton, context: Context ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - FORCED_APP_UPDATE_VERSION_CODE - ) ?: PlatformParameterValue.createDefaultParameter( - context.getVersionCode() - ) + return overriddenPlatformParameters[PlatformParameter.FORCED_APP_UPDATE_VERSION_CODE]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter(FORCED_APP_UPDATE_VERSION_CODE) + ?: PlatformParameterValue.createDefaultParameter(context.getVersionCode()) } @Provides @@ -283,11 +338,10 @@ class PlatformParameterModule { fun provideLowestSupportedApiLevel( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - LOWEST_SUPPORTED_API_LEVEL - ) ?: PlatformParameterValue.createDefaultParameter( - LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE - ) + return overriddenPlatformParameters[PlatformParameter.LOWEST_SUPPORTED_API_LEVEL]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter(LOWEST_SUPPORTED_API_LEVEL) + ?: PlatformParameterValue.createDefaultParameter(LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE) } @Provides @@ -295,11 +349,12 @@ class PlatformParameterModule { fun provideNpsSurveyGracePeriodInDays( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - NPS_SURVEY_GRACE_PERIOD_IN_DAYS - ) ?: PlatformParameterValue.createDefaultParameter( - NPS_SURVEY_GRACE_PERIOD_IN_DAYS_DEFAULT_VALUE - ) + return overriddenPlatformParameters[PlatformParameter.NPS_SURVEY_GRACE_PERIOD_IN_DAYS]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter(NPS_SURVEY_GRACE_PERIOD_IN_DAYS) + ?: PlatformParameterValue.createDefaultParameter( + NPS_SURVEY_GRACE_PERIOD_IN_DAYS_DEFAULT_VALUE + ) } @Provides @@ -307,11 +362,16 @@ class PlatformParameterModule { fun provideNpsSurveyMinimumAggregateLearningTimeInATopicInMinutes( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( + return overriddenPlatformParameters[ + PlatformParameter.NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES + ]?.let { + PlatformParameterValue.createDefaultParameter(it as Int) + } ?: platformParameterSingleton.getIntegerPlatformParameter( NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES_DEFAULT_VALUE ) + ?: PlatformParameterValue.createDefaultParameter( + NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES_DEFAULT_VALUE + ) } @Provides @@ -319,10 +379,10 @@ class PlatformParameterModule { fun provideEnableNpsSurvey( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(ENABLE_NPS_SURVEY) - ?: PlatformParameterValue.createDefaultParameter( - ENABLE_NPS_SURVEY_DEFAULT_VALUE - ) + return overriddenFeatureFlags[FeatureFlag.ENABLE_NPS_SURVEY]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(ENABLE_NPS_SURVEY) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_NPS_SURVEY_DEFAULT_VALUE) } @Provides @@ -330,10 +390,10 @@ class PlatformParameterModule { fun provideEnableOnboardingFlowV2( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(ENABLE_ONBOARDING_FLOW_V2) - ?: PlatformParameterValue.createDefaultParameter( - ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE - ) + return overriddenFeatureFlags[FeatureFlag.ENABLE_ONBOARDING_FLOW_V2]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(ENABLE_ONBOARDING_FLOW_V2) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE) } @Provides @@ -341,9 +401,51 @@ class PlatformParameterModule { fun provideEnableMultipleClassrooms( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(ENABLE_MULTIPLE_CLASSROOMS) - ?: PlatformParameterValue.createDefaultParameter( - ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE - ) + return overriddenFeatureFlags[FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS]?.let { + PlatformParameterValue.createDefaultParameter(it) + } ?: platformParameterSingleton.getBooleanPlatformParameter(ENABLE_MULTIPLE_CLASSROOMS) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE) + } + + companion object { + private val overriddenFeatureFlags = mutableMapOf() + private val overriddenPlatformParameters = mutableMapOf() + + /** + * Overrides the value of the specified feature flag with a new value for testing. + * + * @param name The feature flag to override. + * @param value The new value to assign to the feature flag for testing. + */ + fun overrideFeatureFlags(name: FeatureFlag, value: Boolean) { + overriddenFeatureFlags[name] = value + } + + /** + * Overrides the value of the specified platform parameter with a new value for testing. + * + * @param name The platform parameter to override. + * @param value The new value to assign to the platform parameter for testing. + */ + fun overridePlatformParameters(name: PlatformParameter, value: Any) { + overriddenPlatformParameters[name] = value + } + + /** + * Resets the specified feature flag to its default value by removing it from the overridden map. + * + * @param name The feature flag to reset. + */ + fun resetFeatureFlagToDefault(name: FeatureFlag) { + overriddenFeatureFlags.remove(name) + } + + /** + * Clears all overridden feature flags and platform parameters. + */ + fun clearAllParameterOverrides() { + overriddenFeatureFlags.clear() + overriddenPlatformParameters.clear() + } } } 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 10f3c2df525..2e046630e8f 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 @@ -12,6 +12,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Assert.fail +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -49,11 +50,14 @@ import org.oppia.android.domain.hintsandsolution.HintsAndSolutionProdModule import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_5 +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat @@ -73,11 +77,7 @@ import org.oppia.android.util.locale.LocaleProdModule import org.oppia.android.util.logging.LoggerModule import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics -import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds -import org.oppia.android.util.platformparameter.EnableNpsSurvey -import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 -import org.oppia.android.util.platformparameter.PlatformParameterValue +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.Shadows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -95,6 +95,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AudioPlayerControllerTest.TestApplication::class) class AudioPlayerControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() @Mock lateinit var mockAudioPlayerObserver: Observer> @@ -117,9 +119,13 @@ class AudioPlayerControllerTest { private val profileId by lazy { ProfileId.newBuilder().apply { internalId = 0 }.build() } + @Before + fun setUp() { + setUpMediaReadyApplication() + } + @Test fun testController_initializePlayer_invokePrepared_reportsSuccessfulInit() { - setUpMediaReadyApplication() audioPlayerController.initializeMediaPlayer() audioPlayerController.changeDataSource(TEST_URL, contentId = null, languageCode = "en") @@ -131,7 +137,6 @@ class AudioPlayerControllerTest { @Test fun testController_preparePlayer_invokePlay_checkIsPlaying() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) @@ -141,7 +146,6 @@ class AudioPlayerControllerTest { @Test fun testController_preparePlayer_invokePause_checkNotIsPlaying() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.pause(isFromExplicitUserAction = true) @@ -151,7 +155,6 @@ class AudioPlayerControllerTest { @Test fun testController_preparePlayer_invokeSeekTo_hasCorrectProgress() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.seekTo(500) @@ -162,7 +165,6 @@ class AudioPlayerControllerTest { @Test fun testController_preparePlayer_releaseMediaPlayer_hasEndState() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.releaseMediaPlayer() @@ -172,7 +174,6 @@ class AudioPlayerControllerTest { @Test fun testController_preparePlayer_invokePrepare_capturesPreparedState() { - setUpMediaReadyApplication() arrangeMediaPlayer() verify(mockAudioPlayerObserver, atLeastOnce()).onChanged(audioPlayerResultCaptor.capture()) @@ -183,7 +184,6 @@ class AudioPlayerControllerTest { @Test fun testController_releasePlayer_initializePlayer_capturesPendingState() { - setUpMediaReadyApplication() audioPlayerController.initializeMediaPlayer() audioPlayerController.releaseMediaPlayer() @@ -196,7 +196,6 @@ class AudioPlayerControllerTest { @Test fun tesObserver_preparePlayer_invokeCompletion_capturesCompletedState() { - setUpMediaReadyApplication() arrangeMediaPlayer() shadowMediaPlayer.invokeCompletionListener() @@ -210,7 +209,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokeChangeDataSource_capturesPendingState() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.changeDataSource(TEST_URL2, contentId = null, languageCode = "en") @@ -221,7 +219,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokeChangeDataSourceAfterPlay_capturesPendingState() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) @@ -233,7 +230,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokePlay_capturesPlayingState() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) @@ -247,7 +243,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokePlayAndAdvance_capturesManyPlayingStates() { - setUpMediaReadyApplication() arrangeMediaPlayer() // Wait for 1 second for the player to enter a playing state, then forcibly trigger completion. @@ -271,7 +266,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokePause_capturesPausedState() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) @@ -285,7 +279,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokePrepared_capturesCorrectPosition() { - setUpMediaReadyApplication() arrangeMediaPlayer() verify(mockAudioPlayerObserver, atLeastOnce()).onChanged(audioPlayerResultCaptor.capture()) @@ -296,7 +289,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokeSeekTo_capturesCorrectPosition() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.seekTo(500) @@ -312,7 +304,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokePlay_capturesCorrectDuration() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) @@ -325,7 +316,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_preparePlayer_invokeChangeDataSource_capturesCorrectPosition() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.seekTo(500) @@ -341,7 +331,6 @@ class AudioPlayerControllerTest { @Test fun testObserver_observeInitPlayer_releasePlayer_initPlayer_checkNoNewUpdates() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.releaseMediaPlayer() @@ -356,7 +345,6 @@ class AudioPlayerControllerTest { @Test fun testScheduling_preparePlayer_invokePauseAndAdvance_verifyTestDoesNotHang() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) @@ -373,7 +361,6 @@ class AudioPlayerControllerTest { @Test fun testScheduling_preparePlayer_invokeCompletionAndAdvance_verifyTestDoesNotHang() { - setUpMediaReadyApplication() arrangeMediaPlayer() audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) @@ -390,7 +377,6 @@ class AudioPlayerControllerTest { @Test fun testScheduling_observeData_removeObserver_verifyTestDoesNotHang() { - setUpMediaReadyApplication() val playProgress = audioPlayerController.initializeMediaPlayer() audioPlayerController.changeDataSource(TEST_URL, contentId = null, languageCode = "en") testCoroutineDispatchers.runCurrent() @@ -405,7 +391,6 @@ class AudioPlayerControllerTest { @Test fun testScheduling_addAndRemoveObservers_verifyTestDoesNotHang() { - setUpMediaReadyApplication() val playProgress = audioPlayerController.initializeMediaPlayer() audioPlayerController.changeDataSource(TEST_URL, contentId = null, languageCode = "en") @@ -423,7 +408,6 @@ class AudioPlayerControllerTest { @Test fun testController_invokeErrorListener_invokePrepared_verifyAudioStatusIsFailure() { - setUpMediaReadyApplication() audioPlayerController.initializeMediaPlayer().observeForever(mockAudioPlayerObserver) audioPlayerController.changeDataSource(TEST_URL, contentId = null, languageCode = "en") @@ -436,7 +420,6 @@ class AudioPlayerControllerTest { @Test fun testController_notInitialized_releasePlayer_fails() { - setUpMediaReadyApplication() val exception = assertThrows() { audioPlayerController.releaseMediaPlayer() } @@ -447,7 +430,6 @@ class AudioPlayerControllerTest { @Test fun testController_releasePlayerMultipleTimes_doesNoThrowException() { - setUpMediaReadyApplication() audioPlayerController.initializeMediaPlayer() assertNoExceptionIsThrown { @@ -458,7 +440,6 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokePlay_fails() { - setUpMediaReadyApplication() val exception = assertThrows() { audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) } @@ -468,7 +449,6 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokePause_fails() { - setUpMediaReadyApplication() val exception = assertThrows() { audioPlayerController.pause(isFromExplicitUserAction = true) } @@ -478,7 +458,6 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokeSeekTo_fails() { - setUpMediaReadyApplication() val exception = assertThrows() { audioPlayerController.seekTo(500) } @@ -488,7 +467,6 @@ class AudioPlayerControllerTest { @Test fun testController_initializePlayer_invokePrepared_reportsFailure_logsException() { - setUpMediaReadyApplication() audioPlayerController.initializeMediaPlayer() audioPlayerController.changeDataSource(TEST_FAIL_URL, contentId = null, languageCode = "en") @@ -500,8 +478,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlay_prepared_reloadingMainContent_autoPlaying_studyOn_doesNotLogPlayEvent() { - setUpMediaReadyApplicationWithLearnerStudy() arrangeMediaPlayer(contentId = "test_content_id") audioPlayerController.play(isPlayingFromAutoPlay = true, reloadingMainContent = true) @@ -513,8 +491,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlay_prepared_reloadingMainContent_notAutoPlaying_studyOn_logsPlayEvent() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = "test_content_id") logIntoAnalyticsReadyAdminProfile() @@ -551,8 +529,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlay_prepared_notReloadingMainContent_autoPlaying_studyOn_logsPlayEvent() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = "test_content_id") logIntoAnalyticsReadyAdminProfile() @@ -589,8 +567,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlay_prepared_notReloadingMainContent_notAutoPlaying_studyOn_logsPlayEvent() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = "test_content_id", languageCode = "sw") logIntoAnalyticsReadyAdminProfile() @@ -627,8 +605,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlay_prepared_missingContentId_studyOn_logsPlayEventWithoutContentId() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = null) logIntoAnalyticsReadyAdminProfile() @@ -648,8 +626,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlay_prepared_outsideExploration_studyOn_doesNotLogEvent() { - setUpMediaReadyApplicationWithLearnerStudy() arrangeMediaPlayer(contentId = "test_content_id") logIntoAnalyticsReadyAdminProfile() @@ -662,8 +640,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPause_playing_explicitUserAction_studyOn_logsPauseEvent() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = "test_content_id", languageCode = "sw") logIntoAnalyticsReadyAdminProfile() @@ -702,8 +680,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPause_playing_explicitAction_missingContentId_studyOn_logsPauseEventWithoutContentId() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = null) logIntoAnalyticsReadyAdminProfile() @@ -725,8 +703,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPause_playing_explicitUserAction_outsideExp_studyOn_doesNotLogEvent() { - setUpMediaReadyApplicationWithLearnerStudy() arrangeMediaPlayer(contentId = "test_content_id") logIntoAnalyticsReadyAdminProfile() audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) @@ -742,8 +720,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPause_playing_notExplicitUserAction_studyOn_doesNotLogEvent() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = "test_content_id", languageCode = "sw") logIntoAnalyticsReadyAdminProfile() @@ -766,8 +744,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPause_notPlaying_explicitUserAction_studyOn_doesNotLogEvent() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = "test_content_id", languageCode = "sw") logIntoAnalyticsReadyAdminProfile() @@ -788,8 +766,8 @@ class AudioPlayerControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPause_notPlaying_notExplicitUserAction_studyOn_doesNotLogEvent() { - setUpMediaReadyApplicationWithLearnerStudy() val explorationId = TEST_EXPLORATION_ID_5 arrangeMediaPlayer(contentId = "test_content_id", languageCode = "sw") logIntoAnalyticsReadyAdminProfile() @@ -869,11 +847,6 @@ class AudioPlayerControllerTest { ).exploration } - private fun setUpMediaReadyApplicationWithLearnerStudy() { - TestModule.enableLearnerStudyAnalytics = true - setUpMediaReadyApplication() - } - private fun setUpMediaReadyApplication() { setUpTestApplicationComponent() addMediaInfo() @@ -896,51 +869,11 @@ class AudioPlayerControllerTest { // TODO(#89): Move this to a common test application component. @Module class TestModule { - companion object { - var enableLearnerStudyAnalytics: Boolean = false - } - @Provides @Singleton fun provideContext(application: Application): Context { return application } - - // The scoping here is to ensure changes to the module value above don't change the parameter - // within the same application instance. - @Provides - @Singleton - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics(): PlatformParameterValue { - // Snapshot the value so that it doesn't change between injection and use. - val enableFeature = enableLearnerStudyAnalytics - return PlatformParameterValue.createDefaultParameter( - defaultValue = enableFeature - ) - } - - @Provides - @Singleton - @EnableLoggingLearnerStudyIds - fun provideLoggingLearnerStudyIds(): PlatformParameterValue { - // Snapshot the value so that it doesn't change between injection and use. - val enableFeature = enableLearnerStudyAnalytics - return PlatformParameterValue.createDefaultParameter( - defaultValue = enableFeature - ) - } - - @Provides - @EnableNpsSurvey - fun provideEnableNpsSurvey(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(defaultValue = true) - } - - @Provides - @EnableOnboardingFlowV2 - fun provideEnableOnboardingFlowV2(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(defaultValue = true) - } } // TODO(#89): Move this to a common test application component. @@ -959,7 +892,7 @@ class AudioPlayerControllerTest { NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class, MathEquationInputModule::class, CachingTestModule::class, HintsAndSolutionProdModule::class, HintsAndSolutionConfigModule::class, LoggerModule::class, ExplorationProgressModule::class, - TestAuthenticationModule::class + TestAuthenticationModule::class, PlatformParameterModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { diff --git a/domain/src/test/java/org/oppia/android/domain/audio/CellularAudioDialogControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/CellularAudioDialogControllerTest.kt index bdfeb58c7ad..ac9e5e41306 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/CellularAudioDialogControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/CellularAudioDialogControllerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.LogStorageModule @@ -17,6 +18,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.robolectric.RobolectricModule @@ -43,6 +45,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = CellularAudioDialogControllerTest.TestApplication::class) class CellularAudioDialogControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var cellularAudioDialogController: CellularAudioDialogController @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory 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 2b69a7e7c76..364adb402c7 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 @@ -22,6 +22,7 @@ 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImpl import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -44,6 +45,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AuthenticationControllerTest.TestApplication::class) class AuthenticationControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() @Inject lateinit var firebaseAuthWrapper: FirebaseAuthWrapper diff --git a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationModuleTest.kt index c8ee88e7bd6..65880ebb6cb 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.util.data.DataProvidersInjector @@ -29,6 +31,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AuthenticationModuleTest.TestApplication::class) class AuthenticationModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var firebaseAuthWrapper: FirebaseAuthWrapper 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 8983ae92125..e3cd0ecdf5a 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 @@ -10,10 +10,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.testing.FakeFirebaseAuthInstanceWrapperImpl +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -32,6 +34,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FirebaseAuthWrapperImplTest.TestApplication::class) class FirebaseAuthWrapperImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var firebaseAuthWrapperImpl: FirebaseAuthWrapperImpl 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 8553d8d1f99..59e54e91e54 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 @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AnswerGroup @@ -49,6 +50,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule @@ -140,6 +142,9 @@ class AnswerClassificationControllerTest { private const val TEST_MISCONCEPTION_ID_0 = "test-misconception-id-0" } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var answerClassificationController: AnswerClassificationController diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest.kt index c233180629e..98ffe35c166 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest.kt @@ -9,6 +9,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject @@ -16,6 +17,7 @@ import org.oppia.android.app.model.SchemaObject import org.oppia.android.app.model.SchemaObjectList import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -45,6 +47,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: AlgebraicExpressionInputIsEquivalentToRuleClassifierProvider diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt index 624d16d2a0a..29dc3da3153 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt @@ -9,6 +9,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject @@ -16,6 +17,7 @@ import org.oppia.android.app.model.SchemaObject import org.oppia.android.app.model.SchemaObjectList import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -46,6 +48,9 @@ import org.oppia.android.domain.classify.rules.algebraicexpressioninput.DaggerAl @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProvider diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt index 5b711d3b879..a765fd77246 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt @@ -9,6 +9,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject @@ -16,6 +17,7 @@ import org.oppia.android.app.model.SchemaObject import org.oppia.android.app.model.SchemaObjectList import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -47,6 +49,9 @@ import org.oppia.android.domain.classify.rules.algebraicexpressioninput.DaggerAl @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: RuleClassifierProvider @Parameter lateinit var answer: String diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputModuleTest.kt index 81560a49781..2581dab347b 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputModuleTest.kt @@ -10,10 +10,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.domain.classify.rules.AlgebraicExpressionInputRules +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -31,6 +33,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AlgebraicExpressionInputModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Inject AlgebraicExpressionInputRules] lateinit var algebraicExpressionInputClassifiers: Map< String, @JvmSuppressWildcards RuleClassifier> diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/BUILD.bazel index 60ea68740a9..4b3bd4b96d4 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/BUILD.bazel @@ -15,6 +15,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput:algebraic_expression_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -41,6 +42,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput:algebraic_expression_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -67,6 +69,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput:algebraic_expression_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -92,6 +95,7 @@ oppia_android_test( "//:dagger", "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput:algebraic_expression_input_rule_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", 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 c7d224753c4..2259d4acd83 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 @@ -7,6 +7,7 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext @@ -14,6 +15,7 @@ import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createList import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createNonNegativeInt import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createTranslatableHtmlContentId import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -26,6 +28,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_0 = createNonNegativeInt(value = 1) private val NON_NEGATIVE_VALUE_1 = createNonNegativeInt(value = 2) 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 a40e47d06f4..930e997c3fe 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 @@ -7,6 +7,7 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext @@ -14,6 +15,7 @@ import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createList import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createNonNegativeInt import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createTranslatableHtmlContentId import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -26,6 +28,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val VALID_CONTENT_ID_1 = createTranslatableHtmlContentId(contentId = "content_id_1") private val VALID_CONTENT_ID_2 = createTranslatableHtmlContentId(contentId = "content_id_2") 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 c6783f37ca1..9e01c94ea74 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createListOfSetsOfTranslatableHtmlContentIds import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -24,6 +26,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class DragDropSortInputIsEqualToOrderingClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val ITEM_SET_1_ITEM_1 = listOf("content_id_1") private val ITEM_SET_1_ITEMS_12 = listOf("content_id_1", "content_id_2") 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 9da1c50711e..b84684d464a 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 @@ -7,12 +7,14 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createListOfSetsOfTranslatableHtmlContentIds import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createNonNegativeInt import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -25,6 +27,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_0 = createNonNegativeInt(value = 0) private val ITEM_SET_1_ITEMS_12 = listOf("content_id_1", "content_id_2") 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 c0be3182da6..c9b245109c1 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputHasDenominatorEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val WHOLE_NUMBER_VALUE_TEST_123 = InteractionObjectTestBuilder.createWholeNumber( 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 d5d95ca9253..088dc47cbcd 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_TEST_0 = InteractionObjectTestBuilder.createNonNegativeInt( 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 c1212a3a082..e7b6a1fa0ac 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputHasIntegerPartEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val FRACTION_VALUE_TEST_1_OVER_2 = InteractionObjectTestBuilder.createFraction( diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNoFractionalPartRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNoFractionalPartRuleClassifierProviderTest.kt index cb72a6d9b50..ecc99cdd793 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNoFractionalPartRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNoFractionalPartRuleClassifierProviderTest.kt @@ -7,12 +7,14 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputHasNoFractionalPartRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val WHOLE_NUMBER_VALUE_TEST_123 = InteractionObjectTestBuilder.createWholeNumber( 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 bc4bb343c03..8ddb4e1d40c 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputHasNumeratorEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_TEST_0 = InteractionObjectTestBuilder.createNonNegativeInt( 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 8a2d65bf340..f31feb9af30 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val WHOLE_NUMBER_VALUE_TEST_5 = InteractionObjectTestBuilder.createWholeNumber( 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 4788fa0e9d9..4d543ead2e7 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -21,6 +23,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputIsEquivalentToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val WHOLE_NUMBER_VALUE_TEST_123 = InteractionObjectTestBuilder.createWholeNumber( 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 67f4cdba623..f04ac1337dd 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputIsExactlyEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_TEST_0 = InteractionObjectTestBuilder.createNonNegativeInt( 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 aecd631ac68..4dfe408c6bb 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputIsGreaterThanRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val FRACTION_VALUE_TEST_1_OVER_3 = InteractionObjectTestBuilder.createFraction( 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 03a00646b82..0f5ec64eb83 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FractionInputIsLessThanRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val FRACTION_VALUE_TEST_1_OVER_3 = InteractionObjectTestBuilder.createFraction( 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 565da313100..a6b0a0c9c33 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 @@ -7,6 +7,7 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ClickOnImage @@ -14,6 +15,7 @@ import org.oppia.android.app.model.InteractionObject import org.oppia.android.app.model.Point2d import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class ImageClickInputIsInRegionRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + private val NON_NEGATIVE_VALUE_0 = createNonNegativeInt(value = 0) private val ITEM_REGION_A = "a" private val ITEM_REGION_B = "b" diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputContainsAtLeastOneOfRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputContainsAtLeastOneOfRuleClassifierProviderTest.kt index e182692d80b..d19cdc73bff 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputContainsAtLeastOneOfRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputContainsAtLeastOneOfRuleClassifierProviderTest.kt @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createSetOfTranslatableHtmlContentIds +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class ItemSelectionInputContainsAtLeastOneOfRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val ITEM_SELECTION_12345 = createSetOfTranslatableHtmlContentIds("test1", "test2", "test3", "test4", "test5") 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 b6eedff3056..313f627180c 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createInt import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createSetOfTranslatableHtmlContentIds +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -24,6 +26,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val ITEM_SET_12345 = createSetOfTranslatableHtmlContentIds("test1", "test2", "test3", "test4", "test5") 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 a3c467dcbdc..4a98d4db6c6 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createSetOfTranslatableHtmlContentIds import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -24,6 +26,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class ItemSelectionInputEqualsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val TEST_HTML_STRING_SET_LOWERCASE = createSetOfTranslatableHtmlContentIds("item ab") private val TEST_HTML_STRING_SET_UPPERCASE = createSetOfTranslatableHtmlContentIds("item AB") 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 a4d3a9fadb4..ba68eb73eb7 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createSetOfTranslatableHtmlContentIds import org.oppia.android.domain.classify.InteractionObjectTestBuilder.createString +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -24,6 +26,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest() { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val ITEM_SELECTION_12345 = createSetOfTranslatableHtmlContentIds("test1", "test2", "test3", "test4", "test5") diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/BUILD.bazel index 8170eefb44e..0979f957e89 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/BUILD.bazel @@ -15,6 +15,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/mathequationinput:math_equation_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -41,6 +42,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/mathequationinput:math_equation_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -67,6 +69,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/mathequationinput:math_equation_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -92,6 +95,7 @@ oppia_android_test( "//:dagger", "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/mathequationinput:math_equation_input_rule_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", diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputIsEquivalentToRuleClassifierProviderTest.kt index 9435187bb25..eb57638c91d 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputIsEquivalentToRuleClassifierProviderTest.kt @@ -9,6 +9,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject @@ -16,6 +17,7 @@ import org.oppia.android.app.model.SchemaObject import org.oppia.android.app.model.SchemaObjectList import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -45,6 +47,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MathEquationInputIsEquivalentToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: MathEquationInputIsEquivalentToRuleClassifierProvider diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesExactlyWithRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesExactlyWithRuleClassifierProviderTest.kt index 22a7444050a..b1f445c0c75 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesExactlyWithRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesExactlyWithRuleClassifierProviderTest.kt @@ -9,6 +9,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject @@ -16,6 +17,7 @@ import org.oppia.android.app.model.SchemaObject import org.oppia.android.app.model.SchemaObjectList import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -45,6 +47,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: MathEquationInputMatchesExactlyWithRuleClassifierProvider diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt index 9a3d9d24c05..90834134f19 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt @@ -9,6 +9,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject @@ -16,6 +17,7 @@ import org.oppia.android.app.model.SchemaObject import org.oppia.android.app.model.SchemaObjectList import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -47,6 +49,9 @@ import org.oppia.android.domain.classify.rules.mathequationinput.MathEquationInp @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: RuleClassifierProvider @Parameter lateinit var answer: String diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputModuleTest.kt index 4958d6d0fb4..90961a8f6e3 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputModuleTest.kt @@ -10,10 +10,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.domain.classify.rules.MathEquationInputRules +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -31,6 +33,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MathEquationInputModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Inject MathEquationInputRules] lateinit var mathEquationInputClassifiers: Map< String, @JvmSuppressWildcards RuleClassifier> 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 c66ab000848..4968fdccd00 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MultipleChoiceInputEqualsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_TEST_0 = InteractionObjectTestBuilder.createNonNegativeInt(value = 0) 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 ee150667497..d904006f6a3 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumberWithUnitsIsEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val WHOLE_NUMBER_VALUE_9 = InteractionObjectTestBuilder.createWholeNumber( 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 4e6ed68a7e7..d8c37b2c607 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumberWithUnitsIsEquivalentToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val FRACTION_VALUE_TEST_1_OVER_2 = InteractionObjectTestBuilder.createFraction( diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/BUILD.bazel index aebbea64f41..0be5f86599f 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/BUILD.bazel @@ -15,6 +15,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/numericexpressioninput:numeric_expression_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -41,6 +42,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/numericexpressioninput:numeric_expression_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -67,6 +69,7 @@ oppia_android_test( "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/numericexpressioninput:numeric_expression_input_providers", "//model/src/main/proto:interaction_object_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", @@ -92,6 +95,7 @@ oppia_android_test( "//:dagger", "//domain", "//domain/src/main/java/org/oppia/android/domain/classify/rules/numericexpressioninput:numeric_expression_input_rule_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", diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputIsEquivalentToRuleClassifierProviderTest.kt index 7a0f3a1b6c2..6f9db1601c8 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputIsEquivalentToRuleClassifierProviderTest.kt @@ -9,11 +9,13 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -43,6 +45,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: NumericExpressionInputIsEquivalentToRuleClassifierProvider diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt index bf48dd05303..bab96eb63f8 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt @@ -9,11 +9,13 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -44,6 +46,9 @@ import org.oppia.android.domain.classify.rules.numericexpressioninput.DaggerNume @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: NumericExpressionInputMatchesExactlyWithRuleClassifierProvider diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt index d4ad34e873a..d57ac6d3b89 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt @@ -9,11 +9,13 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.InteractionObject import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -45,6 +47,9 @@ import org.oppia.android.domain.classify.rules.numericexpressioninput.NumericExp @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var provider: RuleClassifierProvider @Parameter lateinit var answer: String diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputModuleTest.kt index 9a5b411670d..646502ea1b5 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputModuleTest.kt @@ -10,10 +10,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.domain.classify.rules.NumericExpressionInputRules +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -31,6 +33,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericExpressionInputModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Inject NumericExpressionInputRules] lateinit var numericExpressionInputClassifiers: Map 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 daa27f53145..f61d2948f09 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.util.math.DOUBLE_EQUALITY_EPSILON import org.robolectric.annotation.Config @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericInputEqualsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val POSITIVE_REAL_VALUE_1_5 = InteractionObjectTestBuilder.createReal(value = 1.5) 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 95bab873ae0..b40d245c545 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val POSITIVE_REAL_VALUE_1_5 = InteractionObjectTestBuilder.createReal(value = 1.5) 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 d488eba6b5a..789c73eeaec 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericInputIsGreaterThanRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val POSITIVE_REAL_VALUE_1_5 = InteractionObjectTestBuilder.createReal(value = 1.5) 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 948327a4ec9..d2d9b6b6f3d 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val POSITIVE_REAL_VALUE_1_5 = InteractionObjectTestBuilder.createReal(value = 1.5) 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 90cba1612af..29853223857 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val POSITIVE_REAL_VALUE_1_5 = InteractionObjectTestBuilder.createReal(value = 1.5) 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 e1819859a89..5bedaa9e598 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericInputIsLessThanRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val POSITIVE_REAL_VALUE_1_5 = InteractionObjectTestBuilder.createReal(value = 1.5) 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 710210dcc39..4749d231399 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 @@ -7,10 +7,12 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -22,6 +24,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NumericInputIsWithinToleranceRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val POSITIVE_REAL_VALUE_1_5 = InteractionObjectTestBuilder.createReal(value = 1.5) 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 07945a20691..a53284d27df 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class RatioInputEqualsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_TEST_0 = InteractionObjectTestBuilder.createNonNegativeInt( 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 a8c1b27243c..f0112c1c7d6 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_TEST_3 = InteractionObjectTestBuilder.createNonNegativeInt( 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 14101f1d79e..66e2f1b0d43 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject internal lateinit var ratioInputHasSpecificTermEqualToRuleClassifierProvider: RatioInputHasSpecificTermEqualToRuleClassifierProvider 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 09fdeb952bb..7fe71c9bc3a 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 @@ -7,11 +7,13 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext import org.oppia.android.domain.classify.InteractionObjectTestBuilder import org.oppia.android.domain.classify.RuleClassifier +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class RatioInputIsEquivalentRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NON_NEGATIVE_VALUE_TEST_0 = InteractionObjectTestBuilder.createNonNegativeInt( 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 1c258aec94e..c4ff2e8df78 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 @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext @@ -23,6 +24,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule @@ -44,6 +46,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class TextInputContainsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val STRING_VALUE_TEST_ANSWER_NULL = createString(value = "") private val STRING_VALUE_IS_ANSWER = createString(value = "is") 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 6c5c53471c2..5f5e649d4ac 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 @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext @@ -23,6 +24,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule @@ -44,6 +46,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class TextInputEqualsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val STRING_VALUE_TEST_UPPERCASE = createString(value = "TEST") private val STRING_VALUE_TEST_LOWERCASE = createString(value = "test") 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 3bb592d1499..4250aa4939d 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 @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext @@ -23,6 +24,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule @@ -44,6 +46,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class TextInputFuzzyEqualsRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val STRING_VALUE_TEST_ANSWER_UPPERCASE = createString(value = "TEST") private val STRING_VALUE_TEST_ANSWER_LOWERCASE = createString(value = "test") 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 60ea011ad34..3a15a4f0fe1 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 @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.classify.ClassificationContext @@ -23,6 +24,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule @@ -44,6 +46,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class TextInputStartsWithRuleClassifierProviderTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val STRING_VALUE_TEST_STRING_LOWERCASE = createString(value = "test string") private val STRING_VALUE_TEST_LOWERCASE = createString(value = "test") diff --git a/domain/src/test/java/org/oppia/android/domain/classroom/ClassroomControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/classroom/ClassroomControllerTest.kt index 6c1cee650bf..288a4c34ada 100644 --- a/domain/src/test/java/org/oppia/android/domain/classroom/ClassroomControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classroom/ClassroomControllerTest.kt @@ -17,17 +17,18 @@ import org.oppia.android.app.model.ProfileId import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.topic.TEST_TOPIC_ID_1 import org.oppia.android.domain.topic.TEST_TOPIC_ID_2 +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.OppiaTestRule 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.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -46,6 +47,7 @@ import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.image.DefaultGcsPrefix import org.oppia.android.util.parser.image.ImageDownloadUrlTemplate +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -57,6 +59,7 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ClassroomControllerTest.TestApplication::class) +@EnableFeatureFlag(FeatureFlag.ENABLE_MULTIPLE_CLASSROOMS) class ClassroomControllerTest { @get:Rule val oppiaTestRule = OppiaTestRule() @@ -72,7 +75,6 @@ class ClassroomControllerTest { @Before fun setUp() { profileId0 = ProfileId.newBuilder().setInternalId(0).build() - TestPlatformParameterModule.forceEnableMultipleClassrooms(true) setUpTestApplicationComponent() } @@ -381,7 +383,7 @@ class ClassroomControllerTest { TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, LoggingIdentifierModule::class, ApplicationLifecycleModule::class, - SyncStatusModule::class, TestPlatformParameterModule::class, + SyncStatusModule::class, PlatformParameterModule::class, PlatformParameterSingletonModule::class ] ) diff --git a/domain/src/test/java/org/oppia/android/domain/clipboard/ClipboardControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/clipboard/ClipboardControllerTest.kt index f508418b833..ee653009521 100644 --- a/domain/src/test/java/org/oppia/android/domain/clipboard/ClipboardControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/clipboard/ClipboardControllerTest.kt @@ -12,12 +12,14 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.clipboard.ClipboardController.CurrentClip import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.logging.SyncStatusTestModule @@ -49,6 +51,9 @@ class ClipboardControllerTest { private const val TEST_TEXT_FROM_OTHER_APP_2 = "test text to copy from another app two" } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var clipboardController: ClipboardController @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory diff --git a/domain/src/test/java/org/oppia/android/domain/devoptions/ModifyLessonProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/devoptions/ModifyLessonProgressControllerTest.kt index 8039a9d77de..3c38ed1c70f 100644 --- a/domain/src/test/java/org/oppia/android/domain/devoptions/ModifyLessonProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/devoptions/ModifyLessonProgressControllerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ChapterPlayState @@ -21,6 +22,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig @@ -72,6 +74,9 @@ class ModifyLessonProgressControllerTest { private const val FRACTIONS_EXPLORATION_ID_1 = "MjZzEVOG47_1" } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var storyProgressTestHelper: StoryProgressTestHelper @Inject lateinit var modifyLessonProgressController: ModifyLessonProgressController @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers diff --git a/domain/src/test/java/org/oppia/android/domain/devoptions/ShowAllHintsAndSolutionControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/devoptions/ShowAllHintsAndSolutionControllerTest.kt index 37a6585c751..a566931c9d7 100644 --- a/domain/src/test/java/org/oppia/android/domain/devoptions/ShowAllHintsAndSolutionControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/devoptions/ShowAllHintsAndSolutionControllerTest.kt @@ -10,12 +10,14 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.util.logging.SyncStatusModule import org.robolectric.annotation.Config @@ -28,6 +30,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ShowAllHintsAndSolutionControllerTest.TestApplication::class) class ShowAllHintsAndSolutionControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var showAllHintsAndSolutionController: ShowAllHintsAndSolutionController diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/exploration/BUILD.bazel index c292a5d8c1f..c4b8ac7d687 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/exploration/BUILD.bazel @@ -152,7 +152,6 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -198,7 +197,6 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", 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 5de6ae1179c..bfbc4315e35 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 @@ -9,7 +9,7 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides -import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ProfileId @@ -36,16 +36,18 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleObserver import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_2 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.topic.TEST_TOPIC_ID_1 +import org.oppia.android.testing.EnableFeatureFlag +import org.oppia.android.testing.OppiaTestRule 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.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -62,6 +64,7 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.util.concurrent.TimeUnit @@ -76,7 +79,11 @@ private const val SESSION_LENGTH_3 = 100000L @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ExplorationActiveTimeControllerTest.TestApplication::class) +@EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) class ExplorationActiveTimeControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @@ -98,11 +105,6 @@ class ExplorationActiveTimeControllerTest { private val firstTestProfile = ProfileId.newBuilder().setInternalId(0).build() private val secondTestProfile = ProfileId.newBuilder().setInternalId(1).build() - @Before - fun setUp() { - TestPlatformParameterModule.forceEnableNpsSurvey(true) - } - @Test fun testSessionTimer_explorationStartedCallbackReceived_startsSessionTimer() { setUpTestApplicationComponent() @@ -562,7 +564,7 @@ class ExplorationActiveTimeControllerTest { AlgebraicExpressionInputModule::class, MathEquationInputModule::class, RatioInputModule::class, SyncStatusModule::class, LoggingIdentifierModule::class, CpuPerformanceSnapshotterModule::class, PlatformParameterSingletonModule::class, - TestPlatformParameterModule::class, ExplorationStorageTestModule::class, + PlatformParameterModule::class, ExplorationStorageTestModule::class, LogStorageModule::class ] ) 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 9e6e7e78b5e..fc1f7e83601 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 @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ExplorationCheckpoint @@ -51,6 +52,7 @@ 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig @@ -83,6 +85,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ExplorationDataControllerTest.TestApplication::class) class ExplorationDataControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var explorationDataController: ExplorationDataController @Inject lateinit var fakeExceptionLogger: FakeExceptionLogger @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers 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 ad42696a603..b925c936393 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 @@ -71,6 +71,7 @@ import org.oppia.android.domain.hintsandsolution.isSolutionRevealed import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_0 @@ -86,6 +87,7 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_1 import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.util.toAnswerString import org.oppia.android.testing.BuildEnvironment +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.OppiaTestRule @@ -113,11 +115,7 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics -import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds -import org.oppia.android.util.platformparameter.EnableNpsSurvey -import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 -import org.oppia.android.util.platformparameter.PlatformParameterValue +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.util.Locale @@ -2239,6 +2237,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlayNewExploration_logsStartCardEvent() { logIntoAnalyticsReadyAdminProfile() @@ -2258,6 +2257,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testResumeExploration_logsResumeExplorationEventAndNotStartCardEvent() { logIntoAnalyticsReadyAdminProfile() val checkpoint = createTestExp2CheckpointToState6() @@ -2278,6 +2278,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testStartOverExploration_logsStartCardAndStartOverEvents() { logIntoAnalyticsReadyAdminProfile() createTestExp2CheckpointToState6() @@ -2303,6 +2304,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlayExplorationAgain_logsStartCardEvent() { logIntoAnalyticsReadyAdminProfile() createTestExp2CheckpointToState6() @@ -2473,6 +2475,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testPlayNewExp_logsStartExplorationEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -2761,6 +2764,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testSubmitAnswer_correctAnswer_logsEndCardAndSubmitAnswerEvents() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -2787,6 +2791,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testSubmitAnswer_wrongAnswer_logsSubmitAnswerEvent_logsProgressSavingSuccessEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -2811,6 +2816,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testMoveToNextState_logsStartCardEvent_logsProgressSavingSuccessEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -2835,6 +2841,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testHint_offered_logsHintOfferedEvent_logsProgressSavingSuccessEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -2869,6 +2876,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testHint_offeredThenViewed_logsRevealedHint_logsPgrssSavSuccEvent_logsExtingHintViwdEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -2903,6 +2911,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testHint_existingHintViewed_logsExistingHintViewedEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -2931,6 +2940,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testHint_lastHintWithNoSolution_offered_logsHintOfferedEvent_logsProgressSavingSuccessEvt() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -2970,6 +2980,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testHint_lastHintWithNoSol_offeredThenViewed_logsRevealedHintEvt_logsPgrssSavingSucssEvt() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -3003,6 +3014,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testSolution_offered_logsSolutionOfferedEvent_logsProgressSavingSuccessEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -3030,6 +3042,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testSolution_offeredThenViewed_logsViewSolutionEvent_logsProgressSavingSuccessEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -3068,6 +3081,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testSolution_viewExistingSolution_logsExistingSolutionViewedEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -3102,6 +3116,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testEndExploration_withoutFinishing_logsExitExplorationEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -3117,6 +3132,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testEndExploration_afterFinishing_logsFinishExplorationEvent() { logIntoAnalyticsReadyAdminProfile() startPlayingNewExploration( @@ -3157,6 +3173,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testUpdateLanguageMidLesson_englishToSwahili_logsLanguageSwitchEvent() { logIntoAnalyticsReadyAdminProfile() updateContentLanguage(profileId, OppiaLanguage.ENGLISH) @@ -3238,6 +3255,7 @@ class ExplorationProgressControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testUpdateLanguageMidLesson_swahiliToEnglish_logsLanguageSwitchEvent() { logIntoAnalyticsReadyAdminProfile() updateContentLanguage(profileId, OppiaLanguage.SWAHILI) @@ -3849,32 +3867,6 @@ class ExplorationProgressControllerTest { @LoadLessonProtosFromAssets fun provideLoadLessonProtosFromAssets(testEnvironmentConfig: TestEnvironmentConfig): Boolean = testEnvironmentConfig.isUsingBazel() - - @Provides - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics(): PlatformParameterValue { - // Enable the study by default in tests. - return PlatformParameterValue.createDefaultParameter(defaultValue = true) - } - - @Provides - @EnableLoggingLearnerStudyIds - fun provideLoggingLearnerStudyIds(): PlatformParameterValue { - // Enable study IDs by default in tests. - return PlatformParameterValue.createDefaultParameter(defaultValue = true) - } - - @Provides - @EnableNpsSurvey - fun provideEnableNpsSurvey(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(defaultValue = true) - } - - @Provides - @EnableOnboardingFlowV2 - fun provideEnableOnboardingFlowV2(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(defaultValue = true) - } } // TODO(#89): Move this to a common test application component. @@ -3893,7 +3885,8 @@ class ExplorationProgressControllerTest { AlgebraicExpressionInputModule::class, MathEquationInputModule::class, LoggingIdentifierModule::class, ApplicationLifecycleModule::class, SyncStatusModule::class, PlatformParameterSingletonModule::class, - ExplorationProgressModule::class, TestAuthenticationModule::class + ExplorationProgressModule::class, TestAuthenticationModule::class, + PlatformParameterModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressModuleTest.kt index eea2f6708ee..60a35489f53 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressModuleTest.kt @@ -11,12 +11,15 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.exploration.testing.ExplorationStorageTestModule import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -40,6 +43,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ExplorationProgressModuleTest.TestApplication::class) class ExplorationProgressModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var progressListeners: Set<@JvmSuppressWildcards ExplorationProgressListener> @@ -87,7 +93,7 @@ class ExplorationProgressModuleTest { FakeOppiaClockModule::class, ExplorationProgressModule::class, TestDispatcherModule::class, LocaleProdModule::class, TestLogReportingModule::class, LogStorageModule::class, NetworkConnectionUtilDebugModule::class, ExplorationStorageTestModule::class, - TestPlatformParameterModule::class + PlatformParameterModule::class, PlatformParameterSingletonModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationStorageModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationStorageModuleTest.kt index 589c9fed830..df5ea29b2ba 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationStorageModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationStorageModuleTest.kt @@ -21,6 +21,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.robolectric.RobolectricModule @@ -49,6 +50,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ExplorationStorageModuleTest.TestApplication::class) class ExplorationStorageModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() @field:[Inject JvmField ExplorationStorageDatabaseSize] var databaseSize: Int = Int.MIN_VALUE 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 864af6b2745..daccd9b3dd9 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 @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.CheckpointState @@ -49,6 +50,7 @@ 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig @@ -108,6 +110,9 @@ private const val TEST_CHECKPOINTING_FAKE_EXP_ID = "test_checkpointing_fake_expl @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ExplorationCheckpointControllerTest.TestApplication::class) class ExplorationCheckpointControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var context: Context @Inject lateinit var fakeOppiaClock: FakeOppiaClock diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/testing/ExplorationStorageTestModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/testing/ExplorationStorageTestModuleTest.kt index f7351b8d327..7cc325980a6 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/testing/ExplorationStorageTestModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/testing/ExplorationStorageTestModuleTest.kt @@ -22,6 +22,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.robolectric.RobolectricModule @@ -50,6 +51,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ExplorationStorageTestModuleTest.TestApplication::class) class ExplorationStorageTestModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() @field:[Inject JvmField ExplorationStorageDatabaseSize] var databaseSize: Int = Int.MIN_VALUE 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 6d8ed9c82fa..278c8ca0007 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 @@ -18,6 +18,7 @@ import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule 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.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.robolectric.RobolectricModule @@ -39,6 +40,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FakeExplorationRetrieverTest.TestApplication::class) class FakeExplorationRetrieverTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() @Inject lateinit var fakeExplorationRetriever: FakeExplorationRetriever diff --git a/domain/src/test/java/org/oppia/android/domain/feedbackreporting/ReportSchemaVersionTest.kt b/domain/src/test/java/org/oppia/android/domain/feedbackreporting/ReportSchemaVersionTest.kt index 027e0de0f3d..34540b1d216 100644 --- a/domain/src/test/java/org/oppia/android/domain/feedbackreporting/ReportSchemaVersionTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/feedbackreporting/ReportSchemaVersionTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.data.backends.gae.model.GaeFeedbackReport @@ -22,6 +23,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -38,6 +40,8 @@ import kotlin.reflect.KCallable @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class ReportSchemaVersionTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @JvmField @field:[Inject ReportSchemaVersion] diff --git a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HelpIndexExtensionsTest.kt b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HelpIndexExtensionsTest.kt index 40534449c0a..6a3c0b94a7f 100644 --- a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HelpIndexExtensionsTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HelpIndexExtensionsTest.kt @@ -2,11 +2,13 @@ package org.oppia.android.domain.hintsandsolution import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.HelpIndex import org.oppia.android.app.model.Hint import org.oppia.android.app.model.SubtitledHtml +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -27,6 +29,9 @@ class HelpIndexExtensionsTest { private val HINT_LIST_OF_SIZE_3 = HINT_LIST_OF_SIZE_2 + HINT_2 } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testIsHintRevealed_defaultHelpIndex_returnsFalse() { val helpIndex = HelpIndex.getDefaultInstance() diff --git a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerDebugImplTest.kt b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerDebugImplTest.kt index 5d9ac5269d5..70c75493433 100644 --- a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerDebugImplTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerDebugImplTest.kt @@ -33,6 +33,7 @@ import org.oppia.android.app.model.State import org.oppia.android.domain.devoptions.ShowAllHintsAndSolutionController import org.oppia.android.domain.exploration.ExplorationRetriever import org.oppia.android.domain.exploration.testing.ExplorationStorageTestModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.robolectric.RobolectricModule @@ -57,6 +58,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = HintHandlerDebugImplTest.TestApplication::class) class HintHandlerDebugImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() 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 93edcf5c43e..0c5cec1c81e 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 @@ -32,6 +32,7 @@ import org.oppia.android.app.model.HelpIndex import org.oppia.android.app.model.State import org.oppia.android.domain.exploration.ExplorationRetriever import org.oppia.android.domain.exploration.testing.ExplorationStorageTestModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.environment.TestEnvironmentConfig @@ -58,6 +59,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = HintHandlerProdImplTest.TestApplication::class) class HintHandlerProdImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionDebugModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionDebugModuleTest.kt index edbee8a92f2..b57e55cae64 100644 --- a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionDebugModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionDebugModuleTest.kt @@ -11,9 +11,11 @@ import dagger.Component import dagger.Module import kotlinx.coroutines.ObsoleteCoroutinesApi import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.hintsandsolution.HintHandlerDebugImpl.FactoryDebugImpl +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -30,6 +32,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = HintsAndSolutionDebugModuleTest.TestApplication::class) class HintsAndSolutionDebugModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var hintHandlerFactory: HintHandler.Factory diff --git a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionProdModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionProdModuleTest.kt index 6277dfa2eaf..6b5f31f79af 100644 --- a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionProdModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionProdModuleTest.kt @@ -10,8 +10,10 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -28,6 +30,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = HintsAndSolutionProdModuleTest.TestApplication::class) class HintsAndSolutionProdModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var hintHandlerFactory: HintHandler.Factory diff --git a/domain/src/test/java/org/oppia/android/domain/locale/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/locale/BUILD.bazel index 7b02bf08e9c..f98a8ac2276 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/locale/BUILD.bazel @@ -15,6 +15,7 @@ oppia_android_test( "//config/src/java/org/oppia/android/config:all_languages_config", "//domain/src/main/java/org/oppia/android/domain/locale:content_locale_impl", "//model/src/main/proto:languages_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", "//third_party:com_google_truth_truth", @@ -34,6 +35,7 @@ oppia_android_test( "//:dagger", "//config/src/java/org/oppia/android/config:all_languages_config", "//domain/src/main/java/org/oppia/android/domain/locale:language_config_retriever", + "//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", @@ -59,6 +61,7 @@ oppia_android_test( "//:dagger", "//config/src/java/org/oppia/android/config:production_languages_config", "//domain/src/main/java/org/oppia/android/domain/locale:language_config_retriever", + "//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", @@ -84,6 +87,7 @@ oppia_android_test( "//:dagger", "//config/src/java/org/oppia/android/config:all_languages_config", "//domain/src/main/java/org/oppia/android/domain/locale:language_config_retriever", + "//testing", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", "//third_party:androidx_test_ext_junit", diff --git a/domain/src/test/java/org/oppia/android/domain/locale/ContentLocaleImplTest.kt b/domain/src/test/java/org/oppia/android/domain/locale/ContentLocaleImplTest.kt index ad9ad675268..812522c1cc2 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/ContentLocaleImplTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/locale/ContentLocaleImplTest.kt @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.LanguageSupportDefinition @@ -18,6 +19,7 @@ import org.oppia.android.app.model.OppiaLanguage 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.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Singleton @@ -35,6 +37,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class ContentLocaleImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Before fun setUp() { setUpTestApplicationComponent() diff --git a/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverProductionTest.kt b/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverProductionTest.kt index 5f2e49fab4b..5e5445bbe95 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverProductionTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverProductionTest.kt @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.LanguageSupportDefinition @@ -19,6 +20,7 @@ import org.oppia.android.app.model.OppiaRegion import org.oppia.android.app.model.RegionSupportDefinition import org.oppia.android.app.model.SupportedLanguages import org.oppia.android.app.model.SupportedRegions +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -40,6 +42,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class LanguageConfigRetrieverProductionTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var languageConfigRetriever: LanguageConfigRetriever @Before diff --git a/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverTest.kt b/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverTest.kt index aeae202724f..e03292ff9cf 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverTest.kt @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.LanguageSupportDefinition @@ -19,6 +20,7 @@ import org.oppia.android.app.model.OppiaRegion import org.oppia.android.app.model.RegionSupportDefinition import org.oppia.android.app.model.SupportedLanguages import org.oppia.android.app.model.SupportedRegions +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -41,6 +43,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class LanguageConfigRetrieverTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var languageConfigRetriever: LanguageConfigRetriever @Before diff --git a/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverWithoutAssetsTest.kt b/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverWithoutAssetsTest.kt index ff5b65014d5..b1345a9d2a4 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverWithoutAssetsTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/locale/LanguageConfigRetrieverWithoutAssetsTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.util.caching.testing.AssetTestNoOpModule @@ -33,6 +35,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class LanguageConfigRetrieverWithoutAssetsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var languageConfigRetriever: LanguageConfigRetriever 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 9a5eb36e8cc..b5a9a2da915 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 @@ -35,6 +35,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.DataProviderTestMonitor @@ -69,6 +70,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = LocaleControllerTest.TestApplication::class) class LocaleControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt index 64aafa421d5..686a5c81050 100644 --- a/domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt @@ -12,6 +12,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AppStartupState.BuildFlavorNoticeMode.FLAVOR_NOTICE_MODE_UNSPECIFIED @@ -43,6 +44,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterController import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.junit.OppiaParameterizedTestRunner @@ -85,6 +87,9 @@ import javax.inject.Singleton @SelectRunnerPlatform(ParameterizedRobolectricTestRunner::class) @Config(application = AppStartupStateControllerTest.TestApplication::class) class AppStartupStateControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var appStartupStateController: AppStartupStateController @Inject lateinit var platformParameterController: PlatformParameterController diff --git a/domain/src/test/java/org/oppia/android/domain/onboarding/DeprecationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/onboarding/DeprecationControllerTest.kt index ddec4a04d86..b96118e4518 100644 --- a/domain/src/test/java/org/oppia/android/domain/onboarding/DeprecationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/onboarding/DeprecationControllerTest.kt @@ -11,6 +11,7 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AppStartupState.StartupMode @@ -28,6 +29,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterController import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.junit.OppiaParameterizedTestRunner @@ -67,6 +69,9 @@ import javax.inject.Singleton @SelectRunnerPlatform(ParameterizedRobolectricTestRunner::class) @Config(application = DeprecationControllerTest.TestApplication::class) class DeprecationControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var deprecationController: DeprecationController @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers 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 b44cba6a347..555e9c41f68 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 @@ -19,11 +19,14 @@ import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.DeviceContextDatabase import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.robolectric.RobolectricModule @@ -42,12 +45,6 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics -import org.oppia.android.util.platformparameter.PlatformParameterValue -import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg -import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours import org.oppia.android.util.threading.BackgroundDispatcher import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -65,6 +62,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = LoggingIdentifierControllerTest.TestApplication::class) class LoggingIdentifierControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var loggingIdentifierController: LoggingIdentifierController @Inject lateinit var asyncDataSubscriptionManager: AsyncDataSubscriptionManager @Inject lateinit var context: Context @@ -460,34 +460,6 @@ class LoggingIdentifierControllerTest { fun provideApplicationIdSeed(): Long = applicationIdSeed!! // Fail if not initialized. } - @Module - class TestPlatformParameterModule { - - companion object { - var forceLearnerAnalyticsStudy: Boolean = false - } - - @Provides - @SplashScreenWelcomeMsg - fun provideSplashScreenWelcomeMsgParam(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE) - } - - @Provides - @SyncUpWorkerTimePeriodHours - fun provideSyncUpWorkerTimePeriod(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE - ) - } - - @Provides - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(forceLearnerAnalyticsStudy) - } - } - // TODO(#89): Move this to a common test application component. @Singleton @Component( @@ -495,7 +467,7 @@ class LoggingIdentifierControllerTest { TestModule::class, TestLogReportingModule::class, TestLogStorageModule::class, TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestLoggingIdentifierModule::class, ApplicationLifecycleModule::class, SyncStatusModule::class ] ) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierModuleTest.kt index 627db547a66..5c96b806bcd 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.system.OppiaClock import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -29,6 +31,9 @@ class LoggingIdentifierModuleTest { private const val FIXED_CURRENT_TIME_MS = 12345L } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[JvmField Inject ApplicationIdSeed] var applicationIdSeed: Long = Long.MIN_VALUE @Before diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt index 4da145e5a91..f2f35e8dbbd 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt @@ -11,6 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.APP_IN_FOREGROUND_TIME @@ -38,6 +39,7 @@ import org.oppia.android.app.model.ProfileId import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -113,6 +115,9 @@ class OppiaLoggerTest { private val TEST_PROFILE_ID = ProfileId.newBuilder().setInternalId(0).build() } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var oppiaLogger: OppiaLogger diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt index 3017b830a39..c99460979c4 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt @@ -16,6 +16,8 @@ import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import org.junit.Assert.fail +import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AppLanguageSelection @@ -34,17 +36,19 @@ import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.OppiaLogger import org.oppia.android.domain.oppialogger.PerformanceMetricsLogStorageCacheSize +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.translation.TranslationController +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.logging.TestSyncStatusManager -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -67,6 +71,7 @@ import org.oppia.android.util.networking.NetworkConnectionDebugUtil import org.oppia.android.util.networking.NetworkConnectionUtil.ProdConnectionStatus.LOCAL import org.oppia.android.util.networking.NetworkConnectionUtil.ProdConnectionStatus.NONE import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.system.OppiaClock import org.oppia.android.util.threading.BackgroundDispatcher import org.robolectric.annotation.Config @@ -94,6 +99,9 @@ private const val TEST_SUB_TOPIC_ID = 1 @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AnalyticsControllerTest.TestApplication::class) class AnalyticsControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var analyticsControllerProvider: Provider @Inject lateinit var oppiaLogger: OppiaLogger @Inject lateinit var networkConnectionUtil: NetworkConnectionDebugUtil @@ -113,9 +121,13 @@ class AnalyticsControllerTest { private val profileManagementController by lazy { profileManagementControllerProvider.get() } private val analyticsController by lazy { analyticsControllerProvider.get() } + @Before + fun setUp() { + setUpTestApplicationComponent() + } + @Test fun testController_logImportantEvent_withQuestionContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenQuestionPlayerContext( TEST_QUESTION_ID, @@ -136,7 +148,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withExplorationContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenExplorationActivityContext( TEST_CLASSROOM_ID, @@ -157,7 +168,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withOpenInfoTabContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenInfoTabContext(TEST_TOPIC_ID), profileId = null, TEST_TIMESTAMP ) @@ -171,7 +181,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withOpenPracticeTabContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenPracticeTabContext(TEST_TOPIC_ID), profileId = null, TEST_TIMESTAMP ) @@ -185,7 +194,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withOpenLessonsTabContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenLessonsTabContext(TEST_TOPIC_ID), profileId = null, TEST_TIMESTAMP ) @@ -199,7 +207,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withOpenRevisionTabContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenRevisionTabContext(TEST_TOPIC_ID), profileId = null, TEST_TIMESTAMP ) @@ -213,7 +220,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withStoryContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenStoryActivityContext(TEST_TOPIC_ID, TEST_STORY_ID), profileId = null, @@ -229,7 +235,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withRevisionContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenRevisionCardContext(TEST_TOPIC_ID, TEST_SUB_TOPIC_ID), profileId = null, @@ -245,7 +250,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withConceptCardContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenConceptCardContext(TEST_SKILL_ID), profileId = null, TEST_TIMESTAMP ) @@ -259,7 +263,6 @@ class AnalyticsControllerTest { @Test fun testLogImportantEvent_forOpenHomeEvent_logsEssentialEventWithCurrentTime() { - setUpTestApplicationComponent() val openHomeEventContext = oppiaLogger.createOpenHomeContext() analyticsController.logImportantEvent(openHomeEventContext, profileId = null, TEST_TIMESTAMP) @@ -272,7 +275,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_nullProfileId_hasDefaultLanguageSettings() { - setUpTestApplicationComponent() val openHomeEventContext = oppiaLogger.createOpenHomeContext() // Create a new profile & set its language settings, but don't use it when logging an event. val profileId = addNewProfileAndLogIn() @@ -292,7 +294,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_profileWithNoLangSettings_hasDefaultLanguageSettings() { - setUpTestApplicationComponent() val openHomeEventContext = oppiaLogger.createOpenHomeContext() // Create a profile without any language settings. val profileId = addNewProfileAndLogIn() @@ -310,7 +311,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_profileWithLangSettings_hasCorrectLanguageSettings() { - setUpTestApplicationComponent() val openHomeEventContext = oppiaLogger.createOpenHomeContext() val profileId = addNewProfileAndLogIn() ensureAppLanguageIsUpdatedTo(profileId, ENGLISH) @@ -335,7 +335,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_noProfile_hasNoProfileId() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenConceptCardContext(TEST_SKILL_ID), profileId = null, TEST_TIMESTAMP ) @@ -347,7 +346,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withProfile_includesProfileId() { - setUpTestApplicationComponent() val profileId = addNewProfileAndLogIn() analyticsController.logImportantEvent( oppiaLogger.createOpenConceptCardContext(TEST_SKILL_ID), profileId, TEST_TIMESTAMP @@ -361,7 +359,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withQuestionContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenQuestionPlayerContext( TEST_QUESTION_ID, @@ -382,7 +379,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withExplorationContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenExplorationActivityContext( TEST_CLASSROOM_ID, @@ -403,7 +399,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withOpenInfoTabContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenInfoTabContext(TEST_TOPIC_ID), profileId = null, TEST_TIMESTAMP ) @@ -417,7 +412,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withOpenPracticeTabContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenPracticeTabContext(TEST_TOPIC_ID), profileId = null, TEST_TIMESTAMP ) @@ -431,7 +425,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withOpenLessonsTabContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenLessonsTabContext(TEST_TOPIC_ID), profileId = null, TEST_TIMESTAMP ) @@ -445,7 +438,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withOpenRevisionTabContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenRevisionTabContext(TEST_TOPIC_ID), profileId = null, TEST_TIMESTAMP ) @@ -459,7 +451,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withStoryContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenStoryActivityContext(TEST_TOPIC_ID, TEST_STORY_ID), profileId = null, @@ -475,7 +466,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withRevisionContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenRevisionCardContext(TEST_TOPIC_ID, TEST_SUB_TOPIC_ID), profileId = null, @@ -491,7 +481,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withConceptCardContext_checkLogsEvent() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenConceptCardContext(TEST_SKILL_ID), profileId = null, TEST_TIMESTAMP ) @@ -508,7 +497,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withNoNetwork_checkLogsEventToStore() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logImportantEvent( oppiaLogger.createOpenQuestionPlayerContext( @@ -533,7 +521,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_withNoNetwork_checkLogsEventToStore() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logLowPriorityEvent( oppiaLogger.createOpenQuestionPlayerContext( @@ -558,7 +545,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_nullProfileId_hasDefaultLanguageSettings() { - setUpTestApplicationComponent() val openHomeEventContext = oppiaLogger.createOpenHomeContext() // Create a new profile & set its language settings, but don't use it when logging an event. val profileId = addNewProfileAndLogIn() @@ -578,7 +564,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_profileWithNoLangSettings_hasDefaultLanguageSettings() { - setUpTestApplicationComponent() val openHomeEventContext = oppiaLogger.createOpenHomeContext() // Create a profile without any language settings. val profileId = addNewProfileAndLogIn() @@ -596,7 +581,6 @@ class AnalyticsControllerTest { @Test fun testController_logLowPriorityEvent_profileWithLangSettings_hasCorrectLanguageSettings() { - setUpTestApplicationComponent() val openHomeEventContext = oppiaLogger.createOpenHomeContext() val profileId = addNewProfileAndLogIn() ensureAppLanguageIsUpdatedTo(profileId, ENGLISH) @@ -621,7 +605,6 @@ class AnalyticsControllerTest { @Test fun testController_logPriorityEvent_noProfile_hasNoProfileId() { - setUpTestApplicationComponent() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenConceptCardContext(TEST_SKILL_ID), profileId = null, TEST_TIMESTAMP ) @@ -633,7 +616,6 @@ class AnalyticsControllerTest { @Test fun testController_logPriorityEvent_withProfile_includesProfileId() { - setUpTestApplicationComponent() val profileId = addNewProfileAndLogIn() analyticsController.logLowPriorityEvent( oppiaLogger.createOpenConceptCardContext(TEST_SKILL_ID), profileId, TEST_TIMESTAMP @@ -647,7 +629,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_withNoNetwork_exceedLimit_checkEventLogStoreSize() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) logFourEvents() @@ -659,8 +640,8 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_logImportantEvent_withNoNetwork_exceedLimit_studyOn_checkEventLogStoreSize() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) networkConnectionUtil.setCurrentConnectionStatus(NONE) logFourEvents() @@ -673,7 +654,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_logLowPriorityEvent_withNoNetwork_checkOrderinCache() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logLowPriorityEvent( oppiaLogger.createOpenQuestionPlayerContext( @@ -710,7 +690,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_switchToNoNetwork_logLowPriorityEvent_checkManagement() { - setUpTestApplicationComponent() analyticsController.logImportantEvent( oppiaLogger.createOpenQuestionPlayerContext( TEST_QUESTION_ID, @@ -752,7 +731,6 @@ class AnalyticsControllerTest { @Test fun testController_logEvents_exceedLimit_withNoNetwork_checkCorrectEventIsEvicted() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) logFourEvents() @@ -778,9 +756,9 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_logEvent_withoutNetwork_studyOn_verifySyncStatusIsUnchanged() { // Sync statuses only make sense in the context of the learner study feature being enabled. - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logImportantEvent( oppiaLogger.createOpenQuestionPlayerContext( @@ -799,9 +777,9 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_logEvent_studyOn_verifySyncStatusChangesToRepresentLoggedEvent() { // Sync statuses only make sense in the context of the learner study feature being enabled. - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) analyticsController.logImportantEvent( oppiaLogger.createOpenQuestionPlayerContext( TEST_QUESTION_ID, @@ -821,7 +799,6 @@ class AnalyticsControllerTest { @Test fun testController_logImportantEvent_studyOff_doesNotRecordEventsAsUploaded() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = false) // The important event should be marked as uploaded. analyticsController.logImportantEvent(oppiaLogger.createOpenHomeContext(), profileId = null) testCoroutineDispatchers.runCurrent() @@ -834,9 +811,9 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_logImportantEvent_studyOn_recordsEventAsUploaded() { // Events are only tracked as uploaded when the learner study feature being enabled. - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) // The important event should be marked as uploaded. analyticsController.logImportantEvent(oppiaLogger.createOpenHomeContext(), profileId = null) testCoroutineDispatchers.runCurrent() @@ -850,7 +827,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogs_noLogs_cacheUnchanged() { - setUpTestApplicationComponent() val monitor = monitorFactory.createMonitor(analyticsController.getEventLogStore()) monitorFactory.ensureDataProviderExecutes(analyticsController.uploadEventLogs()) @@ -861,8 +837,8 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_uploadEventLogs_noLogs_studyOn_cacheUnchanged() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) val monitor = monitorFactory.createMonitor(analyticsController.getEventLogStore()) monitorFactory.ensureDataProviderExecutes(analyticsController.uploadEventLogs()) @@ -874,7 +850,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogs_noLogs_returnsPendingAndSimpleSuccessDataProvider() { - setUpTestApplicationComponent() val uploadResults = monitorFactory.waitForAllNextResults { analyticsController.uploadEventLogs() } @@ -885,9 +860,9 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_uploadEventLogs_withPreviousLogs_studyOn_setsSyncStatusToUploadingUploaded() { // Sync statuses only make sense in the context of the learner study feature being enabled. - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) logTwoEvents() monitorFactory.waitForAllNextResults { analyticsController.uploadEventLogs() } @@ -904,9 +879,9 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_uploadEventLogs_withLogs_studyOn_setsSyncStatusToUploadingThenUploaded() { // Sync statuses only make sense in the context of the learner study feature being enabled. - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) logTwoEventsOffline() monitorFactory.waitForAllNextResults { analyticsController.uploadEventLogs() } @@ -919,7 +894,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogs_withLogs_studyOff_removesEventsButDoesNotTrackThem() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = false) logTwoEventsOffline() monitorFactory.waitForAllNextResults { analyticsController.uploadEventLogs() } @@ -932,8 +906,8 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_uploadEventLogs_withLogs_studyOn_removesEventsForUploading() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) logTwoEventsOffline() monitorFactory.waitForAllNextResults { analyticsController.uploadEventLogs() } @@ -946,7 +920,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogs_withPreviousLogs_recordsEventsAsUploaded() { - setUpTestApplicationComponent() logTwoEvents() monitorFactory.waitForAllNextResults { analyticsController.uploadEventLogs() } @@ -956,7 +929,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogs_withLogs_recordsEventsAsUploaded() { - setUpTestApplicationComponent() logTwoEventsOffline() monitorFactory.waitForAllNextResults { analyticsController.uploadEventLogs() } @@ -966,7 +938,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogs_withPreviousLogs_returnsProgressContext() { - setUpTestApplicationComponent() logTwoEvents() val uploadResults = monitorFactory.waitForAllNextResults { @@ -981,7 +952,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogs_withLogs_returnsProgressContext() { - setUpTestApplicationComponent() logTwoEventsOffline() val uploadResults = monitorFactory.waitForAllNextResults { @@ -1015,7 +985,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogsAndWait_noLogs_cacheUnchanged() { - setUpTestApplicationComponent() val monitor = monitorFactory.createMonitor(analyticsController.getEventLogStore()) runSynchronously { analyticsController.uploadEventLogsAndWait() } @@ -1026,8 +995,8 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_uploadEventLogsAndWait_noLogs_studyOn_cacheUnchanged() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) val monitor = monitorFactory.createMonitor(analyticsController.getEventLogStore()) runSynchronously { analyticsController.uploadEventLogsAndWait() } @@ -1038,9 +1007,9 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_uploadEventLogsAndWait_prevLogs_studyOn_setsSyncStatusToUploadingUploaded() { // Sync statuses only make sense in the context of the learner study feature being enabled. - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) logTwoEvents() runSynchronously { analyticsController.uploadEventLogsAndWait() } @@ -1059,9 +1028,9 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_uploadEventLogsAndWait_withLogs_studyOn_setsSyncStatusToUploadingUploaded() { // Sync statuses only make sense in the context of the learner study feature being enabled. - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) logTwoEventsOffline() runSynchronously { analyticsController.uploadEventLogsAndWait() } @@ -1074,7 +1043,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogsAndWait_withLogs_studyOff_removesEventsButDoesNotTrackThem() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = false) logTwoEventsOffline() runSynchronously { analyticsController.uploadEventLogsAndWait() } @@ -1087,8 +1055,8 @@ class AnalyticsControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testController_uploadEventLogsAndWait_withLogs_studyOn_removesEventsForUploading() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) logTwoEventsOffline() runSynchronously { analyticsController.uploadEventLogsAndWait() } @@ -1101,7 +1069,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogsAndWait_withPreviousLogs_recordsEventsAsUploaded() { - setUpTestApplicationComponent() logTwoEvents() runSynchronously { analyticsController.uploadEventLogsAndWait() } @@ -1111,7 +1078,6 @@ class AnalyticsControllerTest { @Test fun testController_uploadEventLogsAndWait_withLogs_recordsEventsAsUploaded() { - setUpTestApplicationComponent() logTwoEventsOffline() runSynchronously { analyticsController.uploadEventLogsAndWait() } @@ -1121,7 +1087,6 @@ class AnalyticsControllerTest { @Test fun testController_cachedEventsFromLastAppInstance_logNewEvent_onlyLatestEventLogged() { - setUpTestApplicationComponent() // Simulate events being logged in a previous instance of the app. logTwoCachedEventsDirectlyOnDisk() @@ -1134,7 +1099,6 @@ class AnalyticsControllerTest { @Test fun testController_cachedEventsFromLastAppInstance_logNewEvent_thenForceSync_everythingUploads() { - setUpTestApplicationComponent() // Simulate events being logged in a previous instance of the app. logTwoCachedEventsDirectlyOnDisk() analyticsController.logImportantEvent(oppiaLogger.createOpenHomeContext(), profileId = null) @@ -1177,8 +1141,7 @@ class AnalyticsControllerTest { } } - private fun setUpTestApplicationComponent(enableLearnerStudyAnalytics: Boolean = false) { - TestPlatformParameterModule.forceEnableLearnerStudyAnalytics(enableLearnerStudyAnalytics) + private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) } @@ -1391,7 +1354,7 @@ class AnalyticsControllerTest { TestModule::class, TestLogReportingModule::class, RobolectricModule::class, TestDispatcherModule::class, TestLogStorageModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggingIdentifierModule::class, SyncStatusTestModule::class, AssetModule::class ] ) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleModuleTest.kt index 86b1240bb67..41a0b4f9d3e 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleModuleTest.kt @@ -12,15 +12,17 @@ import dagger.Module import dagger.Provides import dagger.multibindings.Multibinds import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.exploration.ExplorationActiveTimeController import org.oppia.android.domain.oppialogger.ApplicationIdSeed import org.oppia.android.domain.oppialogger.ApplicationStartupListener import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -44,6 +46,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ApplicationLifecycleModuleTest.TestApplication::class) class ApplicationLifecycleModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var startupListeners: Set<@JvmSuppressWildcards ApplicationStartupListener> @@ -109,7 +114,7 @@ class ApplicationLifecycleModuleTest { TestModule::class, TestLogReportingModule::class, LogStorageModule::class, TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestLoggingIdentifierModule::class, ApplicationLifecycleModule::class, LoggerModule::class, SyncStatusModule::class, CpuPerformanceSnapshotterModule::class, AssetModule::class diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt index 48e1ccc01c4..2093d4af7ac 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt @@ -15,7 +15,7 @@ import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer -import org.junit.After +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -30,18 +30,21 @@ import org.oppia.android.data.backends.gae.NetworkLoggingInterceptor import org.oppia.android.domain.oppialogger.ApplicationIdSeed import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.LoggingIdentifierController +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakePerformanceMetricsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TextInputActionTestActivity import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.platformparameter.EnableTestFeatureFlag import org.oppia.android.testing.platformparameter.EnableTestFeatureFlagWithEnabledDefault +import org.oppia.android.testing.platformparameter.PlatformParameterTestConstantsModule import org.oppia.android.testing.platformparameter.TEST_FEATURE_FLAG -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -59,6 +62,7 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -136,6 +140,9 @@ class ApplicationLifecycleObserverTest { @field:[Inject EnableTestFeatureFlagWithEnabledDefault] lateinit var testFeatureFlagWithEnabledDefault: PlatformParameterValue + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule var activityRule = ActivityScenarioRule( @@ -156,14 +163,13 @@ class ApplicationLifecycleObserverTest { private lateinit var mockWebServerUrl: HttpUrl private lateinit var request: Request - @After - fun tearDown() { - TestPlatformParameterModule.reset() + @Before + fun setUp() { + setUpTestApplicationComponent() } @Test fun testObserver_withDisabledMetricsCollection_doesNotLogAnyEvent() { - setUpTestApplicationComponent() applicationLifecycleObserver.onAppInForeground() testCoroutineDispatchers.runCurrent() assertThat(fakePerformanceMetricsEventLogger.noPerformanceMetricsEventsPresent()).isTrue() @@ -171,7 +177,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_getSessionId_backgroundApp_thenForeground_limitExceeded_sessionIdUpdated() { - setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) val sessionIdProvider = loggingIdentifierController.getSessionId() val firstSessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) @@ -184,7 +189,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_getSessionId_backgroundApp_thenForeground_limitNotExceeded_sessionIdUnchanged() { - setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) val sessionIdProvider = loggingIdentifierController.getSessionId() val firstSessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) @@ -196,8 +200,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testObserver_onAppInForeground_loggedIntoProfile_studyOn_logsForegroundEventWithBothIds() { - setUpTestApplicationWithLearnerStudy() logIntoAnalyticsReadyAdminProfile() applicationLifecycleObserver.onAppInForeground() @@ -212,9 +216,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testObserver_onAppInForeground_notLoggedIn_studyOn_logsForegroundEventWithoutLearnerId() { - setUpTestApplicationWithLearnerStudy() - applicationLifecycleObserver.onAppInForeground() testCoroutineDispatchers.runCurrent() @@ -227,8 +230,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testObserver_onAppInBackground_loggedIntoProfile_studyOn_logsBackgroundEventWithBothIds() { - setUpTestApplicationWithLearnerStudy() logIntoAnalyticsReadyAdminProfile() applicationLifecycleObserver.onAppInBackground() @@ -243,9 +246,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testObserver_onAppInBackground_notLoggedIn_studyOn_logsBackgroundEventWithoutLearnerId() { - setUpTestApplicationWithLearnerStudy() - applicationLifecycleObserver.onAppInBackground() testCoroutineDispatchers.runCurrent() @@ -260,7 +262,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_onAppInForeground_setsAppInForeground() { - setUpTestApplicationComponent() applicationLifecycleObserver.onAppInForeground() assertThat(performanceMetricsController.getIsAppInForeground()).isTrue() @@ -268,7 +269,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_onAppInBackground_setsAppInBackground() { - setUpTestApplicationComponent() applicationLifecycleObserver.onAppInBackground() assertThat(performanceMetricsController.getIsAppInForeground()).isFalse() @@ -276,14 +276,12 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_getCurrentScreen_verifyInitialValueIsUnspecified() { - setUpTestApplicationComponent() assertThat(applicationLifecycleObserver.getCurrentScreen()) .isEqualTo(ScreenName.SCREEN_NAME_UNSPECIFIED) } @Test fun testObserver_onUnspecifiedActivityResume_verifyCurrentScreenReturnsUnspecifiedValue() { - setUpTestApplicationComponent() activityRuleForUnspecifiedActivity.scenario.onActivity { activity -> applicationLifecycleObserver.onActivityResumed(activity) val currentScreenValue = applicationLifecycleObserver.getCurrentScreen() @@ -292,8 +290,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testObserver_onCreate_performanceMetricsLoggingWithCorrectDetailsOccurs() { - setUpTestApplicationWithPerformanceMetricsCollection() applicationLifecycleObserver.onCreate() testCoroutineDispatchers.runCurrent() @@ -309,7 +307,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_onFirstActivityResume_verifyCurrentScreenReturnsCorrectValue() { - setUpTestApplicationComponent() activityRule.scenario.onActivity { activity -> applicationLifecycleObserver.onActivityResumed(activity) val currentScreenValue = applicationLifecycleObserver.getCurrentScreen() @@ -318,8 +315,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testObserver_onFirstActivityResume_logsStartupLatency() { - setUpTestApplicationWithPerformanceMetricsCollection() applicationLifecycleObserver.onCreate() testCoroutineDispatchers.runCurrent() fakeOppiaClock.setCurrentTimeMs(TEST_TIMESTAMP_IN_MILLIS_TWO) @@ -341,8 +338,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testObserver_onSecondActivityResume_startupLatencyIsLoggedOnce() { - setUpTestApplicationWithPerformanceMetricsCollection() applicationLifecycleObserver.onCreate() testCoroutineDispatchers.runCurrent() @@ -363,9 +360,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testObserver_activityResumed_logsMemoryUsage() { - setUpTestApplicationWithPerformanceMetricsCollection() - activityRule.scenario.onActivity { activity -> applicationLifecycleObserver.onActivityResumed(activity) @@ -382,7 +378,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_activityResumed_activityPaused_currentScreenReturnsBackgroundValue() { - setUpTestApplicationComponent() activityRule.scenario.onActivity { activity -> applicationLifecycleObserver.onActivityResumed(activity) applicationLifecycleObserver.onActivityPaused(activity) @@ -393,8 +388,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testObserver_onAppInForeground_logsCpuUsageWithCurrentScreenForeground() { - setUpTestApplicationWithPerformanceMetricsCollection() applicationLifecycleObserver.onCreate() applicationLifecycleObserver.onAppInForeground() testCoroutineDispatchers.runCurrent() @@ -406,8 +401,8 @@ class ApplicationLifecycleObserverTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testObserver_onAppInBackground_logsCpuUsageWithCurrentScreenBackground() { - setUpTestApplicationWithPerformanceMetricsCollection() applicationLifecycleObserver.onCreate() applicationLifecycleObserver.onAppInBackground() testCoroutineDispatchers.runCurrent() @@ -420,8 +415,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_onAppInForeground_logsAllFeatureFlags() { - setUpTestApplicationComponent() - featureFlagsLogger.setFeatureFlagItemMap( mapOf(TEST_FEATURE_FLAG to testFeatureFlag) ) @@ -448,7 +441,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_onAppInForeground_thenInBackground_logsAppInForegroundTime() { - setUpTestApplicationComponent() fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) applicationLifecycleObserver.onCreate() @@ -477,8 +469,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_onAppInForeground_onConsoleError_logsConsoleErrors() { - setUpTestApplicationComponent() - applicationLifecycleObserver.onCreate() applicationLifecycleObserver.onAppInForeground() testCoroutineDispatchers.runCurrent() @@ -500,7 +490,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_onAppInForeground_onNetworkCall_logsNetworkCalls() { - setUpTestApplicationComponent() setUpRetrofitApiCall() applicationLifecycleObserver.onCreate() @@ -525,7 +514,6 @@ class ApplicationLifecycleObserverTest { @Test fun testObserver_onAppInForeground_onNetworkCall_logsFailedNetworkCalls() { - setUpTestApplicationComponent() setUpRetrofitApiCall() applicationLifecycleObserver.onCreate() @@ -577,16 +565,6 @@ class ApplicationLifecycleObserverTest { ) } - private fun setUpTestApplicationWithLearnerStudy() { - TestPlatformParameterModule.forceEnableLoggingLearnerStudyIds(true) - setUpTestApplicationComponent() - } - - private fun setUpTestApplicationWithPerformanceMetricsCollection() { - TestPlatformParameterModule.forceEnablePerformanceMetricsCollection(true) - setUpTestApplicationComponent() - } - private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -666,9 +644,10 @@ class ApplicationLifecycleObserverTest { TestModule::class, TestLogReportingModule::class, LogStorageModule::class, TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, - TestLoggingIdentifierModule::class, ApplicationLifecycleModule::class, - SyncStatusModule::class, CpuPerformanceSnapshotterModule::class, AssetModule::class + PlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterTestConstantsModule::class, TestLoggingIdentifierModule::class, + ApplicationLifecycleModule::class, SyncStatusModule::class, + CpuPerformanceSnapshotterModule::class, AssetModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index 3d8e5efdbfe..94b09d210fd 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -19,7 +19,6 @@ oppia_android_test( "//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/logging:test_sync_status_manager", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -48,7 +47,6 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -78,7 +76,7 @@ oppia_android_test( "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", "//testing/src/main/java/org/oppia/android/testing/logging:event_log_subject", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", + "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_constants_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -110,7 +108,6 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -140,7 +137,6 @@ oppia_android_test( "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", "//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", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -215,7 +211,6 @@ oppia_android_test( "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", "//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", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -245,7 +240,6 @@ oppia_android_test( "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", "//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", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -276,7 +270,6 @@ oppia_android_test( "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", "//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", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", @@ -308,7 +301,7 @@ oppia_android_test( "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//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/platformparameter:test_constants_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterModuleTest.kt index 25d84be598b..1e9065c51f5 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterModuleTest.kt @@ -12,14 +12,16 @@ import dagger.Module import dagger.Provides import dagger.multibindings.Multibinds import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.ApplicationIdSeed import org.oppia.android.domain.oppialogger.ApplicationStartupListener import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -42,6 +44,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = CpuPerformanceSnapshotterModuleTest.TestApplication::class) class CpuPerformanceSnapshotterModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[JvmField Inject ForegroundCpuLoggingTimePeriodMillis] var foregroundCpuLoggingTimePeriodMillis: Long = Long.MIN_VALUE @@ -95,7 +100,7 @@ class CpuPerformanceSnapshotterModuleTest { TestModule::class, TestLogReportingModule::class, LogStorageModule::class, TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, TestLoggingIdentifierModule::class, ApplicationLifecycleModule::class, LoggerModule::class, SyncStatusModule::class, CpuPerformanceSnapshotterModule::class ] 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 adf3376b77d..6f078808575 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 @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.OppiaMetricLog.LoggableMetric.LoggableMetricTypeCase.CPU_USAGE_METRIC @@ -18,13 +19,15 @@ import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.PerformanceMetricsLogStorageCacheSize +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakePerformanceMetricAssessor import org.oppia.android.testing.FakePerformanceMetricsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.logging.SyncStatusTestModule -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -42,6 +45,7 @@ import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsAsses import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsAssessor.AppIconification.APP_IN_FOREGROUND import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsAssessor.AppIconification.UNINITIALIZED import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.util.concurrent.TimeUnit @@ -57,7 +61,10 @@ private const val TEST_CPU_USAGE_TWO = 0.32192 @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = CpuPerformanceSnapshotterTest.TestApplication::class) +@EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) class CpuPerformanceSnapshotterTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var cpuPerformanceSnapshotter: CpuPerformanceSnapshotter @@ -83,7 +90,6 @@ class CpuPerformanceSnapshotterTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnablePerformanceMetricsCollection(true) setUpTestApplicationComponent() } @@ -485,7 +491,7 @@ class CpuPerformanceSnapshotterTest { TestModule::class, TestLogReportingModule::class, RobolectricModule::class, TestDispatcherModule::class, TestLogStorageModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggingIdentifierModule::class, SyncStatusTestModule::class, CpuPerformanceSnapshotterModule::class, ApplicationLifecycleModule::class, AssetModule::class ] diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 73abeb09be5..c1583aacb66 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -9,14 +9,17 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.PlatformParameter.SyncStatus import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.domain.oppialogger.LoggingIdentifierModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration @@ -27,9 +30,9 @@ import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.platformparameter.EnableTestFeatureFlag import org.oppia.android.testing.platformparameter.EnableTestFeatureFlagWithEnabledDefault +import org.oppia.android.testing.platformparameter.PlatformParameterTestConstantsModule import org.oppia.android.testing.platformparameter.TEST_FEATURE_FLAG import org.oppia.android.testing.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -73,6 +76,9 @@ import javax.inject.Singleton sdk = [Build.VERSION_CODES.O] ) class FeatureFlagsLoggerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var featureFlagsLogger: FeatureFlagsLogger @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger @@ -250,8 +256,9 @@ class FeatureFlagsLoggerTest { TestModule::class, TestLogReportingModule::class, RobolectricModule::class, TestDispatcherModule::class, TestLogStorageModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, - LoggingIdentifierModule::class, SyncStatusTestModule::class, AssetModule::class + PlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterTestConstantsModule::class, LoggingIdentifierModule::class, + SyncStatusTestModule::class, AssetModule::class ] ) 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 2de079ee3c0..8e0de6a863e 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 @@ -16,6 +16,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EventLog @@ -27,6 +28,7 @@ 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -60,6 +62,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FirestoreDataControllerTest.TestApplication::class) class FirestoreDataControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var dataControllerProvider: Provider 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 30523eb52e7..e0b07a665be 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 @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.Exploration @@ -43,6 +44,7 @@ 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -90,6 +92,9 @@ class LearnerAnalyticsLoggerTest { private const val DEFAULT_INITIAL_SESSION_ID = "ab4532d6-476c-3727-bc5a-ad84e5dae60f" } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var learnerAnalyticsLogger: LearnerAnalyticsLogger @Inject diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/PerformanceMetricsControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/PerformanceMetricsControllerTest.kt index 26e1d951d83..0a20a3ac747 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/PerformanceMetricsControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/PerformanceMetricsControllerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.OppiaMetricLog @@ -31,6 +32,7 @@ import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModul import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakePerformanceMetricsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.logging.SyncStatusTestModule @@ -71,6 +73,8 @@ private const val TEST_MEMORY_USAGE = Long.MAX_VALUE @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PerformanceMetricsControllerTest.TestApplication::class) class PerformanceMetricsControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var performanceMetricsController: PerformanceMetricsController diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/PerformanceMetricsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/PerformanceMetricsLoggerTest.kt index d45e32f5f6e..2f1cd68b0ed 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/PerformanceMetricsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/PerformanceMetricsLoggerTest.kt @@ -10,7 +10,8 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides -import org.junit.After +import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock @@ -29,12 +30,14 @@ import org.oppia.android.app.model.ScreenName.SCREEN_NAME_UNSPECIFIED import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.PerformanceMetricsLogStorageCacheSize +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakePerformanceMetricAssessor import org.oppia.android.testing.FakePerformanceMetricsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.logging.SyncStatusTestModule -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClock @@ -48,6 +51,7 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsAssessor import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -69,6 +73,8 @@ private const val TEST_STARTUP_LATENCY_IN_MILLISECONDS = 3000L @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PerformanceMetricsLoggerTest.TestApplication::class) class PerformanceMetricsLoggerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var performanceMetricsLogger: PerformanceMetricsLogger @@ -91,9 +97,9 @@ class PerformanceMetricsLoggerTest { private val testDeviceStorageTier = OppiaMetricLog.StorageTier.MEDIUM_STORAGE private val testDeviceMemoryTier = OppiaMetricLog.MemoryTier.MEDIUM_MEMORY_TIER - @After - fun tearDown() { - TestPlatformParameterModule.reset() + @Before + fun setUp() { + setUpApplicationInDefaultMode() } @Test @@ -112,8 +118,8 @@ class PerformanceMetricsLoggerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testLogger_logApkSizePerformanceMetric_verifyLogsMetricCorrectly() { - setUpApplicationForPerformanceMetricsLogging() val apkSize = fakePerformanceMetricAssessor.getApkSize() val memoryTier = fakePerformanceMetricAssessor.getDeviceMemoryTier() val storageTier = fakePerformanceMetricAssessor.getDeviceStorageTier() @@ -132,8 +138,8 @@ class PerformanceMetricsLoggerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testLogger_logStorageUsagePerformanceMetric_verifyLogsMetricCorrectly() { - setUpApplicationForPerformanceMetricsLogging() val memoryTier = fakePerformanceMetricAssessor.getDeviceMemoryTier() val storageTier = fakePerformanceMetricAssessor.getDeviceStorageTier() val isAppInForeground = performanceMetricsController.getIsAppInForeground() @@ -154,8 +160,8 @@ class PerformanceMetricsLoggerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testLogger_logMemoryUsagePerformanceMetric_verifyLogsMetricCorrectly() { - setUpApplicationForPerformanceMetricsLogging() val memoryUsage = fakePerformanceMetricAssessor.getTotalPssUsed() val memoryTier = fakePerformanceMetricAssessor.getDeviceMemoryTier() val storageTier = fakePerformanceMetricAssessor.getDeviceStorageTier() @@ -174,8 +180,8 @@ class PerformanceMetricsLoggerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testLogger_logStartupLatencyPerformanceMetric_verifyLogsMetricCorrectly() { - setUpApplicationForPerformanceMetricsLogging() val memoryTier = fakePerformanceMetricAssessor.getDeviceMemoryTier() val storageTier = fakePerformanceMetricAssessor.getDeviceStorageTier() val isAppInForeground = performanceMetricsController.getIsAppInForeground() @@ -200,8 +206,8 @@ class PerformanceMetricsLoggerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testLogger_logCpuUsagePerformanceMetric_verifyLogsMetricCorrectly() { - setUpApplicationForPerformanceMetricsLogging() val memoryTier = fakePerformanceMetricAssessor.getDeviceMemoryTier() val storageTier = fakePerformanceMetricAssessor.getDeviceStorageTier() val isAppInForeground = performanceMetricsController.getIsAppInForeground() @@ -222,8 +228,8 @@ class PerformanceMetricsLoggerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) fun testLogger_logNetworkUsagePerformanceMetric_verifyLogsMetricCorrectly() { - setUpApplicationForPerformanceMetricsLogging() val bytesSent = fakePerformanceMetricAssessor.getTotalSentBytes() val bytesReceived = fakePerformanceMetricAssessor.getTotalReceivedBytes() val memoryTier = fakePerformanceMetricAssessor.getDeviceMemoryTier() @@ -265,14 +271,6 @@ class PerformanceMetricsLoggerTest { fakeOppiaClock.setCurrentTimeMs(TEST_TIMESTAMP) } - private fun setUpApplicationForPerformanceMetricsLogging() { - TestPlatformParameterModule.forceEnablePerformanceMetricsCollection(true) - ApplicationProvider.getApplicationContext().inject(this) - setUpFakePerformanceMetricsUtils() - fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) - fakeOppiaClock.setCurrentTimeMs(TEST_TIMESTAMP) - } - private fun setUpFakePerformanceMetricsUtils() { fakePerformanceMetricAssessor.apply { setApkSize(TEST_APK_SIZE) @@ -336,7 +334,7 @@ class PerformanceMetricsLoggerTest { TestModule::class, TestLogReportingModule::class, RobolectricModule::class, TestDispatcherModule::class, TestLogStorageModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggingIdentifierModule::class, SyncStatusTestModule::class, ApplicationLifecycleModule::class ] 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 a8962bb0af4..5c8c7532851 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 @@ -9,6 +9,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MarketFitAnswer @@ -20,14 +21,15 @@ import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.domain.oppialogger.FirestoreLogStorageCacheSize import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.survey.SurveyEventsLogger +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeFirestoreEventLogger +import org.oppia.android.testing.OppiaTestRule 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 import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -58,6 +60,9 @@ class SurveyEventsLoggerTest { private const val TEST_ANSWER = "Some text response" } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var surveyEventsLogger: SurveyEventsLogger @@ -190,7 +195,7 @@ class SurveyEventsLoggerTest { TestModule::class, TestLogReportingModule::class, RobolectricModule::class, TestDispatcherModule::class, TestLogStorageModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, - TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggingIdentifierModule::class, SyncStatusTestModule::class, ApplicationLifecycleModule::class, AssetModule::class, TestAuthenticationModule::class, ] diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/testing/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/testing/BUILD.bazel index 533770e2c80..1c2b5bc8371 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/testing/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/testing/BUILD.bazel @@ -17,7 +17,6 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/testing:fake_log_scheduler", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/testing/FakeLogSchedulerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/testing/FakeLogSchedulerTest.kt index d05034cbd5f..a164c86e303 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/testing/FakeLogSchedulerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/testing/FakeLogSchedulerTest.kt @@ -17,6 +17,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize @@ -30,6 +31,7 @@ import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulingWork import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorker import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -56,6 +58,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FakeLogSchedulerTest.TestApplication::class) class FakeLogSchedulerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var fakeLogScheduler: FakeLogScheduler diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/exceptions/ExceptionsControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/exceptions/ExceptionsControllerTest.kt index 7e4bc2e6614..e44ddec4119 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/exceptions/ExceptionsControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/exceptions/ExceptionsControllerTest.kt @@ -10,11 +10,13 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ExceptionLog.ExceptionType import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.robolectric.RobolectricModule @@ -48,6 +50,9 @@ private const val TEST_TIMESTAMP_IN_MILLIS_FOUR = 1556094000000 @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ExceptionsControllerTest.TestApplication::class) class ExceptionsControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var dataProviders: DataProviders @Inject lateinit var exceptionsController: ExceptionsController @Inject lateinit var networkConnectionUtil: NetworkConnectionDebugUtil diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/exceptions/UncaughtExceptionLoggerStartupListenerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/exceptions/UncaughtExceptionLoggerStartupListenerTest.kt index b0702bf7430..9bb319d116c 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/exceptions/UncaughtExceptionLoggerStartupListenerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/exceptions/UncaughtExceptionLoggerStartupListenerTest.kt @@ -10,10 +10,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.robolectric.RobolectricModule @@ -40,6 +42,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = UncaughtExceptionLoggerStartupListenerTest.TestApplication::class) class UncaughtExceptionLoggerStartupListenerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var dataProviders: DataProviders @Inject lateinit var uncaughtExceptionStartupListener: UncaughtExceptionLoggerStartupListener @Inject lateinit var networkConnectionUtil: NetworkConnectionDebugUtil diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulerModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulerModuleTest.kt index ac65b6d1c92..5212236b379 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulerModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulerModuleTest.kt @@ -10,8 +10,10 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.locale.LocaleProdModule @@ -29,6 +31,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MetricLogSchedulerModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var metricLogScheduler: MetricLogScheduler diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorkerTest.kt index 04d07ab4cdb..c682808e960 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorkerTest.kt @@ -20,6 +20,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.OppiaMetricLog.LoggableMetric.LoggableMetricTypeCase.MEMORY_USAGE_METRIC @@ -35,13 +36,15 @@ import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterM import org.oppia.android.domain.oppialogger.analytics.PerformanceMetricsController import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorker +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.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.FakePerformanceMetricsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.logging.SyncStatusTestModule -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -60,6 +63,7 @@ import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsConfi import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsEventLogger import org.oppia.android.util.networking.NetworkConnectionDebugUtil import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -73,7 +77,11 @@ private const val INCORRECT_WORKER_CASE = "incorrect_worker_case" @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = MetricLogSchedulingWorkerTest.TestApplication::class) +@EnableFeatureFlag(FeatureFlag.ENABLE_PERFORMANCE_METRICS_COLLECTION) class MetricLogSchedulingWorkerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var networkConnectionUtil: NetworkConnectionDebugUtil @@ -99,7 +107,6 @@ class MetricLogSchedulingWorkerTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnablePerformanceMetricsCollection(true) setUpTestApplicationComponent() context = InstrumentationRegistry.getInstrumentation().targetContext val config = Configuration.Builder() @@ -268,7 +275,7 @@ class MetricLogSchedulingWorkerTest { TestDispatcherModule::class, LogReportWorkerModule::class, TestFirebaseLogUploaderModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, LoggerModule::class, - AssetModule::class, TestPlatformParameterModule::class, LoggingIdentifierModule::class, + AssetModule::class, PlatformParameterModule::class, LoggingIdentifierModule::class, SyncStatusTestModule::class, PlatformParameterSingletonModule::class, PerformanceMetricsAssessorModule::class, PerformanceMetricsConfigurationsModule::class, ApplicationLifecycleModule::class, CpuPerformanceSnapshotterModule::class diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/PerformanceMetricsLogSchedulerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/PerformanceMetricsLogSchedulerTest.kt index 8ba3115e5a5..a7fce976dd8 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/PerformanceMetricsLogSchedulerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/logscheduler/PerformanceMetricsLogSchedulerTest.kt @@ -17,6 +17,7 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.LogStorageModule @@ -26,6 +27,7 @@ import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterM import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.robolectric.RobolectricModule @@ -52,6 +54,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PerformanceMetricsLogSchedulerTest.TestApplication::class) class PerformanceMetricsLogSchedulerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var performanceMetricsLogScheduler: PerformanceMetricsLogScheduler diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/BUILD.bazel index a6e4f4d9620..d7aa229e2bd 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/BUILD.bazel @@ -54,7 +54,6 @@ oppia_android_test( "//testing", "//testing/src/main/java/org/oppia/android/testing/logging:sync_status_test_module", "//testing/src/main/java/org/oppia/android/testing/logging:test_sync_status_manager", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//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", 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 9f9443e1708..507673b2383 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 @@ -20,6 +20,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize @@ -38,6 +39,7 @@ 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule @@ -64,6 +66,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = LogReportWorkManagerInitializerTest.TestApplication::class) class LogReportWorkManagerInitializerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var logUploadWorkerFactory: LogUploadWorkerFactory 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 6ecf7a83e28..3148d209eab 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 @@ -19,6 +19,8 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides +import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.`when` @@ -38,18 +40,20 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.oppialogger.analytics.FirestoreDataController import org.oppia.android.domain.oppialogger.analytics.PerformanceMetricsController import org.oppia.android.domain.oppialogger.exceptions.ExceptionsController +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.EnableFeatureFlag 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.OppiaTestRule 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 -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -76,6 +80,7 @@ import org.oppia.android.util.networking.NetworkConnectionDebugUtil import org.oppia.android.util.networking.NetworkConnectionUtil.ProdConnectionStatus.LOCAL import org.oppia.android.util.networking.NetworkConnectionUtil.ProdConnectionStatus.NONE import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -92,7 +97,11 @@ private const val TEST_APK_SIZE = Long.MAX_VALUE @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = LogUploadWorkerTest.TestApplication::class) +@EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) class LogUploadWorkerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var networkConnectionUtil: NetworkConnectionDebugUtil @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger @Inject lateinit var fakeExceptionLogger: FakeExceptionLogger @@ -137,9 +146,13 @@ class LogUploadWorkerTest { private val exception = Exception("TEST") + @Before + fun setUp() { + setUpTestApplicationComponent() + } + @Test fun testWorker_logEvent_withoutNetwork_enqueueRequest_verifyFailed() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logImportantEvent( oppiaLogger.createOpenInfoTabContext(TEST_TOPIC_ID), @@ -170,7 +183,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logEvent_withNetwork_enqueueRequest_verifySuccess() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logImportantEvent( oppiaLogger.createOpenInfoTabContext(TEST_TOPIC_ID), @@ -201,7 +213,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logEvent_withoutNetwork_enqueueRequest_writeFails_verifyFailure() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logImportantEvent( oppiaLogger.createOpenInfoTabContext(TEST_TOPIC_ID), @@ -232,7 +243,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logException_withoutNetwork_enqueueRequest_verifySuccess() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) exceptionsController.logNonFatalException(exception, TEST_TIMESTAMP) testCoroutineDispatchers.runCurrent() @@ -264,7 +274,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logPerformanceMetric_withoutNetwork_enqueueRequest_verifySuccess() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) performanceMetricsController.logPerformanceMetricsEvent( TEST_TIMESTAMP, @@ -306,7 +315,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logEvent_withNetwork_enqueueRequest_studyOn_verifySyncStatusesHasSuccess() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logImportantEvent( oppiaLogger.createOpenInfoTabContext(TEST_TOPIC_ID), @@ -341,7 +349,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logEvent_withoutNetwork_enqueueRequest_studyOn_verifySyncStatusesHasFailed() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logImportantEvent( oppiaLogger.createOpenInfoTabContext(TEST_TOPIC_ID), @@ -377,7 +384,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logEvent_noNetwork_enqueueRequest_writeFails_studyOn_verifyHasFailedSyncStatus() { - setUpTestApplicationComponent(enableLearnerStudyAnalytics = true) networkConnectionUtil.setCurrentConnectionStatus(NONE) analyticsController.logImportantEvent( oppiaLogger.createOpenInfoTabContext(TEST_TOPIC_ID), @@ -413,7 +419,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logFirestoreEvent_withNetwork_enqueueRequest_verifySuccess() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) dataController.logEvent( createOptionalSurveyResponseContext(), @@ -446,7 +451,6 @@ class LogUploadWorkerTest { @Test fun testWorker_logFirestoreEvent_withoutNetwork_enqueueRequest_writeFails_verifyFailure() { - setUpTestApplicationComponent() networkConnectionUtil.setCurrentConnectionStatus(NONE) dataController.logEvent( createOptionalSurveyResponseContext(), @@ -523,8 +527,7 @@ class LogUploadWorkerTest { private fun Array.extractRelevantDetails(): List> = map { elem -> listOf(elem.fileName, elem.methodName, elem.lineNumber, elem.className) } - private fun setUpTestApplicationComponent(enableLearnerStudyAnalytics: Boolean = false) { - TestPlatformParameterModule.forceEnableLearnerStudyAnalytics(enableLearnerStudyAnalytics) + private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) context = InstrumentationRegistry.getInstrumentation().targetContext val config = Configuration.Builder() @@ -628,7 +631,7 @@ class LogUploadWorkerTest { TestDispatcherModule::class, LogReportWorkerModule::class, TestFirebaseLogUploaderModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, LoggerModule::class, - AssetModule::class, TestPlatformParameterModule::class, + AssetModule::class, PlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggingIdentifierModule::class, SyncStatusTestModule::class, PerformanceMetricsAssessorModule::class, ApplicationLifecycleModule::class, PerformanceMetricsConfigurationsModule::class, diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerTest.kt index 6bbb4c3366b..9dbbcfb6368 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerTest.kt @@ -9,10 +9,12 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.PlatformParameter import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.robolectric.RobolectricModule @@ -47,6 +49,9 @@ private const val BOOLEAN_PLATFORM_PARAMETER_VALUE = true @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PlatformParameterControllerTest.TestApplication::class) class PlatformParameterControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var platformParameterController: PlatformParameterController @Inject lateinit var platformParameterSingleton: PlatformParameterSingleton @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt index 53ccda14f55..1af6b3db59f 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt @@ -11,9 +11,12 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.testing.OppiaTestRule +import org.oppia.android.testing.platformparameter.PlatformParameterTestConstantsModule import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_DEFAULT_VALUE import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_SERVER_VALUE @@ -25,11 +28,14 @@ import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SERVER_VALUE import org.oppia.android.testing.platformparameter.TestBooleanParam import org.oppia.android.testing.platformparameter.TestIntegerParam -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.platformparameter.TestStringParam import org.oppia.android.util.extensions.getVersionCode +import org.oppia.android.util.platformparameter.AUTOMATIC_UPDATE_TOPIC_SETTING_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.AutomaticUpdateTopicSetting import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL import org.oppia.android.util.platformparameter.LowestSupportedApiLevel import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PlatformParameterSingleton @@ -49,6 +55,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PlatformParameterModuleTest.TestApplication::class) class PlatformParameterModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var platformParameterSingleton: PlatformParameterSingleton @@ -77,6 +85,9 @@ class PlatformParameterModuleTest { @field:[Inject LowestSupportedApiLevel] lateinit var lowestSupportedApiLevelProvider: Provider> + @field:[Inject AutomaticUpdateTopicSetting] + lateinit var automaticUpdateTopicSettingProvider: Provider> + private val platformParameterMapWithValues by lazy { val mockStringPlatformParameter = PlatformParameter.newBuilder() .setString(TEST_STRING_PARAM_SERVER_VALUE).build() @@ -161,6 +172,25 @@ class PlatformParameterModuleTest { .isEqualTo(TEST_BOOLEAN_PARAM_SERVER_VALUE) } + @Test + fun testModule_injectAutomaticUpdateTopicSetting_hasCorrectDefaultValue() { + setUpTestApplicationComponent(platformParameterMapWithValues) + assertThat(automaticUpdateTopicSettingProvider.get().value) + .isEqualTo(AUTOMATIC_UPDATE_TOPIC_SETTING_DEFAULT_VALUE) + } + + @Test + fun testModule_injectAutomaticUpdateTopicSettingWithOverride_overriddenPlatformParameterValue() { + val overridePlatformParameterValue = !AUTOMATIC_UPDATE_TOPIC_SETTING_DEFAULT_VALUE + setUpTestApplicationComponentWithPlatformParameterBooleanOverrides( + platformParameterMapWithValues, + org.oppia.android.util.platformparameter.PlatformParameter.AUTOMATIC_UPDATE_TOPIC_SETTING, + overridePlatformParameterValue + ) + assertThat(automaticUpdateTopicSettingProvider.get().value) + .isEqualTo(!AUTOMATIC_UPDATE_TOPIC_SETTING_DEFAULT_VALUE) + } + @Test fun testModule_injectEnableAppAndOsDeprecation_hasCorrectDefaultValue() { setUpTestApplicationComponent(platformParameterMapWithValues) @@ -168,6 +198,17 @@ class PlatformParameterModuleTest { .isEqualTo(TEST_ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE) } + @Test + fun testModule_injectEnableAppAndOsDeprecationWithOverride_overriddenFeatureFlagValue() { + setUpTestApplicationComponentWithFeatureFlagOverrides( + platformParameterMapWithValues, + FeatureFlag.APP_AND_OS_DEPRECATION, + TEST_BOOLEAN_PARAM_SERVER_VALUE + ) + assertThat(enableAppAndOsDeprecationProvider.get().value) + .isEqualTo(!TEST_ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE) + } + @Test fun testModule_injectOptionalAppUpdateVersionCode_hasCorrectAppVersionCode() { setUpTestApplicationComponent(platformParameterMapWithValues) @@ -193,6 +234,43 @@ class PlatformParameterModuleTest { .isEqualTo(TEST_LOWEST_SUPPORTED_API_LEVEL) } + @Test + fun testModule_injectLowestSupportedApiLevelWithOverride_overriddenPlatformParameterValue() { + val overridePlatformParameterValue = 18 + setUpTestApplicationComponentWithPlatformParameterIntegerOverrides( + platformParameterMapWithValues, + org.oppia.android.util.platformparameter.PlatformParameter.LOWEST_SUPPORTED_API_LEVEL, + overridePlatformParameterValue + ) + assertThat(lowestSupportedApiLevelProvider.get().value) + .isEqualTo(overridePlatformParameterValue) + } + + @Test + fun testModule_injectEnableAppAndOsDeprecationClearOverride_resetsFeatureFlagValue() { + setUpTestApplicationComponentWithFeatureFlagOverrides( + platformParameterMapWithValues, + FeatureFlag.APP_AND_OS_DEPRECATION, + TEST_BOOLEAN_PARAM_SERVER_VALUE + ) + PlatformParameterModule.clearAllParameterOverrides() + assertThat(enableAppAndOsDeprecationProvider.get().value) + .isEqualTo(TEST_ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE) + } + + @Test + fun testModule_injectLowestSupportedApiLevelClearOverride_resetsPlatformParameterValue() { + val overridePlatformParameterValue = 18 + setUpTestApplicationComponentWithPlatformParameterIntegerOverrides( + platformParameterMapWithValues, + org.oppia.android.util.platformparameter.PlatformParameter.LOWEST_SUPPORTED_API_LEVEL, + overridePlatformParameterValue + ) + PlatformParameterModule.clearAllParameterOverrides() + assertThat(lowestSupportedApiLevelProvider.get().value) + .isEqualTo(TEST_LOWEST_SUPPORTED_API_LEVEL) + } + private fun registerTestApplication() { val packageManager = Shadows.shadowOf(context.packageManager) val applicationInfo = @@ -215,6 +293,45 @@ class PlatformParameterModuleTest { registerTestApplication() } + private fun setUpTestApplicationComponentWithFeatureFlagOverrides( + platformParameterMap: Map, + featureFlagName: FeatureFlag, + featureFlagValue: Boolean + ) { + ApplicationProvider.getApplicationContext().inject(this) + platformParameterSingleton.setPlatformParameterMap(platformParameterMap) + PlatformParameterModule.overrideFeatureFlags(featureFlagName, featureFlagValue) + registerTestApplication() + } + + private fun setUpTestApplicationComponentWithPlatformParameterIntegerOverrides( + platformParameterMap: Map, + platformParameterName: org.oppia.android.util.platformparameter.PlatformParameter, + platformParameterValue: Int + ) { + ApplicationProvider.getApplicationContext().inject(this) + platformParameterSingleton.setPlatformParameterMap(platformParameterMap) + PlatformParameterModule.overridePlatformParameters( + platformParameterName, + platformParameterValue + ) + registerTestApplication() + } + + private fun setUpTestApplicationComponentWithPlatformParameterBooleanOverrides( + platformParameterMap: Map, + platformParameterName: org.oppia.android.util.platformparameter.PlatformParameter, + platformParameterValue: Boolean + ) { + ApplicationProvider.getApplicationContext().inject(this) + platformParameterSingleton.setPlatformParameterMap(platformParameterMap) + PlatformParameterModule.overridePlatformParameters( + platformParameterName, + platformParameterValue + ) + registerTestApplication() + } + @Module class TestModule { @Provides @@ -232,7 +349,8 @@ class PlatformParameterModuleTest { @Singleton @Component( modules = [ - TestModule::class, TestPlatformParameterModule::class + TestModule::class, PlatformParameterModule::class, + PlatformParameterTestConstantsModule::class ] ) interface TestApplicationComponent { diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonTest.kt index 8be5d7815e0..0f29c9ee714 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonTest.kt @@ -9,9 +9,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.platformparameter.PlatformParameterSingleton import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config @@ -38,6 +40,8 @@ private const val INCORRECT_PLATFORM_PARAMETER_NAME = "incorrect_platform_parame @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PlatformParameterSingletonTest.TestApplication::class) class PlatformParameterSingletonTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var platformParameterSingleton: PlatformParameterSingleton diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkManagerInitializerTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkManagerInitializerTest.kt index e3283289cb4..797a3c21f9c 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkManagerInitializerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkManagerInitializerTest.kt @@ -21,6 +21,7 @@ import dagger.Module import dagger.Provides import okhttp3.OkHttpClient import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.data.backends.gae.BaseUrl @@ -35,6 +36,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.network.MockPlatformParameterService import org.oppia.android.testing.network.RetrofitTestModule @@ -66,6 +68,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class PlatformParameterSyncUpWorkManagerInitializerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var syncUpWorkManagerInitializer: PlatformParameterSyncUpWorkManagerInitializer diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt index 82e756c79e6..00d77bb792b 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt @@ -22,6 +22,7 @@ import dagger.Module import dagger.Provides import okhttp3.OkHttpClient import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.PlatformParameter @@ -40,6 +41,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterController import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonImpl import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.network.MockPlatformParameterService @@ -85,6 +87,9 @@ import javax.inject.Singleton manifest = Config.NONE ) class PlatformParameterSyncUpWorkerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var platformParameterSingleton: PlatformParameterSingleton @Inject lateinit var platformParameterController: PlatformParameterController @Inject lateinit var platformParameterSyncUpWorkerFactory: PlatformParameterSyncUpWorkerFactory 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 1abb3c13590..7b5a5f345ac 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 @@ -16,7 +16,7 @@ import kotlinx.coroutines.Deferred import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow -import org.junit.After +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -37,7 +37,11 @@ import org.oppia.android.domain.oppialogger.ApplicationIdSeed import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.LoggingIdentifierController import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule +import org.oppia.android.domain.platformparameter.PlatformParameterModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.BuildEnvironment +import org.oppia.android.testing.DisableFeatureFlag +import org.oppia.android.testing.EnableFeatureFlag import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn @@ -63,12 +67,7 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics -import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds -import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 -import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.PlatformParameterValue +import org.oppia.android.util.platformparameter.FeatureFlag import org.oppia.android.util.threading.BackgroundDispatcher import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -87,6 +86,7 @@ import javax.inject.Singleton class ProfileManagementControllerTest { @get:Rule val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var profileManagementController: ProfileManagementController @@ -123,10 +123,9 @@ class ProfileManagementControllerTest { private const val CURRENT_TIMESTAMP = 1556094120000 } - @After - fun tearDown() { - TestModule.enableLearnerStudyAnalytics = false - TestModule.enableOnboardingFlowV2 = false + @Before + fun setUp() { + setUpTestApplicationComponent() } @Test @@ -151,8 +150,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAddProfile_addSoleLearnerProfile_onboardingV2Enabled_checkProfileIsAdded() { - setUpTestWithOnboardingV2Enabled(true) val dataProvider = addAdminProfile(name = "James", pin = "") monitorFactory.waitForNextSuccessfulResult(dataProvider) @@ -171,8 +170,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAddProfile_addSupervisorProfile_withPin_onboardingV2Enabled_checkProfileIsAdded() { - setUpTestWithOnboardingV2Enabled(true) val dataProvider = addAdminProfile(name = "James") monitorFactory.waitForNextSuccessfulResult(dataProvider) @@ -191,8 +190,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAddProfile_addAdditionalLearnerProfile_withPin_onboardingV2Enabled_checkProfileIsAdded() { - setUpTestWithOnboardingV2Enabled(true) val dataProvider = addNonAdminProfile(name = "James") monitorFactory.waitForNextSuccessfulResult(dataProvider) @@ -211,8 +210,8 @@ class ProfileManagementControllerTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAddProfile_addProfile_withPin_onboardingV2Disabled_checkProfileTypeIsNotSet() { - setUpTestWithOnboardingV2Enabled(false) val dataProvider = addAdminProfile(name = "James") monitorFactory.waitForNextSuccessfulResult(dataProvider) @@ -232,8 +231,8 @@ class ProfileManagementControllerTest { } @Test + @DisableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testAddProfile_addProfile_withoutPin_onboardingV2Disabled_checkProfileTypeIsNotSet() { - setUpTestWithOnboardingV2Enabled(false) val dataProvider = addAdminProfile(name = "James", pin = "") monitorFactory.waitForNextSuccessfulResult(dataProvider) @@ -253,8 +252,8 @@ class ProfileManagementControllerTest { } @Test + @DisableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testAddProfile_addProfile_studyOff_checkProfileDoesNotIncludeLearnerId() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() val dataProvider = addAdminProfile(name = "James", pin = "123") monitorFactory.waitForNextSuccessfulResult(dataProvider) @@ -266,8 +265,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testAddProfile_addProfile_studyOn_checkProfileDoesNotIncludeLearnerId() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() val dataProvider = addAdminProfile(name = "James", pin = "123") monitorFactory.waitForNextSuccessfulResult(dataProvider) @@ -279,7 +278,6 @@ class ProfileManagementControllerTest { @Test fun testAddProfile_addProfileWithNotUniqueName_checkResultIsFailure() { - setUpTestApplicationComponent() addTestProfiles() val dataProvider = addAdminProfile(name = "JAMES", pin = "321") @@ -290,7 +288,6 @@ class ProfileManagementControllerTest { @Test fun testAddProfile_addProfileWithNumberInName_checkResultIsFailure() { - setUpTestApplicationComponent() addTestProfiles() val dataProvider = addAdminProfile(name = "James034", pin = "321") @@ -301,7 +298,6 @@ class ProfileManagementControllerTest { @Test fun testGetProfile_addManyProfiles_checkGetProfileIsCorrect() { - setUpTestApplicationComponent() addTestProfiles() val dataProvider = profileManagementController.getProfile(PROFILE_ID_3) @@ -316,7 +312,6 @@ class ProfileManagementControllerTest { @Test fun testGetProfiles_addManyProfiles_checkAllProfilesAreAdded() { - setUpTestApplicationComponent() addTestProfiles() val dataProvider = profileManagementController.getProfiles() @@ -330,7 +325,6 @@ class ProfileManagementControllerTest { @Test fun testGetProfiles_addManyProfiles_restartApplication_addProfile_checkAllProfilesAreAdded() { - setUpTestApplicationComponent() addTestProfiles() setUpTestApplicationComponent() @@ -345,8 +339,8 @@ class ProfileManagementControllerTest { } @Test + @DisableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testUpdateLearnerId_addProfiles_updateLearnerIdWithSeed_withoutStudy_learnerIdIsUnchanged() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() addTestProfiles() testCoroutineDispatchers.runCurrent() @@ -361,8 +355,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testUpdateLearnerId_addProfiles_updateLearnerIdWithSeed_withStudy_learnerIdIsUnchanged() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() addTestProfiles() testCoroutineDispatchers.runCurrent() @@ -376,8 +370,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testGetCurrentProfileId_noProfileLoggedIn_returnsNull() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() addTestProfiles() val currentProfileId = profileManagementController.getCurrentProfileId() @@ -387,8 +381,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testGetCurrentProfileId_withProfileLoggedIn_returnsLoggedInProfileId() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -401,8 +395,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testGetCurrentProfileId_withProfileLoggedIn_thenAnother_returnsLatestLoggedInProfileId() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -419,7 +413,6 @@ class ProfileManagementControllerTest { @Test fun testFetchCurrentLearnerId_noLoggedInProfile_returnsNull() { - setUpTestApplicationComponent() addTestProfiles() val learnerId = fetchSuccessfulAsyncValue(profileManagementController::fetchCurrentLearnerId) @@ -429,7 +422,6 @@ class ProfileManagementControllerTest { @Test fun testFetchContinueButtonAnimationStatus_logInProfile1_checkStatusForProfile2IsFalse() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -444,7 +436,6 @@ class ProfileManagementControllerTest { @Test fun testFetchContinueButtonAnimationStatus_realProfile_notSeen_returnsFalse() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -458,7 +449,6 @@ class ProfileManagementControllerTest { @Test fun testFetchContinueButtonAnimationStatus_realProfile_markedAsSeen_returnsTrue() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -478,7 +468,6 @@ class ProfileManagementControllerTest { @Test fun testFetchContinueButtonAnimationStatus_realProfile_markedAsSeenTwice_returnsTrue() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -502,7 +491,6 @@ class ProfileManagementControllerTest { @Test fun testFetchContinueButtonAnimationStatus_realProfile_markedAsSeen_inDiffProfile_returnsFalse() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -525,8 +513,8 @@ class ProfileManagementControllerTest { } @Test + @DisableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testFetchCurrentLearnerId_loggedInProfile_createdWithStudyOff_returnsEmptyString() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -538,8 +526,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testFetchCurrentLearnerId_loggedInProfile_createdWithStudyOn_returnsEmptyString() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -552,7 +540,6 @@ class ProfileManagementControllerTest { @Test fun testFetchLearnerId_nonExistentProfile_returnsNull() { - setUpTestApplicationComponent() val learnerId = fetchSuccessfulAsyncValue { profileManagementController.fetchLearnerId(PROFILE_ID_2) @@ -562,8 +549,8 @@ class ProfileManagementControllerTest { } @Test + @DisableFeatureFlag(FeatureFlag.LEARNER_STUDY_ANALYTICS) fun testFetchLearnerId_createdProfileWithStudyOff_returnsEmptyString() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() addTestProfiles() val learnerId = fetchSuccessfulAsyncValue { @@ -574,8 +561,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testFetchLearnerId_createdProfileWithStudyOn_returnsEmptyString() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() addTestProfiles() val learnerId = fetchSuccessfulAsyncValue { @@ -587,7 +574,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateName_addProfiles_updateWithUniqueName_checkUpdateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController.updateName(PROFILE_ID_2, "John") @@ -600,7 +586,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateName_addProfiles_updateWithNotUniqueName_checkUpdatedFailed() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController.updateName(PROFILE_ID_2, "James") @@ -611,7 +596,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateName_addProfiles_updateWithBadProfileId_checkUpdatedFailed() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController.updateName(PROFILE_ID_6, "John") @@ -622,7 +606,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateName_addProfiles_updateProfileAvatar_checkUpdateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController @@ -640,7 +623,6 @@ class ProfileManagementControllerTest { @Test fun testUpdatePin_addProfiles_updatePin_checkUpdateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController.updatePin(PROFILE_ID_2, "321") @@ -653,7 +635,6 @@ class ProfileManagementControllerTest { @Test fun testUpdatePin_addProfiles_updateWithBadProfileId_checkUpdateFailed() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController.updatePin(PROFILE_ID_6, "321") @@ -665,7 +646,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateAllowDownloadAccess_addProfiles_updateDownloadAccess_checkUpdateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController.updateAllowDownloadAccess(PROFILE_ID_2, false) @@ -678,7 +658,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateAllowDownloadAccess_addProfiles_updateWithBadProfileId_checkUpdatedFailed() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController.updateAllowDownloadAccess(PROFILE_ID_6, false) @@ -690,7 +669,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_badProfileId_updateFails() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -703,7 +681,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_noPerm_enablePermission_updateSucceeds() { - setUpTestApplicationComponent() addProfileForLanguageSwitching(allowInLessonQuickLanguageSwitching = false) val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -717,7 +694,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_noPerm_enablePermission_profileCanNowSwitchLangs() { - setUpTestApplicationComponent() addProfileForLanguageSwitching(allowInLessonQuickLanguageSwitching = false) val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -732,7 +708,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_noPerm_disablePermission_updateSucceeds() { - setUpTestApplicationComponent() addProfileForLanguageSwitching(allowInLessonQuickLanguageSwitching = false) val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -746,7 +721,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_noPerm_disablePermission_profileCannotSwitchLangs() { - setUpTestApplicationComponent() addProfileForLanguageSwitching(allowInLessonQuickLanguageSwitching = false) val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -760,7 +734,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_withPerm_enablePermission_updateSucceeds() { - setUpTestApplicationComponent() addProfileForLanguageSwitching(allowInLessonQuickLanguageSwitching = true) val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -774,7 +747,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_withPerm_enablePermission_profileCanSwitchLangs() { - setUpTestApplicationComponent() addProfileForLanguageSwitching(allowInLessonQuickLanguageSwitching = true) val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -788,7 +760,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_withPerm_disablePermission_updateSucceeds() { - setUpTestApplicationComponent() addProfileForLanguageSwitching(allowInLessonQuickLanguageSwitching = true) val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -802,7 +773,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateEnableInLessonLangSwitching_withPerm_disablePerm_profileCannotNowSwitchLangs() { - setUpTestApplicationComponent() addProfileForLanguageSwitching(allowInLessonQuickLanguageSwitching = true) val updateProvider = profileManagementController.updateEnableInLessonQuickLanguageSwitching( @@ -817,7 +787,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateReadingTextSize_addProfiles_updateWithFontSize18_checkUpdateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -833,7 +802,6 @@ class ProfileManagementControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testGetAudioLanguage_initialProfileCreation_defaultsToEnglish() { - setUpTestApplicationComponent() addTestProfiles() @@ -844,7 +812,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateAudioLanguage_updateToHindi_updateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -857,7 +824,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateAudioLanguage_updateToBrazilianPortuguese_updateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -870,7 +836,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateAudioLanguage_updateToArabic_updateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -883,7 +848,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateAudioLanguage_updateToNigerianPidgin_updateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -898,7 +862,6 @@ class ProfileManagementControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToHindi_updateChangesAudioLanguage() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -914,7 +877,6 @@ class ProfileManagementControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToBrazilianPortuguese_updateChangesAudioLanguage() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -930,7 +892,6 @@ class ProfileManagementControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToArabic_updateChangesAudioLanguage() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -946,7 +907,6 @@ class ProfileManagementControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToNigerianPidgin_updateChangesAudioLanguage() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -962,7 +922,6 @@ class ProfileManagementControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToArabicThenEnglish_updateChangesAudioLanguageToEnglish() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider1 = profileManagementController.updateAudioLanguage(PROFILE_ID_2, NIGERIAN_PIDGIN_LANGUAGE) @@ -981,7 +940,6 @@ class ProfileManagementControllerTest { @Test @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateProfile1ToArabic_profile2IsUnchanged() { - setUpTestApplicationComponent() addTestProfiles() val updateProvider = @@ -995,7 +953,6 @@ class ProfileManagementControllerTest { @Test fun testDeleteProfile_addProfiles_deleteProfile_checkDeletionIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() val deleteProvider = profileManagementController.deleteProfile(PROFILE_ID_2) @@ -1008,7 +965,6 @@ class ProfileManagementControllerTest { @Test fun testDeleteProfile_addProfiles_deleteProfiles_addProfile_checkIdIsNotReused() { - setUpTestApplicationComponent() addTestProfiles() profileManagementController.deleteProfile(PROFILE_ID_3).ensureExecutes() @@ -1029,14 +985,12 @@ class ProfileManagementControllerTest { @Test fun testDeleteProfile_addProfiles_deleteProfiles_restartApplication_checkDeletionIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() profileManagementController.deleteProfile(PROFILE_ID_1).ensureExecutes() profileManagementController.deleteProfile(PROFILE_ID_2).ensureExecutes() profileManagementController.deleteProfile(PROFILE_ID_3).ensureExecutes() testCoroutineDispatchers.runCurrent() - setUpTestApplicationComponent() val profilesProvider = profileManagementController.getProfiles() val profiles = monitorFactory.waitForNextSuccessfulResult(profilesProvider) @@ -1050,7 +1004,6 @@ class ProfileManagementControllerTest { @Test fun testLoginProfile_addedProfile_profileIdTimestampAndNumberOfLoginsIsCorrectlyUpdated() { - setUpTestApplicationComponent() addTestProfiles() val loginProvider = profileManagementController.loginToProfile(PROFILE_ID_2) @@ -1065,7 +1018,6 @@ class ProfileManagementControllerTest { @Test fun testLoginToProfile_addProfile_loginToProfileTwice_checkNumberOfLoginsIsTwo() { - setUpTestApplicationComponent() addTestProfiles() var loginProvider = profileManagementController.loginToProfile(PROFILE_ID_2) monitorFactory.waitForNextSuccessfulResult(loginProvider) @@ -1083,7 +1035,6 @@ class ProfileManagementControllerTest { @Test fun testLoginToProfile_addProfiles_loginToProfileWithBadProfileId_checkLoginFailed() { - setUpTestApplicationComponent() addTestProfiles() val loginProvider = profileManagementController.loginToProfile(PROFILE_ID_6) @@ -1099,7 +1050,6 @@ class ProfileManagementControllerTest { @Test fun testLogInToProfile_sessionIdHasChanged() { - setUpTestApplicationComponent() addTestProfiles() val previousSessionId = retrieveCurrentSessionId() @@ -1114,7 +1064,6 @@ class ProfileManagementControllerTest { @Test fun testLogInToProfile_thenToSameProfileAgain_sessionIdHasChangedAgain() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -1133,7 +1082,6 @@ class ProfileManagementControllerTest { @Test fun testLogInToProfile_thenToAnotherProfile_sessionIdHasChangedAgain() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_1) @@ -1151,7 +1099,6 @@ class ProfileManagementControllerTest { @Test fun testLogInToProfile_invalidProfile_sessionIdDoesNotChange() { - setUpTestApplicationComponent() addTestProfiles() val previousSessionId = retrieveCurrentSessionId() @@ -1166,7 +1113,6 @@ class ProfileManagementControllerTest { @Test fun testWasProfileEverAdded_addAdminProfile_checkIfProfileEverAdded() { - setUpTestApplicationComponent() val addProvider = addAdminProfile(name = "James", pin = "123") monitorFactory.waitForNextSuccessfulResult(addProvider) @@ -1177,7 +1123,6 @@ class ProfileManagementControllerTest { @Test fun testWasProfileEverAdded_addAdminProfile_getWasProfileEverAdded() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") val wasProfileAddedProvider = profileManagementController.getWasProfileEverAdded() @@ -1188,7 +1133,6 @@ class ProfileManagementControllerTest { @Test fun testWasProfileEverAdded_addAdminProfile_addUserProfile_checkIfProfileEverAdded() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") addNonAdminProfileAndWait(name = "Rajat", pin = "01234") @@ -1200,7 +1144,6 @@ class ProfileManagementControllerTest { @Test fun testWasProfileEverAdded_addAdminProfile_addUserProfile_getWasProfileEverAdded() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") addNonAdminProfileAndWait(name = "Rajat", pin = "01234") @@ -1213,7 +1156,6 @@ class ProfileManagementControllerTest { @Test fun testWasProfileEverAdded_addAdminProfile_addUserProfile_deleteUserProfile_profileIsAdded() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") addNonAdminProfileAndWait(name = "Rajat", pin = "01234") @@ -1226,7 +1168,6 @@ class ProfileManagementControllerTest { @Test fun testWasProfileEverAdded_addAdminProfile_addUserProfile_deleteUserProfile_profileWasAdded() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") addNonAdminProfileAndWait(name = "Rajat", pin = "01234") profileManagementController.deleteProfile(PROFILE_ID_1).ensureExecutes() @@ -1240,8 +1181,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.LOGGING_LEARNER_STUDY_IDS) fun testDeleteProfile_logsDeleteProfileEvent() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() addTestProfiles() monitorFactory.ensureDataProviderExecutes( @@ -1258,7 +1199,6 @@ class ProfileManagementControllerTest { @Test fun testAddAdminProfile_addAnotherAdminProfile_checkSecondAdminProfileWasNotAdded() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "Rohit") val addProfile2 = addAdminProfile(name = "Ben") @@ -1269,7 +1209,6 @@ class ProfileManagementControllerTest { @Test fun testDeviceSettings_addAdminProfile_getDefaultDeviceSettings_isSuccessful() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") val deviceSettingsProvider = profileManagementController.getDeviceSettings() @@ -1281,7 +1220,6 @@ class ProfileManagementControllerTest { @Test fun testDeviceSettings_addAdminProfile_updateDeviceWifiSettings_getDeviceSettings_isSuccessful() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") val updateProvider = profileManagementController.updateWifiPermissionDeviceSettings( @@ -1298,7 +1236,6 @@ class ProfileManagementControllerTest { @Test fun testDeviceSettings_addAdminProfile_updateTopicsAutoDeviceSettings_isSuccessful() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") val updateProvider = @@ -1315,7 +1252,6 @@ class ProfileManagementControllerTest { @Test fun testDeviceSettings_addAdminProfile_updateDeviceWifiSettings_andTopicDevSettings_succeeds() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") val updateProvider1 = @@ -1337,7 +1273,6 @@ class ProfileManagementControllerTest { @Test fun testDeviceSettings_updateDeviceWifiSettings_fromUserProfile_isFailure() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") addNonAdminProfileAndWait(name = "Rajat", pin = "01234") @@ -1351,7 +1286,6 @@ class ProfileManagementControllerTest { @Test fun testDeviceSettings_updateTopicsAutomaticallyDeviceSettings_fromUserProfile_isFailure() { - setUpTestApplicationComponent() addAdminProfileAndWait(name = "James") addNonAdminProfileAndWait(name = "Rajat", pin = "01234") @@ -1365,7 +1299,6 @@ class ProfileManagementControllerTest { @Test fun testFetchSurveyLastShownTime_realProfile_beforeFirstSurveyShown_returnsDefaultTimestamp() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( @@ -1383,7 +1316,6 @@ class ProfileManagementControllerTest { @Test fun testFetchSurveyLastShownTime_updateLastShownTimeFunctionCalled_returnsCurrentTime() { - setUpTestApplicationComponent() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(CURRENT_TIMESTAMP) addTestProfiles() @@ -1408,7 +1340,6 @@ class ProfileManagementControllerTest { @Test fun testFetchSurveyLastShownTime_updateLastShownTime_inOneProfile_doesNotUpdateOtherProfiles() { - setUpTestApplicationComponent() oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) oppiaClock.setCurrentTimeMs(CURRENT_TIMESTAMP) addTestProfiles() @@ -1437,7 +1368,6 @@ class ProfileManagementControllerTest { @Test fun testFetchLastSelectedClassroomId_updateClassroomId_checkUpdateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( @@ -1460,7 +1390,6 @@ class ProfileManagementControllerTest { @Test fun testFetchLastSelectedClassroomId_updateClassroomIdTwice_checkUpdateIsSuccessful() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( @@ -1490,7 +1419,6 @@ class ProfileManagementControllerTest { @Test fun testFetchLastSelectedClassroomId_updateClassroomIds_checkUpdateIsSuccessfulPerProfile() { - setUpTestApplicationComponent() addTestProfiles() // Login to profile 0 and update the last selected classroom to classroom 1. @@ -1530,7 +1458,6 @@ class ProfileManagementControllerTest { @Test fun testFetchLastSelectedClassroomId_withoutUpdatingClassroomId_returnEmptyClassroomId() { - setUpTestApplicationComponent() addTestProfiles() monitorFactory.ensureDataProviderExecutes( @@ -1544,7 +1471,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateProfile_updateMultipleFields_checkUpdateIsSuccessful() { - setUpTestApplicationComponent() profileTestHelper.createDefaultAdminProfile() val updateProvider = profileManagementController.updateNewProfileDetails( @@ -1569,7 +1495,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateProfile_updateMultipleFields_invalidName_checkNameUpdateFailed() { - setUpTestApplicationComponent() profileTestHelper.createDefaultAdminProfile() val updateProvider = profileManagementController.updateNewProfileDetails( @@ -1587,7 +1512,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateProfile_updateMultipleFields_nullAvatarUri_setsAvatarColorSuccessfully() { - setUpTestApplicationComponent() profileTestHelper.createDefaultAdminProfile() val updateProvider = profileManagementController.updateNewProfileDetails( @@ -1612,7 +1536,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateProfile_updateMultipleFields_unspecifiedProfileType_returnsProfileTypeError() { - setUpTestApplicationComponent() profileTestHelper.createDefaultAdminProfile() val updateProvider = profileManagementController.updateNewProfileDetails( @@ -1630,7 +1553,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateProfile_updateMultipleFields_invalidProfileId_checkUpdateFailed() { - setUpTestApplicationComponent() profileTestHelper.createDefaultAdminProfile() val updateProvider = profileManagementController.updateNewProfileDetails( @@ -1649,7 +1571,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateExistingAdminProfile_updateProfileTypeToSupervisor_checkProfileTypeSupervisor() { - setUpTestApplicationComponent() profileTestHelper.addOnlyAdminProfile() val updateProvider = profileManagementController.updateProfileType( @@ -1665,7 +1586,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateExistingPinlessAdmin_updateProfileTypeToSoleLearner_checkProfileTypeSoleLearner() { - setUpTestApplicationComponent() addAdminProfile(name = "Admin", pin = "") val updateProvider = profileManagementController.updateProfileType( @@ -1681,7 +1601,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateExistingNonAdminProfile_updateProfileTypeToLearner_checkProfileTypeAddLearner() { - setUpTestApplicationComponent() addAdminProfile("Admin") addNonAdminProfileAndWait(name = "Rajat", pin = "01234") @@ -1698,7 +1617,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateDefaultProfile_profileTypeToSoleLearner_checkProfileTypeSoleLearner() { - setUpTestApplicationComponent() profileTestHelper.createDefaultAdminProfile() val updateProvider = profileManagementController.updateProfileType( @@ -1714,7 +1632,6 @@ class ProfileManagementControllerTest { @Test fun testUpdateDefaultProfile_profileTypeUnspecified_returnsProfileTypeError() { - setUpTestApplicationComponent() profileTestHelper.createDefaultAdminProfile() val updateProvider = profileManagementController.updateProfileType( @@ -1727,6 +1644,7 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileMigration_getExistingNonAdminProfile_checkProfileTypeIsAdditionalLearner() { // Simulate profiles already created in a previous app instance. executeInPreviousAppInstance { testComponent -> @@ -1749,13 +1667,13 @@ class ProfileManagementControllerTest { testComponent.getTestCoroutineDispatchers().runCurrent() } - setUpTestWithOnboardingV2Enabled(true) val getProfileProvider = profileManagementController.getProfile(PROFILE_ID_1) val profile = monitorFactory.waitForNextSuccessfulResult(getProfileProvider) assertThat(profile.profileType).isEqualTo(ProfileType.ADDITIONAL_LEARNER) } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileMigration_getExistingAdminWithPin_checkProfileTypeIsSupervisor() { // Simulate profiles already created in a previous app instance. executeInPreviousAppInstance { testComponent -> @@ -1778,13 +1696,13 @@ class ProfileManagementControllerTest { testComponent.getTestCoroutineDispatchers().runCurrent() } - setUpTestWithOnboardingV2Enabled(true) val getProfileProvider = profileManagementController.getProfile(PROFILE_ID_0) val profile = monitorFactory.waitForNextSuccessfulResult(getProfileProvider) assertThat(profile.profileType).isEqualTo(ProfileType.SUPERVISOR) } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileMigration_getExistingAdminWithoutPin_checkProfileTypeIsSoleLearner() { // Simulate profiles already created in a previous app instance. executeInPreviousAppInstance { testComponent -> @@ -1799,15 +1717,14 @@ class ProfileManagementControllerTest { testComponent.getTestCoroutineDispatchers().runCurrent() } - setUpTestWithOnboardingV2Enabled(true) val getProfileProvider = profileManagementController.getProfile(PROFILE_ID_0) val profile = monitorFactory.waitForNextSuccessfulResult(getProfileProvider) assertThat(profile.profileType).isEqualTo(ProfileType.SOLE_LEARNER) } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileOnboardingState_oneAdminProfileWithoutPassword_returnsSoleLeanerTypeMode() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfileAndWait(name = "James", pin = "") val updateProfileProvider = @@ -1824,8 +1741,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileOnboardingState_oneAdminProfileWithPassword_returnsAdminOnlyMode() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfileAndWait(name = "James") val updateProfileProvider = @@ -1840,8 +1757,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileOnboardingState_multipleProfiles_returnsMultipleProfilesTypeMode() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfileAndWait(name = "James") addNonAdminProfileAndWait(name = "Rajat", pin = "01234") addNonAdminProfileAndWait(name = "Rohit", pin = "") @@ -1854,8 +1771,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileOnboardingState_noProfilesFound_returnsNewInstallTypeMode() { - setUpTestWithOnboardingV2Enabled(true) val profileOnboardingModeProvider = profileManagementController.getProfileOnboardingMode() val profileOnboardingModeResult = @@ -1865,8 +1782,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileOnboardingState_existingProfilesV1_returnsUnknownProfileTypeMode() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfileAndWait(name = "James") val profileOnboardingModeProvider = profileManagementController.getProfileOnboardingMode() @@ -1877,24 +1794,24 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testGetProfile_createAdmin_returnsSupervisorType() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfile(name = "James") val profile = retrieveProfile(PROFILE_ID_0) assertThat(profile.profileType).isEqualTo(ProfileType.SUPERVISOR) } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testGetProfile_createSoleLearner_returnsSoleLearnerType() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfile(name = "James", pin = "") val profile = retrieveProfile(PROFILE_ID_0) assertThat(profile.profileType).isEqualTo(ProfileType.SOLE_LEARNER) } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testGetProfile_createAdditionalLearner_returnsAdditionalLearnerType() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfile(name = "James") addNonAdminProfile(name = "Rajat") val profile = retrieveProfile(PROFILE_ID_1) @@ -1902,8 +1819,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileOnboarding_markOnboardingStarted_logsStartProfileOnboardingEvent() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfile(name = "James", pin = "") val onboardingProvider = profileManagementController.markProfileOnboardingStarted(PROFILE_ID_0) monitorFactory.ensureDataProviderExecutes(onboardingProvider) @@ -1914,8 +1831,8 @@ class ProfileManagementControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_ONBOARDING_FLOW_V2) fun testProfileOnboarding_markOnboardingCompleted_logsEndProfileOnboardingEvent() { - setUpTestWithOnboardingV2Enabled(true) addAdminProfile(name = "James", pin = "") val onboardingProvider = profileManagementController.markProfileOnboardingEnded(PROFILE_ID_0) monitorFactory.ensureDataProviderExecutes(onboardingProvider) @@ -2062,21 +1979,6 @@ class ProfileManagementControllerTest { private fun DataProvider.ensureExecutes() = monitorFactory.ensureDataProviderExecutes(this) - private fun setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() { - TestModule.enableLearnerStudyAnalytics = false - setUpTestApplicationComponent() - } - - private fun setUpTestApplicationComponentWithLearnerAnalyticsStudy() { - TestModule.enableLearnerStudyAnalytics = true - setUpTestApplicationComponent() - } - - private fun setUpTestWithOnboardingV2Enabled(enableOnboardingV2: Boolean) { - TestModule.enableOnboardingFlowV2 = enableOnboardingV2 - setUpTestApplicationComponent() - } - private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) } @@ -2097,13 +1999,6 @@ class ProfileManagementControllerTest { // TODO(#89): Move this to a common test application component. @Module class TestModule { - internal companion object { - // This is expected to be off by default, so this helps the tests above confirm that the - // feature's default value is, indeed, off. - var enableLearnerStudyAnalytics = LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE - var enableOnboardingFlowV2 = ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE - } - @Provides @Singleton fun provideContext(application: Application): Context { @@ -2123,40 +2018,6 @@ class ProfileManagementControllerTest { @GlobalLogLevel @Provides fun provideGlobalLogLevel(): LogLevel = LogLevel.VERBOSE - - // The scoping here is to ensure changes to the module value above don't change the parameter - // within the same application instance. - @Provides - @Singleton - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics(): PlatformParameterValue { - // Snapshot the value so that it doesn't change between injection and use. - val enableFeature = enableLearnerStudyAnalytics - return PlatformParameterValue.createDefaultParameter( - defaultValue = enableFeature - ) - } - - @Provides - @Singleton - @EnableLoggingLearnerStudyIds - fun provideLoggingLearnerStudyIds(): PlatformParameterValue { - // Snapshot the value so that it doesn't change between injection and use. - val enableFeature = enableLearnerStudyAnalytics - return PlatformParameterValue.createDefaultParameter( - defaultValue = enableFeature - ) - } - - @Provides - @EnableOnboardingFlowV2 - fun provideEnableOnboardingFlowV2(): PlatformParameterValue { - // Snapshot the value so that it doesn't change between injection and use. - val enableFeature = enableOnboardingFlowV2 - return PlatformParameterValue.createDefaultParameter( - defaultValue = enableFeature - ) - } } @Module @@ -2178,7 +2039,8 @@ class ProfileManagementControllerTest { TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, TestLoggingIdentifierModule::class, SyncStatusModule::class, AssetModule::class, - ApplicationLifecycleModule::class + ApplicationLifecycleModule::class, PlatformParameterModule::class, + PlatformParameterSingletonModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { diff --git a/domain/src/test/java/org/oppia/android/domain/question/QuestionTrainingControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/question/QuestionTrainingControllerTest.kt index 206dee7d22b..959ad598147 100644 --- a/domain/src/test/java/org/oppia/android/domain/question/QuestionTrainingControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/question/QuestionTrainingControllerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ProfileId @@ -41,6 +42,7 @@ import org.oppia.android.domain.topic.TEST_SKILL_ID_0 import org.oppia.android.domain.topic.TEST_SKILL_ID_1 import org.oppia.android.domain.topic.TEST_SKILL_ID_2 import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.robolectric.RobolectricModule @@ -70,6 +72,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = QuestionTrainingControllerTest.TestApplication::class) class QuestionTrainingControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var questionTrainingController: QuestionTrainingController @Inject lateinit var questionAssessmentProgressController: QuestionAssessmentProgressController @Inject lateinit var fakeExceptionLogger: FakeExceptionLogger diff --git a/domain/src/test/java/org/oppia/android/domain/spotlight/SpotlightStateControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/spotlight/SpotlightStateControllerTest.kt index a6d69f7e768..d16734ee864 100644 --- a/domain/src/test/java/org/oppia/android/domain/spotlight/SpotlightStateControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/spotlight/SpotlightStateControllerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ProfileId @@ -42,6 +43,7 @@ import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig @@ -70,6 +72,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = SpotlightStateControllerTest.TestApplication::class) class SpotlightStateControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var spotlightStateController: SpotlightStateController diff --git a/domain/src/test/java/org/oppia/android/domain/survey/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/survey/BUILD.bazel index a3fbfdef517..4906fc11ea6 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/survey/BUILD.bazel @@ -16,7 +16,6 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//domain/src/main/java/org/oppia/android/domain/survey:gating_controller", "//testing", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//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", 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 8ea319426f5..ac28d9bd75f 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 @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ProfileId @@ -18,7 +19,10 @@ import org.oppia.android.domain.exploration.ExplorationProgressModule 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.domain.platformparameter.PlatformParameterModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -36,8 +40,6 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics -import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -48,6 +50,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = SurveyControllerTest.TestApplication::class) class SurveyControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var fakeExceptionLogger: FakeExceptionLogger @@ -184,13 +189,6 @@ class SurveyControllerTest { @GlobalLogLevel @Provides fun provideGlobalLogLevel(): LogLevel = LogLevel.VERBOSE - - @Provides - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics(): PlatformParameterValue { - // Enable the study by default in tests. - return PlatformParameterValue.createDefaultParameter(defaultValue = true) - } } @Module @@ -213,6 +211,7 @@ class SurveyControllerTest { ExplorationProgressModule::class, TestLogReportingModule::class, AssetModule::class, NetworkConnectionUtilDebugModule::class, SyncStatusModule::class, LogStorageModule::class, TestLoggingIdentifierModule::class, TestAuthenticationModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt index b757364aab3..97512d30e17 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ProfileId @@ -18,13 +19,16 @@ import org.oppia.android.domain.exploration.ExplorationProgressModule 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.domain.platformparameter.PlatformParameterModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController 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.EnableFeatureFlag import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -41,7 +45,7 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FeatureFlag import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -56,6 +60,9 @@ private const val SESSION_LENGTH_MINIMUM = 300000L @LooperMode(LooperMode.Mode.PAUSED) @Config(application = SurveyGatingControllerTest.TestApplication::class) class SurveyGatingControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var fakeExceptionLogger: FakeExceptionLogger @@ -82,7 +89,6 @@ class SurveyGatingControllerTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableNpsSurvey(true) setUpTestApplicationComponent() profileTestHelper.initializeProfiles() } @@ -280,6 +286,7 @@ class SurveyGatingControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testGating_midMorning_isPastGracePeriod_minimumAggregateTimeMet_returnsTrue() { oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) startAndEndExplorationSession(SESSION_LENGTH_MINIMUM, PROFILE_ID_0, TEST_TOPIC_ID_0) @@ -299,6 +306,7 @@ class SurveyGatingControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testGating_midMorning_isPastGracePeriod_minimumAggregateTimeExceeded_returnsTrue() { oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) startAndEndExplorationSession(SESSION_LENGTH_LONG, PROFILE_ID_0, TEST_TOPIC_ID_0) @@ -384,6 +392,7 @@ class SurveyGatingControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testGating_afternoon_isPastGracePeriod_minimumAggregateTimeMet_returnsTrue() { oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) startAndEndExplorationSession(SESSION_LENGTH_MINIMUM, PROFILE_ID_0, TEST_TOPIC_ID_0) @@ -403,6 +412,7 @@ class SurveyGatingControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testGating_afternoon_isPastGracePeriod_minimumAggregateTimeExceeded_returnsTrue() { oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) startAndEndExplorationSession(SESSION_LENGTH_LONG, PROFILE_ID_0, TEST_TOPIC_ID_0) @@ -488,6 +498,7 @@ class SurveyGatingControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testGating_evening_isPastGracePeriod_minimumAggregateTimeMet_returnsTrue() { oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) startAndEndExplorationSession(SESSION_LENGTH_MINIMUM, PROFILE_ID_0, TEST_TOPIC_ID_0) @@ -552,6 +563,7 @@ class SurveyGatingControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testGating_otherCriteriaMet_multipleTopicsHaveTimeThreshold_triggersSurveyInEitherTopic() { oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_UPTIME_MILLIS) startAndEndExplorationSession(SESSION_LENGTH_LONG, PROFILE_ID_0, TEST_TOPIC_ID_0) @@ -571,6 +583,7 @@ class SurveyGatingControllerTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testGating_criteriaMetOnProfileTwo_afterSurveyShownOnProfileOne_triggersSurveyProfileTwo() { monitorFactory.ensureDataProviderExecutes( profileManagementController.loginToProfile(PROFILE_ID_0) @@ -620,10 +633,6 @@ class SurveyGatingControllerTest { @Module class TestModule { - internal companion object { - var enableLearnerStudyAnalytics = LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE - } - @Provides @Singleton fun provideContext(application: Application): Context { @@ -663,7 +672,8 @@ class SurveyGatingControllerTest { ApplicationLifecycleModule::class, TestDispatcherModule::class, LocaleProdModule::class, ExplorationProgressModule::class, TestLogReportingModule::class, AssetModule::class, NetworkConnectionUtilDebugModule::class, SyncStatusModule::class, LogStorageModule::class, - TestLoggingIdentifierModule::class, TestPlatformParameterModule::class + TestLoggingIdentifierModule::class, PlatformParameterModule::class, + PlatformParameterSingletonModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { 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 ea336df027a..fcd6f8844f7 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 @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EphemeralSurveyQuestion @@ -22,9 +23,12 @@ import org.oppia.android.domain.exploration.ExplorationProgressModule 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.domain.platformparameter.PlatformParameterModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.FakeFirestoreEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -43,9 +47,6 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics -import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -56,6 +57,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = SurveyProgressControllerTest.TestApplication::class) class SurveyProgressControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var fakeExceptionLogger: FakeExceptionLogger @@ -516,10 +520,6 @@ class SurveyProgressControllerTest { @Module class TestModule { - internal companion object { - var enableLearnerStudyAnalytics = LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE - } - @Provides @Singleton fun provideContext(application: Application): Context { @@ -538,13 +538,6 @@ class SurveyProgressControllerTest { @GlobalLogLevel @Provides fun provideGlobalLogLevel(): LogLevel = LogLevel.VERBOSE - - @Provides - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics(): PlatformParameterValue { - // Enable the study by default in tests. - return PlatformParameterValue.createDefaultParameter(defaultValue = true) - } } @Module @@ -567,6 +560,7 @@ class SurveyProgressControllerTest { ExplorationProgressModule::class, TestLogReportingModule::class, AssetModule::class, NetworkConnectionUtilDebugModule::class, SyncStatusModule::class, LogStorageModule::class, TestLoggingIdentifierModule::class, TestAuthenticationModule::class, + PlatformParameterModule::class, PlatformParameterSingletonModule::class ] ) diff --git a/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt index ac37fe5a6e0..9e0dc70b34f 100644 --- a/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ChapterPlayState @@ -19,6 +20,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.profile.ProfileTestHelper @@ -49,6 +51,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = StoryProgressControllerTest.TestApplication::class) class StoryProgressControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var storyProgressController: StoryProgressController @Inject lateinit var profileTestHelper: ProfileTestHelper 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 c483bf494dd..316fc050fef 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 @@ -12,6 +12,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AppLanguageSelection @@ -51,6 +52,7 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.robolectric.RobolectricModule @@ -83,6 +85,9 @@ import org.oppia.android.app.model.WrittenTranslationLanguageSelection.Selection @LooperMode(LooperMode.Mode.PAUSED) @Config(application = TranslationControllerTest.TestApplication::class) class TranslationControllerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var translationController: TranslationController diff --git a/domain/src/test/java/org/oppia/android/domain/util/InteractionObjectExtensionsTest.kt b/domain/src/test/java/org/oppia/android/domain/util/InteractionObjectExtensionsTest.kt index 8e3f3afd864..0afe7655985 100644 --- a/domain/src/test/java/org/oppia/android/domain/util/InteractionObjectExtensionsTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/util/InteractionObjectExtensionsTest.kt @@ -2,6 +2,7 @@ package org.oppia.android.domain.util import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ClickOnImage @@ -15,6 +16,7 @@ import org.oppia.android.app.model.ListOfSetsOfHtmlStrings import org.oppia.android.app.model.Point2d import org.oppia.android.app.model.RatioExpression import org.oppia.android.app.model.StringList +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -23,6 +25,8 @@ import org.robolectric.annotation.LooperMode @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class InteractionObjectExtensionsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Test fun testToAnswerStr_listOfSetsOfHtmlStrings_multipleLists_correctlyFormatsElements() { diff --git a/domain/src/test/java/org/oppia/android/domain/util/StateRetrieverTest.kt b/domain/src/test/java/org/oppia/android/domain/util/StateRetrieverTest.kt index b0a2d882258..71b2d8e2bf0 100644 --- a/domain/src/test/java/org/oppia/android/domain/util/StateRetrieverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/util/StateRetrieverTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AnswerGroup @@ -24,6 +25,7 @@ import org.oppia.android.app.model.SchemaObject.ObjectTypeCase.SUBTITLED_UNICODE import org.oppia.android.app.model.SetOfTranslatableHtmlContentIds import org.oppia.android.app.model.State import org.oppia.android.app.model.TranslatableHtmlContentId +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -58,6 +60,9 @@ class StateRetrieverTest { private val DRAG_DROP_CHOICE_CONTENT_ID_3 = createXlatableContentId(contentId = "ca_choices_3") } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var stateRetriever: StateRetriever @Inject lateinit var jsonAssetRetriever: JsonAssetRetriever diff --git a/domain/src/test/java/org/oppia/android/domain/util/StringExtensionsTest.kt b/domain/src/test/java/org/oppia/android/domain/util/StringExtensionsTest.kt index 4e42340ba6b..d84ee16f366 100644 --- a/domain/src/test/java/org/oppia/android/domain/util/StringExtensionsTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/util/StringExtensionsTest.kt @@ -2,8 +2,10 @@ package org.oppia.android.domain.util import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.extensions.normalizeWhitespace import org.oppia.android.util.extensions.removeWhitespace import org.robolectric.annotation.LooperMode @@ -12,6 +14,8 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class StringExtensionsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Test fun testRemoveWhitespace_stringWithoutSpaces_returnsOriginalString() { diff --git a/instrumentation/src/javatests/org/oppia/android/instrumentation/application/BUILD.bazel b/instrumentation/src/javatests/org/oppia/android/instrumentation/application/BUILD.bazel index 56bcf6097bf..9e8d46ab897 100644 --- a/instrumentation/src/javatests/org/oppia/android/instrumentation/application/BUILD.bazel +++ b/instrumentation/src/javatests/org/oppia/android/instrumentation/application/BUILD.bazel @@ -13,6 +13,7 @@ oppia_android_test( deps = [ "//:dagger", "//instrumentation/src/java/org/oppia/android/instrumentation/application:oppia_test_application", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:androidx_test_runner", "//third_party:com_google_truth_truth", @@ -30,6 +31,7 @@ oppia_android_test( deps = [ "//:dagger", "//instrumentation/src/java/org/oppia/android/instrumentation/application:oppia_test_application", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:androidx_test_runner", "//third_party:com_google_truth_truth", @@ -47,6 +49,7 @@ oppia_android_test( deps = [ "//:dagger", "//instrumentation/src/java/org/oppia/android/instrumentation/application:oppia_test_application", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:androidx_test_runner", "//third_party:com_google_truth_truth", diff --git a/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestGcsResourceModuleTest.kt b/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestGcsResourceModuleTest.kt index da0b0529df6..a12b2bfb5c0 100644 --- a/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestGcsResourceModuleTest.kt +++ b/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestGcsResourceModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.gcsresource.DefaultResourceBucketName import org.oppia.android.util.gcsresource.QuestionResourceBucketName import org.robolectric.annotation.Config @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = EndToEndTestGcsResourceModuleTest.TestApplication::class) class EndToEndTestGcsResourceModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @field:[Inject DefaultResourceBucketName] lateinit var defaultResourceBucketName: String diff --git a/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestImageParsingModuleTest.kt b/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestImageParsingModuleTest.kt index 34e16dfb090..7f3a316c91d 100644 --- a/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestImageParsingModuleTest.kt +++ b/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestImageParsingModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.parser.image.DefaultGcsPrefix import org.oppia.android.util.parser.image.ImageDownloadUrlTemplate import org.oppia.android.util.parser.image.ThumbnailDownloadUrlTemplate @@ -24,6 +26,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = EndToEndTestImageParsingModuleTest.TestApplication::class) class EndToEndTestImageParsingModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @field:[Inject DefaultGcsPrefix] lateinit var defaultGcsPrefix: String diff --git a/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestNetworkConfigModuleTest.kt b/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestNetworkConfigModuleTest.kt index 6718bc040ef..162c767e2aa 100644 --- a/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestNetworkConfigModuleTest.kt +++ b/instrumentation/src/javatests/org/oppia/android/instrumentation/application/EndToEndTestNetworkConfigModuleTest.kt @@ -10,10 +10,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.data.backends.gae.BaseUrl import org.oppia.android.data.backends.gae.XssiPrefix +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -23,6 +25,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = EndToEndTestNetworkConfigModuleTest.TestApplication::class) class EndToEndTestNetworkConfigModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @field:[Inject BaseUrl] lateinit var baseUrl: String diff --git a/scripts/assets/file_content_validation_checks.textproto b/scripts/assets/file_content_validation_checks.textproto index fe0d7d9aba9..30ee9dfa96a 100644 --- a/scripts/assets/file_content_validation_checks.textproto +++ b/scripts/assets/file_content_validation_checks.textproto @@ -606,6 +606,13 @@ file_content_checks { 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" } +file_content_checks { + file_path_regex: ".+?Test\\.kt" + required_content_regex: "@get:Rule\\s+val\\s+oppiaTestRule\\s*=\\s*OppiaTestRule\\(\\)" + failure_message: "Missing `OppiaTestRule` declaration." + exempted_file_name: "utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt" + exempted_file_name: "testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt" +} file_content_checks { file_path_regex: ".+?\\.kt" prohibited_content_regex: "computeIfAbsent\\(" diff --git a/scripts/assets/kdoc_validity_exemptions.textproto b/scripts/assets/kdoc_validity_exemptions.textproto index c82f70cd255..b91f236ad1e 100644 --- a/scripts/assets/kdoc_validity_exemptions.textproto +++ b/scripts/assets/kdoc_validity_exemptions.textproto @@ -294,7 +294,6 @@ exempted_file_path: "domain/src/test/java/org/oppia/android/domain/classify/Inte exempted_file_path: "instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/RichTextViewMatcher.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/espresso/ImageViewMatcher.kt" -exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/threading/TestCoroutineDispatcherRobolectricImpl.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/threading/TestCoroutineDispatchersEspressoImpl.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/threading/TestCoroutineDispatchersRobolectricImpl.kt" diff --git a/scripts/assets/test_file_exemptions.textproto b/scripts/assets/test_file_exemptions.textproto index c358c7d68a4..cc3a8d4fc4c 100644 --- a/scripts/assets/test_file_exemptions.textproto +++ b/scripts/assets/test_file_exemptions.textproto @@ -3950,6 +3950,14 @@ test_file_exemption { exempted_file_path: "testing/src/main/java/org/oppia/android/testing/DisableAccessibilityChecks.kt" test_file_not_required: true } +test_file_exemption { + exempted_file_path: "testing/src/main/java/org/oppia/android/testing/DisableFeatureFlag.kt" + test_file_not_required: true +} +test_file_exemption { + exempted_file_path: "testing/src/main/java/org/oppia/android/testing/EnableFeatureFlag.kt" + test_file_not_required: true +} test_file_exemption { exempted_file_path: "testing/src/main/java/org/oppia/android/testing/FakeAnalyticsEventLogger.kt" source_file_is_incompatible_with_code_coverage: true @@ -3990,6 +3998,22 @@ test_file_exemption { exempted_file_path: "testing/src/main/java/org/oppia/android/testing/OppiaTestRunner.kt" test_file_not_required: true } +test_file_exemption { + exempted_file_path: "testing/src/main/java/org/oppia/android/testing/OverrideBoolParameter.kt" + test_file_not_required: true +} +test_file_exemption { + exempted_file_path: "testing/src/main/java/org/oppia/android/testing/OverrideIntParameter.kt" + test_file_not_required: true +} +test_file_exemption { + exempted_file_path: "testing/src/main/java/org/oppia/android/testing/OverrideStringParameter.kt" + test_file_not_required: true +} +test_file_exemption { + exempted_file_path: "testing/src/main/java/org/oppia/android/testing/ResetFeatureFlagToDefault.kt" + test_file_not_required: true +} test_file_exemption { exempted_file_path: "testing/src/main/java/org/oppia/android/testing/RichTextViewMatcher.kt" test_file_not_required: true @@ -4175,11 +4199,11 @@ test_file_exemption { test_file_not_required: true } test_file_exemption { - exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt" + exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/PlatformParameterTestConstants.kt" test_file_not_required: true } test_file_exemption { - exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt" + exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/PlatformParameterTestConstantsModule.kt" test_file_not_required: true } test_file_exemption { 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 5f47d4b81e1..1c894356309 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -142,6 +142,7 @@ class RegexPatternValidationCheckTest { "presence of a screen name for this activity. To do this, add a test named " + "testActivity_createIntent_verifyScreenNameInIntent and verify that an appropriate screen " + "name has been added to the activity's intent." + private val missingOppiaTestRuleErrorMessage = "Missing `OppiaTestRule` declaration." private val doNotUseProtoLibrary = "Don't use proto_library. Use oppia_proto_library instead." private val parameterizedTestRunnerRequiresException = "To use OppiaParameterizedTestRunner, please add an exemption to" + @@ -1652,6 +1653,7 @@ class RegexPatternValidationCheckTest { @Test fun testFileContent_kotlinTestUsesParameterizedTestRunner_fileContentIsNotCorrect() { + val oppiaTestRule = "@get:Rule\n" + "val oppiaTestRule = OppiaTestRule()\n" val prohibitedContent = """ import org.oppia.android.testing.junit.OppiaParameterizedTestRunner @@ -1659,7 +1661,10 @@ class RegexPatternValidationCheckTest { """.trimIndent() tempFolder.newFolder("testfiles", "domain", "src", "test") val stringFilePath = "domain/src/test/SomeTest.kt" - tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) + tempFolder.newFile("testfiles/$stringFilePath").apply { + writeText(oppiaTestRule) + appendText(prohibitedContent) + } val exception = assertThrows() { runScript() } @@ -1667,8 +1672,8 @@ class RegexPatternValidationCheckTest { assertThat(outContent.toString().trim()) .isEqualTo( """ - $stringFilePath:1: $parameterizedTestRunnerRequiresException - $stringFilePath:2: $parameterizedTestRunnerRequiresException + $stringFilePath:3: $parameterizedTestRunnerRequiresException + $stringFilePath:4: $parameterizedTestRunnerRequiresException $wikiReferenceNote """.trimIndent() ) @@ -2365,9 +2370,10 @@ class RegexPatternValidationCheckTest { @Test fun testScreenNameTestPresence_activityTestWithoutScreenNameTest_screenNameTestIsNotPresent() { + val oppiaTestRule = "@get:Rule\n" + "val oppiaTestRule = OppiaTestRule()\n" tempFolder.newFolder("testfiles", "app", "src", "main", "activity") val stringFilePath = "app/src/main/activity/HomeActivityTest.kt" - tempFolder.newFile("testfiles/$stringFilePath") + tempFolder.newFile("testfiles/$stringFilePath").writeText(oppiaTestRule) val exception = assertThrows() { runScript() } @@ -2383,16 +2389,72 @@ class RegexPatternValidationCheckTest { @Test fun testScreenNameTestPresence_activityTestWithScreenNameTest_screenNameTestIsPresent() { + val oppiaTestRule = "@get:Rule\n" + "val oppiaTestRule = OppiaTestRule()\n" val requiredContent = "testActivity_createIntent_verifyScreenNameInIntent()" tempFolder.newFolder("testfiles", "app", "src", "main") val stringFilePath = "app/src/main/HomeActivityTest.kt" - tempFolder.newFile("testfiles/$stringFilePath").writeText(requiredContent) + tempFolder.newFile("testfiles/$stringFilePath").apply { + writeText(oppiaTestRule) + appendText(requiredContent) + } + + runScript() + + assertThat(outContent.toString().trim()).isEqualTo(REGEX_CHECK_PASSED_OUTPUT_INDICATOR) + } + + @Test + fun testFileContent_oppiaTestRuleDeclared_fileContentIsCorrect() { + val requiredOppiaTestRule = "@get:Rule\n" + "val oppiaTestRule = OppiaTestRule()" + tempFolder.newFolder("testfiles", "app", "src", "main") + val stringFilePath = "app/src/main/ExampleTest.kt" + tempFolder.newFile("testfiles/$stringFilePath").writeText(requiredOppiaTestRule) runScript() assertThat(outContent.toString().trim()).isEqualTo(REGEX_CHECK_PASSED_OUTPUT_INDICATOR) } + @Test + fun testFileContent_oppiaTestRuleNotDeclared_fileContentIsNotCorrect() { + val exampleTestRule = "@get:Rule\n" + "val exampleTestRule = ExampleTestRule()" + tempFolder.newFolder("testfiles", "app", "src", "main") + val stringFilePath = "app/src/main/ExampleTest.kt" + tempFolder.newFile("testfiles/$stringFilePath").writeText(exampleTestRule) + + val exception = assertThrows() { runScript() } + + assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) + + assertThat(outContent.toString().trim()) + .isEqualTo( + """ + $stringFilePath: $missingOppiaTestRuleErrorMessage + $wikiReferenceNote + """.trimIndent() + ) + } + + @Test + fun testFileContent_noTestRuleIncluded_fileContentIsNotCorrect() { + val testFileContent = "testActivity_createIntent_verifyScreenNameInIntent()" + tempFolder.newFolder("testfiles", "app", "src", "main") + val stringFilePath = "app/src/main/HomeActivityTest.kt" + tempFolder.newFile("testfiles/$stringFilePath").writeText(testFileContent) + + val exception = assertThrows() { runScript() } + + assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) + + assertThat(outContent.toString().trim()) + .isEqualTo( + """ + $stringFilePath: $missingOppiaTestRuleErrorMessage + $wikiReferenceNote + """.trimIndent() + ) + } + @Test fun testFileContent_referenceGetInstance_fileContentIsNotCorrect() { val prohibitedContent = @@ -2690,13 +2752,17 @@ class RegexPatternValidationCheckTest { @Test fun testFileContent_referencesActivityTestRule_fileContentIsNotCorrect() { + val oppiaTestRule = "@get:Rule\n" + "val oppiaTestRule = OppiaTestRule()\n" 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) + tempFolder.newFile("testfiles/$stringFilePath").apply { + writeText(oppiaTestRule) + appendText(prohibitedContent) + } val exception = assertThrows() { runScript() } @@ -2704,7 +2770,7 @@ class RegexPatternValidationCheckTest { assertThat(outContent.toString().trim()) .isEqualTo( """ - $stringFilePath:1: $activityTestRuleShouldNotBeUsed + $stringFilePath:3: $activityTestRuleShouldNotBeUsed $wikiReferenceNote """.trimIndent() ) @@ -2712,13 +2778,17 @@ class RegexPatternValidationCheckTest { @Test fun testFileContent_referencesActivityScenarioRule_fileContentIsNotCorrect() { + val oppiaTestRule = "@get:Rule\n" + "val oppiaTestRule = OppiaTestRule()\n" 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) + tempFolder.newFile("testfiles/$stringFilePath").apply { + writeText(oppiaTestRule) + appendText(prohibitedContent) + } val exception = assertThrows() { runScript() } @@ -2726,7 +2796,7 @@ class RegexPatternValidationCheckTest { assertThat(outContent.toString().trim()) .isEqualTo( """ - $stringFilePath:1: $activityScenarioRuleShouldNotBeUsed + $stringFilePath:3: $activityScenarioRuleShouldNotBeUsed $wikiReferenceNote """.trimIndent() ) diff --git a/testing/src/main/java/org/oppia/android/testing/DisableFeatureFlag.kt b/testing/src/main/java/org/oppia/android/testing/DisableFeatureFlag.kt new file mode 100644 index 00000000000..285b22fbbe0 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/DisableFeatureFlag.kt @@ -0,0 +1,14 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.FeatureFlag + +/** + * Repeatable test class or method annotation for disabling the feature flag for tests of the + * class or the specific method may run on. The feature flag names are provided by the + * FeatureFlagConstants.kt. + * + * Note that this annotation only works if the test also has an [OppiaTestRule] hooked up. + */ +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Repeatable +annotation class DisableFeatureFlag(val name: FeatureFlag) diff --git a/testing/src/main/java/org/oppia/android/testing/EnableFeatureFlag.kt b/testing/src/main/java/org/oppia/android/testing/EnableFeatureFlag.kt new file mode 100644 index 00000000000..b241bc1ddbd --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/EnableFeatureFlag.kt @@ -0,0 +1,14 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.FeatureFlag + +/** + * Repeatable test class or method annotation for enabling the feature flag for tests of the + * class or the specific method may run on. The feature flag names are provided by the + * FeatureFlagConstants.kt. + * + * Note that this annotation only works if the test also has an [OppiaTestRule] hooked up. + */ +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Repeatable +annotation class EnableFeatureFlag(val name: FeatureFlag) diff --git a/testing/src/main/java/org/oppia/android/testing/OppiaTestRule.kt b/testing/src/main/java/org/oppia/android/testing/OppiaTestRule.kt index 37880ffb335..70755657ed4 100644 --- a/testing/src/main/java/org/oppia/android/testing/OppiaTestRule.kt +++ b/testing/src/main/java/org/oppia/android/testing/OppiaTestRule.kt @@ -13,11 +13,13 @@ import org.junit.AssumptionViolatedException import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement +import org.oppia.android.domain.platformparameter.PlatformParameterModule private const val DEFAULT_ACCESSIBILITY_CHECKS_ENABLED_STATE = true /** JUnit rule to enable [RunOn] test targeting. */ class OppiaTestRule : TestRule { + override fun apply(base: Statement?, description: Description?): Statement { return object : Statement() { override fun evaluate() { @@ -27,46 +29,145 @@ class OppiaTestRule : TestRule { val currentPlatform = getCurrentPlatform() val currentEnvironment = getCurrentBuildEnvironment() - when { - currentPlatform in targetPlatforms && currentEnvironment in targetEnvironments -> { - // Only run this test if it's targeting the current platform & environment. - if (currentPlatform == TestPlatform.ESPRESSO && areAccessibilityChecksEnabled) { - AccessibilityChecks.enable().apply { - // Suppressing failures for all views which matches with below conditions as we do not - // want to change the UI to pass these failures as it will change the expected behaviour - // for learner. - setSuppressingResultMatcher( - allOf( - matchesCheckNames(`is`("TouchTargetSizeViewCheck")), - matchesViews(withContentDescription("More options")), - matchesViews(withClassName(endsWith("OverflowMenuButton"))) + val enabledFeatureFlags = extractParametersAndFeatureFlags( + description?.testClass?.annotations?.toList(), EnableFeatureFlag::class.java + ) + + extractParametersAndFeatureFlags(description?.annotations, EnableFeatureFlag::class.java) + + val disabledFeatureFlags = extractParametersAndFeatureFlags( + description?.testClass?.annotations?.toList(), DisableFeatureFlag::class.java + ) + + extractParametersAndFeatureFlags(description?.annotations, DisableFeatureFlag::class.java) + + val overriddenBoolParameters = extractParametersAndFeatureFlags( + description?.testClass?.annotations?.toList(), + OverrideBoolParameter::class.java + ) + + extractParametersAndFeatureFlags( + description?.annotations, + OverrideBoolParameter::class.java + ) + + val overriddenIntParameters = extractParametersAndFeatureFlags( + description?.testClass?.annotations?.toList(), + OverrideIntParameter::class.java + ) + + extractParametersAndFeatureFlags( + description?.annotations, + OverrideIntParameter::class.java + ) + + val overriddenStringParameters = extractParametersAndFeatureFlags( + description?.testClass?.annotations?.toList(), + OverrideStringParameter::class.java + ) + + extractParametersAndFeatureFlags( + description?.annotations, + OverrideStringParameter::class.java + ) + + val resetFeatureFlagToDefault = extractParametersAndFeatureFlags( + description?.annotations, ResetFeatureFlagToDefault::class.java + ) + + try { + applyOverrides( + enabledFeatureFlags, + disabledFeatureFlags, + overriddenBoolParameters, + overriddenIntParameters, + overriddenStringParameters, + resetFeatureFlagToDefault + ) + + when { + currentPlatform in targetPlatforms && currentEnvironment in targetEnvironments -> { + // Only run this test if it's targeting the current platform & environment. + if (currentPlatform == TestPlatform.ESPRESSO && areAccessibilityChecksEnabled) { + AccessibilityChecks.enable().apply { + // Suppressing failures for all views which matches with below conditions as we do not + // want to change the UI to pass these failures as it will change the expected behaviour + // for learner. + setSuppressingResultMatcher( + allOf( + matchesCheckNames(`is`("TouchTargetSizeViewCheck")), + matchesViews(withContentDescription("More options")), + matchesViews(withClassName(endsWith("OverflowMenuButton"))) + ) ) - ) - }.setRunChecksFromRootView(true) + }.setRunChecksFromRootView(true) + } + base?.evaluate() } - base?.evaluate() - } - currentPlatform !in targetPlatforms -> { - // See https://github.com/junit-team/junit4/issues/116 for context. - throw AssumptionViolatedException( - "Test targeting ${targetPlatforms.toPluralPlatformDescription()} ignored on" + - " $currentPlatform" - ) - } - currentEnvironment !in targetEnvironments -> { - throw AssumptionViolatedException( - "Test targeting ${targetEnvironments.toPluralEnvironmentDescription()} ignored on" + - " $currentEnvironment" - ) + currentPlatform !in targetPlatforms -> { + // See https://github.com/junit-team/junit4/issues/116 for context. + throw AssumptionViolatedException( + "Test targeting ${targetPlatforms.toPluralPlatformDescription()} ignored on" + + " $currentPlatform" + ) + } + currentEnvironment !in targetEnvironments -> { + throw AssumptionViolatedException( + "Test targeting ${targetEnvironments.toPluralEnvironmentDescription()} ignored on" + + " $currentEnvironment" + ) + } + else -> throw AssertionError("Reached impossible state in test rule") } - else -> throw AssertionError("Reached impossible state in test rule") + } finally { + PlatformParameterModule.clearAllParameterOverrides() } } } } + private fun applyOverrides( + enabledFeatureFlags: List?, + disabledFeatureFlags: List?, + overriddenBoolParameters: List?, + overriddenIntParameters: List?, + overriddenStringParameters: List?, + resetFeatureFlagToDefault: List? + ) { + enabledFeatureFlags?.forEach { flag -> + PlatformParameterModule.overrideFeatureFlags(flag.name, true) + } + + disabledFeatureFlags?.forEach { flag -> + PlatformParameterModule.overrideFeatureFlags(flag.name, false) + } + + resetFeatureFlagToDefault?.forEach { resetFeatureFlag -> + PlatformParameterModule.resetFeatureFlagToDefault(resetFeatureFlag.name) + } + + overriddenBoolParameters?.forEach { overriddenValue -> + PlatformParameterModule.overridePlatformParameters( + overriddenValue.name, overriddenValue.value + ) + } + + overriddenIntParameters?.forEach { overriddenValue -> + PlatformParameterModule.overridePlatformParameters( + overriddenValue.name, overriddenValue.value + ) + } + + overriddenStringParameters?.forEach { overriddenValue -> + PlatformParameterModule.overridePlatformParameters( + overriddenValue.name, overriddenValue.value + ) + } + } + private fun getCurrentPlatform(): TestPlatform { - return if (Build.FINGERPRINT.contains("robolectric", ignoreCase = true)) { + val fingerprint = try { + Build.FINGERPRINT + } catch (e: Exception) { + null + } ?: return TestPlatform.ROBOLECTRIC + + return if (fingerprint.contains("robolectric", ignoreCase = true)) { TestPlatform.ROBOLECTRIC } else { TestPlatform.ESPRESSO @@ -133,5 +234,34 @@ class OppiaTestRule : TestRule { private fun Class.areAccessibilityTestsEnabledForClass(): Boolean { return getAnnotation(DisableAccessibilityChecks::class.java) == null } + + /** + * Extracts all feature flag annotations of the specified type from a collection of annotations. + * + * @param annotations a collection of annotations to be checked for feature flag annotations. + * @param featureFlagClass the class of the feature flag annotation type to extract. + * @return a list of feature flag annotations of the specified type, + * including those found in container annotations. + */ + inline fun extractParametersAndFeatureFlags( + annotations: Collection?, + featureFlagClass: Class + ): List { + return annotations?.flatMap { annotation -> + when (annotation) { + is T -> listOf(annotation) + else -> { + val containerClass = annotation.annotationClass.java + if (containerClass.simpleName == "Container") { + val valueMethod = containerClass.getDeclaredMethod("value") + val flagsArray = valueMethod.invoke(annotation) as Array<*> + flagsArray.filterIsInstance(featureFlagClass) + } else { + emptyList() + } + } + } + } ?: emptyList() + } } } diff --git a/testing/src/main/java/org/oppia/android/testing/OverrideBoolParameter.kt b/testing/src/main/java/org/oppia/android/testing/OverrideBoolParameter.kt new file mode 100644 index 00000000000..afc8c4f797b --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/OverrideBoolParameter.kt @@ -0,0 +1,14 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.PlatformParameter + +/** + * Repeatable test class or method annotation for overriding boolean platform parameter values + * for tests of the class or the specific method may run on. The platform parameter names are provided + * by the PlatformParameterConstants.kt. + * + * Note that this annotation only works if the test also has an [OppiaTestRule] hooked up. + */ +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Repeatable +annotation class OverrideBoolParameter(val name: PlatformParameter, val value: Boolean) diff --git a/testing/src/main/java/org/oppia/android/testing/OverrideIntParameter.kt b/testing/src/main/java/org/oppia/android/testing/OverrideIntParameter.kt new file mode 100644 index 00000000000..dc280130f45 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/OverrideIntParameter.kt @@ -0,0 +1,14 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.PlatformParameter + +/** + * Repeatable test class or method annotation for overriding integer platform parameter values + * for tests of the class or the specific method may run on. The platform parameter names are provided + * by the PlatformParameterConstants.kt. + * + * Note that this annotation only works if the test also has an [OppiaTestRule] hooked up. + */ +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Repeatable +annotation class OverrideIntParameter(val name: PlatformParameter, val value: Int) diff --git a/testing/src/main/java/org/oppia/android/testing/OverrideStringParameter.kt b/testing/src/main/java/org/oppia/android/testing/OverrideStringParameter.kt new file mode 100644 index 00000000000..b31f8e62502 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/OverrideStringParameter.kt @@ -0,0 +1,14 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.PlatformParameter + +/** + * Repeatable test class or method annotation for overriding string platform parameter values + * for tests of the class or the specific method may run on. The platform parameter names are provided + * by the PlatformParameterConstants.kt. + * + * Note that this annotation only works if the test also has an [OppiaTestRule] hooked up. + */ +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Repeatable +annotation class OverrideStringParameter(val name: PlatformParameter, val value: String) diff --git a/testing/src/main/java/org/oppia/android/testing/ResetFeatureFlagToDefault.kt b/testing/src/main/java/org/oppia/android/testing/ResetFeatureFlagToDefault.kt new file mode 100644 index 00000000000..be6bf2f06ea --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/ResetFeatureFlagToDefault.kt @@ -0,0 +1,14 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.FeatureFlag + +/** + * Repeatable test method annotation for resetting the feature flag for tests of the + * specific method may run on. The feature flag names are provided by the + * FeatureFlagConstants.kt. + * + * Note that this annotation only works if the test also has an [OppiaTestRule] hooked up. + */ +@Target(AnnotationTarget.FUNCTION) +@Repeatable +annotation class ResetFeatureFlagToDefault(val name: FeatureFlag) diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel b/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel index 1ff35e43281..7593755fcb4 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel @@ -9,7 +9,7 @@ kt_android_library( name = "test_constants", testonly = True, srcs = [ - "TestPlatformParameterConstants.kt", + "PlatformParameterTestConstants.kt", ], visibility = [ "//:oppia_testing_visibility", @@ -20,10 +20,10 @@ kt_android_library( ) kt_android_library( - name = "test_module", + name = "test_constants_module", testonly = True, srcs = [ - "TestPlatformParameterModule.kt", + "PlatformParameterTestConstantsModule.kt", ], visibility = [ "//:oppia_testing_visibility", diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/PlatformParameterTestConstants.kt similarity index 100% rename from testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt rename to testing/src/main/java/org/oppia/android/testing/platformparameter/PlatformParameterTestConstants.kt diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/PlatformParameterTestConstantsModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/PlatformParameterTestConstantsModule.kt new file mode 100644 index 00000000000..f365032ebab --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/PlatformParameterTestConstantsModule.kt @@ -0,0 +1,65 @@ +package org.oppia.android.testing.platformparameter + +import dagger.Module +import dagger.Provides +import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.util.platformparameter.PlatformParameterSingleton +import org.oppia.android.util.platformparameter.PlatformParameterValue +import javax.inject.Singleton + +/** Fake Platform Parameter Module that provides individual Platform Parameters for testing. */ +@Module +class PlatformParameterTestConstantsModule { + @Provides + @EnableTestFeatureFlag + fun provideEnableTestFeatureFlag( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) + ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) + } + + @Provides + @EnableTestFeatureFlagWithEnabledDefault + fun provideEnableTestFeatureFlagWithEnabledDefault( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS + ) + ?: PlatformParameterValue.createDefaultParameter( + defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, + defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER + ) + } + + @TestStringParam + @Provides + @Singleton + fun provideTestStringParam( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getStringPlatformParameter(TEST_STRING_PARAM_NAME) + ?: PlatformParameterValue.createDefaultParameter(TEST_STRING_PARAM_DEFAULT_VALUE) + } + + @TestIntegerParam + @Provides + @Singleton + fun provideTestIntegerParam( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter(TEST_INTEGER_PARAM_NAME) + ?: PlatformParameterValue.createDefaultParameter(TEST_INTEGER_PARAM_DEFAULT_VALUE) + } + + @TestBooleanParam + @Provides + @Singleton + fun provideTestBooleanParam( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(TEST_BOOLEAN_PARAM_NAME) + ?: PlatformParameterValue.createDefaultParameter(TEST_BOOLEAN_PARAM_DEFAULT_VALUE) + } +} diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt deleted file mode 100644 index fc848d39233..00000000000 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ /dev/null @@ -1,437 +0,0 @@ -package org.oppia.android.testing.platformparameter - -import android.content.Context -import androidx.annotation.VisibleForTesting -import dagger.Module -import dagger.Provides -import org.oppia.android.app.model.PlatformParameter -import org.oppia.android.util.extensions.getVersionCode -import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION -import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING -import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.CacheLatexRendering -import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT -import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation -import org.oppia.android.util.platformparameter.EnableDownloadsSupport -import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi -import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi -import org.oppia.android.util.platformparameter.EnableFastLanguageSwitchingInLesson -import org.oppia.android.util.platformparameter.EnableInteractionConfigChangeStateRetention -import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics -import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds -import org.oppia.android.util.platformparameter.EnableMultipleClassrooms -import org.oppia.android.util.platformparameter.EnableNpsSurvey -import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 -import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection -import org.oppia.android.util.platformparameter.EnableSpotlightUi -import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode -import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL -import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.LowestSupportedApiLevel -import org.oppia.android.util.platformparameter.NPS_SURVEY_GRACE_PERIOD_IN_DAYS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.NpsSurveyGracePeriodInDays -import org.oppia.android.util.platformparameter.NpsSurveyMinimumAggregateLearningTimeInATopicInMinutes -import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL -import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionHighFrequencyTimeIntervalInMinutes -import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionLowFrequencyTimeIntervalInMinutes -import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionUploadTimeIntervalInMinutes -import org.oppia.android.util.platformparameter.PlatformParameterSingleton -import org.oppia.android.util.platformparameter.PlatformParameterValue -import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG -import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS -import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg -import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours -import javax.inject.Singleton - -/* Fake Platform Parameter Module that provides individual Platform Parameters for testing. */ -@Module -class TestPlatformParameterModule { - @Provides - @EnableTestFeatureFlag - fun provideEnableTestFeatureFlag( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) - ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) - } - - @Provides - @EnableTestFeatureFlagWithEnabledDefault - fun provideEnableTestFeatureFlagWithEnabledDefault( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS - ) - ?: PlatformParameterValue.createDefaultParameter( - defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, - defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER - ) - } - - @Provides - @EnableDownloadsSupport - fun provideEnableDownloadsSupport( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) - ?: PlatformParameterValue.createDefaultParameter(enableDownloadsSupport) - } - - @TestStringParam - @Provides - @Singleton - fun provideTestStringParam( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getStringPlatformParameter(TEST_STRING_PARAM_NAME) - ?: PlatformParameterValue.createDefaultParameter(TEST_STRING_PARAM_DEFAULT_VALUE) - } - - @TestIntegerParam - @Provides - @Singleton - fun provideTestIntegerParam( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter(TEST_INTEGER_PARAM_NAME) - ?: PlatformParameterValue.createDefaultParameter(TEST_INTEGER_PARAM_DEFAULT_VALUE) - } - - @TestBooleanParam - @Provides - @Singleton - fun provideTestBooleanParam( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(TEST_BOOLEAN_PARAM_NAME) - ?: PlatformParameterValue.createDefaultParameter(TEST_BOOLEAN_PARAM_DEFAULT_VALUE) - } - - @Provides - @SplashScreenWelcomeMsg - fun provideSplashScreenWelcomeMsgParam( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(SPLASH_SCREEN_WELCOME_MSG) - ?: PlatformParameterValue.createDefaultParameter(SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE) - } - - @Provides - @SyncUpWorkerTimePeriodHours - fun provideSyncUpWorkerTimePeriod( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS - ) ?: PlatformParameterValue.createDefaultParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE - ) - } - - @Provides - @EnableEditAccountsOptionsUi - fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(enableEditAccountsOptionsUi) - - @Provides - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(enableLearnerStudyAnalytics) - - @Provides - @EnableFastLanguageSwitchingInLesson - fun provideFastInLessonLanguageSwitching(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(enableFastLanguageSwitchingInLesson) - - @Provides - @EnableLoggingLearnerStudyIds - fun provideLoggingLearnerStudyIds(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(enableLoggingLearnerStudyIds) - - @Provides - @CacheLatexRendering - fun provideCacheLatexRendering( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(CACHE_LATEX_RENDERING) - ?: PlatformParameterValue.createDefaultParameter(CACHE_LATEX_RENDERING_DEFAULT_VALUE) - } - - @Provides - @EnablePerformanceMetricsCollection - fun provideEnablePerformanceMetricCollection(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(enablePerformanceMetricsCollection) - } - - @Provides - @PerformanceMetricsCollectionUploadTimeIntervalInMinutes - fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL - ) - } - - @Provides - @PerformanceMetricsCollectionHighFrequencyTimeIntervalInMinutes - fun providePerformanceMetricsCollectionHighFrequencyTimeIntervalInMinutes( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL - ) - } - - @Provides - @PerformanceMetricsCollectionLowFrequencyTimeIntervalInMinutes - fun providePerformanceMetricsCollectionLowFrequencyTimeIntervalInMinutes( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL - ) - } - - @Provides - @EnableExtraTopicTabsUi - fun provideEnableExtraTopicTabsUi(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(enableExtraTopicTabsUi) - - @Provides - @EnableInteractionConfigChangeStateRetention - fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(enableInteractionConfigChangeStateRetention) - - @Provides - @EnableSpotlightUi - fun provideEnableSpotlightUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - enableSpotlightUi - ) - } - - @Provides - @EnableAppAndOsDeprecation - fun provideEnableAppAndOsDeprecation( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(APP_AND_OS_DEPRECATION) - ?: PlatformParameterValue.createDefaultParameter(ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE) - } - - @Provides - @Singleton - @OptionalAppUpdateVersionCode - fun provideOptionalAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton, - context: Context - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - OPTIONAL_APP_UPDATE_VERSION_CODE - ) ?: PlatformParameterValue.createDefaultParameter( - context.getVersionCode() - ) - } - - @Provides - @ForcedAppUpdateVersionCode - fun provideForcedAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton, - context: Context - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - FORCED_APP_UPDATE_VERSION_CODE - ) ?: PlatformParameterValue.createDefaultParameter( - context.getVersionCode() - ) - } - - @Provides - @LowestSupportedApiLevel - fun provideLowestSupportedApiLevel( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - LOWEST_SUPPORTED_API_LEVEL - ) ?: PlatformParameterValue.createDefaultParameter( - LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE - ) - } - - @Provides - @NpsSurveyGracePeriodInDays - fun provideNpsSurveyGracePeriodInDays(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(gracePeriodInDays) - } - - @Provides - @NpsSurveyMinimumAggregateLearningTimeInATopicInMinutes - fun provideNpsSurveyMinimumAggregateLearningTimeInATopicInMinutes(): - PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(minimumLearningTime) - } - - @Provides - @EnableNpsSurvey - fun provideEnableNpsSurvey(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(enableNpsSurvey) - } - - @Provides - @EnableOnboardingFlowV2 - fun provideEnableOnboardingFlowV2(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(enableOnboardingFlowV2) - } - - @Provides - @EnableMultipleClassrooms - fun provideEnableMultipleClassrooms(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(enableMultipleClassrooms) - } - - companion object { - private var enableDownloadsSupport = ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE - private var enableEditAccountsOptionsUi = ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE - private var enableLearnerStudyAnalytics = LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE - private var enableFastLanguageSwitchingInLesson = - FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE - private var enableLoggingLearnerStudyIds = LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE - private var enableExtraTopicTabsUi = ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE - private var enableInteractionConfigChangeStateRetention = - ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE - private var enablePerformanceMetricsCollection = - ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE - private var enableSpotlightUi = true - private var enableAppAndOsDeprecation = ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE - private var minimumLearningTime = - NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES_DEFAULT_VALUE - private var gracePeriodInDays = NPS_SURVEY_GRACE_PERIOD_IN_DAYS_DEFAULT_VALUE - private var enableNpsSurvey = ENABLE_NPS_SURVEY_DEFAULT_VALUE - private var enableOnboardingFlowV2 = ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE - private var enableMultipleClassrooms = ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE - - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableDownloadsSupport(value: Boolean) { - enableDownloadsSupport = value - } - - /** Enables forcing [EnableEditAccountsOptionsUI] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableEditAccountsOptionsUi(value: Boolean) { - enableEditAccountsOptionsUi = value - } - - /** Enables forcing [EnableLearnerStudyAnalytics] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableLearnerStudyAnalytics(value: Boolean) { - enableLearnerStudyAnalytics = value - } - - /** Enables forcing [EnableFastLanguageSwitchingInLesson] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableFastLanguageSwitchingInLesson(value: Boolean) { - enableFastLanguageSwitchingInLesson = value - } - - /** Enables forcing [EnableLoggingLearnerStudyIds] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableLoggingLearnerStudyIds(value: Boolean) { - enableLoggingLearnerStudyIds = value - } - - /** Enables forcing [EnableExtraTopicTabsUi] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableExtraTopicTabsUi(value: Boolean) { - enableExtraTopicTabsUi = value - } - - /** Enables forcing [EnableInteractionConfigChangeStateRetention] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableInteractionConfigChangeStateRetention(value: Boolean) { - enableInteractionConfigChangeStateRetention = value - } - - /** Enables forcing [EnablePerformanceMetricsCollection] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnablePerformanceMetricsCollection(value: Boolean) { - enablePerformanceMetricsCollection = value - } - - /** Enables forcing [EnableSpotlightUi] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableSpotlightUi(value: Boolean) { - enableSpotlightUi = value - } - - /** Enables forcing [EnableNpsSurvey] feature flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableNpsSurvey(value: Boolean) { - enableNpsSurvey = value - } - - /** Enables forcing [EnableOnboardingFlowV2] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableOnboardingFlowV2(value: Boolean) { - enableOnboardingFlowV2 = value - } - - /** Enables forcing [EnableMultipleClassrooms] platform parameter flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableMultipleClassrooms(value: Boolean) { - enableMultipleClassrooms = value - } - - /** Enables forcing [EnableAppAndOsDeprecation] feature flag from tests. */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun forceEnableAppAndOsDeprecation(value: Boolean) { - enableAppAndOsDeprecation = value - } - - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - fun reset() { - enableDownloadsSupport = ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE - enableEditAccountsOptionsUi = ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE - enableLearnerStudyAnalytics = LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE - enableFastLanguageSwitchingInLesson = FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE - enableLoggingLearnerStudyIds = LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE - enableExtraTopicTabsUi = ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE - enableInteractionConfigChangeStateRetention = - ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE - enablePerformanceMetricsCollection = ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE - enableAppAndOsDeprecation = ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE - enableOnboardingFlowV2 = ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE - enableMultipleClassrooms = ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE - } - } -} 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 f165269bcad..d5d30766d5f 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EventLog @@ -31,6 +32,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FakeAnalyticsEventLoggerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger @Inject lateinit var analyticsEventLogger: AnalyticsEventLogger 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 433731da58c..815ff1f3302 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.util.logging.ExceptionLogger @@ -22,6 +23,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FakeExceptionLoggerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var fakeExceptionLogger: FakeExceptionLogger 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 b04b5d13890..530a3f6ab23 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EventLog @@ -31,6 +32,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FakeFirestoreEventLoggerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var fakeEventLogger: FakeFirestoreEventLogger diff --git a/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt b/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt index cb43cd5aaf0..abf502a822c 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.OppiaMetricLog @@ -35,6 +36,8 @@ private const val DEFAULT_TEST_BYTES_RECEIVED = 0L @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FakePerformanceMetricAssessorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var fakePerformanceMetricAssessor: FakePerformanceMetricAssessor 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 7f7b55a2d17..33961de2300 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.OppiaMetricLog @@ -32,6 +33,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class FakePerformanceMetricsEventLoggerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var fakePerformanceMetricsEventLogger: FakePerformanceMetricsEventLogger 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 aaa3f578c02..f6d3a1147bd 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 @@ -14,10 +14,12 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async import kotlinx.coroutines.delay import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.exceptions.verification.NeverWantedButInvoked import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat @@ -49,6 +51,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = DataProviderTestMonitorTest.TestApplication::class) class DataProviderTestMonitorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory @Inject lateinit var dataProviders: DataProviders @Inject lateinit var asyncDataSubscriptionManager: AsyncDataSubscriptionManager diff --git a/testing/src/test/java/org/oppia/android/testing/espresso/TextInputActionTest.kt b/testing/src/test/java/org/oppia/android/testing/espresso/TextInputActionTest.kt index 34d7f816950..80877b3efe8 100644 --- a/testing/src/test/java/org/oppia/android/testing/espresso/TextInputActionTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/espresso/TextInputActionTest.kt @@ -10,6 +10,7 @@ import org.hamcrest.StringDescription import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TextInputActionTestActivity import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText @@ -18,6 +19,8 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class TextInputActionTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @get:Rule var activityRule = diff --git a/testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt b/testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt index fff494e2ec3..1511db08abb 100644 --- a/testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt @@ -10,10 +10,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImpl.FakeAuthState import org.oppia.android.testing.robolectric.RobolectricModule @@ -33,6 +35,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FakeFirebaseAuthWrapperImplTest.TestApplication::class) class FakeFirebaseAuthWrapperImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var fakeFirebaseAuthWrapperImpl: FakeFirebaseAuthWrapperImpl diff --git a/testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt b/testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt index 284f0b27bc4..c8cf3ca33ec 100644 --- a/testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt @@ -10,9 +10,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.auth.FirebaseAuthWrapper +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.util.data.DataProvidersInjector @@ -29,6 +31,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class TestAuthenticationModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var firebaseAuthWrapper: FirebaseAuthWrapper 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 ba70eadf910..a51e3190f12 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 @@ -59,6 +59,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule @@ -100,6 +101,9 @@ import javax.inject.Singleton appStringAndroidRegionId = "en" ) class InitializeDefaultLocaleRuleCustomContextTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() 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 eaaf0521394..9595c26c3ea 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 @@ -8,6 +8,7 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.activity.ActivityComponent @@ -56,6 +57,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -93,6 +95,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = InitializeDefaultLocaleRuleOmissionTest.TestApplication::class) class InitializeDefaultLocaleRuleOmissionTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var appLanguageLocaleHandler: AppLanguageLocaleHandler 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 cf6b0da998c..2551f11eed2 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 @@ -60,6 +60,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule @@ -90,6 +91,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = InitializeDefaultLocaleRuleTest.TestApplication::class) class InitializeDefaultLocaleRuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() diff --git a/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt b/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt index 40c87c049d0..cbac96afbcd 100644 --- a/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ExplorationCheckpoint @@ -38,6 +39,7 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_0 import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_1 import org.oppia.android.domain.topic.RATIOS_EXPLORATION_ID_0 +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig @@ -69,6 +71,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ExplorationCheckpointTestHelperTest.TestApplication::class) class ExplorationCheckpointTestHelperTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var fakeOppiaClock: FakeOppiaClock @Inject lateinit var explorationCheckpointTestHelper: ExplorationCheckpointTestHelper diff --git a/testing/src/test/java/org/oppia/android/testing/logging/SyncStatusTestModuleTest.kt b/testing/src/test/java/org/oppia/android/testing/logging/SyncStatusTestModuleTest.kt index 9e4a588b9cd..2b0ccfb8499 100644 --- a/testing/src/test/java/org/oppia/android/testing/logging/SyncStatusTestModuleTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/logging/SyncStatusTestModuleTest.kt @@ -10,9 +10,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -35,6 +37,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = SyncStatusTestModuleTest.TestApplication::class) class SyncStatusTestModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var syncStatusManager: SyncStatusManager @Before diff --git a/testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt b/testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt index e92463a7982..e416054fe48 100644 --- a/testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt @@ -55,6 +55,7 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = TestSyncStatusManagerTest.TestApplication::class) class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { + @Inject override lateinit var impl: TestSyncStatusManager @Inject override lateinit var monitorFactory: DataProviderTestMonitor.Factory @Inject override lateinit var persistentCacheStoreFactory: PersistentCacheStore.Factory diff --git a/testing/src/test/java/org/oppia/android/testing/network/MockPlatformParameterServiceTest.kt b/testing/src/test/java/org/oppia/android/testing/network/MockPlatformParameterServiceTest.kt index 558b75d27fb..f05183f281e 100644 --- a/testing/src/test/java/org/oppia/android/testing/network/MockPlatformParameterServiceTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/network/MockPlatformParameterServiceTest.kt @@ -10,11 +10,13 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.data.backends.gae.NetworkConfigProdModule import org.oppia.android.data.backends.gae.NetworkModule import org.oppia.android.data.backends.gae.api.PlatformParameterService +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_SERVER_VALUE import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_NAME @@ -35,6 +37,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MockPlatformParameterServiceTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @field:[Inject MockPlatformParameterService] lateinit var mockPlatformParameterService: PlatformParameterService diff --git a/testing/src/test/java/org/oppia/android/testing/networking/BUILD.bazel b/testing/src/test/java/org/oppia/android/testing/networking/BUILD.bazel index f4e43827563..979e4e53db9 100644 --- a/testing/src/test/java/org/oppia/android/testing/networking/BUILD.bazel +++ b/testing/src/test/java/org/oppia/android/testing/networking/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//testing:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", diff --git a/testing/src/test/java/org/oppia/android/testing/networking/NetworkConnectionTestUtilTest.kt b/testing/src/test/java/org/oppia/android/testing/networking/NetworkConnectionTestUtilTest.kt index 7daf950c448..97f00875858 100644 --- a/testing/src/test/java/org/oppia/android/testing/networking/NetworkConnectionTestUtilTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/networking/NetworkConnectionTestUtilTest.kt @@ -14,8 +14,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.logging.EnableConsoleLog @@ -32,6 +34,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NetworkConnectionTestUtilTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NO_CONNECTION = -1 diff --git a/testing/src/test/java/org/oppia/android/testing/profile/ProfileTestHelperTest.kt b/testing/src/test/java/org/oppia/android/testing/profile/ProfileTestHelperTest.kt index abe33ac86a7..7051ef1b5fa 100644 --- a/testing/src/test/java/org/oppia/android/testing/profile/ProfileTestHelperTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/profile/ProfileTestHelperTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ProfileType @@ -19,6 +20,7 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.profile.ProfileManagementController +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat import org.oppia.android.testing.data.DataProviderTestMonitor @@ -48,6 +50,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ProfileTestHelperTest.TestApplication::class) class ProfileTestHelperTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var profileManagementController: ProfileManagementController diff --git a/testing/src/test/java/org/oppia/android/testing/robolectric/BUILD.bazel b/testing/src/test/java/org/oppia/android/testing/robolectric/BUILD.bazel index b40626ec252..0b58d92e3e2 100644 --- a/testing/src/test/java/org/oppia/android/testing/robolectric/BUILD.bazel +++ b/testing/src/test/java/org/oppia/android/testing/robolectric/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//testing:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/robolectric:oppia_shadow_activity_manager", "//third_party:androidx_core_core", "//third_party:androidx_test_ext_junit", @@ -30,6 +31,7 @@ oppia_android_test( test_manifest = "//testing:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/robolectric:oppia_shadow_traffic_stats", "//third_party:androidx_core_core", "//third_party:androidx_test_ext_junit", @@ -48,6 +50,7 @@ oppia_android_test( test_manifest = "//testing:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/robolectric:shadow_bidi_formatter", "//third_party:androidx_core_core", "//third_party:androidx_test_ext_junit", diff --git a/testing/src/test/java/org/oppia/android/testing/robolectric/OppiaShadowActivityManagerTest.kt b/testing/src/test/java/org/oppia/android/testing/robolectric/OppiaShadowActivityManagerTest.kt index b6b6df2c20c..71d5e482b36 100644 --- a/testing/src/test/java/org/oppia/android/testing/robolectric/OppiaShadowActivityManagerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/robolectric/OppiaShadowActivityManagerTest.kt @@ -13,8 +13,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.robolectric.Shadows.shadowOf import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -32,6 +34,9 @@ import javax.inject.Singleton shadows = [OppiaShadowActivityManager::class] ) class OppiaShadowActivityManagerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context diff --git a/testing/src/test/java/org/oppia/android/testing/robolectric/OppiaShadowTrafficStatsTest.kt b/testing/src/test/java/org/oppia/android/testing/robolectric/OppiaShadowTrafficStatsTest.kt index 4532c593db4..bc18526c262 100644 --- a/testing/src/test/java/org/oppia/android/testing/robolectric/OppiaShadowTrafficStatsTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/robolectric/OppiaShadowTrafficStatsTest.kt @@ -13,8 +13,10 @@ import dagger.Module import dagger.Provides import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import org.robolectric.shadow.api.Shadow @@ -34,6 +36,8 @@ private const val ARBITRARY_UID = 0 shadows = [OppiaShadowTrafficStats::class] ) class OppiaShadowTrafficStatsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var context: Context diff --git a/testing/src/test/java/org/oppia/android/testing/robolectric/ShadowBidiFormatterTest.kt b/testing/src/test/java/org/oppia/android/testing/robolectric/ShadowBidiFormatterTest.kt index 9aaddb5201c..5e6862a6362 100644 --- a/testing/src/test/java/org/oppia/android/testing/robolectric/ShadowBidiFormatterTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/robolectric/ShadowBidiFormatterTest.kt @@ -13,8 +13,10 @@ import dagger.Module import dagger.Provides import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.util.Locale @@ -29,6 +31,9 @@ import javax.inject.Singleton manifest = Config.NONE, sdk = [Build.VERSION_CODES.P], shadows = [ShadowBidiFormatter::class] ) class ShadowBidiFormatterTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Before fun setUp() { setUpTestApplicationComponent() diff --git a/testing/src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt b/testing/src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt index 1cd8edc65cd..2210f514d4b 100644 --- a/testing/src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ChapterPlayState @@ -47,6 +48,7 @@ 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.domain.topic.TopicController +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig @@ -77,6 +79,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = StoryProgressTestHelperTest.TestApplication::class) class StoryProgressTestHelperTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var storyProgressTestHelper: StoryProgressTestHelper @Inject lateinit var topicController: TopicController 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 fb240e57feb..52fe8207ef4 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 @@ -28,6 +28,7 @@ import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat @@ -68,6 +69,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @OptIn(ExperimentalCoroutinesApi::class) class CoroutineExecutorServiceTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherEspressoImplTest.kt b/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherEspressoImplTest.kt index 235223c754b..e9f499a1756 100644 --- a/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherEspressoImplTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherEspressoImplTest.kt @@ -10,11 +10,13 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.mock import org.mockito.Mockito.timeout import org.mockito.Mockito.verify +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.IsOnRobolectric import org.oppia.android.util.data.DataProvidersInjector @@ -45,6 +47,9 @@ class TestCoroutineDispatcherEspressoImplTest : TestCoroutineDispatcherTestBase( longTaskDelayMillis = 15000L, longTaskDelayDeltaCheckMillis = 1000L ) { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Before override fun setUp() { setUpTestApplicationComponent() diff --git a/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherRobolectricImplTest.kt b/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherRobolectricImplTest.kt index 9834a847c06..8a076041ff6 100644 --- a/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherRobolectricImplTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherRobolectricImplTest.kt @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.atLeast @@ -19,6 +20,7 @@ import org.mockito.Mockito.never import org.mockito.Mockito.reset import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.IsOnRobolectric import org.oppia.android.testing.time.FakeSystemClock @@ -47,6 +49,9 @@ class TestCoroutineDispatcherRobolectricImplTest : TestCoroutineDispatcherTestBa // issue in the base tests. longTaskDelayDeltaCheckMillis = 1L ) { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var fakeSystemClock: FakeSystemClock diff --git a/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherTest.kt b/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherTest.kt index cf7cb9060d1..9a9605d1dd6 100644 --- a/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/threading/TestCoroutineDispatcherTest.kt @@ -12,8 +12,10 @@ 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.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.robolectric.IsOnRobolectric import org.oppia.android.util.data.DataProvidersInjector @@ -42,6 +44,9 @@ import kotlin.reflect.KClass qualifiers = "port-xxhdpi" ) class TestCoroutineDispatcherTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject @field:BackgroundTestDispatcher lateinit var backgroundTestDispatcher: TestCoroutineDispatcher 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 aabaee20ebc..f651fd64617 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 @@ -14,9 +14,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.LogStorageModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule @@ -49,6 +51,9 @@ private const val EVENING_TIMESTAMP = 1556061720000 @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FakeOppiaClockTest.TestApplication::class) class FakeOppiaClockTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var fakeOppiaClock: FakeOppiaClock diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 40ff91d8c59..efba6a70e9b 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -113,7 +113,6 @@ TEST_DEPS = [ "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/mockito", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:oppia_shadow_activity_manager", "//testing/src/main/java/org/oppia/android/testing/robolectric:oppia_shadow_traffic_stats", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", diff --git a/utility/build.gradle b/utility/build.gradle index b6949ef736c..6dce2da4e9c 100644 --- a/utility/build.gradle +++ b/utility/build.gradle @@ -112,6 +112,7 @@ dependencies { 'org.robolectric:robolectric:4.5', project(":data"), project(":testing"), + project(":domain") ) kapt( 'com.github.bumptech.glide:compiler:4.11.0', diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 39a63ec453a..7be6f34d8f5 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -2,6 +2,48 @@ package org.oppia.android.util.platformparameter import javax.inject.Qualifier +/** Represents all the feature flag names. */ +enum class FeatureFlag { + /** Corresponds to downloads support. */ + DOWNLOADS_SUPPORT, + + /** Corresponds to extra topics tab UI. */ + EXTRA_TOPIC_TABS_UI, + + /** Corresponds to learner study related analytics logging. */ + LEARNER_STUDY_ANALYTICS, + + /** Corresponds to allow learners to quickly switch between content languages. */ + FAST_LANGUAGE_SWITCHING_IN_LESSON, + + /** Corresponds to generating and logging learner study IDs. */ + LOGGING_LEARNER_STUDY_IDS, + + /** Corresponds to edit accounts options. */ + EDIT_ACCOUNTS_OPTIONS_UI, + + /** Corresponds to record performance metrics. */ + ENABLE_PERFORMANCE_METRICS_COLLECTION, + + /** Corresponds to spotlight UI. */ + SPOTLIGHT_UI, + + /** Corresponds to retaining input interaction state across configuration changes. */ + INTERACTION_CONFIG_CHANGE_STATE_RETENTION, + + /** Corresponds to app and OS deprecation. */ + APP_AND_OS_DEPRECATION, + + /** Corresponds to NPS survey. */ + ENABLE_NPS_SURVEY, + + /** Corresponds to new onboarding flow. */ + ENABLE_ONBOARDING_FLOW_V2, + + /** Corresponds to new multiple classrooms. */ + ENABLE_MULTIPLE_CLASSROOMS +} + /** * This file contains all the constants that are associated with individual Feature Flags. * These constants are: diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt index 4648120ab79..d9a1855dae5 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt @@ -2,6 +2,45 @@ package org.oppia.android.util.platformparameter import javax.inject.Qualifier +/** Represents all the platform parameter names. */ +enum class PlatformParameter { + /** Corresponds to automatically updating topics. */ + AUTOMATIC_UPDATE_TOPIC_SETTING, + + /** Corresponds to visibility of splash screen welcome message. */ + SPLASH_SCREEN_WELCOME_MSG, + + /** Corresponds to time period in hours. */ + SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS, + + /** Corresponds to cache LaTeX rendering using Glide. */ + CACHE_LATEX_RENDERING, + + /** Corresponds to uploading time interval of previously recorded performance metrics in minutes. */ + PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES, + + /** Corresponds to recording time interval of high frequent performance metrics collection in minutes. */ + PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES, + + /** Corresponds to recording time interval of low frequent performance metrics collection in minutes. */ + PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES, + + /** Corresponds to version code of latest app available soft update. */ + OPTIONAL_APP_UPDATE_VERSION_CODE, + + /** Corresponds to version code of latest app available forced update. */ + FORCED_APP_UPDATE_VERSION_CODE, + + /** Corresponds to integer indicating lowest supported Android API level. */ + LOWEST_SUPPORTED_API_LEVEL, + + /** Corresponds to time interval of showing subsequent NPS surveys in days. */ + NPS_SURVEY_GRACE_PERIOD_IN_DAYS, + + /** Corresponds to minimum learning time in a topic in minutes. */ + NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES +} + /** * This file contains all the constants that are associated with individual Platform Parameters. * These constants are: @@ -10,6 +49,13 @@ import javax.inject.Qualifier * - Platform Parameter Default Value */ +/** + * Qualifier for the platform parameter that controls the automatic updates of topics + * in the [AdministratorControlsFragmentPresenter]. + */ +@Qualifier +annotation class AutomaticUpdateTopicSetting + /** * Name of the platform parameter that automatically updates topics when a user toggles the * switch in the [AdministratorControlsFragmentPresenter]. @@ -20,7 +66,7 @@ const val AUTOMATIC_UPDATE_TOPIC_SETTING = "automatically_update_topic" * Default value of the platform parameter that automatically updates topics when a user toggles the * switch in the [AdministratorControlsFragmentPresenter]. */ -const val AUTOMATIC_UPDATE_TOPIC_SETTING_VALUE = false +const val AUTOMATIC_UPDATE_TOPIC_SETTING_DEFAULT_VALUE = false /** * Qualifier for the platform parameter that controls the visibility of splash screen welcome diff --git a/utility/src/test/java/org/oppia/android/util/caching/AssetModuleTest.kt b/utility/src/test/java/org/oppia/android/util/caching/AssetModuleTest.kt index 9bdfeec4f96..09ff0fe6764 100644 --- a/utility/src/test/java/org/oppia/android/util/caching/AssetModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/caching/AssetModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -29,6 +31,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AssetModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var assetRepository: AssetRepository diff --git a/utility/src/test/java/org/oppia/android/util/caching/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/caching/BUILD.bazel index e733344f2d0..ac1a4756b97 100644 --- a/utility/src/test/java/org/oppia/android/util/caching/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/caching/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", 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", diff --git a/utility/src/test/java/org/oppia/android/util/caching/testing/AssetTestNoOpModuleTest.kt b/utility/src/test/java/org/oppia/android/util/caching/testing/AssetTestNoOpModuleTest.kt index d577afad117..dbede7a2941 100644 --- a/utility/src/test/java/org/oppia/android/util/caching/testing/AssetTestNoOpModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/caching/testing/AssetTestNoOpModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.caching.AssetRepository import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AssetTestNoOpModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var assetRepository: AssetRepository diff --git a/utility/src/test/java/org/oppia/android/util/caching/testing/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/caching/testing/BUILD.bazel index 013c0b633ec..98637b2390d 100644 --- a/utility/src/test/java/org/oppia/android/util/caching/testing/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/caching/testing/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", 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 ea5346c2490..df33fe49779 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 @@ -11,9 +11,11 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.TestMessage +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.util.caching.AssetRepository import org.robolectric.annotation.Config @@ -28,6 +30,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class TestNoOpAssetRepositoryTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var assetRepository: AssetRepository 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 0926b2fd323..63f9468682c 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 @@ -22,6 +22,7 @@ import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -40,6 +41,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AsyncDataSubscriptionManagerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/utility/src/test/java/org/oppia/android/util/data/AsyncResultTest.kt b/utility/src/test/java/org/oppia/android/util/data/AsyncResultTest.kt index fe012cf291d..18aa4df7dd7 100644 --- a/utility/src/test/java/org/oppia/android/util/data/AsyncResultTest.kt +++ b/utility/src/test/java/org/oppia/android/util/data/AsyncResultTest.kt @@ -10,8 +10,10 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.async import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.BackgroundTestDispatcher @@ -31,6 +33,8 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class AsyncResultTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var fakeSystemClock: FakeSystemClock 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 7af56c535c4..f0df4e19d1e 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 @@ -30,6 +30,7 @@ import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat import org.oppia.android.testing.data.DataProviderTestMonitor @@ -73,6 +74,9 @@ private const val COMBINED_STR_VALUE_02 = "I used to be indecisive. At least I t @LooperMode(LooperMode.Mode.PAUSED) @Config(application = DataProvidersTest.TestApplication::class) class DataProvidersTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() @Inject lateinit var application: Application 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 f7931e4e0b5..2d2b737a2c6 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 @@ -15,8 +15,10 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.async import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatcher @@ -42,6 +44,9 @@ private const val UPDATED_ASYNC_VALUE = "updated async value" @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class InMemoryBlockingCacheTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var cacheFactory: InMemoryBlockingCache.Factory diff --git a/utility/src/test/java/org/oppia/android/util/extensions/BundleExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/extensions/BundleExtensionsTest.kt index 384ff2df1f2..4655f87ddc2 100644 --- a/utility/src/test/java/org/oppia/android/util/extensions/BundleExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/extensions/BundleExtensionsTest.kt @@ -6,11 +6,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.truth.content.IntentSubject.assertThat import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.LiteProtoTruth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.IncompatibleTestMessage import org.oppia.android.app.model.TestMessage import org.oppia.android.app.model.TestMessage2 +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -19,6 +21,9 @@ import org.robolectric.annotation.LooperMode @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class BundleExtensionsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + private val TEST_STRING = "String value" private val TEST_MESSAGE_WITH_STR_AND_INT = 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 581668c878c..8a00640f957 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 @@ -14,6 +14,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.LanguageSupportDefinition @@ -25,6 +26,7 @@ import org.oppia.android.app.model.OppiaLanguage 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.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -50,6 +52,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AndroidLocaleFactoryTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var androidLocaleFactory: AndroidLocaleFactory @field:[Inject BackgroundDispatcher] lateinit var backgroundDispatcher: CoroutineDispatcher @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers 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 d686a5aaea9..d2b8417ea46 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 @@ -10,6 +10,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.LanguageSupportDefinition.AndroidLanguageId @@ -19,6 +20,7 @@ import org.oppia.android.app.model.LanguageSupportDefinition.MacaronicLanguageId 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.OppiaTestRule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.locale.AndroidLocaleProfile.LanguageAndRegionProfile import org.oppia.android.util.locale.AndroidLocaleProfile.LanguageAndWildcardRegionProfile @@ -38,6 +40,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class AndroidLocaleProfileTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var androidLocaleProfileFactory: AndroidLocaleProfile.Factory private val brazilianPortugueseLocale by lazy { Locale("pt", "BR") } 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 ba3f39fbc63..c19a62834f5 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 @@ -34,6 +34,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/time:test_module", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", @@ -53,6 +54,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/time:test_module", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", @@ -97,6 +99,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/time:test_module", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", @@ -115,6 +118,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/robolectric:shadow_bidi_formatter", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", @@ -135,6 +139,7 @@ oppia_android_test( deps = [ "//:dagger", "//model/src/main/proto:languages_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", "//third_party:junit_junit", 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 dfc1ba84b79..6f1a665f610 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 @@ -13,6 +13,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.LanguageSupportDefinition @@ -20,6 +21,7 @@ import org.oppia.android.app.model.OppiaLanguage 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.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -38,6 +40,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class DisplayLocaleImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var machineLocale: OppiaLocale.MachineLocale diff --git a/utility/src/test/java/org/oppia/android/util/locale/LocaleProdModuleTest.kt b/utility/src/test/java/org/oppia/android/util/locale/LocaleProdModuleTest.kt index 33cb92ef7cb..98f2c743a2b 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/LocaleProdModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/LocaleProdModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.time.FakeOppiaClockModule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -25,6 +27,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class LocaleProdModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var machineLocale: OppiaLocale.MachineLocale diff --git a/utility/src/test/java/org/oppia/android/util/locale/MachineLocaleImplTest.kt b/utility/src/test/java/org/oppia/android/util/locale/MachineLocaleImplTest.kt index cf7ddbd2a0a..73080d2deb8 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/MachineLocaleImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/MachineLocaleImplTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.time.FakeOppiaClock import org.oppia.android.testing.time.FakeOppiaClockModule import org.robolectric.annotation.Config @@ -27,6 +29,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class MachineLocaleImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var machineLocale: OppiaLocale.MachineLocale diff --git a/utility/src/test/java/org/oppia/android/util/locale/OppiaBidiFormatterImplTest.kt b/utility/src/test/java/org/oppia/android/util/locale/OppiaBidiFormatterImplTest.kt index d8b5c05dbf5..7b23103e714 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/OppiaBidiFormatterImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/OppiaBidiFormatterImplTest.kt @@ -11,8 +11,10 @@ import dagger.Module import dagger.Provides import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.ShadowBidiFormatter import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -27,6 +29,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE, shadows = [ShadowBidiFormatter::class]) class OppiaBidiFormatterImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var formatterFactory: OppiaBidiFormatter.Factory diff --git a/utility/src/test/java/org/oppia/android/util/locale/OppiaLocaleContextExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/locale/OppiaLocaleContextExtensionsTest.kt index c14734a7e43..f2a2f502b68 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/OppiaLocaleContextExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/OppiaLocaleContextExtensionsTest.kt @@ -10,12 +10,14 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.LanguageSupportDefinition import org.oppia.android.app.model.LanguageSupportDefinition.LanguageId import org.oppia.android.app.model.OppiaLanguage import org.oppia.android.app.model.OppiaLocaleContext +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Singleton @@ -28,6 +30,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class OppiaLocaleContextExtensionsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Before fun setUp() { setUpTestApplicationComponent() diff --git a/utility/src/test/java/org/oppia/android/util/locale/testing/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/locale/testing/BUILD.bazel index 7d91ef52f46..9becc626364 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/testing/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/locale/testing/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/time:test_module", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", diff --git a/utility/src/test/java/org/oppia/android/util/locale/testing/LocaleTestModuleTest.kt b/utility/src/test/java/org/oppia/android/util/locale/testing/LocaleTestModuleTest.kt index 159b8cee2bb..b33cab1e976 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/testing/LocaleTestModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/testing/LocaleTestModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.locale.MachineLocaleImpl import org.oppia.android.util.locale.OppiaBidiFormatter @@ -28,6 +30,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class LocaleTestModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var machineLocale: OppiaLocale.MachineLocale 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 91eefeac704..7a1ed9b8c17 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 @@ -11,8 +11,10 @@ import dagger.Module import dagger.Provides import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.ShadowBidiFormatter import org.oppia.android.util.locale.OppiaBidiFormatter @@ -29,6 +31,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE, shadows = [ShadowBidiFormatter::class]) class TestOppiaBidiFormatterTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var formatterFactory: OppiaBidiFormatter.Factory diff --git a/utility/src/test/java/org/oppia/android/util/logging/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/logging/BUILD.bazel index d23fb656a4c..6a6618eeaf4 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/logging/BUILD.bazel @@ -30,6 +30,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:androidx_test_ext_truth", "//third_party:com_google_truth_truth", diff --git a/utility/src/test/java/org/oppia/android/util/logging/ConsoleLoggerTest.kt b/utility/src/test/java/org/oppia/android/util/logging/ConsoleLoggerTest.kt index 05df6b8c3c7..d719430b497 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/ConsoleLoggerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/ConsoleLoggerTest.kt @@ -15,8 +15,10 @@ import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.toList import org.junit.After import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform @@ -51,6 +53,9 @@ class ConsoleLoggerTest { private const val testMessage = "test error message" } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var consoleLogger: ConsoleLogger @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers diff --git a/utility/src/test/java/org/oppia/android/util/logging/CurrentAppScreenNameIntentDecoratorTest.kt b/utility/src/test/java/org/oppia/android/util/logging/CurrentAppScreenNameIntentDecoratorTest.kt index 67f2c92a5db..80750927f56 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/CurrentAppScreenNameIntentDecoratorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/CurrentAppScreenNameIntentDecoratorTest.kt @@ -3,9 +3,11 @@ package org.oppia.android.util.logging import android.content.Intent import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ScreenName +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.extractCurrentAppScreenName import org.robolectric.annotation.LooperMode @@ -16,6 +18,8 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class CurrentAppScreenNameIntentDecoratorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Test fun testDecorator_decorateWithScreenName_returnsIntentWithCorrectScreenName() { diff --git a/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt b/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt index e0b29f36d15..de6223add39 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt @@ -13,6 +13,7 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.After +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AppLanguageSelection @@ -84,6 +85,7 @@ import org.oppia.android.app.model.OppiaMetricLog.StorageTier.MEDIUM_STORAGE import org.oppia.android.app.model.ScreenName import org.oppia.android.app.model.ScreenName.SCREEN_NAME_UNSPECIFIED import org.oppia.android.app.model.WrittenTranslationLanguageSelection +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -154,6 +156,9 @@ class EventBundleCreatorTest { private const val TEST_MEMORY_USAGE = Long.MAX_VALUE } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var context: Context @Inject lateinit var eventBundleCreator: EventBundleCreator diff --git a/utility/src/test/java/org/oppia/android/util/logging/EventTypeToHumanReadableNameConverterTest.kt b/utility/src/test/java/org/oppia/android/util/logging/EventTypeToHumanReadableNameConverterTest.kt index 55bff1f748e..b203c83018f 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/EventTypeToHumanReadableNameConverterTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/EventTypeToHumanReadableNameConverterTest.kt @@ -8,9 +8,11 @@ import com.google.common.truth.Truth.assertWithMessage import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EventLog.Context.ActivityContextCase +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -31,6 +33,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = EventTypeToHumanReadableNameConverterTest.TestApplication::class) class EventTypeToHumanReadableNameConverterTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var converter: EventTypeToHumanReadableNameConverter private companion object { diff --git a/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt b/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt index aaf4eff062c..8a2fb917f9d 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt @@ -12,6 +12,7 @@ import kotlinx.coroutines.CoroutineDispatcher import org.junit.Before import org.junit.runner.RunWith import org.oppia.android.data.persistence.PersistentCacheStore +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.networking.NetworkConnectionTestUtil @@ -23,12 +24,6 @@ import org.oppia.android.util.data.DataProvidersInjector import org.oppia.android.util.data.DataProvidersInjectorProvider import org.oppia.android.util.locale.LocaleProdModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics -import org.oppia.android.util.platformparameter.PlatformParameterValue -import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg -import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours import org.oppia.android.util.threading.BackgroundDispatcher import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -86,34 +81,6 @@ class SyncStatusManagerImplTest : SyncStatusManagerTestBase() { fun provideGlobalLogLevel(): LogLevel = LogLevel.VERBOSE } - @Module - class TestPlatformParameterModule { - - companion object { - var forceLearnerAnalyticsStudy: Boolean = false - } - - @Provides - @SplashScreenWelcomeMsg - fun provideSplashScreenWelcomeMsgParam(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE) - } - - @Provides - @SyncUpWorkerTimePeriodHours - fun provideSyncUpWorkerTimePeriod(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE - ) - } - - @Provides - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(forceLearnerAnalyticsStudy) - } - } - // TODO(#89): Move this to a common test application component. @Singleton @Component( @@ -121,7 +88,7 @@ class SyncStatusManagerImplTest : SyncStatusManagerTestBase() { TestModule::class, TestLogReportingModule::class, TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, - TestPlatformParameterModule::class, SyncStatusModule::class + PlatformParameterModule::class, SyncStatusModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { 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 8690cc70ae8..b2957e783c3 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 @@ -8,12 +8,14 @@ import kotlinx.coroutines.Deferred import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import org.junit.Rule import org.junit.Test import org.oppia.android.app.model.EventLog import org.oppia.android.app.model.OppiaEventLogs import org.oppia.android.data.persistence.PersistentCacheStore import org.oppia.android.data.persistence.PersistentCacheStore.PublishMode.PUBLISH_TO_IN_MEMORY_CACHE import org.oppia.android.data.persistence.PersistentCacheStore.UpdateMode.UPDATE_ALWAYS +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.networking.NetworkConnectionTestUtil @@ -34,6 +36,9 @@ import org.oppia.android.util.logging.SyncStatusManager.SyncStatus // Function name: test names are conventionally named with underscores. @Suppress("SameParameterValue", "FunctionName") abstract class SyncStatusManagerTestBase { + @get:Rule + val oppiaTestRule = OppiaTestRule() + protected abstract val impl: SyncStatusManager protected abstract val monitorFactory: DataProviderTestMonitor.Factory protected abstract val persistentCacheStoreFactory: PersistentCacheStore.Factory 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 32d83a0d91c..5f903b08db3 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 @@ -10,10 +10,12 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EventLog import org.oppia.android.testing.FakeFirestoreInstanceWrapperImpl +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -35,6 +37,9 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class DebugFirestoreEventLoggerImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Inject lateinit var debugFirestoreLoggerImpl: DebugFirestoreEventLoggerImpl diff --git a/utility/src/test/java/org/oppia/android/util/logging/firebase/LogReportingModuleTest.kt b/utility/src/test/java/org/oppia/android/util/logging/firebase/LogReportingModuleTest.kt index 40c20ad719c..89f522be363 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/firebase/LogReportingModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/firebase/LogReportingModuleTest.kt @@ -9,10 +9,13 @@ import dagger.Binds import dagger.BindsInstance import dagger.Component import dagger.Module -import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.domain.platformparameter.PlatformParameterModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -24,12 +27,6 @@ import org.oppia.android.util.logging.LoggerModule import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsEventLogger import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds -import org.oppia.android.util.platformparameter.PlatformParameterValue -import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg -import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -42,6 +39,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = LogReportingModuleTest.TestApplication::class) class LogReportingModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var performanceMetricsEventLogger: PerformanceMetricsEventLogger @@ -75,34 +74,6 @@ class LogReportingModuleTest { fun provideContext(application: Application): Context } - @Module - class TestPlatformParameterModule { - - companion object { - var forceLoggingLearnerStudyIds: Boolean = false - } - - @Provides - @SplashScreenWelcomeMsg - fun provideSplashScreenWelcomeMsgParam(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE) - } - - @Provides - @SyncUpWorkerTimePeriodHours - fun provideSyncUpWorkerTimePeriod(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE - ) - } - - @Provides - @EnableLoggingLearnerStudyIds - fun provideLoggingLearnerStudyIds(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter(forceLoggingLearnerStudyIds) - } - } - // TODO(#89): Move this to a common test application component. @Singleton @Component( @@ -110,7 +81,8 @@ class LogReportingModuleTest { TestModule::class, LogReportingModule::class, TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, - TestPlatformParameterModule::class, LoggerModule::class, SyncStatusModule::class, + PlatformParameterModule::class, LoggerModule::class, SyncStatusModule::class, + PlatformParameterSingletonModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { diff --git a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/BUILD.bazel index 58eb7dfd8a0..3ad792ee1dd 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/BUILD.bazel @@ -15,7 +15,6 @@ oppia_android_test( "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", - "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:oppia_shadow_activity_manager", "//testing/src/main/java/org/oppia/android/testing/robolectric:oppia_shadow_traffic_stats", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", diff --git a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorImplTest.kt b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorImplTest.kt index 161a3b19fa7..ca857c1428a 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorImplTest.kt @@ -13,17 +13,19 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.OppiaMetricLog +import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.testing.FakeExceptionLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner -import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.OppiaShadowActivityManager import org.oppia.android.testing.robolectric.OppiaShadowTrafficStats import org.oppia.android.testing.robolectric.RobolectricModule @@ -74,6 +76,8 @@ private const val TEST_CURRENT_TIME = 1665790700L shadows = [OppiaShadowActivityManager::class, OppiaShadowTrafficStats::class] ) class PerformanceMetricsAssessorImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Parameter var totalMemory: Long = Long.MIN_VALUE @Parameter var secondCpuValue: Long = 1200L @@ -470,7 +474,7 @@ class PerformanceMetricsAssessorImplTest { TestModule::class, TestLogReportingModule::class, TestDispatcherModule::class, RobolectricModule::class, FakeOppiaClockModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, - TestPlatformParameterModule::class, SyncStatusModule::class, + PlatformParameterModule::class, SyncStatusModule::class, TestPerformanceMetricsAssessorModule::class ] ) diff --git a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorModuleTest.kt b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorModuleTest.kt index 68046f25d8a..f17c212fd41 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorModuleTest.kt @@ -10,11 +10,13 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.FakePerformanceMetricsEventLogger +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.util.data.DataProvidersInjector @@ -36,6 +38,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PerformanceMetricsAssessorModuleTest.TestApplication::class) class PerformanceMetricsAssessorModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var performanceMetricsAssessor: PerformanceMetricsAssessor diff --git a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsConfigurationsModuleTest.kt b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsConfigurationsModuleTest.kt index dde7045ad67..8e97fedaf1d 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsConfigurationsModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsConfigurationsModuleTest.kt @@ -10,8 +10,10 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.util.data.DataProvidersInjector @@ -32,6 +34,8 @@ private const val ONE_GIGABYTE = 1024L * 1024L * 1024L @LooperMode(LooperMode.Mode.PAUSED) @Config(application = PerformanceMetricsConfigurationsModuleTest.TestApplication::class) class PerformanceMetricsConfigurationsModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @JvmField @field:[Inject MediumMemoryTierUpperBound] diff --git a/utility/src/test/java/org/oppia/android/util/math/AlgebraicEquationParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/AlgebraicEquationParserTest.kt index fa0ccedbb17..206e8604f67 100644 --- a/utility/src/test/java/org/oppia/android/util/math/AlgebraicEquationParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/AlgebraicEquationParserTest.kt @@ -2,10 +2,12 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MathEquation import org.oppia.android.app.model.MathFunctionCall.FunctionType.SQUARE_ROOT +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.math.MathEquationSubject.Companion.assertThat import org.oppia.android.util.math.MathExpressionParser.Companion.ErrorCheckingMode import org.oppia.android.util.math.MathExpressionParser.Companion.MathParsingResult @@ -27,6 +29,9 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class AlgebraicEquationParserTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testParseAlgEq_simpleVariableAssignment_correctlyParsesBothSidesStructures() { val equation = parseAlgebraicEquation("x = 1") diff --git a/utility/src/test/java/org/oppia/android/util/math/AlgebraicExpressionParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/AlgebraicExpressionParserTest.kt index 3c327a362cc..1099353255f 100644 --- a/utility/src/test/java/org/oppia/android/util/math/AlgebraicExpressionParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/AlgebraicExpressionParserTest.kt @@ -2,10 +2,12 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MathExpression import org.oppia.android.app.model.MathFunctionCall.FunctionType.SQUARE_ROOT +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.math.MathExpressionSubject.Companion.assertThat import org.oppia.android.util.math.MathExpressionParser.Companion.ErrorCheckingMode import org.oppia.android.util.math.MathExpressionParser.Companion.MathParsingResult @@ -35,6 +37,9 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class AlgebraicExpressionParserTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testParse_variable_returnsExpWithVariable() { val expression = parseAlgebraicExpressionWithAllErrors("x") diff --git a/utility/src/test/java/org/oppia/android/util/math/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/math/BUILD.bazel index 7a59fa5612c..361b7b6f9b2 100644 --- a/utility/src/test/java/org/oppia/android/util/math/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/math/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/math:math_equation_subject", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", @@ -31,6 +32,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/math:math_expression_subject", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", @@ -50,6 +52,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", @@ -68,6 +71,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:test_models", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", @@ -85,6 +89,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_junit_test_runner", "//testing/src/main/java/org/oppia/android/testing/math:comparable_operation_subject", @@ -105,6 +110,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", "//third_party:com_google_truth_truth", @@ -124,6 +130,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/math:polynomial_subject", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", @@ -142,6 +149,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", @@ -218,6 +226,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_junit_test_runner", "//testing/src/main/java/org/oppia/android/testing/math:math_parsing_error_subject", @@ -238,6 +247,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing:assertion_helpers", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_junit_test_runner", @@ -258,6 +268,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing:assertion_helpers", "//testing/src/main/java/org/oppia/android/testing/math:real_subject", "//third_party:androidx_test_ext_junit", @@ -277,6 +288,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/math:math_expression_subject", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", @@ -314,6 +326,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_junit_test_runner", "//testing/src/main/java/org/oppia/android/testing/math:polynomial_subject", @@ -333,6 +346,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", diff --git a/utility/src/test/java/org/oppia/android/util/math/ComparableOperationExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/ComparableOperationExtensionsTest.kt index f7198f2ba4e..c3056996d16 100644 --- a/utility/src/test/java/org/oppia/android/util/math/ComparableOperationExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/ComparableOperationExtensionsTest.kt @@ -2,12 +2,14 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ComparableOperation import org.oppia.android.app.model.ComparableOperation.CommutativeAccumulation import org.oppia.android.app.model.ComparableOperation.NonCommutativeOperation import org.oppia.android.app.model.Real +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.LooperMode /** Tests for [ComparableOperation] extensions. */ @@ -16,6 +18,9 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class ComparableOperationExtensionsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + private val fractionParser by lazy { FractionParser() } @Test diff --git a/utility/src/test/java/org/oppia/android/util/math/ComparatorExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/ComparatorExtensionsTest.kt index a1c73b45d71..ab2ad48f9d6 100644 --- a/utility/src/test/java/org/oppia/android/util/math/ComparatorExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/ComparatorExtensionsTest.kt @@ -2,9 +2,11 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.TestMessage +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.LooperMode /** Tests for [Comparator] extensions. */ @@ -19,6 +21,9 @@ class ComparatorExtensionsTest { private val TEST_MESSAGE_2 = TestMessage.newBuilder().apply { intValue = 2 }.build() } + @get:Rule + val oppiaTestRule = OppiaTestRule() + private val stringComparator: Comparator by lazy { Comparator { o1, o2 -> o1.compareTo(o2) } } diff --git a/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt b/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt index 5a20ba0cc07..fd46205067c 100644 --- a/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt @@ -1,12 +1,14 @@ package org.oppia.android.util.math import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ComparableOperation import org.oppia.android.app.model.ComparableOperation.CommutativeAccumulation.AccumulationType.PRODUCT import org.oppia.android.app.model.ComparableOperation.CommutativeAccumulation.AccumulationType.SUMMATION import org.oppia.android.app.model.MathExpression +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -32,6 +34,9 @@ import org.robolectric.annotation.LooperMode @SelectRunnerPlatform(ParameterizedJunitTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) class ExpressionToComparableOperationConverterTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Parameter lateinit var op1: String @Parameter lateinit var op2: String diff --git a/utility/src/test/java/org/oppia/android/util/math/ExpressionToLatexConverterTest.kt b/utility/src/test/java/org/oppia/android/util/math/ExpressionToLatexConverterTest.kt index e351f9fc6d9..9abbad8dfd8 100644 --- a/utility/src/test/java/org/oppia/android/util/math/ExpressionToLatexConverterTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/ExpressionToLatexConverterTest.kt @@ -2,10 +2,12 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MathEquation import org.oppia.android.app.model.MathExpression +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.math.ExpressionToLatexConverter.Companion.convertToLatex import org.oppia.android.util.math.MathExpressionParser.Companion.ErrorCheckingMode import org.oppia.android.util.math.MathExpressionParser.Companion.MathParsingResult @@ -18,6 +20,9 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class ExpressionToLatexConverterTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testConvert_numericExp_number_returnsConstantLatex() { val exp = parseNumericExpressionWithAllErrors("1") diff --git a/utility/src/test/java/org/oppia/android/util/math/ExpressionToPolynomialConverterTest.kt b/utility/src/test/java/org/oppia/android/util/math/ExpressionToPolynomialConverterTest.kt index bcf64991b55..975c633e3d5 100644 --- a/utility/src/test/java/org/oppia/android/util/math/ExpressionToPolynomialConverterTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/ExpressionToPolynomialConverterTest.kt @@ -2,9 +2,11 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MathExpression +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.math.PolynomialSubject.Companion.assertThat import org.oppia.android.util.math.ExpressionToPolynomialConverter.Companion.reduceToPolynomial import org.oppia.android.util.math.MathExpressionParser.Companion.ErrorCheckingMode @@ -25,6 +27,9 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class ExpressionToPolynomialConverterTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testReduce_integerConstantExpression_returnsConstantPolynomial() { val expression = parseAlgebraicExpression("2") diff --git a/utility/src/test/java/org/oppia/android/util/math/FloatExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/FloatExtensionsTest.kt index e814d753cae..93d036f6521 100644 --- a/utility/src/test/java/org/oppia/android/util/math/FloatExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/FloatExtensionsTest.kt @@ -2,8 +2,10 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.LooperMode /** Tests for [Float] and [Double] extensions. */ @@ -12,6 +14,9 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class FloatExtensionsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testFloat_isApproximatelyEqualTo_bothZero_returnsTrue() { val leftFloat = 0f 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 f44bc197f98..d08651850eb 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 @@ -2,9 +2,11 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.Fraction +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.math.FractionSubject.Companion.assertThat import org.robolectric.annotation.LooperMode @@ -106,6 +108,9 @@ class FractionExtensionsTest { }.build() } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testHasFractionalPart_zeroFraction_returnsFalse() { val result = ZERO_FRACTION.hasFractionalPart() 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 81d07c867fa..33ce9d609f4 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 @@ -3,9 +3,11 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.Fraction +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode @@ -17,6 +19,9 @@ import org.robolectric.annotation.LooperMode @LooperMode(LooperMode.Mode.PAUSED) @Config class FractionParserTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + private lateinit var fractionParser: FractionParser @Before diff --git a/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt index 371048728af..216307067c3 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt @@ -1,10 +1,12 @@ package org.oppia.android.util.math import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MathEquation import org.oppia.android.app.model.MathExpression +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -37,6 +39,9 @@ import org.robolectric.annotation.LooperMode @SelectRunnerPlatform(ParameterizedJunitTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) class MathExpressionExtensionsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Parameter lateinit var exp1: String @Parameter lateinit var exp2: String diff --git a/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt index 3a164f810f1..850da372905 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt @@ -1,6 +1,7 @@ package org.oppia.android.util.math import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MathBinaryOperation.Operator.ADD @@ -10,6 +11,7 @@ import org.oppia.android.app.model.MathBinaryOperation.Operator.MULTIPLY import org.oppia.android.app.model.MathBinaryOperation.Operator.SUBTRACT import org.oppia.android.app.model.MathEquation import org.oppia.android.app.model.MathExpression +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -44,6 +46,9 @@ import org.robolectric.annotation.LooperMode @SelectRunnerPlatform(ParameterizedJunitTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) class MathExpressionParserTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Parameter lateinit var lhsOp: String @Parameter diff --git a/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt index 4a620f29118..bedddf6a222 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt @@ -1,8 +1,10 @@ package org.oppia.android.util.math import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -18,6 +20,9 @@ import org.robolectric.annotation.LooperMode @SelectRunnerPlatform(ParameterizedJunitTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) class MathTokenizerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Parameter lateinit var variableName: String @Parameter lateinit var funcName: String @Parameter lateinit var token: String diff --git a/utility/src/test/java/org/oppia/android/util/math/NumericExpressionEvaluatorTest.kt b/utility/src/test/java/org/oppia/android/util/math/NumericExpressionEvaluatorTest.kt index 1f4786bde4b..152b1b9b6f3 100644 --- a/utility/src/test/java/org/oppia/android/util/math/NumericExpressionEvaluatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/NumericExpressionEvaluatorTest.kt @@ -2,9 +2,11 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MathExpression +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.math.RealSubject.Companion.assertThat import org.oppia.android.util.math.MathExpressionParser.Companion.ErrorCheckingMode import org.oppia.android.util.math.MathExpressionParser.Companion.ErrorCheckingMode.ALL_ERRORS @@ -28,6 +30,9 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class NumericExpressionEvaluatorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testEvaluate_defaultExpression_returnsNull() { val expression = MathExpression.getDefaultInstance() diff --git a/utility/src/test/java/org/oppia/android/util/math/NumericExpressionParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/NumericExpressionParserTest.kt index 37e89515be3..e1b92c4f07b 100644 --- a/utility/src/test/java/org/oppia/android/util/math/NumericExpressionParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/NumericExpressionParserTest.kt @@ -2,10 +2,12 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.MathExpression import org.oppia.android.app.model.MathFunctionCall.FunctionType.SQUARE_ROOT +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.math.MathExpressionSubject.Companion.assertThat import org.oppia.android.util.math.MathExpressionParser.Companion.ErrorCheckingMode import org.oppia.android.util.math.MathExpressionParser.Companion.MathParsingResult @@ -30,6 +32,8 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class NumericExpressionParserTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Test fun testParse_singleInteger_returnsExpressionWithConstant() { 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 e342081aab0..5ac49af8356 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 @@ -13,6 +13,7 @@ import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.util.math.PeekableIterator.Companion.toPeekableIterator import org.robolectric.annotation.LooperMode @@ -24,6 +25,9 @@ import java.util.function.Supplier @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class PeekableIteratorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt index 1f9824e2b1d..db894bbb45a 100644 --- a/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt @@ -1,6 +1,7 @@ package org.oppia.android.util.math import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.Fraction @@ -8,6 +9,7 @@ import org.oppia.android.app.model.Polynomial import org.oppia.android.app.model.Polynomial.Term import org.oppia.android.app.model.Polynomial.Term.Variable import org.oppia.android.app.model.Real +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -129,6 +131,9 @@ class PolynomialExtensionsTest { ) } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Parameter lateinit var var1: String @Parameter lateinit var var2: String @Parameter lateinit var var3: String diff --git a/utility/src/test/java/org/oppia/android/util/math/RatioExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/RatioExtensionsTest.kt index 2b9bea5df06..027aa922b39 100644 --- a/utility/src/test/java/org/oppia/android/util/math/RatioExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/RatioExtensionsTest.kt @@ -2,9 +2,11 @@ package org.oppia.android.util.math import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.RatioExpression +import org.oppia.android.testing.OppiaTestRule import org.robolectric.annotation.LooperMode /** Tests for [RatioExpression] extensions. */ @@ -13,6 +15,8 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class RatioExtensionsTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Test fun testRatio_ratioReduced_returnsOriginalList() { 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 f39b7a75d9a..43567d57ecd 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 @@ -1,10 +1,12 @@ package org.oppia.android.util.math import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.Fraction import org.oppia.android.app.model.Real +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration @@ -81,6 +83,9 @@ class RealExtensionsTest { private val fractionParser by lazy { FractionParser() } + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Parameter var lhsInt: Int = Int.MIN_VALUE @Parameter lateinit var lhsFrac: String @Parameter var lhsDouble: Double = Double.MIN_VALUE diff --git a/utility/src/test/java/org/oppia/android/util/networking/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/networking/BUILD.bazel index c76aa778976..660c70f11f1 100644 --- a/utility/src/test/java/org/oppia/android/util/networking/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/networking/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", @@ -34,6 +35,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", @@ -56,6 +58,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", @@ -78,6 +81,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", diff --git a/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugImplTest.kt b/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugImplTest.kt index d3fd4f6bf9b..63cff5acc6c 100644 --- a/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugImplTest.kt @@ -14,8 +14,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.networking.NetworkConnectionTestUtil import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -36,6 +38,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NetworkConnectionUtilDebugImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NO_CONNECTION = -1 diff --git a/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugModuleTest.kt b/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugModuleTest.kt index 93df3cd6c88..a073d0d9ddc 100644 --- a/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.logging.EnableConsoleLog import org.oppia.android.util.logging.EnableFileLog import org.oppia.android.util.logging.GlobalLogLevel @@ -26,6 +28,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NetworkConnectionUtilDebugModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var networkConnectionUtil: NetworkConnectionUtil diff --git a/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilProdImplTest.kt b/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilProdImplTest.kt index 17a0393454d..ce41001e504 100644 --- a/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilProdImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilProdImplTest.kt @@ -14,8 +14,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.networking.NetworkConnectionTestUtil import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -36,6 +38,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NetworkConnectionUtilProdImplTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() private val NO_CONNECTION = -1 diff --git a/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilProdModuleTest.kt b/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilProdModuleTest.kt index 8babd7863cc..be6673bfa3a 100644 --- a/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilProdModuleTest.kt +++ b/utility/src/test/java/org/oppia/android/util/networking/NetworkConnectionUtilProdModuleTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.logging.EnableConsoleLog import org.oppia.android.util.logging.EnableFileLog import org.oppia.android.util.logging.GlobalLogLevel @@ -26,6 +28,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class NetworkConnectionUtilProdModuleTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var networkConnectionUtil: NetworkConnectionUtil diff --git a/utility/src/test/java/org/oppia/android/util/parser/html/ConceptCardTagHandlerTest.kt b/utility/src/test/java/org/oppia/android/util/parser/html/ConceptCardTagHandlerTest.kt index 4d70a5d1b4f..8c237c4892c 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/html/ConceptCardTagHandlerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/html/ConceptCardTagHandlerTest.kt @@ -26,6 +26,7 @@ import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.mockito.capture import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -60,6 +61,9 @@ private const val CONCEPT_CARD_LINK_WITHOUT_TEXT_MARKUP = @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class ConceptCardTagHandlerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() 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 2042ef72ec8..454f54051e2 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 @@ -27,6 +27,7 @@ import org.oppia.android.app.model.OppiaLanguage 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.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -56,6 +57,9 @@ private const val OL_TAG_MARKUP_1 = @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class CustomHtmlContentHandlerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + private lateinit var tagHandlersWithListTagSupport: Map @Rule diff --git a/utility/src/test/java/org/oppia/android/util/parser/html/ImageTagHandlerTest.kt b/utility/src/test/java/org/oppia/android/util/parser/html/ImageTagHandlerTest.kt index e1bd9e22a2e..069da9ad79b 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/html/ImageTagHandlerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/html/ImageTagHandlerTest.kt @@ -27,6 +27,7 @@ import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.mockito.capture import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -83,6 +84,9 @@ private const val IMAGE_TAG_WITH_CAPTION_MARKUP = @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class ImageTagHandlerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() 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 1341bc68776..bbbbb62e5c5 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 @@ -23,6 +23,7 @@ import org.oppia.android.app.model.OppiaLanguage 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.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule @@ -41,6 +42,9 @@ import kotlin.reflect.KClass @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class LiTagHandlerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/utility/src/test/java/org/oppia/android/util/parser/html/MathTagHandlerTest.kt b/utility/src/test/java/org/oppia/android/util/parser/html/MathTagHandlerTest.kt index 535d5c90e58..0aa5f6693c0 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/html/MathTagHandlerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/html/MathTagHandlerTest.kt @@ -26,6 +26,7 @@ import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.mockito.capture import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -78,6 +79,9 @@ private const val MATH_WITHOUT_FILENAME_RENDER_TYPE_BLOCK_MARKUP = @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class MathTagHandlerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/utility/src/test/java/org/oppia/android/util/parser/html/PolicyPageTagHandlerTest.kt b/utility/src/test/java/org/oppia/android/util/parser/html/PolicyPageTagHandlerTest.kt index f258cfe1ef0..8e836f672a5 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/html/PolicyPageTagHandlerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/html/PolicyPageTagHandlerTest.kt @@ -23,6 +23,7 @@ import org.mockito.Mock import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.mockito.capture import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -46,6 +47,9 @@ private const val POLICY_PAGE_LINK_MARKUP_1 = @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class PolicyPageTagHandlerTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/utility/src/test/java/org/oppia/android/util/parser/image/UrlImageParserTest.kt b/utility/src/test/java/org/oppia/android/util/parser/image/UrlImageParserTest.kt index d1480089590..7882c122a22 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/image/UrlImageParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/image/UrlImageParserTest.kt @@ -16,6 +16,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule @@ -34,6 +35,9 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class UrlImageParserTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Rule @JvmField val mockitoRule: MockitoRule = MockitoJUnit.rule() diff --git a/utility/src/test/java/org/oppia/android/util/parser/math/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/parser/math/BUILD.bazel index 3fb1fc751be..d693c47368b 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/math/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/parser/math/BUILD.bazel @@ -11,6 +11,7 @@ oppia_android_test( test_class = "org.oppia.android.util.parser.math.MathModelTest", test_manifest = "//utility:test_manifest", deps = [ + "//testing", "//third_party:com_google_truth_truth", "//third_party:junit_junit", "//third_party:robolectric_android-all", diff --git a/utility/src/test/java/org/oppia/android/util/parser/math/MathModelTest.kt b/utility/src/test/java/org/oppia/android/util/parser/math/MathModelTest.kt index ceea0fbf2ca..681f40e4e27 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/math/MathModelTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/math/MathModelTest.kt @@ -1,13 +1,21 @@ package org.oppia.android.util.parser.math +import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat +import org.junit.Rule import org.junit.Test +import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import java.security.MessageDigest /** Tests for [MathModel]. */ // FunctionName: test names are conventionally named with underscores. +@RunWith(AndroidJUnit4::class) @Suppress("FunctionName") class MathModelTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() + @Test fun testToKeySignature_sameModelByValues_returnsSameKeyWithSameDigest() { val model1 = MathModel(rawLatex = "\\frac{2}{6}", lineHeight = 21.5f, useInlineRendering = true) diff --git a/utility/src/test/java/org/oppia/android/util/profile/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/profile/BUILD.bazel index 480f7a244ec..ad228b8fc4a 100644 --- a/utility/src/test/java/org/oppia/android/util/profile/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/profile/BUILD.bazel @@ -11,6 +11,7 @@ oppia_android_test( test_class = "org.oppia.android.util.profile.CurrentUserProfileIdIntentDecoratorTest", test_manifest = "//utility:test_manifest", deps = [ + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", "//third_party:com_google_truth_truth", @@ -29,6 +30,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", "//third_party:androidx_test_ext_junit", @@ -49,6 +51,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", diff --git a/utility/src/test/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecoratorTest.kt b/utility/src/test/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecoratorTest.kt index 679dd21a3f0..1e8fcb6e318 100644 --- a/utility/src/test/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecoratorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/profile/CurrentUserProfileIdIntentDecoratorTest.kt @@ -5,9 +5,11 @@ import android.os.Bundle import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.LiteProtoTruth.assertThat +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ProfileId +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId import org.robolectric.annotation.LooperMode @@ -18,6 +20,8 @@ import org.robolectric.annotation.LooperMode @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) class CurrentUserProfileIdIntentDecoratorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Test fun testDecorator_decorateWithProfileId_returnsIntentWithCorrectProfileId() { diff --git a/utility/src/test/java/org/oppia/android/util/profile/DirectoryManagementUtilTest.kt b/utility/src/test/java/org/oppia/android/util/profile/DirectoryManagementUtilTest.kt index 6623ec67c1b..52d35b5153f 100644 --- a/utility/src/test/java/org/oppia/android/util/profile/DirectoryManagementUtilTest.kt +++ b/utility/src/test/java/org/oppia/android/util/profile/DirectoryManagementUtilTest.kt @@ -10,8 +10,10 @@ import dagger.Component import dagger.Module import dagger.Provides import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.logging.EnableConsoleLog @@ -29,6 +31,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class DirectoryManagementUtilTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var directoryManagementUtil: DirectoryManagementUtil diff --git a/utility/src/test/java/org/oppia/android/util/profile/ProfileNameValidatorTest.kt b/utility/src/test/java/org/oppia/android/util/profile/ProfileNameValidatorTest.kt index 2875834c868..08b21e57276 100644 --- a/utility/src/test/java/org/oppia/android/util/profile/ProfileNameValidatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/profile/ProfileNameValidatorTest.kt @@ -6,8 +6,10 @@ import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter @@ -25,6 +27,8 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) class ProfileNameValidatorTest { + @get:Rule + val oppiaTestRule = OppiaTestRule() @Inject lateinit var profileNameValidator: ProfileNameValidator diff --git a/wiki/Platform-Parameters-&-Feature-Flags.md b/wiki/Platform-Parameters-&-Feature-Flags.md index 451baebf93c..654ef990703 100644 --- a/wiki/Platform-Parameters-&-Feature-Flags.md +++ b/wiki/Platform-Parameters-&-Feature-Flags.md @@ -6,8 +6,6 @@ - [How to consume a Platform Parameter or Feature Flag](#how-to-consume-a-platform-parameter-or-feature-flag) - [Ensuring your Feature Flags are logged on each app session](#ensuring-your-feature-flags-are-logged-on-each-app-session) - [How to write tests related Platform Parameter](#how-to-write-tests-related-platform-parameter) - - [1. We actually don't test for platform parameter(s)](#1-we-actually-dont-test-for-platform-parameters) - - [2. We test for different values of platform parameter(s)](#2-we-test-for-different-values-of-platform-parameters) ## Introduction With a large scale system like Oppia, we sometimes have features that contain several points of integration in the codebase, and/or require additional data priming or migrations ahead of the feature being released. These features often span multiple releases and thus require feature flags to gate integration points to ensure that the feature is not partially released ahead of schedule. Moreover, these features often require migrations which need to be run in specific releases due to new versions being made in irreversible data structures (e.g. explorations). @@ -218,62 +216,122 @@ Besides the feature-flag logger, the `FeatureFlagLoggerTest` located at `domain/ - The second test that will need to be updated is the `testLogFeatureFlags_allFeatureFlagNamesAreLogged`. This is a parameterized test that iterates through each currently existing feature flag to ensure each one of them is logged as expected. To update this test and ensure it passes after a feature flag change, modify the `RunParameterized()` section and either add the expected values for the new flag or remove the expected values for a removed feature flag. ## How to write tests related to Platform Parameters -Before writing a test we must understand the purpose of the platform parameter in our class/classes (that needs to be tested). After verifying this we can divide testing procedures into following groups - +Feature Flags and Platform Parameters might be toggled on or off, and it is essential to ensure their functionality is maintained so that tests behave as intended. -### 1. We actually don't test for platform parameter(s) -We just need specific platform parameter(s) in the dagger graph because our class needs it, but our test cases are not actually verifying the behaviour of class based on different values of the platform parameter. These are the simplest cases to write tests for. We will only need to create a `TestModule` inside the Test class and then include this into the @Component for the `TestApplicationComponent`. For eg - +To facilitate this, specific annotations can be used: +- **Feature Flags**: + - `@EnableFeatureFlag` + - `@DisableFeatureFlag` + - `@ResetFeatureFlag` + +- **Platform Parameters**: + - `@OverrideBoolParameter` + - `@OverrideIntParameter` + - `@OverrideStringParameter` + +These annotations allow to easily configure feature flags and platform parameters for their tests. + +## Usage + +Ensure that the `PlatformParameterModule` is properly injected into the test class. ```kotlin -@Module -class TestModule { - @Provides - @SyncUpWorkerTimePeriodInHours - fun provideSyncUpWorkerTimePeriod(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE - ) - } +@Singleton +@Component( + modules = [PlatformParameterModule::class] +) +``` + +Include `OppiaTestRule` in the test file. + +```kotlin +@get:Rule +val oppiaTestRule = OppiaTestRule() +``` + +### 1. Feature Flags + +Use the appropriate annotations for enabling, disabling, or resetting feature flags. + +```kotlin +@Test +@EnableFeatureFlag(FeatureFlag.TEST_FEATURE) +fun testWhenFeatureFlagIsEnabled() { + // Test logic with the feature flag enabled } -@Singleton -@Component(modules = [TestModule::class, ... ]) -interface TestApplicationComponent { - @Component.Builder - interface Builder { - @BindsInstance - fun setApplication(application: Application): Builder - fun build(): TestApplicationComponent - } - fun inject(platformParameterSyncUpWorkManagerInitializerTest: PlatformParameterSyncUpWorkManagerInitializerTest) +@Test +@DisableFeatureFlag(FeatureFlag.TEST_FEATURE) +fun testWhenFeatureFlagIsDisabled() { + // Test logic with the feature flag disabled } -``` -### 2. We test for different values of platform parameter(s) -We need to test the behaviour of the target class/classes based on different values of the platform parameter. Same platform parameter can have different values because of the difference between its compile-time/default and runtime/server value. To test for this case we can set up a fake singleton class and provide the seed values that we want to be injected into target classes. For eg - +@Test +@ResetFeatureFlag(FeatureFlag.TEST_FEATURE) +fun testWithDefaultFeatureFlagState() { + // Test logic with default feature flag state +} ``` + +The feature flag names are derived from the list of feature flag constant values. + +### 2. Platform Parameters + +Use override annotations to override type specific platform parameter values for testing. + +```kotlin @Test -fun testSyncUpWorker_checkIfServerValueOfSyncUpTimePeriodIsUsed(){ - val seedValues = mapOf( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS to SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_SERVER_VALUE - ) - setUpTestApplicationComponent(seedValues) - // Continue your normal testing +@OverrideBoolParameter(PlatformParameter.BOOLEAN_PARAMETER, value = true) +fun testWithOverriddenBooleanParameter() { + // Test logic with overridden boolean parameter } -private fun setUpTestApplicationComponent(seedValues: Map) { - MockPlatformParameterSingleton.seedPlatformParameterMap.putAll(seedValues) - ApplicationProvider.getApplicationContext().inject(this) +@Test +@OverrideIntParameter(PlatformParameter.INT_PARAMETER, value = 42) +fun testWithOverriddenIntParameter() { + // Test logic with overridden int parameter } -@Module -class TestModule { - @Provides - fun provideMockPlatformParameterSingleton( - platformParameterSingletonImpl: PlatformParameterSingletonImpl - ) : PlatformParameterSingleton { - return MockPlatformParameterSingleton(platformParameterSingletonImpl) - } +@Test +@OverrideStringParameter(PlatformParameter.STRING_PARAMETER, value = "Test Value") +fun testWithOverriddenStringParameter() { + // Test logic with overridden string parameter +} +``` + +Use these annotations to simulate specific runtime conditions by overriding the platform parameter values for your test cases. + +### Annotation Functionalities + +- Scope of Annotations + - `@EnableFeatureFlag`, `@DisableFeatureFlag`, `@OverrideBoolParameter`, `@OverrideIntParameter` and `@OverrideStringParameter` can be used at both class and method levels. + - `@ResetFeatureFlag` is specific to method level + +```kotlin +@EnableFeatureFlag(FeatureFlag.TEST_FEATURE) +@OverrideBoolParameter(PlatformParameter.BOOLEAN_PARAMETER, value = true) +class FeatureFlagPlatformParameterTest { + + @Test + @DisableFeatureFlag(FeatureFlag.TEST_FEATURE) + @ResetFeatureFlag(FeatureFlag.TEST_FEATURE) + fun testWithMethodLevelOverrides() { + // Test logic + } +} +``` + +- Multiple Annotations + - Multiple annotations can be applied simultaneously to tweak the values of multiple feature flags and platform parameters. + +```kotlin +@Test +@EnableFeatureFlag(FeatureFlag.FEATURE_A) +@DisableFeatureFlag(FeatureFlag.FEATURE_B) +@OverrideIntParameter(PlatformParameter.PARAMETER_X, value = 100) +fun testWithMultipleOverrides() { + // Test logic combining multiple feature flags and platform parameter overrides } ``` -Note : To understand the underlying mechanism of this test, you will need to understand how these platform parameters reach the dagger graph. You can refer to this [document](https://docs.google.com/document/d/1o8MtAO8e8bX7UtWFYx-T9G4vCGRfvY9oIwDutDn4pVM/edit#heading=h.m1q1hwhhqigf) for detailed explanation about the flow for the platform parameter architecture. +Note : To understand the underlying mechanism of this test, you will need to understand how these platform parameters reach the dagger graph. You can refer to this [document](https://docs.google.com/document/d/1o8MtAO8e8bX7UtWFYx-T9G4vCGRfvY9oIwDutDn4pVM/edit#heading=h.m1q1hwhhqigf) for detailed explanation about the flow for the platform parameter architecture. \ No newline at end of file