dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 1 | # Accessibility |
| 2 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 3 | Here's a quick overview of all of the locations in the codebase where you'll |
| 4 | find accessibility tests, and a brief overview of the purpose of all of them. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 5 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 6 | ## Web Tests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 7 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 8 | This is the primary place where we test accessibility code in Blink. This code |
| 9 | should have no platform-specific code. Use this to test anything where there's |
| 10 | any interesting web platform logic, or where you need to be able to query things |
| 11 | synchronously from the renderer thread to test them. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 12 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 13 | Don't add tests for trivial features like ARIA attributes that we just expose |
| 14 | directly to the next layer up. In those cases the Blink tests are trivial and |
| 15 | it's more valuable to test these features at a higher level where we can ensure |
| 16 | they actually work. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 17 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 18 | Note that many of these tests are inherited from WebKit and the coding style has |
| 19 | evolved a lot since then. Look for more recent tests as a guide if writing a new |
| 20 | one. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 21 | |
| 22 | Test files: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 23 | [third_party/blink/web_tests/accessibility](https://cs.chromium.org/chromium/src/third_party/blink/web_tests/accessibility/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 24 | |
| 25 | Source code to AccessibilityController and WebAXObjectProxy: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 26 | [content/shell/test_runner](https://cs.chromium.org/chromium/src/content/shell/test_runner/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 27 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 28 | To run all accessibility web tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 29 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 30 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 31 | autoninja -C out/release blink_tests third_party/blink/tools/run_web_tests.py \ |
| 32 | --build-directory=out --target=release accessibility/ |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 33 | ``` |
| 34 | |
| 35 | To run just one test by itself without the script: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 36 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 37 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 38 | autoninja -C out/release blink_tests && out/release/content_shell \ |
| 39 | --run-web-tests third_party/blink/web_tests/accessibility/name-calc-inputs.html |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 40 | ``` |
| 41 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 42 | For information on modifying or adding web tests, see the main |
| 43 | [web tests documentation](https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_tests.md). |
| 44 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 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: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 56 | [content/test/data/accessibility](https://cs.chromium.org/chromium/src/content/test/data/accessibility/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 57 | |
| 58 | Test runner: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 59 | [content/browser/accessibility/dump_accessibility_tree_browsertest.cc](https://cs.chromium.org/chromium/src/content/browser/accessibility/dump_accessibility_tree_browsertest.cc) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 60 | |
| 61 | To run all tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 62 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 63 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 64 | autoninja -C out/release content_browsertests && \ |
| 65 | out/release/content_browsertests --gtest_filter="DumpAccessibilityTree*" |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 66 | ``` |
| 67 | |
| 68 | ## Other content_browsertests |
| 69 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 70 | There are many other tests in content/ that relate to accessibility. All of |
| 71 | these tests work by launching a full multi-process browser shell, loading a web |
| 72 | page in a renderer, then accessing the resulting accessibility tree from the |
| 73 | browser process, and running some test from there. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 74 | |
| 75 | To run all tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 76 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 77 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 78 | autoninja -C out/release content_browsertests && \ |
| 79 | out/release/content_browsertests --gtest_filter="*ccessib*" |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 80 | ``` |
| 81 | |
| 82 | ## Accessibility unittests |
| 83 | |
| 84 | This tests the core accessibility code that's shared by both web and non-web |
| 85 | accessibility infrastructure. |
| 86 | |
| 87 | Code location: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 88 | [ui/accessibility](https://cs.chromium.org/chromium/src/ui/accessibility/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 89 | |
| 90 | To run all tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 91 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 92 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 93 | autoninja -C out/release accessibility_unittests && \ |
| 94 | out/release/accessibility_unittests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 95 | ``` |
| 96 | |
| 97 | ## ChromeVox tests |
| 98 | |
James Cook | 1380ad16 | 2018-10-25 00:51:19 | [diff] [blame] | 99 | ChromeVox tests are part of the browser_tests suite. You must build with |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 100 | `target_os = "chromeos"` in your GN args. |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 101 | |
| 102 | To run all tests: |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 103 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 104 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 105 | autoninja -C out/release browser_tests && \ |
| 106 | out/release/browser_tests --test-launcher-jobs=20 --gtest_filter=ChromeVox* |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 107 | ``` |
| 108 | |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 109 | ### Select-To-Speak tests |
| 110 | |
| 111 | ``` |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 112 | autoninja -C out/Default unit_tests browser_tests && \ |
| 113 | out/Default/unit_tests --gtest_filter=*SelectToSpeak* && \ |
| 114 | out/Default/browser_tests --gtest_filter=*SelectToSpeak* |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 115 | ``` |
| 116 | |
Dominic Mazzoni | b11c82d | 2018-08-29 17:01:58 | [diff] [blame] | 117 | ## Performance tests |
| 118 | |
| 119 | We also have a page on [Performance Tests](perf.md). |
| 120 | |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 121 | ## Other locations of accessibility tests: |
| 122 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 123 | Even this isn't a complete list. The tests described above cover more than 90% |
| 124 | of the accessibility tests, and the remainder are scattered throughout the |
| 125 | codebase. Here are a few other locations to check: |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 126 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 127 | * [chrome/android/javatests/src/org/chromium/chrome/browser/accessibility](https://cs.chromium.org/chromium/src/chrome/android/javatests/src/org/chromium/chrome/browser/accessibility/) |
| 128 | * [chrome/browser/accessibility](https://cs.chromium.org/chromium/src/chrome/browser/accessibility/) |
| 129 | * [chrome/browser/chromeos/accessibility/](https://cs.chromium.org/chromium/src/chrome/browser/chromeos/accessibility/) |
| 130 | * [ui/chromeos](https://cs.chromium.org/chromium/src/ui/chromeos/) |
| 131 | * [ui/views/accessibility](https://cs.chromium.org/chromium/src/ui/views/accessibility/) |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 132 | |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 133 | ## Helpful flags: |
| 134 | |
| 135 | Across all tests there are some helpful flags that will make testing easier. |
| 136 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 137 | * Run tests multiple times in parallel (useful for finding flakes): |
| 138 | `--test-launcher-jobs=10` |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 139 | |
Aran Gilman | e7035589cd | 2019-05-01 23:47:30 | [diff] [blame] | 140 | * Filter which tests to run: `--gtest_filter="*Cats*"` |