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

Commit e8b3dd47 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi
Browse files

TextView test: insertion handle movement tests.

Bug: 25730231
Change-Id: Iea6528f414314daf971f11bc090cfccfefee25e1
parent 26454141
Loading
Loading
Loading
Loading
+40 −0
Original line number Original line Diff line number Diff line
@@ -169,6 +169,46 @@ public class TextViewActivityTest extends ActivityInstrumentationTestCase2<TextV
        assertFloatingToolbarIsDisplayed(getActivity());
        assertFloatingToolbarIsDisplayed(getActivity());
    }
    }


    @SmallTest
    public void testInsertionHandle() throws Exception {
        final String text = "abcd efg hijk ";
        onView(withId(R.id.textview)).perform(click());
        onView(withId(R.id.textview)).perform(typeTextIntoFocusedView(text));

        onView(withId(R.id.textview)).perform(clickOnTextAtIndex(text.length()));
        onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.length()));

        final TextView textView = (TextView)getActivity().findViewById(R.id.textview);

        onHandleView(com.android.internal.R.id.insertion_handle)
                .perform(dragHandle(textView, Handle.INSERTION, text.indexOf('a')));
        onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.indexOf("a")));

        onHandleView(com.android.internal.R.id.insertion_handle)
                .perform(dragHandle(textView, Handle.INSERTION, text.indexOf('f')));
        onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.indexOf("f")));
    }

    @SmallTest
    public void testInsertionHandle_multiLine() throws Exception {
        final String text = "abcd\n" + "efg\n" + "hijk\n";
        onView(withId(R.id.textview)).perform(click());
        onView(withId(R.id.textview)).perform(typeTextIntoFocusedView(text));

        onView(withId(R.id.textview)).perform(clickOnTextAtIndex(text.length()));
        onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.length()));

        final TextView textView = (TextView)getActivity().findViewById(R.id.textview);

        onHandleView(com.android.internal.R.id.insertion_handle)
                .perform(dragHandle(textView, Handle.INSERTION, text.indexOf('a')));
        onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.indexOf("a")));

        onHandleView(com.android.internal.R.id.insertion_handle)
                .perform(dragHandle(textView, Handle.INSERTION, text.indexOf('f')));
        onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.indexOf("f")));
    }

    @SmallTest
    @SmallTest
    public void testSelectionHandles() throws Exception {
    public void testSelectionHandles() throws Exception {
        final String text = "abcd efg hijk lmn";
        final String text = "abcd efg hijk lmn";