blob: fb1793e151c9af5f4a2800abad7c435a3079d01e [file] [log] [blame] [view]
dmazzoni9cd171242017-03-02 06:58:461# Accessibility
2
3Here's a quick overview of all of the locations in the codebase where
4you'll find accessibility tests, and a brief overview of the purpose of
5all of them.
6
7## Layout Tests
8
9This is the primary place where we test accessibility code in Blink. This
10code should have no platform-specific code. Use this to test anything
11where there's any interesting web platform logic, or where you need to be
12able to query things synchronously from the renderer thread to test them.
13
14Don't add tests for trivial features like ARIA attributes that we just
15expose directly to the next layer up. In those cases the Blink tests are
16trivial and it's more valuable to test these features at a higher level
17where we can ensure they actually work.
18
19Note that many of these tests are inherited from WebKit and the coding style
20has evolved a lot since then. Look for more recent tests as a guide if writing
21a new one.
22
23Test files:
24```
25third_party/WebKit/LayoutTests/accessibility
26```
27
28Source code to AccessibilityController and WebAXObjectProxy:
29```
30content/shell/test_runner
31```
32
33To run all accessibility LayoutTests:
34```
Max Morozf5b31fcd2018-08-10 21:55:4835autoninja -C out/release blink_tests
Kent Tamuraa045a7f2018-04-25 05:08:1136third_party/blink/tools/run_web_tests.py --build-directory=out --target=release accessibility/
dmazzoni9cd171242017-03-02 06:58:4637```
38
39To run just one test by itself without the script:
40```
Max Morozf5b31fcd2018-08-10 21:55:4841autoninja -C out/release blink_tests
Kent Tamuracd3ebc42018-05-16 06:44:2242out/release/content_shell --run-web-tests third_party/WebKit/LayoutTests/accessibility/name-calc-inputs.html
dmazzoni9cd171242017-03-02 06:58:4643```
44
45## DumpAccessibilityTree tests
46
47This is the best way to write both cross-platform and platform-specific tests
48using only an input HTML file, some magic strings to describe what attributes
49you're interested in, and one or more expectation files to enable checking
50whether the resulting accessibility tree is correct or not. In particular,
51almost no test code is required.
52
53[More documentation on DumpAccessibilityTree](../../content/test/data/accessibility/readme.md)
54
55Test files:
56```
57content/test/data/accessibility
58```
59
60Test runner:
61```
62content/browser/accessibility/dump_accessibility_tree_browsertest.cc
63```
64
65To run all tests:
66```
Max Morozf5b31fcd2018-08-10 21:55:4867autoninja -C out/release content_browsertests
dmazzoni9cd171242017-03-02 06:58:4668out/release/content_browsertests --gtest_filter="DumpAccessibilityTree*"
69```
70
71## Other content_browsertests
72
73There are many other tests in content/ that relate to accessibility.
74All of these tests work by launching a full multi-process browser shell,
75loading a web page in a renderer, then accessing the resulting accessibility
76tree from the browser process, and running some test from there.
77
78To run all tests:
79```
Max Morozf5b31fcd2018-08-10 21:55:4880autoninja -C out/release content_browsertests
dmazzoni9cd171242017-03-02 06:58:4681out/release/content_browsertests --gtest_filter="*ccessib*"
82```
83
84## Accessibility unittests
85
86This tests the core accessibility code that's shared by both web and non-web
87accessibility infrastructure.
88
89Code location:
90```
91ui/accessibility
92```
93
94To run all tests:
95```
Max Morozf5b31fcd2018-08-10 21:55:4896autoninja -C out/release accessibility_unittests
dmazzoni9cd171242017-03-02 06:58:4697out/release/accessibility_unittests
98```
99
100## ChromeVox tests
101
102You must build with ```target_os = "chromeos"``` in your GN args.
103
104To run all tests:
105```
Max Morozf5b31fcd2018-08-10 21:55:48106autoninja -C out/release chromevox_tests
dmazzoni9cd171242017-03-02 06:58:46107out/release/chromevox_tests --test-launcher-jobs=10
108```
109
Katie Dektar4a165e1b2017-09-27 16:15:13110### Select-To-Speak tests
111
112```
Max Morozf5b31fcd2018-08-10 21:55:48113autoninja -C out/release unit_tests
Katie Dektar4a165e1b2017-09-27 16:15:13114out/release/unit_tests --gtest_filter="*SelectToSpeak*"
115```
116
Dominic Mazzonib11c82d2018-08-29 17:01:58117## Performance tests
118
119We also have a page on [Performance Tests](perf.md).
120
dmazzoni9cd171242017-03-02 06:58:46121## Other locations of accessibility tests:
122
123Even this isn't a complete list. The tests described above cover more
124than 90% of the accessibility tests, and the remainder are scattered
125throughout the codebase. Here are a few other locations to check:
126
127```
128chrome/android/javatests/src/org/chromium/chrome/browser/accessibility
129chrome/browser/accessibility
130chrome/browser/chromeos/accessibility/
131ui/chromeos
132ui/views/accessibility
133```
134
Katie Dektar4a165e1b2017-09-27 16:15:13135## Helpful flags:
136
137Across all tests there are some helpful flags that will make testing easier.
138
139```
140--test-launcher-jobs=10 # This will run stuff in parallel and make flakes more obvious
141```
142
143```
144--gtest_filter="*Cats*" # Filter which tests run. Takes a wildcard (*) optionally.
145```