From 503ce966efb399b81e422b71c3e51f823c26fb67 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Mon, 15 Apr 2024 15:58:19 +0000 Subject: [PATCH] Revert^2 "Wait for LauncherModel loaded in waitForLauncherInitialized" This reverts commit b80c6c347a6c3c425bcb317bfba3c3f789db8fd1. Reason for revert: The original change was not the cause for the test failures Change-Id: Icfe0da43a96f5471076554c4dd25eae649bee81e --- .../launcher3/testing/TestInformationHandler.java | 10 ++++++++++ .../launcher3/testing/shared/TestProtocol.java | 1 + .../launcher3/tapl/LauncherInstrumentation.java | 14 +++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index d5c9b9fa89..ab8b94e81d 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -41,6 +41,7 @@ import androidx.annotation.Keep; import androidx.annotation.Nullable; import androidx.core.view.WindowInsetsCompat; +import com.android.launcher3.BaseActivity; import com.android.launcher3.BubbleTextView; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; @@ -136,6 +137,10 @@ public class TestInformationHandler implements ResourceBasedOverride { }); } + case TestProtocol.REQUEST_IS_LAUNCHER_BINDING: { + return getUIProperty(Bundle::putBoolean, t -> isLauncherBinding(), () -> true); + } + case TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED: { return getUIProperty(Bundle::putBoolean, t -> isLauncherInitialized(), () -> true); } @@ -484,6 +489,11 @@ public class TestInformationHandler implements ResourceBasedOverride { return target; } + protected boolean isLauncherBinding() { + BaseActivity baseActivity = Launcher.ACTIVITY_TRACKER.getCreatedActivity(); + return baseActivity != null && baseActivity.isBindingItems(); + } + protected boolean isLauncherInitialized() { return Launcher.ACTIVITY_TRACKER.getCreatedActivity() == null || LauncherAppState.getInstance(mContext).getModel().isModelLoaded(); diff --git a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java index fea0330a16..d029dd8457 100644 --- a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -87,6 +87,7 @@ public final class TestProtocol { "home-to-all-apps-swipe-height"; public static final String REQUEST_ICON_HEIGHT = "icon-height"; + public static final String REQUEST_IS_LAUNCHER_BINDING = "is-launcher-binding"; public static final String REQUEST_IS_LAUNCHER_INITIALIZED = "is-launcher-initialized"; public static final String REQUEST_IS_LAUNCHER_LAUNCHER_ACTIVITY_STARTED = "is-launcher-activity-started"; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 0a52955cbe..608ee34acf 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1002,6 +1002,19 @@ public final class LauncherInstrumentation { } public void waitForLauncherInitialized() { + boolean isLauncherBinding = true; + for (int i = 0; i < 100; ++i) { + isLauncherBinding = getTestInfo(TestProtocol.REQUEST_IS_LAUNCHER_BINDING) + .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); + if (!isLauncherBinding) { + break; + } + SystemClock.sleep(100); + } + if (isLauncherBinding) { + fail("Launcher didn't finish binding"); + } + for (int i = 0; i < 100; ++i) { if (getTestInfo( TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED). @@ -1010,7 +1023,6 @@ public final class LauncherInstrumentation { } SystemClock.sleep(100); } - checkForAnomaly(); fail("Launcher didn't initialize"); }