Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/walkers/object_walker_test.unitjs

Issue 563773003: Migrate walker tests from upstream ChromeVox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Finish walker tests. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 CvoxObjectWalkerUnitTest() {}
14
15 CvoxObjectWalkerUnitTest.prototype = {
16 __proto__: CvoxWalkerUnitTestBase.prototype,
17
18 /** @override */
19 closureModuleDeps: CvoxWalkerUnitTestBase.prototype.closureModuleDeps.concat(
20 'cvox.ObjectWalker'),
21
22 /** @override */
23 newWalker: function() {
24 return new cvox.ObjectWalker();
25 },
26
27 /**
28 * Set up for simple html tests.
29 * @private
30 */
31 setUpSimpleHtml_: function() {
32 this.loadDoc(function() {/*!
33 <div id="a">
34 <p id="b">b</p>
35 <p id="c">c</p>
36 </div>
37 */});
38 }
39 };
40
41 CvoxWalkerUnitTestBase.addCommonTests('CvoxObjectWalkerUnitTest');
42
43 TEST_F('CvoxObjectWalkerUnitTest', 'testSimpleForwardSync', function() {
44 this.setUpSimpleHtml_();
45
46 // invalid selection
47 var sel = cvox.CursorSelection.fromNode($('a'));
48 var ret = this.go(sel, 'sync', {selParentNodeId: 'b', selReversed: false});
49
50 // valid selection
51 var ret2 = this.walker.sync(ret);
52 assertTrue(ret2.equals(ret));
53 });
54
55 TEST_F('CvoxObjectWalkerUnitTest', 'testSimpleReversedSync', function() {
56 this.setUpSimpleHtml_();
57
58 // invalid selection
59 var sel = cvox.CursorSelection.fromNode($('a'));
60 sel.setReversed(true);
61 var ret = this.go(sel, 'sync', {selParentNodeId: 'c', selReversed: true});
62
63 // valid selection
64 var ret2 = this.walker.sync(ret);
65 assertTrue(ret2.equals(ret));
66 });
67
68 TEST_F('CvoxObjectWalkerUnitTest', 'testSimpleForwardNext', function() {
69 this.setUpSimpleHtml_();
70
71 var sel = cvox.CursorSelection.fromNode($('a'));
72 sel = this.walker.sync(sel);
73 var ret = this.go(sel, 'next', {selParentNodeId: 'c', selReversed: false});
74 });
75
76 TEST_F('CvoxObjectWalkerUnitTest', 'testSimpleReversedNext', function() {
77 this.setUpSimpleHtml_();
78
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});
82 });
83
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>
89 </a>
90 */});
91
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);
97 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698