FileDocCategorySizeDatePackage
MenuWith1ItemTest.javaAPI DocAndroid 5.1 API3091Thu Mar 12 22:22:12 GMT 2015android.view.menu

MenuWith1ItemTest

public class MenuWith1ItemTest extends android.test.ActivityInstrumentationTestCase

Fields Summary
private android.view.menu.MenuWith1Item
mActivity
Constructors Summary
public MenuWith1ItemTest()

        super("com.android.frameworks.coretests", MenuWith1Item.class);
    
Methods Summary
protected voidsetUp()

        super.setUp();
        mActivity = getActivity();
    
public voidtestItemClick()


        // Open menu, click on an item
        KeyUtils.tapMenuKey(this);
        getInstrumentation().waitForIdleSync();
        assertFalse("Item seems to have been clicked before we clicked on it", mActivity
                .wasItemClicked(0));
        sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
        assertTrue("Item doesn't seem to have registered our click", mActivity.wasItemClicked(0));
    
public voidtestPreconditions()

        assertNotNull(mActivity);
        assertFalse(mActivity.getButton().isInTouchMode());
    
public voidtestTouchModeTransfersRemovesFocus()

        /* TODO These need to be rewritten to account for presenters that an activity
         * does not have access to.

        // open menu, move around to give it focus
        sendKeys(KeyEvent.KEYCODE_MENU, KeyEvent.KEYCODE_DPAD_LEFT);
        final View menuItem = mActivity.getItemView(MenuBuilder.TYPE_ICON, 0);
        assertTrue("menuItem.isFocused()", menuItem.isFocused());

        // close the menu
        sendKeys(KeyEvent.KEYCODE_MENU);
        Thread.sleep(500);

        // touch the screen
        TouchUtils.clickView(this, mActivity.getButton());
        assertTrue("should be in touch mode after touching button",
                mActivity.getButton().isInTouchMode());

        // open the menu, menu item shouldn't be focused, because we are not
        // in touch mode
        sendKeys(KeyEvent.KEYCODE_MENU);
        assertTrue("menuItem.isInTouchMode()", menuItem.isInTouchMode());
        assertFalse("menuItem.isFocused()", menuItem.isFocused());
         */