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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/testing/tester.js

Issue 563773003: Migrate walker tests from upstream ChromeVox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Fix another test that only fails on the bots. Created 6 years, 3 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 goog.provide('cvox.ChromeVoxTester');
6
7 goog.require('cvox.AbstractBraille');
8 goog.require('cvox.AbstractEarcons');
9 goog.require('cvox.ChromeVoxEventWatcher');
10 goog.require('cvox.ChromeVoxUserCommands');
11 goog.require('cvox.LiveRegions');
12 goog.require('cvox.NavigationManager');
13 goog.require('cvox.NavigationShifter');
14 goog.require('cvox.TestHost');
15 goog.require('cvox.TestMathJax');
16 goog.require('cvox.TestMsgs');
17 goog.require('cvox.TestTts');
18
19
20 /**
21 * @fileoverview Testing framework for ChromeVox.
22 *
23 */
24
25
26 /**
27 * Initializes cvox.ChromeVoxTester and sets up the mock ChromeVox
28 * environment.
29 * @param {!Document} doc The DOM document to add event listeners to.
30 */
31 cvox.ChromeVoxTester.setUp = function(doc) {
32 cvox.ChromeVox.mathJax = new cvox.TestMathJax();
33
34 cvox.ChromeVox.navigationManager = new cvox.NavigationManager();
35 cvox.ChromeVoxTester.testTts_ = new cvox.TestTts();
36 cvox.ChromeVox.tts = cvox.ChromeVoxTester.testTts_;
37
38 // TODO(deboer): Factor this out as 'TestEarcons'
39 cvox.ChromeVox.earcons = new cvox.AbstractEarcons();
40 cvox.ChromeVox.earcons.playEarcon = function(earcon) { };
41
42 cvox.ChromeVox.braille = new cvox.AbstractBraille();
43 cvox.ChromeVox.braille.write = function(params) {};
44
45 cvox.ChromeVox.msgs = new cvox.TestMsgs();
46
47 cvox.ChromeVox.host = new cvox.TestHost();
48
49 // Init LiveRegions with a date of 0 so that the initial delay before
50 // things is spoken is skipped.
51 cvox.LiveRegions.init(new Date(0), cvox.AbstractTts.QUEUE_MODE_QUEUE, false);
52
53 cvox.ChromeVoxEventWatcher.init(doc);
54 window.console.log('done setup');
55 };
56
57 /**
58 * Tears down cvox.ChromeVoxTester.
59 * @param {!Document} doc The DOM document where event listeners were added.
60 */
61 cvox.ChromeVoxTester.tearDown = function(doc) {
62 cvox.ChromeVoxEventWatcher.cleanup(doc);
63 };
64
65
66 /**
67 * Returns the cvox.TestTts created by the tester.
68 * @return {cvox.TestTts} The TestTts.
69 */
70 cvox.ChromeVoxTester.testTts = function() {
71 return cvox.ChromeVoxTester.testTts_;
72 };
73
74
75 /**
76 * All calls to tts.speak are saved in an array of utterances.
77 * Clear any utterances that were saved up to this poing.
78 */
79 cvox.ChromeVoxTester.clearUtterances = function() {
80 cvox.ChromeVoxTester.testTts_.clearUtterances();
81 };
82
83
84 /**
85 * Return a list of strings of what was spoken by tts.speak().
86 * @return {Array.<string>} A list of all utterances spoken since
87 * initialization or the last call to clearUtterances.
88 */
89 cvox.ChromeVoxTester.getUtteranceList = function() {
90 return cvox.ChromeVoxTester.testTts_.getUtteranceList();
91 };
92
93 /**
94 * @type {Object.<string, number>} Map from a navigation strategy name
95 * to the Navigation Manager strategy enum.
96 */
97 cvox.ChromeVoxTester.STRATEGY_MAP = {
98 'lineardom': cvox.NavigationShifter.GRANULARITIES.OBJECT,
99 'smart': cvox.NavigationShifter.GRANULARITIES.GROUP,
100 'selection': cvox.NavigationShifter.GRANULARITIES.SENTENCE
101 };
102
103 /**
104 * Switches to a different navigation strategy.
105 * @param {string} strategy The desired navigation strategy.
106 */
107 cvox.ChromeVoxTester.setStrategy = function(strategy) {
108 cvox.ChromeVox.navigationManager.ensureNotSubnavigating();
109 cvox.ChromeVox.navigationManager.setGranularity(
110 cvox.ChromeVoxTester.STRATEGY_MAP[strategy]);
111 };
112
113 /**
114 * Starts reading the page from the current node.
115 */
116 cvox.ChromeVoxTester.readFromHere = function() {
117 cvox.ChromeVox.navigationManager.startReading(
118 cvox.AbstractTts.QUEUE_MODE_FLUSH);
119 };
120
121 /**
122 * Syncs to the given node in the test HTML
123 * @param {Node} node The node to sync to.
124 */
125 cvox.ChromeVoxTester.syncToNode = function(node) {
126 cvox.ChromeVox.navigationManager
127 .updateSel(cvox.CursorSelection.fromNode(node));
128 cvox.ChromeVox.navigationManager.sync();
129 };
130
131 /**
132 * Syncs to the first node in the test.
133 */
134 cvox.ChromeVoxTester.syncToFirstNode = function() {
135 cvox.ChromeVox.navigationManager.updateSel(cvox.CursorSelection.fromBody());
136 cvox.ChromeVox.navigationManager.sync();
137 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698