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

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

Issue 2943193002: Run clang-format on .js files in c/b/r/chromeos/chromevox (Closed)
Patch Set: Created 3 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
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 GEN_INCLUDE([ 5 GEN_INCLUDE(['common.js', 'callback_helper.js']);
6 'common.js',
7 'callback_helper.js']);
8 6
9 /** 7 /**
10 * Base test fixture for ChromeVox end to end tests. 8 * Base test fixture for ChromeVox end to end tests.
11 * 9 *
12 * These tests run against production ChromeVox inside of the extension's 10 * These tests run against production ChromeVox inside of the extension's
13 * background page context. 11 * background page context.
14 * @constructor 12 * @constructor
15 */ 13 */
16 function ChromeVoxE2ETest() { 14 function ChromeVoxE2ETest() {
17 this.callbackHelper_ = new CallbackHelper(this); 15 this.callbackHelper_ = new CallbackHelper(this);
18 } 16 }
19 17
20 ChromeVoxE2ETest.prototype = { 18 ChromeVoxE2ETest.prototype = {
21 __proto__: testing.Test.prototype, 19 __proto__: testing.Test.prototype,
22 20
23 /** 21 /**
24 * @override 22 * @override
25 * No UI in the background context. 23 * No UI in the background context.
26 */ 24 */
27 runAccessibilityChecks: false, 25 runAccessibilityChecks: false,
28 26
29 /** @override */ 27 /** @override */
30 isAsync: true, 28 isAsync: true,
31 29
32 /** @override */ 30 /** @override */
33 browsePreload: null, 31 browsePreload: null,
34 32
35 /** @override */ 33 /** @override */
36 testGenCppIncludes: function() { 34 testGenCppIncludes: function() {
37 GEN_BLOCK(function() {/*! 35 GEN_BLOCK(function() { /*!
38 #include "ash/accessibility_delegate.h" 36 #include "ash/accessibility_delegate.h"
39 #include "base/bind.h" 37 #include "base/bind.h"
40 #include "base/callback.h" 38 #include "base/callback.h"
41 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 39 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
42 #include "chrome/common/extensions/extension_constants.h" 40 #include "chrome/common/extensions/extension_constants.h"
43 */}); 41 */ });
44 }, 42 },
45 43
46 /** @override */ 44 /** @override */
47 testGenPreamble: function() { 45 testGenPreamble: function() {
48 GEN_BLOCK(function() {/*! 46 GEN_BLOCK(function() { /*!
49 base::Closure load_cb = 47 base::Closure load_cb =
50 base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback, 48 base::Bind(&chromeos::AccessibilityManager::EnableSpokenFeedback,
51 base::Unretained(chromeos::AccessibilityManager::Get()), 49 base::Unretained(chromeos::AccessibilityManager::Get()),
52 true, 50 true,
53 ash::A11Y_NOTIFICATION_NONE); 51 ash::A11Y_NOTIFICATION_NONE);
54 WaitForExtension(extension_misc::kChromeVoxExtensionId, load_cb); 52 WaitForExtension(extension_misc::kChromeVoxExtensionId, load_cb);
55 */}); 53 */ });
56 }, 54 },
57 55
58 /** 56 /**
59 * Launch a new tab, wait until tab status complete, then run callback. 57 * Launch a new tab, wait until tab status complete, then run callback.
60 * @param {function() : void} doc Snippet wrapped inside of a function. 58 * @param {function() : void} doc Snippet wrapped inside of a function.
61 * @param {function()} callback Called once the document is ready. 59 * @param {function()} callback Called once the document is ready.
62 */ 60 */
63 runWithLoadedTab: function(doc, callback) { 61 runWithLoadedTab: function(doc, callback) {
64 this.launchNewTabWithDoc(doc, function(tab) { 62 this.launchNewTabWithDoc(doc, function(tab) {
65 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) { 63 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
66 if (tabId == tab.id && changeInfo.status == 'complete') { 64 if (tabId == tab.id && changeInfo.status == 'complete') {
67 callback(tabId); 65 callback(tabId);
68 } 66 }
69 }); 67 });
70 }); 68 });
71 }, 69 },
72 70
73 /** 71 /**
74 * Launches the given document in a new tab. 72 * Launches the given document in a new tab.
75 * @param {function() : void} doc Snippet wrapped inside of a function. 73 * @param {function() : void} doc Snippet wrapped inside of a function.
76 * @param {function(url: string)} opt_callback Called once the 74 * @param {function(url: string)} opt_callback Called once the
77 * document is created. 75 * document is created.
78 */ 76 */
79 runWithTab: function(doc, opt_callback) { 77 runWithTab: function(doc, opt_callback) {
80 var url = TestUtils.createUrlForDoc(doc); 78 var url = TestUtils.createUrlForDoc(doc);
81 var createParams = { 79 var createParams = {active: true, url: url};
82 active: true,
83 url: url
84 };
85 chrome.tabs.create(createParams, function(tab) { 80 chrome.tabs.create(createParams, function(tab) {
86 if (opt_callback) 81 if (opt_callback)
87 opt_callback(tab.url); 82 opt_callback(tab.url);
88 }); 83 });
89 }, 84 },
90 85
91 /** 86 /**
92 * Increment the selected index of a select control. 87 * Increment the selected index of a select control.
93 * @param {number} tabId Of the page. 88 * @param {number} tabId Of the page.
94 * @param {string} elementQueryString 89 * @param {string} elementQueryString
95 */ 90 */
96 incrementSelectedIndex: function(tabId, elementQueryString) { 91 incrementSelectedIndex: function(tabId, elementQueryString) {
97 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! 92 var code = TestUtils.extractHtmlFromCommentEncodedString(
93 function() { /*!
98 var target = document.body.querySelector('$0'); 94 var target = document.body.querySelector('$0');
99 target.focus(); 95 target.focus();
100 target.selectedIndex++; 96 target.selectedIndex++;
101 */}, [elementQueryString]); 97 */ },
98 [elementQueryString]);
102 99
103 chrome.tabs.executeScript(tabId, {code: code}); 100 chrome.tabs.executeScript(tabId, {code: code});
104 }, 101 },
105 102
106 /** 103 /**
107 * Creates a callback that optionally calls {@code opt_callback} when 104 * Creates a callback that optionally calls {@code opt_callback} when
108 * called. If this method is called one or more times, then 105 * called. If this method is called one or more times, then
109 * {@code testDone()} will be called when all callbacks have been called. 106 * {@code testDone()} will be called when all callbacks have been called.
110 * @param {Function=} opt_callback Wrapped callback that will have its this 107 * @param {Function=} opt_callback Wrapped callback that will have its this
111 * reference bound to the test fixture. 108 * reference bound to the test fixture.
112 * @return {Function} 109 * @return {Function}
113 */ 110 */
114 newCallback: function(opt_callback) { 111 newCallback: function(opt_callback) {
115 return this.callbackHelper_.wrap(opt_callback); 112 return this.callbackHelper_.wrap(opt_callback);
116 } 113 }
117 }; 114 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698