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.
5 // Include test fixture.
6 GEN_INCLUDE(['walker_unittest_base.js']);
11 * @extends {CvoxWalkerTestBase}
13 function CvoxObjectWalkerUnitTest() {}
15 CvoxObjectWalkerUnitTest.prototype = {
16 __proto__: CvoxWalkerUnitTestBase.prototype,
19 closureModuleDeps: CvoxWalkerUnitTestBase.prototype.closureModuleDeps.concat(
23 newWalker: function() {
24 return new cvox.ObjectWalker();
28 * Set up for simple html tests.
31 setUpSimpleHtml_: function() {
32 this.loadDoc(function() {/*!
41 CvoxWalkerUnitTestBase.addCommonTests('CvoxObjectWalkerUnitTest');
43 TEST_F('CvoxObjectWalkerUnitTest', 'testSimpleForwardSync', function() {
44 this.setUpSimpleHtml_();
47 var sel = cvox.CursorSelection.fromNode($('a'));
48 var ret = this.go(sel, 'sync', {selParentNodeId: 'b', selReversed: false});
51 var ret2 = this.walker.sync(ret);
52 assertTrue(ret2.equals(ret));
55 TEST_F('CvoxObjectWalkerUnitTest', 'testSimpleReversedSync', function() {
56 this.setUpSimpleHtml_();
59 var sel = cvox.CursorSelection.fromNode($('a'));
60 sel.setReversed(true);
61 var ret = this.go(sel, 'sync', {selParentNodeId: 'c', selReversed: true});
64 var ret2 = this.walker.sync(ret);
65 assertTrue(ret2.equals(ret));
68 TEST_F('CvoxObjectWalkerUnitTest', 'testSimpleForwardNext', function() {
69 this.setUpSimpleHtml_();
71 var sel = cvox.CursorSelection.fromNode($('a'));
72 sel = this.walker.sync(sel);
73 var ret = this.go(sel, 'next', {selParentNodeId: 'c', selReversed: false});
76 TEST_F('CvoxObjectWalkerUnitTest', 'testSimpleReversedNext', function() {
77 this.setUpSimpleHtml_();
79 var sel = cvox.CursorSelection.fromNode($('a'));
80 sel = this.walker.sync(sel.setReversed(true));
81 var ret = this.go(sel, 'next', {selParentNodeId: 'b', selReversed: true});
84 /** tests for unbroken anchor link descriptions. */
85 TEST_F('CvoxObjectWalkerUnitTest', 'testAnchorLinkDescriptions', function() {
86 this.loadDoc(function() {/*!
87 <a href='a1.html' id='a1'>
88 This link <em>has</em> a few <strong>complications.</strong>
92 var sel = this.walker.sync(
93 cvox.CursorSelection.fromNode($('a1')));
94 assertEquals('A', sel.start.node.tagName);
95 assertEquals('This link has a few complications.',
96 this.walker.getDescription(sel, sel)[0].text);