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 CvoxCharacterWalkerUnitTest() {}
15 CvoxCharacterWalkerUnitTest.prototype = {
16 __proto__: CvoxWalkerUnitTestBase.prototype,
19 closureModuleDeps: CvoxWalkerUnitTestBase.prototype.closureModuleDeps.concat(
20 'cvox.CharacterWalker'),
23 newWalker: function() {
24 return new cvox.CharacterWalker();
28 * Set up for simple tests so we don't have to repeat.
31 setUpSimpleHtml_: function() {
32 this.loadDoc(function() {/*!
33 <div id="a"><p id="b">Th</p><p id="c">e quick</p></div>
38 CvoxWalkerUnitTestBase.addCommonTests('CvoxCharacterWalkerUnitTest');
40 TEST_F('CvoxCharacterWalkerUnitTest', 'SimpleForwardSync', function() {
41 this.setUpSimpleHtml_();
44 var sel = cvox.CursorSelection.fromNode($('a'));
45 var ret = this.go(sel, 'sync', {
54 var ret2 = this.walker.sync(ret);
55 assertTrue(ret2.equals(ret));
58 TEST_F('CvoxCharacterWalkerUnitTest', 'testSimpleReversedSync', function() {
59 this.setUpSimpleHtml_();
62 var sel = cvox.CursorSelection.fromNode($('a'));
63 sel.setReversed(true);
64 var ret = this.go(sel, 'sync', {
73 var ret2 = this.walker.sync(ret);
74 assertTrue(ret2.equals(ret));
77 TEST_F('CvoxCharacterWalkerUnitTest', 'testSimpleForwardNext', function() {
78 this.setUpSimpleHtml_();
80 var sel = cvox.CursorSelection.fromNode($('a'));
81 sel = this.walker.sync(sel);
82 var ret = this.go(sel, 'next', {
91 TEST_F('CvoxCharacterWalkerUnitTest', 'testSimpleReversedNext', function() {
92 this.setUpSimpleHtml_();
94 var sel = cvox.CursorSelection.fromNode($('a'));
95 sel = this.walker.sync(sel.setReversed(true));
96 var ret = this.go(sel, 'next', {
106 * Tests for how spaces should be navigated character by character.
108 TEST_F('CvoxCharacterWalkerUnitTest', 'testSpaces', function() {
109 this.loadDoc(function() {/*!
110 <div id="foo">a <i>b</i> c<input type="text" value="asdf"/></div>
113 var sel = cvox.CursorSelection.fromNode(node);
114 var ret = this.go(sel, 'next', {descText: 'a'});
115 ret = this.go(ret, 'next', {descText: ' '});
116 ret = this.go(ret, 'next', {descText: 'b'});