@Test @MediumTest public void testBasicContent() throws Throwable { final Builder menuBuilder = new Builder(); menuBuilder.wireToActionButton(); onView(withId(R.id.test_button)).perform(click()); assertNotNull("Popup menu created", mPopupMenu); final MenuItem hightlightItem = mPopupMenu.getMenu().findItem(R.id.action_highlight); assertEquals(mResources.getString(R.string.popup_menu_highlight_description), MenuItemCompat.getContentDescription(hightlightItem)); assertEquals(mResources.getString(R.string.popup_menu_highlight_tooltip), MenuItemCompat.getTooltipText(hightlightItem)); final MenuItem editItem = mPopupMenu.getMenu().findItem(R.id.action_edit); assertNotNull(MenuItemCompat.getContentDescription(hightlightItem)); assertNotNull(MenuItemCompat.getTooltipText(hightlightItem)); mActivityTestRule.runOnUiThread(new Runnable() { @Override public void run() { MenuItemCompat.setContentDescription(editItem, mResources.getString(R.string.popup_menu_edit_description)); MenuItemCompat.setTooltipText(editItem, mResources.getString(R.string.popup_menu_edit_tooltip)); } }); onView(withClassName(Matchers.is(DROP_DOWN_CLASS_NAME))) .inRoot(isPlatformPopup()).check(matches(isDisplayed())); onData(anything()).atPosition(0).check(matches(isDisplayed())); onView(withText(mResources.getString(R.string.popup_menu_highlight))) .inRoot(withDecorView(not(is(mMainDecorView)))) .check(matches(isDisplayed())) .check(matches(selfOrParentWithContentDescription( mResources.getString(R.string.popup_menu_highlight_description)))); onData(anything()).atPosition(1).check(matches(isDisplayed())); onView(withText(mResources.getString(R.string.popup_menu_edit))) .inRoot(withDecorView(not(is(mMainDecorView)))) .check(matches(isDisplayed())) .check(matches(selfOrParentWithContentDescription( mResources.getString(R.string.popup_menu_edit_description)))); onData(anything()).atPosition(2).check(matches(isDisplayed())); onView(withText(mResources.getString(R.string.popup_menu_delete))) .inRoot(withDecorView(not(is(mMainDecorView)))) .check(matches(isDisplayed())); onData(anything()).atPosition(3).check(matches(isDisplayed())); onView(withText(mResources.getString(R.string.popup_menu_ignore))) .inRoot(withDecorView(not(is(mMainDecorView)))) .check(matches(isDisplayed())); onData(anything()).atPosition(4).check(matches(isDisplayed())); onView(withText(mResources.getString(R.string.popup_menu_share))) .inRoot(withDecorView(not(is(mMainDecorView)))) .check(matches(isDisplayed())); onData(anything()).atPosition(5).check(matches(isDisplayed())); onView(withText(mResources.getString(R.string.popup_menu_print))) .inRoot(withDecorView(not(is(mMainDecorView)))) .check(matches(isDisplayed())); onView(withText(mResources.getString(R.string.popup_menu_share_email))) .inRoot(withDecorView(not(is(mMainDecorView)))) .check(doesNotExist()); onView(withText(mResources.getString(R.string.popup_menu_share_circles))) .inRoot(withDecorView(not(is(mMainDecorView)))) .check(doesNotExist()); }
@NonNull public Menu getMenu() { return mMenu; }
PopupMenu { @NonNull public Menu getMenu() { return mMenu; } }
PopupMenu { @NonNull public Menu getMenu() { return mMenu; } PopupMenu(@NonNull Context context, @NonNull View anchor);  PopupMenu(@NonNull Context context, @NonNull View anchor, int gravity);  PopupMenu(@NonNull Context context, @NonNull View anchor, int gravity,
            @AttrRes int popupStyleAttr, @StyleRes int popupStyleRes); }
PopupMenu { @NonNull public Menu getMenu() { return mMenu; } PopupMenu(@NonNull Context context, @NonNull View anchor);  PopupMenu(@NonNull Context context, @NonNull View anchor, int gravity);  PopupMenu(@NonNull Context context, @NonNull View anchor, int gravity,
            @AttrRes int popupStyleAttr, @StyleRes int popupStyleRes); void setGravity(int gravity); int getGravity(); @NonNull View.OnTouchListener getDragToOpenListener(); @NonNull Menu getMenu(); @NonNull MenuInflater getMenuInflater(); void inflate(@MenuRes int menuRes); void show(); void dismiss(); void setOnMenuItemClickListener(@Nullable OnMenuItemClickListener listener); void setOnDismissListener(@Nullable OnDismissListener listener); }
PopupMenu { @NonNull public Menu getMenu() { return mMenu; } PopupMenu(@NonNull Context context, @NonNull View anchor);  PopupMenu(@NonNull Context context, @NonNull View anchor, int gravity);  PopupMenu(@NonNull Context context, @NonNull View anchor, int gravity,
            @AttrRes int popupStyleAttr, @StyleRes int popupStyleRes); void setGravity(int gravity); int getGravity(); @NonNull View.OnTouchListener getDragToOpenListener(); @NonNull Menu getMenu(); @NonNull MenuInflater getMenuInflater(); void inflate(@MenuRes int menuRes); void show(); void dismiss(); void setOnMenuItemClickListener(@Nullable OnMenuItemClickListener listener); void setOnDismissListener(@Nullable OnDismissListener listener);  }