blob: f2e9e3dceea0075c0fc0f7a177994fa63ff230fe [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Include test fixture.
GEN_INCLUDE(['walker_unittest_base.js']);
/**
* Test fixture.
* @constructor
* @extends {CvoxWalkerTestBase}
*/
function CvoxTableWalkerUnitTest() {}
CvoxTableWalkerUnitTest.prototype = {
__proto__: CvoxWalkerUnitTestBase.prototype,
/** @override */
closureModuleDeps: CvoxWalkerUnitTestBase.prototype.closureModuleDeps.concat(
'cvox.TableWalker'),
/** @override */
newWalker: function() {
return new cvox.TableWalker();
}
};
// NOTE: The common walker tests don't work for the table walker, so they are
// not added here.
/**
* Simple tests for TableWalker
*/
TEST_F('CvoxTableWalkerUnitTest', 'testSimpleTableWalker', function() {
this.loadDoc(function() {/*!
<p id="before">Before</p>
<table id="table">
<tr><td>A</td><td>1</td></tr>
<tr><td>B</td><td>2</td></tr>
</table>
*/});
var node = document.getElementById('table');
var sel = cvox.CursorSelection.fromNode(node);
var ret = this.go(sel, 'sync', {descText: 'A'});
});
/**
* Test navigating rows.
*/
TEST_F('CvoxTableWalkerUnitTest', 'testNavigateRows', function() {
this.loadDoc(function() {/*!
<table id="table">
<tr><td>A</td><td>1</td></tr>
<tr><td>B</td><td>2</td></tr>
</table>
*/});
var node = document.getElementById('table');
var sel = cvox.CursorSelection.fromNode(node);
var ret = this.go(sel, 'sync', {descText: 'A'});
ret = this.go(ret, 'nextRow', {descText: 'B'});
this.go(ret, 'nextRow', null);
ret.setReversed(true);
ret = this.go(ret, 'nextRow', {descText: 'A'});
this.go(ret, 'nextRow', null);
});
/**
* Test navigating columns.
*/
TEST_F('CvoxTableWalkerUnitTest', 'testNavigateCols', function() {
this.loadDoc(function() {/*!
<table id="table">
<tr><td>A</td><td>1</td></tr>
<tr><td>B</td><td>2</td></tr>
</table>
*/});
var node = document.getElementById('table');
var sel = cvox.CursorSelection.fromNode(node);
var ret = this.go(sel, 'sync', {descText: 'A'});
ret = this.go(ret, 'nextCol', {descText: '1'});
this.go(ret, 'nextCol', null);
ret.setReversed(true);
ret = this.go(ret, 'nextCol', {descText: 'A'});
this.go(ret, 'nextCol', null);
});