Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs

Issue 337843005: Support basic reading of focus for both desktop and tabs trees. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b90c93bbf2e6093fed9cb6f9aca81edba8f3a4ad 100644
--- a/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs
+++ b/chrome/browser/resources/chromeos/chromevox2/cvox2/background/background.extjs
@@ -3,52 +3,99 @@
// 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;
+ });
}
};
+function SYNC_TEST_F(testFixture, testName, testFunction) {
Peter Lundblad 2014/06/19 20:54:10 nit: jsdoc. Also, move to the base class right aw
David Tseng 2014/06/19 22:30:37 Done.
+ var wrappedTestFunction = function() {
+ testFunction();
+ testDone([true, '']);
+ };
+ TEST_F(testFixture, testName, wrappedTestFunction);
+}
+
/** Tests ChromeVox classic is in this context. */
-TEST_F('BackgroundTest', 'ClassicNamespaces', function() {
+SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() {
assertEquals('object', typeof(cvox));
assertEquals('function', typeof(cvox.ChromeVoxBackground));
});
+
+/** Tests ChromeVox next is in this context. */
Peter Lundblad 2014/06/19 20:54:10 nit: Tests that (I find it easier to read that way
David Tseng 2014/06/19 22:30:37 Done. (and below).
+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();
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698