From 839fb7b3aedee54065e3cba307c878df25cb3343 Mon Sep 17 00:00:00 2001 From: vadimt Date: Mon, 22 Jun 2020 15:01:49 -0700 Subject: [PATCH] Eliminating messages that launcher activity is frozen They were ultimately caused by killing Launcher process from tests. Now having a test info handler request to clear db. Bug: 152629799 Change-Id: Ia81ddc3e338718c4cff08c7396b9fda1b7091024 --- .../testing/DebugTestInformationHandler.java | 13 +++++++++++++ .../android/launcher3/testing/TestProtocol.java | 1 + .../launcher3/ui/AbstractLauncherUiTest.java | 14 +++----------- .../launcher3/tapl/LauncherInstrumentation.java | 4 ++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java index ad21106759..0b7d4bf27e 100644 --- a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java +++ b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java @@ -18,6 +18,8 @@ package com.android.launcher3.testing; import static android.graphics.Bitmap.Config.ARGB_8888; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; + import android.content.Context; import android.graphics.Bitmap; import android.graphics.Color; @@ -28,6 +30,9 @@ import android.view.View; import androidx.annotation.Keep; +import com.android.launcher3.LauncherAppState; +import com.android.launcher3.LauncherSettings; + import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; @@ -165,6 +170,14 @@ public class DebugTestInformationHandler extends TestInformationHandler { return response; } + case TestProtocol.REQUEST_CLEAR_DATA: { + LauncherSettings.Settings.call(mContext.getContentResolver(), + LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB); + MAIN_EXECUTOR.submit(() -> + LauncherAppState.getInstance(mContext).getModel().forceReload()); + return response; + } + default: return super.call(method); } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 49da7b3d8d..3ca08fd8ec 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -91,6 +91,7 @@ public final class TestProtocol { 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_STOP_EVENT_LOGGING = "stop-event-logging"; + public static final String REQUEST_CLEAR_DATA = "clear-data"; public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 3d39d254b1..858e183ab7 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -300,17 +300,9 @@ public abstract class AbstractLauncherUiTest { checkDetectedLeaks(mLauncher); } - protected void clearLauncherData() throws IOException, InterruptedException { - if (TestHelpers.isInLauncherProcess()) { - LauncherSettings.Settings.call(mTargetContext.getContentResolver(), - LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB); - resetLoaderState(); - } else { - clearPackageData(mDevice.getLauncherPackageName()); - mLauncher.enableDebugTracing(); - mLauncherPid = mLauncher.getPid(); - mLauncher.waitForLauncherInitialized(); - } + protected void clearLauncherData() { + mLauncher.clearLauncherData(); + mLauncher.waitForLauncherInitialized(); } /** diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index f634ce1951..5cf5d0fa88 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1335,6 +1335,10 @@ public final class LauncherInstrumentation { return tasks; } + public void clearLauncherData() { + getTestInfo(TestProtocol.REQUEST_CLEAR_DATA); + } + public Closable eventsCheck() { Assert.assertTrue("Nested event checking", mEventChecker == null); disableSensorRotation();