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(['../testing/chromevox_unittest_base.js']); | |
7 | |
8 /** | |
9 * Test fixture. | |
10 * @constructor | |
11 * @extends {ChromeVoxUnitTestBase} | |
12 */ | |
13 function CvoxFindUtilUnitTest() {} | |
14 | |
15 CvoxFindUtilUnitTest.prototype = { | |
16 __proto__: ChromeVoxUnitTestBase.prototype, | |
17 | |
18 /** @override */ | |
19 closureModuleDeps: [ | |
20 'cvox.FindUtil', | |
21 ] | |
22 }; | |
23 | |
24 TEST_F('CvoxFindUtilUnitTest', 'Links', function() { | |
25 this.loadDoc(function() {/*! | |
26 <div> | |
27 <p id="before">Before</p> | |
28 <h2>Chapter 1</h2> | |
29 <h2>Chapter 2</h2> | |
30 <a href="#c3" id="c3" name="chapter_3"></a> | |
31 <h2 id="c3_2">Chapter 3</h2> | |
32 <h2 id="c4">Chapter 4</h2> | |
33 <h2>Chapter 5</h2> | |
34 <h2>Chapter 6</h2> | |
35 <a href='#c7' id="c7" name="chapter_7"><h2 id="c7_2">Chapter 7</h2></a> | |
36 <h2 id="c8">Chapter 8</h2> | |
37 <p id="after">After</p> | |
38 </div> | |
39 */}); | |
40 | |
41 var sel = cvox.CursorSelection.fromNode($('before')); | |
42 | |
43 var ret = cvox.FindUtil.findNext(sel, cvox.DomPredicates.linkPredicate); | |
44 assertEquals('c3', ret.start.node.id); | |
45 ret = cvox.FindUtil.findNext(ret, cvox.DomPredicates.linkPredicate); | |
46 assertEquals('c7', ret.start.node.id); | |
47 | |
48 ret.setReversed(true); | |
49 ret = cvox.FindUtil.findNext(ret, cvox.DomPredicates.linkPredicate); | |
50 assertEquals('c3', ret.start.node.id); | |
51 }); | |
OLD | NEW |