Skip to content

Commit 9cd1712

Browse files
minorninthCommit bot
authored and
Commit bot
committed
Added docs on accessibility tests
BUG=none NOTRY=true TBR=nektar@chromium.org Review-Url: https://codereview.chromium.org/2728663004 Cr-Commit-Position: refs/heads/master@{#454197}
1 parent 59ed1a9 commit 9cd1712

File tree

3 files changed

+135
-4
lines changed

3 files changed

+135
-4
lines changed

content/test/data/accessibility/readme.txt content/test/data/accessibility/readme.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DumpAccessibilityTreeTest and DumpAccessibilityEventsTest Notes:
1+
# DumpAccessibilityTreeTest and DumpAccessibilityEventsTest Notes:
22

33
Both sets of tests use a similar format for files.
44

@@ -28,6 +28,7 @@ ninja -C out/Debug content_browsertests
2828
out/Debug/content_browsertests --gtest_filter="DumpAccessibility*"
2929

3030
Files used:
31+
3132
* foo.html -- a file to be tested
3233
* foo-expected-android.txt -- expected Android AccessibilityNodeInfo output
3334
* foo-expected-auralinux.txt -- expected Linux ATK output
@@ -36,13 +37,15 @@ Files used:
3637
* foo-expected-win.txt -- expected Win IAccessible/IAccessible2 output
3738

3839
Format for expected files:
40+
3941
* Blank lines and lines beginning with # are ignored
4042
* Skipped files: if first line of file begins with #<skip then the
4143
test passes. This can be used to indicate desired output with a link
4244
to a bug, or as a way to temporarily disable a test during refactoring.
4345
* Use 2 plus signs for indent to show hierarchy
4446

4547
Filters:
48+
4649
* By default only some attributes of nodes in the accessibility tree, or
4750
events fired (when running DumpAccessibilityEvents) are output.
4851
This is to keep the tests robust and not prone to failure when unrelated
@@ -51,11 +54,13 @@ Filters:
5154
They can appear anywhere but typically they're in an HTML comment block,
5255
and must be one per line.
5356
* Filters are platform-specific:
57+
```
5458
@WIN-
5559
@MAC-
5660
@BLINK-
5761
@ANDROID-
5862
@AURALINUX-
63+
```
5964
* To dump all attributes while writing or debugging a test, add this filter:
6065
@WIN-ALLOW:*
6166
(and similarly for other platforms).
@@ -64,16 +69,18 @@ Filters:
6469
ALLOW filter means to include the attribute, and a DENY filter means to
6570
exclude it. Filters can contain simple wildcards ('*') only, they're not
6671
regular expressions. Examples:
72+
```
6773
- @WIN-ALLOW:name* - this will output the name attribute on Windows
6874
- @WIN-ALLOW:name='Foo' - this will only output the name attribute if it
6975
exactly matches 'Foo'.
7076
- @WIN-DENY:name='X* - this will skip outputting any name that begins with
7177
the letter X.
78+
```
7279
* By default empty attributes are skipped. To output the value an attribute
7380
even if it's empty, use @WIN-ALLOW-EMPTY:name, for example, and similarly
7481
for other platforms.
7582

76-
Advanced:
83+
## Advanced:
7784

7885
Normally the system waits for the document to finish loading before dumping
7986
the accessibility tree.
@@ -98,7 +105,7 @@ To load an iframe from a different site, forcing it into a different process,
98105
use /cross-site/HOSTNAME/ in the url, for example:
99106
<iframe src="cross-site/1.com/accessibility/html/frame.html"></iframe>
100107

101-
Generating expectations and rebaselining:
108+
## Generating expectations and rebaselining:
102109

103110
If you want to populate the expectation file directly rather than typing it
104111
or copying-and-pasting it, first make sure the file exists (it can be empty),
@@ -113,7 +120,7 @@ This will replace the -expected-*.txt file with the current output. It's
113120
a great way to rebaseline a bunch of tests after making a change. Please
114121
manually check the diff, of course!
115122

116-
Adding a new test:
123+
## Adding a new test:
117124

118125
If you are adding a new test file remember to add a corresponding test case in
119126
content/browser/accessibility/dump_accessibility_events_browsertest.cc

docs/accessibility.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Accessibility
22

33
* [Accessibility Overview](accessibility/overview.md)
4+
* [Accessibility Tests](accessibility/tests.md)
45

56
## Chrome OS
67

docs/accessibility/tests.md

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Accessibility
2+
3+
Here's a quick overview of all of the locations in the codebase where
4+
you'll find accessibility tests, and a brief overview of the purpose of
5+
all of them.
6+
7+
## Layout Tests
8+
9+
This is the primary place where we test accessibility code in Blink. This
10+
code should have no platform-specific code. Use this to test anything
11+
where there's any interesting web platform logic, or where you need to be
12+
able to query things synchronously from the renderer thread to test them.
13+
14+
Don't add tests for trivial features like ARIA attributes that we just
15+
expose directly to the next layer up. In those cases the Blink tests are
16+
trivial and it's more valuable to test these features at a higher level
17+
where we can ensure they actually work.
18+
19+
Note that many of these tests are inherited from WebKit and the coding style
20+
has evolved a lot since then. Look for more recent tests as a guide if writing
21+
a new one.
22+
23+
Test files:
24+
```
25+
third_party/WebKit/LayoutTests/accessibility
26+
```
27+
28+
Source code to AccessibilityController and WebAXObjectProxy:
29+
```
30+
content/shell/test_runner
31+
```
32+
33+
To run all accessibility LayoutTests:
34+
```
35+
ninja -C out/release blink_tests
36+
third_party/WebKit/Tools/Scripts/run-webkit-tests --build-directory=out --target=release accessibility/
37+
```
38+
39+
To run just one test by itself without the script:
40+
```
41+
ninja -C out/release blink_tests
42+
out/release/content_shell --run-layout-test third_party/WebKit/LayoutTests/accessibility/name-calc-inputs.html
43+
```
44+
45+
## DumpAccessibilityTree tests
46+
47+
This is the best way to write both cross-platform and platform-specific tests
48+
using only an input HTML file, some magic strings to describe what attributes
49+
you're interested in, and one or more expectation files to enable checking
50+
whether the resulting accessibility tree is correct or not. In particular,
51+
almost no test code is required.
52+
53+
[More documentation on DumpAccessibilityTree](../../content/test/data/accessibility/readme.md)
54+
55+
Test files:
56+
```
57+
content/test/data/accessibility
58+
```
59+
60+
Test runner:
61+
```
62+
content/browser/accessibility/dump_accessibility_tree_browsertest.cc
63+
```
64+
65+
To run all tests:
66+
```
67+
ninja -C out/release content_browsertests
68+
out/release/content_browsertests --gtest_filter="DumpAccessibilityTree*"
69+
```
70+
71+
## Other content_browsertests
72+
73+
There are many other tests in content/ that relate to accessibility.
74+
All of these tests work by launching a full multi-process browser shell,
75+
loading a web page in a renderer, then accessing the resulting accessibility
76+
tree from the browser process, and running some test from there.
77+
78+
To run all tests:
79+
```
80+
ninja -C out/release content_browsertests
81+
out/release/content_browsertests --gtest_filter="*ccessib*"
82+
```
83+
84+
## Accessibility unittests
85+
86+
This tests the core accessibility code that's shared by both web and non-web
87+
accessibility infrastructure.
88+
89+
Code location:
90+
```
91+
ui/accessibility
92+
```
93+
94+
To run all tests:
95+
```
96+
ninja -C out/release accessibility_unittests
97+
out/release/accessibility_unittests
98+
```
99+
100+
## ChromeVox tests
101+
102+
You must build with ```target_os = "chromeos"``` in your GN args.
103+
104+
To run all tests:
105+
```
106+
ninja -C out/release chromevox_tests
107+
out/release/chromevox_tests --test-launcher-jobs=10
108+
```
109+
110+
## Other locations of accessibility tests:
111+
112+
Even this isn't a complete list. The tests described above cover more
113+
than 90% of the accessibility tests, and the remainder are scattered
114+
throughout the codebase. Here are a few other locations to check:
115+
116+
```
117+
chrome/android/javatests/src/org/chromium/chrome/browser/accessibility
118+
chrome/browser/accessibility
119+
chrome/browser/chromeos/accessibility/
120+
ui/chromeos
121+
ui/views/accessibility
122+
```
123+

0 commit comments

Comments
 (0)