dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 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 | ``` |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 35 | autoninja -C out/release blink_tests |
Kent Tamura | a045a7f | 2018-04-25 05:08:11 | [diff] [blame] | 36 | third_party/blink/tools/run_web_tests.py --build-directory=out --target=release accessibility/ |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 37 | ``` |
| 38 | |
| 39 | To run just one test by itself without the script: |
| 40 | ``` |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 41 | autoninja -C out/release blink_tests |
Kent Tamura | cd3ebc4 | 2018-05-16 06:44:22 | [diff] [blame] | 42 | out/release/content_shell --run-web-tests third_party/WebKit/LayoutTests/accessibility/name-calc-inputs.html |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 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 | ``` |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 67 | autoninja -C out/release content_browsertests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 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 | ``` |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 80 | autoninja -C out/release content_browsertests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 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 | ``` |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 96 | autoninja -C out/release accessibility_unittests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 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 | ``` |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 106 | autoninja -C out/release chromevox_tests |
dmazzoni | 9cd17124 | 2017-03-02 06:58:46 | [diff] [blame] | 107 | out/release/chromevox_tests --test-launcher-jobs=10 |
| 108 | ``` |
| 109 | |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 110 | ### Select-To-Speak tests |
| 111 | |
| 112 | ``` |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 113 | autoninja -C out/release unit_tests |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 114 | out/release/unit_tests --gtest_filter="*SelectToSpeak*" |
| 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 | |
| 123 | Even this isn't a complete list. The tests described above cover more |
| 124 | than 90% of the accessibility tests, and the remainder are scattered |
| 125 | throughout the codebase. Here are a few other locations to check: |
| 126 | |
| 127 | ``` |
| 128 | chrome/android/javatests/src/org/chromium/chrome/browser/accessibility |
| 129 | chrome/browser/accessibility |
| 130 | chrome/browser/chromeos/accessibility/ |
| 131 | ui/chromeos |
| 132 | ui/views/accessibility |
| 133 | ``` |
| 134 | |
Katie Dektar | 4a165e1b | 2017-09-27 16:15:13 | [diff] [blame] | 135 | ## Helpful flags: |
| 136 | |
| 137 | Across 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 | ``` |