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

TouchModeFocusableTest

public class TouchModeFocusableTest extends android.test.ActivityInstrumentationTestCase
Some views, like edit texts, can keep and gain focus even when in touch mode.

Fields Summary
private android.widget.EditText
mEditText
private android.widget.Button
mButton
Constructors Summary
public TouchModeFocusableTest()

        super("com.android.frameworktest", LLEditTextThenButton.class);
    
Methods Summary
protected voidsetUp()

        super.setUp();

        mEditText = getActivity().getEditText();
        mButton = getActivity().getButton();
    
public voidtestClickButtonEditTextKeepsFocus()

        assertInTouchModeAfterTap(this, mButton);
        assertTrue("should be in touch mode", mButton.isInTouchMode());
        assertTrue("edit text should still have focus", mEditText.isFocused());
    
public voidtestClickEditTextGivesItFocus()

        // go down to button
        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        assertTrue("button should have focus", mButton.isFocused());

        assertInTouchModeAfterClick(this, mEditText);
        assertTrue("clicking edit text should have entered touch mode", mButton.isInTouchMode());
        assertTrue("clicking edit text should have given it focus", mEditText.isFocused());
    
public voidtestEnterTouchModeGivesFocusBackToFocusableInTouchMode()

        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);

        assertTrue("button should have focus",
                mButton.isFocused());
        
        assertInTouchModeAfterClick(this, mButton);
        assertTrue("should be in touch mode", mButton.isInTouchMode());
        assertNull("nothing should have focus", getActivity().getCurrentFocus());
        assertFalse("layout should not have focus",
                getActivity().getLayout().hasFocus());
    
public voidtestPreconditions()

        assertFalse("should not be in touch mode to start off", mButton.isInTouchMode());
        assertTrue("edit text should have focus", mEditText.isFocused());
        assertTrue("edit text should be focusable in touch mode", mEditText.isFocusableInTouchMode());