From aa3c3f015bbb2daedf349548d559da63cbebf7f0 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Tue, 11 Jul 2023 13:35:55 +0200 Subject: [PATCH 1/2] Use Theme_MaterialComponents style in FragmentScenarioLauncherRule by default --- .../odk/collect/androidshared/ui/ColorPickerDialogTest.kt | 3 +-- .../android/audio/AudioRecordingControllerFragmentTest.java | 2 +- .../audio/AudioRecordingFormErrorDialogFragmentTest.java | 4 +--- .../android/audio/BackgroundAudioHelpDialogFragmentTest.java | 4 +--- .../org/odk/collect/android/draw/PenColorPickerDialogTest.kt | 2 +- .../BackgroundAudioPermissionDialogFragmentTest.java | 1 - .../android/formentry/FormLoadingDialogFragmentTest.java | 4 +--- .../android/formentry/RefreshFormListDialogFragmentTest.java | 4 +--- .../formentry/SaveFormProgressDialogFragmentTest.java | 1 - .../collect/android/formlists/DeleteBlankFormFragmentTest.kt | 3 +-- .../fragments/dialogs/FormsDownloadResultDialogTest.kt | 3 +-- .../android/mainmenu/PermissionsDialogFragmentTest.kt | 5 +---- .../preferences/dialogs/AdminPasswordDialogFragmentTest.kt | 4 +--- .../preferences/dialogs/ChangeAdminPasswordDialogTest.kt | 4 +--- .../android/preferences/dialogs/ResetProgressDialogTest.kt | 3 +-- .../preferences/dialogs/ServerAuthDialogFragmentTest.java | 4 +--- .../screens/ProjectDisplayPreferencesFragmentTest.kt | 3 +-- .../android/projects/ManualProjectCreatorDialogTest.kt | 3 +-- .../collect/android/projects/ProjectSettingsDialogTest.kt | 2 -- .../android/projects/QrCodeProjectCreatorDialogTest.kt | 3 +-- .../widgets/items/SelectOneFromMapDialogFragmentTest.kt | 1 - fragmentstest/build.gradle | 1 + .../collect/fragmentstest/FragmentScenarioLauncherRule.kt | 4 ++-- .../odk/collect/geo/geopoint/GeoPointDialogFragmentTest.kt | 3 +-- .../odk/collect/geo/selection/SelectionMapFragmentTest.kt | 1 - .../odk/collect/material/MaterialAlertDialogFragmentTest.kt | 3 +-- .../collect/material/MaterialProgressDialogFragmentTest.java | 4 +--- 27 files changed, 23 insertions(+), 56 deletions(-) diff --git a/androidshared/src/test/java/org/odk/collect/androidshared/ui/ColorPickerDialogTest.kt b/androidshared/src/test/java/org/odk/collect/androidshared/ui/ColorPickerDialogTest.kt index b1375f4907c..45faf29ef9a 100644 --- a/androidshared/src/test/java/org/odk/collect/androidshared/ui/ColorPickerDialogTest.kt +++ b/androidshared/src/test/java/org/odk/collect/androidshared/ui/ColorPickerDialogTest.kt @@ -29,8 +29,7 @@ class ColorPickerDialogTest { } @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Test fun `The dialog should be dismissed after clicking on a device back button`() { diff --git a/collect_app/src/test/java/org/odk/collect/android/audio/AudioRecordingControllerFragmentTest.java b/collect_app/src/test/java/org/odk/collect/android/audio/AudioRecordingControllerFragmentTest.java index 1dc5c6d79e0..0a415a32ea7 100644 --- a/collect_app/src/test/java/org/odk/collect/android/audio/AudioRecordingControllerFragmentTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/audio/AudioRecordingControllerFragmentTest.java @@ -65,7 +65,7 @@ public T create(@NonNull Class modelClass, @NonNull Cre }; @Rule - public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule(com.google.android.material.R.style.Theme_MaterialComponents, new FragmentFactoryBuilder() + public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule(new FragmentFactoryBuilder() .forClass(AudioRecordingControllerFragment.class, () -> new AudioRecordingControllerFragment(viewModelFactory)) .build()); diff --git a/collect_app/src/test/java/org/odk/collect/android/audio/AudioRecordingFormErrorDialogFragmentTest.java b/collect_app/src/test/java/org/odk/collect/android/audio/AudioRecordingFormErrorDialogFragmentTest.java index e99ae36483c..69a3a3e2b2f 100644 --- a/collect_app/src/test/java/org/odk/collect/android/audio/AudioRecordingFormErrorDialogFragmentTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/audio/AudioRecordingFormErrorDialogFragmentTest.java @@ -31,9 +31,7 @@ public class AudioRecordingFormErrorDialogFragmentTest { private StubAudioRecorder audioRecorder; @Rule - public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents - ); + public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule(); @Before public void setup() throws Exception { diff --git a/collect_app/src/test/java/org/odk/collect/android/audio/BackgroundAudioHelpDialogFragmentTest.java b/collect_app/src/test/java/org/odk/collect/android/audio/BackgroundAudioHelpDialogFragmentTest.java index fca4d48a16e..3f5b758618d 100644 --- a/collect_app/src/test/java/org/odk/collect/android/audio/BackgroundAudioHelpDialogFragmentTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/audio/BackgroundAudioHelpDialogFragmentTest.java @@ -19,9 +19,7 @@ public class BackgroundAudioHelpDialogFragmentTest { @Rule - public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents - ); + public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule(); @Test public void hasOkButton() { diff --git a/collect_app/src/test/java/org/odk/collect/android/draw/PenColorPickerDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/draw/PenColorPickerDialogTest.kt index c18aa7f5760..c802c3b05e1 100644 --- a/collect_app/src/test/java/org/odk/collect/android/draw/PenColorPickerDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/draw/PenColorPickerDialogTest.kt @@ -28,7 +28,7 @@ import org.odk.collect.shared.settings.Settings class PenColorPickerDialogTest { @get:Rule - val launcherRule = FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Test fun `dialog should be cancelable`() { diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/BackgroundAudioPermissionDialogFragmentTest.java b/collect_app/src/test/java/org/odk/collect/android/formentry/BackgroundAudioPermissionDialogFragmentTest.java index d8b403ab2ec..986158c1ac0 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formentry/BackgroundAudioPermissionDialogFragmentTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/BackgroundAudioPermissionDialogFragmentTest.java @@ -47,7 +47,6 @@ public T create(@NonNull Class modelClass, @NonNull Cre @Rule public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents, new FragmentFactoryBuilder() .forClass(BackgroundAudioPermissionDialogFragment.class, () -> new BackgroundAudioPermissionDialogFragment(viewModelFactory)) .build() diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/FormLoadingDialogFragmentTest.java b/collect_app/src/test/java/org/odk/collect/android/formentry/FormLoadingDialogFragmentTest.java index 167af67f502..396ed43b864 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formentry/FormLoadingDialogFragmentTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/FormLoadingDialogFragmentTest.java @@ -15,9 +15,7 @@ public class FormLoadingDialogFragmentTest { @Rule - public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents - ); + public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule(); @Test public void dialogIsNotCancellable() { diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/RefreshFormListDialogFragmentTest.java b/collect_app/src/test/java/org/odk/collect/android/formentry/RefreshFormListDialogFragmentTest.java index e81e4fe68f9..4c74b55d6f4 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formentry/RefreshFormListDialogFragmentTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/RefreshFormListDialogFragmentTest.java @@ -21,9 +21,7 @@ public class RefreshFormListDialogFragmentTest { @Rule - public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents - ); + public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule(); @Test public void dialogIsNotCancellable() { diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/SaveFormProgressDialogFragmentTest.java b/collect_app/src/test/java/org/odk/collect/android/formentry/SaveFormProgressDialogFragmentTest.java index 6fc51b409c6..4a6eedf6c6c 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formentry/SaveFormProgressDialogFragmentTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/SaveFormProgressDialogFragmentTest.java @@ -36,7 +36,6 @@ public T create(@NonNull Class modelClass, @NonNull Cre @Rule public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents, new FragmentFactoryBuilder() .forClass(SaveFormProgressDialogFragment.class, () -> new SaveFormProgressDialogFragment(viewModelFactory)) .build() diff --git a/collect_app/src/test/java/org/odk/collect/android/formlists/DeleteBlankFormFragmentTest.kt b/collect_app/src/test/java/org/odk/collect/android/formlists/DeleteBlankFormFragmentTest.kt index 89e86061079..326df92088b 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formlists/DeleteBlankFormFragmentTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formlists/DeleteBlankFormFragmentTest.kt @@ -73,8 +73,7 @@ class DeleteBlankFormFragmentTest { @get:Rule val fragmentScenarioLauncherRule = FragmentScenarioLauncherRule( - defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents, - defaultFactory = FragmentFactoryBuilder() + FragmentFactoryBuilder() .forClass(DeleteBlankFormFragment::class) { DeleteBlankFormFragment(viewModelFactory, menuHost) }.build() diff --git a/collect_app/src/test/java/org/odk/collect/android/fragments/dialogs/FormsDownloadResultDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/fragments/dialogs/FormsDownloadResultDialogTest.kt index 6fa0fb51b42..d04fd4fe855 100644 --- a/collect_app/src/test/java/org/odk/collect/android/fragments/dialogs/FormsDownloadResultDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/fragments/dialogs/FormsDownloadResultDialogTest.kt @@ -32,8 +32,7 @@ class FormsDownloadResultDialogTest { val listener = mock() @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Test fun `The dialog should be dismissed after clicking out of it's area or on device back button`() { diff --git a/collect_app/src/test/java/org/odk/collect/android/mainmenu/PermissionsDialogFragmentTest.kt b/collect_app/src/test/java/org/odk/collect/android/mainmenu/PermissionsDialogFragmentTest.kt index f7794678f5b..db7b3043ab9 100644 --- a/collect_app/src/test/java/org/odk/collect/android/mainmenu/PermissionsDialogFragmentTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/mainmenu/PermissionsDialogFragmentTest.kt @@ -36,10 +36,7 @@ class PermissionsDialogFragmentTest { .build() @get:Rule - val launcherRule = FragmentScenarioLauncherRule( - defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents, - defaultFactory = fragmentFactory - ) + val launcherRule = FragmentScenarioLauncherRule(fragmentFactory) @Test fun clickingOK_asksForPermissions() { diff --git a/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/AdminPasswordDialogFragmentTest.kt b/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/AdminPasswordDialogFragmentTest.kt index d199084f89d..4eadcb877cc 100644 --- a/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/AdminPasswordDialogFragmentTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/AdminPasswordDialogFragmentTest.kt @@ -18,7 +18,6 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.verifyNoMoreInteractions import org.mockito.kotlin.whenever -import org.odk.collect.android.R import org.odk.collect.android.injection.config.AppDependencyModule import org.odk.collect.android.preferences.ProjectPreferencesViewModel import org.odk.collect.android.support.CollectHelpers @@ -38,8 +37,7 @@ class AdminPasswordDialogFragmentTest { lateinit var factory: ProjectPreferencesViewModel.Factory @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Before fun setup() { diff --git a/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ChangeAdminPasswordDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ChangeAdminPasswordDialogTest.kt index 3aaf90a39de..1b2d96c3568 100644 --- a/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ChangeAdminPasswordDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ChangeAdminPasswordDialogTest.kt @@ -18,7 +18,6 @@ import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.verifyNoMoreInteractions -import org.odk.collect.android.R import org.odk.collect.android.injection.config.AppDependencyModule import org.odk.collect.android.preferences.ProjectPreferencesViewModel import org.odk.collect.android.support.CollectHelpers @@ -40,8 +39,7 @@ class ChangeAdminPasswordDialogTest { lateinit var factory: ProjectPreferencesViewModel.Factory @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Before fun setup() { diff --git a/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ResetProgressDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ResetProgressDialogTest.kt index 64a5623b88a..98048c160a5 100644 --- a/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ResetProgressDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ResetProgressDialogTest.kt @@ -18,8 +18,7 @@ class ResetProgressDialogTest { private val context = ApplicationProvider.getApplicationContext() @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Test fun `The dialog should not be dismissed after clicking out of its area or on device back button`() { diff --git a/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ServerAuthDialogFragmentTest.java b/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ServerAuthDialogFragmentTest.java index 0e8777f7e9f..83ceddbd74a 100644 --- a/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ServerAuthDialogFragmentTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/preferences/dialogs/ServerAuthDialogFragmentTest.java @@ -25,9 +25,7 @@ public class ServerAuthDialogFragmentTest { private final Settings generalSettings = TestSettingsProvider.getUnprotectedSettings(); @Rule - public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents - ); + public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule(); @Test public void prefillsUsernameAndPassword() { diff --git a/collect_app/src/test/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragmentTest.kt b/collect_app/src/test/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragmentTest.kt index 6b023e0d048..1aa7e6bdd35 100644 --- a/collect_app/src/test/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragmentTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/preferences/screens/ProjectDisplayPreferencesFragmentTest.kt @@ -32,8 +32,7 @@ class ProjectDisplayPreferencesFragmentTest { lateinit var projectsRepository: ProjectsRepository @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Before fun setup() { diff --git a/collect_app/src/test/java/org/odk/collect/android/projects/ManualProjectCreatorDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/projects/ManualProjectCreatorDialogTest.kt index 562743e87f1..505c9ff78f6 100644 --- a/collect_app/src/test/java/org/odk/collect/android/projects/ManualProjectCreatorDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/projects/ManualProjectCreatorDialogTest.kt @@ -37,8 +37,7 @@ import org.robolectric.shadows.ShadowToast class ManualProjectCreatorDialogTest { @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Test fun `Password should be protected`() { diff --git a/collect_app/src/test/java/org/odk/collect/android/projects/ProjectSettingsDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/projects/ProjectSettingsDialogTest.kt index 059b4eeb165..27146a756e2 100644 --- a/collect_app/src/test/java/org/odk/collect/android/projects/ProjectSettingsDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/projects/ProjectSettingsDialogTest.kt @@ -21,7 +21,6 @@ import org.junit.runner.RunWith import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock import org.mockito.kotlin.verify -import org.odk.collect.android.R import org.odk.collect.android.activities.AboutActivity import org.odk.collect.android.injection.config.AppDependencyModule import org.odk.collect.android.mainmenu.CurrentProjectViewModel @@ -61,7 +60,6 @@ class ProjectSettingsDialogTest { @get:Rule val launcherRule = FragmentScenarioLauncherRule( - defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents, defaultFactory = FragmentFactoryBuilder() .forClass(ProjectSettingsDialog::class) { ProjectSettingsDialog(viewModelFactory) } .build() diff --git a/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt index ab2637aa3a3..94cf39d585b 100644 --- a/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt @@ -48,8 +48,7 @@ class QrCodeProjectCreatorDialogTest { private val permissionsProvider = FakePermissionsProvider() @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Before fun setup() { diff --git a/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragmentTest.kt b/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragmentTest.kt index 7120cd19630..9727429d3ba 100644 --- a/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragmentTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/widgets/items/SelectOneFromMapDialogFragmentTest.kt @@ -91,7 +91,6 @@ class SelectOneFromMapDialogFragmentTest { @get:Rule val launcherRule = FragmentScenarioLauncherRule( - defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents, FragmentFactoryBuilder() .forClass(SelectOneFromMapDialogFragment::class.java) { SelectOneFromMapDialogFragment(viewModelFactory) diff --git a/fragmentstest/build.gradle b/fragmentstest/build.gradle index de67b6e66e6..016fee8411a 100644 --- a/fragmentstest/build.gradle +++ b/fragmentstest/build.gradle @@ -35,6 +35,7 @@ android { dependencies { implementation Dependencies.kotlin_stdlib implementation Dependencies.androidx_test_espresso_core + implementation Dependencies.android_material //noinspection FragmentGradleConfiguration debugApi(Dependencies.androidx_fragment_testing) { diff --git a/fragmentstest/src/main/java/org/odk/collect/fragmentstest/FragmentScenarioLauncherRule.kt b/fragmentstest/src/main/java/org/odk/collect/fragmentstest/FragmentScenarioLauncherRule.kt index a978c90516b..6e6134e0b0c 100644 --- a/fragmentstest/src/main/java/org/odk/collect/fragmentstest/FragmentScenarioLauncherRule.kt +++ b/fragmentstest/src/main/java/org/odk/collect/fragmentstest/FragmentScenarioLauncherRule.kt @@ -14,8 +14,8 @@ import org.junit.rules.ExternalResource * scenarios in a test. */ class FragmentScenarioLauncherRule @JvmOverloads constructor( - @StyleRes private val defaultThemeResId: Int? = null, - private val defaultFactory: FragmentFactory? = null + private val defaultFactory: FragmentFactory? = null, + @StyleRes private val defaultThemeResId: Int = com.google.android.material.R.style.Theme_MaterialComponents ) : ExternalResource() { private val scenarios = mutableListOf>() diff --git a/geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointDialogFragmentTest.kt b/geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointDialogFragmentTest.kt index 803d99e6a20..f54d865fcbd 100644 --- a/geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointDialogFragmentTest.kt +++ b/geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointDialogFragmentTest.kt @@ -49,8 +49,7 @@ class GeoPointDialogFragmentTest { } @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Before fun setup() { diff --git a/geo/src/test/java/org/odk/collect/geo/selection/SelectionMapFragmentTest.kt b/geo/src/test/java/org/odk/collect/geo/selection/SelectionMapFragmentTest.kt index 9337282484a..aeb7378f195 100644 --- a/geo/src/test/java/org/odk/collect/geo/selection/SelectionMapFragmentTest.kt +++ b/geo/src/test/java/org/odk/collect/geo/selection/SelectionMapFragmentTest.kt @@ -70,7 +70,6 @@ class SelectionMapFragmentTest { @get:Rule val launcherRule = FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents, object : FragmentFactory() { override fun instantiate(classLoader: ClassLoader, className: String): Fragment { return SelectionMapFragment(data, onBackPressedDispatcher = { onBackPressedDispatcher }) diff --git a/material/src/test/java/org/odk/collect/material/MaterialAlertDialogFragmentTest.kt b/material/src/test/java/org/odk/collect/material/MaterialAlertDialogFragmentTest.kt index 73491ea0421..a07b10b3984 100644 --- a/material/src/test/java/org/odk/collect/material/MaterialAlertDialogFragmentTest.kt +++ b/material/src/test/java/org/odk/collect/material/MaterialAlertDialogFragmentTest.kt @@ -24,8 +24,7 @@ class MaterialAlertDialogFragmentTest { } @get:Rule - val launcherRule = - FragmentScenarioLauncherRule(defaultThemeResId = com.google.android.material.R.style.Theme_MaterialComponents) + val launcherRule = FragmentScenarioLauncherRule() @Test fun `dialog should be cancelable`() { diff --git a/material/src/test/java/org/odk/collect/material/MaterialProgressDialogFragmentTest.java b/material/src/test/java/org/odk/collect/material/MaterialProgressDialogFragmentTest.java index 378bef1fb3c..255a5b53ba4 100644 --- a/material/src/test/java/org/odk/collect/material/MaterialProgressDialogFragmentTest.java +++ b/material/src/test/java/org/odk/collect/material/MaterialProgressDialogFragmentTest.java @@ -25,9 +25,7 @@ public class MaterialProgressDialogFragmentTest { @Rule - public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule( - com.google.android.material.R.style.Theme_MaterialComponents - ); + public FragmentScenarioLauncherRule launcherRule = new FragmentScenarioLauncherRule(); @Test public void setTitle_updatesTitle() { From 60e59d6522cddaf367dfc78f51bdaf36f78ad45e Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Tue, 11 Jul 2023 13:52:50 +0200 Subject: [PATCH 2/2] Use Theme_MaterialComponents style in RobolectricHelpers.createThemedActivity by default --- .../java/org/odk/collect/android/audio/AudioButtonTest.java | 2 +- .../android/formentry/FormEntryMenuDelegateTest.java | 2 +- .../org/odk/collect/android/support/CollectHelpers.java | 2 +- .../android/widgets/utilities/DateTimeWidgetUtilsTest.java | 2 +- .../geo/geopoly/GeoPolySettingsDialogFragmentTest.java | 2 +- .../odk/collect/permissions/PermissionsDialogCreatorTest.kt | 2 +- .../java/org/odk/collect/testshared/RobolectricHelpers.kt | 6 +++++- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/collect_app/src/test/java/org/odk/collect/android/audio/AudioButtonTest.java b/collect_app/src/test/java/org/odk/collect/android/audio/AudioButtonTest.java index 94748e81559..7d508d0677f 100644 --- a/collect_app/src/test/java/org/odk/collect/android/audio/AudioButtonTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/audio/AudioButtonTest.java @@ -22,7 +22,7 @@ public class AudioButtonTest { @Before public void setup() { - Activity activity = RobolectricHelpers.createThemedActivity(FragmentActivity.class, com.google.android.material.R.style.Theme_MaterialComponents); + Activity activity = RobolectricHelpers.createThemedActivity(FragmentActivity.class); button = new AudioButton(activity); } diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/FormEntryMenuDelegateTest.java b/collect_app/src/test/java/org/odk/collect/android/formentry/FormEntryMenuDelegateTest.java index ee299523abb..f8cb19d608b 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formentry/FormEntryMenuDelegateTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/FormEntryMenuDelegateTest.java @@ -52,7 +52,7 @@ public class FormEntryMenuDelegateTest { @Before public void setup() { - activity = RobolectricHelpers.createThemedActivity(AppCompatActivity.class, com.google.android.material.R.style.Theme_MaterialComponents); + activity = RobolectricHelpers.createThemedActivity(AppCompatActivity.class); FormController formController = mock(FormController.class); answersProvider = mock(AnswersProvider.class); diff --git a/collect_app/src/test/java/org/odk/collect/android/support/CollectHelpers.java b/collect_app/src/test/java/org/odk/collect/android/support/CollectHelpers.java index e994aaba459..d7419315ab3 100644 --- a/collect_app/src/test/java/org/odk/collect/android/support/CollectHelpers.java +++ b/collect_app/src/test/java/org/odk/collect/android/support/CollectHelpers.java @@ -68,7 +68,7 @@ public static AppDependencyComponent overrideAppDependencyModule(AppDependencyMo } public static T createThemedActivity(Class clazz) { - return RobolectricHelpers.createThemedActivity(clazz, com.google.android.material.R.style.Theme_MaterialComponents); + return RobolectricHelpers.createThemedActivity(clazz); } public static FragmentActivity createThemedActivity() { diff --git a/collect_app/src/test/java/org/odk/collect/android/widgets/utilities/DateTimeWidgetUtilsTest.java b/collect_app/src/test/java/org/odk/collect/android/widgets/utilities/DateTimeWidgetUtilsTest.java index fdfcad3b775..64172265ef0 100644 --- a/collect_app/src/test/java/org/odk/collect/android/widgets/utilities/DateTimeWidgetUtilsTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/widgets/utilities/DateTimeWidgetUtilsTest.java @@ -76,7 +76,7 @@ public class DateTimeWidgetUtilsTest { public void setUp() { dateTimeWidgetUtils = new DateTimeWidgetUtils(); - activity = RobolectricHelpers.createThemedActivity(WidgetTestActivity.class, com.google.android.material.R.style.Theme_MaterialComponents); + activity = RobolectricHelpers.createThemedActivity(WidgetTestActivity.class); datePickerDetails = mock(DatePickerDetails.class); when(datePickerDetails.getDatePickerType()).thenReturn(GREGORIAN); diff --git a/geo/src/test/java/org/odk/collect/geo/geopoly/GeoPolySettingsDialogFragmentTest.java b/geo/src/test/java/org/odk/collect/geo/geopoly/GeoPolySettingsDialogFragmentTest.java index da95452b0d7..5c40bd3897f 100644 --- a/geo/src/test/java/org/odk/collect/geo/geopoly/GeoPolySettingsDialogFragmentTest.java +++ b/geo/src/test/java/org/odk/collect/geo/geopoly/GeoPolySettingsDialogFragmentTest.java @@ -39,7 +39,7 @@ public class GeoPolySettingsDialogFragmentTest { @Before public void setup() { - FragmentActivity activity = RobolectricHelpers.createThemedActivity(FragmentActivity.class, com.google.android.material.R.style.Theme_MaterialComponents); + FragmentActivity activity = RobolectricHelpers.createThemedActivity(FragmentActivity.class); fragmentManager = activity.getSupportFragmentManager(); dialogFragment = new GeoPolySettingsDialogFragment(); diff --git a/permissions/src/test/java/org/odk/collect/permissions/PermissionsDialogCreatorTest.kt b/permissions/src/test/java/org/odk/collect/permissions/PermissionsDialogCreatorTest.kt index 31267746aa8..5f7a5644a48 100644 --- a/permissions/src/test/java/org/odk/collect/permissions/PermissionsDialogCreatorTest.kt +++ b/permissions/src/test/java/org/odk/collect/permissions/PermissionsDialogCreatorTest.kt @@ -32,7 +32,7 @@ class PermissionsDialogCreatorTest { @Before fun setup() { - activity = createThemedActivity(FragmentActivity::class.java, com.google.android.material.R.style.Theme_MaterialComponents) + activity = createThemedActivity(FragmentActivity::class.java) } @Test diff --git a/testshared/src/main/java/org/odk/collect/testshared/RobolectricHelpers.kt b/testshared/src/main/java/org/odk/collect/testshared/RobolectricHelpers.kt index ed4a0e6db97..1368e4bbc6f 100644 --- a/testshared/src/main/java/org/odk/collect/testshared/RobolectricHelpers.kt +++ b/testshared/src/main/java/org/odk/collect/testshared/RobolectricHelpers.kt @@ -28,7 +28,11 @@ object RobolectricHelpers { var services: MutableMap, ServiceScenario<*>> = HashMap() @JvmStatic - fun createThemedActivity(clazz: Class, theme: Int): T { + @JvmOverloads + fun createThemedActivity( + clazz: Class, + theme: Int = com.google.android.material.R.style.Theme_MaterialComponents + ): T { val activity = Robolectric.buildActivity(clazz) activity.get()!!.setTheme(theme) return activity.setup().get()