Skip to content

Commit

Permalink
Expose Roborazzi options (#2458)
Browse files Browse the repository at this point in the history
* Expose Roborazzi options
  • Loading branch information
yschimke authored Nov 12, 2024
1 parent 9acf67a commit 42a9990
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions roboscreenshots/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ package com.google.android.horologist.screenshots.rng {
method public coil.test.FakeImageLoaderEngine? getImageLoader();
method @org.junit.Rule public final org.junit.rules.TestName getTestInfo();
method public float getTolerance();
method public com.github.takahirom.roborazzi.RoborazziOptions roborazziOptions(optional boolean applyDeviceCrop);
method public final void runTest(optional String? suffix, optional com.google.android.horologist.screenshots.rng.WearDevice? device, optional boolean applyDeviceConfig, optional boolean captureScreenshot, kotlin.jvm.functions.Function0<kotlin.Unit> content);
method public String testName(String suffix);
property @org.junit.Rule public final androidx.compose.ui.test.junit4.ComposeContentTestRule composeRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ public abstract class WearScreenshotTest {

public open val imageLoader: FakeImageLoaderEngine? = null

public open fun roborazziOptions(applyDeviceCrop: Boolean = true): RoborazziOptions =
RoborazziOptions(
recordOptions = RoborazziOptions.RecordOptions(
applyDeviceCrop = applyDeviceCrop,
),
compareOptions = RoborazziOptions.CompareOptions(
resultValidator = ThresholdValidator(tolerance),
),
)

public fun runTest(
suffix: String? = null,
device: WearDevice? = this.device,
Expand Down Expand Up @@ -101,14 +111,7 @@ public abstract class WearScreenshotTest {
public fun captureScreenshot(suffix: String = "") {
captureScreenRoboImage(
filePath = testName(suffix),
roborazziOptions = RoborazziOptions(
recordOptions = RoborazziOptions.RecordOptions(
applyDeviceCrop = true,
),
compareOptions = RoborazziOptions.CompareOptions(
resultValidator = ThresholdValidator(tolerance),
),
),
roborazziOptions = roborazziOptions(),
)
}

Expand Down

0 comments on commit 42a9990

Please sign in to comment.