Initialize variables on TV tests lazily

The TV resources no longer exist on phones and the tests now crash instead of being skipped

Test: atest WMShellFlickerTests
Fixes: 264242504
Change-Id: Ifd424ba2f2a0de06e735844bc75c9b198a95457e
This commit is contained in:
Nataniel Borges
2023-01-03 13:49:19 +00:00
parent f76de3d634
commit 9f31b1fe2a

View File

@@ -31,22 +31,26 @@ import org.junit.Test
@RequiresDevice
class TvPipMenuTests : TvPipTestBase() {
private val systemUiResources =
private val systemUiResources by lazy {
packageManager.getResourcesForApplication(SYSTEM_UI_PACKAGE_NAME)
private val pipBoundsWhileInMenu: Rect =
}
private val pipBoundsWhileInMenu: Rect by lazy {
systemUiResources.run {
val bounds =
getString(getIdentifier("pip_menu_bounds", "string", SYSTEM_UI_PACKAGE_NAME))
Rect.unflattenFromString(bounds) ?: error("Could not retrieve PiP menu bounds")
}
private val playButtonDescription =
}
private val playButtonDescription by lazy {
systemUiResources.run {
getString(getIdentifier("pip_play", "string", SYSTEM_UI_PACKAGE_NAME))
}
private val pauseButtonDescription =
}
private val pauseButtonDescription by lazy {
systemUiResources.run {
getString(getIdentifier("pip_pause", "string", SYSTEM_UI_PACKAGE_NAME))
}
}
@Before
fun tvPipMenuTestsTestUp() {