Fix and re-enable TextViewActivityMouseTest
The main problem was in MouseUiController: when generating an ACTION_UP event, button state was not being reset so the event was getting filtered out by the check in Editor.shouldFilterOutTouchEvent. This CL also removes the slow negative assertions for the selection handles (assertNoSelectionHandles). There is one remaining issue in testDragAndDrop_longClick() which for now is still suppressed. The real for this will be in a separate CL because it requires updates to the touch state logic of Editor. Bug: 29591177 Test: Ran tests atest FrameworksCoreTests:TextViewActivityMouseTest atest FrameworksCoreTests:TextViewActivityTest Change-Id: I6ce73bf30d9c49ec1b5a5930db0f9cf52929bf43
This commit is contained in:
@@ -19,7 +19,6 @@ 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;
|
||||
@@ -64,7 +63,6 @@ import org.junit.runner.RunWith;
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@MediumTest
|
||||
@Suppress // Consistently failing. b/29591177
|
||||
public class TextViewActivityMouseTest {
|
||||
|
||||
@Rule
|
||||
@@ -86,11 +84,8 @@ public class TextViewActivityMouseTest {
|
||||
onView(withId(R.id.textview)).perform(mouseClick());
|
||||
onView(withId(R.id.textview)).perform(replaceText(helloWorld));
|
||||
|
||||
assertNoSelectionHandles();
|
||||
|
||||
onView(withId(R.id.textview)).perform(
|
||||
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)
|
||||
@@ -100,8 +95,6 @@ public class TextViewActivityMouseTest {
|
||||
|
||||
onView(withId(R.id.textview)).perform(mouseClickOnTextAtIndex(helloWorld.indexOf("w")));
|
||||
onView(withId(R.id.textview)).check(hasSelection(""));
|
||||
|
||||
assertNoSelectionHandles();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,11 +189,11 @@ public class TextViewActivityMouseTest {
|
||||
|
||||
onView(withId(R.id.textview)).check(matches(withText("abc ghi.def")));
|
||||
onView(withId(R.id.textview)).check(hasSelection(""));
|
||||
assertNoSelectionHandles();
|
||||
onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex("abc ghi.def".length()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress // Consistently failing. b/29591177
|
||||
public void testDragAndDrop_longClick() {
|
||||
final String text = "abc def ghi.";
|
||||
onView(withId(R.id.textview)).perform(mouseClick());
|
||||
@@ -213,7 +206,6 @@ public class TextViewActivityMouseTest {
|
||||
|
||||
onView(withId(R.id.textview)).check(matches(withText("abc ghi.def")));
|
||||
onView(withId(R.id.textview)).check(hasSelection(""));
|
||||
assertNoSelectionHandles();
|
||||
onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex("abc ghi.def".length()));
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ public final class MouseUiController implements UiController {
|
||||
event.setSource(InputDevice.SOURCE_MOUSE);
|
||||
if (event.getActionMasked() != MotionEvent.ACTION_UP) {
|
||||
event.setButtonState(mButton);
|
||||
} else {
|
||||
event.setButtonState(0);
|
||||
}
|
||||
return mUiController.injectMotionEvent(event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user