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 // 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 .call(off) | 460 .call(off) |
461 .call(focusThen.bind(this, rootNode.find({ role: 'link' }), on)) | 461 .call(focusThen.bind(this, rootNode.find({ role: 'link' }), on)) |
462 .call(focusThen.bind(this, rootNode.find({ role: 'textField' }))) | 462 .call(focusThen.bind(this, rootNode.find({ role: 'textField' }))) |
463 .expectNextSpeechUtteranceIsNot('a') | 463 .expectNextSpeechUtteranceIsNot('a') |
464 .expectSpeech('Edit text'); | 464 .expectSpeech('Edit text'); |
465 | 465 |
466 mockFeedback.replay(); | 466 mockFeedback.replay(); |
467 } | 467 } |
468 ); | 468 ); |
469 }); | 469 }); |
| 470 |
| 471 TEST_F('BackgroundTest', 'ModeSwitching', function() { |
| 472 this.runWithLoadedTree('<button></button>', function(root) { |
| 473 // Tests default to force next mode. |
| 474 assertEquals('force_next', global.backgroundObj.mode); |
| 475 |
| 476 // Force next mode stays set regardless of where the range lands. |
| 477 global.backgroundObj.refreshMode('http://google.com'); |
| 478 assertEquals('force_next', global.backgroundObj.mode); |
| 479 // Empty urls occur before document load or when root is desktop. |
| 480 global.backgroundObj.refreshMode(''); |
| 481 assertEquals('force_next', global.backgroundObj.mode); |
| 482 |
| 483 // Verify compat -> classic switching. |
| 484 global.backgroundObj.setMode('compat'); |
| 485 global.backgroundObj.refreshMode('http://google.com'); |
| 486 assertEquals('classic', global.backgroundObj.mode); |
| 487 |
| 488 // Ensure we switch to compat if our current range has focused |
| 489 // state set and is not in web content. |
| 490 assertTrue(root.parent.state.focused); |
| 491 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root.parent)); |
| 492 global.backgroundObj.refreshMode(''); |
| 493 assertEquals('compat', global.backgroundObj.mode); |
| 494 |
| 495 // And back to classic. |
| 496 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root)); |
| 497 global.backgroundObj.refreshMode(''); |
| 498 assertEquals('classic', global.backgroundObj.mode); |
| 499 |
| 500 // Now, try refreshing mode (which we call after tab switching) with a range |
| 501 // that's not actually focused. |
| 502 assertEquals(undefined, root.parent.parent.state.focused); |
| 503 global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root.parent.pare
nt)); |
| 504 global.backgroundObj.refreshMode(''); |
| 505 assertEquals('classic', global.backgroundObj.mode); |
| 506 }.bind(this)); |
| 507 }); |
OLD | NEW |