>(), any())
verify(launcherBinder).bindDeepShortcuts()
verify(launcherBinder).bindWidgets()
- verify(modelDelegate).loadAndBindOtherItems(anyOrNull())
+ verify(modelDelegate).loadAndBindOtherItems()
verify(iconCacheUpdateHandler).finish()
verify(modelDelegate).modelLoadComplete()
verify(transaction).commit()
diff --git a/tests/src/com/android/launcher3/ui/BaseLauncherTaplTest.java b/tests/src/com/android/launcher3/ui/BaseLauncherTaplTest.java
index c9577dbf52..59800ecf6f 100644
--- a/tests/src/com/android/launcher3/ui/BaseLauncherTaplTest.java
+++ b/tests/src/com/android/launcher3/ui/BaseLauncherTaplTest.java
@@ -40,6 +40,7 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.platform.test.flag.junit.SetFlagsRule;
+import android.platform.test.rule.ExtendedLongPressTimeoutRule;
import android.platform.test.rule.LimitDevicesRule;
import android.util.Log;
@@ -57,7 +58,6 @@ import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.Wait;
-import com.android.launcher3.util.rule.ExtendedLongPressTimeoutRule;
import com.android.launcher3.util.rule.FailureWatcher;
import com.android.launcher3.util.rule.MutualExclusionRule;
import com.android.launcher3.util.rule.SamplerRule;
diff --git a/tests/src/com/android/launcher3/util/rule/ExtendedLongPressTimeoutRule.java b/tests/src/com/android/launcher3/util/rule/ExtendedLongPressTimeoutRule.java
deleted file mode 100644
index b04df7ec01..0000000000
--- a/tests/src/com/android/launcher3/util/rule/ExtendedLongPressTimeoutRule.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.util.rule;
-
-import static com.android.launcher3.util.TestUtil.grantWriteSecurePermission;
-
-import android.content.ContentResolver;
-import android.provider.Settings;
-import android.util.Log;
-import android.view.ViewConfiguration;
-
-import androidx.test.InstrumentationRegistry;
-
-import com.android.launcher3.BuildConfig;
-
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-/**
- * Increases the device's long-press timeout in remote tests to reduce flakiness in slow-running
- * devices.
- */
-public class ExtendedLongPressTimeoutRule implements TestRule {
-
- private static final String TAG = "ExtendedLongPressTimeoutRule";
-
- private static final float LONG_PRESS_TIMEOUT_MULTIPLIER = 10f;
-
- @Override
- public Statement apply(Statement base, Description description) {
- if (BuildConfig.IS_STUDIO_BUILD) {
- // Skip rule on studio builds since cancelling a test run will not run the finally block
- return base;
- }
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- ContentResolver contentResolver = InstrumentationRegistry.getInstrumentation()
- .getContext()
- .getContentResolver();
- int prevLongPressTimeout = Settings.Secure.getInt(
- contentResolver,
- Settings.Secure.LONG_PRESS_TIMEOUT,
- ViewConfiguration.getLongPressTimeout());
- int newLongPressTimeout =
- (int) (prevLongPressTimeout * LONG_PRESS_TIMEOUT_MULTIPLIER);
-
- try {
- Log.d(TAG, "In try-block: Setting long press timeout from "
- + prevLongPressTimeout + "ms to " + newLongPressTimeout + "ms");
- grantWriteSecurePermission();
- Settings.Secure.putInt(
- contentResolver,
- Settings.Secure.LONG_PRESS_TIMEOUT,
- (int) (prevLongPressTimeout * LONG_PRESS_TIMEOUT_MULTIPLIER));
-
- base.evaluate();
- } catch (Exception e) {
- Log.e(TAG, "Error", e);
- throw e;
- } finally {
- Log.d(TAG, "In finally-block: resetting long press timeout to "
- + prevLongPressTimeout + "ms");
- grantWriteSecurePermission();
- Settings.Secure.putInt(
- contentResolver,
- Settings.Secure.LONG_PRESS_TIMEOUT,
- prevLongPressTimeout);
- }
- }
- };
- }
-}
diff --git a/tests/src_tapl_build_config/com/android/launcher3/testing/BuildConfig.java b/tests/src_tapl_build_config/com/android/launcher3/testing/BuildConfig.java
new file mode 100644
index 0000000000..b60f517953
--- /dev/null
+++ b/tests/src_tapl_build_config/com/android/launcher3/testing/BuildConfig.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.testing;
+
+public final class BuildConfig {
+ public static final boolean DEBUG = Boolean.parseBoolean("true");
+
+ // Field from default config.
+ public static final boolean IS_STUDIO_BUILD = false;
+}
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index fa94cbf2f7..6b43bf6131 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -152,6 +152,10 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
/**
* Dismissed all tasks by scrolling to Clear-all button and pressing it.
+ *
+ * NOTE: Fails if there are already no recent tasks. If a test needs to start with an empty task
+ * list, check {@link #hasTasks} before calling this since the previous test may have already
+ * cleared the task list.
*/
public void dismissAllTasks() {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java
index ac2748e6a1..acf4c6c2b2 100644
--- a/tests/tapl/com/android/launcher3/tapl/Widgets.java
+++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java
@@ -254,6 +254,7 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer
targetAppSelector);
final UiObject2 searchBar = findSearchBar();
+
// If header's title is under or above search bar, let's not process the header yet,
// scroll a bit more to bring the header into visible area.
if (headerTitle != null
@@ -270,6 +271,14 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer
// to briefly appear to handle the gesture, which can break our test.
boolean isHeaderOutOfGestureRegion = headerTitle.getVisibleCenter().y
< mLauncher.getBottomGestureStartOnScreen();
+
+ if (!isHeaderOutOfGestureRegion) {
+ log("Test app's header is not out of gesture region, scrolling up");
+ mLauncher.scrollDownByDistance(widgetListView, scrollDistance);
+ isHeaderOutOfGestureRegion = true;
+ }
+
+
if (!hasHeaderExpanded && isHeaderOutOfGestureRegion) {
log("Header has not been expanded. Click to expand.");
hasHeaderExpanded = true;
@@ -286,6 +295,7 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer
UiObject2 widgetsContainer = mLauncher.findObjectInContainer(
rightPane != null ? rightPane : widgetListView,
widgetsContainerSelector);
+
if (widgetsContainer != null) {
log("Widgets container found.");
return widgetsContainer;