From 149dbcb137e4ea972e7604bf714067cfd4b8ff98 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Mon, 8 Nov 2021 18:12:38 -0500 Subject: [PATCH] Allow overriding getOptionsPopup test method. Test: TAPL Bug: 205491724 Change-Id: Ib4adfa85df6aa9e52922f76479487c9459535fcd --- src/com/android/launcher3/Launcher.java | 10 ++++++++++ src/com/android/launcher3/views/OptionsPopupView.java | 6 ------ .../com/android/launcher3/ui/TaplTestsLauncher3.java | 7 +++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8d92bf2d2e..8154168e4f 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -154,6 +154,7 @@ import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.notification.NotificationListener; import com.android.launcher3.pm.PinRequestHelper; import com.android.launcher3.pm.UserCache; +import com.android.launcher3.popup.ArrowPopup; import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.popup.PopupDataProvider; import com.android.launcher3.popup.SystemShortcut; @@ -3032,4 +3033,13 @@ public class Launcher extends StatefulActivity implements Launche public StatsLogManager getStatsLogManager() { return super.getStatsLogManager().withDefaultInstanceId(mAllAppsSessionLogId); } + + /** + * Returns the current popup for testing, if any. + */ + @VisibleForTesting + @Nullable + public ArrowPopup getOptionsPopup() { + return findViewById(R.id.popup_container); + } } diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index 9774c46624..fc8b4b7edb 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -37,7 +37,6 @@ import android.view.View.OnLongClickListener; import android.widget.Toast; import androidx.annotation.Nullable; -import androidx.annotation.VisibleForTesting; import androidx.core.content.ContextCompat; import com.android.launcher3.AbstractFloatingView; @@ -176,11 +175,6 @@ public class OptionsPopupView extends ArrowPopup return children; } - @VisibleForTesting - public static ArrowPopup getOptionsPopup(Launcher launcher) { - return launcher.findViewById(R.id.popup_container); - } - /** * Returns the list of supported actions */ diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index f29ac23dc3..a9bcd67d66 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -38,7 +38,6 @@ import com.android.launcher3.tapl.Folder; import com.android.launcher3.tapl.FolderIcon; import com.android.launcher3.tapl.Widgets; import com.android.launcher3.tapl.Workspace; -import com.android.launcher3.views.OptionsPopupView; import com.android.launcher3.widget.picker.WidgetsFullSheet; import com.android.launcher3.widget.picker.WidgetsRecyclerView; @@ -102,8 +101,8 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { mDevice.pressMenu(); mDevice.waitForIdle(); executeOnLauncher( - launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu", - OptionsPopupView.getOptionsPopup(launcher) != null)); + launcher -> assertNotNull("Launcher internal state didn't switch to Showing Menu", + launcher.getOptionsPopup())); // Check that pressHome works when the menu is shown. mLauncher.pressHome(); } @@ -286,7 +285,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } private boolean isOptionsPopupVisible(Launcher launcher) { - final ArrowPopup popup = OptionsPopupView.getOptionsPopup(launcher); + final ArrowPopup popup = launcher.getOptionsPopup(); return popup != null && popup.isShown(); }