diff --git a/.github/workflows/snapshots-checks.yml b/.github/workflows/snapshots-checks.yml index 891cda3a..c1cda0b3 100644 --- a/.github/workflows/snapshots-checks.yml +++ b/.github/workflows/snapshots-checks.yml @@ -10,7 +10,6 @@ on: paths: - gradle/** - snapshots/** - - snapshots-processor/** - snapshots-shared/** jobs: diff --git a/.github/workflows/snapshots-processor-checks.yml b/.github/workflows/snapshots-processor-checks.yml deleted file mode 100644 index 2bfb0813..00000000 --- a/.github/workflows/snapshots-processor-checks.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: snapshots-processor checks - -on: - push: - branches: - - main - pull_request: - branches: - - main - paths: - - gradle/** - - snapshots/** - - snapshots-processor/** - - snapshots-shared/** - -jobs: - - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDKs - uses: actions/setup-java@v3 - with: - distribution: 'adopt' - java-version: 17 - - name: Run build - run: ./gradlew :snapshots:snapshots-processor:build - - processor_tests: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDKs - uses: actions/setup-java@v3 - with: - distribution: 'adopt' - java-version: 17 - - name: Run unit tests - run: ./gradlew :snapshots:snapshots-processor-test:test -Pandroid.useAndroidX=true - - unit_tests: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDKs - uses: actions/setup-java@v3 - with: - distribution: 'adopt' - java-version: 17 - - name: Run unit tests - run: ./gradlew :snapshots:snapshots-processor:test diff --git a/.github/workflows/snapshots-release.yml b/.github/workflows/snapshots-release.yml index 9f30853e..b68a7724 100644 --- a/.github/workflows/snapshots-release.yml +++ b/.github/workflows/snapshots-release.yml @@ -31,8 +31,6 @@ jobs: distribution: 'adopt' - name: Sanity check snapshots test run: ./gradlew :snapshots:snapshots:test -Pandroid.useAndroidX=true - - name: Sanity check snapshots-processor test - run: ./gradlew :snapshots:snapshots-processor:test - name: Sanity check snapshots-shared test run: ./gradlew :snapshots:snapshots-shared:test - name: Deploy snapshots-shared @@ -41,6 +39,3 @@ jobs: run: ./gradlew :snapshots:snapshots-annotations:publishReleasePublicationToSonatypeStagingRepository - name: Deploy snapshots run: ./gradlew :snapshots:snapshots:publishReleasePublicationToSonatypeStagingRepository -Pandroid.useAndroidX=true -# Temporarily disabled for 1.0 release, TODO (ryan) fully remove once 1.0 stable is released -# - name: Deploy snapshots-processor -# run: ./gradlew :snapshots:snapshots-processor:publishReleasePublicationToSonatypeStagingRepository diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4184ed45..57ca3c69 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,9 +7,6 @@ compose-bom = "2023.10.01" compose-compiler-extension = "1.5.10" detekt = "1.22.0" kotlin = "1.9.22" -kotlinpoet = "1.14.2" -kotlin-compile-testing = "1.5.0" -ksp = "1.9.22-1.0.17" okhttp = "4.10.0" junit-jupiter = "5.8.2" @@ -27,9 +24,7 @@ buildconfig = "com.github.gmazzo.buildconfig:3.0.3" detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } gradle-publish = { id = "com.gradle.plugin-publish", version = "0.20.0" } grgit = { id = "org.ajoberstar.grgit", version = "5.0.0" } plugin-best-practices = { id = "com.autonomousapps.plugin-best-practices-plugin", version = "0.10" } @@ -51,9 +46,6 @@ androidx-tracing-ktx = { module = "androidx.tracing:tracing-ktx", version = "1.1 assertj = "org.assertj:assertj-core:3.21.0" -compile-testing = { module = "com.github.tschuchortdev:kotlin-compile-testing", version.ref = "kotlin-compile-testing" } -compile-testing-ksp = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version.ref = "kotlin-compile-testing" } - compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" } compose-runtime = { group = "androidx.compose.runtime", name = "runtime" } compose-material = { group = "androidx.compose.material3", name = "material3" } @@ -83,11 +75,6 @@ kotlinx-serialization = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1" ktor-network = { module = "io.ktor:ktor-network", version = "2.1.1" } -kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" } -kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" } -ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } -ksp-gradle-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } - okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" } diff --git a/performance/sample/app/build.gradle.kts b/performance/sample/app/build.gradle.kts index 9b47436f..fafb8d02 100644 --- a/performance/sample/app/build.gradle.kts +++ b/performance/sample/app/build.gradle.kts @@ -1,7 +1,6 @@ plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) - alias(libs.plugins.ksp) id("com.emergetools.android") } diff --git a/settings.gradle.kts b/settings.gradle.kts index 04e4ad1f..432a8110 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,8 +27,6 @@ include( ":snapshots", ":snapshots:snapshots", ":snapshots:snapshots-annotations", - ":snapshots:snapshots-processor", - ":snapshots:snapshots-processor-test", ":snapshots:snapshots-shared", ":snapshots:sample", ":snapshots:sample:app", diff --git a/snapshots/README.md b/snapshots/README.md index 86f1dbd4..3b769a47 100644 --- a/snapshots/README.md +++ b/snapshots/README.md @@ -28,21 +28,14 @@ emerge { See [gradle-plugin](../gradle-plugin/README.md) for more information. -### Add Snapshot SDK(s) +### Add Snapshot SDK Add the Emerge snapshot SDK as an `androidTest` dependency to your application module. For automatic compose `@Preview` snapshot generation, add the KSP processor as a `ksp` dependency. ```kotlin -plugins { - // For Compose @Preview snapshot generation: - id("com.google.devtools.ksp") -} - dependencies { androidTestImplementation("com.emergetools.snapshots:snapshots:{latest_version}") - // For Compose @Preview snapshot generation from the main source set: - ksp("com.emergetools.snapshots:snapshots-processor:{latest_version}") } ``` @@ -129,7 +122,6 @@ snapshot tests from the `androidTest` source set. ```kotlin plugins { id("com.emergetools.android") - id("com.google.devtools.ksp") } emerge { @@ -138,8 +130,6 @@ emerge { dependencies { androidTestImplementation("com.emergetools.snapshots:snapshots:{latest_version}") - // For Compose @Preview snapshot generation from androidTest source set: - kspAndroidTest("com.emergetools.snapshots:snapshots-processor:{latest_version}") } ``` diff --git a/snapshots/snapshots-processor-test/build.gradle.kts b/snapshots/snapshots-processor-test/build.gradle.kts deleted file mode 100644 index 92bd620a..00000000 --- a/snapshots/snapshots-processor-test/build.gradle.kts +++ /dev/null @@ -1,45 +0,0 @@ -plugins { - alias(libs.plugins.kotlin.android) - alias(libs.plugins.android.library) -} - -android { - namespace = "com.emergetools.snapshots.snapshots_processor_test" - compileSdk = 34 - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() - } - - defaultConfig { - minSdk = 23 - } - - buildFeatures { - compose = true - } - - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.compose.compiler.extension.get() - } -} - -dependencies { - testImplementation(projects.snapshots.snapshotsProcessor) - - testImplementation(platform(libs.compose.bom)) - testImplementation(libs.compose.runtime) - testImplementation(libs.compose.ui.tooling) - - testImplementation(libs.assertj) - testImplementation(libs.compile.testing) - testImplementation(libs.compile.testing.ksp) - testImplementation(libs.junit) - testImplementation(libs.guava) - testImplementation(libs.google.truth) -} diff --git a/snapshots/snapshots-processor-test/src/main/AndroidManifest.xml b/snapshots/snapshots-processor-test/src/main/AndroidManifest.xml deleted file mode 100644 index cc947c56..00000000 --- a/snapshots/snapshots-processor-test/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/snapshots/snapshots-processor-test/src/test/kotlin/com/emergetools/snapshots/processor/PreviewProcessorTest.kt b/snapshots/snapshots-processor-test/src/test/kotlin/com/emergetools/snapshots/processor/PreviewProcessorTest.kt deleted file mode 100644 index 92908fef..00000000 --- a/snapshots/snapshots-processor-test/src/test/kotlin/com/emergetools/snapshots/processor/PreviewProcessorTest.kt +++ /dev/null @@ -1,179 +0,0 @@ -package com.emergetools.snapshots.processor - -import com.google.common.io.Resources -import com.tschuchort.compiletesting.KotlinCompilation -import com.tschuchort.compiletesting.SourceFile -import com.tschuchort.compiletesting.kspArgs -import com.tschuchort.compiletesting.kspSourcesDir -import com.tschuchort.compiletesting.symbolProcessorProviders -import junit.framework.Assert.assertEquals -import junit.framework.Assert.assertTrue -import org.assertj.core.api.Assertions.assertThat -import org.junit.Rule -import org.junit.Test -import java.io.File - -class PreviewProcessorTest { - - companion object { - // Set to true to overwrite the test outputs with those generated from tests above. - const val UPDATE_TEST_OUTPUTS = false - } - - @Rule - @JvmField - val testNameRule = TestNameRule() - - @Test - fun `standalone preview function produces one snapshot test`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `standalone preview function with two previews produces two snapshot tests`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `two preview functions produces two snapshot tests`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `standalone preview function with private preview produces no snapshot test`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `standalone preview function with internal preview produces no snapshot test without arg`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `standalone preview function with internal preview produces one snapshot test with arg`() { - compileInputsAndVerifyOutputs( - mutableMapOf("emerge.experimentalInternalEnabled" to "true") - ) - } - - @Test - fun `multipreview function with two previews produces two snapshots`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `multipreview internal function with two previews produces no snapshots without arg`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `multipreview internal function with two previews produces two snapshots with arg`() { - compileInputsAndVerifyOutputs( - mutableMapOf("emerge.experimentalInternalEnabled" to "true") - ) - } - - @Test - fun `multipreview function with two previews and additional preview produces three snapshots`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `multipreview with three previews and normal preview produces four snapshots`() { - compileInputsAndVerifyOutputs() - } - - @Test - fun `stacked multipreview five total previews produces five snapshots`() { - compileInputsAndVerifyOutputs() - } - - private fun compileInputs( - options: MutableMap = mutableMapOf(), - onCompilation: (compilation: KotlinCompilation, result: KotlinCompilation.Result) -> Unit, - ) { - val testResourcesDir = getTestResourcesDirectory(getRootResourcesDir()) - - val inputDir = File(testResourcesDir, "input") - inputDir.mkdirs() - - val compilation = KotlinCompilation().apply { - sources = inputDir.listFiles()?.toList().orEmpty().map(SourceFile::fromPath) - symbolProcessorProviders = listOf(PreviewProcessorProvider()) - kspArgs = options - inheritClassPath = true - messageOutputStream = System.out - } - - val result = compilation.compile() - onCompilation(compilation, result) - } - - @Suppress("UnusedPrivateMember") - private fun assertCompilationFails(errorMessage: String) { - compileInputs { _, result -> - assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) - - assertTrue(result.messages.contains(errorMessage)) - } - } - - private fun compileInputsAndVerifyOutputs( - options: MutableMap = mutableMapOf(), - ) { - compileInputs(options = options) { compilation, result -> - result.assertGeneratedSources(compilation) - } - } - - /** - * Collects the files in the "output" directory of this test's resources directory - * and validates that they match the generated sources of this compilation result. - */ - private fun KotlinCompilation.Result.assertGeneratedSources( - compilation: KotlinCompilation, - ) { - assertEquals(KotlinCompilation.ExitCode.OK, exitCode) - - val testResourcesDir = getTestResourcesDirectory(getRootResourcesDir()) - val outputDir = File(testResourcesDir, "output") - - if (UPDATE_TEST_OUTPUTS) { - outputDir.deleteRecursively() - } - outputDir.mkdirs() - - val generatedSources = compilation.kspSourcesDir.walk().filter { it.isFile }.toList() - if (UPDATE_TEST_OUTPUTS) { - generatedSources.forEach { - it.copyTo(File(outputDir, it.name)) - } - } else { - assertEquals(outputDir.listFiles()?.size ?: 0, generatedSources.size) - - generatedSources.forEach { actualFile -> - val expectedFile = File(outputDir, actualFile.name) - assertTrue(expectedFile.exists()) - assertThat(actualFile).hasSameTextualContentAs(expectedFile) - } - } - } - - private fun getRootResourcesDir(): File { - val path = Resources.getResource("") - .path - .substringBefore("/build/") - .plus("/src/test/resources") - - return File(path) - } - - private fun getTestResourcesDirectory(rootResourcesDir: File): File { - val methodName = testNameRule - .methodName - .replace(" ", "_") - - val className = testNameRule.className.substringAfterLast(".") - return File(rootResourcesDir, "$className/$methodName") - } -} diff --git a/snapshots/snapshots-processor-test/src/test/kotlin/com/emergetools/snapshots/processor/TestNameRule.kt b/snapshots/snapshots-processor-test/src/test/kotlin/com/emergetools/snapshots/processor/TestNameRule.kt deleted file mode 100644 index 41f833b9..00000000 --- a/snapshots/snapshots-processor-test/src/test/kotlin/com/emergetools/snapshots/processor/TestNameRule.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.emergetools.snapshots.processor - -import org.junit.rules.TestWatcher -import org.junit.runner.Description - -class TestNameRule : TestWatcher() { - /** - * @return the name of the currently-running test method - */ - lateinit var methodName: String - private set - - lateinit var className: String - - override fun starting(d: Description) { - methodName = d.methodName - className = d.className - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/input/FontScalePreviews.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/input/FontScalePreviews.kt deleted file mode 100644 index 32e4020b..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/input/FontScalePreviews.kt +++ /dev/null @@ -1,13 +0,0 @@ -package PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input - -import androidx.compose.ui.tooling.preview.Preview - -@Preview( - name = "Small font", - fontScale = 0.5f, -) -@Preview( - name = "Large font", - fontScale = 1.5f, -) -annotation class FontScalePreviews diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/input/MultiPreviewComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/input/MultiPreviewComposable.kt deleted file mode 100644 index 35d8e1eb..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/input/MultiPreviewComposable.kt +++ /dev/null @@ -1,11 +0,0 @@ -package PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input - -import PreviewProcessorTest.multipreview_function_with_two_previews_produces_two_snapshots.input.FontScalePreviews -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable - -@Preview -@FontScalePreviews -@Composable -fun MultiPreviewComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_-1121164302_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_-1121164302_GenSnapshot.kt deleted file mode 100644 index f5f13369..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_-1121164302_GenSnapshot.kt +++ /dev/null @@ -1,38 +0,0 @@ -package PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input - -import PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input.MultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class `MultiPreviewComposable_-1121164302_GenSnapshot` { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input.MultiPreviewComposable", - name = "Small font", - fontScale = 0.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_1326053438_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_1326053438_GenSnapshot.kt deleted file mode 100644 index be478dc7..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_1326053438_GenSnapshot.kt +++ /dev/null @@ -1,38 +0,0 @@ -package PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input - -import PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input.MultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class MultiPreviewComposable_1326053438_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input.MultiPreviewComposable", - name = "Large font", - fontScale = 1.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_GenSnapshot.kt deleted file mode 100644 index fb856568..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots/output/MultiPreviewComposable_GenSnapshot.kt +++ /dev/null @@ -1,36 +0,0 @@ -package PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input - -import PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input.MultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class MultiPreviewComposable_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.multipreview_function_with_two_previews_and_additional_preview_produces_three_snapshots.input.MultiPreviewComposable") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/input/FontScalePreviews.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/input/FontScalePreviews.kt deleted file mode 100644 index bec9a072..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/input/FontScalePreviews.kt +++ /dev/null @@ -1,13 +0,0 @@ -package PreviewProcessorTest.multipreview_function_with_two_previews_produces_two_snapshots.input - -import androidx.compose.ui.tooling.preview.Preview - -@Preview( - name = "Small font", - fontScale = 0.5f, -) -@Preview( - name = "Large font", - fontScale = 1.5f, -) -annotation class FontScalePreviews diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/input/MultiPreviewComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/input/MultiPreviewComposable.kt deleted file mode 100644 index e6e5cba4..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/input/MultiPreviewComposable.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import PreviewProcessorTest.multipreview_function_with_two_previews_produces_two_snapshots.input.FontScalePreviews -import androidx.compose.runtime.Composable - -@FontScalePreviews -@Composable -fun MultiPreviewComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/output/MultiPreviewComposable_-849881519_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/output/MultiPreviewComposable_-849881519_GenSnapshot.kt deleted file mode 100644 index b44e5234..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/output/MultiPreviewComposable_-849881519_GenSnapshot.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.android.standalone_preview_function_compiles_ok.MultiPreviewComposable -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class `MultiPreviewComposable_-849881519_GenSnapshot` { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = "com.emergetools.android.standalone_preview_function_compiles_ok.MultiPreviewComposable", - name = "Small font", - fontScale = 0.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/output/MultiPreviewComposable_1597336221_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/output/MultiPreviewComposable_1597336221_GenSnapshot.kt deleted file mode 100644 index 7d085efd..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_function_with_two_previews_produces_two_snapshots/output/MultiPreviewComposable_1597336221_GenSnapshot.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.android.standalone_preview_function_compiles_ok.MultiPreviewComposable -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class MultiPreviewComposable_1597336221_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = "com.emergetools.android.standalone_preview_function_compiles_ok.MultiPreviewComposable", - name = "Large font", - fontScale = 1.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_no_snapshots_without_arg/input/FontScalePreviews.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_no_snapshots_without_arg/input/FontScalePreviews.kt deleted file mode 100644 index bdf21b69..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_no_snapshots_without_arg/input/FontScalePreviews.kt +++ /dev/null @@ -1,13 +0,0 @@ -package PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_no_snapshots_without_arg.input - -import androidx.compose.ui.tooling.preview.Preview - -@Preview( - name = "Small font", - fontScale = 0.5f, -) -@Preview( - name = "Large font", - fontScale = 1.5f, -) -annotation class FontScalePreviews diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_no_snapshots_without_arg/input/MultiPreviewComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_no_snapshots_without_arg/input/MultiPreviewComposable.kt deleted file mode 100644 index 31f69778..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_no_snapshots_without_arg/input/MultiPreviewComposable.kt +++ /dev/null @@ -1,8 +0,0 @@ -package PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_no_snapshots_without_arg.input - -import androidx.compose.runtime.Composable - -@FontScalePreviews -@Composable -internal fun MultiPreviewComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/input/FontScalePreviews.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/input/FontScalePreviews.kt deleted file mode 100644 index 33f4efe1..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/input/FontScalePreviews.kt +++ /dev/null @@ -1,13 +0,0 @@ -package PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg.input - -import androidx.compose.ui.tooling.preview.Preview - -@Preview( - name = "Small font", - fontScale = 0.5f, -) -@Preview( - name = "Large font", - fontScale = 1.5f, -) -annotation class FontScalePreviews diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/input/MultiPreviewComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/input/MultiPreviewComposable.kt deleted file mode 100644 index 184c7d88..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/input/MultiPreviewComposable.kt +++ /dev/null @@ -1,8 +0,0 @@ -package PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg.input - -import androidx.compose.runtime.Composable - -@FontScalePreviews -@Composable -internal fun MultiPreviewComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/output/MultiPreviewComposable_-1707151673_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/output/MultiPreviewComposable_-1707151673_GenSnapshot.kt deleted file mode 100644 index b35be600..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/output/MultiPreviewComposable_-1707151673_GenSnapshot.kt +++ /dev/null @@ -1,38 +0,0 @@ -package PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg.input - -import PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg.input.MultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class `MultiPreviewComposable_-1707151673_GenSnapshot` { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg.input.MultiPreviewComposable", - name = "Large font", - fontScale = 1.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/output/MultiPreviewComposable_140597883_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/output/MultiPreviewComposable_140597883_GenSnapshot.kt deleted file mode 100644 index 90e0c3c7..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg/output/MultiPreviewComposable_140597883_GenSnapshot.kt +++ /dev/null @@ -1,38 +0,0 @@ -package PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg.input - -import PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg.input.MultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class MultiPreviewComposable_140597883_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.multipreview_internal_function_with_two_previews_produces_two_snapshots_with_arg.input.MultiPreviewComposable", - name = "Small font", - fontScale = 0.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/MultiPreviewComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/MultiPreviewComposable.kt deleted file mode 100644 index 0dbbdd7d..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/MultiPreviewComposable.kt +++ /dev/null @@ -1,8 +0,0 @@ -package PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input - -import androidx.compose.runtime.Composable - -@PreviewVariants -@Composable -fun MultiPreviewComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/PreviewVariants.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/PreviewVariants.kt deleted file mode 100644 index 6f997e89..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/PreviewVariants.kt +++ /dev/null @@ -1,20 +0,0 @@ -package PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input - -import android.content.res.Configuration -import androidx.compose.ui.tooling.preview.Preview - -@Preview( - name = "Default", - group = "Default", -) -@Preview( - name = "Dark Mode", - group = "Dark Mode", - uiMode = Configuration.UI_MODE_NIGHT_YES, -) -@Preview( - name = "Large Font", - group = "Large Font", - fontScale = 1.5f, -) -annotation class PreviewVariants diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/TestComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/TestComposable.kt deleted file mode 100644 index f654e05f..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/input/TestComposable.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable - -@Preview -@Composable -fun TestComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_-339123963_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_-339123963_GenSnapshot.kt deleted file mode 100644 index 307825a5..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_-339123963_GenSnapshot.kt +++ /dev/null @@ -1,39 +0,0 @@ -package PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input - -import PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input.MultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class `MultiPreviewComposable_-339123963_GenSnapshot` { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input.MultiPreviewComposable", - name = "Dark Mode", - group = "Dark Mode", - uiMode = 32) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_49214469_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_49214469_GenSnapshot.kt deleted file mode 100644 index 2a0e7040..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_49214469_GenSnapshot.kt +++ /dev/null @@ -1,39 +0,0 @@ -package PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input - -import PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input.MultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class MultiPreviewComposable_49214469_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input.MultiPreviewComposable", - name = "Large Font", - group = "Large Font", - fontScale = 1.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_GenSnapshot.kt deleted file mode 100644 index a37cf554..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/MultiPreviewComposable_GenSnapshot.kt +++ /dev/null @@ -1,38 +0,0 @@ -package PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input - -import PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input.MultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class MultiPreviewComposable_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.multipreview_with_three_previews_and_normal_preview_produces_four_snapshots.input.MultiPreviewComposable", - name = "Default", - group = "Default") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun MultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - MultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/TestComposable_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/TestComposable_GenSnapshot.kt deleted file mode 100644 index 470c90a5..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/multipreview_with_three_previews_and_normal_preview_produces_four_snapshots/output/TestComposable_GenSnapshot.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class TestComposable_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = "com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun TestComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - TestComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/FontScaleVariants.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/FontScaleVariants.kt deleted file mode 100644 index f069e150..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/FontScaleVariants.kt +++ /dev/null @@ -1,20 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -import androidx.compose.ui.tooling.preview.Preview - -@Preview( - name = "Normal font", - group = "Font scale", - fontScale = 1f, -) -@Preview( - name = "Large font", - group = "Font scale", - fontScale = 1.5f, -) -@Preview( - name = "Small font", - group = "Font scale", - fontScale = .5f, -) -annotation class FontScaleVariants diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/PreviewVariants.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/PreviewVariants.kt deleted file mode 100644 index 11bbc07e..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/PreviewVariants.kt +++ /dev/null @@ -1,5 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -@FontScaleVariants -@UIModeVariants -annotation class PreviewVariants diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/StackedMultiPreviewComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/StackedMultiPreviewComposable.kt deleted file mode 100644 index e8c28957..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/StackedMultiPreviewComposable.kt +++ /dev/null @@ -1,8 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -import androidx.compose.runtime.Composable - -@PreviewVariants -@Composable -fun StackedMultiPreviewComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/UIModeVariants.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/UIModeVariants.kt deleted file mode 100644 index fed50cf6..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/input/UIModeVariants.kt +++ /dev/null @@ -1,16 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -import android.content.res.Configuration -import androidx.compose.ui.tooling.preview.Preview - -@Preview( - name = "Light", - group = "UIMode", - uiMode = Configuration.UI_MODE_NIGHT_NO, -) -@Preview( - name = "Dark", - group = "UIMode", - uiMode = Configuration.UI_MODE_NIGHT_YES, -) -annotation class UIModeVariants diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-2110175474_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-2110175474_GenSnapshot.kt deleted file mode 100644 index 13b7bebd..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-2110175474_GenSnapshot.kt +++ /dev/null @@ -1,39 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -import PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class `StackedMultiPreviewComposable_-2110175474_GenSnapshot` { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable", - name = "Large font", - group = "Font scale", - fontScale = 1.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun StackedMultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - StackedMultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-262425918_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-262425918_GenSnapshot.kt deleted file mode 100644 index 1ceb8503..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-262425918_GenSnapshot.kt +++ /dev/null @@ -1,39 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -import PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class `StackedMultiPreviewComposable_-262425918_GenSnapshot` { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable", - name = "Small font", - group = "Font scale", - fontScale = 0.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun StackedMultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - StackedMultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-441987374_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-441987374_GenSnapshot.kt deleted file mode 100644 index 2f60db34..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_-441987374_GenSnapshot.kt +++ /dev/null @@ -1,39 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -import PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class `StackedMultiPreviewComposable_-441987374_GenSnapshot` { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable", - name = "Dark", - group = "UIMode", - uiMode = 32) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun StackedMultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - StackedMultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_441959458_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_441959458_GenSnapshot.kt deleted file mode 100644 index a647b983..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_441959458_GenSnapshot.kt +++ /dev/null @@ -1,39 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -import PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class StackedMultiPreviewComposable_441959458_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable", - name = "Light", - group = "UIMode", - uiMode = 16) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun StackedMultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - StackedMultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_GenSnapshot.kt deleted file mode 100644 index ffbc4f5c..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/stacked_multipreview_five_total_previews_produces_five_snapshots/output/StackedMultiPreviewComposable_GenSnapshot.kt +++ /dev/null @@ -1,38 +0,0 @@ -package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input - -import PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class StackedMultiPreviewComposable_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input.StackedMultiPreviewComposable", - name = "Normal font", - group = "Font scale") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun StackedMultiPreviewComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - StackedMultiPreviewComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_produces_one_snapshot_test/input/TestComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_produces_one_snapshot_test/input/TestComposable.kt deleted file mode 100644 index f654e05f..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_produces_one_snapshot_test/input/TestComposable.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable - -@Preview -@Composable -fun TestComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_produces_one_snapshot_test/output/TestComposable_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_produces_one_snapshot_test/output/TestComposable_GenSnapshot.kt deleted file mode 100644 index 470c90a5..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_produces_one_snapshot_test/output/TestComposable_GenSnapshot.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class TestComposable_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = "com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun TestComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - TestComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_no_snapshot_test_without_arg/input/TestComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_no_snapshot_test_without_arg/input/TestComposable.kt deleted file mode 100644 index 54a5b4cd..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_no_snapshot_test_without_arg/input/TestComposable.kt +++ /dev/null @@ -1,9 +0,0 @@ -package PreviewProcessorTest.standalone_preview_function_with_internal_preview_produces_no_snapshot_test_without_arg.input - -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable - -@Preview -@Composable -internal fun TestComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg/input/TestComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg/input/TestComposable.kt deleted file mode 100644 index 2b812319..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg/input/TestComposable.kt +++ /dev/null @@ -1,9 +0,0 @@ -package PreviewProcessorTest.standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg.input - -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable - -@Preview -@Composable -internal fun TestComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg/output/TestComposable_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg/output/TestComposable_GenSnapshot.kt deleted file mode 100644 index 78ce77d6..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg/output/TestComposable_GenSnapshot.kt +++ /dev/null @@ -1,36 +0,0 @@ -package PreviewProcessorTest.standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg.input - -import PreviewProcessorTest.standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg.input.TestComposable -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class TestComposable_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = - "PreviewProcessorTest.standalone_preview_function_with_internal_preview_produces_one_snapshot_test_with_arg.input.TestComposable") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun TestComposable_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - TestComposable() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_private_preview_produces_no_snapshot_test/input/TestComposable.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_private_preview_produces_no_snapshot_test/input/TestComposable.kt deleted file mode 100644 index 10639fe2..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_private_preview_produces_no_snapshot_test/input/TestComposable.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable - -@Preview -@Composable -private fun TestComposable() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/input/TestComposables.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/input/TestComposables.kt deleted file mode 100644 index 751417ea..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/input/TestComposables.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable - -@Preview -@Preview(fontScale = 1.5f) -@Composable -fun TestComposable1() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/output/TestComposable1_-732131735_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/output/TestComposable1_-732131735_GenSnapshot.kt deleted file mode 100644 index ffca59c4..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/output/TestComposable1_-732131735_GenSnapshot.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable1 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class `TestComposable1_-732131735_GenSnapshot` { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = "com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable1", - fontScale = 1.5f) - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun TestComposable1_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - TestComposable1() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/output/TestComposable1_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/output/TestComposable1_GenSnapshot.kt deleted file mode 100644 index b9387013..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/standalone_preview_function_with_two_previews_produces_two_snapshot_tests/output/TestComposable1_GenSnapshot.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable1 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class TestComposable1_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = "com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable1") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun TestComposable1_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - TestComposable1() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/input/TestComposables.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/input/TestComposables.kt deleted file mode 100644 index 309bbbc2..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/input/TestComposables.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable - -@Preview -@Composable -fun TestComposable1() { -} - -@Preview -@Composable -fun TestComposable2() { -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/output/TestComposable1_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/output/TestComposable1_GenSnapshot.kt deleted file mode 100644 index b9387013..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/output/TestComposable1_GenSnapshot.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable1 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class TestComposable1_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = "com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable1") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun TestComposable1_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - TestComposable1() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/output/TestComposable2_GenSnapshot.kt b/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/output/TestComposable2_GenSnapshot.kt deleted file mode 100644 index cef8cbd8..00000000 --- a/snapshots/snapshots-processor-test/src/test/resources/PreviewProcessorTest/two_preview_functions_produces_two_snapshot_tests/output/TestComposable2_GenSnapshot.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.emergetools.android.standalone_preview_function_compiles_ok - -import androidx.compose.runtime.Composable -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable2 -import com.emergetools.snapshots.EmergeSnapshots -import com.emergetools.snapshots.compose.SnapshotVariantProvider -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -public class TestComposable2_GenSnapshot { - @get:Rule - public val composeRule: ComposeContentTestRule = createComposeRule() - - public val previewConfig: ComposePreviewSnapshotConfig = ComposePreviewSnapshotConfig(originalFqn - = "com.emergetools.android.standalone_preview_function_compiles_ok.TestComposable2") - - @get:Rule - public val snapshotRule: EmergeSnapshots = EmergeSnapshots() - - @Test - public fun TestComposable2_GenSnapshot() { - composeRule.setContent { - SnapshotVariantProvider(previewConfig) { - TestComposable2() - } - } - snapshotRule.take(composeRule, previewConfig) - } -} diff --git a/snapshots/snapshots-processor/build.gradle.kts b/snapshots/snapshots-processor/build.gradle.kts deleted file mode 100644 index 27244931..00000000 --- a/snapshots/snapshots-processor/build.gradle.kts +++ /dev/null @@ -1,122 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.text.SimpleDateFormat -import java.util.Date - -plugins { - alias(libs.plugins.kotlin.jvm) - alias(libs.plugins.grgit) - `java-library` - `maven-publish` - signing -} - -group = "com.emergetools.snapshots" -version = libs.versions.emerge.snapshots.get() - -var metaInfResDir = File(buildDir, "generated/emerge/") -var metaInfDestDir = File(metaInfResDir, "META-INF/com/emergetools/test/") - -java { - withJavadocJar() - withSourcesJar() - - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 -} - -tasks.withType { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() - } -} - -dependencies { - implementation(libs.kotlin.reflect) - implementation(libs.kotlinpoet) - implementation(libs.kotlinpoet.ksp) - implementation(libs.kotlinx.serialization) - implementation(libs.ksp.api) - - api(projects.snapshots.snapshotsShared) - api(projects.snapshots.snapshotsAnnotations) -} - -tasks.register("generateMetaInfVersion") { - doLast { - metaInfDestDir.mkdirs() - File(metaInfDestDir, "version.txt").writeText( - "version: $version" + - "\nbuild time: ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(Date())}" + - "\nrevision: ${grgit.head().id}" - ) - } -} - -afterEvaluate { - tasks.filter { task -> - task.name.startsWith("generate") && task.name.endsWith("Resources") - }.forEach { task -> - task.dependsOn(tasks.findByName("generateMetaInfVersion")) - } -} - -publishing { - repositories { - maven { - name = "SonatypeStaging" - url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") - } - } - - maven { - name = "SonatypeSnapshots" - url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") - credentials { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") - } - } - } - - publications { - create("release") { - artifactId = "snapshots-processor" - - afterEvaluate { - from(components["java"]) - } - - pom { - name.set("Emerge Tools Snapshots Annotation Processor") - description.set("Annotation processor for Emerge Composable Preview snapshots.") - url.set("https://www.emergetools.com") - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - scm { - url.set("https://github.com/EmergeTools/emerge-android") - } - developers { - developer { - id.set("ryan") - name.set("Ryan Brooks") - email.set("ryan@emergetools.com") - } - } - } - } - } -} - -signing { - val signingKey: String? by project - val signingPassword: String? by project - useInMemoryPgpKeys(signingKey, signingPassword) - sign(publishing.publications["release"]) -} diff --git a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/PreviewProcessor.kt b/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/PreviewProcessor.kt deleted file mode 100644 index 75d7742e..00000000 --- a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/PreviewProcessor.kt +++ /dev/null @@ -1,234 +0,0 @@ -package com.emergetools.snapshots.processor - -import com.emergetools.snapshots.annotations.IgnoreEmergeSnapshot -import com.emergetools.snapshots.processor.preview.ComposablePreviewSnapshotBuilder.addComposableSnapshotBlock -import com.emergetools.snapshots.processor.preview.ComposablePreviewSnapshotBuilder.addComposeRuleProperty -import com.emergetools.snapshots.processor.preview.ComposablePreviewSnapshotBuilder.addEmergeSnapshotRuleProperty -import com.emergetools.snapshots.processor.preview.ComposablePreviewSnapshotBuilder.addPreviewConfigProperty -import com.emergetools.snapshots.processor.utils.COMPOSE_PREVIEW_ANNOTATION_NAME -import com.emergetools.snapshots.processor.utils.functionsWithMultiPreviewAnnotations -import com.emergetools.snapshots.processor.utils.functionsWithPreviewAnnotation -import com.emergetools.snapshots.processor.utils.getSymbolsWithMultiPreviewAnnotations -import com.emergetools.snapshots.processor.utils.putOrAppend -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import com.google.devtools.ksp.KspExperimental -import com.google.devtools.ksp.isAnnotationPresent -import com.google.devtools.ksp.isInternal -import com.google.devtools.ksp.isPrivate -import com.google.devtools.ksp.processing.CodeGenerator -import com.google.devtools.ksp.processing.Dependencies -import com.google.devtools.ksp.processing.Resolver -import com.google.devtools.ksp.processing.SymbolProcessor -import com.google.devtools.ksp.processing.SymbolProcessorEnvironment -import com.google.devtools.ksp.processing.SymbolProcessorProvider -import com.google.devtools.ksp.symbol.KSAnnotated -import com.google.devtools.ksp.symbol.KSFunctionDeclaration -import com.squareup.kotlinpoet.AnnotationSpec -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.FileSpec -import com.squareup.kotlinpoet.FunSpec -import com.squareup.kotlinpoet.TypeSpec -import com.squareup.kotlinpoet.ksp.writeTo -import java.nio.file.Path -import kotlin.io.path.absolutePathString -import kotlin.io.path.createDirectories -import kotlin.io.path.moveTo -import kotlin.io.path.writeText - -/** - * A generally simple processor, finds all functions annotated with `@Preview`, filters to unique - * preview configurations and generates a test class that takes a snapshot of each. - */ -class PreviewProcessor( - private val environment: SymbolProcessorEnvironment, -) : SymbolProcessor { - - private val logger = environment.logger - - @OptIn(KspExperimental::class) - override fun process(resolver: Resolver): List { - val symbolsWithPreviewAnnotations = resolver - .getSymbolsWithAnnotation(COMPOSE_PREVIEW_ANNOTATION_NAME) - .toList() - val symbolsWithMultiPreviewAnnotations = resolver.getSymbolsWithMultiPreviewAnnotations(logger) - - val previewAnnotatedFunctions = symbolsWithPreviewAnnotations - .functionsWithPreviewAnnotation() - val multiPreviewAnnotatedFunctions = symbolsWithMultiPreviewAnnotations - .functionsWithMultiPreviewAnnotations(resolver, logger) - - val previewFunctionMap = buildMap { - putOrAppend(previewAnnotatedFunctions) - putOrAppend(multiPreviewAnnotatedFunctions) - } - - val codeGenerator = environment.codeGenerator - - val generatedPreviews = previewFunctionMap.entries.flatMap { previewFunction -> - logger.info("Generating snapshot tests for ${previewFunction.key.simpleName.asString()}") - - val function = previewFunction.key - val previewConfigs = previewFunction.value - // Intentionally skipping functions with parameters for now. - if (function.parameters.isNotEmpty()) { - logger.info("Skipping ${function.simpleName.asString()} because it has parameters") - return@flatMap emptyList() - } - - if (function.isPrivate()) { - logger.info("Skipping ${function.simpleName.asString()} as it is private") - return@flatMap emptyList() - } - - if (function.isInternal() && environment.options[INTERNAL_ENABLED_OPTION_NAME] != "true") { - logger.info("Skipping ${function.simpleName.asString()} as it is internal") - return@flatMap emptyList() - } - - if (function.isAnnotationPresent(IgnoreEmergeSnapshot::class)) { - logger.info( - "Skipping ${function.simpleName.asString()} as it's annotated with @IgnoreEmergeSnapshot" - ) - return@flatMap emptyList() - } - - generateEmergeSnapshotTest( - codeGenerator = codeGenerator, - previewFunction = function, - previewConfigs = previewConfigs, - ) - } - - /** - * KSP currently doesn't allow for generation across source sets, so we have to - * manually move files to a custom source directory that our plugin sets. - * - * This file move must take place as part of the process step to ensure no compilation takes - * place on the generated files while they're in the default KSP generated source set. - * - * Relevant KSP Issues: - * - https://github.com/google/ksp/issues/799 - * - https://github.com/google/ksp/issues/1037 - */ - val outputSrcDir = environment.options[OUTPUT_SRC_DIR_OPTION_NAME] - if (outputSrcDir != null) { - codeGenerator.generatedFile.forEach { generatedFile -> - if (!generatedPreviews.contains(generatedFile.nameWithoutExtension)) { - logger.info( - "Skipping ${generatedFile.nameWithoutExtension} move as it was not generated by our plugin" - ) - return@forEach - } - moveFile(generatedFile.toPath(), outputSrcDir) - } - } - return emptyList() - } - - private fun generateEmergeSnapshotTest( - codeGenerator: CodeGenerator, - previewFunction: KSFunctionDeclaration, - previewConfigs: List, - ): List { - return previewConfigs.map { previewConfig -> - val packageName = previewFunction.containingFile!!.packageName.asString() - val functionName = previewFunction.simpleName.asString() - - val testClassName = getTestClassName(functionName, previewConfig) - val testAnnotation = AnnotationSpec.builder(JUNIT_TEST_ANNOTATION_CLASSNAME).build() - - val testFunctionSpec = FunSpec.builder("${functionName}_GenSnapshot").apply { - addAnnotation(testAnnotation) - addComposableSnapshotBlock(functionName) - }.build() - - val testRunnerAnnotation = AnnotationSpec.builder(ClassName("org.junit.runner", "RunWith")) - .addMember("%T::class", ANDROID_JUNIT_RUNNER_CLASSNAME) - .build() - - val typeSpec = TypeSpec.classBuilder(testClassName).apply { - addFunction(testFunctionSpec) - addAnnotation(testRunnerAnnotation) - addComposeRuleProperty() - addPreviewConfigProperty(previewConfig) - addEmergeSnapshotRuleProperty() - }.build() - - val fileSpec = FileSpec.builder(packageName, testClassName).apply { - addType(typeSpec) - addImport("androidx.compose.runtime", "Composable") - previewFunction.qualifiedName?.asString()?.let { - addImport(previewFunction.packageName.asString(), functionName) - } - addImport("com.emergetools.snapshots.compose", "SnapshotVariantProvider") - }.build() - - fileSpec.writeTo(codeGenerator, Dependencies(false)) - val filename = fileSpec.name - logger.info("Generated snapshot test: $filename") - fileSpec.name - } - } - - private fun moveFile( - path: Path, - outputDir: String, - ) { - val pathAfterKotlin = path.absolutePathString().substringAfter("kotlin") - - val newPathFile = Path.of(outputDir, pathAfterKotlin) - logger.info("Moving generated snapshot test from $path to $newPathFile") - path.moveTo(newPathFile.apply { parent?.createDirectories() }, true) - - /** - * Kotlin compilation will fail if test dependencies aren't available for the test class. - * Deleting these files also won't work as KSP && Kotlin compilation seem to be closely tied - * together. TODO: Ryan to investigate further to see if we can delete these. - * - * In our generated snapshot test cases, without deleting the file, the main source set would - * need to include test dependencies, which is not ideal. - * - * To avoid this, we'll just write a placeholder file that will ensure Kotlin compilation - * succeeds and won't have any direct impact on the main source set's build. - */ - path.writeText( - """ - // This file has been moved to $newPathFile - // This file acts as a placeholder and will have no effect on the build. - """.trimIndent(), - ) - } - - /** - * Helper to create a unique testClass name. We do so by appending the hashcode of the Preview - * config if the config is not a default preview, to ensure test names are unique. - */ - private fun getTestClassName( - composableFunctionName: String, - previewConfig: ComposePreviewSnapshotConfig, - ): String { - var testFunctionName = composableFunctionName - if (!previewConfig.isDefault()) { - // Function name can use hashcode as the saved image key will be - // the same regardless of test name. - testFunctionName = "${testFunctionName}_${previewConfig.hashCode()}" - } - return "${testFunctionName}_GenSnapshot" - } - - companion object { - private const val OUTPUT_SRC_DIR_OPTION_NAME = "emerge.outputDir" - private const val INTERNAL_ENABLED_OPTION_NAME = "emerge.experimentalInternalEnabled" - - private val ANDROID_JUNIT_RUNNER_CLASSNAME = - ClassName("androidx.test.ext.junit.runners", "AndroidJUnit4") - private val JUNIT_TEST_ANNOTATION_CLASSNAME = ClassName("org.junit", "Test") - } -} - -class PreviewProcessorProvider : SymbolProcessorProvider { - - override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor { - return PreviewProcessor(environment) - } -} diff --git a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/preview/ComposablePreviewSnapshotBuilder.kt b/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/preview/ComposablePreviewSnapshotBuilder.kt deleted file mode 100644 index d12e32e0..00000000 --- a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/preview/ComposablePreviewSnapshotBuilder.kt +++ /dev/null @@ -1,91 +0,0 @@ -package com.emergetools.snapshots.processor.preview - -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import com.squareup.kotlinpoet.AnnotationSpec -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.CodeBlock -import com.squareup.kotlinpoet.FunSpec -import com.squareup.kotlinpoet.PropertySpec -import com.squareup.kotlinpoet.TypeSpec - -object ComposablePreviewSnapshotBuilder { - private const val PREVIEW_CONFIG_PROPERTY_NAME = "previewConfig" - private const val SNAPSHOT_RULE_PROPERTY_NAME = "snapshotRule" - private const val COMPOSE_RULE_PROPERTY_NAME = "composeRule" - private val SNAPSHOT_VARIANT_PROVIDER_CLASSNAME = ClassName( - "com.emergetools.snapshots.compose", - "SnapshotVariantProvider" - ) - private val EMERGE_SNAPSHOTS_RULE_CLASSNAME = - ClassName("com.emergetools.snapshots", "EmergeSnapshots") - private val EMERGE_COMPOSE_PREVIEW_SNAPSHOT_CONFIG_CLASSNAME = - ClassName("com.emergetools.snapshots.shared", "ComposePreviewSnapshotConfig") - - private val COMPOSE_CONTENT_TEST_RULE_CLASSNAME = - ClassName("androidx.compose.ui.test.junit4", "ComposeContentTestRule") - private val COMPOSE_RULE_CREATOR_CLASSNAME = - ClassName("androidx.compose.ui.test.junit4", "createComposeRule") - - private val JUNIT_RULE_ANNOTATION_CLASSNAME = ClassName("org.junit", "Rule") - - private val ruleAnnotation by lazy { - AnnotationSpec.builder(JUNIT_RULE_ANNOTATION_CLASSNAME) - .useSiteTarget(AnnotationSpec.UseSiteTarget.GET) - .build() - } - - fun TypeSpec.Builder.addPreviewConfigProperty(config: ComposePreviewSnapshotConfig) { - val configInitializer = mutableListOf().apply { - add("originalFqn = \"${config.originalFqn}\"") - config.name?.let { add("name = \"$it\"") } - config.group?.let { add("group = \"$it\"") } - config.uiMode?.let { add("uiMode = $it") } - config.locale?.let { add("locale = \"$it\"") } - config.fontScale?.let { add("fontScale = ${it}f") } - }.joinToString(",\n") - - val property = PropertySpec.builder( - name = PREVIEW_CONFIG_PROPERTY_NAME, - type = EMERGE_COMPOSE_PREVIEW_SNAPSHOT_CONFIG_CLASSNAME - ).initializer("%T($configInitializer)", EMERGE_COMPOSE_PREVIEW_SNAPSHOT_CONFIG_CLASSNAME) - .build() - - addProperty(property) - } - - fun TypeSpec.Builder.addComposeRuleProperty() { - val composeRuleProperty = - PropertySpec.builder(COMPOSE_RULE_PROPERTY_NAME, COMPOSE_CONTENT_TEST_RULE_CLASSNAME).apply { - initializer("%T()", COMPOSE_RULE_CREATOR_CLASSNAME) - addAnnotation(ruleAnnotation) - }.build() - - addProperty(composeRuleProperty) - } - - fun TypeSpec.Builder.addEmergeSnapshotRuleProperty() { - val snapshotsRuleProperty = - PropertySpec.builder(SNAPSHOT_RULE_PROPERTY_NAME, EMERGE_SNAPSHOTS_RULE_CLASSNAME).apply { - initializer("%T()", EMERGE_SNAPSHOTS_RULE_CLASSNAME) - addAnnotation(ruleAnnotation) - }.build() - addProperty(snapshotsRuleProperty) - } - - /** - * Builds a compositionLocal that sets the Preview configuration for the passed snapshot as well - * as the snapshotting code. - */ - fun FunSpec.Builder.addComposableSnapshotBlock(functionName: String) { - val codeBlock = CodeBlock.builder().apply { - addStatement("$COMPOSE_RULE_PROPERTY_NAME.setContent {") - addStatement(" %T($PREVIEW_CONFIG_PROPERTY_NAME) {", SNAPSHOT_VARIANT_PROVIDER_CLASSNAME) - addStatement(" $functionName()") - addStatement(" }") - addStatement("}") - addStatement("$SNAPSHOT_RULE_PROPERTY_NAME.take(composeRule, $PREVIEW_CONFIG_PROPERTY_NAME)") - }.build() - - addCode(codeBlock) - } -} diff --git a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/preview/ComposePreviewUtils.kt b/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/preview/ComposePreviewUtils.kt deleted file mode 100644 index 367c78d2..00000000 --- a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/preview/ComposePreviewUtils.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.emergetools.snapshots.processor.preview - -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import com.google.devtools.ksp.symbol.KSAnnotation -import com.google.devtools.ksp.symbol.KSFunctionDeclaration -import com.google.devtools.ksp.symbol.KSValueArgument - -object ComposePreviewUtils { - - private const val PREVIEW_ANNOTATION_SIMPLE_NAME = "Preview" - private const val PREVIEW_NAME_ARGUMENT_NAME = "name" - private const val PREVIEW_GROUP_ARGUMENT_NAME = "group" - private const val PREVIEW_LOCALE_ARGUMENT_NAME = "locale" - private const val PREVIEW_FONT_SCALE_ARGUMENT_NAME = "fontScale" - private const val PREVIEW_UI_MODE_ARGUMENT_NAME = "uiMode" - - /** - * Simple helper to get unique preview annotations for a given function. - * A unique preview annotation is one that has a unique combination of name, group, locale, - * fontScale and uiMode, the current supported arguments for Emerge snapshots of the @Preview - * annotation. - */ - fun getUniqueSnapshotConfigsFromPreviewAnnotations( - previewFunction: KSFunctionDeclaration, - ): List = previewFunction.annotations.filter { - it.shortName.asString() == PREVIEW_ANNOTATION_SIMPLE_NAME - }.map { composePreviewShapshotConfigFromPreviewAnnotation(previewFunction, it) } - .distinct() - .toList() - - fun getUniqueSnapshotConfigsFromMultiPreviewAnnotation( - annotations: List, - previewFunction: KSFunctionDeclaration, - ): List { - return annotations.map { - composePreviewShapshotConfigFromPreviewAnnotation(previewFunction, it) - }.distinct() - .toList() - } - - private fun composePreviewShapshotConfigFromPreviewAnnotation( - previewFunction: KSFunctionDeclaration, - previewAnnotation: KSAnnotation, - ): ComposePreviewSnapshotConfig { - // We need to explicitly check for nulls here so we don't set a default unintentionally and - // so we don't default to the Preview annotation default empty values. - val nameArgument = previewAnnotation.argumentForName(PREVIEW_NAME_ARGUMENT_NAME) - val nameValue = - nameArgument?.value?.takeIf { (it as? String)?.isNotBlank() == true }?.toString() - - val groupArgument = previewAnnotation.argumentForName(PREVIEW_GROUP_ARGUMENT_NAME) - val groupValue = - groupArgument?.value?.takeIf { (it as? String)?.isNotBlank() == true }?.toString() - - val localeArgument = previewAnnotation.argumentForName(PREVIEW_LOCALE_ARGUMENT_NAME) - val localeValue = - localeArgument?.value?.takeIf { (it as? String)?.isNotBlank() == true }?.toString() - - val fontScaleArgument = previewAnnotation.argumentForName(PREVIEW_FONT_SCALE_ARGUMENT_NAME) - val fontScaleValue = fontScaleArgument?.value?.takeIf { - (it as? Float) != 1.0f - }?.let { it as Float } - - val uiModeArgument = previewAnnotation.argumentForName(PREVIEW_UI_MODE_ARGUMENT_NAME) - val uiModeValue = uiModeArgument?.value?.takeIf { (it as? Int) != 0 }?.let { it as Int } - - val originalFqn = previewFunction.qualifiedName?.asString() - ?: "${previewFunction.packageName.asString()}.${previewFunction.simpleName.asString()}}" - - return ComposePreviewSnapshotConfig( - originalFqn = originalFqn, - name = nameValue, - group = groupValue, - locale = localeValue, - fontScale = fontScaleValue, - uiMode = uiModeValue, - ) - } - - private fun KSAnnotation.argumentForName(name: String): KSValueArgument? { - return arguments.firstOrNull { it.name?.asString() == name } - } -} diff --git a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/utils/MapUtils.kt b/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/utils/MapUtils.kt deleted file mode 100644 index b3325896..00000000 --- a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/utils/MapUtils.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.emergetools.snapshots.processor.utils - -fun MutableMap>.putOrAppend( - key: K, - values: List, - appendOnlyDistinct: Boolean = true, -) = get(key)?.let { value -> - val newList = value + values - put(key, if (appendOnlyDistinct) newList.distinct() else newList) -} ?: put(key, values) - -fun MutableMap>.putOrAppend(map: Map>) { - map.forEach(::putOrAppend) -} diff --git a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/utils/PreviewFinderUtils.kt b/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/utils/PreviewFinderUtils.kt deleted file mode 100644 index 69431364..00000000 --- a/snapshots/snapshots-processor/src/main/kotlin/com/emergetools/snapshots/processor/utils/PreviewFinderUtils.kt +++ /dev/null @@ -1,143 +0,0 @@ -package com.emergetools.snapshots.processor.utils - -import com.emergetools.snapshots.processor.preview.ComposePreviewUtils.getUniqueSnapshotConfigsFromMultiPreviewAnnotation -import com.emergetools.snapshots.processor.preview.ComposePreviewUtils.getUniqueSnapshotConfigsFromPreviewAnnotations -import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig -import com.google.devtools.ksp.processing.KSPLogger -import com.google.devtools.ksp.processing.Resolver -import com.google.devtools.ksp.symbol.KSAnnotated -import com.google.devtools.ksp.symbol.KSAnnotation -import com.google.devtools.ksp.symbol.KSClassDeclaration -import com.google.devtools.ksp.symbol.KSFunctionDeclaration - -const val COMPOSE_PREVIEW_ANNOTATION_NAME = - "androidx.compose.ui.tooling.preview.Preview" - -fun List.functionsWithPreviewAnnotation(): Map> { - return filterIsInstance() - .associateWith { getUniqueSnapshotConfigsFromPreviewAnnotations(it) } -} - -fun List.functionsWithMultiPreviewAnnotations( - resolver: Resolver, - logger: KSPLogger, -): Map> { - val uniqueSnapshotConfigs = filterIsInstance() - .map { function -> - val allPreviewAnnotations = function.annotations.flatMap { - resolver.findAllDirectOrTransitivePreviewAnnotations( - annotation = it, - logger = logger, - ) - }.toList() - function to getUniqueSnapshotConfigsFromMultiPreviewAnnotation( - annotations = allPreviewAnnotations, - previewFunction = function, - ) - } - - // The same function declaration can show up multiple times, so ensure the values are merged together - val mergedConfigs = mutableMapOf>() - uniqueSnapshotConfigs.forEach { - logger.info( - "Found multipreview function: ${it.first.simpleName.asString()} with configs: ${it.second.joinToString()}" - ) - mergedConfigs.putOrAppend(it.first, it.second) - } - - return mergedConfigs -} - -fun Resolver.getSymbolsWithMultiPreviewAnnotations(logger: KSPLogger): List { - return getMultiPreviewAnnotations(logger) - .mapNotNull { annotation -> - val annotationQN = annotation.annotationType.resolve().declaration.qualifiedName - annotationQN?.let { getSymbolsWithAnnotation(it.asString()) } - } - .flatMap { it } -} - -fun Resolver.getMultiPreviewAnnotations(logger: KSPLogger): List { - return getAllFiles() - .flatMap { it.declarations } - .flatMap { it.annotations } - .toSet() - .filter { - val annotationQN = it.annotationType.resolve().declaration.qualifiedName - val annotationClassDecl = annotationQN?.let { qualifiedName -> - getClassDeclarationByName(qualifiedName) - } - annotationClassDecl?.let { classDecl -> - val hasPreviewAnnotation = hasDirectOrTransitivePreviewAnnotation(classDecl) - logger.info( - "Checking annotation for preview annotation: ${classDecl.qualifiedName?.asString()}, $hasPreviewAnnotation" - ) - hasPreviewAnnotation - } ?: false - } - .toList() - .sortedBy { it.shortName.asString() } -} - -fun Resolver.hasDirectOrTransitivePreviewAnnotation( - declaration: KSAnnotated, - seenAnnotations: MutableSet = mutableSetOf(), -): Boolean { - if (declaration in seenAnnotations) { - return false - } - - val hasPreviewAnnotation = declaration.annotations.any { - it.annotationType.resolve().declaration.qualifiedName?.asString() == - COMPOSE_PREVIEW_ANNOTATION_NAME - } - if (hasPreviewAnnotation) { - return true - } - - seenAnnotations.add(declaration) - - return declaration.annotations.any { annotation -> - val annotationQualifiedName = annotation.annotationType.resolve().declaration.qualifiedName - val classDeclaration = annotationQualifiedName?.let { getClassDeclarationByName(it) } - classDeclaration?.let { - hasDirectOrTransitivePreviewAnnotation(classDeclaration, seenAnnotations) - } ?: false - } -} - -fun Resolver.findAllDirectOrTransitivePreviewAnnotations( - annotation: KSAnnotation, - seenAnnotations: MutableSet = mutableSetOf(), - logger: KSPLogger, -): List { - val classDeclaration = annotation.annotationType.resolve().declaration.qualifiedName?.let { - getClassDeclarationByName(it) - } - val isPreviewAnnotation = - classDeclaration?.qualifiedName?.asString() == COMPOSE_PREVIEW_ANNOTATION_NAME - - // Annotations can recursively reference each other so be sure to have a base recursion case - // @Preview itself can't have a recursive relation so we can exclude them from our check - if (classDeclaration == null || (classDeclaration in seenAnnotations && !isPreviewAnnotation)) { - return emptyList() - } - - logger.info( - "Found preview or multipreview annotation: ${classDeclaration.qualifiedName?.asString()}" - ) - seenAnnotations.add(classDeclaration) - - val currentPreviewAnnotations = - if (classDeclaration.qualifiedName?.asString() == COMPOSE_PREVIEW_ANNOTATION_NAME) { - listOf(annotation) - } else { - emptyList() - } - - val nestedPreviewAnnotations = classDeclaration.annotations.flatMap { - findAllDirectOrTransitivePreviewAnnotations(it, seenAnnotations, logger) - } - - return currentPreviewAnnotations + nestedPreviewAnnotations -} diff --git a/snapshots/snapshots-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider b/snapshots/snapshots-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider deleted file mode 100644 index e30b5742..00000000 --- a/snapshots/snapshots-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider +++ /dev/null @@ -1 +0,0 @@ -com.emergetools.snapshots.processor.PreviewProcessorProvider \ No newline at end of file