Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes part of #4302 - Introducing a JUnit annotation & rule for overriding Platform Parameters and Feature Flags #5565

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from
Draft
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ android {
exceptionFormat = "full"
showCauses = true
showStackTraces = true
showStandardStreams = false
showStandardStreams = true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -181,7 +185,6 @@ class AdministratorControlsActivityTest {

@Before
fun setUp() {
TestPlatformParameterModule.forceEnableEditAccountsOptionsUi(true)
Intents.init()
setUpTestApplicationComponent()
testCoroutineDispatchers.registerIdlingResource()
Expand Down Expand Up @@ -234,8 +237,8 @@ class AdministratorControlsActivityTest {
}

@Test
@DisableFeatureFlag(FeatureFlag.EDIT_ACCOUNTS_OPTIONS_UI)
fun testAdministratorControlsFragment_editAccountOptionsDisabled_generalOptionsIsNotDisplayed() {
TestPlatformParameterModule.forceEnableEditAccountsOptionsUi(false)

launch<AdministratorControlsActivity>(
createAdministratorControlsActivityIntent(
Expand Down Expand Up @@ -618,8 +621,8 @@ class AdministratorControlsActivityTest {

@Test
@Config(qualifiers = "sw600dp")
@EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT)
fun testAdminControls_selectAdmin_tabletConfigChange_downloadsEnabled_hasNoDownloadSettings() {
TestPlatformParameterModule.forceEnableDownloadsSupport(true)
launch<AdministratorControlsActivity>(
createAdministratorControlsActivityIntent(
profileId = profileId
Expand All @@ -637,8 +640,8 @@ class AdministratorControlsActivityTest {

@Test
@Config(qualifiers = "sw600dp")
@EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT)
fun testAdminControls_selectUser_tabletConfigChange_downloadsEnabled_hasDownloadSettings() {
TestPlatformParameterModule.forceEnableDownloadsSupport(true)
launch<AdministratorControlsActivity>(
createAdministratorControlsActivityIntent(
profileId = profileId
Expand All @@ -657,8 +660,8 @@ class AdministratorControlsActivityTest {

@Test
@Config(qualifiers = "sw600dp")
@EnableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT)
fun testAdminControls_selectAdmin_tabletConfigChange_downloadsDisabled_hasNoDownloadSettings() {
TestPlatformParameterModule.forceEnableDownloadsSupport(false)
launch<AdministratorControlsActivity>(
createAdministratorControlsActivityIntent(
profileId = profileId
Expand All @@ -678,8 +681,8 @@ class AdministratorControlsActivityTest {

@Test
@Config(qualifiers = "sw600dp")
@DisableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT)
fun testAdminControls_selectUser_tabletConfigChange_downloadsDisabled_hasNoDownloadSettings() {
TestPlatformParameterModule.forceEnableDownloadsSupport(false)
launch<AdministratorControlsActivity>(
createAdministratorControlsActivityIntent(
profileId = profileId
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -142,8 +147,6 @@ class AdministratorControlsFragmentTest {

@Before
fun setUp() {
TestPlatformParameterModule.forceEnableEditAccountsOptionsUi(true)
TestPlatformParameterModule.forceEnableDownloadsSupport(true)
Intents.init()
setUpTestApplicationComponent()
profileTestHelper.initializeProfiles()
Expand Down Expand Up @@ -223,8 +226,8 @@ class AdministratorControlsFragmentTest {
}

@Test
@DisableFeatureFlag(FeatureFlag.DOWNLOADS_SUPPORT)
fun testAdministratorControlsFragment_downloadPermissionsAndSettings_autoUpdateIsNotDisplayed() {
TestPlatformParameterModule.forceEnableDownloadsSupport(false)
launch<AdministratorControlsFragmentTestActivity>(
createAdministratorControlsFragmentTestActivityIntent(
profileId = internalProfileId
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -173,9 +178,6 @@ class ProfileAndDeviceIdFragmentTest {

@Before
fun setUp() {
TestPlatformParameterModule.forceEnableEditAccountsOptionsUi(true)
TestPlatformParameterModule.forceEnableLearnerStudyAnalytics(true)
TestPlatformParameterModule.forceEnableLoggingLearnerStudyIds(true)
setUpTestApplicationComponent()
Intents.init()
testCoroutineDispatchers.registerIdlingResource()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading
Loading