TouchModeFocusableTestpublic 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.frameworks.coretests", LLEditTextThenButton.class);
|
Methods Summary |
---|
protected void | setUp()
super.setUp();
mEditText = getActivity().getEditText();
mButton = getActivity().getButton();
| public void | testClickButtonEditTextKeepsFocus()
assertInTouchModeAfterTap(this, mButton);
assertTrue("should be in touch mode", mButton.isInTouchMode());
assertTrue("edit text should still have focus", mEditText.isFocused());
| public void | testClickEditTextGivesItFocus()
// 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 void | testEnterTouchModeGivesFocusBackToFocusableInTouchMode()
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 void | testPreconditions()
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());
|
|