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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 /** | 38 /** |
39 * This class will be exported as testing.Test, and is provided to hold the | 39 * This class will be exported as testing.Test, and is provided to hold the |
40 * fixture's configuration and callback methods for the various phases of | 40 * fixture's configuration and callback methods for the various phases of |
41 * invoking a test. It is called "Test" rather than TestFixture to roughly | 41 * invoking a test. It is called "Test" rather than TestFixture to roughly |
42 * mimic the gtest's class names. | 42 * mimic the gtest's class names. |
43 * @constructor | 43 * @constructor |
44 */ | 44 */ |
45 function Test() {}; | 45 function Test() {}; |
46 | 46 |
| 47 /** |
| 48 * Make all transitions and animations take 0ms. NOTE: this will completely |
| 49 * disable webkitTransitionEnd events. If your code relies on them firing, it |
| 50 * will break. webkitAnimationEnd events should still work. |
| 51 */ |
| 52 Test.disableAnimationsAndTransitions = function() { |
| 53 var noAnimationStyle = document.createElement('style'); |
| 54 noAnimationStyle.id = 'no-animation'; |
| 55 noAnimationStyle.textContent = |
| 56 '* {' + |
| 57 ' -webkit-transition-duration: 0ms !important;' + |
| 58 ' -webkit-transition-delay: 0ms !important;' + |
| 59 ' -webkit-animation-duration: 0ms !important;' + |
| 60 ' -webkit-animation-delay: 0ms !important;' + |
| 61 '}'; |
| 62 document.querySelector('head').appendChild(noAnimationStyle); |
| 63 }; |
| 64 |
47 Test.prototype = { | 65 Test.prototype = { |
48 /** | 66 /** |
49 * The name of the test. | 67 * The name of the test. |
50 */ | 68 */ |
51 name: null, | 69 name: null, |
52 | 70 |
53 /** | 71 /** |
54 * When set to a string value representing a url, generate BrowsePreload | 72 * When set to a string value representing a url, generate BrowsePreload |
55 * call, which will browse to the url and call fixture.preLoad of the | 73 * call, which will browse to the url and call fixture.preLoad of the |
56 * currentTestCase. | 74 * currentTestCase. |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 317 } |
300 }, | 318 }, |
301 | 319 |
302 /** | 320 /** |
303 * Override this method to perform tasks after running your test. If you | 321 * Override this method to perform tasks after running your test. If you |
304 * create a mock class, you must call Mock4JS.verifyAllMocks() in this | 322 * create a mock class, you must call Mock4JS.verifyAllMocks() in this |
305 * phase. | 323 * phase. |
306 * @type {Function} | 324 * @type {Function} |
307 */ | 325 */ |
308 tearDown: function() { | 326 tearDown: function() { |
| 327 if (typeof document != 'undefined') { |
| 328 var noAnimationStyle = document.getElementById('no-animation'); |
| 329 if (noAnimationStyle) |
| 330 noAnimationStyle.parentNode.removeChild(noAnimationStyle); |
| 331 } |
| 332 |
309 Mock4JS.verifyAllMocks(); | 333 Mock4JS.verifyAllMocks(); |
310 }, | 334 }, |
311 | 335 |
312 /** | 336 /** |
313 * Called to run the body from the perspective of this fixture. | 337 * Called to run the body from the perspective of this fixture. |
314 * @type {Function} | 338 * @type {Function} |
315 */ | 339 */ |
316 runTest: function(testBody) { | 340 runTest: function(testBody) { |
317 testBody.call(this); | 341 testBody.call(this); |
318 }, | 342 }, |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 exports.TEST = TEST; | 1829 exports.TEST = TEST; |
1806 exports.TEST_F = TEST_F; | 1830 exports.TEST_F = TEST_F; |
1807 exports.RUNTIME_TEST_F = TEST_F; | 1831 exports.RUNTIME_TEST_F = TEST_F; |
1808 exports.GEN = GEN; | 1832 exports.GEN = GEN; |
1809 exports.GEN_INCLUDE = GEN_INCLUDE; | 1833 exports.GEN_INCLUDE = GEN_INCLUDE; |
1810 exports.WhenTestDone = WhenTestDone; | 1834 exports.WhenTestDone = WhenTestDone; |
1811 | 1835 |
1812 // Import the Mock4JS helpers. | 1836 // Import the Mock4JS helpers. |
1813 Mock4JS.addMockSupport(exports); | 1837 Mock4JS.addMockSupport(exports); |
1814 })(this); | 1838 })(this); |
OLD | NEW |