| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 test fixture. | 5 // Include test fixture. |
| 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', |
| 7 '../../testing/assert_additions.js']); | 7 '../../testing/assert_additions.js']); |
| 8 | 8 |
| 9 GEN_INCLUDE(['../../testing/mock_feedback.js']); | 9 GEN_INCLUDE(['../../testing/mock_feedback.js']); |
| 10 | 10 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (line == 0) | 235 if (line == 0) |
| 236 dir = 'forward'; | 236 dir = 'forward'; |
| 237 if (line == 2) | 237 if (line == 2) |
| 238 dir = 'backward'; | 238 dir = 'backward'; |
| 239 }, true); | 239 }, true); |
| 240 </script> | 240 </script> |
| 241 */}, function(root) { | 241 */}, function(root) { |
| 242 var input = root.find({role: RoleType.TEXT_FIELD}); | 242 var input = root.find({role: RoleType.TEXT_FIELD}); |
| 243 var moveByLine = input.doDefault.bind(input); | 243 var moveByLine = input.doDefault.bind(input); |
| 244 mockFeedback.call(input.focus.bind(input)) | 244 mockFeedback.call(input.focus.bind(input)) |
| 245 .expectSpeech('Text area') |
| 245 .call(moveByLine) | 246 .call(moveByLine) |
| 246 .expectSpeech('blank') | 247 .expectSpeech('blank') |
| 247 .expectBraille('') | 248 .expectBraille('') |
| 248 .call(moveByLine) | 249 .call(moveByLine) |
| 249 .expectSpeech('This is a ', 'test', 'Link', ' of rich text') | 250 .expectSpeech('This is a ', 'test', 'Link', ' of rich text') |
| 250 .expectBraille('This is a test lnk of rich text') | 251 .expectBraille('This is a test lnk of rich text') |
| 251 .call(moveByLine) | 252 .call(moveByLine) |
| 252 .expectSpeech('blank') | 253 .expectSpeech('blank') |
| 253 .expectBraille('') | 254 .expectBraille('') |
| 254 .call(moveByLine) | 255 .call(moveByLine) |
| 255 .expectSpeech('hello', 'Heading 2') | 256 .expectSpeech('hello', 'Heading 2') |
| 256 .expectBraille('hello h2') | 257 .expectBraille('hello h2 \n') |
| 257 .replay(); | 258 .replay(); |
| 258 }); | 259 }); |
| 259 }); | 260 }); |
| 261 |
| 262 TEST_F('EditingTest', 'RichTextMoveByCharacter', function() { |
| 263 editing.useRichText = true; |
| 264 var mockFeedback = this.createMockFeedback(); |
| 265 this.runWithLoadedTree(function() {/*! |
| 266 <div id="go" role="textbox" contenteditable>This <b>is</b> a test.</div> |
| 267 |
| 268 <script> |
| 269 var dir = 'forward'; |
| 270 var char = 0; |
| 271 document.getElementById('go').addEventListener('click', function() { |
| 272 var sel = getSelection(); |
| 273 sel.modify('move', dir, 'character'); |
| 274 if (dir == 'forward') |
| 275 char++; |
| 276 else |
| 277 char--; |
| 278 |
| 279 if (char == 0) |
| 280 dir = 'forward'; |
| 281 if (line == 16) |
| 282 dir = 'backward'; |
| 283 }, true); |
| 284 </script> |
| 285 */}, function(root) { |
| 286 // Note that the braille output below is wrong. It depends on Chrome |
| 287 // providing apis for getting the current visual line. |
| 288 |
| 289 var input = root.find({role: RoleType.TEXT_FIELD}); |
| 290 var moveByChar = input.doDefault.bind(input); |
| 291 mockFeedback.call(input.focus.bind(input)) |
| 292 .expectSpeech('Text area') |
| 293 .call(moveByChar) |
| 294 .expectSpeech('h') |
| 295 .expectBraille('This ', { startIndex: 1, endIndex: 1 }) |
| 296 .call(moveByChar) |
| 297 .expectSpeech('i') |
| 298 .expectBraille('This ', { startIndex: 2, endIndex: 2 }) |
| 299 .call(moveByChar) |
| 300 .expectSpeech('s') |
| 301 .expectBraille('This ', { startIndex: 3, endIndex: 3 }) |
| 302 .call(moveByChar) |
| 303 .expectSpeech(' ') |
| 304 .expectBraille('This ', { startIndex: 4, endIndex: 4 }) |
| 305 |
| 306 .call(moveByChar) |
| 307 .expectSpeech('i') |
| 308 .expectBraille(' ', { startIndex: 0, endIndex: 0 }) |
| 309 |
| 310 .call(moveByChar) |
| 311 .expectSpeech('s') |
| 312 .expectBraille('is', { startIndex: 1, endIndex: 1 }) |
| 313 |
| 314 // This is a move from one static text to another. It is not clear what |
| 315 // needs to be read here, so currently, it is left silent. The new node |
| 316 // initializes the plain text state machine. |
| 317 .call(moveByChar) |
| 318 |
| 319 .call(moveByChar) |
| 320 .expectSpeech('a') |
| 321 .expectBraille(' a test.', { startIndex: 1, endIndex: 1 }) |
| 322 |
| 323 .call(moveByChar) |
| 324 .expectSpeech(' ') |
| 325 .expectBraille(' a test.', { startIndex: 2, endIndex: 2 }) |
| 326 |
| 327 .replay(); |
| 328 }); |
| 329 }); |
| OLD | NEW |