Index: chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs |
diff --git a/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs b/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs |
index 496978203f7a0dff573de56916053900955bb0fa..370805234d18f298040c47c5ae1b5902e8f914af 100644 |
--- a/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs |
+++ b/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs |
@@ -3,52 +3,91 @@ |
// found in the LICENSE file. |
// Include test fixture. |
-GEN_INCLUDE(['../../../chromevox/testing/chromevox_unittest_base.js']); |
+GEN_INCLUDE(['../../../chromevox/testing/chromevox_e2e_test.js']); |
/** |
* Test fixture for cvox2.Background. |
* @constructor |
- * @extends {ChromeVoxUnitTestBase} |
+ * @extends {ChromeVoxE2ETest} |
*/ |
function BackgroundTest() {} |
BackgroundTest.prototype = { |
- __proto__: ChromeVoxUnitTestBase.prototype, |
+ __proto__: ChromeVoxE2ETest.prototype, |
/** @override */ |
- browsePreload: null, |
+ setUp: function() { |
+ this.mockTts = new MockTts(); |
+ cvox.ChromeVox.tts = this.mockTts; |
+ } |
+}; |
- /** @override */ |
- testGenCppIncludes: function() { |
- GEN_BLOCK(function() {/*! |
-#include "ash/accessibility_delegate.h" |
-#include "base/bind.h" |
-#include "base/callback.h" |
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
-#include "chrome/common/extensions/extension_constants.h" |
- */}); |
- }, |
+/** |
+ * Mock tts class. |
+ * @constructor |
+ * @extends {cvox.TtsInterface} |
+ */ |
+var MockTts = function() { |
+}; |
+ |
+MockTts.prototype = { |
+ /** Tracks all spoken text. @type {!Array.<string>} */ |
+ utterances: [], |
/** @override */ |
- testGenPreamble: function() { |
- GEN_BLOCK(function() {/*! |
- if (chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
- chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(false, |
- ash::A11Y_NOTIFICATION_NONE); |
- } |
+ speak: function(textString, queueMode, properties) { |
+ this.utterances.push(textString); |
+ }, |
- base::Closure load_cb = |
- base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback, |
- base::Unretained(chromeos::AccessibilityManager::Get()), |
- true, |
- ash::A11Y_NOTIFICATION_NONE); |
- WaitForExtension(extension_misc::kChromeVoxExtensionId, load_cb); |
- */}); |
+ /** |
+ * 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 ChromeVox classic is in this context. */ |
-TEST_F('BackgroundTest', 'ClassicNamespaces', function() { |
+/** 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(); |
+ }); |
+}); |