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