Merge "Move Pip assertions to flickerlib" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2935ef01dc
@@ -26,8 +26,6 @@ import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE
|
|||||||
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
|
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
|
||||||
import com.android.wm.shell.flicker.pip.tv.closeTvPipWindow
|
import com.android.wm.shell.flicker.pip.tv.closeTvPipWindow
|
||||||
import com.android.wm.shell.flicker.pip.tv.isFocusedOrHasFocusedChild
|
import com.android.wm.shell.flicker.pip.tv.isFocusedOrHasFocusedChild
|
||||||
import com.android.wm.shell.flicker.pip.waitPipWindowGone
|
|
||||||
import com.android.wm.shell.flicker.pip.waitPipWindowShown
|
|
||||||
import com.android.wm.shell.flicker.testapp.Components
|
import com.android.wm.shell.flicker.testapp.Components
|
||||||
|
|
||||||
class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
||||||
@@ -64,7 +62,7 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
|||||||
stringExtras: Map<String, String>
|
stringExtras: Map<String, String>
|
||||||
) {
|
) {
|
||||||
super.launchViaIntent(wmHelper, expectedWindowName, action, stringExtras)
|
super.launchViaIntent(wmHelper, expectedWindowName, action, stringExtras)
|
||||||
wmHelper.waitPipWindowShown()
|
wmHelper.waitFor { it.wmState.hasPipWindow() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun focusOnObject(selector: BySelector): Boolean {
|
private fun focusOnObject(selector: BySelector): Boolean {
|
||||||
@@ -86,7 +84,7 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
|||||||
clickObject(ENTER_PIP_BUTTON_ID)
|
clickObject(ENTER_PIP_BUTTON_ID)
|
||||||
|
|
||||||
// Wait on WMHelper or simply wait for 3 seconds
|
// Wait on WMHelper or simply wait for 3 seconds
|
||||||
wmHelper?.waitPipWindowShown() ?: SystemClock.sleep(3_000)
|
wmHelper?.waitFor { it.wmState.hasPipWindow() } ?: SystemClock.sleep(3_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickStartMediaSessionButton() {
|
fun clickStartMediaSessionButton() {
|
||||||
@@ -139,7 +137,7 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for animation to complete.
|
// Wait for animation to complete.
|
||||||
wmHelper.waitPipWindowGone()
|
wmHelper.waitFor { !it.wmState.hasPipWindow() }
|
||||||
wmHelper.waitForHomeActivityVisible()
|
wmHelper.waitForHomeActivityVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +167,7 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
|||||||
val windowRect = windowRegion.bounds
|
val windowRect = windowRegion.bounds
|
||||||
uiDevice.click(windowRect.centerX(), windowRect.centerY())
|
uiDevice.click(windowRect.centerX(), windowRect.centerY())
|
||||||
uiDevice.click(windowRect.centerX(), windowRect.centerY())
|
uiDevice.click(windowRect.centerX(), windowRect.centerY())
|
||||||
wmHelper.waitPipWindowGone()
|
wmHelper.waitFor { !it.wmState.hasPipWindow() }
|
||||||
wmHelper.waitForAppTransitionIdle()
|
wmHelper.waitForAppTransitionIdle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class EnterPipToOtherOrientationTest(
|
|||||||
// Enter PiP, and assert that the PiP is within bounds now that the device is back
|
// Enter PiP, and assert that the PiP is within bounds now that the device is back
|
||||||
// in portrait
|
// in portrait
|
||||||
broadcastActionTrigger.doAction(ACTION_ENTER_PIP)
|
broadcastActionTrigger.doAction(ACTION_ENTER_PIP)
|
||||||
wmHelper.waitPipWindowShown()
|
wmHelper.waitFor { it.wmState.hasPipWindow() }
|
||||||
wmHelper.waitForAppTransitionIdle()
|
wmHelper.waitForAppTransitionIdle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,62 +16,14 @@
|
|||||||
|
|
||||||
package com.android.wm.shell.flicker.pip
|
package com.android.wm.shell.flicker.pip
|
||||||
|
|
||||||
import android.app.WindowConfiguration
|
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import com.android.server.wm.flicker.traces.windowmanager.WindowManagerStateSubject
|
|
||||||
import com.android.server.wm.traces.common.windowmanager.WindowManagerState
|
import com.android.server.wm.traces.common.windowmanager.WindowManagerState
|
||||||
import com.android.server.wm.traces.parser.toWindowName
|
import com.android.server.wm.traces.parser.toWindowName
|
||||||
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
|
|
||||||
import com.google.common.truth.Truth
|
|
||||||
|
|
||||||
inline val WindowManagerState.pinnedWindows
|
|
||||||
get() = visibleWindows
|
|
||||||
.filter { it.windowingMode == WindowConfiguration.WINDOWING_MODE_PINNED }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the state has any window in PIP mode
|
|
||||||
*/
|
|
||||||
fun WindowManagerState.hasPipWindow(): Boolean = pinnedWindows.isNotEmpty()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that an activity [activity] is in PIP mode
|
* Checks that an activity [activity] is in PIP mode
|
||||||
*/
|
*/
|
||||||
fun WindowManagerState.isInPipMode(activity: ComponentName): Boolean {
|
fun WindowManagerState.isInPipMode(activity: ComponentName): Boolean {
|
||||||
val windowName = activity.toWindowName()
|
val windowName = activity.toWindowName()
|
||||||
return pinnedWindows.any { it.title == windowName }
|
return isInPipMode(windowName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Asserts that an activity [activity] exists and is in PIP mode
|
|
||||||
*/
|
|
||||||
fun WindowManagerStateSubject.isInPipMode(
|
|
||||||
activity: ComponentName
|
|
||||||
): WindowManagerStateSubject = apply {
|
|
||||||
val windowName = activity.toWindowName()
|
|
||||||
contains(windowName)
|
|
||||||
val pinnedWindows = wmState.pinnedWindows
|
|
||||||
.map { it.title }
|
|
||||||
Truth.assertWithMessage("Window not in PIP mode")
|
|
||||||
.that(pinnedWindows)
|
|
||||||
.contains(windowName)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Waits until the state has a window in PIP mode, i.e., with
|
|
||||||
* windowingMode = WindowConfiguration.WINDOWING_MODE_PINNED
|
|
||||||
*/
|
|
||||||
fun WindowManagerStateHelper.waitPipWindowShown(): Boolean =
|
|
||||||
waitFor("PIP window shown") {
|
|
||||||
val result = it.wmState.hasPipWindow()
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Waits until the state doesn't have a window in PIP mode, i.e., with
|
|
||||||
* windowingMode = WindowConfiguration.WINDOWING_MODE_PINNED
|
|
||||||
*/
|
|
||||||
fun WindowManagerStateHelper.waitPipWindowGone(): Boolean =
|
|
||||||
waitFor("PIP window gone") {
|
|
||||||
val result = !it.wmState.hasPipWindow()
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -131,13 +131,13 @@ abstract class PipTransition(protected val testSpec: FlickerTestParameter) {
|
|||||||
removeAllTasksButHome()
|
removeAllTasksButHome()
|
||||||
if (!eachRun) {
|
if (!eachRun) {
|
||||||
pipApp.launchViaIntent(wmHelper, stringExtras = stringExtras)
|
pipApp.launchViaIntent(wmHelper, stringExtras = stringExtras)
|
||||||
wmHelper.waitPipWindowShown()
|
wmHelper.waitFor { it.wmState.hasPipWindow() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eachRun {
|
eachRun {
|
||||||
if (eachRun) {
|
if (eachRun) {
|
||||||
pipApp.launchViaIntent(wmHelper, stringExtras = stringExtras)
|
pipApp.launchViaIntent(wmHelper, stringExtras = stringExtras)
|
||||||
wmHelper.waitPipWindowShown()
|
wmHelper.waitFor { it.wmState.hasPipWindow() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user