OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // | 48 // |
49 // The flow of the test is as outlined below. | 49 // The flow of the test is as outlined below. |
50 // 1. Load an html file from content/test/data/accessibility. | 50 // 1. Load an html file from content/test/data/accessibility. |
51 // 2. Read the expectation. | 51 // 2. Read the expectation. |
52 // 3. Browse to the page and serialize the platform specific tree into a human | 52 // 3. Browse to the page and serialize the platform specific tree into a human |
53 // readable string. | 53 // readable string. |
54 // 4. Perform a comparison between actual and expected and fail if they do not | 54 // 4. Perform a comparison between actual and expected and fail if they do not |
55 // exactly match. | 55 // exactly match. |
56 class DumpAccessibilityTreeTest : public DumpAccessibilityTestBase { | 56 class DumpAccessibilityTreeTest : public DumpAccessibilityTestBase { |
57 public: | 57 public: |
58 void AddDefaultFilters(std::vector<Filter>* filters) override { | 58 void AddDefaultFilters(std::vector<Filter>* filters) override; |
59 filters->push_back(Filter(base::ASCIIToUTF16("FOCUSABLE"), Filter::ALLOW)); | 59 void AddFilter(std::vector<Filter>* filters, |
60 filters->push_back(Filter(base::ASCIIToUTF16("READONLY"), Filter::ALLOW)); | 60 std::string filter, |
61 filters->push_back(Filter(base::ASCIIToUTF16("roleDescription=*"), | 61 Filter::Type type = Filter::ALLOW) { |
62 Filter::ALLOW)); | 62 filters->push_back(Filter(base::ASCIIToUTF16(filter), type)); |
63 filters->push_back(Filter(base::ASCIIToUTF16("*=''"), Filter::DENY)); | |
64 // After denying empty values, because we want to allow name='' | |
65 filters->push_back( | |
66 Filter(base::ASCIIToUTF16("name=*"), Filter::ALLOW_EMPTY)); | |
67 } | 63 } |
68 | 64 |
69 void SetUpCommandLine(base::CommandLine* command_line) override { | 65 void SetUpCommandLine(base::CommandLine* command_line) override { |
70 DumpAccessibilityTestBase::SetUpCommandLine(command_line); | 66 DumpAccessibilityTestBase::SetUpCommandLine(command_line); |
71 // Enable <dialog>, which is used in some tests. | 67 // Enable <dialog>, which is used in some tests. |
72 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 68 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
73 switches::kEnableExperimentalWebPlatformFeatures); | 69 switches::kEnableExperimentalWebPlatformFeatures); |
74 // Enable accessibility object model, used in other tests. | 70 // Enable accessibility object model, used in other tests. |
75 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 71 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
76 switches::kEnableBlinkFeatures, "AccessibilityObjectModel"); | 72 switches::kEnableBlinkFeatures, "AccessibilityObjectModel"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 formatter->FormatAccessibilityTree( | 126 formatter->FormatAccessibilityTree( |
131 web_contents->GetRootBrowserAccessibilityManager()->GetRoot(), | 127 web_contents->GetRootBrowserAccessibilityManager()->GetRoot(), |
132 &actual_contents_utf16); | 128 &actual_contents_utf16); |
133 std::string actual_contents = base::UTF16ToUTF8(actual_contents_utf16); | 129 std::string actual_contents = base::UTF16ToUTF8(actual_contents_utf16); |
134 return base::SplitString( | 130 return base::SplitString( |
135 actual_contents, "\n", | 131 actual_contents, "\n", |
136 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 132 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
137 } | 133 } |
138 }; | 134 }; |
139 | 135 |
| 136 void DumpAccessibilityTreeTest::AddDefaultFilters( |
| 137 std::vector<Filter>* filters) { |
| 138 // TODO(aleventhal) Each platform deserves separate default filters. |
| 139 |
| 140 // |
| 141 // Windows |
| 142 // |
| 143 |
| 144 // Too noisy: HOTTRACKED, LINKED, SELECTABLE, IA2_STATE_EDITABLE, |
| 145 // IA2_STATE_OPAQUE, IA2_STATE_SELECTAbLE_TEXT, |
| 146 // IA2_STATE_SINGLE_LINE, IA2_STATE_VERTICAL. |
| 147 // Too unpredictible: OFFSCREEN |
| 148 // Windows states to log by default: |
| 149 AddFilter(filters, "ALERT*"); |
| 150 AddFilter(filters, "ANIMATED*"); |
| 151 AddFilter(filters, "BUSY"); |
| 152 AddFilter(filters, "CHECKED"); |
| 153 AddFilter(filters, "COLLAPSED"); |
| 154 AddFilter(filters, "DEFAULT"); |
| 155 AddFilter(filters, "EXPANDED"); |
| 156 AddFilter(filters, "FLOATING"); |
| 157 AddFilter(filters, "FOCUS*"); |
| 158 AddFilter(filters, "HASPOPUP"); |
| 159 AddFilter(filters, "INVISIBLE"); |
| 160 AddFilter(filters, "MARQUEED"); |
| 161 AddFilter(filters, "MIXED"); |
| 162 AddFilter(filters, "MOVEABLE"); |
| 163 AddFilter(filters, "MULTISELECTABLE"); |
| 164 AddFilter(filters, "READONLY"); |
| 165 AddFilter(filters, "PRESSED"); |
| 166 AddFilter(filters, "PROTECTED"); |
| 167 AddFilter(filters, "SELECTED"); |
| 168 AddFilter(filters, "SIZEABLE"); |
| 169 AddFilter(filters, "TRAVERSED"); |
| 170 AddFilter(filters, "UNAVAILABLE"); |
| 171 AddFilter(filters, "IA2_STATE_ACTIVE"); |
| 172 AddFilter(filters, "IA2_STATE_ARMED"); |
| 173 AddFilter(filters, "IA2_STATE_CHECKABLE"); |
| 174 AddFilter(filters, "IA2_STATE_DEFUNCT"); |
| 175 AddFilter(filters, "IA2_STATE_HORIZONTAL"); |
| 176 AddFilter(filters, "IA2_STATE_ICONIFIED"); |
| 177 AddFilter(filters, "IA2_STATE_INVALID_ENTRY"); |
| 178 AddFilter(filters, "IA2_STATE_MODAL"); |
| 179 AddFilter(filters, "IA2_STATE_MULTI_LINE"); |
| 180 AddFilter(filters, "IA2_STATE_PINNED"); |
| 181 AddFilter(filters, "IA2_STATE_REQUIRED"); |
| 182 AddFilter(filters, "IA2_STATE_STALE"); |
| 183 AddFilter(filters, "IA2_STATE_TRANSIENT"); |
| 184 |
| 185 // |
| 186 // Blink |
| 187 // |
| 188 |
| 189 // Noisy, perhaps add later: |
| 190 // editable, focus*, horizontal, linked, richlyEditable, vertical |
| 191 // Too flaky: hovered, offscreen |
| 192 AddFilter(filters, "check*"); |
| 193 AddFilter(filters, "descript*"); |
| 194 AddFilter(filters, "invalid"); |
| 195 AddFilter(filters, "busy"); |
| 196 AddFilter(filters, "collapsed"); |
| 197 AddFilter(filters, "default"); |
| 198 AddFilter(filters, "haspopup"); |
| 199 AddFilter(filters, "horizontal"); |
| 200 AddFilter(filters, "invisible"); |
| 201 // TODO(aleventhal) multiline |
| 202 AddFilter(filters, "multiselectable"); |
| 203 AddFilter(filters, "protected"); |
| 204 // TODO(aleventhal) Add readonly support back after control mode refactor |
| 205 AddFilter(filters, "required"); |
| 206 AddFilter(filters, "select*"); |
| 207 AddFilter(filters, "visited"); |
| 208 |
| 209 // |
| 210 // OS X |
| 211 // |
| 212 |
| 213 AddFilter(filters, "roleDescription=*"); |
| 214 |
| 215 // |
| 216 // General |
| 217 // |
| 218 |
| 219 // Deny most empty values |
| 220 AddFilter(filters, "*=''", Filter::DENY); |
| 221 // After denying empty values, because we want to allow name='' |
| 222 AddFilter(filters, "name=*", Filter::ALLOW_EMPTY); |
| 223 } |
| 224 |
140 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCSSColor) { | 225 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCSSColor) { |
141 RunCSSTest(FILE_PATH_LITERAL("color.html")); | 226 RunCSSTest(FILE_PATH_LITERAL("color.html")); |
142 } | 227 } |
143 | 228 |
144 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCSSFontStyle) { | 229 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCSSFontStyle) { |
145 RunCSSTest(FILE_PATH_LITERAL("font-style.html")); | 230 RunCSSTest(FILE_PATH_LITERAL("font-style.html")); |
146 } | 231 } |
147 | 232 |
148 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCSSFontFamily) { | 233 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCSSFontFamily) { |
149 RunCSSTest(FILE_PATH_LITERAL("font-family.html")); | 234 RunCSSTest(FILE_PATH_LITERAL("font-family.html")); |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 // crbug.com/281952 | 1571 // crbug.com/281952 |
1487 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, DISABLED_AccessibilityVideo) { | 1572 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, DISABLED_AccessibilityVideo) { |
1488 RunHtmlTest(FILE_PATH_LITERAL("video.html")); | 1573 RunHtmlTest(FILE_PATH_LITERAL("video.html")); |
1489 } | 1574 } |
1490 | 1575 |
1491 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) { | 1576 IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) { |
1492 RunHtmlTest(FILE_PATH_LITERAL("wbr.html")); | 1577 RunHtmlTest(FILE_PATH_LITERAL("wbr.html")); |
1493 } | 1578 } |
1494 | 1579 |
1495 } // namespace content | 1580 } // namespace content |
OLD | NEW |