diff options
Diffstat (limited to 'chromium/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs')
-rw-r--r-- | chromium/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/chromium/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs b/chromium/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs new file mode 100644 index 00000000000..370805234d1 --- /dev/null +++ b/chromium/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs @@ -0,0 +1,93 @@ +// 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(['../../../chromevox/testing/chromevox_e2e_test.js']); + +/** + * Test fixture for cvox2.Background. + * @constructor + * @extends {ChromeVoxE2ETest} + */ +function BackgroundTest() {} + +BackgroundTest.prototype = { + __proto__: ChromeVoxE2ETest.prototype, + + /** @override */ + setUp: function() { + this.mockTts = new MockTts(); + cvox.ChromeVox.tts = this.mockTts; + } +}; + +/** + * Mock tts class. + * @constructor + * @extends {cvox.TtsInterface} + */ +var MockTts = function() { +}; + +MockTts.prototype = { + /** Tracks all spoken text. @type {!Array.<string>} */ + utterances: [], + + /** @override */ + speak: function(textString, queueMode, properties) { + this.utterances.push(textString); + }, + + /** + * Checks to see if a string was spoken. + * @param {string} textString The string to check. + * @return {boolean} True if the string was spoken (possibly as part of a + * larger utterance). + */ + checkIfTextWasSpoken: function(textString) { + return this.utterances.some(function(t) { + return t.indexOf(textString) != -1; + }); + } +}; + +/** Tests that ChromeVox classic is in this context. */ +SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() { + assertEquals('object', typeof(cvox)); + assertEquals('function', typeof(cvox.ChromeVoxBackground)); +}); + +/** Tests that ChromeVox next is in this context. */ +SYNC_TEST_F('BackgroundTest', 'NextNamespaces', function() { + assertEquals('object', typeof(cvox2)); + assertEquals('function', typeof(cvox2.Background)); +}); + +/** Tests that ChromeVox reads the desktop tree. */ +TEST_F('BackgroundTest', 'DesktopFocus', function() { + function findStatusTray(root) { + if (root.role == chrome.automation.RoleType.button && + root.attributes.name == 'Status tray') { + return root; + } + for (var i = 0; i < root.children().length; i++) { + var found = findStatusTray(root.children()[i]); + if (found) + return found; + } + return null; + } + + chrome.automation.getDesktop(function(root) { + var testButton = findStatusTray(root); + testButton.addEventListener(chrome.automation.EventType.focus, + function(e) { + var result = + cvox.ChromeVox.tts.checkIfTextWasSpoken('Status tray button'); + testDone([result, '']); + }, + true); + testButton.focus(); + }); +}); |