Chromium Code Reviews| 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. | |
| 49 * Any animations will still happen and webkitAnimationEnd should be | |
| 50 * listened to. | |
|
Dan Beam
2015/04/30 23:22:04
Make all transitions and animations take 0ms. NOTE
hcarmona
2015/05/01 16:51:31
Done.
| |
| 51 * Transitions will not dispatch any webkitTransitionEnd events. | |
| 52 */ | |
| 53 Test.disableAnimationsAndTransitions = function() { | |
| 54 var noAnimationStyle = document.createElement('style'); | |
| 55 noAnimationStyle.id = 'no-animation'; | |
| 56 noAnimationStyle.textContent = | |
| 57 '* {' + | |
| 58 ' -webkit-transition-duration: 0ms !important;' + | |
| 59 ' -webkit-transition-delay: 0ms !important;' + | |
| 60 ' -webkit-animation-duration: 0ms !important;' + | |
| 61 ' -webkit-animation-delay: 0ms !important;' + | |
| 62 '}'; | |
| 63 document.querySelector('head').appendChild(noAnimationStyle); | |
| 64 }; | |
| 65 | |
| 47 Test.prototype = { | 66 Test.prototype = { |
| 48 /** | 67 /** |
| 49 * The name of the test. | 68 * The name of the test. |
| 50 */ | 69 */ |
| 51 name: null, | 70 name: null, |
| 52 | 71 |
| 53 /** | 72 /** |
| 54 * When set to a string value representing a url, generate BrowsePreload | 73 * 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 | 74 * call, which will browse to the url and call fixture.preLoad of the |
| 56 * currentTestCase. | 75 * currentTestCase. |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 } | 318 } |
| 300 }, | 319 }, |
| 301 | 320 |
| 302 /** | 321 /** |
| 303 * Override this method to perform tasks after running your test. If you | 322 * Override this method to perform tasks after running your test. If you |
| 304 * create a mock class, you must call Mock4JS.verifyAllMocks() in this | 323 * create a mock class, you must call Mock4JS.verifyAllMocks() in this |
| 305 * phase. | 324 * phase. |
| 306 * @type {Function} | 325 * @type {Function} |
| 307 */ | 326 */ |
| 308 tearDown: function() { | 327 tearDown: function() { |
| 328 var noAnimationStyle = $('no-animation'); | |
| 329 if (noAnimationStyle) | |
| 330 noAnimationStyle.parentNode.removeChild(noAnimationStyle); | |
| 331 | |
| 309 Mock4JS.verifyAllMocks(); | 332 Mock4JS.verifyAllMocks(); |
| 310 }, | 333 }, |
| 311 | 334 |
| 312 /** | 335 /** |
| 313 * Called to run the body from the perspective of this fixture. | 336 * Called to run the body from the perspective of this fixture. |
| 314 * @type {Function} | 337 * @type {Function} |
| 315 */ | 338 */ |
| 316 runTest: function(testBody) { | 339 runTest: function(testBody) { |
| 317 testBody.call(this); | 340 testBody.call(this); |
| 318 }, | 341 }, |
| (...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1805 exports.TEST = TEST; | 1828 exports.TEST = TEST; |
| 1806 exports.TEST_F = TEST_F; | 1829 exports.TEST_F = TEST_F; |
| 1807 exports.RUNTIME_TEST_F = TEST_F; | 1830 exports.RUNTIME_TEST_F = TEST_F; |
| 1808 exports.GEN = GEN; | 1831 exports.GEN = GEN; |
| 1809 exports.GEN_INCLUDE = GEN_INCLUDE; | 1832 exports.GEN_INCLUDE = GEN_INCLUDE; |
| 1810 exports.WhenTestDone = WhenTestDone; | 1833 exports.WhenTestDone = WhenTestDone; |
| 1811 | 1834 |
| 1812 // Import the Mock4JS helpers. | 1835 // Import the Mock4JS helpers. |
| 1813 Mock4JS.addMockSupport(exports); | 1836 Mock4JS.addMockSupport(exports); |
| 1814 })(this); | 1837 })(this); |
| OLD | NEW |