Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f4958c4 authored by Jay Aliomer's avatar Jay Aliomer Committed by Android (Google) Code Review
Browse files

Merge "Make golden path relative to $ANDROID_BUILD_TOP" into tm-qpr-dev

parents c59839db aed6e83f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -38,12 +38,18 @@ import platform.test.screenshot.ScreenshotTestRule
import platform.test.screenshot.getEmulatedDevicePathConfig

/** A rule for Compose screenshot diff tests. */
class ComposeScreenshotTestRule(emulationSpec: DeviceEmulationSpec) : TestRule {
class ComposeScreenshotTestRule(
    emulationSpec: DeviceEmulationSpec,
    assetPathRelativeToBuildRoot: String
) : TestRule {
    private val colorsRule = MaterialYouColorsRule()
    private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
    private val screenshotRule =
        ScreenshotTestRule(
            SystemUIGoldenImagePathManager(getEmulatedDevicePathConfig(emulationSpec))
            SystemUIGoldenImagePathManager(
                getEmulatedDevicePathConfig(emulationSpec),
                assetPathRelativeToBuildRoot
            )
        )
    private val composeRule = createAndroidComposeRule<ScreenshotActivity>()
    private val delegateRule =
+8 −2
Original line number Diff line number Diff line
@@ -34,13 +34,19 @@ import platform.test.screenshot.*
/**
 * A rule that allows to run a screenshot diff test on a view that is hosted in another activity.
 */
class ExternalViewScreenshotTestRule(emulationSpec: DeviceEmulationSpec) : TestRule {
class ExternalViewScreenshotTestRule(
    emulationSpec: DeviceEmulationSpec,
    assetPathRelativeToBuildRoot: String
) : TestRule {

    private val colorsRule = MaterialYouColorsRule()
    private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
    private val screenshotRule =
        ScreenshotTestRule(
            SystemUIGoldenImagePathManager(getEmulatedDevicePathConfig(emulationSpec))
            SystemUIGoldenImagePathManager(
                getEmulatedDevicePathConfig(emulationSpec),
                assetPathRelativeToBuildRoot
            )
        )
    private val delegateRule =
        RuleChain.outerRule(colorsRule).around(deviceEmulationRule).around(screenshotRule)
+2 −2
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ import platform.test.screenshot.PathConfig
/** A [GoldenImagePathManager] that should be used for all SystemUI screenshot tests. */
class SystemUIGoldenImagePathManager(
    pathConfig: PathConfig,
    override val assetsPathRelativeToRepo: String = "tests/screenshot/assets"
    assetsPathRelativeToBuildRoot: String
) :
    GoldenImagePathManager(
        appContext = InstrumentationRegistry.getInstrumentation().context,
        assetsPathRelativeToRepo = assetsPathRelativeToRepo,
        assetsPathRelativeToBuildRoot = assetsPathRelativeToBuildRoot,
        deviceLocalPath =
            InstrumentationRegistry.getInstrumentation()
                .targetContext
+6 −2
Original line number Diff line number Diff line
@@ -41,13 +41,17 @@ import platform.test.screenshot.matchers.BitmapMatcher
/** A rule for View screenshot diff unit tests. */
class ViewScreenshotTestRule(
    emulationSpec: DeviceEmulationSpec,
    private val matcher: BitmapMatcher = UnitTestBitmapMatcher
    private val matcher: BitmapMatcher = UnitTestBitmapMatcher,
    assetsPathRelativeToBuildRoot: String
) : TestRule {
    private val colorsRule = MaterialYouColorsRule()
    private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
    private val screenshotRule =
        ScreenshotTestRule(
            SystemUIGoldenImagePathManager(getEmulatedDevicePathConfig(emulationSpec))
            SystemUIGoldenImagePathManager(
                getEmulatedDevicePathConfig(emulationSpec),
                assetsPathRelativeToBuildRoot
            )
        )
    private val activityRule = ActivityScenarioRule(ScreenshotActivity::class.java)
    private val delegateRule =