Port old tests to new "missing layer" Android accessibility suite
This continues the work on the "missing layer" test fixes for the
Android accessibility code.
With this CL we remove some previously existing tests from the
WebContentsAccessibilityTest file and instead include them in the
corresponding Event* and Tree* test suites. These tests are easier to
understand and maintain, and this makes the original
WebContentsAccessibilityTest file contain only tests that cannot be
done with the static dump tests.
We also include new PRESUBMIT checks to give helpful hints to other
developers so we can more easily maintain consistency across platforms.
AX-Relnotes: N/A
Bug: 1258230
Change-Id: I5dd19ef407afba10a8b711cf55458c84860dc4f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3390858
Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Mark Schillaci <mschillaci@google.com>
Cr-Commit-Position: refs/heads/main@{#960717}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1d0b2c0ca7
commit
e5a0be2079
107
PRESUBMIT.py
107
PRESUBMIT.py
@ -4250,6 +4250,113 @@ def CheckAccessibilityRelnotesField(input_api, output_api):
|
||||
|
||||
return [output_api.PresubmitNotifyResult(message)]
|
||||
|
||||
|
||||
_ACCESSIBILITY_EVENTS_TEST_PATH = (
|
||||
r"^content[\\/]test[\\/]data[\\/]accessibility[\\/]event[\\/].*\.html",
|
||||
)
|
||||
|
||||
_ACCESSIBILITY_TREE_TEST_PATH = (
|
||||
r"^content[\\/]test[\\/]data[\\/]accessibility[\\/]accname[\\/].*\.html",
|
||||
r"^content[\\/]test[\\/]data[\\/]accessibility[\\/]aria[\\/].*\.html",
|
||||
r"^content[\\/]test[\\/]data[\\/]accessibility[\\/]css[\\/].*\.html",
|
||||
r"^content[\\/]test[\\/]data[\\/]accessibility[\\/]html[\\/].*\.html",
|
||||
)
|
||||
|
||||
_ACCESSIBILITY_ANDROID_EVENTS_TEST_PATH = (
|
||||
r"^.*[\\/]WebContentsAccessibilityEventsTest\.java",
|
||||
)
|
||||
|
||||
_ACCESSIBILITY_ANDROID_TREE_TEST_PATH = (
|
||||
r"^.*[\\/]WebContentsAccessibilityEventsTest\.java",
|
||||
)
|
||||
|
||||
def CheckAccessibilityEventsTestsAreIncludedForAndroid(input_api, output_api):
|
||||
"""Checks that commits that include a newly added, renamed/moved, or deleted
|
||||
test in the DumpAccessibilityEventsTest suite also includes a corresponding
|
||||
change to the Android test."""
|
||||
def FilePathFilter(affected_file):
|
||||
paths = _ACCESSIBILITY_EVENTS_TEST_PATH
|
||||
return input_api.FilterSourceFile(affected_file, files_to_check=paths)
|
||||
|
||||
def AndroidFilePathFilter(affected_file):
|
||||
paths = _ACCESSIBILITY_ANDROID_EVENTS_TEST_PATH
|
||||
return input_api.FilterSourceFile(affected_file, files_to_check=paths)
|
||||
|
||||
# Only consider changes in the events test data path with html type.
|
||||
if not any(input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=FilePathFilter)):
|
||||
return []
|
||||
|
||||
# If the commit contains any change to the Android test file, ignore.
|
||||
if any(input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=AndroidFilePathFilter)):
|
||||
return []
|
||||
|
||||
# Only consider changes that are adding/renaming or deleting a file
|
||||
message = []
|
||||
for f in input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=FilePathFilter):
|
||||
if f.Action()=='A' or f.Action()=='D':
|
||||
message = ("It appears that you are adding, renaming or deleting"
|
||||
"\na dump_accessibility_events* test, but have not included"
|
||||
"\na corresponding change for Android."
|
||||
"\nPlease include (or remove) the test from:"
|
||||
"\n content/public/android/javatests/src/org/chromium/"
|
||||
"content/browser/accessibility/"
|
||||
"WebContentsAccessibilityEventsTest.java"
|
||||
"\nIf this message is confusing or annoying, please contact"
|
||||
"\nmembers of ui/accessibility/OWNERS.")
|
||||
|
||||
# If no message was set, return empty.
|
||||
if not len(message):
|
||||
return []
|
||||
|
||||
return [output_api.PresubmitPromptWarning(message)]
|
||||
|
||||
def CheckAccessibilityTreeTestsAreIncludedForAndroid(input_api, output_api):
|
||||
"""Checks that commits that include a newly added, renamed/moved, or deleted
|
||||
test in the DumpAccessibilityTreeTest suite also includes a corresponding
|
||||
change to the Android test."""
|
||||
def FilePathFilter(affected_file):
|
||||
paths = _ACCESSIBILITY_TREE_TEST_PATH
|
||||
return input_api.FilterSourceFile(affected_file, files_to_check=paths)
|
||||
|
||||
def AndroidFilePathFilter(affected_file):
|
||||
paths = _ACCESSIBILITY_ANDROID_TREE_TEST_PATH
|
||||
return input_api.FilterSourceFile(affected_file, files_to_check=paths)
|
||||
|
||||
# Only consider changes in the various tree test data paths with html type.
|
||||
if not any(input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=FilePathFilter)):
|
||||
return []
|
||||
|
||||
# If the commit contains any change to the Android test file, ignore.
|
||||
if any(input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=AndroidFilePathFilter)):
|
||||
return []
|
||||
|
||||
# Only consider changes that are adding/renaming or deleting a file
|
||||
message = []
|
||||
for f in input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=FilePathFilter):
|
||||
if f.Action()=='A' or f.Action()=='D':
|
||||
message = ("It appears that you are adding, renaming or deleting"
|
||||
"\na dump_accessibility_tree* test, but have not included"
|
||||
"\na corresponding change for Android."
|
||||
"\nPlease include (or remove) the test from:"
|
||||
"\n content/public/android/javatests/src/org/chromium/"
|
||||
"content/browser/accessibility/"
|
||||
"WebContentsAccessibilityTreeTest.java"
|
||||
"\nIf this message is confusing or annoying, please contact"
|
||||
"\nmembers of ui/accessibility/OWNERS.")
|
||||
|
||||
# If no message was set, return empty.
|
||||
if not len(message):
|
||||
return []
|
||||
|
||||
return [output_api.PresubmitPromptWarning(message)]
|
||||
|
||||
|
||||
# string pattern, sequence of strings to show when pattern matches,
|
||||
# error flag. True if match is a presubmit error, otherwise it's a warning.
|
||||
_NON_INCLUSIVE_TERMS = (
|
||||
|
@ -1028,6 +1028,234 @@ class AccessibilityRelnotesFieldTest(unittest.TestCase):
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
class AccessibilityEventsTestsAreIncludedForAndroidTest(unittest.TestCase):
|
||||
# Test that no warning is raised when the Android file is also modified.
|
||||
def testAndroidChangeIncluded(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile(
|
||||
'accessibility/WebContentsAccessibilityEventsTest.java',
|
||||
[''], action='M')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that a warning is raised when the Android file is not modified.
|
||||
def testAndroidChangeMissing(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[''], action='A'),
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (1, len(msgs), msgs))
|
||||
|
||||
# Test that Android change is not required when no html file is added/removed.
|
||||
def testIgnoreNonHtmlFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.txt',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.cc',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.h',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.py',
|
||||
[''], action='A')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that Android change is not required for unrelated html files.
|
||||
def testIgnoreNonRelatedHtmlFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/aria/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/html/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('chrome/tests/data/accessibility/foo.html',
|
||||
[''], action='A')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that only modifying an html file will not trigger the warning.
|
||||
def testIgnoreModifiedFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[''], action='M')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that deleting an html file will trigger the warning.
|
||||
def testAndroidChangeMissingOnDeletedFile(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[], action='D')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (1, len(msgs), msgs))
|
||||
|
||||
class AccessibilityTreeTestsAreIncludedForAndroidTest(unittest.TestCase):
|
||||
# Test that no warning is raised when the Android file is also modified.
|
||||
def testAndroidChangeIncluded(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/aria/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile(
|
||||
'accessibility/WebContentsAccessibilityEventsTest.java',
|
||||
[''], action='M')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityTreeTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that no warning is raised when the Android file is also modified.
|
||||
def testAndroidChangeIncludedManyFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/accname/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/aria/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/css/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/html/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile(
|
||||
'accessibility/WebContentsAccessibilityEventsTest.java',
|
||||
[''], action='M')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityTreeTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that a warning is raised when the Android file is not modified.
|
||||
def testAndroidChangeMissing(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/aria/foo.html',
|
||||
[''], action='A'),
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityTreeTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (1, len(msgs), msgs))
|
||||
|
||||
# Test that Android change is not required when no html file is added/removed.
|
||||
def testIgnoreNonHtmlFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/accname/foo.txt',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/aria/foo.cc',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/css/foo.h',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/tree/foo.py',
|
||||
[''], action='A')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityTreeTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that Android change is not required for unrelated html files.
|
||||
def testIgnoreNonRelatedHtmlFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[''], action='A'),
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityTreeTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that only modifying an html file will not trigger the warning.
|
||||
def testIgnoreModifiedFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/aria/foo.html',
|
||||
[''], action='M')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityTreeTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that deleting an html file will trigger the warning.
|
||||
def testAndroidChangeMissingOnDeletedFile(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/accname/foo.html',
|
||||
[], action='D')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityTreeTestsAreIncludedForAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (1, len(msgs), msgs))
|
||||
|
||||
class AndroidDeprecatedTestAnnotationTest(unittest.TestCase):
|
||||
def testCheckAndroidTestAnnotationUsage(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
@ -697,6 +697,24 @@ public class WebContentsAccessibilityEventsTest {
|
||||
performTest("inner-html-change.html", EMPTY_EXPECTATIONS_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void test_inputCombobox() {
|
||||
performTest("input-combobox.html", "input-combobox-expected-android.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void test_inputComboboxAria1() {
|
||||
performTest("input-combobox-aria1.html", "input-combobox-aria1-expected-android.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void test_inputComboboxDialog() {
|
||||
performTest("input-combobox-dialog.html", "input-combobox-dialog-expected-android.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void test_inputTypeTextValueChanged() {
|
||||
|
@ -20,7 +20,6 @@ import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.Acces
|
||||
import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_COPY;
|
||||
import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CUT;
|
||||
import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_FOCUS;
|
||||
import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_LONG_CLICK;
|
||||
import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY;
|
||||
import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_NEXT_HTML_ELEMENT;
|
||||
import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_PAGE_UP;
|
||||
@ -44,7 +43,6 @@ import static org.chromium.content.browser.accessibility.AccessibilityContentShe
|
||||
import static org.chromium.content.browser.accessibility.AccessibilityContentShellTestUtils.sInputTypeMatcher;
|
||||
import static org.chromium.content.browser.accessibility.AccessibilityContentShellTestUtils.sRangeInfoMatcher;
|
||||
import static org.chromium.content.browser.accessibility.AccessibilityContentShellTestUtils.sTextMatcher;
|
||||
import static org.chromium.content.browser.accessibility.AccessibilityContentShellTestUtils.sTextOrContentDescriptionMatcher;
|
||||
import static org.chromium.content.browser.accessibility.AccessibilityContentShellTestUtils.sViewIdResourceNameMatcher;
|
||||
import static org.chromium.content.browser.accessibility.WebContentsAccessibilityImpl.EVENTS_DROPPED_HISTOGRAM;
|
||||
import static org.chromium.content.browser.accessibility.WebContentsAccessibilityImpl.EXTRAS_DATA_REQUEST_IMAGE_DATA_KEY;
|
||||
@ -60,7 +58,6 @@ import static org.chromium.content.browser.accessibility.WebContentsAccessibilit
|
||||
import static org.chromium.content.browser.accessibility.WebContentsAccessibilityImpl.PERCENTAGE_DROPPED_HISTOGRAM;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.graphics.Rect;
|
||||
@ -104,33 +101,20 @@ import java.util.concurrent.ExecutionException;
|
||||
* implements the interface.
|
||||
*/
|
||||
@RunWith(ContentJUnit4ClassRunner.class)
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP)
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@SuppressLint("VisibleForTests")
|
||||
public class WebContentsAccessibilityTest {
|
||||
// Test output error messages
|
||||
private static final String COMBOBOX_ERROR = "expanded combobox announcement was incorrect.";
|
||||
private static final String DISABLED_COMBOBOX_ERROR =
|
||||
"disabled combobox child elements should not be clickable";
|
||||
private static final String LONG_CLICK_ERROR =
|
||||
"node should not have the ACTION_LONG_CLICK action as an available action";
|
||||
private static final String ACTION_SET_ERROR =
|
||||
"node should have the ACTION_SET_TEXT action as an available action";
|
||||
private static final String THRESHOLD_ERROR =
|
||||
"Too many TYPE_WINDOW_CONTENT_CHANGED events received in an atomic update.";
|
||||
private static final String THRESHOLD_LOW_EVENT_COUNT_ERROR =
|
||||
"Expected more TYPE_WINDOW_CONTENT_CHANGED events"
|
||||
+ "in an atomic update, is throttling still necessary?";
|
||||
private static final String ARIA_INVALID_ERROR =
|
||||
"Error message for aria-invalid node has not been set correctly.";
|
||||
private static final String CONTENTEDITABLE_ERROR =
|
||||
"contenteditable node is not being identified and/or received incorrect class name";
|
||||
private static final String SPELLING_ERROR =
|
||||
"node should have a Spannable with spelling correction for given text.";
|
||||
private static final String INPUT_RANGE_VALUE_MISMATCH =
|
||||
"Value for <input type='range'> is incorrect, did you honor 'step' value?";
|
||||
private static final String INPUT_RANGE_VALUETEXT_MISMATCH =
|
||||
"Value for <input type='range'> text is incorrect, did you honor aria-valuetext?";
|
||||
private static final String INPUT_RANGE_EVENT_ERROR =
|
||||
"TYPE_VIEW_SCROLLED event not received before timeout.";
|
||||
private static final String CACHING_ERROR = "AccessibilityNodeInfo cache has stale data";
|
||||
@ -262,7 +246,6 @@ public class WebContentsAccessibilityTest {
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.O)
|
||||
public void testAccessibilityNodeInfo_inputTypeRange() throws Throwable {
|
||||
// Create a basic input range, and find the associated |AccessibilityNodeInfo| object.
|
||||
setupTestWithHTML("<input type='range' min='0' max='40'>");
|
||||
@ -316,7 +299,6 @@ public class WebContentsAccessibilityTest {
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.O)
|
||||
public void testAccessibilityNodeInfo_inputTypeRange_withStepValue() throws Throwable {
|
||||
// Create a basic input range, and find the associated |AccessibilityNodeInfo| object.
|
||||
setupTestWithHTML("<input type='range' min='0' max='144' step='12'>");
|
||||
@ -372,7 +354,6 @@ public class WebContentsAccessibilityTest {
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.O)
|
||||
public void testAccessibilityNodeInfo_inputTypeRange_withRequiredMin() throws Throwable {
|
||||
// Create a basic input range, and find the associated |AccessibilityNodeInfo| object.
|
||||
setupTestWithHTML("<input type='range' min='0' max='1000' step='1'>");
|
||||
@ -421,39 +402,6 @@ public class WebContentsAccessibilityTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test <input type="range"> nodes are properly populated when aria-valuetext is set.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testAccessibilityNodeInfo_inputTypeRange_withAriaValueText() {
|
||||
// Build a simple web page with input nodes that have aria-valuetext.
|
||||
setupTestWithHTML(
|
||||
"<input id='in1' type='range' value='1' min='0' max='2' aria-valuetext='medium'>"
|
||||
+ "<label for='in2'>This is a test label"
|
||||
+ " <input id='in2' type='range' value='0' min='0' max='2' aria-valuetext='small'>"
|
||||
+ "</label>");
|
||||
|
||||
int vvIdInput1 = waitForNodeMatching(sViewIdResourceNameMatcher, "in1");
|
||||
int vvIdInput2 = waitForNodeMatching(sViewIdResourceNameMatcher, "in2");
|
||||
AccessibilityNodeInfoCompat mNodeInfo1 = createAccessibilityNodeInfo(vvIdInput1);
|
||||
AccessibilityNodeInfoCompat mNodeInfo2 = createAccessibilityNodeInfo(vvIdInput2);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo1);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo2);
|
||||
|
||||
mActivityTestRule.sendEndOfTestSignal();
|
||||
|
||||
// Check the text of each element, and that RangeInfo has not been set.
|
||||
mNodeInfo1 = createAccessibilityNodeInfo(vvIdInput1);
|
||||
mNodeInfo2 = createAccessibilityNodeInfo(vvIdInput2);
|
||||
Assert.assertEquals(
|
||||
INPUT_RANGE_VALUETEXT_MISMATCH, "medium", mNodeInfo1.getText().toString());
|
||||
Assert.assertEquals(INPUT_RANGE_VALUETEXT_MISMATCH, "small, This is a test label",
|
||||
mNodeInfo2.getText().toString());
|
||||
Assert.assertNull(INPUT_RANGE_VALUETEXT_MISMATCH, mNodeInfo1.getRangeInfo());
|
||||
Assert.assertNull(INPUT_RANGE_VALUETEXT_MISMATCH, mNodeInfo2.getRangeInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure we throttle TYPE_WINDOW_CONTENT_CHANGED events for large tree updates.
|
||||
*/
|
||||
@ -526,90 +474,6 @@ public class WebContentsAccessibilityTest {
|
||||
Assert.assertTrue(lowThresholdError(eventCount), eventCount > UNSUPPRESSED_EXPECTED_COUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure we send an announcement on combobox expansion.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testEventText_Combobox() throws Throwable {
|
||||
// Build a simple web page with a combobox, and focus the input field.
|
||||
setupTestFromFile("content/test/data/android/input/input_combobox.html");
|
||||
|
||||
// Find a node in the accessibility tree of the correct class.
|
||||
int comboBoxVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(comboBoxVirtualViewId);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
|
||||
focusNode(comboBoxVirtualViewId);
|
||||
|
||||
// Run JS code to expand the combobox
|
||||
executeJS("expandCombobox()");
|
||||
|
||||
// Signal end of test
|
||||
mActivityTestRule.sendEndOfTestSignal();
|
||||
|
||||
// We should have received a TYPE_ANNOUNCEMENT event, check announcement text.
|
||||
Assert.assertEquals(COMBOBOX_ERROR, "expanded, 3 autocomplete options available.",
|
||||
mTestData.getAnnouncementText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure we send an announcement on combobox expansion that opens a dialog.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testEventText_Combobox_dialog() throws Throwable {
|
||||
// Build a simple web page with a combobox, and focus the input field.
|
||||
setupTestFromFile("content/test/data/android/input/input_combobox_dialog.html");
|
||||
|
||||
// Find a node in the accessibility tree of the correct class.
|
||||
int comboBoxVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(comboBoxVirtualViewId);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
|
||||
focusNode(comboBoxVirtualViewId);
|
||||
|
||||
// Run JS code to expand the combobox
|
||||
executeJS("expandCombobox()");
|
||||
|
||||
// Signal end of test
|
||||
mActivityTestRule.sendEndOfTestSignal();
|
||||
|
||||
// We should have received a TYPE_ANNOUNCEMENT event, check announcement text.
|
||||
Assert.assertEquals(
|
||||
COMBOBOX_ERROR, "expanded, dialog opened.", mTestData.getAnnouncementText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure we send an announcement on combobox expansion with aria-1.0 spec.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testEventText_Combobox_ariaOne() throws Throwable {
|
||||
// Build a simple web page with a combobox, and focus the input field.
|
||||
setupTestFromFile("content/test/data/android/input/input_combobox_aria1.0.html");
|
||||
|
||||
// Find a node in the accessibility tree of the correct class.
|
||||
int comboBoxVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(comboBoxVirtualViewId);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
|
||||
focusNode(comboBoxVirtualViewId);
|
||||
|
||||
// Run JS code to expand the combobox
|
||||
executeJS("expandCombobox()");
|
||||
|
||||
// Signal end of test
|
||||
mActivityTestRule.sendEndOfTestSignal();
|
||||
|
||||
// We should have received a TYPE_ANNOUNCEMENT event, check announcement text.
|
||||
Assert.assertEquals(COMBOBOX_ERROR, "expanded, 3 autocomplete options available.",
|
||||
mTestData.getAnnouncementText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that disabled comboboxes and children are not shadow clickable.
|
||||
*/
|
||||
@ -978,95 +842,6 @@ public class WebContentsAccessibilityTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object for contenteditable node.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testNodeInfo_className_contenteditable() {
|
||||
setupTestWithHTML("<div contenteditable>Edit This</div>");
|
||||
|
||||
int textNodeVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(textNodeVirtualViewId);
|
||||
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
Assert.assertTrue(CONTENTEDITABLE_ERROR, mNodeInfo.isEditable());
|
||||
Assert.assertEquals(CONTENTEDITABLE_ERROR, "Edit This", mNodeInfo.getText().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object for node with aria-invalid="true".
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testNodeInfo_errorMessage_true() {
|
||||
setupTestWithHTML("<input type='text' aria-invalid='true' value='123456789'>");
|
||||
|
||||
int textNodeVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(textNodeVirtualViewId);
|
||||
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
Assert.assertTrue(ARIA_INVALID_ERROR, mNodeInfo.isContentInvalid());
|
||||
Assert.assertEquals(ARIA_INVALID_ERROR, "Invalid entry", mNodeInfo.getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object for node with aria-invalid="spelling".
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testNodeInfo_errorMessage_spelling() {
|
||||
setupTestWithHTML("<input type='text' aria-invalid='spelling' value='123456789'>");
|
||||
|
||||
int textNodeVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(textNodeVirtualViewId);
|
||||
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
Assert.assertTrue(ARIA_INVALID_ERROR, mNodeInfo.isContentInvalid());
|
||||
// Spelling and Grammar errors via aria-invalid label on the whole text field are reported
|
||||
// as general errors.
|
||||
Assert.assertEquals(ARIA_INVALID_ERROR, "Invalid entry", mNodeInfo.getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object for node with aria-invalid="grammar".
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testNodeInfo_errorMessage_grammar() {
|
||||
setupTestWithHTML("<input type='text' aria-invalid='grammar' value='123456789'>");
|
||||
|
||||
int textNodeVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(textNodeVirtualViewId);
|
||||
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
Assert.assertTrue(ARIA_INVALID_ERROR, mNodeInfo.isContentInvalid());
|
||||
// Spelling and Grammar errors via aria-invalid label on the whole text field are reported
|
||||
// as general errors.
|
||||
Assert.assertEquals(ARIA_INVALID_ERROR, "Invalid entry", mNodeInfo.getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object for node with no aria-invalid.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testNodeInfo_errorMessage_none() {
|
||||
setupTestWithHTML("<input type='text'>");
|
||||
|
||||
int textNodeVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(textNodeVirtualViewId);
|
||||
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
Assert.assertFalse(ARIA_INVALID_ERROR, mNodeInfo.isContentInvalid());
|
||||
Assert.assertNull(ARIA_INVALID_ERROR, mNodeInfo.getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object for node with spelling error, and ensure the
|
||||
* spelling error is encoded as a Spannable.
|
||||
@ -1104,8 +879,6 @@ public class WebContentsAccessibilityTest {
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.O)
|
||||
@TargetApi(Build.VERSION_CODES.O)
|
||||
public void testNodeInfo_extraDataAdded_characterLocations() {
|
||||
setupTestWithHTML("<h1>Simple test page</h1><section><p>Text</p></section>");
|
||||
|
||||
@ -1190,8 +963,6 @@ public class WebContentsAccessibilityTest {
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.O)
|
||||
@TargetApi(Build.VERSION_CODES.O)
|
||||
public void testNodeInfo_extraDataAdded_imageData() {
|
||||
// Setup test page with example image (20px red square).
|
||||
setupTestWithHTML("<img id='id1' src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEU"
|
||||
@ -1264,51 +1035,12 @@ public class WebContentsAccessibilityTest {
|
||||
mNodeInfo.getExtras().getInt(EXTRAS_KEY_UNCLIPPED_BOTTOM) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object actions to ensure we are not adding ACTION_LONG_CLICK
|
||||
* to nodes due to verbose utterances issue.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.M)
|
||||
public void testNodeInfo_noLongClickAction() {
|
||||
// Build a simple web page with a node.
|
||||
setupTestWithHTML("<p>Example paragraph</p>");
|
||||
|
||||
int textViewId = waitForNodeMatching(sTextOrContentDescriptionMatcher, "Example paragraph");
|
||||
mNodeInfo = createAccessibilityNodeInfo(textViewId);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
|
||||
// Confirm the ACTION_LONG_CLICK action has not been added to the node.
|
||||
Assert.assertFalse(LONG_CLICK_ERROR, mNodeInfo.getActionList().contains(ACTION_LONG_CLICK));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object actions for text node.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.M)
|
||||
public void testNodeInfo_Actions_SetText() {
|
||||
// Load a web page with a text field.
|
||||
setupTestWithHTML("<input type='text'>");
|
||||
|
||||
int textNodeVirtualViewId =
|
||||
waitForNodeMatching(sClassNameMatcher, "android.widget.EditText");
|
||||
mNodeInfo = createAccessibilityNodeInfo(textNodeVirtualViewId);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
|
||||
// Confirm the ACTION_SET_TEXT action has been added to the node.
|
||||
Assert.assertTrue(ACTION_SET_ERROR, mNodeInfo.getActionList().contains(ACTION_SET_TEXT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test |AccessibilityNodeInfo| object actions for node is specifically user scrollable,
|
||||
* and not just programmatically scrollable.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.M)
|
||||
public void testNodeInfo_Actions_OverflowHidden() throws Throwable {
|
||||
// Build a simple web page with a div and overflow:hidden
|
||||
setupTestWithHTML("<div title='1234' style='overflow:hidden; width: 200px; height:50px'>\n"
|
||||
@ -1354,7 +1086,6 @@ public class WebContentsAccessibilityTest {
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.M)
|
||||
public void testNodeInfo_Actions_OverflowScroll() throws Throwable {
|
||||
// Build a simple web page with a div and overflow:scroll
|
||||
setupTestWithHTML("<div title='1234' style='overflow:scroll; width: 200px; height:50px'>\n"
|
||||
@ -1403,7 +1134,6 @@ public class WebContentsAccessibilityTest {
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.M)
|
||||
public void testNodeInfoCache_AccessibilityFocusAndActions() throws Throwable {
|
||||
// Build a simple web page with two paragraphs that can be focused.
|
||||
setupTestWithHTML("<div>\n"
|
||||
@ -1866,7 +1596,6 @@ public class WebContentsAccessibilityTest {
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.M)
|
||||
public void testPerformAction_paste() throws Throwable {
|
||||
// Build a simple web page with an input field.
|
||||
setupTestWithHTML("<input type='text'>");
|
||||
@ -2191,7 +1920,6 @@ public class WebContentsAccessibilityTest {
|
||||
Assert.assertFalse(PERFORM_ACTION_ERROR, mNodeInfo2.isFocused());
|
||||
}
|
||||
|
||||
@MinAndroidSdkLevel(Build.VERSION_CODES.M)
|
||||
private void assertActionsContainNoScrolls(AccessibilityNodeInfoCompat nodeInfo) {
|
||||
Assert.assertFalse(nodeInfo.getActionList().contains(ACTION_SCROLL_FORWARD));
|
||||
Assert.assertFalse(nodeInfo.getActionList().contains(ACTION_SCROLL_BACKWARD));
|
||||
|
@ -1801,6 +1801,12 @@ public class WebContentsAccessibilityTreeTest {
|
||||
performHtmlTest("input-text-name-calc.html");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void test_inputTextRange() {
|
||||
performHtmlTest("input-text-range.html");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void test_inputTextReadOnly() {
|
||||
|
@ -1,60 +0,0 @@
|
||||
# Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""Presubmit script for content/test/data/accessibility*"""
|
||||
|
||||
PRESUBMIT_VERSION = '2.0.0'
|
||||
|
||||
USE_PYTHON3 = True
|
||||
|
||||
_ACCESSIBILITY_EVENTS_TEST_PATH = (
|
||||
r"^content[\\/]test[\\/]data[\\/]accessibility[\\/]event[\\/].*\.html",
|
||||
)
|
||||
|
||||
_ACCESSIBILITY_ANDROID_EVENTS_TEST_PATH = (
|
||||
r"^.*[\\/]WebContentsAccessibilityEventsTest\.java",
|
||||
)
|
||||
|
||||
def CheckAccessibilityEventsTestIncludesAndroid(input_api, output_api):
|
||||
"""Checks that commits that include a newly added, renamed/moved, or deleted
|
||||
test in the DumpAccessibilityEventsTest suite also includes a corresponding
|
||||
change to the Android test."""
|
||||
def FilePathFilter(affected_file):
|
||||
paths = _ACCESSIBILITY_EVENTS_TEST_PATH
|
||||
return input_api.FilterSourceFile(affected_file, files_to_check=paths)
|
||||
|
||||
def AndroidFilePathFilter(affected_file):
|
||||
paths = _ACCESSIBILITY_ANDROID_EVENTS_TEST_PATH
|
||||
return input_api.FilterSourceFile(affected_file, files_to_check=paths)
|
||||
|
||||
# Only consider changes in the events test data path with html type.
|
||||
if not any(input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=FilePathFilter)):
|
||||
return []
|
||||
|
||||
# If the commit contains any change to the Android test file, ignore.
|
||||
if any(input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=AndroidFilePathFilter)):
|
||||
return []
|
||||
|
||||
# Only consider changes that are adding/renaming or deleting a file
|
||||
message = []
|
||||
for f in input_api.AffectedFiles(include_deletes=True,
|
||||
file_filter=FilePathFilter):
|
||||
if f.Action()=='A' or f.Action()=='D':
|
||||
message = ("It appears that you are adding, renaming or deleting"
|
||||
"\na dump_accessibility_events* test, but have not included"
|
||||
"\na corresponding change for Android."
|
||||
"\nPlease include (or remove) the test from:"
|
||||
"\n content/public/android/javatests/src/org/chromium/"
|
||||
"content/browser/accessibility/"
|
||||
"WebContentsAccessibilityEventsTest.java"
|
||||
"\nIf this message is confusing or annoying, please contact"
|
||||
"\nmembers of ui/accessibility/OWNERS.")
|
||||
|
||||
# If no message was set, return empty.
|
||||
if not len(message):
|
||||
return []
|
||||
|
||||
return [output_api.PresubmitPromptWarning(message)]
|
@ -1,122 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import PRESUBMIT
|
||||
|
||||
sys.path.append(
|
||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..',
|
||||
'..', '..'))
|
||||
from PRESUBMIT_test_mocks import (MockInputApi, MockOutputApi, MockAffectedFile)
|
||||
|
||||
class AccessibilityEventsTestIncludesAndroidTest(unittest.TestCase):
|
||||
# Test that no warning is raised when the Android file is also modified.
|
||||
def testAndroidChangeIncluded(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile(
|
||||
'accessibility/WebContentsAccessibilityEventsTest.java',
|
||||
[''], action='M')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestIncludesAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that a warning is raised when the Android file is not modified.
|
||||
def testAndroidChangeMissing(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[''], action='A'),
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestIncludesAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (1, len(msgs), msgs))
|
||||
|
||||
# Test that Android change is not required when no html file is added/removed.
|
||||
def testIgnoreNonHtmlFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.txt',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.cc',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.h',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.py',
|
||||
[''], action='A')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestIncludesAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that Android change is not required for unrelated html files.
|
||||
def testIgnoreNonRelatedHtmlFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/aria/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('content/test/data/accessibility/html/foo.html',
|
||||
[''], action='A'),
|
||||
MockAffectedFile('chrome/tests/data/accessibility/foo.html',
|
||||
[''], action='A')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestIncludesAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that only modifying an html file will not trigger the warning.
|
||||
def testIgnoreModifiedFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[''], action='M')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestIncludesAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (0, len(msgs), msgs))
|
||||
|
||||
# Test that deleting an html file will trigger the warning.
|
||||
def testAndroidChangeMissingOnDeletedFile(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
||||
mock_input_api.files = [
|
||||
MockAffectedFile('content/test/data/accessibility/event/foo.html',
|
||||
[], action='D')
|
||||
]
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityEventsTestIncludesAndroid(
|
||||
mock_input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(msgs),
|
||||
'Expected %d messages, found %d: %s'
|
||||
% (1, len(msgs), msgs))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,2 @@
|
||||
TYPE_VIEW_TEXT_SELECTION_CHANGED - [0, 0]
|
||||
TYPE_ANNOUNCEMENT - [expanded, 3 autocomplete options available.]
|
@ -2,7 +2,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function expandCombobox() {
|
||||
function go() {
|
||||
document.getElementById('test-input').focus();
|
||||
document.getElementById('test-input').setAttribute('aria-expanded', 'true');
|
||||
document.getElementById('test-listbox').removeAttribute('hidden');
|
||||
document.getElementById('test-input').setAttribute('aria-controls', 'test-listbox');
|
@ -0,0 +1,3 @@
|
||||
TYPE_VIEW_TEXT_SELECTION_CHANGED - [0, 0]
|
||||
TYPE_ANNOUNCEMENT - [expanded, dialog opened.]
|
||||
TYPE_WINDOW_STATE_CHANGED - [contentTypes=16]
|
@ -2,7 +2,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function expandCombobox() {
|
||||
function go() {
|
||||
document.getElementById('test-input').focus();
|
||||
document.getElementById('test-combobox').setAttribute('aria-expanded', 'true');
|
||||
document.getElementById('test-dialog').removeAttribute('hidden');
|
||||
document.getElementById('test-input').setAttribute('aria-controls', 'test-dialog');
|
@ -0,0 +1,2 @@
|
||||
TYPE_VIEW_TEXT_SELECTION_CHANGED - [0, 0]
|
||||
TYPE_ANNOUNCEMENT - [expanded, 3 autocomplete options available.]
|
@ -2,7 +2,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function expandCombobox() {
|
||||
function go() {
|
||||
document.getElementById('test-input').focus();
|
||||
document.getElementById('test-combobox').setAttribute('aria-expanded', 'true');
|
||||
document.getElementById('test-listbox').removeAttribute('hidden');
|
||||
document.getElementById('test-input').setAttribute('aria-controls', 'test-listbox');
|
@ -0,0 +1,6 @@
|
||||
WebView focusable focused scrollable actions:[CLEAR_FOCUS, AX_FOCUS] bundle:[chromeRole="rootWebArea"]
|
||||
++View actions:[AX_FOCUS] bundle:[chromeRole="genericContainer"]
|
||||
++++SeekBar text:"medium" clickable focusable actions:[FOCUS, CLICK, AX_FOCUS, NEXT, PREVIOUS, SCROLL_FORWARD, SCROLL_BACKWARD, SET_PROGRESS] bundle:[chromeRole="slider", roleDescription="slider"]
|
||||
++++View actions:[AX_FOCUS] bundle:[chromeRole="labelText"]
|
||||
++++++TextView text:"This is a test label " actions:[AX_FOCUS, NEXT, PREVIOUS] bundle:[chromeRole="staticText"]
|
||||
++++++SeekBar text:"small" clickable focusable actions:[FOCUS, CLICK, AX_FOCUS, NEXT, PREVIOUS, SCROLL_FORWARD, SET_PROGRESS] bundle:[chromeRole="slider", roleDescription="slider"]
|
@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<input type='range' value='1' min='0' max='2' aria-valuetext='medium'>
|
||||
<label for='in2'>This is a test label
|
||||
<input type='range' value='0' min='0' max='2' aria-valuetext='small'>
|
||||
</label>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user