From ba96f8b02a8655656b2cd92f219bf14e1bf2c457 Mon Sep 17 00:00:00 2001 From: Faltenreich Date: Fri, 29 Nov 2024 15:55:54 +0100 Subject: [PATCH] Fix tests --- .../{navigation => shared}/system/AndroidSystemSettings.kt | 2 +- .../{navigation => shared}/system/SystemSettingsModule.kt | 2 +- .../kotlin/com/faltenreich/diaguard/AppModules.kt | 2 ++ .../com/faltenreich/diaguard/navigation/NavigationModule.kt | 3 --- .../navigation/system/OpenNotificationSettingsUseCase.kt | 2 ++ .../preference/overview/GetOverviewPreferencesUseCase.kt | 2 +- .../{navigation => shared}/system/SystemSettings.kt | 2 +- .../{navigation => shared}/system/SystemSettingsModule.kt | 2 +- .../kotlin/com/faltenreich/diaguard/TestModules.kt | 6 +++++- .../preference/overview/OverviewPreferenceViewModelTest.kt | 1 + .../faltenreich/diaguard/shared/config/FakeBuildConfig.kt | 2 ++ .../diaguard/shared/system/FakeSystemSettings.kt | 6 ++++++ .../{navigation => shared}/system/SystemSettingsModule.kt | 2 +- 13 files changed, 24 insertions(+), 10 deletions(-) rename shared/src/androidMain/kotlin/com/faltenreich/diaguard/{navigation => shared}/system/AndroidSystemSettings.kt (90%) rename shared/src/androidMain/kotlin/com/faltenreich/diaguard/{navigation => shared}/system/SystemSettingsModule.kt (79%) rename shared/src/commonMain/kotlin/com/faltenreich/diaguard/{navigation => shared}/system/SystemSettings.kt (56%) rename shared/src/commonMain/kotlin/com/faltenreich/diaguard/{navigation => shared}/system/SystemSettingsModule.kt (60%) create mode 100644 shared/src/commonTest/kotlin/com/faltenreich/diaguard/shared/system/FakeSystemSettings.kt rename shared/src/iosMain/kotlin/com/faltenreich/diaguard/{navigation => shared}/system/SystemSettingsModule.kt (72%) diff --git a/shared/src/androidMain/kotlin/com/faltenreich/diaguard/navigation/system/AndroidSystemSettings.kt b/shared/src/androidMain/kotlin/com/faltenreich/diaguard/shared/system/AndroidSystemSettings.kt similarity index 90% rename from shared/src/androidMain/kotlin/com/faltenreich/diaguard/navigation/system/AndroidSystemSettings.kt rename to shared/src/androidMain/kotlin/com/faltenreich/diaguard/shared/system/AndroidSystemSettings.kt index 1db02adad..310a9786e 100644 --- a/shared/src/androidMain/kotlin/com/faltenreich/diaguard/navigation/system/AndroidSystemSettings.kt +++ b/shared/src/androidMain/kotlin/com/faltenreich/diaguard/shared/system/AndroidSystemSettings.kt @@ -1,4 +1,4 @@ -package com.faltenreich.diaguard.navigation.system +package com.faltenreich.diaguard.shared.system import android.content.Context import android.content.Intent diff --git a/shared/src/androidMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt b/shared/src/androidMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt similarity index 79% rename from shared/src/androidMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt rename to shared/src/androidMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt index caf2d6696..db04ddb45 100644 --- a/shared/src/androidMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt +++ b/shared/src/androidMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt @@ -1,4 +1,4 @@ -package com.faltenreich.diaguard.navigation.system +package com.faltenreich.diaguard.shared.system import org.koin.android.ext.koin.androidContext import org.koin.dsl.module diff --git a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/AppModules.kt b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/AppModules.kt index 277f5e862..2953088cf 100644 --- a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/AppModules.kt +++ b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/AppModules.kt @@ -24,6 +24,7 @@ import com.faltenreich.diaguard.shared.logging.loggerModule import com.faltenreich.diaguard.shared.networking.networkingModule import com.faltenreich.diaguard.shared.primitive.primitiveModule import com.faltenreich.diaguard.shared.serialization.serializationModule +import com.faltenreich.diaguard.shared.system.systemSettingsModule import com.faltenreich.diaguard.shared.theme.themeModule import com.faltenreich.diaguard.statistic.statisticModule import com.faltenreich.diaguard.tag.tagModule @@ -43,6 +44,7 @@ fun appModules() = listOf( databaseModule(), networkingModule(), dateTimeModule(), + systemSettingsModule(), // Feature themeModule(), seedModule(), diff --git a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/NavigationModule.kt b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/NavigationModule.kt index e1239af3d..9952cf6af 100644 --- a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/NavigationModule.kt +++ b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/NavigationModule.kt @@ -11,14 +11,11 @@ import com.faltenreich.diaguard.navigation.screen.GetTopAppBarStyleUseCase import com.faltenreich.diaguard.navigation.screen.PopScreenUseCase import com.faltenreich.diaguard.navigation.screen.PushScreenUseCase import com.faltenreich.diaguard.navigation.system.OpenNotificationSettingsUseCase -import com.faltenreich.diaguard.navigation.system.systemSettingsModule import org.koin.core.module.dsl.singleOf import org.koin.core.module.dsl.viewModelOf import org.koin.dsl.module fun navigationModule() = module { - includes(systemSettingsModule()) - singleOf(::Navigation) singleOf(::CollectNavigationEventsUseCase) diff --git a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/OpenNotificationSettingsUseCase.kt b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/OpenNotificationSettingsUseCase.kt index bd6b04350..5dc5ffae4 100644 --- a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/OpenNotificationSettingsUseCase.kt +++ b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/OpenNotificationSettingsUseCase.kt @@ -1,5 +1,7 @@ package com.faltenreich.diaguard.navigation.system +import com.faltenreich.diaguard.shared.system.SystemSettings + class OpenNotificationSettingsUseCase(private val systemSettings: SystemSettings) { operator fun invoke() { diff --git a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/preference/overview/GetOverviewPreferencesUseCase.kt b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/preference/overview/GetOverviewPreferencesUseCase.kt index cce9169a3..0537101d0 100644 --- a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/preference/overview/GetOverviewPreferencesUseCase.kt +++ b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/preference/overview/GetOverviewPreferencesUseCase.kt @@ -5,7 +5,7 @@ import com.faltenreich.diaguard.backup.user.write.WriteBackupFormScreen import com.faltenreich.diaguard.measurement.category.list.MeasurementCategoryListScreen import com.faltenreich.diaguard.navigation.bottomsheet.OpenBottomSheetUseCase import com.faltenreich.diaguard.navigation.screen.PushScreenUseCase -import com.faltenreich.diaguard.navigation.system.SystemSettings +import com.faltenreich.diaguard.shared.system.SystemSettings import com.faltenreich.diaguard.preference.color.ColorSchemeFormScreen import com.faltenreich.diaguard.preference.color.ColorSchemePreference import com.faltenreich.diaguard.preference.decimal.DecimalPlacesFormScreen diff --git a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettings.kt b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettings.kt similarity index 56% rename from shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettings.kt rename to shared/src/commonMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettings.kt index ca2784fcc..adbcdee7e 100644 --- a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettings.kt +++ b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettings.kt @@ -1,4 +1,4 @@ -package com.faltenreich.diaguard.navigation.system +package com.faltenreich.diaguard.shared.system interface SystemSettings { diff --git a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt similarity index 60% rename from shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt rename to shared/src/commonMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt index 2829a0a0b..bd535d821 100644 --- a/shared/src/commonMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt +++ b/shared/src/commonMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt @@ -1,4 +1,4 @@ -package com.faltenreich.diaguard.navigation.system +package com.faltenreich.diaguard.shared.system import org.koin.core.module.Module diff --git a/shared/src/commonTest/kotlin/com/faltenreich/diaguard/TestModules.kt b/shared/src/commonTest/kotlin/com/faltenreich/diaguard/TestModules.kt index ebfc8d481..85a30b975 100644 --- a/shared/src/commonTest/kotlin/com/faltenreich/diaguard/TestModules.kt +++ b/shared/src/commonTest/kotlin/com/faltenreich/diaguard/TestModules.kt @@ -1,7 +1,7 @@ package com.faltenreich.diaguard -import com.faltenreich.diaguard.backup.legacy.LegacyDao import com.faltenreich.diaguard.backup.legacy.FakeLegacyDao +import com.faltenreich.diaguard.backup.legacy.LegacyDao import com.faltenreich.diaguard.backup.seed.query.food.FoodSeedQueries import com.faltenreich.diaguard.backup.seed.query.tag.TagSeedQueries import com.faltenreich.diaguard.export.pdf.PdfExport @@ -19,6 +19,8 @@ import com.faltenreich.diaguard.shared.localization.Localization import com.faltenreich.diaguard.shared.logging.ConsoleLogger import com.faltenreich.diaguard.shared.logging.Logger import com.faltenreich.diaguard.shared.serialization.Serialization +import com.faltenreich.diaguard.shared.system.FakeSystemSettings +import com.faltenreich.diaguard.shared.system.SystemSettings import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.StandardTestDispatcher @@ -34,6 +36,8 @@ fun testModules() = module { single { StandardTestDispatcher() } single { TestScope(context = get()) } + factory { FakeSystemSettings() } + single { FakeBuildConfig() } single { ConsoleLogger() } diff --git a/shared/src/commonTest/kotlin/com/faltenreich/diaguard/preference/overview/OverviewPreferenceViewModelTest.kt b/shared/src/commonTest/kotlin/com/faltenreich/diaguard/preference/overview/OverviewPreferenceViewModelTest.kt index b698ca866..d72f5c8ac 100644 --- a/shared/src/commonTest/kotlin/com/faltenreich/diaguard/preference/overview/OverviewPreferenceViewModelTest.kt +++ b/shared/src/commonTest/kotlin/com/faltenreich/diaguard/preference/overview/OverviewPreferenceViewModelTest.kt @@ -20,6 +20,7 @@ class OverviewPreferenceViewModelTest : TestSuite { "color_scheme", "start_screen", "decimal_places", + "reminders", "therapy", "measurement_categories", "tags", diff --git a/shared/src/commonTest/kotlin/com/faltenreich/diaguard/shared/config/FakeBuildConfig.kt b/shared/src/commonTest/kotlin/com/faltenreich/diaguard/shared/config/FakeBuildConfig.kt index b5710944c..dca708654 100644 --- a/shared/src/commonTest/kotlin/com/faltenreich/diaguard/shared/config/FakeBuildConfig.kt +++ b/shared/src/commonTest/kotlin/com/faltenreich/diaguard/shared/config/FakeBuildConfig.kt @@ -2,6 +2,8 @@ package com.faltenreich.diaguard.shared.config class FakeBuildConfig : BuildConfig { + override fun getPackageName(): String = "com.faltenreich.diaguard" + override fun getVersionCode(): Long = 1 override fun getVersionName(): String = "1.0.0" diff --git a/shared/src/commonTest/kotlin/com/faltenreich/diaguard/shared/system/FakeSystemSettings.kt b/shared/src/commonTest/kotlin/com/faltenreich/diaguard/shared/system/FakeSystemSettings.kt new file mode 100644 index 000000000..eba182d15 --- /dev/null +++ b/shared/src/commonTest/kotlin/com/faltenreich/diaguard/shared/system/FakeSystemSettings.kt @@ -0,0 +1,6 @@ +package com.faltenreich.diaguard.shared.system + +class FakeSystemSettings : SystemSettings { + + override fun openNotificationSettings() = Unit +} \ No newline at end of file diff --git a/shared/src/iosMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt b/shared/src/iosMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt similarity index 72% rename from shared/src/iosMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt rename to shared/src/iosMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt index cfaddc969..1463b2c8c 100644 --- a/shared/src/iosMain/kotlin/com/faltenreich/diaguard/navigation/system/SystemSettingsModule.kt +++ b/shared/src/iosMain/kotlin/com/faltenreich/diaguard/shared/system/SystemSettingsModule.kt @@ -1,4 +1,4 @@ -package com.faltenreich.diaguard.navigation.system +package com.faltenreich.diaguard.shared.system import org.koin.dsl.module