OptionsPopupMenu.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (C) 2020 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.android.launcher3.tapl;
  17. import androidx.annotation.NonNull;
  18. import androidx.test.uiautomator.By;
  19. import androidx.test.uiautomator.UiObject2;
  20. public class OptionsPopupMenu {
  21. private final LauncherInstrumentation mLauncher;
  22. private final UiObject2 mDeepShortcutsContainer;
  23. OptionsPopupMenu(LauncherInstrumentation launcher) {
  24. mLauncher = launcher;
  25. mDeepShortcutsContainer = launcher.waitForLauncherObject("deep_shortcuts_container");
  26. }
  27. /**
  28. * Returns a menu item with a given label. Fails if it doesn't exist.
  29. */
  30. @NonNull
  31. public OptionsPopupMenuItem getMenuItem(@NonNull final String label) {
  32. final UiObject2 menuItem = mLauncher.waitForObjectInContainer(mDeepShortcutsContainer,
  33. By.text(label));
  34. return new OptionsPopupMenuItem(mLauncher, menuItem);
  35. }
  36. }