Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03e6b30f authored by Evan Rosky's avatar Evan Rosky
Browse files

Directly focus button in touchmode coretests

Was relying on the behavior of arrow keys change focus. Since
we now restrict keyboard arrows from leaving EditTexts, this
test was failing.

Bug: 38250888
Test: android.widget.touchmode coretests pass
Change-Id: I24b9bc165124e93f08793ae18c2604061a132d78
parent b827c523
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -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,7 +77,8 @@ 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());