From 6be6906321a2d05aa4a5e210d85fdd116fbbeab9 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Mon, 22 Jan 2024 16:22:39 -0800 Subject: [PATCH] Send ACTION_UP if there is an exception Test: presubmit Flag: N/A Bug: 187761685 Change-Id: I22fa5a9da7384a44b35bdd3b21c79837dbbd11d2 --- .../tapl/LauncherInstrumentation.java | 28 +++++++++++-------- .../launcher3/tapl/WidgetResizeFrame.java | 14 ++++++---- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index f68e12cc88..b501bd3fad 100644 --- a/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -2055,11 +2055,14 @@ public final class LauncherInstrumentation { final long downTime = SystemClock.uptimeMillis(); sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, targetCenter, GestureScope.DONT_EXPECT_PILFER); - expectEvent(TestProtocol.SEQUENCE_MAIN, longClickEvent); - final UiObject2 result = waitForLauncherObject(resName); - sendPointer(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, targetCenter, - GestureScope.DONT_EXPECT_PILFER); - return result; + try { + expectEvent(TestProtocol.SEQUENCE_MAIN, longClickEvent); + final UiObject2 result = waitForLauncherObject(resName); + return result; + } finally { + sendPointer(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, targetCenter, + GestureScope.DONT_EXPECT_PILFER); + } } @NonNull @@ -2070,12 +2073,15 @@ public final class LauncherInstrumentation { sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, targetCenter, GestureScope.DONT_EXPECT_PILFER, InputDevice.SOURCE_MOUSE, /* isRightClick= */ true); - expectEvent(TestProtocol.SEQUENCE_MAIN, rightClickEvent); - final UiObject2 result = waitForLauncherObject(resName); - sendPointer(downTime, SystemClock.uptimeMillis(), ACTION_UP, targetCenter, - GestureScope.DONT_EXPECT_PILFER, InputDevice.SOURCE_MOUSE, - /* isRightClick= */ true); - return result; + try { + expectEvent(TestProtocol.SEQUENCE_MAIN, rightClickEvent); + final UiObject2 result = waitForLauncherObject(resName); + return result; + } finally { + sendPointer(downTime, SystemClock.uptimeMillis(), ACTION_UP, targetCenter, + GestureScope.DONT_EXPECT_PILFER, InputDevice.SOURCE_MOUSE, + /* isRightClick= */ true); + } } private static int getSystemIntegerRes(Context context, String resName) { diff --git a/tests/multivalentTests/tapl/com/android/launcher3/tapl/WidgetResizeFrame.java b/tests/multivalentTests/tapl/com/android/launcher3/tapl/WidgetResizeFrame.java index ec1cbd8ec1..d0573e077b 100644 --- a/tests/multivalentTests/tapl/com/android/launcher3/tapl/WidgetResizeFrame.java +++ b/tests/multivalentTests/tapl/com/android/launcher3/tapl/WidgetResizeFrame.java @@ -16,6 +16,7 @@ package com.android.launcher3.tapl; import static com.android.launcher3.tapl.Launchable.DEFAULT_DRAG_STEPS; + import static org.junit.Assert.assertTrue; import android.graphics.Point; @@ -61,11 +62,14 @@ public class WidgetResizeFrame { final long downTime = SystemClock.uptimeMillis(); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, targetStart, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); - mLauncher.movePointer(targetStart, targetDest, DEFAULT_DRAG_STEPS, - true, downTime, downTime, true, - LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); - mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, targetDest, - LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); + try { + mLauncher.movePointer(targetStart, targetDest, DEFAULT_DRAG_STEPS, + true, downTime, downTime, true, + LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); + } finally { + mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, targetDest, + LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); + } try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer( "want to return resized widget resize frame")) {