Skip to content

Commit

Permalink
Cleanup preview param
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-powell committed Aug 29, 2024
1 parent 107acd3 commit 3b5486e
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 415 deletions.
9 changes: 0 additions & 9 deletions buildSrc/build.gradle

This file was deleted.

9 changes: 0 additions & 9 deletions buildSrc/settings.gradle

This file was deleted.

114 changes: 0 additions & 114 deletions gradle/aarAsJar.gradle

This file was deleted.

1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ bytebuddy-agent = { module = "net.bytebuddy:byte-buddy-agent", version.ref = "by
bytebuddy-core = { module = "net.bytebuddy:byte-buddy", version.ref = "bytebuddy" }

compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" }
composeUi-foundation = { module = "androidx.compose.foundation:foundation" }
composeUi-material = { module = "androidx.compose.material:material", version.ref = "compose" }
composeUi-uiTooling = { module = "androidx.compose.ui:ui-tooling" }

Expand Down
39 changes: 39 additions & 0 deletions paparazzi-annotations/api/paparazzi-annotations.api
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
public abstract interface annotation class app/cash/paparazzi/annotations/Paparazzi : java/lang/annotation/Annotation {
}

public abstract interface class app/cash/paparazzi/annotations/PaparazziPreviewData {
}

public final class app/cash/paparazzi/annotations/PaparazziPreviewData$Default : app/cash/paparazzi/annotations/PaparazziPreviewData {
public static final field $stable I
public fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function2;)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Lkotlin/jvm/functions/Function2;
public final fun copy (Ljava/lang/String;Lkotlin/jvm/functions/Function2;)Lapp/cash/paparazzi/annotations/PaparazziPreviewData$Default;
public static synthetic fun copy$default (Lapp/cash/paparazzi/annotations/PaparazziPreviewData$Default;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lapp/cash/paparazzi/annotations/PaparazziPreviewData$Default;
public fun equals (Ljava/lang/Object;)Z
public final fun getComposable ()Lkotlin/jvm/functions/Function2;
public final fun getSnapshotName ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class app/cash/paparazzi/annotations/PaparazziPreviewData$Empty : app/cash/paparazzi/annotations/PaparazziPreviewData {
public static final field $stable I
public static final field INSTANCE Lapp/cash/paparazzi/annotations/PaparazziPreviewData$Empty;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class app/cash/paparazzi/annotations/PaparazziPreviewData$Error : app/cash/paparazzi/annotations/PaparazziPreviewData {
public static final field $stable I
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;Ljava/lang/String;)Lapp/cash/paparazzi/annotations/PaparazziPreviewData$Error;
public static synthetic fun copy$default (Lapp/cash/paparazzi/annotations/PaparazziPreviewData$Error;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lapp/cash/paparazzi/annotations/PaparazziPreviewData$Error;
public fun equals (Ljava/lang/Object;)Z
public final fun getMessage ()Ljava/lang/String;
public final fun getSnapshotName ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

6 changes: 2 additions & 4 deletions paparazzi-annotations/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
apply plugin: 'com.vanniktech.maven.publish'
apply plugin: 'aar2jar'

aar2jar.configureForConfiguration("compileOnly")

dependencies {
compileOnlyAarAsJar libs.compose.runtime
compileOnly libs.compose.runtime
}
1 change: 1 addition & 0 deletions paparazzi-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ buildConfig {
tasks.withType(Test).configureEach {
dependsOn(':paparazzi:publishMavenPublicationToProjectLocalMavenRepository')
dependsOn(':paparazzi-annotations:publishMavenPublicationToProjectLocalMavenRepository')
dependsOn(':paparazzi-preview-test-junit:publishMavenPublicationToProjectLocalMavenRepository')
}

// When cleaning this project, we also want to clean the test projects.
Expand Down
25 changes: 25 additions & 0 deletions paparazzi-preview-test-junit/api/paparazzi-preview-test-junit.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public final class app/cash/paparazzi/preview/ComposableSingletons$SnapshotKt {
public static final field INSTANCE Lapp/cash/paparazzi/preview/ComposableSingletons$SnapshotKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$paparazzi_preview_test_junit ()Lkotlin/jvm/functions/Function3;
}

public final class app/cash/paparazzi/preview/ComposableSingletons$UtilsKt {
public static final field INSTANCE Lapp/cash/paparazzi/preview/ComposableSingletons$UtilsKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$paparazzi_preview_test_junit ()Lkotlin/jvm/functions/Function3;
}

public class app/cash/paparazzi/preview/PaparazziValuesProvider : com/google/testing/junit/testparameterinjector/TestParameter$TestParameterValuesProvider {
public static final field $stable I
public fun <init> (Ljava/util/List;)V
public fun provideValues ()Ljava/util/List;
}

public final class app/cash/paparazzi/preview/SnapshotKt {
public static final fun snapshot (Lapp/cash/paparazzi/Paparazzi;Lapp/cash/paparazzi/annotations/PaparazziPreviewData;Ljava/lang/String;Lkotlin/jvm/functions/Function3;)V
public static synthetic fun snapshot$default (Lapp/cash/paparazzi/Paparazzi;Lapp/cash/paparazzi/annotations/PaparazziPreviewData;Ljava/lang/String;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)V
}

10 changes: 10 additions & 0 deletions paparazzi-preview-test-junit/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
apply plugin: 'com.vanniktech.maven.publish'

dependencies {
compileOnly libs.compose.runtime
implementation projects.paparazzi
implementation projects.paparazziAnnotations
api libs.testParameterInjector
}
4 changes: 4 additions & 0 deletions paparazzi-preview-test-junit/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POM_ARTIFACT_ID=paparazzi-preview-test-junit
POM_NAME=Paparazzi Preview Test JUnit
POM_DESCRIPTION=Adds helpers to use in code generated from Paparazzi Gradle Plugin for composables annotated with @Paparazzi
POM_PACKAGING=jar
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright Square, Inc.
package app.cash.paparazzi.preview

import androidx.compose.runtime.Composable
import app.cash.paparazzi.Paparazzi
import app.cash.paparazzi.annotations.PaparazziPreviewData
import com.google.testing.junit.testparameterinjector.TestParameter.TestParameterValuesProvider

/**
* Take a snapshot of the given [previewData].
*/
public fun Paparazzi.snapshot(
previewData: PaparazziPreviewData,
name: String? = null,
wrapper: @Composable (@Composable () -> Unit) -> Unit = { it() }
) {
when (previewData) {
is PaparazziPreviewData.Default -> snapshotDefault(previewData, name, wrapper)
is PaparazziPreviewData.Empty -> Unit
is PaparazziPreviewData.Error -> error(previewData.message)
}
}

/**
* A `@TestParameter` values provider for the given [annotations].
*
* Example usage:
* ```
* private class ValuesProvider : PaparazziValuesProvider(paparazziAnnotations)
* ```
*/
public open class PaparazziValuesProvider(
private val annotations: List<PaparazziPreviewData>
) : TestParameterValuesProvider {
override fun provideValues(): List<PaparazziPreviewData> = annotations
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright Square, Inc.
package app.cash.paparazzi.preview

import androidx.compose.runtime.Composable
import app.cash.paparazzi.Paparazzi
import app.cash.paparazzi.annotations.PaparazziPreviewData

internal fun Paparazzi.snapshotDefault(
previewData: PaparazziPreviewData.Default,
name: String?,
wrapper: @Composable (@Composable () -> Unit) -> Unit = { it() }
) {
snapshot(name) {
wrapper { previewData.composable() }
}
}
38 changes: 0 additions & 38 deletions paparazzi/api/paparazzi.api
Original file line number Diff line number Diff line change
Expand Up @@ -235,41 +235,3 @@ public final class app/cash/paparazzi/accessibility/AccessibilityRenderExtension
public fun renderView (Landroid/view/View;)Landroid/view/View;
}

public final class app/cash/paparazzi/preview/ComposableSingletons$SnapshotKt {
public static final field INSTANCE Lapp/cash/paparazzi/preview/ComposableSingletons$SnapshotKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$paparazzi ()Lkotlin/jvm/functions/Function3;
}

public final class app/cash/paparazzi/preview/ComposableSingletons$UtilsKt {
public static final field INSTANCE Lapp/cash/paparazzi/preview/ComposableSingletons$UtilsKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public static field lambda-2 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$paparazzi ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-2$paparazzi ()Lkotlin/jvm/functions/Function3;
}

public final class app/cash/paparazzi/preview/DefaultLocaleRule : org/junit/rules/TestRule {
public static final field $stable I
public fun <init> (Ljava/lang/String;)V
public fun apply (Lorg/junit/runners/model/Statement;Lorg/junit/runner/Description;)Lorg/junit/runners/model/Statement;
public final fun getLocale ()Ljava/lang/String;
}

public class app/cash/paparazzi/preview/PaparazziValuesProvider : com/google/testing/junit/testparameterinjector/TestParameter$TestParameterValuesProvider {
public static final field $stable I
public fun <init> (Ljava/util/List;)V
public fun provideValues ()Ljava/util/List;
}

public final class app/cash/paparazzi/preview/SnapshotKt {
public static final fun deviceConfig (Lapp/cash/paparazzi/annotations/PaparazziPreviewData;Lapp/cash/paparazzi/DeviceConfig;)Lapp/cash/paparazzi/DeviceConfig;
public static synthetic fun deviceConfig$default (Lapp/cash/paparazzi/annotations/PaparazziPreviewData;Lapp/cash/paparazzi/DeviceConfig;ILjava/lang/Object;)Lapp/cash/paparazzi/DeviceConfig;
public static final fun flatten (Ljava/util/List;)Ljava/util/List;
public static final fun locale (Lapp/cash/paparazzi/annotations/PaparazziPreviewData;)Ljava/lang/String;
public static final fun snapshot (Lapp/cash/paparazzi/Paparazzi;Lapp/cash/paparazzi/annotations/PaparazziPreviewData;Ljava/lang/String;ZLkotlin/jvm/functions/Function3;)V
public static synthetic fun snapshot$default (Lapp/cash/paparazzi/Paparazzi;Lapp/cash/paparazzi/annotations/PaparazziPreviewData;Ljava/lang/String;ZLkotlin/jvm/functions/Function3;ILjava/lang/Object;)V
}

3 changes: 0 additions & 3 deletions paparazzi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies {
testImplementationAarAsJar libs.androidx.compose.ui.android
compileOnlyAarAsJar libs.androidx.compose.ui.android
compileOnlyAarAsJar libs.androidx.activity
compileOnlyAarAsJar libs.composeUi.foundation

implementation libs.bytebuddy.agent
implementation libs.bytebuddy.core
Expand All @@ -48,12 +47,10 @@ dependencies {
api libs.guava
api libs.kotlinx.coroutines.android
api libs.okio
api libs.testParameterInjector
api platform(libs.kotlin.bom)
implementation libs.moshi.core
implementation libs.moshi.adapters
implementation libs.moshi.kotlinReflect
implementation projects.paparazziAnnotations

def osName = System.getProperty("os.name").toLowerCase(Locale.US)
def osLabel
Expand Down
Loading

0 comments on commit 3b5486e

Please sign in to comment.