OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Include test fixture. |
| 6 GEN_INCLUDE(['walker_unittest_base.js']); |
| 7 |
| 8 /** |
| 9 * Test fixture. |
| 10 * @constructor |
| 11 * @extends {CvoxWalkerTestBase} |
| 12 */ |
| 13 function CvoxSentenceWalkerUnitTest() {} |
| 14 |
| 15 CvoxSentenceWalkerUnitTest.prototype = { |
| 16 __proto__: CvoxWalkerUnitTestBase.prototype, |
| 17 |
| 18 /** @override */ |
| 19 closureModuleDeps: CvoxWalkerUnitTestBase.prototype.closureModuleDeps.concat( |
| 20 'cvox.SentenceWalker'), |
| 21 |
| 22 /** @override */ |
| 23 newWalker: function() { |
| 24 return new cvox.SentenceWalker(); |
| 25 }, |
| 26 |
| 27 /** |
| 28 * Set up simple html. |
| 29 * @private |
| 30 */ |
| 31 setUpSimpleHtml_: function() { |
| 32 this.loadDoc(function() {/*! |
| 33 <div id="a"><p id="b">The quick</p><p id="c">brown. fox.</p></div> |
| 34 */}); |
| 35 } |
| 36 }; |
| 37 |
| 38 CvoxWalkerUnitTestBase.addCommonTests('CvoxSentenceWalkerUnitTest'); |
| 39 |
| 40 TEST_F('CvoxSentenceWalkerUnitTest', 'testSimpleForwardSync', function() { |
| 41 this.setUpSimpleHtml_(); |
| 42 |
| 43 var sel = cvox.CursorSelection.fromNode($('a')); |
| 44 var ret = this.go(sel, 'sync', { |
| 45 selText: 'The quick', |
| 46 selParentNodeId: 'b', |
| 47 selStartIndex: 0, |
| 48 selEndIndex: 9, |
| 49 selReversed: false |
| 50 }); |
| 51 |
| 52 // valid selection |
| 53 var ret2 = this.walker.sync(ret); |
| 54 assertTrue(ret2.equals(ret)); |
| 55 }); |
| 56 |
| 57 TEST_F('CvoxSentenceWalkerUnitTest', 'testSimpleReversedSync', function() { |
| 58 this.setUpSimpleHtml_(); |
| 59 |
| 60 var sel = cvox.CursorSelection.fromNode($('a')); |
| 61 sel.setReversed(true); |
| 62 var ret = this.go(sel, 'sync', { |
| 63 selText: 'brown. fox.', |
| 64 selParentNodeId: 'c', |
| 65 selStartIndex: 0, |
| 66 selEndIndex: 6, |
| 67 selReversed: true |
| 68 }); |
| 69 |
| 70 // valid selection |
| 71 var ret2 = this.walker.sync(ret); |
| 72 assertTrue(ret2.equals(ret)); |
| 73 }); |
| 74 |
| 75 TEST_F('CvoxSentenceWalkerUnitTest', 'testSimpleForwardNext', function() { |
| 76 this.setUpSimpleHtml_(); |
| 77 |
| 78 var sel = cvox.CursorSelection.fromNode($('a')); |
| 79 sel = this.walker.sync(sel); |
| 80 var ret = this.go(sel, 'next', { |
| 81 selText: 'brown. fox.', |
| 82 selParentNodeId: 'c', |
| 83 selStartIndex: 0, |
| 84 selEndIndex: 6, |
| 85 selReversed: false |
| 86 }); |
| 87 }); |
| 88 |
| 89 TEST_F('CvoxSentenceWalkerUnitTest', 'testSimpleReversedNext', function() { |
| 90 this.setUpSimpleHtml_(); |
| 91 |
| 92 var sel = cvox.CursorSelection.fromNode($('a')); |
| 93 sel = this.walker.sync(sel.setReversed(true)); |
| 94 var ret = this.go(sel, 'next', { |
| 95 selText: 'The quick', |
| 96 selParentNodeId: 'b', |
| 97 selStartIndex: 0, |
| 98 selEndIndex: 9, |
| 99 selReversed: true |
| 100 }); |
| 101 ret = this.go(ret, 'next', null); |
| 102 }); |
| 103 |
| 104 TEST_F('CvoxSentenceWalkerUnitTest', 'testControlElements', function() { |
| 105 this.loadDoc(function() {/*! |
| 106 <div id="a"><p>Before</p><input type="text"/><p>After</p></div> |
| 107 */}); |
| 108 var node = $('a'); |
| 109 var sel = this.walker.sync(cvox.CursorSelection.fromNode(node)); |
| 110 var ret = this.go(sel, 'next', {descAnnotation: 'Edit text'}); |
| 111 }); |
OLD | NEW |