From ea51fbce2dfdffc88aff229411b2601a9ed0eb16 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 15 Aug 2024 21:12:48 +0000 Subject: [PATCH] Fix broken Gradle tests. --- app/build.gradle | 3 ++- .../options/ReadingTextSizeFragmentTest.kt | 4 ++++ .../ProfileManagementControllerTest.kt | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 13fae2de07a..7c94678f75c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -107,7 +107,8 @@ def filesToExclude = [ '**/*AppLanguageLocaleHandlerTest*.kt', '**/*AppLanguageResourceHandlerTest*.kt', '**/*AppLanguageWatcherMixinTest*.kt', - '**/*ActivityLanguageLocaleHandlerTest*.kt' + '**/*ActivityLanguageLocaleHandlerTest*.kt', + '**/*OptionsFragmentTest*.kt', // Excludes 2 tests. ] _excludeSourceFiles(filesToExclude) diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt index 75e9b20db35..5e4b14be4aa 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt @@ -74,7 +74,9 @@ 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.OppiaTestRule +import org.oppia.android.testing.RunOn import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule @@ -180,8 +182,10 @@ class ReadingTextSizeFragmentTest { } } + // Requires language configurations. @Test @Config(qualifiers = "sw600dp") + @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testTextSize_changeTextSizeToMedium_mediumItemIsSelected() { launch(createOptionActivityIntent(0, true)).use { testCoroutineDispatchers.runCurrent() diff --git a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt index ab3e4011330..91d58907646 100644 --- a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt @@ -17,6 +17,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import org.junit.After +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.AudioLanguage.ARABIC_LANGUAGE @@ -34,7 +35,10 @@ import org.oppia.android.domain.oppialogger.ApplicationIdSeed import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.LoggingIdentifierController import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule +import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.OppiaTestRule +import org.oppia.android.testing.RunOn import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat @@ -77,6 +81,7 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = ProfileManagementControllerTest.TestApplication::class) class ProfileManagementControllerTest { + @get:Rule val oppiaTestRule = OppiaTestRule() @Inject lateinit var context: Context @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var profileManagementController: ProfileManagementController @@ -716,7 +721,9 @@ class ProfileManagementControllerTest { assertThat(profile.readingTextSize).isEqualTo(MEDIUM_TEXT_SIZE) } + // Requires language configurations. @Test + @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testGetAudioLanguage_initialProfileCreation_defaultsToEnglish() { setUpTestApplicationComponent() @@ -779,7 +786,9 @@ class ProfileManagementControllerTest { monitor.ensureNextResultIsSuccess() } + // Requires language configurations. @Test + @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToHindi_updateChangesAudioLanguage() { setUpTestApplicationComponent() addTestProfiles() @@ -793,7 +802,9 @@ class ProfileManagementControllerTest { assertThat(audioLanguage).isEqualTo(HINDI_AUDIO_LANGUAGE) } + // Requires language configurations. @Test + @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToBrazilianPortuguese_updateChangesAudioLanguage() { setUpTestApplicationComponent() addTestProfiles() @@ -807,7 +818,9 @@ class ProfileManagementControllerTest { assertThat(audioLanguage).isEqualTo(BRAZILIAN_PORTUGUESE_LANGUAGE) } + // Requires language configurations. @Test + @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToArabic_updateChangesAudioLanguage() { setUpTestApplicationComponent() addTestProfiles() @@ -821,7 +834,9 @@ class ProfileManagementControllerTest { assertThat(audioLanguage).isEqualTo(ARABIC_LANGUAGE) } + // Requires language configurations. @Test + @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToNigerianPidgin_updateChangesAudioLanguage() { setUpTestApplicationComponent() addTestProfiles() @@ -835,7 +850,9 @@ class ProfileManagementControllerTest { assertThat(audioLanguage).isEqualTo(NIGERIAN_PIDGIN_LANGUAGE) } + // Requires language configurations. @Test + @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateToArabicThenEnglish_updateChangesAudioLanguageToEnglish() { setUpTestApplicationComponent() addTestProfiles() @@ -852,7 +869,9 @@ class ProfileManagementControllerTest { assertThat(audioLanguage).isEqualTo(ENGLISH_AUDIO_LANGUAGE) } + // Requires language configurations. @Test + @RunOn(buildEnvironments = [BuildEnvironment.BAZEL]) fun testUpdateAudioLanguage_updateProfile1ToArabic_profile2IsUnchanged() { setUpTestApplicationComponent() addTestProfiles()