Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32281991 authored by Sergey Nikolaienkov's avatar Sergey Nikolaienkov Committed by Android (Google) Code Review
Browse files

Merge "Filter out WmShellFlickerTests that are not supported on TV"

parents 8fb6d9fb 7c6db063
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -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 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)
        }
    val uiDevice by lazy {
        UiDevice.getInstance(instrumentation)
    }
    val packageManager: PackageManager by lazy {
        instrumentation.context.getPackageManager()
    }

    /**
     * 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
+10 −0
Original line number Diff line number Diff line
@@ -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.
         */
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -51,8 +51,7 @@ class TvPipMenuTests : TvPipTestBase() {
    }

    @Before
    override fun setUp() {
        super.setUp()
    fun tvPipMenuTestsTestUp() {
        // Launch the app and go to PiP
        testApp.launchViaIntent()
    }
+1 −2
Original line number Diff line number Diff line
@@ -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")
+2 −7
Original line number Diff line number Diff line
@@ -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()