From a1f0a106624012bba5ae6d060b051e84e27b9a23 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 29 Apr 2020 14:22:46 -0700 Subject: [PATCH] Removing tracking activity start/stop events They were not especially useful in investigations; besides, these events can be sent by the system asynchronously for actions that happened before entering TAPL, causing flakes. Change-Id: I72b5aad5521c6c0969f5b657b3db3e4d855f1d64 --- src/com/android/launcher3/Launcher.java | 3 --- .../com/android/launcher3/tapl/Background.java | 18 ------------------ .../com/android/launcher3/tapl/Launchable.java | 7 ++----- .../tapl/LauncherInstrumentation.java | 8 -------- .../launcher3/tapl/OptionsPopupMenuItem.java | 8 -------- .../android/launcher3/tapl/OverviewTask.java | 2 -- .../com/android/launcher3/tapl/Workspace.java | 4 ---- 7 files changed, 2 insertions(+), 48 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 070a3926c4..e556bd6b98 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -921,8 +921,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } }); } - - TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Activity.onStop"); } @Override @@ -936,7 +934,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, mAppWidgetHost.setListenIfResumed(true); TraceHelper.INSTANCE.endSection(traceToken); - TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Activity.onStart"); } private void handleDeferredResume() { diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index 80b8e89601..94ab780649 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -71,7 +71,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer { } protected void goToOverviewUnchecked() { - final boolean launcherWasVisible = mLauncher.isLauncherVisible(); switch (mLauncher.getNavigationModel()) { case ZERO_BUTTON: { final int centerX = mLauncher.getDevice().getDisplayWidth() / 2; @@ -138,11 +137,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer { break; } expectSwitchToOverviewEvents(); - - if (!launcherWasVisible) { - mLauncher.expectEvent( - TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START_ACTIVITY); - } } private void expectSwitchToOverviewEvents() { @@ -192,11 +186,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer { } final boolean isZeroButton = mLauncher.getNavigationModel() == LauncherInstrumentation.NavigationModel.ZERO_BUTTON; - if (!launcherWasVisible) { - mLauncher.expectEvent( - TestProtocol.SEQUENCE_MAIN, - LauncherInstrumentation.EVENT_START_ACTIVITY); - } mLauncher.swipeToState(startX, startY, endX, endY, 20, expectedState, launcherWasVisible && isZeroButton ? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE @@ -208,11 +197,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer { // Double press the recents button. UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps"); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); - if (!launcherWasVisible) { - mLauncher.expectEvent( - TestProtocol.SEQUENCE_MAIN, - LauncherInstrumentation.EVENT_START_ACTIVITY); - } mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL); mLauncher.getOverview(); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); @@ -220,8 +204,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer { break; } mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT); - mLauncher.expectEvent( - TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_STOP_ACTIVITY); } protected String getSwipeHeightRequestName() { diff --git a/tests/tapl/com/android/launcher3/tapl/Launchable.java b/tests/tapl/com/android/launcher3/tapl/Launchable.java index df7436ce8f..13ecfb8589 100644 --- a/tests/tapl/com/android/launcher3/tapl/Launchable.java +++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java @@ -25,8 +25,6 @@ import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; -import com.android.launcher3.testing.TestProtocol; - /** * Ancestor for AppIcon and AppMenuItem. */ @@ -64,8 +62,6 @@ abstract class Launchable { event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Launching an app didn't open a new window: " + mObject.getText()); expectActivityStartEvents(); - mLauncher.expectEvent( - TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_STOP_ACTIVITY); mLauncher.assertTrue( "App didn't start: " + selector, @@ -76,7 +72,8 @@ abstract class Launchable { /** * Drags an object to the center of homescreen. - * @param startsActivity whether it's expected to start an activity. + * + * @param startsActivity whether it's expected to start an activity. * @param isWidgetShortcut whether we drag a widget shortcut */ public void dragToWorkspace(boolean startsActivity, boolean isWidgetShortcut) { diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index d46845f118..bad8be5133 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -97,8 +97,6 @@ public final class LauncherInstrumentation { private static final Pattern EVENT_TOUCH_UP = getTouchEventPattern("ACTION_UP"); private static final Pattern EVENT_TOUCH_CANCEL = getTouchEventPattern("ACTION_CANCEL"); private static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers"); - static final Pattern EVENT_START_ACTIVITY = Pattern.compile("Activity\\.onStart"); - static final Pattern EVENT_STOP_ACTIVITY = Pattern.compile("Activity\\.onStop"); static final Pattern EVENT_START = Pattern.compile("start:"); static final Pattern EVENT_TOUCH_DOWN_TIS = getTouchEventPatternTIS("ACTION_DOWN"); @@ -680,14 +678,8 @@ public final class LauncherInstrumentation { ? GestureScope.INSIDE_TO_OUTSIDE : GestureScope.OUTSIDE); } - if (!launcherWasVisible) { - expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_START_ACTIVITY); - } } } else { - if (!launcherWasVisible) { - expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_START_ACTIVITY); - } log("Hierarchy before clicking home:"); dumpViewHierarchy(); log(action = "clicking home button from " + getVisibleStateMessage()); diff --git a/tests/tapl/com/android/launcher3/tapl/OptionsPopupMenuItem.java b/tests/tapl/com/android/launcher3/tapl/OptionsPopupMenuItem.java index d1268ccc2c..42b6bc9b3a 100644 --- a/tests/tapl/com/android/launcher3/tapl/OptionsPopupMenuItem.java +++ b/tests/tapl/com/android/launcher3/tapl/OptionsPopupMenuItem.java @@ -15,8 +15,6 @@ */ package com.android.launcher3.tapl; -import android.os.Build; - import androidx.annotation.NonNull; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; @@ -44,12 +42,6 @@ public class OptionsPopupMenuItem { + mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject)); mLauncher.clickLauncherObject(mObject); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START); - if (!Build.MODEL.contains("Cuttlefish") || - Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q && - !"R".equals(Build.VERSION.CODENAME)) { - mLauncher.expectEvent( - TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_STOP_ACTIVITY); - } mLauncher.assertTrue( "App didn't start: " + By.pkg(expectedPackageName), mLauncher.getDevice().wait(Until.hasObject(By.pkg(expectedPackageName)), diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java index fae5f19126..b2359190ba 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java @@ -79,8 +79,6 @@ public final class OverviewTask { () -> "Launching task didn't open a new window: " + mTask.getParent().getContentDescription()); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT); - mLauncher.expectEvent( - TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_STOP_ACTIVITY); } return new Background(mLauncher); } diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 0d91dc2db8..9f809173b7 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -229,10 +229,6 @@ public final class Workspace extends Home { if (startsActivity || isWidgetShortcut) { launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START); } - if (startsActivity) { - launcher.expectEvent( - TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_STOP_ACTIVITY); - } LauncherInstrumentation.log("dragIconToWorkspace: end"); launcher.waitUntilGone("drop_target_bar"); }