OLD | NEW |
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([ |
6 'chrome/browser/resources/chromeos/chromevox/testing/common.js']); | 6 'chrome/browser/resources/chromeos/chromevox/testing/common.js', |
| 7 'chrome/browser/resources/chromeos/chromevox/testing/callback_helper.js']); |
7 | 8 |
8 /** | 9 /** |
9 * Base test fixture for ChromeVox end to end tests. | 10 * Base test fixture for ChromeVox end to end tests. |
10 * | 11 * |
11 * These tests run against production ChromeVox inside of the extension's | 12 * These tests run against production ChromeVox inside of the extension's |
12 * background page context. | 13 * background page context. |
13 * @constructor | 14 * @constructor |
14 */ | 15 */ |
15 function ChromeVoxE2ETest() {} | 16 function ChromeVoxE2ETest() { |
| 17 this.callbackHelper_ = new CallbackHelper(this); |
| 18 } |
16 | 19 |
17 ChromeVoxE2ETest.prototype = { | 20 ChromeVoxE2ETest.prototype = { |
18 __proto__: testing.Test.prototype, | 21 __proto__: testing.Test.prototype, |
19 | 22 |
20 /** | 23 /** |
21 * @override | 24 * @override |
22 * No UI in the background context. | 25 * No UI in the background context. |
23 */ | 26 */ |
24 runAccessibilityChecks: false, | 27 runAccessibilityChecks: false, |
25 | 28 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! | 97 var code = TestUtils.extractHtmlFromCommentEncodedString(function() {/*! |
95 var target = document.body.querySelector('$1'); | 98 var target = document.body.querySelector('$1'); |
96 target.focus(); | 99 target.focus(); |
97 var evt = document.createEvent('KeyboardEvent'); | 100 var evt = document.createEvent('KeyboardEvent'); |
98 evt.initKeyboardEvent('keydown', true, true, window, '$0', 0, false, | 101 evt.initKeyboardEvent('keydown', true, true, window, '$0', 0, false, |
99 false, false, false); | 102 false, false, false); |
100 document.activeElement.dispatchEvent(evt); | 103 document.activeElement.dispatchEvent(evt); |
101 */}, [key, elementQueryString]); | 104 */}, [key, elementQueryString]); |
102 | 105 |
103 chrome.tabs.executeScript(tabId, {code: code}); | 106 chrome.tabs.executeScript(tabId, {code: code}); |
| 107 }, |
| 108 |
| 109 /** |
| 110 * Creates a callback that optionally calls {@code opt_callback} when |
| 111 * called. If this method is called one or more times, then |
| 112 * {@code testDone()} will be called when all callbacks have been called. |
| 113 * @param {Function=} opt_callback Wrapped callback that will have its this |
| 114 * reference bound to the test fixture. |
| 115 * @return {Function} |
| 116 */ |
| 117 newCallback: function(opt_callback) { |
| 118 return this.callbackHelper_.wrap(opt_callback); |
104 } | 119 } |
105 }; | 120 }; |
106 | 121 |
107 /** | 122 /** |
108 * Similar to |TEST_F|. Generates a test for the given |testFixture|, | 123 * Similar to |TEST_F|. Generates a test for the given |testFixture|, |
109 * |testName|, and |testFunction|. | 124 * |testName|, and |testFunction|. |
110 * Used this variant when an |isAsync| fixture wants to temporarily mix in an | 125 * Used this variant when an |isAsync| fixture wants to temporarily mix in an |
111 * sync test. | 126 * sync test. |
112 * @param {string} testFixture Fixture name. | 127 * @param {string} testFixture Fixture name. |
113 * @param {string} testName Test name. | 128 * @param {string} testName Test name. |
114 * @param {function} testFunction The test impl. | 129 * @param {function} testFunction The test impl. |
115 */ | 130 */ |
116 function SYNC_TEST_F(testFixture, testName, testFunction) { | 131 function SYNC_TEST_F(testFixture, testName, testFunction) { |
117 var wrappedTestFunction = function() { | 132 var wrappedTestFunction = function() { |
118 testFunction.call(this); | 133 testFunction.call(this); |
119 testDone([true, '']); | 134 testDone([true, '']); |
120 }; | 135 }; |
121 TEST_F(testFixture, testName, wrappedTestFunction); | 136 TEST_F(testFixture, testName, wrappedTestFunction); |
122 } | 137 } |
OLD | NEW |