From 7c6db063bc71eb967e837bbd64ff8a70c29b0c75 Mon Sep 17 00:00:00 2001 From: Sergey Nikolaienkov Date: Mon, 21 Dec 2020 12:31:02 +0000 Subject: [PATCH] Filter out WmShellFlickerTests that are not supported on TV By default all new WmShellFlickerTests are enabled on TV even despite the fact that most of them focus the features that are not supported on TV, and never been run on TV devices prior to adding. Some examples are: com.android.wm.shell.flicker.apppairs.AppPairsTest com.android.wm.shell.flicker.splitscreen.* com.android.wm.shell.flicker.legacysplitscreen.* To address this we move from "opt-out" to "opt-in" model for WmShellFlickerTests on TV. Bug: 176074784 Test: run `atest WMShellFlickerTests` on ADT-3 Change-Id: Ic71f9ed4cd0f3b13d81763b2741e827f32b26c4a --- .../wm/shell/flicker/FlickerTestBase.kt | 26 +++++++++++++------ .../wm/shell/flicker/pip/PipTestBase.kt | 10 +++++++ .../wm/shell/flicker/pip/tv/TvPipMenuTests.kt | 3 +-- .../flicker/pip/tv/TvPipNotificationTests.kt | 3 +-- .../wm/shell/flicker/pip/tv/TvPipTestBase.kt | 9 ++----- 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/FlickerTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/FlickerTestBase.kt index 7809be04de96f..baa2ef7f4cb52 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/FlickerTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/FlickerTestBase.kt @@ -17,6 +17,8 @@ package com.android.wm.shell.flicker import android.content.pm.PackageManager +import android.content.pm.PackageManager.FEATURE_LEANBACK +import android.content.pm.PackageManager.FEATURE_LEANBACK_ONLY import android.os.RemoteException import android.os.SystemClock import android.platform.helpers.IAppHelper @@ -24,6 +26,8 @@ import android.view.Surface import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import com.android.server.wm.flicker.Flicker +import org.junit.Assume.assumeFalse +import org.junit.Before /** * Base class of all Flicker test that performs common functions for all flicker tests: @@ -36,16 +40,22 @@ import com.android.server.wm.flicker.Flicker * - Fails tests if results are not available for any test due to jank. */ abstract class FlickerTestBase { - val instrumentation by lazy { - InstrumentationRegistry.getInstrumentation() - } - val uiDevice by lazy { - UiDevice.getInstance(instrumentation) - } - val packageManager: PackageManager by lazy { - instrumentation.context.getPackageManager() + val instrumentation by lazy { InstrumentationRegistry.getInstrumentation() } + val uiDevice by lazy { UiDevice.getInstance(instrumentation) } + val packageManager: PackageManager by lazy { instrumentation.context.getPackageManager() } + protected val isTelevision: Boolean by lazy { + packageManager.run { + hasSystemFeature(FEATURE_LEANBACK) || hasSystemFeature(FEATURE_LEANBACK_ONLY) + } } + /** + * By default WmShellFlickerTests do not run on TV devices. + * If the test should run on TV - it should override this method. + */ + @Before + open fun televisionSetUp() = assumeFalse(isTelevision) + /** * Build a test tag for the test * @param testName Name of the transition(s) being tested diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTestBase.kt index 03a92119fc861..96b6c912d1526 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTestBase.kt @@ -17,10 +17,20 @@ package com.android.wm.shell.flicker.pip import com.android.wm.shell.flicker.helpers.PipAppHelper +import org.junit.Before abstract class PipTestBase( rotationName: String, rotation: Int ) : AppTestBase(rotationName, rotation) { protected val testApp = PipAppHelper(instrumentation) + + @Before + override fun televisionSetUp() { + /** + * The super implementation assumes ([org.junit.Assume]) that not running on TV, thus + * disabling the test on TV. This test, however, *should run on TV*, so we overriding this + * method and simply leaving it blank. + */ + } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt index 66efb5ae3c2da..d21bb9d3cd6de 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt @@ -51,8 +51,7 @@ class TvPipMenuTests : TvPipTestBase() { } @Before - override fun setUp() { - super.setUp() + fun tvPipMenuTestsTestUp() { // Launch the app and go to PiP testApp.launchViaIntent() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt index 75388bf2a189d..4b6fe505a3f4a 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt @@ -40,8 +40,7 @@ import org.junit.Test @RequiresDevice class TvPipNotificationTests : TvPipTestBase() { @Before - override fun setUp() { - super.setUp() + fun tvPipNotificationTestsSetUp() { val started = startNotificationListener() if (!started) { error("NotificationListener hasn't started") diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt index 251bc064352dc..31e9167c79b24 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt @@ -19,8 +19,6 @@ package com.android.wm.shell.flicker.pip.tv import android.app.ActivityManager import android.app.IActivityManager import android.app.IProcessObserver -import android.content.pm.PackageManager.FEATURE_LEANBACK -import android.content.pm.PackageManager.FEATURE_LEANBACK_ONLY import android.os.SystemClock import android.view.Surface.ROTATION_0 import android.view.Surface.rotationToString @@ -34,14 +32,11 @@ import org.junit.Before abstract class TvPipTestBase : PipTestBase(rotationToString(ROTATION_0), ROTATION_0) { - private val isTelevision: Boolean - get() = packageManager.run { - hasSystemFeature(FEATURE_LEANBACK) || hasSystemFeature(FEATURE_LEANBACK_ONLY) - } private val systemUiProcessObserver = SystemUiProcessObserver() @Before - open fun setUp() { + final override fun televisionSetUp() { + // Should run only on TVs. Assume.assumeTrue(isTelevision) systemUiProcessObserver.start()