Code example for Button

Methods: hasFocus, isFocused

0
    public void testTouchButtonNotTakeFocus() { 
        assertInTouchModeAfterTap(this, mFirstButton);
 
        assertTrue("should be in touch mode", mActivity.isInTouchMode());
        assertFalse("button.isFocused",
                mFirstButton.isFocused());
        assertFalse("button.hasFocus",
                mFirstButton.hasFocus());
        assertNull("activity shouldn't have focus", mActivity.getCurrentFocus());
        assertFalse("linear layout should not have focus",
                mActivity.getLayout().hasFocus());
 
        assertTrue("button's onClickListener should have fired",
                mActivity.buttonClickListenerFired());
    } 
 
    // TODO: reenable when more reliable 
    public void DISABLE_testLeaveTouchModeWithDpadEvent() { 
        assertInTouchModeAfterClick(this, mFirstButton);
 
        assertTrue("should be in touch mode", mActivity.isInTouchMode());