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 CvoxGroupWalkerUnitTest() {} |
| 14 |
| 15 CvoxGroupWalkerUnitTest.prototype = { |
| 16 __proto__: CvoxWalkerUnitTestBase.prototype, |
| 17 |
| 18 /** @override */ |
| 19 closureModuleDeps: CvoxWalkerUnitTestBase.prototype.closureModuleDeps.concat( |
| 20 'cvox.GroupWalker'), |
| 21 |
| 22 /** @override */ |
| 23 newWalker: function() { |
| 24 return new cvox.GroupWalker(); |
| 25 }, |
| 26 |
| 27 /** |
| 28 * Set up for simple html tests. |
| 29 * @private |
| 30 */ |
| 31 setUpSimpleHtml_: function() { |
| 32 this.loadDoc(function() {/*! |
| 33 <div id="asdf"> |
| 34 <p id="a">a</p> |
| 35 <ul id="b"> |
| 36 <li>cat</li> |
| 37 <li>in</li> |
| 38 <li>hat</li> |
| 39 </ul> |
| 40 <p id="c">c</p> |
| 41 </div> |
| 42 */}); |
| 43 } |
| 44 }; |
| 45 |
| 46 CvoxWalkerUnitTestBase.addCommonTests('CvoxGroupWalkerUnitTest'); |
| 47 |
| 48 TEST_F('CvoxGroupWalkerUnitTest', 'testSimpleForwardSync', function() { |
| 49 this.setUpSimpleHtml_(); |
| 50 |
| 51 // invalid selection |
| 52 var sel = cvox.CursorSelection.fromNode($('asdf')); |
| 53 var ret = this.go(sel, 'sync', {selNodeId: 'a', selReversed: false}); |
| 54 |
| 55 // valid selection |
| 56 var ret2 = this.walker.sync(ret); |
| 57 assertTrue(ret2.equals(ret)); |
| 58 }); |
| 59 |
| 60 TEST_F('CvoxGroupWalkerUnitTest', 'testSimpleReversedSync', function() { |
| 61 this.setUpSimpleHtml_(); |
| 62 |
| 63 // invalid selection |
| 64 var sel = cvox.CursorSelection.fromNode($('asdf')); |
| 65 sel.setReversed(true); |
| 66 var ret = this.go(sel, 'sync', {selNodeId: 'c', selReversed: true}); |
| 67 |
| 68 // valid selection |
| 69 var ret2 = this.walker.sync(ret); |
| 70 assertTrue(ret2.equals(ret)); |
| 71 }); |
| 72 |
| 73 TEST_F('CvoxGroupWalkerUnitTest', 'testSimpleForwardNext', function() { |
| 74 this.setUpSimpleHtml_(); |
| 75 |
| 76 // invalid selection |
| 77 var sel = cvox.CursorSelection.fromNode($('asdf')); |
| 78 sel = this.walker.sync(sel); |
| 79 var ret = this.go(sel, 'next', {selNodeId: 'b', selReversed: false}); |
| 80 }); |
| 81 |
| 82 TEST_F('CvoxGroupWalkerUnitTest', 'testSimpleReversedNext', function() { |
| 83 this.setUpSimpleHtml_(); |
| 84 |
| 85 // invalid selection |
| 86 var sel = cvox.CursorSelection.fromNode($('asdf')); |
| 87 sel = this.walker.sync(sel.setReversed(true)); |
| 88 var ret = this.go(sel, 'next', {selNodeId: 'b', selReversed: true}); |
| 89 }); |
OLD | NEW |