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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/walkers/math_shifter_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(['../testing/chromevox_unittest_base.js']);
7
8 /**
9 * Test fixture.
10 * @constructor
11 * @extends {ChromeVoxUnitTestBase}
12 */
13 function CvoxMathShifterUnitTest() {}
14
15 CvoxMathShifterUnitTest.prototype = {
16 __proto__: ChromeVoxUnitTestBase.prototype,
17
18 closureModuleDeps: [
19 'cvox.ChromeVoxTester',
20 'cvox.CursorSelection',
21 'cvox.DescriptionUtil',
22 'cvox.MathmlStoreRules'
23 ],
24
25 /** @override */
26 setUp: function() {
27 cvox.ChromeVoxTester.setUp(document);
28 },
29
30 /** @override */
31 tearDown: function() {
32 cvox.ChromeVoxTester.tearDown(document);
33 },
34
35 /**
36 * Simulates speaking the node (only text, no annotations!).
37 * @param {Node} node The node to be described.
38 * @return {!string} The resulting string.
39 */
40 getNodeDescription: function(node) {
41 if (node) {
42 var descs = cvox.DescriptionUtil.getMathDescription(node);
43 var descs_str = descs.map(function(desc) {return desc.text;});
44 return descs_str.filter(function(str) {return str;}).join(' ');
45 }
46 return '';
47 }
48 };
49
50 TEST_F('CvoxMathShifterUnitTest', 'MathmlMtext', function() {
51 console.log('Starting');
dmazzoni 2014/09/12 15:53:27 Let's delete console logging if not necessary
52 this.loadHtml(
53 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m0">' +
54 '<mtext>Quod erat demonstrandum</mtext>' +
55 '</math></div>'
56 );
57 var node = $('m0');
58 assertEquals('Quod erat demonstrandum', this.getNodeDescription(node));
59 });
60
61
62 /** Test MathML individual.
63 * @export
64 */
65 TEST_F('CvoxMathShifterUnitTest', 'MathmlMi', function() {
66 this.loadHtml(
67 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m1">' +
68 '<mi>x</mi>' +
69 '</math></div>');
70 var node = $('m1');
71 assertEquals('x', this.getNodeDescription(node));
72 });
73
74
75 /** Test MathML numeral.
76 * @export
77 */
78 TEST_F('CvoxMathShifterUnitTest', 'MathmlMn', function() {
79 this.loadHtml(
80 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m2">' +
81 '<mn>123</mn>' +
82 '</math></div>');
83 var node = $('m2');
84 assertEquals('123', this.getNodeDescription(node));
85 });
86
87
88 /** Test MathML operator
89 * @export
90 */
91 TEST_F('CvoxMathShifterUnitTest', 'MathmlMo', function() {
92 this.loadHtml(
93 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m3">' +
94 '<mo>+</mo>' +
95 '</math></div>');
96 var node = $('m3');
97 assertEquals('+', this.getNodeDescription(node));
98 });
99
100
101 /** Test MathML superscript.
102 * @export
103 */
104 TEST_F('CvoxMathShifterUnitTest', 'MathmlMsup', function() {
105 this.loadHtml(
106 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m4">' +
107 '<msup><mi>x</mi><mn>4</mn></msup>' +
108 '</math></div>');
109 var node = $('m4');
110 assertEquals('x super 4', this.getNodeDescription(node));
111 });
112
113
114 /** Test MathML subscript.
115 * @export
116 */
117 TEST_F('CvoxMathShifterUnitTest', 'MathmlMsub', function() {
118 this.loadHtml(
119 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m5">' +
120 '<msub><mi>x</mi><mn>3</mn></msub>' +
121 '</math></div>');
122 var node = $('m5');
123 assertEquals('x sub 3', this.getNodeDescription(node));
124 });
125
126
127 /** Test MathML subsupscript.
128 * @export
129 */
130 TEST_F('CvoxMathShifterUnitTest', 'MathmlMsubsup', function() {
131 this.loadHtml(
132 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m6">' +
133 '<msubsup><mi>x</mi><mn>3</mn><mn>4</mn></msubsup>' +
134 '</math></div>');
135 var node = $('m6');
136 assertEquals('x sub 3 super 4', this.getNodeDescription(node));
137 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698