diff options
| author | David Göransson <david.goransson90@gmail.com> | 2023-09-29 20:02:08 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson90@gmail.com> | 2023-10-02 16:06:03 +0200 |
| commit | 3d38b605ca87c63e293afecb3e37f062c4f31265 (patch) | |
| tree | cbce556569110b160120a9ede5eea2697b0d710b /android/test | |
| parent | 0995760e5ea6dde06b56065ea45346c1f9672839 (diff) | |
| download | mullvadvpn-3d38b605ca87c63e293afecb3e37f062c4f31265.tar.xz mullvadvpn-3d38b605ca87c63e293afecb3e37f062c4f31265.zip | |
Add Compose Preview test and fix issues
Diffstat (limited to 'android/test')
| -rw-r--r-- | android/test/arch/build.gradle.kts | 15 | ||||
| -rw-r--r-- | android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposePreviewTests.kt | 22 |
2 files changed, 26 insertions, 11 deletions
diff --git a/android/test/arch/build.gradle.kts b/android/test/arch/build.gradle.kts index 0a28fd2fab..dff039f0e2 100644 --- a/android/test/arch/build.gradle.kts +++ b/android/test/arch/build.gradle.kts @@ -7,18 +7,14 @@ android { namespace = "net.mullvad.mullvadvpn.test.arch" compileSdk = Versions.Android.compileSdkVersion - defaultConfig { - minSdk = Versions.Android.minSdkVersion - } + defaultConfig { minSdk = Versions.Android.minSdkVersion } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = Versions.jvmTarget - } + kotlinOptions { jvmTarget = Versions.jvmTarget } lint { lintConfig = file("${rootProject.projectDir}/config/lint.xml") @@ -28,14 +24,11 @@ android { } androidComponents { - beforeVariants { variantBuilder -> - variantBuilder.apply { - enable = name != "release" - } - } + beforeVariants { variantBuilder -> variantBuilder.apply { enable = name != "release" } } } dependencies { + testImplementation(Dependencies.Compose.uiToolingAndroidPreview) testImplementation(Dependencies.AndroidX.appcompat) testImplementation(Dependencies.junit) testImplementation(Dependencies.konsist) diff --git a/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposePreviewTests.kt b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposePreviewTests.kt new file mode 100644 index 0000000000..64b221d0c0 --- /dev/null +++ b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposePreviewTests.kt @@ -0,0 +1,22 @@ +package net.mullvad.mullvadvpn.test.arch.compose + +import androidx.compose.ui.tooling.preview.Preview +import com.lemonappdev.konsist.api.Konsist +import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf +import com.lemonappdev.konsist.api.verify.assert +import org.junit.Test + +class ComposePreviewTests { + @Test + fun `all preview functions are private`() { + allPreviewFunctions().assert { it.hasPrivateModifier } + } + + @Test + fun `all preview functions are prefixed with Preview`() { + allPreviewFunctions().assert { it.name.startsWith("Preview") } + } + + private fun allPreviewFunctions() = + Konsist.scopeFromProduction().functions().withAllAnnotationsOf(Preview::class) +} |
