forked from cashapp/paparazzi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac8b177
commit 8da493d
Showing
15 changed files
with
626 additions
and
42 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
34 changes: 34 additions & 0 deletions
34
paparazzi-gradle-plugin/src/main/java/app/cash/paparazzi/gradle/RecordPaparazziTask.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,34 @@ | ||
package app.cash.paparazzi.gradle | ||
|
||
import org.gradle.api.file.Directory | ||
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.tasks.InputDirectory | ||
import org.gradle.api.tasks.Internal | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
public abstract class RecordPaparazziTask : PaparazziPlugin.PaparazziTask() { | ||
|
||
@get:Internal | ||
internal abstract val reportsDirectory: DirectoryProperty | ||
|
||
@InputDirectory | ||
internal fun getImageSnapshots(): Provider<Directory> { | ||
return reportsDirectory.dir("goldenImages") | ||
} | ||
|
||
// Don't declare as output so that Gradle doesn't require | ||
// a depnendency from test task to this task. | ||
// Since this is just copying files it's ok to run it every time. | ||
@get:Internal | ||
internal abstract val goldenSnapshotDirectory: DirectoryProperty | ||
|
||
@TaskAction | ||
public fun copy() { | ||
val goldenImagesDirectory = goldenSnapshotDirectory.dir("images").get() | ||
getImageSnapshots().get().asFile.listFiles()!!.forEach { snapshotFile -> | ||
val target = goldenImagesDirectory.file(snapshotFile.name) | ||
snapshotFile.copyTo(target.asFile, overwrite = true) | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
paparazzi-gradle-plugin/src/test/projects/rerun-snapshots-existing/build.gradle
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,22 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'kotlin-android' | ||
id 'app.cash.paparazzi' | ||
} | ||
|
||
android { | ||
namespace 'app.cash.paparazzi.plugin.test' | ||
compileSdk libs.versions.compileSdk.get() as int | ||
defaultConfig { | ||
minSdk libs.versions.minSdk.get() as int | ||
} | ||
compileOptions { | ||
sourceCompatibility = libs.versions.javaTarget.get() | ||
targetCompatibility = libs.versions.javaTarget.get() | ||
} | ||
kotlinOptions { | ||
jvmTarget = libs.versions.javaTarget.get() | ||
} | ||
} | ||
|
||
apply from: '../guava-fix.gradle' |
16 changes: 16 additions & 0 deletions
16
...jects/rerun-snapshots-existing/src/test/java/app/cash/paparazzi/plugin/test/RecordTest.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,16 @@ | ||
package app.cash.paparazzi.plugin.test | ||
|
||
import android.view.View | ||
import app.cash.paparazzi.Paparazzi | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class RecordTest { | ||
@get:Rule | ||
val paparazzi = Paparazzi() | ||
|
||
@Test | ||
fun record() { | ||
paparazzi.snapshot(View(paparazzi.context)) | ||
} | ||
} |
Binary file added
BIN
+4.36 KB
.../src/test/snapshots/images/app.cash.paparazzi.plugin.test_RecordTest_record.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.