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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/walkers/character_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 CvoxCharacterWalkerUnitTest() {}
14
15 CvoxCharacterWalkerUnitTest.prototype = {
16 __proto__: CvoxWalkerUnitTestBase.prototype,
17
18 /** @override */
19 closureModuleDeps: CvoxWalkerUnitTestBase.prototype.closureModuleDeps.concat(
20 'cvox.CharacterWalker'),
21
22 /** @override */
23 newWalker: function() {
24 return new cvox.CharacterWalker();
25 },
26
27 /**
28 * Set up for simple tests so we don't have to repeat.
29 * @private
30 */
31 setUpSimpleHtml_: function() {
32 this.loadDoc(function() {/*!
33 <div id="a"><p id="b">Th</p><p id="c">e quick</p></div>
34 */});
35 }
36 };
37
38 CvoxWalkerUnitTestBase.addCommonTests('CvoxCharacterWalkerUnitTest');
39
40 TEST_F('CvoxCharacterWalkerUnitTest', 'SimpleForwardSync', function() {
41 this.setUpSimpleHtml_();
42
43 // invalid selection
44 var sel = cvox.CursorSelection.fromNode($('a'));
45 var ret = this.go(sel, 'sync', {
46 selText: 'Th',
47 selParentNodeId: 'b',
48 selStartIndex: 0,
49 selEndIndex: 1,
50 selReversed: false
51 });
52
53 // valid selection
54 var ret2 = this.walker.sync(ret);
55 assertTrue(ret2.equals(ret));
56 });
57
58 TEST_F('CvoxCharacterWalkerUnitTest', 'testSimpleReversedSync', function() {
59 this.setUpSimpleHtml_();
60
61 // invalid selection
62 var sel = cvox.CursorSelection.fromNode($('a'));
63 sel.setReversed(true);
64 var ret = this.go(sel, 'sync', {
65 selText: 'e quick',
66 selParentNodeId: 'c',
67 selStartIndex: 0,
68 selEndIndex: 1,
69 selReversed: true
70 });
71
72 // valid selection
73 var ret2 = this.walker.sync(ret);
74 assertTrue(ret2.equals(ret));
75 });
76
77 TEST_F('CvoxCharacterWalkerUnitTest', 'testSimpleForwardNext', function() {
78 this.setUpSimpleHtml_();
79
80 var sel = cvox.CursorSelection.fromNode($('a'));
81 sel = this.walker.sync(sel);
82 var ret = this.go(sel, 'next', {
83 selText: 'Th',
84 selParentNodeId: 'b',
85 selStartIndex: 1,
86 selEndIndex: 2,
87 selReversed: false
88 });
89 });
90
91 /**
92 * @override
dmazzoni 2014/09/12 15:53:27 nit: did you mean to have @override here?
93 */
94 TEST_F('CvoxCharacterWalkerUnitTest', 'testSimpleReversedNext', function() {
95 this.setUpSimpleHtml_();
96
97 var sel = cvox.CursorSelection.fromNode($('a'));
98 sel = this.walker.sync(sel.setReversed(true));
99 var ret = this.go(sel, 'next', {
100 selText: 'Th',
101 selParentNodeId: 'b',
102 selStartIndex: 1,
103 selEndIndex: 2,
104 selReversed: true
105 });
106 });
107
108 /**
109 * Tests for how spaces should be navigated character by character.
110 */
111 TEST_F('CvoxCharacterWalkerUnitTest', 'testSpaces', function() {
112 this.loadDoc(function() {/*!
113 <div id="foo">a <i>b</i> c<input type="text" value="asdf"/></div>
114 */});
115 var node = $('foo');
116 var sel = cvox.CursorSelection.fromNode(node);
117 var ret = this.go(sel, 'next', {descText: 'a'});
118 ret = this.go(ret, 'next', {descText: ' '});
119 ret = this.go(ret, 'next', {descText: 'b'});
120 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698