-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Showkase + Paparazzi artifact to automate screenshot test…
…ing (#294) * Stash changes * Working version * Expose an artifact that auto generates Paparazzi test class using Showkase * Generate snapshots with default setup * Revert change in gradle.properties * Add validations for PaparazziShowkaseScreenshotTest * Fix detekt issues * Fix refactor error * Delay check of Paparazzi classes in validation for backward compatibility * Fix detekt issue * Fix lint error * Fix more lint errors * Attempt to fix duplicate class issue on build * Use correct version of paparazzi * Fix error * Add a compileOnly dependency to paparazzi * Added tests and documentation * Update paparazzi screenshots after name change
- Loading branch information
Showing
245 changed files
with
1,551 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...plementing_different_interface_throws_compilation_error/input/MyShowkaseScreenshotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
import android.graphics.Bitmap | ||
import com.airbnb.android.showkase.annotation.ShowkaseScreenshot | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.PaparazziShowkaseScreenshotTest | ||
|
||
@ShowkaseScreenshot(rootShowkaseClass = TestShowkaseRoot::class) | ||
public abstract class MyScreenshotTest: PaparazziShowkaseScreenshotTest { | ||
} |
8 changes: 8 additions & 0 deletions
8
...bject_implementing_different_interface_throws_compilation_error/input/TestShowkaseRoot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
import com.airbnb.android.showkase.annotation.ShowkaseRoot | ||
import com.airbnb.android.showkase.annotation.ShowkaseRootModule | ||
|
||
@ShowkaseRoot | ||
public class TestShowkaseRoot: ShowkaseRootModule { | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...object_implementing_different_interface_throws_compilation_error/input/testComposables.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.airbnb.android.showkase.annotation.ShowkaseColor | ||
import com.airbnb.android.showkase.annotation.ShowkaseComposable | ||
import com.airbnb.android.showkase.annotation.ShowkaseTypography | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
|
||
@ShowkaseComposable(name = "name1", group = "group1") | ||
@Composable | ||
public fun TestComposable1() { | ||
|
||
} | ||
|
||
@ShowkaseComposable(name = "name2", group = "group2") | ||
@Composable | ||
public fun TestComposable2() { | ||
|
||
} | ||
|
||
@ShowkaseColor("name", "color") | ||
public val red: Color = Color(0xffff0000) | ||
|
||
@ShowkaseTypography("name", "typography") | ||
public val title: TextStyle = TextStyle( | ||
fontFamily = FontFamily.Cursive | ||
) |
7 changes: 7 additions & 0 deletions
7
...tTest_but_not_companion_object_throws_compilation_error/input/MyShowkaseScreenshotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import android.graphics.Bitmap | ||
import com.airbnb.android.showkase.annotation.ShowkaseScreenshot | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.PaparazziShowkaseScreenshotTest | ||
|
||
@ShowkaseScreenshot(rootShowkaseClass = TestShowkaseRoot::class) | ||
public abstract class MyScreenshotTest: PaparazziShowkaseScreenshotTest { | ||
} |
9 changes: 9 additions & 0 deletions
9
...creenshotTest_but_not_companion_object_throws_compilation_error/input/TestShowkaseRoot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import com.airbnb.android.showkase.annotation.ShowkaseComposable | ||
import androidx.compose.runtime.Composable | ||
import com.airbnb.android.showkase.annotation.ShowkaseRoot | ||
import com.airbnb.android.showkase.annotation.ShowkaseRootModule | ||
|
||
@ShowkaseRoot | ||
public class TestShowkaseRoot: ShowkaseRootModule { | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...ScreenshotTest_but_not_companion_object_throws_compilation_error/input/testComposables.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import androidx.compose.runtime.Composable | ||
import com.airbnb.android.showkase.annotation.ShowkaseColor | ||
import com.airbnb.android.showkase.annotation.ShowkaseComposable | ||
import com.airbnb.android.showkase.annotation.ShowkaseTypography | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
|
||
@ShowkaseComposable(name = "name1", group = "group1") | ||
@Composable | ||
public fun TestComposable1() { | ||
|
||
} | ||
|
||
@ShowkaseComposable(name = "name2", group = "group2") | ||
@Composable | ||
public fun TestComposable2() { | ||
|
||
} | ||
|
||
@ShowkaseColor("name", "color") | ||
public val red: Color = Color(0xffff0000) | ||
|
||
@ShowkaseTypography("name", "typography") | ||
public val title: TextStyle = TextStyle( | ||
fontFamily = FontFamily.Cursive | ||
) |
11 changes: 11 additions & 0 deletions
11
...generates_paparazzi_screenshot_test_for_all_UI_elements/input/MyShowkaseScreenshotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
import android.graphics.Bitmap | ||
import com.airbnb.android.showkase.annotation.ShowkaseScreenshot | ||
import com.airbnb.android.showkase.screenshot.testing.ShowkaseScreenshotTest | ||
import com.airbnb.android.showkase.screenshot.testing.ShowkaseScreenshotType | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.PaparazziShowkaseScreenshotTest | ||
|
||
@ShowkaseScreenshot(rootShowkaseClass = TestShowkaseRoot::class) | ||
public abstract class MyScreenshotTest: PaparazziShowkaseScreenshotTest { | ||
public companion object: PaparazziShowkaseScreenshotTest.CompanionObject | ||
} |
10 changes: 10 additions & 0 deletions
10
...hotTest_generates_paparazzi_screenshot_test_for_all_UI_elements/input/TestShowkaseRoot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
import com.airbnb.android.showkase.annotation.ShowkaseComposable | ||
import androidx.compose.runtime.Composable | ||
import com.airbnb.android.showkase.annotation.ShowkaseRoot | ||
import com.airbnb.android.showkase.annotation.ShowkaseRootModule | ||
|
||
@ShowkaseRoot | ||
public class TestShowkaseRoot: ShowkaseRootModule { | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...shotTest_generates_paparazzi_screenshot_test_for_all_UI_elements/input/testComposables.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.airbnb.android.showkase.annotation.ShowkaseColor | ||
import com.airbnb.android.showkase.annotation.ShowkaseComposable | ||
import com.airbnb.android.showkase.annotation.ShowkaseTypography | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
|
||
@ShowkaseComposable(name = "name1", group = "group1") | ||
@Composable | ||
public fun TestComposable1() { | ||
|
||
} | ||
|
||
@ShowkaseComposable(name = "name2", group = "group2") | ||
@Composable | ||
public fun TestComposable2() { | ||
|
||
} | ||
|
||
@ShowkaseColor("name", "color") | ||
public val red: Color = Color(0xffff0000) | ||
|
||
@ShowkaseTypography("name", "typography") | ||
public val title: TextStyle = TextStyle( | ||
fontFamily = FontFamily.Cursive | ||
) |
63 changes: 63 additions & 0 deletions
63
...azzi_screenshot_test_for_all_UI_elements/output/MyScreenshotTest_PaparazziShowkaseTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// This is an auto-generated file. Please do not edit/modify this file. | ||
import androidx.compose.ui.unit.LayoutDirection | ||
import app.cash.paparazzi.Paparazzi | ||
import com.airbnb.android.showkase.models.Showkase | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.ColorPaparazziShowkaseTestPreview | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.ComponentPaparazziShowkaseTestPreview | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.PaparazziShowkaseDeviceConfig | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.PaparazziShowkaseTestPreview | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.PaparazziShowkaseUIMode | ||
import com.airbnb.android.showkase.screenshot.testing.paparazzi.TypographyPaparazziShowkaseTestPreview | ||
import com.google.testing.junit.testparameterinjector.TestParameter | ||
import com.google.testing.junit.testparameterinjector.TestParameter.TestParameterValuesProvider | ||
import com.google.testing.junit.testparameterinjector.TestParameterInjector | ||
import getMetadata | ||
import kotlin.Unit | ||
import kotlin.collections.List | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(TestParameterInjector::class) | ||
public class MyScreenshotTest_PaparazziShowkaseTest : MyScreenshotTest() { | ||
@get:Rule | ||
public val paparazzi: Paparazzi = providePaparazzi() | ||
|
||
@Test | ||
public fun test_previews( | ||
@TestParameter(valuesProvider = PaparazziShowkasePreviewProvider::class) | ||
elementPreview: PaparazziShowkaseTestPreview, | ||
@TestParameter(valuesProvider = PaparazziShowkaseDeviceConfigProvider::class) | ||
config: PaparazziShowkaseDeviceConfig, | ||
@TestParameter(valuesProvider = PaparazziShowkaseLayoutDirectionProvider::class) | ||
direction: LayoutDirection, | ||
@TestParameter(valuesProvider = PaparazziShowkaseUIModeProvider::class) | ||
uiMode: PaparazziShowkaseUIMode, | ||
): Unit { | ||
paparazzi.unsafeUpdateConfig(config.deviceConfig.copy(softButtons = false)) | ||
takePaparazziSnapshot(paparazzi, elementPreview, direction, uiMode) | ||
} | ||
|
||
private object PaparazziShowkasePreviewProvider : TestParameter.TestParameterValuesProvider { | ||
public override fun provideValues(): List<PaparazziShowkaseTestPreview> { | ||
val metadata = Showkase.getMetadata() | ||
val components = metadata.componentList.map(::ComponentPaparazziShowkaseTestPreview) | ||
val colors = metadata.colorList.map(::ColorPaparazziShowkaseTestPreview) | ||
val typography = metadata.typographyList.map(::TypographyPaparazziShowkaseTestPreview) | ||
return components + colors + typography | ||
} | ||
} | ||
|
||
private object PaparazziShowkaseDeviceConfigProvider : TestParameter.TestParameterValuesProvider { | ||
public override fun provideValues(): List<PaparazziShowkaseDeviceConfig> = deviceConfigs() | ||
} | ||
|
||
private object PaparazziShowkaseLayoutDirectionProvider : | ||
TestParameter.TestParameterValuesProvider { | ||
public override fun provideValues(): List<LayoutDirection> = layoutDirections() | ||
} | ||
|
||
private object PaparazziShowkaseUIModeProvider : TestParameter.TestParameterValuesProvider { | ||
public override fun provideValues(): List<PaparazziShowkaseUIMode> = uiModes() | ||
} | ||
} |
Oops, something went wrong.