From d452b0513d2082360cf7b4592f71847299d67d6e Mon Sep 17 00:00:00 2001 From: Rd Date: Mon, 4 Nov 2024 18:43:55 +0530 Subject: [PATCH] Fix ktlint issues --- .../AdministratorControlsFragmentTest.kt | 4 +- .../ProfileAndDeviceIdFragmentTest.kt | 6 +-- .../app/player/state/StateFragmentTest.kt | 4 +- .../app/spotlight/SpotlightFragmentTest.kt | 11 ++--- .../PlatformParameterModule.kt | 6 +-- .../oppia/android/testing/OppiaTestRule.kt | 41 ++++++++++++++----- .../TestPlatformParameterModule.kt | 2 +- 7 files changed, 44 insertions(+), 30 deletions(-) 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 db53b32f757..da4d066bfa2 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,9 +82,11 @@ 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.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -113,8 +115,6 @@ import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject import javax.inject.Singleton -import org.oppia.android.domain.platformparameter.PlatformParameterModule -import org.oppia.android.testing.DisableFeatureFlag @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) 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 8a17e0838dd..8fa840a53c3 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 @@ -141,8 +142,6 @@ import java.util.concurrent.TimeUnit import java.util.zip.GZIPInputStream import javax.inject.Inject import javax.inject.Singleton -import org.oppia.android.domain.platformparameter.PlatformParameterModule -import org.oppia.android.testing.EnableFeatureFlag /** Tests for [ProfileAndDeviceIdFragment]. */ // Same parameter value: helpers reduce test context, even if they are used by 1 test. @@ -536,7 +535,6 @@ class ProfileAndDeviceIdFragmentTest { } } - @Test fun testFragment_secondEntry_noLearnerEvents_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) 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 04c1f767ef7..6223ae992dc 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 @@ -195,8 +197,6 @@ import java.io.IOException import java.util.concurrent.TimeoutException import javax.inject.Inject import javax.inject.Singleton -import org.oppia.android.domain.platformparameter.PlatformParameterModule -import org.oppia.android.testing.OverrideBoolParameter /** Tests for [StateFragment]. */ @RunWith(AndroidJUnit4::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 44919dceba9..539ee6b5f35 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,9 +69,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.EnableFeatureFlag +import org.oppia.android.testing.OppiaTestRule +import org.oppia.android.testing.ResetFeatureFlagToDefault import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule @@ -99,13 +103,6 @@ import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject import javax.inject.Singleton -import org.oppia.android.domain.platformparameter.PlatformParameterModule -import org.oppia.android.testing.DisableFeatureFlag -import org.oppia.android.testing.EnableFeatureFlag -import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.ResetFeatureFlagToDefault -import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestPlatform /** Tests for [SpotlightFragment]. */ @RunWith(AndroidJUnit4::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 01552be4ca0..589c08308a2 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 @@ -89,7 +89,7 @@ class PlatformParameterModule { return overriddenParameters[DOWNLOADS_SUPPORT]?.let { PlatformParameterValue.createDefaultParameter(it as Boolean) } ?: platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) - ?: PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) } @Provides @@ -225,7 +225,7 @@ class PlatformParameterModule { return overriddenParameters[SPOTLIGHT_UI]?.let { PlatformParameterValue.createDefaultParameter(it as Boolean) } ?: platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) - ?: PlatformParameterValue.createDefaultParameter(ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE) } @Provides @@ -358,7 +358,7 @@ class PlatformParameterModule { ) } - companion object{ + companion object { private val overriddenParameters = mutableMapOf() 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 7a24f349716..f7ad5806072 100644 --- a/testing/src/main/java/org/oppia/android/testing/OppiaTestRule.kt +++ b/testing/src/main/java/org/oppia/android/testing/OppiaTestRule.kt @@ -30,30 +30,49 @@ class OppiaTestRule : TestRule { val currentEnvironment = getCurrentBuildEnvironment() val enabledFeatureFlags = extractParametersAndFeatureFlags( - description?.testClass?.annotations?.toList(), EnableFeatureFlag::class.java) + + description?.testClass?.annotations?.toList(), EnableFeatureFlag::class.java + ) + extractParametersAndFeatureFlags(description?.annotations, EnableFeatureFlag::class.java) val disabledFeatureFlags = extractParametersAndFeatureFlags( - description?.testClass?.annotations?.toList(), DisableFeatureFlag::class.java) + + 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) + 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) + 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) + description?.testClass?.annotations?.toList(), + OverrideStringParameter::class.java + ) + + extractParametersAndFeatureFlags( + description?.annotations, + OverrideStringParameter::class.java + ) val resetFeatureFlagToDefault = extractParametersAndFeatureFlags( - description?.annotations, ResetFeatureFlagToDefault::class.java) + description?.annotations, ResetFeatureFlagToDefault::class.java + ) val resetParameterToDefault = extractParametersAndFeatureFlags( - description?.annotations, ResetParameterToDefault::class.java) + description?.annotations, ResetParameterToDefault::class.java + ) try { applyOverrides( @@ -101,7 +120,7 @@ class OppiaTestRule : TestRule { else -> throw AssertionError("Reached impossible state in test rule") } } finally { - PlatformParameterModule.clearAllParameterOverrides() + PlatformParameterModule.clearAllParameterOverrides() } } } diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index ea2e4065d72..59994eea381 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -20,6 +20,7 @@ import org.oppia.android.util.platformparameter.ENABLE_MULTIPLE_CLASSROOMS_DEFAU import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.EnableDownloadsSupport import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi @@ -65,7 +66,6 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours import javax.inject.Singleton -import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE /* Fake Platform Parameter Module that provides individual Platform Parameters for testing. */ @Module