From 7711b5aac281e8fd0e2996051d61fa3d3560f2d8 Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Mon, 22 Aug 2022 12:34:39 +0000 Subject: Sleep after interacting with bubbles to stabilize test The test fails sporadically with a StaleObjectException because the bubble widget changes Bug: 242088970 Test: atest FlickerTests WMShellFlickerTests Change-Id: I06eb4ec3e93c7057c85f33441241be7c40453713 --- .../android/wm/shell/flicker/bubble/MultiBubblesScreen.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'libs') diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt index 1950e486f34b..3ad92f87421b 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt @@ -21,6 +21,7 @@ import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By +import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter @@ -58,26 +59,27 @@ open class MultiBubblesScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen setup { test { for (i in 1..3) { - val addBubbleBtn = waitAndGetAddBubbleBtn() - addBubbleBtn?.run { addBubbleBtn.click() } ?: error("Add Bubble not found") + val addBubbleBtn = waitAndGetAddBubbleBtn() ?: error("Add Bubble not found") + addBubbleBtn.click() + SystemClock.sleep(1000) } val showBubble = device.wait( Until.findObject( By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) ), FIND_OBJECT_TIMEOUT - ) - showBubble?.run { showBubble.click() } ?: error("Show bubble not found") + ) ?: error("Show bubble not found") + showBubble.click() SystemClock.sleep(1000) } } transitions { - val bubbles = device.wait( + val bubbles: List = device.wait( Until.findObjects( By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) ), FIND_OBJECT_TIMEOUT ) ?: error("No bubbles found") for (entry in bubbles) { - entry?.run { entry.click() } ?: error("Bubble not found") + entry.click() SystemClock.sleep(1000) } } -- cgit v1.2.3-59-g8ed1b