FileDocCategorySizeDatePackage
TouchModeFocusChangeTest.javaAPI DocAndroid 1.5 API3385Wed May 06 22:42:02 BST 2009com.android.frameworktest.touchmode

TouchModeFocusChangeTest

public class TouchModeFocusChangeTest extends android.test.ActivityInstrumentationTestCase
Make sure focus isn't kept by buttons when entering touch mode. When in touch mode and hitting the d-pad, we should leave touch mode and the top most focusable gets focus.

Fields Summary
private com.android.frameworktest.layout.linear.LLOfButtons1
mActivity
private android.widget.Button
mFirstButton
Constructors Summary
public TouchModeFocusChangeTest()

        super("com.android.frameworktest", LLOfButtons1.class);
    
Methods Summary
public voidDISABLE_testLeaveTouchModeWithDpadEvent()

        assertInTouchModeAfterClick(this, mFirstButton);

        assertTrue("should be in touch mode", mActivity.isInTouchMode());
        assertFalse("button should not have focus when touched",
                mFirstButton.isFocused());

        assertNotInTouchModeAfterKey(this, KeyEvent.KEYCODE_DPAD_RIGHT, mFirstButton);
        assertFalse("should be out of touch mode", mActivity.isInTouchMode());
        assertTrue("first button (the top most focusable) should have gained focus",
                mFirstButton.isFocused());
    
protected voidsetUp()

        super.setUp();

        mActivity = getActivity();
        mFirstButton = mActivity.getFirstButton();
    
public voidtestPreconditions()

        assertFalse("we should not be in touch mode", mActivity.isInTouchMode());
        assertTrue("top button should have focus", mFirstButton.isFocused());
    
public voidtestTouchButtonNotTakeFocus()

        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());