From 31fcbcfed1810b3e116050f27ec3f43759f423ed Mon Sep 17 00:00:00 2001 From: Sergey Nikolaienkov Date: Fri, 13 Nov 2020 08:32:22 +0000 Subject: [PATCH] Test Pip window position when Pip menu is open Bug: 171520419 Test: atest WMShellFlickerTests:TvPipMenuTests Change-Id: Ie0a5651667bfe1bc04ee1127fbcd721b3bd36d81 --- .../wm/shell/flicker/pip/tv/TvPipMenuTests.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 728cc510a79bc..99cbd52c9432a 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 @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.pip.tv +import android.graphics.Rect import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.UiObject2 import com.android.wm.shell.flicker.SYSTEM_UI_PACKAGE_NAME @@ -37,6 +38,10 @@ class TvPipMenuTests(rotationName: String, rotation: Int) private val systemUiResources = packageManager.getResourcesForApplication(SYSTEM_UI_PACKAGE_NAME) + private val pipBoundsWhileInMenu: Rect = 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 = systemUiResources.run { getString(getIdentifier("pip_play", "string", SYSTEM_UI_PACKAGE_NAME)) } @@ -52,12 +57,18 @@ class TvPipMenuTests(rotationName: String, rotation: Int) } @Test - fun pipMenu_open() { + fun pipMenu_correctPosition() { val pipMenu = enterPip_openMenu_assertShown() // Make sure it's fullscreen assertTrue("Pip menu should be shown fullscreen", pipMenu.isFullscreen(uiDevice)) + // Make sure the PiP task is positioned where it should be. + val activityBounds: Rect = testApp.ui?.visibleBounds + ?: error("Could not retrieve PiP Activity bounds") + assertTrue("Pip Activity is positioned correctly while Pip menu is shown", + pipBoundsWhileInMenu == activityBounds) + testApp.closePipWindow() }