Verifying events from TouchInteractionService
There is a guaranteed order in which TIS events will be registered
relative to other TIS events. However, relative to the touch events
arriving to the activity, TIS events can come in any order.
Now the event checker verifies 2 independent ordered event sequences:
from TIS, and “the rest” (Main).
Change-Id: I5872e0e3b0b498050a91c67105fbe4a29411375a
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index f3c5191..217a41c 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -42,6 +42,7 @@
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate;
import com.android.launcher3.testing.TestLogging;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.ViewCache;
@@ -330,9 +331,7 @@
return;
}
try {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- TestLogging.recordEvent("start: shortcut: " + packageName);
- }
+ TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: shortcut", packageName);
getSystemService(LauncherApps.class).startShortcut(packageName, id, sourceBounds,
startActivityOptions, user);
} catch (SecurityException | IllegalStateException e) {
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index dda38b3..8d4af11 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -37,6 +37,7 @@
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.testing.TestLogging;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.uioverrides.DisplayRotationListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
@@ -167,9 +168,7 @@
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
} else if (user == null || user.equals(Process.myUserHandle())) {
// Could be launching some bookkeeping activity
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- TestLogging.recordEvent("start: activity: " + intent);
- }
+ TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: activity", intent);
startActivity(intent, optsBundle);
AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(),
Process.myUserHandle(), sourceContainer);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d250658..a53805f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1778,17 +1778,13 @@
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- TestLogging.recordEvent("Key event: " + event);
- }
+ TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Key event", event);
return (event.getKeyCode() == KeyEvent.KEYCODE_HOME) || super.dispatchKeyEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS && ev.getAction() != MotionEvent.ACTION_MOVE) {
- TestLogging.recordEvent("Touch event: " + ev);
- }
+ TestLogging.recordMotionEvent(TestProtocol.SEQUENCE_MAIN, "Touch event", ev);
return super.dispatchTouchEvent(ev);
}
diff --git a/src/com/android/launcher3/testing/TestLogging.java b/src/com/android/launcher3/testing/TestLogging.java
index fd066c1..d522d81 100644
--- a/src/com/android/launcher3/testing/TestLogging.java
+++ b/src/com/android/launcher3/testing/TestLogging.java
@@ -17,13 +17,30 @@
package com.android.launcher3.testing;
import android.util.Log;
+import android.view.MotionEvent;
import com.android.launcher3.Utilities;
public final class TestLogging {
- public static void recordEvent(String event) {
+ private static void recordEventSlow(String sequence, String event) {
+ Log.d(TestProtocol.TAPL_EVENTS_TAG, sequence + " / " + event);
+ }
+
+ public static void recordEvent(String sequence, String event) {
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.TAPL_EVENTS_TAG, event);
+ recordEventSlow(sequence, event);
+ }
+ }
+
+ public static void recordEvent(String sequence, String message, Object parameter) {
+ if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
+ recordEventSlow(sequence, message + ": " + parameter);
+ }
+ }
+
+ public static void recordMotionEvent(String sequence, String message, MotionEvent event) {
+ if (Utilities.IS_RUNNING_IN_TEST_HARNESS && event.getAction() != MotionEvent.ACTION_MOVE) {
+ recordEventSlow(sequence, message + ": " + event);
}
}
}
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index 2f053c9..35a7f3e 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -33,6 +33,8 @@
public static final int BACKGROUND_APP_STATE_ORDINAL = 6;
public static final int HINT_STATE_ORDINAL = 7;
public static final String TAPL_EVENTS_TAG = "TaplEvents";
+ public static final String SEQUENCE_MAIN = "Main";
+ public static final String SEQUENCE_TIS = "TIS";
public static String stateOrdinalToString(int ordinal) {
switch (ordinal) {