diff --git a/app/build.gradle b/app/build.gradle index 7c94678f75c..32aec63ca66 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -79,7 +79,7 @@ android { exceptionFormat = "full" showCauses = true showStackTraces = true - showStandardStreams = false + showStandardStreams = true } } } 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/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index 890275fa0a6..742fba83b67 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() @@ -779,7 +781,10 @@ class ProfileAndDeviceIdFragmentTest { } } + // req learner study analytics + log learner study id @Test + /*@EnableFeatureFlag("android_enable_logging_learner_study_ids") + @EnableFeatureFlag("android_enable_learner_study_analytics")*/ fun testFragment_multipleProfiles_clickShareIdsAndLogs_sendsIntentWithIdsAndLogsText() { // Use fake time so that the generated event logs are consistent across runs. fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) @@ -1116,7 +1121,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..e95bba2d908 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 @@ -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.topic.FRACTIONS_STORY_ID_0 @@ -106,7 +107,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 @@ -1115,7 +1115,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/home/HomeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt index f0943148df3..77a0c1d243a 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 @@ -131,7 +132,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 @@ -2199,7 +2199,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/player/exploration/ExplorationActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt index d5adce598af..460887a2c03 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 @@ -146,7 +147,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 @@ -2880,7 +2880,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/StateFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt index b9aa97a1a1e..ed74ee57219 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 @@ -138,6 +138,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 @@ -153,6 +154,7 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment 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 @@ -3659,6 +3661,7 @@ class StateFragmentTest { } @Test + @OverrideBoolParameter("cache_latex_rendering", true) fun testStateFragment_mathInteractions_numericExp_validAns_submissionDisplaysLatex() { setUpTestWithLanguageSwitchingFeatureOff() launchForExploration(TEST_EXPLORATION_ID_5, shouldSavePartialProgress = false).use { scenario -> @@ -5933,7 +5936,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/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..73f56e7788b 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,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.profile.ProfileManagementController 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.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -111,6 +112,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 @@ -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/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 fd3abbeb87c..c9dbc36371d 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 @@ -167,8 +169,8 @@ class TopicActivityTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicActivity_hasCorrectActivityLabel() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) launchTopicActivity( internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID ).use { scenario -> @@ -183,8 +185,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(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { // Open the practice tab and select a skill. onView(withText("Practice")).perform(click()) @@ -234,7 +236,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 e7ae27305ff..ffac3fe1a26 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( internalProfileId, 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( internalProfileId, @@ -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( internalProfileId, @@ -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) val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() @@ -310,8 +323,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( @@ -325,8 +339,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) val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() @@ -355,8 +371,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( @@ -378,8 +395,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( @@ -401,8 +419,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( @@ -423,8 +442,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( @@ -445,8 +465,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnToolbarNavigationButton_closeActivity() { - initializeApplicationComponent(false) + initializeApplicationComponent() activityTestRule.launchActivity( createTopicActivityIntent( internalProfileId, @@ -459,16 +480,18 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_showsTopicFragmentWithMultipleTabs() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, 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(internalProfileId, 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()) @@ -477,8 +500,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_infoTopicTab_isDisplayedInTabLayout() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { onView( withText( @@ -492,8 +516,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_infoTopicTab_isNotDisplayedInTabLayout() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { onView(withText(TopicTab.getTabForPosition(position = INFO_TAB_POSITION, true).name)) .check(doesNotExist()) @@ -501,8 +526,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_defaultTabIsLessons() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicPlayStoryActivityIntent( internalProfileId, TEST_CLASSROOM_ID_1, @@ -514,8 +540,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_defaultTabIsLessons() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicPlayStoryActivityIntent( internalProfileId, TEST_CLASSROOM_ID_1, @@ -527,8 +554,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_clickOnLessonsTab_showsPlayTabSelected() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { clickTabAtPosition(position = LESSON_TAB_POSITION_EXTRA_TABS_DISABLED) verifyTabTitleAtPosition(position = LESSON_TAB_POSITION_EXTRA_TABS_DISABLED) @@ -536,8 +564,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnLessonsTab_showsPlayTabWithContentMatched() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -553,8 +582,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_practiceTabEnabled_practiceTopicTabIsDisplayedInTabLayout() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { val practiceTab = TopicTab.getTabForPosition(position = PRACTICE_TAB_POSITION, enableExtraTopicTabsUi.value) @@ -571,8 +601,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_practiceTopicTabIsNotDisplayedInTabLayout() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { // Unconditionally retrieve the practice tab name since this test is verifying that it's not // enabled. @@ -583,8 +614,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_configChange_practiceTopicTabIsNotDisplayed() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { onView(isRoot()).perform(orientationLandscape()) testCoroutineDispatchers.runCurrent() @@ -599,8 +631,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_clickOnPracticeTab_showsPracticeTabSelected() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { clickTabAtPosition(position = PRACTICE_TAB_POSITION) verifyTabTitleAtPosition(position = PRACTICE_TAB_POSITION) @@ -608,8 +641,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_clickOnPracticeTab_showsPracticeTabWithContentMatched() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -625,8 +659,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnReviewTab_showsReviewTabSelected() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { clickTabAtPosition(position = REVISION_TAB_POSITION_EXTRA_TABS_DISABLED) verifyTabTitleAtPosition(position = REVISION_TAB_POSITION_EXTRA_TABS_DISABLED) @@ -634,8 +669,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnReviewTab_showsReviewTabWithContentMatched() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -651,8 +687,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_clickOnReviewTab_thenInfoTab_showsInfoTab() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { clickTabAtPosition(position = REVISION_TAB_POSITION) clickTabAtPosition(position = INFO_TAB_POSITION) @@ -661,8 +698,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun enableExtraTabs_clickOnReviewTab_thenInfoTab_showsInfoTabWithContentMatched() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() clickTabAtPosition(position = REVISION_TAB_POSITION) @@ -678,8 +716,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnLessonsTab_configChange_showsSameTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() clickTabAtPosition(position = LESSON_TAB_POSITION_EXTRA_TABS_DISABLED) @@ -696,8 +735,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun enableExtraTabs_clickOnPracticeTab_configChange_showsSameTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -722,8 +762,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_clickOnReviewTab_configChange_showsSameTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() @@ -741,8 +782,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_enableExtraTabs_configChange_showsDefaultTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() launchTopicPlayStoryActivityIntent( internalProfileId, TEST_CLASSROOM_ID_1, @@ -762,8 +804,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicFragment_disableExtraTabs_configChange_showsDefaultTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() launchTopicPlayStoryActivityIntent( internalProfileId, TEST_CLASSROOM_ID_1, @@ -783,8 +826,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun enableExtraTabs_withStoryId_clickOnPracticeTab_configChange_showsSameTabAndItsContent() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( internalProfileId, @@ -813,8 +857,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_lessonsTabDefaulted_logsLessonsTabOpen() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( internalProfileId, @@ -830,8 +875,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_lessonsTabDefaulted_switchToRevisionTab_logsRevisionTabOpen() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( internalProfileId, @@ -850,8 +896,9 @@ class TopicFragmentTest { } @Test + @DisableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_lessonsTabDefaulted_switchToRevisionTabThenBack_logsLessonsTabOpenAgain() { - initializeApplicationComponent(enableExtraTabsUi = false) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( internalProfileId, @@ -872,8 +919,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_extraTabs_openInfoTab_logsInfoTabOpen() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( internalProfileId, @@ -892,8 +940,9 @@ class TopicFragmentTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testOpenFragment_extraTabs_openQuestionsTab_logsInfoQuestionsOpen() { - initializeApplicationComponent(enableExtraTabsUi = true) + initializeApplicationComponent() markAllSpotlightsSeen() launchTopicPlayStoryActivityIntent( internalProfileId, @@ -1031,8 +1080,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) @@ -1046,7 +1094,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 472e8aefd8a..3d214eb7222 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 @@ -81,10 +81,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 @@ -93,7 +95,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 @@ -110,6 +111,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 @@ -140,6 +142,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() @@ -163,7 +166,6 @@ class TopicInfoFragmentTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() } @@ -491,7 +493,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 0bbc1c36717..55bae61229e 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() @@ -184,7 +187,6 @@ class TopicLessonsFragmentTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) Intents.init() setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() @@ -1335,7 +1337,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 3707b80e7b2..48a51c0b7f2 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") @@ -442,7 +444,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 518d1c8ee84..b8426d19b24 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() @@ -350,7 +352,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/player/exploration/ExplorationActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt index b5059c0892e..d0afb331128 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,11 @@ 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.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 +104,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 @@ -174,8 +176,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 +230,9 @@ class ExplorationActivityLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.ENABLE_NPS_SURVEY) fun testExplorationActivity_closeExploration_surveyGatingCriteriaNotMet_noSurveyPopup() { - setUpTestWithNpsEnabled() + setUpTestApplicationComponent() getApplicationDependencies( internalProfileId, TEST_CLASSROOM_ID_0, @@ -273,8 +277,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 +342,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 +405,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/testing/options/OptionsFragmentTest.kt b/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt index 54178d81774..70cf7fd3811 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,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.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 +88,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 @@ -109,9 +108,6 @@ class OptionsFragmentTest { @Before fun setUp() { - TestPlatformParameterModule.forceEnableEditAccountsOptionsUi( - ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE - ) setUpTestApplicationComponent() testCoroutineDispatchers.registerIdlingResource() profileTestHelper.initializeProfiles() @@ -219,7 +215,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/topic/info/TopicInfoFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt index b7a0a3dcabd..7824d68664f 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 @@ -55,14 +55,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 @@ -80,6 +82,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 @@ -96,6 +99,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 @@ -108,8 +112,8 @@ class TopicInfoFragmentLocalTest { } @Test + @EnableFeatureFlag(FeatureFlag.EXTRA_TOPIC_TABS_UI) fun testTopicInfoFragment_onLaunch_logsEvent() { - TestPlatformParameterModule.forceEnableExtraTopicTabsUi(true) launchTopicActivityIntent(internalProfileId, TEST_CLASSROOM_ID, TEST_TOPIC_ID).use { testCoroutineDispatchers.runCurrent() val event = fakeAnalyticsEventLogger.getMostRecentEvent() @@ -144,7 +148,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/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..6988d3aee27 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 @@ -41,6 +41,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 +68,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 +82,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 as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) ?: PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) } @@ -115,11 +120,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 as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(EDIT_ACCOUNTS_OPTIONS_UI) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE + ) } @Provides @@ -127,7 +133,9 @@ class PlatformParameterModule { fun provideLearnerStudyAnalytics( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(LEARNER_STUDY_ANALYTICS) + return overriddenFeatureFlags[FeatureFlag.LEARNER_STUDY_ANALYTICS]?.let { + PlatformParameterValue.createDefaultParameter(it as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(LEARNER_STUDY_ANALYTICS) ?: PlatformParameterValue.createDefaultParameter(LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE) } @@ -136,7 +144,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 as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(FAST_LANGUAGE_SWITCHING_IN_LESSON) ?: PlatformParameterValue.createDefaultParameter( FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE ) @@ -147,7 +157,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 as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(LOGGING_LEARNER_STUDY_IDS) ?: PlatformParameterValue.createDefaultParameter(LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE) } @@ -156,7 +168,9 @@ 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) } @@ -213,7 +227,9 @@ class PlatformParameterModule { fun provideEnableSpotlightUi( platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) + return overriddenFeatureFlags[FeatureFlag.SPOTLIGHT_UI]?.let { + PlatformParameterValue.createDefaultParameter(it as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) ?: PlatformParameterValue.createDefaultParameter(ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE) } @@ -222,11 +238,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 as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(EXTRA_TOPIC_TABS_UI) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE) } @Provides @@ -319,10 +334,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 as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(ENABLE_NPS_SURVEY) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_NPS_SURVEY_DEFAULT_VALUE) } @Provides @@ -330,10 +345,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 as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(ENABLE_ONBOARDING_FLOW_V2) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE) } @Provides @@ -341,9 +356,34 @@ 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 as Boolean) + } ?: platformParameterSingleton.getBooleanPlatformParameter(ENABLE_MULTIPLE_CLASSROOMS) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_MULTIPLE_CLASSROOMS_DEFAULT_VALUE) + } + + companion object { + private val overriddenFeatureFlags = mutableMapOf() + private val overriddenPlatformParameters = mutableMapOf() + + fun overrideFeatureFlags(name: FeatureFlag, value: Any) { + println("Name: $name, value: $value") + overriddenFeatureFlags[name] = value + } + + fun overridePlatformParameters(name: PlatformParameter, value: Any) { + println("Name: $name, value: $value") + overriddenPlatformParameters[name] = value + } + + fun resetFeatureFlagToDefault(name: FeatureFlag) { + println("Resetting $name") + overriddenFeatureFlags.remove(name) + } + + fun clearAllParameterOverrides() { + overriddenFeatureFlags.clear() + overriddenPlatformParameters.clear() + } } } 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/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/ExplorationProgressModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressModuleTest.kt index eea2f6708ee..a8e96240b6d 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 @@ -15,8 +15,8 @@ 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.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 @@ -87,7 +87,7 @@ class ExplorationProgressModuleTest { FakeOppiaClockModule::class, ExplorationProgressModule::class, TestDispatcherModule::class, LocaleProdModule::class, TestLogReportingModule::class, LogStorageModule::class, NetworkConnectionUtilDebugModule::class, ExplorationStorageTestModule::class, - TestPlatformParameterModule::class + PlatformParameterModule::class ] ) interface TestApplicationComponent : DataProvidersInjector { 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/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..615a38b5814 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/DisableFeatureFlag.kt @@ -0,0 +1,7 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.FeatureFlag + +@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..25e810f9685 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/EnableFeatureFlag.kt @@ -0,0 +1,7 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.FeatureFlag + +@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..4f68ac1c758 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,44 +29,140 @@ 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 + ) + + val resetParameterToDefault = extractParametersAndFeatureFlags( + description?.annotations, ResetParameterToDefault::class.java + ) + + try { + applyOverrides( + enabledFeatureFlags, + disabledFeatureFlags, + overriddenBoolParameters, + overriddenIntParameters, + overriddenStringParameters, + resetFeatureFlagToDefault, + resetParameterToDefault + ) + + 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?, + resetParameterToDefault: 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.overrideParameter(overriddenValue.name, overriddenValue.value) + } + overriddenIntParameters?.forEach { overriddenValue -> + PlatformParameterModule.overrideParameter(overriddenValue.name, overriddenValue.value) + } + overriddenStringParameters?.forEach { overriddenValue -> + PlatformParameterModule.overrideParameter(overriddenValue.name, overriddenValue.value) + } + + resetParameterToDefault?.forEach { resetParameter -> + PlatformParameterModule.resetParameterToDefault(resetParameter.name) + }*/ + } + private fun getCurrentPlatform(): TestPlatform { return if (Build.FINGERPRINT.contains("robolectric", ignoreCase = true)) { TestPlatform.ROBOLECTRIC @@ -133,5 +231,26 @@ class OppiaTestRule : TestRule { private fun Class.areAccessibilityTestsEnabledForClass(): Boolean { return getAnnotation(DisableAccessibilityChecks::class.java) == null } + + 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..4409347eb32 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/OverrideBoolParameter.kt @@ -0,0 +1,5 @@ +package org.oppia.android.testing + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Repeatable +annotation class OverrideBoolParameter(val name: String, 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..63113c25083 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/OverrideIntParameter.kt @@ -0,0 +1,5 @@ +package org.oppia.android.testing + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Repeatable +annotation class OverrideIntParameter(val name: String, 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..bfc1f18a8d1 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/OverrideStringParameter.kt @@ -0,0 +1,5 @@ +package org.oppia.android.testing + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Repeatable +annotation class OverrideStringParameter(val name: String, 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..7b5d0f90ecf --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/ResetFeatureFlagToDefault.kt @@ -0,0 +1,7 @@ +package org.oppia.android.testing + +import org.oppia.android.util.platformparameter.FeatureFlag + +@Target(AnnotationTarget.FUNCTION) +@Repeatable +annotation class ResetFeatureFlagToDefault(val name: FeatureFlag) diff --git a/testing/src/main/java/org/oppia/android/testing/ResetParameterToDefault.kt b/testing/src/main/java/org/oppia/android/testing/ResetParameterToDefault.kt new file mode 100644 index 00000000000..2ad68a04f44 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/ResetParameterToDefault.kt @@ -0,0 +1,5 @@ +package org.oppia.android.testing + +@Target(AnnotationTarget.FUNCTION) +@Repeatable +annotation class ResetParameterToDefault(val name: String) 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..2af4699fb2d 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,22 @@ package org.oppia.android.util.platformparameter import javax.inject.Qualifier +enum class FeatureFlag { + DOWNLOADS_SUPPORT, + EXTRA_TOPIC_TABS_UI, + LEARNER_STUDY_ANALYTICS, + FAST_LANGUAGE_SWITCHING_IN_LESSON, + LOGGING_LEARNER_STUDY_IDS, + EDIT_ACCOUNTS_OPTIONS_UI, + ENABLE_PERFORMANCE_METRICS_COLLECTION, + SPOTLIGHT_UI, + INTERACTION_CONFIG_CHANGE_STATE_RETENTION, + APP_AND_OS_DEPRECATION, + ENABLE_NPS_SURVEY, + ENABLE_ONBOARDING_FLOW_V2, + 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..4bae1a4ef4d 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,21 @@ package org.oppia.android.util.platformparameter import javax.inject.Qualifier +enum class PlatformParameter { + AUTOMATIC_UPDATE_TOPIC_SETTING, + SPLASH_SCREEN_WELCOME_MSG, + SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS, + CACHE_LATEX_RENDERING, + PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES, + PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES, + PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES, + OPTIONAL_APP_UPDATE_VERSION_CODE, + FORCED_APP_UPDATE_VERSION_CODE, + LOWEST_SUPPORTED_API_LEVEL, + NPS_SURVEY_GRACE_PERIOD_IN_DAYS, + 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: @@ -75,7 +90,7 @@ annotation class CacheLatexRendering const val CACHE_LATEX_RENDERING = "cache_latex_rendering" /** Default value for whether to cache LaTeX rendering using Glide. */ -const val CACHE_LATEX_RENDERING_DEFAULT_VALUE = true +const val CACHE_LATEX_RENDERING_DEFAULT_VALUE = false /** * Qualifier for the platform parameter that controls the time interval in minutes of uploading