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

Side by Side 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: Address comments. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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(['../../../chromevox/testing/chromevox_unittest_base.js']); 6 GEN_INCLUDE(['../../../chromevox/testing/chromevox_e2e_test.js']);
7 7
8 /** 8 /**
9 * Test fixture for cvox2.Background. 9 * Test fixture for cvox2.Background.
10 * @constructor 10 * @constructor
11 * @extends {ChromeVoxUnitTestBase} 11 * @extends {ChromeVoxE2ETest}
12 */ 12 */
13 function BackgroundTest() {} 13 function BackgroundTest() {}
14 14
15 BackgroundTest.prototype = { 15 BackgroundTest.prototype = {
16 __proto__: ChromeVoxUnitTestBase.prototype, 16 __proto__: ChromeVoxE2ETest.prototype,
17 17
18 /** @override */ 18 /** @override */
19 browsePreload: null, 19 setUp: function() {
20 20 this.mockTts = new MockTts();
21 /** @override */ 21 cvox.ChromeVox.tts = this.mockTts;
22 testGenCppIncludes: function() {
23 GEN_BLOCK(function() {/*!
24 #include "ash/accessibility_delegate.h"
25 #include "base/bind.h"
26 #include "base/callback.h"
27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
28 #include "chrome/common/extensions/extension_constants.h"
29 */});
30 },
31
32 /** @override */
33 testGenPreamble: function() {
34 GEN_BLOCK(function() {/*!
35 if (chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) {
36 chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(false,
37 ash::A11Y_NOTIFICATION_NONE);
38 }
39
40 base::Closure load_cb =
41 base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback,
42 base::Unretained(chromeos::AccessibilityManager::Get()),
43 true,
44 ash::A11Y_NOTIFICATION_NONE);
45 WaitForExtension(extension_misc::kChromeVoxExtensionId, load_cb);
46 */});
47 } 22 }
48 }; 23 };
49 24
50 /** Tests ChromeVox classic is in this context. */ 25 /**
51 TEST_F('BackgroundTest', 'ClassicNamespaces', function() { 26 * Mock tts class.
27 * @constructor
28 * @extends {cvox.TtsInterface}
29 */
30 var MockTts = function() {
31 };
32
33 MockTts.prototype = {
34 /** Tracks all spoken text. @type {!Array.<string>} */
35 utterances: [],
36
37 /** @override */
38 speak: function(textString, queueMode, properties) {
39 this.utterances.push(textString);
40 },
41
42 /**
43 * Checks to see if a string was spoken.
44 * @param {string} textString The string to check.
45 * @return {boolean} True if the string was spoken (possibly as part of a
46 * larger utterance).
47 */
48 checkIfTextWasSpoken: function(textString) {
49 return this.utterances.some(function(t) {
50 return t.indexOf(textString) != -1;
51 });
52 }
53 };
54
55 /** Tests that ChromeVox classic is in this context. */
56 SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() {
52 assertEquals('object', typeof(cvox)); 57 assertEquals('object', typeof(cvox));
53 assertEquals('function', typeof(cvox.ChromeVoxBackground)); 58 assertEquals('function', typeof(cvox.ChromeVoxBackground));
54 }); 59 });
60
61 /** Tests that ChromeVox next is in this context. */
62 SYNC_TEST_F('BackgroundTest', 'NextNamespaces', function() {
63 assertEquals('object', typeof(cvox2));
64 assertEquals('function', typeof(cvox2.Background));
65 });
66
67 /** Tests that ChromeVox reads the desktop tree. */
68 TEST_F('BackgroundTest', 'DesktopFocus', function() {
69 function findStatusTray(root) {
70 if (root.role == chrome.automation.RoleType.button &&
71 root.attributes.name == 'Status tray') {
72 return root;
73 }
74 for (var i = 0; i < root.children().length; i++) {
75 var found = findStatusTray(root.children()[i]);
76 if (found)
77 return found;
78 }
79 return null;
80 }
81
82 chrome.automation.getDesktop(function(root) {
83 var testButton = findStatusTray(root);
84 testButton.addEventListener(chrome.automation.EventType.focus,
85 function(e) {
86 var result =
87 cvox.ChromeVox.tts.checkIfTextWasSpoken('Status tray button');
88 testDone([result, '']);
89 },
90 true);
91 testButton.focus();
92 });
93 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698