OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 GEN_INCLUDE(['../../testing/assert_additions.js']); | 5 GEN_INCLUDE(['../../testing/assert_additions.js']); |
6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); |
7 | 7 |
8 /** | 8 /** |
9 * Test fixture for output.js. | 9 * Test fixture for output.js. |
10 * @constructor | 10 * @constructor |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 if (typeof expectedValue == 'object') { | 218 if (typeof expectedValue == 'object') { |
219 assertEqualsJSON(expectedValue, o.toSpannableForTest()); | 219 assertEqualsJSON(expectedValue, o.toSpannableForTest()); |
220 } else { | 220 } else { |
221 expected.string_ = expectedValue; | 221 expected.string_ = expectedValue; |
222 assertEqualsJSON(expected, o.toSpannableForTest()); | 222 assertEqualsJSON(expected, o.toSpannableForTest()); |
223 } | 223 } |
224 el = el.nextSibling; | 224 el = el.nextSibling; |
225 }); | 225 }); |
226 }); | 226 }); |
227 }); | 227 }); |
| 228 |
| 229 TEST_F('OutputE2ETest', 'List', function() { |
| 230 this.runWithLoadedTree( |
| 231 '<ul><li>a<li>b<li>c</ul>', |
| 232 function(root) { |
| 233 var el = root.firstChild.firstChild; |
| 234 var range = cursors.Range.fromNode(el); |
| 235 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 236 assertEqualsJSON({string_: 'list|with 3 items|a||List item', spans_: [ |
| 237 {value: 'name', start: 18, end: 19}, |
| 238 {value: 'value', start:20, end: 20}, |
| 239 {value: 'role', start: 21, end: 30}, |
| 240 {value: {}, start: 21, end: 30} |
| 241 ]}, o.toSpannableForTest()); |
| 242 }); |
| 243 }); |
| 244 |
| 245 TEST_F('OutputE2ETest', 'Tree', function() { |
| 246 this.runWithLoadedTree(function() {/*! |
| 247 <ul role="tree"> |
| 248 <li aria-expanded="true" role="treeitem">a |
| 249 <li role="treeitem">b |
| 250 <li aria-expanded="false" role="treeitem">c |
| 251 </ul> |
| 252 */}, |
| 253 function(root) { |
| 254 var el = root.firstChild.children[0].firstChild; |
| 255 var range = cursors.Range.fromNode(el); |
| 256 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 257 assertEqualsJSON( |
| 258 {string_: '|Tree|with 3 items|Tree item|Expanded| 1 of 3 | level 1 |a|', |
| 259 spans_: [ |
| 260 // Enter rule. |
| 261 |
| 262 // TreeItem. |
| 263 {value: 'role','start': 19, end: 28}, |
| 264 {value: 'state', start: 29, end: 37}, |
| 265 |
| 266 // InLineTextBox. |
| 267 {value: 'value', start: 57, end: 58}, |
| 268 {value: 'name', start: 59, end: 59} |
| 269 ]}, o.toSpannableForTest()); |
| 270 |
| 271 el = root.firstChild.children[1].firstChild; |
| 272 var range = cursors.Range.fromNode(el); |
| 273 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 274 assertEqualsJSON( |
| 275 {string_: '|Tree|with 3 items|Tree item| 2 of 3 | level 1 |b|', |
| 276 spans_: [ |
| 277 // Enter rule. |
| 278 |
| 279 // TreeItem. |
| 280 {value: 'role','start': 19, end: 28}, |
| 281 |
| 282 // InLineTextBox. |
| 283 {value: 'value', start: 48, end: 49}, |
| 284 {value: 'name', start: 50, end: 50} |
| 285 ]}, o.toSpannableForTest()); |
| 286 |
| 287 el = root.firstChild.children[2].firstChild; |
| 288 var range = cursors.Range.fromNode(el); |
| 289 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 290 assertEqualsJSON( |
| 291 {string_: '|Tree|with 3 items|Tree item|Collapsed| 3 of 3 | level 1 |c|'
, |
| 292 spans_: [ |
| 293 // Enter rule. |
| 294 |
| 295 // TreeItem. |
| 296 {value: 'role','start': 19, end: 28}, |
| 297 {value: 'state', start: 29, end: 38}, |
| 298 |
| 299 // InLineTextBox. |
| 300 {value: 'value', start: 58, end: 59}, |
| 301 {value: 'name', start: 60, end: 60} |
| 302 ]}, o.toSpannableForTest()); |
| 303 }); |
| 304 }); |
| 305 |
| 306 TEST_F('OutputE2ETest', 'Menu', function() { |
| 307 this.runWithLoadedTree(function() {/*! |
| 308 <div role="menu"> |
| 309 <div role="menuitem">a</div> |
| 310 </div> |
| 311 */}, |
| 312 function(root) { |
| 313 var el = root.firstChild.firstChild; |
| 314 var range = cursors.Range.fromNode(el); |
| 315 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 316 assertEqualsJSON({string_: |
| 317 '|Menu|with 1 items|a, menu item| 1 of 1 ', spans_: [ |
| 318 {value: 'name', start: 0, end: 0}, |
| 319 {value: 'role', start:1, end: 5} |
| 320 ]}, o.toSpannableForTest()); |
| 321 }); |
| 322 }); |
| 323 |
| 324 TEST_F('OutputE2ETest', 'ListBox', function() { |
| 325 this.runWithLoadedTree(function() {/*! |
| 326 <select multiple> |
| 327 <option>1</option> |
| 328 <option>2</option> |
| 329 </select> |
| 330 */}, |
| 331 function(root) { |
| 332 var el = root.firstChild.firstChild.firstChild; |
| 333 var range = cursors.Range.fromNode(el); |
| 334 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 335 assertEqualsJSON({string_: '|List box|with 2 items||List item| 1 of 2 ', |
| 336 spans_: [ |
| 337 // ListBox. |
| 338 // Earcon. |
| 339 {value: {}, start: 1, end: 9}, |
| 340 |
| 341 {value: 'name', start: 23, end: 23}, |
| 342 {value: 'role', start:24, end: 33}, |
| 343 // Earcon. |
| 344 {value: {}, start: 24, end: 33} |
| 345 ]}, o.toSpannableForTest()); |
| 346 }); |
| 347 }); |
OLD | NEW |