Loading core/tests/coretests/src/android/widget/TextViewActivityMouseTest.java +26 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.widget; import static android.widget.espresso.ContextMenuUtils.assertContextMenuContainsItemDisabled; import static android.widget.espresso.ContextMenuUtils.assertContextMenuContainsItemEnabled; import static android.widget.espresso.ContextMenuUtils.assertContextMenuIsNotDisplayed; import static android.widget.espresso.DragHandleUtils.assertNoSelectionHandles; import static android.widget.espresso.DragHandleUtils.onHandleView; import static android.widget.espresso.TextViewActions.mouseClick; import static android.widget.espresso.TextViewActions.mouseClickOnTextAtIndex; Loading Loading @@ -87,11 +88,6 @@ public class TextViewActivityMouseTest { mouseDragOnText(helloWorld.indexOf("llo"), helloWorld.indexOf("ld!"))); onView(withId(R.id.textview)).check(hasSelection("llo wor")); onHandleView(com.android.internal.R.id.selection_start_handle) .check(matches(isDisplayed())); onHandleView(com.android.internal.R.id.selection_end_handle) .check(matches(isDisplayed())); onView(withId(R.id.textview)).perform(mouseClickOnTextAtIndex(helloWorld.indexOf("w"))); onView(withId(R.id.textview)).check(hasSelection("")); } Loading Loading @@ -393,4 +389,29 @@ public class TextViewActivityMouseTest { mouseTripleClickAndDragOnText(text.indexOf("ird"), text.indexOf("First"))); onView(withId(R.id.textview)).check(hasSelection(text)); } @Test public void testSelectionHandlesDisplay() { final String helloWorld = "Hello world!"; onView(withId(R.id.textview)).perform(mouseClick()); onView(withId(R.id.textview)).perform(replaceText(helloWorld)); onView(withId(R.id.textview)).perform( mouseDragOnText(helloWorld.indexOf("llo"), helloWorld.indexOf("ld!"))); onView(withId(R.id.textview)).check(hasSelection("llo wor")); // Confirm that selection handles are shown when there is a selection. onHandleView(com.android.internal.R.id.selection_start_handle) .check(matches(isDisplayed())); onHandleView(com.android.internal.R.id.selection_end_handle) .check(matches(isDisplayed())); onView(withId(R.id.textview)).perform(mouseClickOnTextAtIndex(helloWorld.indexOf("w"))); onView(withId(R.id.textview)).check(hasSelection("")); // Confirm that the selection handles are not shown when there is no selection. This // assertion is slow so we only do it in this one test case. The rest of the tests just // assert via `hasSelection("")`. assertNoSelectionHandles(); } } Loading
core/tests/coretests/src/android/widget/TextViewActivityMouseTest.java +26 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.widget; import static android.widget.espresso.ContextMenuUtils.assertContextMenuContainsItemDisabled; import static android.widget.espresso.ContextMenuUtils.assertContextMenuContainsItemEnabled; import static android.widget.espresso.ContextMenuUtils.assertContextMenuIsNotDisplayed; import static android.widget.espresso.DragHandleUtils.assertNoSelectionHandles; import static android.widget.espresso.DragHandleUtils.onHandleView; import static android.widget.espresso.TextViewActions.mouseClick; import static android.widget.espresso.TextViewActions.mouseClickOnTextAtIndex; Loading Loading @@ -87,11 +88,6 @@ public class TextViewActivityMouseTest { mouseDragOnText(helloWorld.indexOf("llo"), helloWorld.indexOf("ld!"))); onView(withId(R.id.textview)).check(hasSelection("llo wor")); onHandleView(com.android.internal.R.id.selection_start_handle) .check(matches(isDisplayed())); onHandleView(com.android.internal.R.id.selection_end_handle) .check(matches(isDisplayed())); onView(withId(R.id.textview)).perform(mouseClickOnTextAtIndex(helloWorld.indexOf("w"))); onView(withId(R.id.textview)).check(hasSelection("")); } Loading Loading @@ -393,4 +389,29 @@ public class TextViewActivityMouseTest { mouseTripleClickAndDragOnText(text.indexOf("ird"), text.indexOf("First"))); onView(withId(R.id.textview)).check(hasSelection(text)); } @Test public void testSelectionHandlesDisplay() { final String helloWorld = "Hello world!"; onView(withId(R.id.textview)).perform(mouseClick()); onView(withId(R.id.textview)).perform(replaceText(helloWorld)); onView(withId(R.id.textview)).perform( mouseDragOnText(helloWorld.indexOf("llo"), helloWorld.indexOf("ld!"))); onView(withId(R.id.textview)).check(hasSelection("llo wor")); // Confirm that selection handles are shown when there is a selection. onHandleView(com.android.internal.R.id.selection_start_handle) .check(matches(isDisplayed())); onHandleView(com.android.internal.R.id.selection_end_handle) .check(matches(isDisplayed())); onView(withId(R.id.textview)).perform(mouseClickOnTextAtIndex(helloWorld.indexOf("w"))); onView(withId(R.id.textview)).check(hasSelection("")); // Confirm that the selection handles are not shown when there is no selection. This // assertion is slow so we only do it in this one test case. The rest of the tests just // assert via `hasSelection("")`. assertNoSelectionHandles(); } }