OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Include test fixture. | 5 // Include test fixture. |
6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); |
7 | 7 |
8 GEN_INCLUDE(['../../testing/mock_tts.js']); | 8 GEN_INCLUDE(['../../testing/mock_feedback.js']); |
9 | 9 |
10 /** | 10 /** |
11 * Test fixture for Background. | 11 * Test fixture for Background. |
12 * @constructor | 12 * @constructor |
13 * @extends {ChromeVoxNextE2ETest} | 13 * @extends {ChromeVoxNextE2ETest} |
14 */ | 14 */ |
15 function BackgroundTest() { | 15 function BackgroundTest() { |
16 ChromeVoxNextE2ETest.call(this); | 16 ChromeVoxNextE2ETest.call(this); |
17 } | 17 } |
18 | 18 |
19 BackgroundTest.prototype = { | 19 BackgroundTest.prototype = { |
20 __proto__: ChromeVoxNextE2ETest.prototype, | 20 __proto__: ChromeVoxNextE2ETest.prototype, |
21 | 21 |
22 /** @override */ | 22 /** |
23 setUp: function() { | 23 * @return {!MockFeedback} |
24 this.mockTts = new MockTts(); | 24 */ |
25 cvox.ChromeVox.tts = this.mockTts; | 25 createMockFeedback: function() { |
| 26 var mockFeedback = new MockFeedback(this.newCallback()); |
| 27 mockFeedback.install(); |
| 28 return mockFeedback; |
26 }, | 29 }, |
27 | 30 |
28 /** | 31 /** |
29 * Create a function which perform the command |cmd|. | 32 * Create a function which perform the command |cmd|. |
30 * @param {string} cmd | 33 * @param {string} cmd |
31 * @return {function() : void} | 34 * @return {function() : void} |
32 */ | 35 */ |
33 doCmd: function(cmd) { | 36 doCmd: function(cmd) { |
34 return function() { | 37 return function() { |
35 global.backgroundObj.onGotCommand(cmd); | 38 global.backgroundObj.onGotCommand(cmd); |
(...skipping 26 matching lines...) Expand all Loading... |
62 SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() { | 65 SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() { |
63 assertEquals('object', typeof(cvox)); | 66 assertEquals('object', typeof(cvox)); |
64 assertEquals('function', typeof(cvox.ChromeVoxBackground)); | 67 assertEquals('function', typeof(cvox.ChromeVoxBackground)); |
65 }); | 68 }); |
66 | 69 |
67 /** Tests that ChromeVox next is in this context. */ | 70 /** Tests that ChromeVox next is in this context. */ |
68 SYNC_TEST_F('BackgroundTest', 'NextNamespaces', function() { | 71 SYNC_TEST_F('BackgroundTest', 'NextNamespaces', function() { |
69 assertEquals('function', typeof(Background)); | 72 assertEquals('function', typeof(Background)); |
70 }); | 73 }); |
71 | 74 |
72 /** Tests feedback once a page loads. */ | |
73 TEST_F('BackgroundTest', 'MANUAL_InitialFeedback', function() { | |
74 cvox.ChromeVox.tts.expectSpeech('start', this.newCallback()); | |
75 | |
76 this.runWithTab(function() {/*! | |
77 <p>start | |
78 <p>end | |
79 */}); | |
80 }); | |
81 | |
82 /** Tests consistency of navigating forward and backward. */ | 75 /** Tests consistency of navigating forward and backward. */ |
83 TEST_F('BackgroundTest', 'MANUAL_ForwardBackwardNavigation', function() { | 76 TEST_F('BackgroundTest', 'MANUAL_ForwardBackwardNavigation', function() { |
84 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { | 77 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { |
85 var doCmd = this.doCmd.bind(this); | 78 var doCmd = this.doCmd.bind(this); |
86 var expectAfter = | 79 var expectAfter = |
87 cvox.ChromeVox.tts.expectSpeechAfter.bind(cvox.ChromeVox.tts); | 80 cvox.ChromeVox.tts.expectSpeechAfter.bind(cvox.ChromeVox.tts); |
88 | 81 |
89 expectAfter('alpha', doCmd('nextLink')); | 82 expectAfter('alpha', doCmd('nextLink')); |
90 expectAfter('beta', doCmd('nextLink')); | 83 expectAfter('beta', doCmd('nextLink')); |
91 expectAfter('delta', doCmd('nextLink')); | 84 expectAfter('delta', doCmd('nextLink')); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 cvox.ChromeVox.tts.expectSpeech('Link'); | 152 cvox.ChromeVox.tts.expectSpeech('Link'); |
160 cvox.ChromeVox.tts.expectSpeech('beta'); | 153 cvox.ChromeVox.tts.expectSpeech('beta'); |
161 cvox.ChromeVox.tts.expectSpeech('Link'); | 154 cvox.ChromeVox.tts.expectSpeech('Link'); |
162 cvox.ChromeVox.tts.expectSpeech('Heading 1'); | 155 cvox.ChromeVox.tts.expectSpeech('Heading 1'); |
163 cvox.ChromeVox.tts.expectSpeech('charlie'); | 156 cvox.ChromeVox.tts.expectSpeech('charlie'); |
164 cvox.ChromeVox.tts.finishExpectations(); | 157 cvox.ChromeVox.tts.finishExpectations(); |
165 }); | 158 }); |
166 }); | 159 }); |
167 | 160 |
168 TEST_F('BackgroundTest', 'LiveRegionAddElement', function() { | 161 TEST_F('BackgroundTest', 'LiveRegionAddElement', function() { |
| 162 var mockFeedback = this.createMockFeedback(); |
169 this.runWithLoadedTree( | 163 this.runWithLoadedTree( |
170 function() {/*! | 164 function() {/*! |
171 <h1>Document with live region</h1> | 165 <h1>Document with live region</h1> |
172 <p id="live" aria-live="polite"></p> | 166 <p id="live" aria-live="polite"></p> |
173 <button id="go">Go</button> | 167 <button id="go">Go</button> |
174 <script> | 168 <script> |
175 document.getElementById('go').addEventListener('click', function() { | 169 document.getElementById('go').addEventListener('click', function() { |
176 document.getElementById('live').innerHTML = 'Hello, world'; | 170 document.getElementById('live').innerHTML = 'Hello, world'; |
177 }, false); | 171 }, false); |
178 </script> | 172 </script> |
179 */}, | 173 */}, |
180 function(rootNode) { | 174 function(rootNode) { |
181 var go = rootNode.find({ role: chrome.automation.RoleType.button }); | 175 var go = rootNode.find({ role: chrome.automation.RoleType.button }); |
182 go.doDefault(); | 176 mockFeedback.call(go.doDefault.bind(go)) |
183 cvox.ChromeVox.tts.expectSpeech('Hello, world'); | 177 .expectSpeech('Hello, world') |
184 cvox.ChromeVox.tts.finishExpectations(this.newCallback()); | 178 .go(); |
185 }); | 179 }); |
186 }); | 180 }); |
187 | 181 |
188 TEST_F('BackgroundTest', 'LiveRegionRemoveElement', function() { | 182 TEST_F('BackgroundTest', 'LiveRegionRemoveElement', function() { |
| 183 var mockFeedback = this.createMockFeedback(); |
189 this.runWithLoadedTree( | 184 this.runWithLoadedTree( |
190 function() {/*! | 185 function() {/*! |
191 <h1>Document with live region</h1> | 186 <h1>Document with live region</h1> |
192 <p id="live" aria-live="polite" aria-relevant="removals">Hello, world</p> | 187 <p id="live" aria-live="polite" aria-relevant="removals">Hello, world</p> |
193 <button id="go">Go</button> | 188 <button id="go">Go</button> |
194 <script> | 189 <script> |
195 document.getElementById('go').addEventListener('click', function() { | 190 document.getElementById('go').addEventListener('click', function() { |
196 document.getElementById('live').innerHTML = ''; | 191 document.getElementById('live').innerHTML = ''; |
197 }, false); | 192 }, false); |
198 </script> | 193 </script> |
199 */}, | 194 */}, |
200 function(rootNode) { | 195 function(rootNode) { |
201 var go = rootNode.find({ role: chrome.automation.RoleType.button }); | 196 var go = rootNode.find({ role: chrome.automation.RoleType.button }); |
202 go.doDefault(); | 197 go.doDefault(); |
203 cvox.ChromeVox.tts.expectSpeech('removed:'); | 198 mockFeedback.expectSpeech('removed:') |
204 cvox.ChromeVox.tts.expectSpeech('Hello, world'); | 199 .expectSpeech('Hello, world') |
205 cvox.ChromeVox.tts.finishExpectations(this.newCallback()); | 200 .go(); |
206 }); | 201 }); |
207 }); | 202 }); |
208 | 203 |
209 // Test fails because no speech is generated when the rootWebArea is | 204 // Test fails because no speech is generated when the rootWebArea is |
210 // focused. | 205 // focused. |
211 // http://crbug.com/520940 | 206 // http://crbug.com/520940 |
212 TEST_F('BackgroundTest', 'DISABLED_InitialFocus', function() { | 207 TEST_F('BackgroundTest', 'DISABLED_InitialFocus', function() { |
| 208 var mockFeedback = this.createMockFeedback(); |
213 this.runWithLoadedTree('<a href="a">a</a>', | 209 this.runWithLoadedTree('<a href="a">a</a>', |
214 function(rootNode) { | 210 function(rootNode) { |
215 cvox.ChromeVox.tts.expectSpeech('a'); | 211 mockFeedback.expectSpeech('a') |
216 cvox.ChromeVox.tts.expectSpeech('Link', this.newCallback()); | 212 .expectSpeech('Link') |
217 | 213 .go(); |
218 rootNode.focus(); | |
219 }); | 214 }); |
220 }); | 215 }); |
221 | 216 |
222 TEST_F('BackgroundTest', 'AriaLabel', function() { | 217 TEST_F('BackgroundTest', 'AriaLabel', function() { |
| 218 var mockFeedback = this.createMockFeedback(); |
223 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', | 219 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', |
224 function(rootNode) { | 220 function(rootNode) { |
225 cvox.ChromeVox.tts.expectSpeech('foo'); | |
226 cvox.ChromeVox.tts.expectSpeech('Link', this.newCallback()); | |
227 rootNode.find({role: 'link'}).focus(); | 221 rootNode.find({role: 'link'}).focus(); |
| 222 mockFeedback.expectSpeech('foo') |
| 223 .expectSpeech('Link') |
| 224 .expectBraille('foo lnk') |
| 225 .go(); |
228 } | 226 } |
229 ); | 227 ); |
230 }); | 228 }); |
231 | 229 |
232 TEST_F('BackgroundTest', 'ShowContextMenu', function() { | 230 TEST_F('BackgroundTest', 'ShowContextMenu', function() { |
| 231 var mockFeedback = this.createMockFeedback(); |
233 this.runWithLoadedTree('<a href="a">a</a>', | 232 this.runWithLoadedTree('<a href="a">a</a>', |
234 function(rootNode) { | 233 function(rootNode) { |
235 cvox.ChromeVox.tts.expectSpeech(' menu opened', this.newCallback( | 234 mockFeedback.expectSpeech(' menu opened') |
236 function() { | 235 .call(function() { |
237 // When shown, the context menu pushes a new message loop so test | 236 // When shown, the context menu pushes a new message loop so test |
238 // messages sent to the browser do not get processed. Ensure we exit | 237 // messages sent to the browser do not get processed. Ensure we |
239 // the context menu here. | 238 // exit the context menu here. |
240 go.showContextMenu(); | 239 go.showContextMenu(); |
241 }) | 240 }) |
242 ); | 241 .go(); |
243 | 242 |
244 var go = rootNode.find({ role: chrome.automation.RoleType.link }); | 243 var go = rootNode.find({ role: chrome.automation.RoleType.link }); |
245 this.listenOnce(go, 'focus', function(e) { | 244 this.listenOnce(go, 'focus', function(e) { |
246 this.doCmd('showContextMenu')(); | 245 this.doCmd('showContextMenu')(); |
247 }.bind(this), true); | 246 }.bind(this), true); |
248 go.focus(); | 247 go.focus(); |
249 }.bind(this)); | 248 }.bind(this)); |
250 }); | 249 }); |
OLD | NEW |