StubContextMenu implements ContextMenu { @Override public SubMenu addSubMenu(CharSequence title) { Log.i(TAG, "addSubMenu(CharSequence title) " + title); throw new UnsupportedOperationException(OPERATION_NOT_SUPPORTED_BY_FOGGER); } StubContextMenu(Context context); @Override MenuItem add(CharSequence title); @Override MenuItem add(int titleRes); @Override MenuItem add(int groupId, int itemId, int order, CharSequence title); @Override MenuItem add(int groupId, int itemId, int order, int titleRes); @Override SubMenu addSubMenu(CharSequence title); @Override SubMenu addSubMenu(int titleRes); @Override SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title); @Override SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes); @Override int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, //NOSONAR
                                Intent intent, int flags, MenuItem[] outSpecificItems); @Override void removeItem(int id); @Override void removeGroup(int groupId); @Override void clear(); @Override void setGroupCheckable(int group, boolean checkable, boolean exclusive); @Override void setGroupVisible(int group, boolean visible); @Override void setGroupEnabled(int group, boolean enabled); @Override boolean hasVisibleItems(); @Override MenuItem findItem(int id); @Override int size(); @Override MenuItem getItem(int index); @Override void close(); @Override boolean performShortcut(int keyCode, KeyEvent event, int flags); @Override boolean isShortcutKey(int keyCode, KeyEvent event); @Override boolean performIdentifierAction(int id, int flags); @Override void setQwertyMode(boolean isQwerty); CharSequence[] getTitlesArray(); @Override ContextMenu setHeaderTitle(int titleRes); @Override ContextMenu setHeaderTitle(CharSequence title); @Override ContextMenu setHeaderIcon(int iconRes); @Override ContextMenu setHeaderIcon(Drawable icon); @Override ContextMenu setHeaderView(View view); @Override void clearHeader(); static final String TAG; }
@Test public void shouldName() { catchException(stubContextMenu).addSubMenu("sadf"); assertThat(CatchException.<Exception>caughtException()).isInstanceOf(UnsupportedOperationException.class); }