Chromium Code Reviews| 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_tts.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 /** @override */ |
| 23 setUp: function() { | 23 setUp: function() { |
| 24 this.mockTts = new MockTts(); | 24 this.mockTts = new MockTts(); |
| 25 cvox.ChromeVox.tts = this.mockTts; | 25 cvox.ChromeVox.tts = this.mockTts; |
| 26 global.backgroundObj.forceChromeVoxNextActive(); | |
|
Peter Lundblad
2015/08/20 08:30:06
ChromeVoxE2ETest.runWithTab already adds chromevox
David Tseng
2015/08/20 17:52:47
That logic depends on a load complete event to be
| |
| 26 }, | 27 }, |
| 27 | 28 |
| 28 /** | 29 /** |
| 29 * Create a function which perform the command |cmd|. | 30 * Create a function which perform the command |cmd|. |
| 30 * @param {string} cmd | 31 * @param {string} cmd |
| 31 * @return {function() : void} | 32 * @return {function() : void} |
| 32 */ | 33 */ |
| 33 doCmd: function(cmd) { | 34 doCmd: function(cmd) { |
| 34 return function() { | 35 return function() { |
| 35 global.backgroundObj.onGotCommand(cmd); | 36 global.backgroundObj.onGotCommand(cmd); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 // TODO(plundblad): This test finishes prematurely and breaks if that gets | 236 // TODO(plundblad): This test finishes prematurely and breaks if that gets |
| 236 // fixed. | 237 // fixed. |
| 237 TEST_F('BackgroundTest', 'AriaLabel', function() { | 238 TEST_F('BackgroundTest', 'AriaLabel', function() { |
| 238 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', | 239 this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', |
| 239 function(rootNode) { | 240 function(rootNode) { |
| 240 cvox.ChromeVox.tts.expectSpeech('foo link', testDone); | 241 cvox.ChromeVox.tts.expectSpeech('foo link', testDone); |
| 241 | 242 |
| 242 rootNode.focus(); | 243 rootNode.focus(); |
| 243 }.bind(this)); | 244 }.bind(this)); |
| 244 }); | 245 }); |
| 246 | |
| 247 TEST_F('BackgroundTest', 'FocusInputElement', function() { | |
| 248 this.runWithLoadedTree( | |
| 249 function() {/*! | |
| 250 <input id="name" value="Lancelot"> | |
| 251 <input id="quest" value="Grail"> | |
| 252 <input id="color" value="Blue"> | |
| 253 */}, | |
| 254 function(rootNode) { | |
| 255 cvox.ChromeVox.tts.expectSpeech('Grail'); | |
| 256 cvox.ChromeVox.tts.expectSpeech('Edit text'); | |
| 257 | |
| 258 cvox.ChromeVox.tts.expectSpeech('Blue'); | |
| 259 cvox.ChromeVox.tts.expectSpeech('Edit text'); | |
| 260 | |
| 261 var quest = rootNode.find({ attributes: { value: 'Grail' } }); | |
| 262 quest.focus(); | |
| 263 | |
| 264 window.setTimeout(this.newCallback(function() { | |
| 265 var color = rootNode.find({ attributes: { value: 'Blue' } }); | |
| 266 color.focus(); | |
| 267 | |
| 268 cvox.ChromeVox.tts.finishExpectations(this.newCallback()); | |
| 269 }), 100); | |
|
David Tseng
2015/08/19 17:19:25
Can you do this without a timeout (e.g. by adding
Peter Lundblad
2015/08/20 08:30:06
I bet this will flake on some memmory bot. We shou
David Tseng
2015/08/20 17:52:47
See my suggestion above (about focus event handler
| |
| 270 | |
| 271 }.bind(this)); | |
|
Peter Lundblad
2015/08/20 08:30:06
Superflous bind.
| |
| 272 }); | |
| OLD | NEW |