Loading packages/SystemUI/compose/testing/src/com/android/systemui/testing/compose/ComposeScreenshotTestRule.kt +8 −2 Original line number Diff line number Diff line Loading @@ -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 = Loading packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ExternalViewScreenshotTestRule.kt +8 −2 Original line number Diff line number Diff line Loading @@ -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) Loading packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/SystemUIGoldenImagePathManager.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt +6 −2 Original line number Diff line number Diff line Loading @@ -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 = Loading Loading
packages/SystemUI/compose/testing/src/com/android/systemui/testing/compose/ComposeScreenshotTestRule.kt +8 −2 Original line number Diff line number Diff line Loading @@ -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 = Loading
packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ExternalViewScreenshotTestRule.kt +8 −2 Original line number Diff line number Diff line Loading @@ -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) Loading
packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/SystemUIGoldenImagePathManager.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt +6 −2 Original line number Diff line number Diff line Loading @@ -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 = Loading