Merge "Make golden path relative to $ANDROID_BUILD_TOP" into tm-qpr-dev
This commit is contained in:
@@ -38,12 +38,18 @@ import platform.test.screenshot.ScreenshotTestRule
|
|||||||
import platform.test.screenshot.getEmulatedDevicePathConfig
|
import platform.test.screenshot.getEmulatedDevicePathConfig
|
||||||
|
|
||||||
/** A rule for Compose screenshot diff tests. */
|
/** 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 colorsRule = MaterialYouColorsRule()
|
||||||
private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
|
private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
|
||||||
private val screenshotRule =
|
private val screenshotRule =
|
||||||
ScreenshotTestRule(
|
ScreenshotTestRule(
|
||||||
SystemUIGoldenImagePathManager(getEmulatedDevicePathConfig(emulationSpec))
|
SystemUIGoldenImagePathManager(
|
||||||
|
getEmulatedDevicePathConfig(emulationSpec),
|
||||||
|
assetPathRelativeToBuildRoot
|
||||||
|
)
|
||||||
)
|
)
|
||||||
private val composeRule = createAndroidComposeRule<ScreenshotActivity>()
|
private val composeRule = createAndroidComposeRule<ScreenshotActivity>()
|
||||||
private val delegateRule =
|
private val delegateRule =
|
||||||
|
|||||||
@@ -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.
|
* 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 colorsRule = MaterialYouColorsRule()
|
||||||
private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
|
private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
|
||||||
private val screenshotRule =
|
private val screenshotRule =
|
||||||
ScreenshotTestRule(
|
ScreenshotTestRule(
|
||||||
SystemUIGoldenImagePathManager(getEmulatedDevicePathConfig(emulationSpec))
|
SystemUIGoldenImagePathManager(
|
||||||
|
getEmulatedDevicePathConfig(emulationSpec),
|
||||||
|
assetPathRelativeToBuildRoot
|
||||||
|
)
|
||||||
)
|
)
|
||||||
private val delegateRule =
|
private val delegateRule =
|
||||||
RuleChain.outerRule(colorsRule).around(deviceEmulationRule).around(screenshotRule)
|
RuleChain.outerRule(colorsRule).around(deviceEmulationRule).around(screenshotRule)
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ import platform.test.screenshot.PathConfig
|
|||||||
/** A [GoldenImagePathManager] that should be used for all SystemUI screenshot tests. */
|
/** A [GoldenImagePathManager] that should be used for all SystemUI screenshot tests. */
|
||||||
class SystemUIGoldenImagePathManager(
|
class SystemUIGoldenImagePathManager(
|
||||||
pathConfig: PathConfig,
|
pathConfig: PathConfig,
|
||||||
override val assetsPathRelativeToRepo: String = "tests/screenshot/assets"
|
assetsPathRelativeToBuildRoot: String
|
||||||
) :
|
) :
|
||||||
GoldenImagePathManager(
|
GoldenImagePathManager(
|
||||||
appContext = InstrumentationRegistry.getInstrumentation().context,
|
appContext = InstrumentationRegistry.getInstrumentation().context,
|
||||||
assetsPathRelativeToRepo = assetsPathRelativeToRepo,
|
assetsPathRelativeToBuildRoot = assetsPathRelativeToBuildRoot,
|
||||||
deviceLocalPath =
|
deviceLocalPath =
|
||||||
InstrumentationRegistry.getInstrumentation()
|
InstrumentationRegistry.getInstrumentation()
|
||||||
.targetContext
|
.targetContext
|
||||||
|
|||||||
@@ -41,13 +41,17 @@ import platform.test.screenshot.matchers.BitmapMatcher
|
|||||||
/** A rule for View screenshot diff unit tests. */
|
/** A rule for View screenshot diff unit tests. */
|
||||||
class ViewScreenshotTestRule(
|
class ViewScreenshotTestRule(
|
||||||
emulationSpec: DeviceEmulationSpec,
|
emulationSpec: DeviceEmulationSpec,
|
||||||
private val matcher: BitmapMatcher = UnitTestBitmapMatcher
|
private val matcher: BitmapMatcher = UnitTestBitmapMatcher,
|
||||||
|
assetsPathRelativeToBuildRoot: String
|
||||||
) : TestRule {
|
) : TestRule {
|
||||||
private val colorsRule = MaterialYouColorsRule()
|
private val colorsRule = MaterialYouColorsRule()
|
||||||
private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
|
private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
|
||||||
private val screenshotRule =
|
private val screenshotRule =
|
||||||
ScreenshotTestRule(
|
ScreenshotTestRule(
|
||||||
SystemUIGoldenImagePathManager(getEmulatedDevicePathConfig(emulationSpec))
|
SystemUIGoldenImagePathManager(
|
||||||
|
getEmulatedDevicePathConfig(emulationSpec),
|
||||||
|
assetsPathRelativeToBuildRoot
|
||||||
|
)
|
||||||
)
|
)
|
||||||
private val activityRule = ActivityScenarioRule(ScreenshotActivity::class.java)
|
private val activityRule = ActivityScenarioRule(ScreenshotActivity::class.java)
|
||||||
private val delegateRule =
|
private val delegateRule =
|
||||||
|
|||||||
Reference in New Issue
Block a user