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

Unified Diff: chrome/browser/resources/chromeos/chromevox/walkers/structural_line_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/structural_line_walker_test.unitjs
diff --git a/chrome/browser/resources/chromeos/chromevox/walkers/structural_line_walker_test.unitjs b/chrome/browser/resources/chromeos/chromevox/walkers/structural_line_walker_test.unitjs
new file mode 100644
index 0000000000000000000000000000000000000000..7b8de956e0642d46630c1067f3d94caf304f84d0
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/walkers/structural_line_walker_test.unitjs
@@ -0,0 +1,132 @@
+// 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(['../testing/chromevox_unittest_base.js']);
+
+/**
+ * Test fixture.
+ * @constructor
+ * @extends {ChromeVoxUnitTestBase}
+ */
+function CvoxStructuralLineWalkerUnitTest() {}
+
+CvoxStructuralLineWalkerUnitTest.prototype = {
+ __proto__: ChromeVoxUnitTestBase.prototype,
+
+ /** @override */
+ closureModuleDeps: [
+ 'cvox.BrailleUtil',
+ 'cvox.StructuralLineWalker',
+ 'cvox.TestMsgs',
+ ],
+
+ /** @override */
+ setUp: function() {
+ this.loadDoc(function() {/*!
+ <a id='1' href='google.com'>Click Here</a>
+ <p id='2'>This is some text that will wrap within the browser; when using
+ line granularity, moving through this text will speak and braille every
+ visual line. This text will break
+ immediately here!
+ <a href='google.com'>And here!</a>
+ </p>
+ */});
+
+ cvox.ChromeVox.msgs = new cvox.TestMsgs();
+
+ this.walker_ = new cvox.StructuralLineWalker();
+ },
+};
+
+TEST_F('CvoxStructuralLineWalkerUnitTest', 'BrailleLine', function() {
+ var aLink = $('1');
+ var aLinkSel1 = this.walker_.sync(cvox.CursorSelection.fromNode(aLink));
+ assertEquals('Click Here lnk',
+ this.walker_.getBraille(aLinkSel1, aLinkSel1).text.toString());
+
+ var aPSel1 = this.walker_.next(aLinkSel1);
+ assertEquals('This is some text that will wrap within the browser; when' +
+ ' using line granularity, moving through this text will speak and' +
+ ' braille every visual line. This text will break',
+ this.walker_.getBraille(aLinkSel1, aPSel1).text.toString());
+
+ var aPSel2 = this.walker_.next(aPSel1);
+ assertEquals('immediately here!',
+ this.walker_.getBraille(aPSel1, aPSel2).text.toString());
+
+ aLinkSel2 = this.walker_.next(aPSel2);
+ assertEquals('And here! lnk',
+ this.walker_.getBraille(aPSel2, aLinkSel2).text.toString());
+});
+
+
+/** Tests sync'ing to a line in the middle of a paragraph. */
+TEST_F('CvoxStructuralLineWalkerUnitTest', 'Sync', function() {
+ var p1Sel = this.walker_.sync(
+ cvox.CursorSelection.fromNode($('2')));
+
+ // The second structural line of the paragraph.
+ var p2Sel = this.walker_.next(p1Sel);
+ assertEquals(194, p2Sel.start.index);
+ assertEquals(211, p2Sel.end.index);
+
+ // Sync should never mutate a previously synced selection.
+ assertTrue(p2Sel.equals(this.walker_.sync(p2Sel)));
+});
+
+/** Tests syncing into an element treated as a leaf by TraverseUtil. */
+TEST_F('CvoxStructuralLineWalkerUnitTest', 'SyncTraverseUtil', function() {
+ this.loadDoc(function() {/*!
+ <select id='leaf'>
+ <option>apple
+ <option>orange
+ </select>
+ */});
+ var leaf = $('leaf');
+ assertEquals('leaf',
+ this.walker_.sync(cvox.CursorSelection.fromNode(leaf)).start.node.id);
+});
+
+
+/** Tests specialized name calc with listitems with prefixes. */
+TEST_F('CvoxStructuralLineWalkerUnitTest', 'ListitemPrefixes', function() {
+ this.loadDoc(function() {/*!
+ <ol>
+ <li id='li_orange'>orange
+ <li id='li_apple'>apple
+ <li id='li_long'>=========================================================
+================================================== hi long line here
+ </li>
+ </ol>
+ */});
+ var li1 = $('li_orange');
+ var li2 = $('li_apple');
+ var li3 = $('li_long');
+ var li1Sel = this.walker_.sync(cvox.CursorSelection.fromNode(li1));
+ var li2Sel = this.walker_.sync(cvox.CursorSelection.fromNode(li2));
+ var li3Sel = this.walker_.sync(cvox.CursorSelection.fromNode(li3));
+ var li3SelNext = this.walker_.next(li3Sel);
+
+ assertEquals('1. orange',
+ this.walker_.getDescription(li1Sel, li1Sel)[0].text);
+ assertEquals('2. apple', this.walker_.getDescription(li2Sel, li2Sel)[0].text);
+ assertEquals(
+ '3. ========================================================= =====' +
+ '============================================= hi long',
+ this.walker_.getDescription(li3Sel, li3Sel)[0].text);
+ assertEquals('line here', this.walker_.getDescription(
+ li3SelNext, li3SelNext)[0].text.toString());
+
+ assertEquals('1. orange',
+ this.walker_.getBraille(li1Sel, li1Sel).text.toString());
+ assertEquals('2. apple',
+ this.walker_.getBraille(li2Sel, li2Sel).text.toString());
+ assertEquals(
+ '3. ========================================================= =====' +
+ '============================================= hi long',
+ this.walker_.getBraille(li3Sel, li3Sel).text.toString());
+ assertEquals('line here',
+ this.walker_.getBraille(li3SelNext, li3SelNext).text.toString());
+});

Powered by Google App Engine
This is Rietveld 408576698