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

Commit d762f322 authored by Abodunrinwa Toki's avatar Abodunrinwa Toki Committed by Android (Google) Code Review
Browse files

Merge "Fix failing Framework TextView tests."

parents 8ec374d2 4a056a58
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4734,7 +4734,9 @@ public class Editor {
    public static final int HANDLE_TYPE_SELECTION_START = 0;
    public static final int HANDLE_TYPE_SELECTION_END = 1;

    private class SelectionHandleView extends HandleView {
    /** For selection handles */
    @VisibleForTesting
    public final class SelectionHandleView extends HandleView {
        // Indicates the handle type, selection start (HANDLE_TYPE_SELECTION_START) or selection
        // end (HANDLE_TYPE_SELECTION_END).
        @HandleType
+2 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import static android.widget.espresso.TextViewAssertions.hasSelection;

import android.app.Activity;
import android.support.test.filters.MediumTest;
import android.support.test.filters.Suppress;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.view.MotionEvent;
@@ -62,6 +63,7 @@ import org.junit.runner.RunWith;
 */
@RunWith(AndroidJUnit4.class)
@MediumTest
@Suppress // Consistently failing. b/29591177
public class TextViewActivityMouseTest {

    @Rule
+1 −1
Original line number Diff line number Diff line
@@ -310,9 +310,9 @@ public class TextViewActivityTest {
    @Test
    public void testToolbarAndInsertionHandle() {
        final String text = "text";
        assertFloatingToolbarIsNotDisplayed();
        onView(withId(R.id.textview)).perform(replaceText(text));
        onView(withId(R.id.textview)).perform(clickOnTextAtIndex(text.length()));
        assertFloatingToolbarIsNotDisplayed();

        onHandleView(com.android.internal.R.id.insertion_handle).perform(click());
        sleepForFloatingToolbarPopup();
+13 −12
Original line number Diff line number Diff line
@@ -18,11 +18,13 @@ package android.widget.espresso;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.RootMatchers.isPlatformPopup;
import static android.support.test.espresso.matcher.RootMatchers.withDecorView;
import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;

import static org.hamcrest.Matchers.allOf;

import android.support.test.espresso.NoMatchingRootException;
@@ -30,29 +32,28 @@ import android.support.test.espresso.NoMatchingViewException;
import android.support.test.espresso.ViewInteraction;
import android.widget.Editor;

public class DragHandleUtils {
    private DragHandleUtils() {
public final class DragHandleUtils {

    }
    private DragHandleUtils() {}

    public static void assertNoSelectionHandles() {
        try {
            onHandleView(com.android.internal.R.id.selection_start_handle)
            onView(isAssignableFrom(Editor.SelectionHandleView.class))
                    .inRoot(isPlatformPopup())
                    .check(matches(isDisplayed()));
        } catch (NoMatchingRootException | NoMatchingViewException | AssertionError e) {
            try {
                onHandleView(com.android.internal.R.id.selection_end_handle)
                        .check(matches(isDisplayed()));
            } catch (NoMatchingRootException | NoMatchingViewException | AssertionError e1) {
            return;
        }
        }
        throw new AssertionError("Selection handle found");
    }

    public static ViewInteraction onHandleView(int id)
            throws NoMatchingRootException, NoMatchingViewException, AssertionError {
        return onView(allOf(withId(id), isAssignableFrom(Editor.HandleView.class)))
                .inRoot(withDecorView(hasDescendant(withId(id))));
        return onView(allOf(
                        withId(id),
                        isAssignableFrom(Editor.HandleView.class)))
                .inRoot(allOf(
                        isPlatformPopup(),
                        withDecorView(hasDescendant(withId(id)))));
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.widget.espresso;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.RootMatchers.isPlatformPopup;
import static android.support.test.espresso.matcher.RootMatchers.withDecorView;
import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
@@ -58,7 +59,9 @@ public class FloatingToolbarEspressoUtils {

    private static ViewInteraction onFloatingToolBar() {
        return onView(withTagValue(is(TAG)))
                .inRoot(withDecorView(hasDescendant(withTagValue(is(TAG)))));
                .inRoot(allOf(
                        isPlatformPopup(),
                        withDecorView(hasDescendant(withTagValue(is(TAG))))));
    }

    /**