am cab1eb64: am 31072147: Merge "Accessibility CTS tests fail on very small screens (cherry-pick)." into klp-dev
* commit 'cab1eb64a30c48d7ea806d1bfca5292fb535ed34':
Accessibility CTS tests fail on very small screens (cherry-pick).
diff --git a/tests/tests/accessibilityservice/res/layout/accessibility_text_traversal_test.xml b/tests/tests/accessibilityservice/res/layout/accessibility_text_traversal_test.xml
index f86f00f..9906227 100644
--- a/tests/tests/accessibilityservice/res/layout/accessibility_text_traversal_test.xml
+++ b/tests/tests/accessibilityservice/res/layout/accessibility_text_traversal_test.xml
@@ -26,29 +26,32 @@
android:id="@+id/view"
android:layout_width="50dip"
android:layout_height="50dip"
+ android:visibility="gone"
/>
<TextView
android:id="@+id/text"
- android:layout_width="200dip"
- android:layout_height="200dip"
+ android:layout_width="80dip"
+ android:layout_height="80dip"
android:includeFontPadding="false"
- android:textSize="14dip"
+ android:textSize="10dip"
android:textStyle="normal"
android:fontFamily="sans-serif"
+ android:visibility="gone"
/>
<EditText
android:id="@+id/edit"
- android:layout_width="200dip"
- android:layout_height="200dip"
+ android:layout_width="80dip"
+ android:layout_height="80dip"
android:maxLines="1000"
android:scrollbars="vertical"
android:focusable="false"
android:includeFontPadding="false"
- android:textSize="18dip"
+ android:textSize="10dip"
android:textStyle="normal"
android:fontFamily="sans-serif"
+ android:visibility="gone"
/>
</LinearLayout>
diff --git a/tests/tests/accessibilityservice/res/layout/accessibility_view_tree_reporting_test.xml b/tests/tests/accessibilityservice/res/layout/accessibility_view_tree_reporting_test.xml
index fe420bc..0dbd62a 100644
--- a/tests/tests/accessibilityservice/res/layout/accessibility_view_tree_reporting_test.xml
+++ b/tests/tests/accessibilityservice/res/layout/accessibility_view_tree_reporting_test.xml
@@ -29,19 +29,22 @@
android:id="@+id/firstTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/firstTextView" />
+ android:text="@string/firstTextView"
+ android:textSize="10dip" />
<EditText
android:id="@+id/firstEditText"
- android:layout_width="200dip"
+ android:layout_width="20dip"
android:layout_height="wrap_content"
- android:contentDescription="@string/firstEditText" />
+ android:contentDescription="@string/firstEditText"
+ android:textSize="10dip" />
<Button
android:id="@+id/firstButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/firstButton" />
+ android:text="@string/firstButton"
+ android:textSize="10dip" />
</LinearLayout>
@@ -68,19 +71,22 @@
android:id="@+id/secondTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/secondTextView" />
+ android:text="@string/secondTextView"
+ android:textSize="10dip" />
<EditText
android:id="@+id/secondEditText"
- android:layout_width="200dip"
+ android:layout_width="20dip"
android:layout_height="wrap_content"
- android:contentDescription="@string/secondEditText" />
+ android:contentDescription="@string/secondEditText"
+ android:textSize="10dip" />
<Button
android:id="@+id/secondButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/secondButton" />
+ android:text="@string/secondButton"
+ android:textSize="10dip" />
</LinearLayout>
diff --git a/tests/tests/accessibilityservice/res/layout/query_window_test.xml b/tests/tests/accessibilityservice/res/layout/query_window_test.xml
index 37c0ef0..88d4cc9 100644
--- a/tests/tests/accessibilityservice/res/layout/query_window_test.xml
+++ b/tests/tests/accessibilityservice/res/layout/query_window_test.xml
@@ -29,21 +29,24 @@
>
<Button
android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button1"
+ android:textSize="10dip"
/>
<Button
android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button2"
+ android:textSize="10dip"
/>
<Button
android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button3"
+ android:textSize="10dip"
/>
</LinearLayout>
@@ -54,21 +57,24 @@
>
<Button
android:id="@+id/button4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button4"
+ android:textSize="10dip"
/>
<Button
android:id="@+id/button5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button5"
+ android:textSize="10dip"
/>
<Button
android:id="@+id/button6"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button6"
+ android:textSize="10dip"
android:contentDescription="@string/contentDescription"
/>
</LinearLayout>
@@ -80,21 +86,24 @@
>
<Button
android:id="@+id/button7"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button7"
+ android:textSize="10dip"
/>
<Button
android:id="@+id/button8"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button8"
+ android:textSize="10dip"
/>
<Button
android:id="@+id/button9"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="20dip"
+ android:layout_height="20dip"
android:text="@string/button9"
+ android:textSize="10dip"
/>
</LinearLayout>
diff --git a/tests/tests/accessibilityservice/res/values/strings.xml b/tests/tests/accessibilityservice/res/values/strings.xml
index 97ddb7c..f60df17 100644
--- a/tests/tests/accessibilityservice/res/values/strings.xml
+++ b/tests/tests/accessibilityservice/res/values/strings.xml
@@ -52,34 +52,34 @@
<string name="accessibility_query_window_test_activity">Query window test</string>
<!-- String Button1 text -->
- <string name="button1">Button1</string>
+ <string name="button1">B1</string>
<!-- String Button2 text -->
- <string name="button2">Button2</string>
+ <string name="button2">B2</string>
<!-- String Button3 text -->
- <string name="button3">Button3</string>
+ <string name="button3">B3</string>
<!-- String Button4 text -->
- <string name="button4">Button4</string>
+ <string name="button4">B4</string>
<!-- String Button5 text -->
- <string name="button5">Button5</string>
+ <string name="button5">B5</string>
<!-- String Button6 text -->
- <string name="button6">Button6</string>
+ <string name="button6">B6</string>
<!-- String with content description for Button6 -->
<string name="contentDescription">contentDescription</string>
<!-- String Button7 text -->
- <string name="button7">Button7</string>
+ <string name="button7">B7</string>
<!-- String Button8 text -->
- <string name="button8">Button8</string>
+ <string name="button8">B8</string>
<!-- String Button9 text -->
- <string name="button9">Button9</string>
+ <string name="button9">B9</string>
<!-- AccessibilityFocusTest -->
@@ -87,37 +87,37 @@
<string name="accessibility_view_tree_reporting_test_activity">Accessibility view three reporting test</string>
<!-- String root LinearLayout text -->
- <string name="rootLinearLayout">rootLinearLayout</string>
+ <string name="rootLinearLayout">rLL</string>
<!-- String first FrameLayout text -->
- <string name="firstFrameLayout">firstFrameLayout</string>
+ <string name="firstFrameLayout">fFL</string>
<!-- String first LinearLayout text -->
- <string name="firstLinearLayout">firstLinearLayout</string>
+ <string name="firstLinearLayout">fLL</string>
<!-- String first TextView text -->
- <string name="firstTextView">firstTextView</string>
+ <string name="firstTextView">fTV</string>
<!-- String first EditText text -->
- <string name="firstEditText">firstEditText</string>
+ <string name="firstEditText">fET</string>
<!-- String first Button text -->
- <string name="firstButton">firstButton</string>
+ <string name="firstButton">fB</string>
<!-- String second FrameLayout text -->
- <string name="secondFrameLayout">secondFrameLayout</string>
+ <string name="secondFrameLayout">sFL</string>
<!-- String second LinearLayout text -->
- <string name="secondLinearLayout">secondLinearLayout</string>
+ <string name="secondLinearLayout">sLL</string>
<!-- String second TextView text -->
- <string name="secondTextView">secondTextView</string>
+ <string name="secondTextView">sTV</string>
<!-- String second EditText text -->
- <string name="secondEditText">secondEditText</string>
+ <string name="secondEditText">sET</string>
<!-- String second Button text -->
- <string name="secondButton">secondButton</string>
+ <string name="secondButton">sB</string>
<!-- String title of the accessibility focus and input focus sync test activity -->
<string name="accessibility_focus_and_input_focus_sync_test_activity">Accessibility focus and input focus sync test</string>
@@ -126,14 +126,11 @@
<string name="accessibility_text_traversal_test_activity">Accessibility text traversal test</string>
<string name="android_wiki_short">
- Android is a Linux-based operating system for mobile devices</string>
+ Android is a Linux-based operating</string>
<string name="android_wiki">
Android is a Linux-based operating system for mobile devices such as smartphones and tablet
- computers. It is developed by the Open Handset Alliance, led by Google, and other companies.
- Google purchased the initial developer of the software, Android Inc., in 2005. The
- unveiling of the Android distribution in 2007 was announced with the founding of the Open
- Handset Alliance, a consortium of 86 hardware, software, and telecommunication </string>
+ computers. It is developed by the Open Handset Alliance, more</string>
<string name="a_b">A B</string>
@@ -142,12 +139,7 @@
<string name="foo_bar_baz">Foo bar baz.</string>
<string name="android_wiki_paragraphs">
- \n\nAndroid is a Linux-based operating system for mobile devices such as smartphones and tablet
- computers.\n\n It is developed by the Open Handset Alliance, led by Google, and other companies.
- Google purchased the initial developer of the software, Android Inc., in 2005.\n The
- unveiling of the Android distribution in 2007 was announced with the founding of the Open
- Handset Alliance, a consortium of 86 hardware, software, and telecommunication companies
- devoted to advancing open standards for mobile devices. Google releases the
- Android code as open-source, under the Apache License.\n\n</string>
+ \n\nAndroid is a\n\n It is developed\n The
+ unveiling\n\n</string>
</resources>
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
index cbaf5d2..a53fdea 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextTraversalTest.java
@@ -46,6 +46,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ view.setVisibility(View.VISIBLE);
view.setContentDescription(getString(R.string.a_b));
}
});
@@ -260,6 +261,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ view.setVisibility(View.VISIBLE);
view.setContentDescription(getString(R.string.foo_bar_baz));
}
});
@@ -474,6 +476,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ textView.setVisibility(View.VISIBLE);
textView.setText(getString(R.string.a_b));
}
});
@@ -722,6 +725,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ editText.setVisibility(View.VISIBLE);
editText.setText(getString(R.string.a_b));
Selection.removeSelection(editText.getText());
}
@@ -1220,6 +1224,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ textView.setVisibility(View.VISIBLE);
textView.setText(getString(R.string.foo_bar_baz));
}
});
@@ -1463,12 +1468,12 @@
@MediumTest
public void testActionNextAndPreviousAtGranularityWordOverEditTextWithContentDescription()
throws Exception {
-
final EditText editText = (EditText) getActivity().findViewById(R.id.edit);
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ editText.setVisibility(View.VISIBLE);
editText.setText(getString(R.string.foo_bar_baz));
editText.setContentDescription(getString(R.string.android_wiki));
}
@@ -1723,6 +1728,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ editText.setVisibility(View.VISIBLE);
editText.setText(getString(R.string.foo_bar_baz));
Selection.removeSelection(editText.getText());
}
@@ -2217,6 +2223,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ textView.setVisibility(View.VISIBLE);
textView.setText(getString(R.string.android_wiki_short));
}
});
@@ -2258,7 +2265,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
&& event.getFromIndex() == 0
- && event.getToIndex() == 25
+ && event.getToIndex() == 13
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2268,8 +2275,8 @@
assertNotNull(firstExpected);
// Verify the selection position.
- assertEquals(25, Selection.getSelectionStart(textView.getText()));
- assertEquals(25, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(13, Selection.getSelectionStart(textView.getText()));
+ assertEquals(13, Selection.getSelectionEnd(textView.getText()));
// Move to the next line and wait for an event.
AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
@@ -2292,8 +2299,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 25
- && event.getToIndex() == 53
+ && event.getFromIndex() == 13
+ && event.getToIndex() == 25
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2303,8 +2310,8 @@
assertNotNull(secondExpected);
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(textView.getText()));
- assertEquals(53, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(25, Selection.getSelectionStart(textView.getText()));
+ assertEquals(25, Selection.getSelectionEnd(textView.getText()));
// Move to the next line and wait for an event.
AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
@@ -2327,8 +2334,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 53
- && event.getToIndex() == 60
+ && event.getFromIndex() == 25
+ && event.getToIndex() == 34
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2338,16 +2345,16 @@
assertNotNull(thirdExpected);
// Verify the selection position.
- assertEquals(60, Selection.getSelectionStart(textView.getText()));
- assertEquals(60, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(34, Selection.getSelectionStart(textView.getText()));
+ assertEquals(34, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no next.
assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
- assertEquals(60, Selection.getSelectionStart(textView.getText()));
- assertEquals(60, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(34, Selection.getSelectionStart(textView.getText()));
+ assertEquals(34, Selection.getSelectionEnd(textView.getText()));
// Move to the previous line and wait for an event.
AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
@@ -2370,8 +2377,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 53
- && event.getToIndex() == 60
+ && event.getFromIndex() == 25
+ && event.getToIndex() == 34
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2381,8 +2388,8 @@
assertNotNull(fourthExpected);
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(textView.getText()));
- assertEquals(53, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(25, Selection.getSelectionStart(textView.getText()));
+ assertEquals(25, Selection.getSelectionEnd(textView.getText()));
// Move to the previous line and wait for an event.
AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
@@ -2405,8 +2412,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 25
- && event.getToIndex() == 53
+ && event.getFromIndex() == 13
+ && event.getToIndex() == 25
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2416,8 +2423,8 @@
assertNotNull(fifthExpected);
// Verify the selection position.
- assertEquals(25, Selection.getSelectionStart(textView.getText()));
- assertEquals(25, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(13, Selection.getSelectionStart(textView.getText()));
+ assertEquals(13, Selection.getSelectionEnd(textView.getText()));
// Move to the previous line and wait for an event.
AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
@@ -2441,7 +2448,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
&& event.getFromIndex() == 0
- && event.getToIndex() == 25
+ && event.getToIndex() == 13
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2470,6 +2477,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ editText.setVisibility(View.VISIBLE);
editText.setText(getString(R.string.android_wiki_short));
Selection.removeSelection(editText.getText());
}
@@ -2513,7 +2521,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
&& event.getFromIndex() == 0
- && event.getToIndex() == 19
+ && event.getToIndex() == 13
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2524,7 +2532,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(19, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(13, Selection.getSelectionEnd(editText.getText()));
// Move to the next line and wait for an event.
AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
@@ -2547,8 +2555,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 19
- && event.getToIndex() == 35
+ && event.getFromIndex() == 13
+ && event.getToIndex() == 25
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2559,7 +2567,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(35, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(25, Selection.getSelectionEnd(editText.getText()));
// Move to the next line and wait for an event.
AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
@@ -2582,8 +2590,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 35
- && event.getToIndex() == 53
+ && event.getFromIndex() == 25
+ && event.getToIndex() == 34
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2594,7 +2602,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(53, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(34, Selection.getSelectionEnd(editText.getText()));
// Move to the previous line and wait for an event.
AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
@@ -2617,8 +2625,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 35
- && event.getToIndex() == 53
+ && event.getFromIndex() == 25
+ && event.getToIndex() == 34
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2629,7 +2637,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(35, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(25, Selection.getSelectionEnd(editText.getText()));
// Move to the previous line and wait for an event.
AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
@@ -2652,8 +2660,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 19
- && event.getToIndex() == 35
+ && event.getFromIndex() == 13
+ && event.getToIndex() == 25
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2664,7 +2672,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(19, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(13, Selection.getSelectionEnd(editText.getText()));
// Move to the previous line and wait for an event.
AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
@@ -2688,7 +2696,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
&& event.getFromIndex() == 0
- && event.getToIndex() == 19
+ && event.getToIndex() == 13
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2720,14 +2728,14 @@
// Put selection at the end of the text.
Bundle setSelectionArgs = new Bundle();
- setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 53);
- setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 53);
+ setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 34);
+ setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 34);
assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, setSelectionArgs));
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(editText.getText()));
- assertEquals(53, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(34, Selection.getSelectionStart(editText.getText()));
+ assertEquals(34, Selection.getSelectionEnd(editText.getText()));
// Unocus the view so we can hide the keyboard.
getInstrumentation().runOnMainSync(new Runnable() {
@@ -2759,8 +2767,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 35
- && event.getToIndex() == 53
+ && event.getFromIndex() == 25
+ && event.getToIndex() == 34
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2770,8 +2778,8 @@
assertNotNull(seventhExpected);
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(editText.getText()));
- assertEquals(35, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(34, Selection.getSelectionStart(editText.getText()));
+ assertEquals(25, Selection.getSelectionEnd(editText.getText()));
// Move to the previous line and wait for an event.
AccessibilityEvent eightExpected = getInstrumentation().getUiAutomation()
@@ -2794,8 +2802,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 19
- && event.getToIndex() == 35
+ && event.getFromIndex() == 13
+ && event.getToIndex() == 25
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2805,8 +2813,8 @@
assertNotNull(eightExpected);
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(editText.getText()));
- assertEquals(19, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(34, Selection.getSelectionStart(editText.getText()));
+ assertEquals(13, Selection.getSelectionEnd(editText.getText()));
// Move to the previous line and wait for an event.
AccessibilityEvent ninethExpected = getInstrumentation().getUiAutomation()
@@ -2830,7 +2838,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
&& event.getFromIndex() == 0
- && event.getToIndex() == 19
+ && event.getToIndex() == 13
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2840,7 +2848,7 @@
assertNotNull(ninethExpected);
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(editText.getText()));
+ assertEquals(34, Selection.getSelectionStart(editText.getText()));
assertEquals(0, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
@@ -2848,7 +2856,7 @@
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(editText.getText()));
+ assertEquals(34, Selection.getSelectionStart(editText.getText()));
assertEquals(0, Selection.getSelectionEnd(editText.getText()));
// Move to the next line and wait for an event.
@@ -2873,7 +2881,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
&& event.getFromIndex() == 0
- && event.getToIndex() == 19
+ && event.getToIndex() == 13
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2883,8 +2891,8 @@
assertNotNull(tenthExpected);
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(editText.getText()));
- assertEquals(19, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(34, Selection.getSelectionStart(editText.getText()));
+ assertEquals(13, Selection.getSelectionEnd(editText.getText()));
// Move to the next line and wait for an event.
AccessibilityEvent eleventhExpected = getInstrumentation().getUiAutomation()
@@ -2907,8 +2915,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 19
- && event.getToIndex() == 35
+ && event.getFromIndex() == 13
+ && event.getToIndex() == 25
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2918,8 +2926,8 @@
assertNotNull(eleventhExpected);
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(editText.getText()));
- assertEquals(35, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(34, Selection.getSelectionStart(editText.getText()));
+ assertEquals(25, Selection.getSelectionEnd(editText.getText()));
// Move to the next line and wait for an event.
AccessibilityEvent twelvethExpected = getInstrumentation().getUiAutomation()
@@ -2942,8 +2950,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_short))
- && event.getFromIndex() == 35
- && event.getToIndex() == 53
+ && event.getFromIndex() == 25
+ && event.getToIndex() == 34
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE);
}
@@ -2953,8 +2961,8 @@
assertNotNull(twelvethExpected);
// Verify the selection position.
- assertEquals(53, Selection.getSelectionStart(editText.getText()));
- assertEquals(53, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(34, Selection.getSelectionStart(editText.getText()));
+ assertEquals(34, Selection.getSelectionEnd(editText.getText()));
}
@MediumTest
@@ -2964,6 +2972,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ editText.setVisibility(View.VISIBLE);
editText.setText(getString(R.string.android_wiki));
Selection.removeSelection(editText.getText());
}
@@ -3006,7 +3015,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
&& event.getFromIndex() == 0
- && event.getToIndex() == 139
+ && event.getToIndex() == 53
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3016,8 +3025,8 @@
assertNotNull(firstExpected);
// Verify the selection position.
- assertEquals(139, Selection.getSelectionStart(editText.getText()));
- assertEquals(139, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(53, Selection.getSelectionStart(editText.getText()));
+ assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
@@ -3040,8 +3049,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 139
- && event.getToIndex() == 285
+ && event.getFromIndex() == 53
+ && event.getToIndex() == 103
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3051,8 +3060,8 @@
assertNotNull(secondExpected);
// Verify the selection position.
- assertEquals(285, Selection.getSelectionStart(editText.getText()));
- assertEquals(285, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(103, Selection.getSelectionStart(editText.getText()));
+ assertEquals(103, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
@@ -3075,8 +3084,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 285
- && event.getToIndex() == 436
+ && event.getFromIndex() == 103
+ && event.getToIndex() == 153
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3086,16 +3095,16 @@
assertNotNull(thirdExpected);
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
- assertEquals(436, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
+ assertEquals(153, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
- assertEquals(436, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
+ assertEquals(153, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
@@ -3118,8 +3127,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 285
- && event.getToIndex() == 436
+ && event.getFromIndex() == 103
+ && event.getToIndex() == 153
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3129,8 +3138,8 @@
assertNotNull(fourthExpected);
// Verify the selection position.
- assertEquals(285, Selection.getSelectionStart(editText.getText()));
- assertEquals(285, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(103, Selection.getSelectionStart(editText.getText()));
+ assertEquals(103, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
@@ -3153,8 +3162,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 139
- && event.getToIndex() == 285
+ && event.getFromIndex() == 53
+ && event.getToIndex() == 103
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3164,8 +3173,8 @@
assertNotNull(fifthExpected);
// Verify the selection position.
- assertEquals(139, Selection.getSelectionStart(editText.getText()));
- assertEquals(139, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(53, Selection.getSelectionStart(editText.getText()));
+ assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
@@ -3189,7 +3198,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
&& event.getFromIndex() == 0
- && event.getToIndex() == 139
+ && event.getToIndex() == 53
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3218,6 +3227,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ editText.setVisibility(View.VISIBLE);
editText.setText(getString(R.string.android_wiki));
Selection.removeSelection(editText.getText());
}
@@ -3261,7 +3271,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
&& event.getFromIndex() == 0
- && event.getToIndex() == 139
+ && event.getToIndex() == 53
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3272,7 +3282,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(139, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
@@ -3295,8 +3305,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 139
- && event.getToIndex() == 285
+ && event.getFromIndex() == 53
+ && event.getToIndex() == 103
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3307,7 +3317,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(285, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(103, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
@@ -3330,8 +3340,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 285
- && event.getToIndex() == 436
+ && event.getFromIndex() == 103
+ && event.getToIndex() == 153
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3342,7 +3352,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(436, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
assertFalse(text.performAction(
@@ -3369,8 +3379,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 285
- && event.getToIndex() == 436
+ && event.getFromIndex() == 103
+ && event.getToIndex() == 153
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3381,7 +3391,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(285, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(103, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
@@ -3404,8 +3414,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 139
- && event.getToIndex() == 285
+ && event.getFromIndex() == 53
+ && event.getToIndex() == 103
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3416,7 +3426,7 @@
// Verify the selection position.
assertEquals(0, Selection.getSelectionStart(editText.getText()));
- assertEquals(139, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
@@ -3440,7 +3450,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
&& event.getFromIndex() == 0
- && event.getToIndex() == 139
+ && event.getToIndex() == 53
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3472,14 +3482,14 @@
// Put selection at the end of the text.
Bundle setSelectionArgs = new Bundle();
- setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 436);
- setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 436);
+ setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 153);
+ setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 153);
assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, setSelectionArgs));
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
- assertEquals(436, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
+ assertEquals(153, Selection.getSelectionEnd(editText.getText()));
// Unfocus the view so we can hide the soft-keyboard.
getInstrumentation().runOnMainSync(new Runnable() {
@@ -3511,8 +3521,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 285
- && event.getToIndex() == 436
+ && event.getFromIndex() == 103
+ && event.getToIndex() == 153
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3522,8 +3532,8 @@
assertNotNull(seventhExpected);
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
- assertEquals(285, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
+ assertEquals(103, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
AccessibilityEvent eightExpected = getInstrumentation().getUiAutomation()
@@ -3546,8 +3556,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 139
- && event.getToIndex() == 285
+ && event.getFromIndex() == 53
+ && event.getToIndex() == 103
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3557,8 +3567,8 @@
assertNotNull(eightExpected);
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
- assertEquals(139, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
+ assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Move to the previous page and wait for an event.
AccessibilityEvent ninethExpected = getInstrumentation().getUiAutomation()
@@ -3582,7 +3592,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
&& event.getFromIndex() == 0
- && event.getToIndex() == 139
+ && event.getToIndex() == 53
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3592,7 +3602,7 @@
assertNotNull(ninethExpected);
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
assertEquals(0, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
@@ -3600,7 +3610,7 @@
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
assertEquals(0, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
@@ -3625,7 +3635,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
&& event.getFromIndex() == 0
- && event.getToIndex() == 139
+ && event.getToIndex() == 53
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3635,8 +3645,8 @@
assertNotNull(tenthExpected);
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
- assertEquals(139, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
+ assertEquals(53, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
AccessibilityEvent eleventhExpected = getInstrumentation().getUiAutomation()
@@ -3659,8 +3669,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 139
- && event.getToIndex() == 285
+ && event.getFromIndex() == 53
+ && event.getToIndex() == 103
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3670,8 +3680,8 @@
assertNotNull(eleventhExpected);
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
- assertEquals(285, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
+ assertEquals(103, Selection.getSelectionEnd(editText.getText()));
// Move to the next page and wait for an event.
AccessibilityEvent twelvethExpected = getInstrumentation().getUiAutomation()
@@ -3694,8 +3704,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki))
- && event.getFromIndex() == 285
- && event.getToIndex() == 436
+ && event.getFromIndex() == 103
+ && event.getToIndex() == 153
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
}
@@ -3705,8 +3715,8 @@
assertNotNull(twelvethExpected);
// Verify the selection position.
- assertEquals(436, Selection.getSelectionStart(editText.getText()));
- assertEquals(436, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(153, Selection.getSelectionStart(editText.getText()));
+ assertEquals(153, Selection.getSelectionEnd(editText.getText()));
}
@MediumTest
@@ -3716,13 +3726,14 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ textView.setVisibility(View.VISIBLE);
textView.setText(getString(R.string.android_wiki_paragraphs));
}
});
final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
.getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
- R.string.android_wiki_short)).get(0);
+ R.string.android_wiki_paragraphs)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -3757,7 +3768,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
&& event.getFromIndex() == 2
- && event.getToIndex() == 104
+ && event.getToIndex() == 14
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -3767,8 +3778,8 @@
assertNotNull(firstExpected);
// Verify the selection position.
- assertEquals(104, Selection.getSelectionStart(textView.getText()));
- assertEquals(104, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(14, Selection.getSelectionStart(textView.getText()));
+ assertEquals(14, Selection.getSelectionEnd(textView.getText()));
// Move to the next paragraph and wait for an event.
AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
@@ -3791,8 +3802,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 106
- && event.getToIndex() == 267
+ && event.getFromIndex() == 16
+ && event.getToIndex() == 32
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -3802,8 +3813,8 @@
assertNotNull(secondExpected);
// Verify the selection position.
- assertEquals(267, Selection.getSelectionStart(textView.getText()));
- assertEquals(267, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(32, Selection.getSelectionStart(textView.getText()));
+ assertEquals(32, Selection.getSelectionEnd(textView.getText()));
// Move to the next paragraph and wait for an event.
AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
@@ -3826,8 +3837,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 268
- && event.getToIndex() == 582
+ && event.getFromIndex() == 33
+ && event.getToIndex() == 47
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -3837,16 +3848,16 @@
assertNotNull(thirdExpected);
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(textView.getText()));
- assertEquals(582, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(47, Selection.getSelectionStart(textView.getText()));
+ assertEquals(47, Selection.getSelectionEnd(textView.getText()));
// Make sure there is no next.
assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(textView.getText()));
- assertEquals(582, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(47, Selection.getSelectionStart(textView.getText()));
+ assertEquals(47, Selection.getSelectionEnd(textView.getText()));
// Move to the previous paragraph and wait for an event.
AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
@@ -3869,8 +3880,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 268
- && event.getToIndex() == 582
+ && event.getFromIndex() == 33
+ && event.getToIndex() == 47
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -3880,8 +3891,8 @@
assertNotNull(fourthExpected);
// Verify the selection position.
- assertEquals(268, Selection.getSelectionStart(textView.getText()));
- assertEquals(268, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(33, Selection.getSelectionStart(textView.getText()));
+ assertEquals(33, Selection.getSelectionEnd(textView.getText()));
// Move to the previous paragraph and wait for an event.
AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
@@ -3904,8 +3915,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 106
- && event.getToIndex() == 267
+ && event.getFromIndex() == 16
+ && event.getToIndex() == 32
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -3915,8 +3926,8 @@
assertNotNull(fifthExpected);
// Verify the selection position.
- assertEquals(106, Selection.getSelectionStart(textView.getText()));
- assertEquals(106, Selection.getSelectionEnd(textView.getText()));
+ assertEquals(16, Selection.getSelectionStart(textView.getText()));
+ assertEquals(16, Selection.getSelectionEnd(textView.getText()));
// Move to the previous paragraph and wait for an event.
AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
@@ -3940,7 +3951,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
&& event.getFromIndex() == 2
- && event.getToIndex() == 104
+ && event.getToIndex() == 14
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -3969,6 +3980,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ editText.setVisibility(View.VISIBLE);
editText.setText(getString(R.string.android_wiki_paragraphs));
Selection.removeSelection(editText.getText());
}
@@ -3976,7 +3988,7 @@
final AccessibilityNodeInfo text = getInstrumentation().getUiAutomation()
.getRootInActiveWindow().findAccessibilityNodeInfosByText(getString(
- R.string.android_wiki_short)).get(0);
+ R.string.android_wiki_paragraphs)).get(0);
final int granularities = text.getMovementGranularities();
assertEquals(granularities, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
@@ -4012,7 +4024,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
&& event.getFromIndex() == 2
- && event.getToIndex() == 104
+ && event.getToIndex() == 14
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4023,7 +4035,7 @@
// Verify the selection position.
assertEquals(2, Selection.getSelectionStart(editText.getText()));
- assertEquals(104, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(14, Selection.getSelectionEnd(editText.getText()));
// Move to the next paragraph and wait for an event.
AccessibilityEvent secondExpected = getInstrumentation().getUiAutomation()
@@ -4046,8 +4058,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 106
- && event.getToIndex() == 267
+ && event.getFromIndex() == 16
+ && event.getToIndex() == 32
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4058,7 +4070,7 @@
// Verify the selection position.
assertEquals(2, Selection.getSelectionStart(editText.getText()));
- assertEquals(267, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(32, Selection.getSelectionEnd(editText.getText()));
// Move to the next paragraph and wait for an event.
AccessibilityEvent thirdExpected = getInstrumentation().getUiAutomation()
@@ -4081,8 +4093,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 268
- && event.getToIndex() == 582
+ && event.getFromIndex() == 33
+ && event.getToIndex() == 47
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4093,7 +4105,7 @@
// Verify the selection position.
assertEquals(2, Selection.getSelectionStart(editText.getText()));
- assertEquals(582, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
assertFalse(text.performAction(
@@ -4101,7 +4113,7 @@
// Verify the selection position.
assertEquals(2, Selection.getSelectionStart(editText.getText()));
- assertEquals(582, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionEnd(editText.getText()));
// Move to the previous paragraph and wait for an event.
AccessibilityEvent fourthExpected = getInstrumentation().getUiAutomation()
@@ -4124,8 +4136,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 268
- && event.getToIndex() == 582
+ && event.getFromIndex() == 33
+ && event.getToIndex() == 47
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4136,7 +4148,7 @@
// Verify the selection position.
assertEquals(2, Selection.getSelectionStart(editText.getText()));
- assertEquals(268, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(33, Selection.getSelectionEnd(editText.getText()));
// Move to the previous paragraph and wait for an event.
AccessibilityEvent fifthExpected = getInstrumentation().getUiAutomation()
@@ -4159,8 +4171,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 106
- && event.getToIndex() == 267
+ && event.getFromIndex() == 16
+ && event.getToIndex() == 32
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4171,7 +4183,7 @@
// Verify the selection position.
assertEquals(2, Selection.getSelectionStart(editText.getText()));
- assertEquals(106, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(16, Selection.getSelectionEnd(editText.getText()));
// Move to the previous paragraph and wait for an event.
AccessibilityEvent sixthExpected = getInstrumentation().getUiAutomation()
@@ -4195,7 +4207,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
&& event.getFromIndex() == 2
- && event.getToIndex() == 104
+ && event.getToIndex() == 14
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4227,14 +4239,14 @@
// Put selection at the end of the text.
Bundle setSelectionArgs = new Bundle();
- setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 582);
- setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 582);
+ setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 47);
+ setSelectionArgs.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 47);
assertTrue(text.performAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION, setSelectionArgs));
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
- assertEquals(582, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
+ assertEquals(47, Selection.getSelectionEnd(editText.getText()));
// Unfocus the view so we can get rid of the soft-keyboard.
getInstrumentation().runOnMainSync(new Runnable() {
@@ -4266,8 +4278,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 268
- && event.getToIndex() == 582
+ && event.getFromIndex() == 33
+ && event.getToIndex() == 47
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4277,8 +4289,8 @@
assertNotNull(seventhExpected);
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
- assertEquals(268, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
+ assertEquals(33, Selection.getSelectionEnd(editText.getText()));
// Move to the previous paragraph and wait for an event.
AccessibilityEvent eightExpected = getInstrumentation().getUiAutomation()
@@ -4301,8 +4313,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 106
- && event.getToIndex() == 267
+ && event.getFromIndex() == 16
+ && event.getToIndex() == 32
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4312,8 +4324,8 @@
assertNotNull(eightExpected);
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
- assertEquals(106, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
+ assertEquals(16, Selection.getSelectionEnd(editText.getText()));
// Move to the previous paragraph and wait for an event.
AccessibilityEvent ninethExpected = getInstrumentation().getUiAutomation()
@@ -4337,7 +4349,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
&& event.getFromIndex() == 2
- && event.getToIndex() == 104
+ && event.getToIndex() == 14
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4347,7 +4359,7 @@
assertNotNull(ninethExpected);
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
assertEquals(2, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no previous.
@@ -4355,7 +4367,7 @@
AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
assertEquals(2, Selection.getSelectionEnd(editText.getText()));
// Move to the next paragraph and wait for an event.
@@ -4380,7 +4392,7 @@
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
&& event.getFromIndex() == 2
- && event.getToIndex() == 104
+ && event.getToIndex() == 14
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4390,8 +4402,8 @@
assertNotNull(tenthExpected);
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
- assertEquals(104, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
+ assertEquals(14, Selection.getSelectionEnd(editText.getText()));
// Move to the next paragraph and wait for an event.
AccessibilityEvent eleventhExpected = getInstrumentation().getUiAutomation()
@@ -4414,8 +4426,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 106
- && event.getToIndex() == 267
+ && event.getFromIndex() == 16
+ && event.getToIndex() == 32
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4425,8 +4437,8 @@
assertNotNull(eleventhExpected);
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
- assertEquals(267, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
+ assertEquals(32, Selection.getSelectionEnd(editText.getText()));
// Move to the next paragraph and wait for an event.
AccessibilityEvent twlevethExpected = getInstrumentation().getUiAutomation()
@@ -4449,8 +4461,8 @@
&& event.getText().size() > 0
&& event.getText().get(0).toString().equals(getString(
R.string.android_wiki_paragraphs))
- && event.getFromIndex() == 268
- && event.getToIndex() == 582
+ && event.getFromIndex() == 33
+ && event.getToIndex() == 47
&& event.getMovementGranularity() ==
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
}
@@ -4460,16 +4472,16 @@
assertNotNull(twlevethExpected);
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
- assertEquals(582, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
+ assertEquals(47, Selection.getSelectionEnd(editText.getText()));
// Make sure there is no next.
assertFalse(text.performAction(
AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments));
// Verify the selection position.
- assertEquals(582, Selection.getSelectionStart(editText.getText()));
- assertEquals(582, Selection.getSelectionEnd(editText.getText()));
+ assertEquals(47, Selection.getSelectionStart(editText.getText()));
+ assertEquals(47, Selection.getSelectionEnd(editText.getText()));
}
@MediumTest
@@ -4480,6 +4492,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ editText.setVisibility(View.VISIBLE);
editText.setFocusable(true);
editText.requestFocus();
editText.setText(getString(R.string.foo_bar_baz));
@@ -4536,6 +4549,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ view.setVisibility(View.VISIBLE);
view.setContentDescription(getString(R.string.foo_bar_baz));
}
});
@@ -4564,6 +4578,7 @@
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
+ view.setVisibility(View.VISIBLE);
view.setContentDescription(getString(R.string.foo_bar_baz));
}
});
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
index 0ea9a7f..1632489 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
@@ -55,7 +55,7 @@
public void testFindByText() throws Exception {
// find a view by text
List<AccessibilityNodeInfo> buttons = getInstrumentation().getUiAutomation()
- .getRootInActiveWindow().findAccessibilityNodeInfosByText("butto");
+ .getRootInActiveWindow().findAccessibilityNodeInfosByText("b");
assertEquals(9, buttons.size());
}
@@ -84,15 +84,15 @@
classNameAndTextList.add("android.widget.LinearLayout");
classNameAndTextList.add("android.widget.LinearLayout");
classNameAndTextList.add("android.widget.LinearLayout");
- classNameAndTextList.add("android.widget.ButtonButton1");
- classNameAndTextList.add("android.widget.ButtonButton2");
- classNameAndTextList.add("android.widget.ButtonButton3");
- classNameAndTextList.add("android.widget.ButtonButton4");
- classNameAndTextList.add("android.widget.ButtonButton5");
- classNameAndTextList.add("android.widget.ButtonButton6");
- classNameAndTextList.add("android.widget.ButtonButton7");
- classNameAndTextList.add("android.widget.ButtonButton8");
- classNameAndTextList.add("android.widget.ButtonButton9");
+ classNameAndTextList.add("android.widget.ButtonB1");
+ classNameAndTextList.add("android.widget.ButtonB2");
+ classNameAndTextList.add("android.widget.ButtonB3");
+ classNameAndTextList.add("android.widget.ButtonB4");
+ classNameAndTextList.add("android.widget.ButtonB5");
+ classNameAndTextList.add("android.widget.ButtonB6");
+ classNameAndTextList.add("android.widget.ButtonB7");
+ classNameAndTextList.add("android.widget.ButtonB8");
+ classNameAndTextList.add("android.widget.ButtonB9");
Queue<AccessibilityNodeInfo> fringe = new LinkedList<AccessibilityNodeInfo>();
fringe.add(getInstrumentation().getUiAutomation().getRootInActiveWindow());
@@ -420,6 +420,61 @@
}
}
+ private void verifyNodesInAppWindow(AccessibilityNodeInfo root) throws Exception {
+ try {
+ AccessibilityServiceInfo info = getInstrumentation().getUiAutomation().getServiceInfo();
+ info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
+ getInstrumentation().getUiAutomation().setServiceInfo(info);
+
+ root.refresh();
+
+ // make list of expected nodes
+ List<String> classNameAndTextList = new ArrayList<String>();
+ classNameAndTextList.add("android.widget.FrameLayout");
+ classNameAndTextList.add("android.widget.LinearLayout");
+ classNameAndTextList.add("android.widget.FrameLayout");
+ classNameAndTextList.add("android.widget.LinearLayout");
+ classNameAndTextList.add("android.widget.LinearLayout");
+ classNameAndTextList.add("android.widget.LinearLayout");
+ classNameAndTextList.add("android.widget.LinearLayout");
+ classNameAndTextList.add("android.widget.ButtonB1");
+ classNameAndTextList.add("android.widget.ButtonB2");
+ classNameAndTextList.add("android.widget.ButtonB3");
+ classNameAndTextList.add("android.widget.ButtonB4");
+ classNameAndTextList.add("android.widget.ButtonB5");
+ classNameAndTextList.add("android.widget.ButtonB6");
+ classNameAndTextList.add("android.widget.ButtonB7");
+ classNameAndTextList.add("android.widget.ButtonB8");
+ classNameAndTextList.add("android.widget.ButtonB9");
+
+ Queue<AccessibilityNodeInfo> fringe = new LinkedList<AccessibilityNodeInfo>();
+ fringe.add(root);
+
+ // do a BFS traversal and check nodes
+ while (!fringe.isEmpty()) {
+ AccessibilityNodeInfo current = fringe.poll();
+
+ CharSequence text = current.getText();
+ String receivedClassNameAndText = current.getClassName().toString()
+ + ((text != null) ? text.toString() : "");
+ String expectedClassNameAndText = classNameAndTextList.remove(0);
+
+ assertEquals("Did not get the expected node info",
+ expectedClassNameAndText, receivedClassNameAndText);
+
+ final int childCount = current.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ AccessibilityNodeInfo child = current.getChild(i);
+ fringe.add(child);
+ }
+ }
+ } finally {
+ AccessibilityServiceInfo info = getInstrumentation().getUiAutomation().getServiceInfo();
+ info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
+ getInstrumentation().getUiAutomation().setServiceInfo(info);
+ }
+ }
+
@Override
protected void scrubClass(Class<?> testCaseClass) {
/* intentionally do not scrub */