Merge "Directly focus button in touchmode coretests" into oc-dev
This commit is contained in:
@@ -16,16 +16,15 @@
|
||||
|
||||
package android.widget.touchmode;
|
||||
|
||||
import android.widget.layout.linear.LLEditTextThenButton;
|
||||
import static android.util.TouchModeFlexibleAsserts.assertInTouchModeAfterTap;
|
||||
import static android.util.TouchModeFlexibleAsserts.assertInTouchModeAfterClick;
|
||||
import static android.util.TouchModeFlexibleAsserts.assertInTouchModeAfterTap;
|
||||
|
||||
import android.test.ActivityInstrumentationTestCase;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.layout.linear.LLEditTextThenButton;
|
||||
|
||||
/**
|
||||
* Some views, like edit texts, can keep and gain focus even when in touch mode.
|
||||
@@ -64,7 +63,8 @@ public class TouchModeFocusableTest extends ActivityInstrumentationTestCase<LLEd
|
||||
@LargeTest
|
||||
public void testClickEditTextGivesItFocus() {
|
||||
// go down to button
|
||||
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||
getActivity().runOnUiThread(() -> mButton.requestFocus());
|
||||
getInstrumentation().waitForIdleSync();
|
||||
assertTrue("button should have focus", mButton.isFocused());
|
||||
|
||||
assertInTouchModeAfterClick(this, mEditText);
|
||||
@@ -77,11 +77,12 @@ public class TouchModeFocusableTest extends ActivityInstrumentationTestCase<LLEd
|
||||
// isn't focusable in touch mode.
|
||||
@LargeTest
|
||||
public void testEnterTouchModeGivesFocusBackToFocusableInTouchMode() {
|
||||
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||
getActivity().runOnUiThread(() -> mButton.requestFocus());
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user