Loading src/com/android/launcher3/Launcher.java +1 −1 Original line number Diff line number Diff line Loading @@ -1930,7 +1930,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche @Override public boolean dispatchKeyEvent(KeyEvent event) { TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Key event", event); TestLogging.recordKeyEvent(TestProtocol.SEQUENCE_MAIN, "Key event", event); return (event.getKeyCode() == KeyEvent.KEYCODE_HOME) || super.dispatchKeyEvent(event); } Loading src/com/android/launcher3/testing/TestInformationHandler.java +6 −1 Original line number Diff line number Diff line Loading @@ -137,6 +137,11 @@ public class TestInformationHandler implements ResourceBasedOverride { TestProtocol.sForcePauseTimeout = Long.parseLong(arg); return response; case TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS: response.putBoolean( TestProtocol.TEST_INFO_RESPONSE_FIELD, TestLogging.sHadEventsNotFromTest); return response; default: return null; } Loading src/com/android/launcher3/testing/TestLogging.java +10 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.launcher3.testing; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import com.android.launcher3.Utilities; Loading @@ -25,6 +26,7 @@ import java.util.function.BiConsumer; public final class TestLogging { private static BiConsumer<String, String> sEventConsumer; public static boolean sHadEventsNotFromTest; private static void recordEventSlow(String sequence, String event) { Log.d(TestProtocol.TAPL_EVENTS_TAG, sequence + " / " + event); Loading @@ -46,9 +48,17 @@ public final class TestLogging { } } public static void recordKeyEvent(String sequence, String message, KeyEvent event) { if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { recordEventSlow(sequence, message + ": " + event); if (event.getDeviceId() != -1) sHadEventsNotFromTest = true; } } 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); if (event.getDeviceId() != -1) sHadEventsNotFromTest = true; } } Loading src/com/android/launcher3/testing/TestProtocol.java +1 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ public final class TestProtocol { public static final String REQUEST_RECENT_TASKS_LIST = "recent-tasks-list"; public static final String REQUEST_START_EVENT_LOGGING = "start-event-logging"; public static final String REQUEST_GET_TEST_EVENTS = "get-test-events"; public static final String REQUEST_GET_HAD_NONTEST_EVENTS = "get-had-nontest-events"; public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging"; public static final String REQUEST_CLEAR_DATA = "clear-data"; public static final String REQUEST_IS_TABLET = "is-tablet"; Loading tests/src/com/android/launcher3/util/rule/FailureWatcher.java +21 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ import com.android.launcher3.ui.AbstractLauncherUiTest; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.io.File; import java.io.FileOutputStream; Loading @@ -37,6 +38,26 @@ public class FailureWatcher extends TestWatcher { AbstractLauncherUiTest.checkDetectedLeaks(mLauncher); } @Override public Statement apply(Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { try { base.evaluate(); } finally { if (mLauncher.hadNontestEvents()) { throw new AssertionError( "Launcher received events not sent by the test. This may mean " + "that the touch screen of the lab device has sent false" + " events. See the logcat for TaplEvents tag and look " + "for events with deviceId != -1"); } } } }; } @Override protected void failed(Throwable e, Description description) { onError(mDevice, description, e); Loading Loading
src/com/android/launcher3/Launcher.java +1 −1 Original line number Diff line number Diff line Loading @@ -1930,7 +1930,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche @Override public boolean dispatchKeyEvent(KeyEvent event) { TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Key event", event); TestLogging.recordKeyEvent(TestProtocol.SEQUENCE_MAIN, "Key event", event); return (event.getKeyCode() == KeyEvent.KEYCODE_HOME) || super.dispatchKeyEvent(event); } Loading
src/com/android/launcher3/testing/TestInformationHandler.java +6 −1 Original line number Diff line number Diff line Loading @@ -137,6 +137,11 @@ public class TestInformationHandler implements ResourceBasedOverride { TestProtocol.sForcePauseTimeout = Long.parseLong(arg); return response; case TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS: response.putBoolean( TestProtocol.TEST_INFO_RESPONSE_FIELD, TestLogging.sHadEventsNotFromTest); return response; default: return null; } Loading
src/com/android/launcher3/testing/TestLogging.java +10 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.launcher3.testing; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import com.android.launcher3.Utilities; Loading @@ -25,6 +26,7 @@ import java.util.function.BiConsumer; public final class TestLogging { private static BiConsumer<String, String> sEventConsumer; public static boolean sHadEventsNotFromTest; private static void recordEventSlow(String sequence, String event) { Log.d(TestProtocol.TAPL_EVENTS_TAG, sequence + " / " + event); Loading @@ -46,9 +48,17 @@ public final class TestLogging { } } public static void recordKeyEvent(String sequence, String message, KeyEvent event) { if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { recordEventSlow(sequence, message + ": " + event); if (event.getDeviceId() != -1) sHadEventsNotFromTest = true; } } 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); if (event.getDeviceId() != -1) sHadEventsNotFromTest = true; } } Loading
src/com/android/launcher3/testing/TestProtocol.java +1 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ public final class TestProtocol { public static final String REQUEST_RECENT_TASKS_LIST = "recent-tasks-list"; public static final String REQUEST_START_EVENT_LOGGING = "start-event-logging"; public static final String REQUEST_GET_TEST_EVENTS = "get-test-events"; public static final String REQUEST_GET_HAD_NONTEST_EVENTS = "get-had-nontest-events"; public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging"; public static final String REQUEST_CLEAR_DATA = "clear-data"; public static final String REQUEST_IS_TABLET = "is-tablet"; Loading
tests/src/com/android/launcher3/util/rule/FailureWatcher.java +21 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ import com.android.launcher3.ui.AbstractLauncherUiTest; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.io.File; import java.io.FileOutputStream; Loading @@ -37,6 +38,26 @@ public class FailureWatcher extends TestWatcher { AbstractLauncherUiTest.checkDetectedLeaks(mLauncher); } @Override public Statement apply(Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { try { base.evaluate(); } finally { if (mLauncher.hadNontestEvents()) { throw new AssertionError( "Launcher received events not sent by the test. This may mean " + "that the touch screen of the lab device has sent false" + " events. See the logcat for TaplEvents tag and look " + "for events with deviceId != -1"); } } } }; } @Override protected void failed(Throwable e, Description description) { onError(mDevice, description, e); Loading