OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * @fileoverview Library providing basic test framework functionality. | 6 * @fileoverview Library providing basic test framework functionality. |
7 */ | 7 */ |
8 | 8 |
9 /** | 9 /** |
10 * Namespace for |Test|. | 10 * Namespace for |Test|. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 * @type {axs.AuditConfiguration} | 143 * @type {axs.AuditConfiguration} |
144 */ | 144 */ |
145 accessibilityAuditConfig_: null, | 145 accessibilityAuditConfig_: null, |
146 | 146 |
147 /** | 147 /** |
148 * Returns the configuration for the accessibility audit, creating it | 148 * Returns the configuration for the accessibility audit, creating it |
149 * on-demand. | 149 * on-demand. |
150 * @return {axs.AuditConfiguration} | 150 * @return {axs.AuditConfiguration} |
151 */ | 151 */ |
152 get accessibilityAuditConfig() { | 152 get accessibilityAuditConfig() { |
153 if (!this.accessibilityAuditConfig_) { | 153 // The axs namespace is not available in chromevox tests. |
| 154 // Further, 'window' is not available in unit tests, but since the |
| 155 // accessibility audit library pulls in the closure library, |
| 156 // 'goog.global' has to be present if axs is, so we use that here. |
| 157 if (!this.accessibilityAuditConfig_ && |
| 158 goog && goog.global && goog.global.axs) { |
154 this.accessibilityAuditConfig_ = new axs.AuditConfiguration(); | 159 this.accessibilityAuditConfig_ = new axs.AuditConfiguration(); |
155 | 160 |
156 this.accessibilityAuditConfig_.showUnsupportedRulesWarning = false; | 161 this.accessibilityAuditConfig_.showUnsupportedRulesWarning = false; |
157 | 162 |
158 this.accessibilityAuditConfig_.auditRulesToIgnore = [ | 163 this.accessibilityAuditConfig_.auditRulesToIgnore = [ |
159 // The "elements with meaningful background image" accessibility | 164 // The "elements with meaningful background image" accessibility |
160 // audit (AX_IMAGE_01) does not apply, since Chrome doesn't | 165 // audit (AX_IMAGE_01) does not apply, since Chrome doesn't |
161 // disable background images in high-contrast mode like some | 166 // disable background images in high-contrast mode like some |
162 // browsers do. | 167 // browsers do. |
163 "elementsWithMeaningfulBackgroundImage", | 168 "elementsWithMeaningfulBackgroundImage", |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 * creating mocks and registering handlers). | 279 * creating mocks and registering handlers). |
275 * @type {Function} | 280 * @type {Function} |
276 */ | 281 */ |
277 preLoad: function() {}, | 282 preLoad: function() {}, |
278 | 283 |
279 /** | 284 /** |
280 * Override this method to perform tasks before running your test. | 285 * Override this method to perform tasks before running your test. |
281 * @type {Function} | 286 * @type {Function} |
282 */ | 287 */ |
283 setUp: function() { | 288 setUp: function() { |
284 // These should be ignored in many of the web UI tests. | 289 var auditConfig = this.accessibilityAuditConfig; |
285 // user-image-stream and supervised-user-creation-image-stream are | 290 if (auditConfig) { |
286 // streaming video elements used for capturing a user image so they won't | 291 // These should be ignored in many of the web UI tests. |
287 // have captions and should be ignored everywhere. | 292 // user-image-stream and supervised-user-creation-image-stream are |
288 this.accessibilityAuditConfig.ignoreSelectors('videoWithoutCaptions', | 293 // streaming video elements used for capturing a user image so they |
289 '.user-image-stream'); | 294 // won't have captions and should be ignored everywhere. |
290 this.accessibilityAuditConfig.ignoreSelectors( | 295 auditConfig.ignoreSelectors('videoWithoutCaptions', |
291 'videoWithoutCaptions', '.supervised-user-creation-image-stream'); | 296 '.user-image-stream'); |
| 297 auditConfig.ignoreSelectors( |
| 298 'videoWithoutCaptions', '.supervised-user-creation-image-stream'); |
| 299 } |
292 }, | 300 }, |
293 | 301 |
294 /** | 302 /** |
295 * Override this method to perform tasks after running your test. If you | 303 * Override this method to perform tasks after running your test. If you |
296 * create a mock class, you must call Mock4JS.verifyAllMocks() in this | 304 * create a mock class, you must call Mock4JS.verifyAllMocks() in this |
297 * phase. | 305 * phase. |
298 * @type {Function} | 306 * @type {Function} |
299 */ | 307 */ |
300 tearDown: function() { | 308 tearDown: function() { |
301 Mock4JS.verifyAllMocks(); | 309 Mock4JS.verifyAllMocks(); |
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 exports.TEST = TEST; | 1805 exports.TEST = TEST; |
1798 exports.TEST_F = TEST_F; | 1806 exports.TEST_F = TEST_F; |
1799 exports.RUNTIME_TEST_F = TEST_F; | 1807 exports.RUNTIME_TEST_F = TEST_F; |
1800 exports.GEN = GEN; | 1808 exports.GEN = GEN; |
1801 exports.GEN_INCLUDE = GEN_INCLUDE; | 1809 exports.GEN_INCLUDE = GEN_INCLUDE; |
1802 exports.WhenTestDone = WhenTestDone; | 1810 exports.WhenTestDone = WhenTestDone; |
1803 | 1811 |
1804 // Import the Mock4JS helpers. | 1812 // Import the Mock4JS helpers. |
1805 Mock4JS.addMockSupport(exports); | 1813 Mock4JS.addMockSupport(exports); |
1806 })(this); | 1814 })(this); |
OLD | NEW |