Skip to content

Commit

Permalink
Add stacked multipreview test
Browse files Browse the repository at this point in the history
  • Loading branch information
rbro112 committed Sep 29, 2023
1 parent 8976789 commit 301b84a
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ 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()
Expand Down Expand Up @@ -54,6 +59,11 @@ class PreviewProcessorTest {
compileInputsAndVerifyOutputs()
}

@Test
fun `stacked multipreview five total previews produces five snapshots`() {
compileInputsAndVerifyOutputs()
}

private fun compileInputs(
options: MutableMap<String, String> = mutableMapOf(),
onCompilation: (compilation: KotlinCompilation, result: KotlinCompilation.Result) -> Unit,
Expand Down Expand Up @@ -142,9 +152,4 @@ class PreviewProcessorTest {
val className = testNameRule.className.substringAfterLast(".")
return File(rootResourcesDir, "$className/$methodName")
}

companion object {
// Set to true to overwrite the test outputs with those generated from tests above.
const val UPDATE_TEST_OUTPUTS = false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input

@FontScaleVariants
@UIModeVariants
annotation class PreviewVariants
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package PreviewProcessorTest.stacked_multipreview_five_total_previews_produces_five_snapshots.input

import androidx.compose.runtime.Composable

@PreviewVariants
@Composable
fun StackedMultiPreviewComposable() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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)
}
}

0 comments on commit 301b84a

Please sign in to comment.