Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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|. |
| 11 * @type {Object} | 11 * @type {Object} |
| 12 */ | 12 */ |
| 13 var testing = {}; | 13 var testing = {}; |
| 14 (function(window) { | 14 (function(window) { |
|
arv (Not doing code reviews)
2011/11/03 19:04:12
rename window to exports for consistence with code
Sheridan Rawlins
2011/11/05 16:51:25
Done.
| |
| 15 /** | 15 /** |
| 16 * Hold the currentTestCase across between preLoad and run. | 16 * Hold the currentTestCase across between preLoad and run. |
| 17 * @type {TestCase} | 17 * @type {TestCase} |
| 18 */ | 18 */ |
| 19 var currentTestCase = null; | 19 var currentTestCase = null; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * The string representation of the currently running test function. | 22 * The string representation of the currently running test function. |
| 23 * @type {?string} | 23 * @type {?string} |
| 24 */ | 24 */ |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 */ | 103 */ |
| 104 isAsync: false, | 104 isAsync: false, |
| 105 | 105 |
| 106 /** | 106 /** |
| 107 * True when the test is expected to fail for testing the test framework. | 107 * True when the test is expected to fail for testing the test framework. |
| 108 * @type {boolean} | 108 * @type {boolean} |
| 109 */ | 109 */ |
| 110 testShouldFail: false, | 110 testShouldFail: false, |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * Add libraries before loading this test file. | |
|
dpapad
2011/11/03 16:14:34
Would this be a bit more clear as "Libraries to ad
Sheridan Rawlins
2011/11/05 16:51:25
Done.
| |
| 114 * @type {Array.<string>} | |
| 115 */ | |
| 116 addLibraries: [], | |
|
arv (Not doing code reviews)
2011/11/03 19:04:12
This should just be called libraries or something
Sheridan Rawlins
2011/11/05 16:51:25
Changed to extraLibraries - does that work for you
| |
| 117 | |
| 118 /** | |
| 113 * Override this method to perform initialization during preload (such as | 119 * Override this method to perform initialization during preload (such as |
| 114 * creating mocks and registering handlers). | 120 * creating mocks and registering handlers). |
| 115 * @type {Function} | 121 * @type {Function} |
| 116 */ | 122 */ |
| 117 preLoad: function() {}, | 123 preLoad: function() {}, |
| 118 | 124 |
| 119 /** | 125 /** |
| 120 * Override this method to perform tasks before running your test. | 126 * Override this method to perform tasks before running your test. |
| 121 * @type {Function} | 127 * @type {Function} |
| 122 */ | 128 */ |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 currentTestCase = createTestCase(testFixture, testName); | 851 currentTestCase = createTestCase(testFixture, testName); |
| 846 currentTestCase.preLoad(); | 852 currentTestCase.preLoad(); |
| 847 } | 853 } |
| 848 | 854 |
| 849 /** | 855 /** |
| 850 * During generation phase, this outputs; do nothing at runtime. | 856 * During generation phase, this outputs; do nothing at runtime. |
| 851 */ | 857 */ |
| 852 function GEN() {} | 858 function GEN() {} |
| 853 | 859 |
| 854 /** | 860 /** |
| 861 * During generation phase, this outputs; do nothing at runtime. | |
| 862 */ | |
| 863 function GEN_INCLUDE() {} | |
| 864 | |
| 865 /** | |
| 855 * At runtime, register the testName with a test fixture. Since this method | 866 * At runtime, register the testName with a test fixture. Since this method |
| 856 * doesn't have a test fixture, create a dummy fixture to hold its |name| | 867 * doesn't have a test fixture, create a dummy fixture to hold its |name| |
| 857 * and |testCaseBodies|. | 868 * and |testCaseBodies|. |
| 858 * @param {string} testCaseName The name of the test case. | 869 * @param {string} testCaseName The name of the test case. |
| 859 * @param {string} testName The name of the test function. | 870 * @param {string} testName The name of the test function. |
| 860 * @param {Function} testBody The body to execute when running this test. | 871 * @param {Function} testBody The body to execute when running this test. |
| 861 */ | 872 */ |
| 862 function TEST(testCaseName, testName, testBody) { | 873 function TEST(testCaseName, testName, testBody) { |
| 863 var fixtureConstructor = this[testCaseName]; | 874 var fixtureConstructor = this[testCaseName]; |
| 864 if (fixtureConstructor === undefined) { | 875 if (fixtureConstructor === undefined) { |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1297 window.resetTestState = resetTestState; | 1308 window.resetTestState = resetTestState; |
| 1298 window.runAllActions = runAllActions; | 1309 window.runAllActions = runAllActions; |
| 1299 window.runAllActionsAsync = runAllActionsAsync; | 1310 window.runAllActionsAsync = runAllActionsAsync; |
| 1300 window.runTest = runTest; | 1311 window.runTest = runTest; |
| 1301 window.runTestFunction = runTestFunction; | 1312 window.runTestFunction = runTestFunction; |
| 1302 window.SaveMockArguments = SaveMockArguments; | 1313 window.SaveMockArguments = SaveMockArguments; |
| 1303 window.DUMMY_URL = DUMMY_URL; | 1314 window.DUMMY_URL = DUMMY_URL; |
| 1304 window.TEST = TEST; | 1315 window.TEST = TEST; |
| 1305 window.TEST_F = TEST_F; | 1316 window.TEST_F = TEST_F; |
| 1306 window.GEN = GEN; | 1317 window.GEN = GEN; |
| 1318 window.GEN_INCLUDE = GEN_INCLUDE; | |
| 1307 window.WhenTestDone = WhenTestDone; | 1319 window.WhenTestDone = WhenTestDone; |
| 1308 | 1320 |
| 1309 // Import the Mock4JS helpers. | 1321 // Import the Mock4JS helpers. |
| 1310 Mock4JS.addMockSupport(window); | 1322 Mock4JS.addMockSupport(window); |
| 1311 })(('window' in this) ? window : this); | 1323 })(('window' in this) ? window : this); |
|
arv (Not doing code reviews)
2011/11/03 19:04:12
What does window in this do here? How is this bett
Sheridan Rawlins
2011/11/05 16:51:25
I forget why I needed this at some point - it may
| |
| OLD | NEW |