Adding events check to TAPL method for flinging to clear all.

Clear all impl separate from public method, as nested events checking fails assertions.

Fix: 398771634
Test: TaplTestsQuickstep#testDismissLastGridRow
Flag: com.android.launcher3.enable_expressive_dismiss_task_motion
Change-Id: I7f86c0667034c95b4b21dd0fd75307ca0f8cf48d
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index f633d48..214f158 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -157,7 +157,7 @@
              LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                      "dismissing all tasks")) {
             final BySelector clearAllSelector = mLauncher.getOverviewObjectSelector("clear_all");
-            flingForwardUntilClearAllVisible();
+            flingForwardUntilClearAllVisibleImpl();
 
             final Runnable clickClearAll = () -> mLauncher.clickLauncherObject(
                     mLauncher.waitForObjectInContainer(verifyActiveContainer(),
@@ -181,10 +181,19 @@
      * Scrolls until Clear-all button is visible.
      */
     public void flingForwardUntilClearAllVisible() {
-        final BySelector clearAllSelector = mLauncher.getOverviewObjectSelector("clear_all");
-        for (int i = 0; i < FLINGS_FOR_DISMISS_LIMIT
-                && !verifyActiveContainer().hasObject(clearAllSelector); ++i) {
-            flingForwardImpl();
+        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
+            flingForwardUntilClearAllVisibleImpl();
+        }
+    }
+
+    private void flingForwardUntilClearAllVisibleImpl() {
+        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+                "flinging forward to clear all")) {
+            final BySelector clearAllSelector = mLauncher.getOverviewObjectSelector("clear_all");
+            for (int i = 0; i < FLINGS_FOR_DISMISS_LIMIT && !verifyActiveContainer().hasObject(
+                    clearAllSelector); ++i) {
+                flingForwardImpl();
+            }
         }
     }