From 90cdfe0514154bbc008d39f1c99f7a1d2684446c Mon Sep 17 00:00:00 2001 From: Abodunrinwa Toki Date: Tue, 15 Sep 2015 21:15:56 +0100 Subject: [PATCH] TextViewActions for Espresso-testing TextView. The plan is to add common TextView actions here so they can be used in tests. The locateTextAtIndex method is probably not the most efficient way to locate a particular spot in the TextView but it works well enough and doesn't use any private/hidden APIs. This might make it easy to port this test as CTS. Ideas on alternative implementations for this method are welcome. Bug: 24102650 Change-Id: Ifb07cc86c58bd5833c37919fa9294a2374dba2a0 --- .../android/widget/TextViewActivityTest.java | 16 +++ .../widget/espresso/TextViewActions.java | 105 ++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 core/tests/coretests/src/android/widget/espresso/TextViewActions.java diff --git a/core/tests/coretests/src/android/widget/TextViewActivityTest.java b/core/tests/coretests/src/android/widget/TextViewActivityTest.java index 54117df35a01c..b37688f0e2128 100644 --- a/core/tests/coretests/src/android/widget/TextViewActivityTest.java +++ b/core/tests/coretests/src/android/widget/TextViewActivityTest.java @@ -16,8 +16,10 @@ package android.widget; +import static android.widget.espresso.TextViewActions.clickOnTextAtIndex; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.action.ViewActions.pressKey; import static android.support.test.espresso.action.ViewActions.typeTextIntoFocusedView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.withId; @@ -27,6 +29,7 @@ import com.android.frameworks.coretests.R; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.SmallTest; +import android.view.KeyEvent; /** * Tests the TextView widget from an Activity @@ -47,4 +50,17 @@ public class TextViewActivityTest extends ActivityInstrumentationTestCase2 + *
+ * View constraints: + *