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(['../testing/chromevox_unittest_base.js']);
11 * @extends {ChromeVoxUnitTestBase}
13 function CvoxMathShifterUnitTest() {}
15 CvoxMathShifterUnitTest.prototype = {
16 __proto__: ChromeVoxUnitTestBase.prototype,
19 'cvox.ChromeVoxTester',
20 'cvox.CursorSelection',
21 'cvox.DescriptionUtil',
22 'cvox.MathmlStoreRules'
27 cvox.ChromeVoxTester.setUp(document);
31 tearDown: function() {
32 cvox.ChromeVoxTester.tearDown(document);
36 * Simulates speaking the node (only text, no annotations!).
37 * @param {Node} node The node to be described.
38 * @return {!string} The resulting string.
40 getNodeDescription: function(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(' ');
50 TEST_F('CvoxMathShifterUnitTest', 'MathmlMtext', function() {
52 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m0">' +
53 '<mtext>Quod erat demonstrandum</mtext>' +
57 assertEquals('Quod erat demonstrandum', this.getNodeDescription(node));
61 /** Test MathML individual.
64 TEST_F('CvoxMathShifterUnitTest', 'MathmlMi', function() {
66 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m1">' +
70 assertEquals('x', this.getNodeDescription(node));
74 /** Test MathML numeral.
77 TEST_F('CvoxMathShifterUnitTest', 'MathmlMn', function() {
79 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m2">' +
83 assertEquals('123', this.getNodeDescription(node));
87 /** Test MathML operator
90 TEST_F('CvoxMathShifterUnitTest', 'MathmlMo', function() {
92 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m3">' +
96 assertEquals('+', this.getNodeDescription(node));
100 /** Test MathML superscript.
103 TEST_F('CvoxMathShifterUnitTest', 'MathmlMsup', function() {
105 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m4">' +
106 '<msup><mi>x</mi><mn>4</mn></msup>' +
109 assertEquals('x super 4', this.getNodeDescription(node));
113 /** Test MathML subscript.
116 TEST_F('CvoxMathShifterUnitTest', 'MathmlMsub', function() {
118 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m5">' +
119 '<msub><mi>x</mi><mn>3</mn></msub>' +
122 assertEquals('x sub 3', this.getNodeDescription(node));
126 /** Test MathML subsupscript.
129 TEST_F('CvoxMathShifterUnitTest', 'MathmlMsubsup', function() {
131 '<div><math xmlns="http://www.w3.org/1998/Math/MathML" id="m6">' +
132 '<msubsup><mi>x</mi><mn>3</mn><mn>4</mn></msubsup>' +
135 assertEquals('x sub 3 super 4', this.getNodeDescription(node));