Add @TestApi PopupMenu.getMenuListView

This method returns the ListView representing the menu.
It is required to test the actual contents of a PopupMenu.

Bug: 34076597
Test: android.widget.cts.ToolbarTest#testItemViewAttributes,
          android.widget.cts.PopupMenuTest#testItemViewAttributes

Change-Id: Id72a8f482048d724d4fde15b126e0d08e1d18390
This commit is contained in:
Vladislav Kaznacheev
2017-01-11 17:06:28 -08:00
parent 9cea684079
commit f087a17534
2 changed files with 17 additions and 0 deletions

View File

@@ -48793,6 +48793,7 @@ package android.widget {
method public int getGravity();
method public android.view.Menu getMenu();
method public android.view.MenuInflater getMenuInflater();
method public android.widget.ListView getMenuListView();
method public void inflate(int);
method public void setGravity(int);
method public void setOnDismissListener(android.widget.PopupMenu.OnDismissListener);

View File

@@ -17,6 +17,7 @@
package android.widget;
import android.annotation.MenuRes;
import android.annotation.TestApi;
import android.content.Context;
import android.view.Gravity;
import android.view.Menu;
@@ -281,4 +282,19 @@ public class PopupMenu {
*/
void onDismiss(PopupMenu menu);
}
/**
* Returns the {@link ListView} representing the list of menu items in the currently showing
* menu.
*
* @return The view representing the list of menu items.
* @hide
*/
@TestApi
public ListView getMenuListView() {
if (!mPopup.isShowing()) {
return null;
}
return mPopup.getPopup().getListView();
}
}