Merge "Allow overriding getOptionsPopup test method." into sc-v2-dev

This commit is contained in:
Brian Isganitis 2021-11-10 19:56:07 +00:00 committed by Android (Google) Code Review
commit bc1b36344f
3 changed files with 13 additions and 10 deletions

View File

@ -154,6 +154,7 @@ import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.notification.NotificationListener; import com.android.launcher3.notification.NotificationListener;
import com.android.launcher3.pm.PinRequestHelper; import com.android.launcher3.pm.PinRequestHelper;
import com.android.launcher3.pm.UserCache; import com.android.launcher3.pm.UserCache;
import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.popup.PopupDataProvider; import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.popup.SystemShortcut;
@ -3032,4 +3033,13 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
public StatsLogManager getStatsLogManager() { public StatsLogManager getStatsLogManager() {
return super.getStatsLogManager().withDefaultInstanceId(mAllAppsSessionLogId); return super.getStatsLogManager().withDefaultInstanceId(mAllAppsSessionLogId);
} }
/**
* Returns the current popup for testing, if any.
*/
@VisibleForTesting
@Nullable
public ArrowPopup<?> getOptionsPopup() {
return findViewById(R.id.popup_container);
}
} }

View File

@ -37,7 +37,6 @@ import android.view.View.OnLongClickListener;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.AbstractFloatingView;
@ -176,11 +175,6 @@ public class OptionsPopupView extends ArrowPopup<Launcher>
return children; return children;
} }
@VisibleForTesting
public static ArrowPopup getOptionsPopup(Launcher launcher) {
return launcher.findViewById(R.id.popup_container);
}
/** /**
* Returns the list of supported actions * Returns the list of supported actions
*/ */

View File

@ -38,7 +38,6 @@ import com.android.launcher3.tapl.Folder;
import com.android.launcher3.tapl.FolderIcon; import com.android.launcher3.tapl.FolderIcon;
import com.android.launcher3.tapl.Widgets; import com.android.launcher3.tapl.Widgets;
import com.android.launcher3.tapl.Workspace; 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.WidgetsFullSheet;
import com.android.launcher3.widget.picker.WidgetsRecyclerView; import com.android.launcher3.widget.picker.WidgetsRecyclerView;
@ -102,8 +101,8 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
mDevice.pressMenu(); mDevice.pressMenu();
mDevice.waitForIdle(); mDevice.waitForIdle();
executeOnLauncher( executeOnLauncher(
launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu", launcher -> assertNotNull("Launcher internal state didn't switch to Showing Menu",
OptionsPopupView.getOptionsPopup(launcher) != null)); launcher.getOptionsPopup()));
// Check that pressHome works when the menu is shown. // Check that pressHome works when the menu is shown.
mLauncher.pressHome(); mLauncher.pressHome();
} }
@ -286,7 +285,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
} }
private boolean isOptionsPopupVisible(Launcher launcher) { private boolean isOptionsPopupVisible(Launcher launcher) {
final ArrowPopup popup = OptionsPopupView.getOptionsPopup(launcher); final ArrowPopup<?> popup = launcher.getOptionsPopup();
return popup != null && popup.isShown(); return popup != null && popup.isShown();
} }