From 10671a0f9f10b7e0a4c396c7b155453377bc0909 Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Wed, 13 Apr 2022 20:05:59 +0200 Subject: Execute flicker tests with device without wallpaper Currently it fails with Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ComponentName android.app.WallpaperInfo.getComponent()' on a null object reference at com.android.server.wm.flicker.launch.TaskTransitionTest$Companion.getWallpaperPackage(TaskTransitionTest.kt:240) Fixes: 225350160 Test: atest FlickerTests:TaskTransitionTest Change-Id: I516520e806fc17e75c2cdfe07116f7b84fdd5adb --- .../server/wm/flicker/launch/TaskTransitionTest.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt index 04fdda425edf..2f546b56f145 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt @@ -63,8 +63,12 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 class TaskTransitionTest(val testSpec: FlickerTestParameter) { - val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val mTestApp: NewTasksAppHelper = NewTasksAppHelper(instrumentation) + private val mWallpaper by lazy { + getWallpaperPackage(InstrumentationRegistry.getInstrumentation()) + ?: error("Unable to obtain wallpaper") + } @FlickerBuilderProvider fun buildFlicker(): FlickerBuilder { @@ -97,7 +101,7 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) { @Test fun wallpaperWindowIsNeverVisible() { testSpec.assertWm { - this.isNonAppWindowInvisible(WALLPAPER) + this.isNonAppWindowInvisible(mWallpaper) } } @@ -109,7 +113,7 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) { @Test fun wallpaperLayerIsNeverVisible() { testSpec.assertLayers { - this.isInvisible(WALLPAPER) + this.isInvisible(mWallpaper) this.isInvisible(WALLPAPER_BBQ_WRAPPER) } } @@ -229,15 +233,14 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) { fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() companion object { - private val WALLPAPER = getWallpaperPackage(InstrumentationRegistry.getInstrumentation()) private val LAUNCH_NEW_TASK_ACTIVITY = LAUNCH_NEW_TASK_ACTIVITY_COMPONENT_NAME.toFlickerComponent() private val SIMPLE_ACTIVITY = SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME.toFlickerComponent() - private fun getWallpaperPackage(instrumentation: Instrumentation): FlickerComponentName { + private fun getWallpaperPackage(instrumentation: Instrumentation): FlickerComponentName? { val wallpaperManager = WallpaperManager.getInstance(instrumentation.targetContext) - return wallpaperManager.wallpaperInfo.component.toFlickerComponent() + return wallpaperManager.wallpaperInfo?.component?.toFlickerComponent() } @Parameterized.Parameters(name = "{0}") -- cgit v1.2.3-59-g8ed1b