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

Unified Diff: chrome/browser/resources/chromeos/chromevox/walkers/group_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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/walkers/group_walker_test.unitjs
diff --git a/chrome/browser/resources/chromeos/chromevox/walkers/group_walker_test.unitjs b/chrome/browser/resources/chromeos/chromevox/walkers/group_walker_test.unitjs
new file mode 100644
index 0000000000000000000000000000000000000000..d035f89e8c916d37b650dc1534b30f7e5834e439
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/walkers/group_walker_test.unitjs
@@ -0,0 +1,89 @@
+// 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 CvoxGroupWalkerUnitTest() {}
+
+CvoxGroupWalkerUnitTest.prototype = {
+ __proto__: CvoxWalkerUnitTestBase.prototype,
+
+ /** @override */
+ closureModuleDeps: CvoxWalkerUnitTestBase.prototype.closureModuleDeps.concat(
+ 'cvox.GroupWalker'),
+
+ /** @override */
+ newWalker: function() {
+ return new cvox.GroupWalker();
+ },
+
+ /**
+ * Set up for simple html tests.
+ * @private
+ */
+ setUpSimpleHtml_: function() {
+ this.loadDoc(function() {/*!
+ <div id="asdf">
+ <p id="a">a</p>
+ <ul id="b">
+ <li>cat</li>
+ <li>in</li>
+ <li>hat</li>
+ </ul>
+ <p id="c">c</p>
+ </div>
+ */});
+ }
+};
+
+CvoxWalkerUnitTestBase.addCommonTests('CvoxGroupWalkerUnitTest');
+
+TEST_F('CvoxGroupWalkerUnitTest', 'testSimpleForwardSync', function() {
+ this.setUpSimpleHtml_();
+
+ // invalid selection
+ var sel = cvox.CursorSelection.fromNode($('asdf'));
+ var ret = this.go(sel, 'sync', {selNodeId: 'a', selReversed: false});
+
+ // valid selection
+ var ret2 = this.walker.sync(ret);
+ assertTrue(ret2.equals(ret));
+});
+
+TEST_F('CvoxGroupWalkerUnitTest', 'testSimpleReversedSync', function() {
+ this.setUpSimpleHtml_();
+
+ // invalid selection
+ var sel = cvox.CursorSelection.fromNode($('asdf'));
+ sel.setReversed(true);
+ var ret = this.go(sel, 'sync', {selNodeId: 'c', selReversed: true});
+
+ // valid selection
+ var ret2 = this.walker.sync(ret);
+ assertTrue(ret2.equals(ret));
+});
+
+TEST_F('CvoxGroupWalkerUnitTest', 'testSimpleForwardNext', function() {
+ this.setUpSimpleHtml_();
+
+ // invalid selection
+ var sel = cvox.CursorSelection.fromNode($('asdf'));
+ sel = this.walker.sync(sel);
+ var ret = this.go(sel, 'next', {selNodeId: 'b', selReversed: false});
+});
+
+TEST_F('CvoxGroupWalkerUnitTest', 'testSimpleReversedNext', function() {
+ this.setUpSimpleHtml_();
+
+ // invalid selection
+ var sel = cvox.CursorSelection.fromNode($('asdf'));
+ sel = this.walker.sync(sel.setReversed(true));
+ var ret = this.go(sel, 'next', {selNodeId: 'b', selReversed: true});
+});

Powered by Google App Engine
This is Rietveld 408576698