Skip to content

Commit

Permalink
Fix ktlint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Rd4dev committed Nov 4, 2024
1 parent 1195cc1 commit d452b05
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
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 Down Expand Up @@ -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.
Expand Down Expand Up @@ -536,7 +535,6 @@ class ProfileAndDeviceIdFragmentTest {
}
}


@Test
fun testFragment_secondEntry_noLearnerEvents_hasZeroLearnerEventsReported() {
profileTestHelper.addMoreProfiles(numProfiles = 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -358,7 +358,7 @@ class PlatformParameterModule {
)
}

companion object{
companion object {

private val overriddenParameters = mutableMapOf<String, Any>()

Expand Down
41 changes: 30 additions & 11 deletions testing/src/main/java/org/oppia/android/testing/OppiaTestRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -101,7 +120,7 @@ class OppiaTestRule : TestRule {
else -> throw AssertionError("Reached impossible state in test rule")
}
} finally {
PlatformParameterModule.clearAllParameterOverrides()
PlatformParameterModule.clearAllParameterOverrides()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d452b05

Please sign in to comment.