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|. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 * phase. | 122 * phase. |
123 * @type {Function} | 123 * @type {Function} |
124 */ | 124 */ |
125 tearDown: function() { | 125 tearDown: function() { |
126 Mock4JS.verifyAllMocks(); | 126 Mock4JS.verifyAllMocks(); |
127 }, | 127 }, |
128 | 128 |
129 /** | 129 /** |
130 * Called to run the body from the perspective of this fixture. | 130 * Called to run the body from the perspective of this fixture. |
131 * @type {Function} | 131 * @type {Function} |
132 * TODO(scr): Fix TEST_F to call testDone when assertions fail in async | |
133 * mode. | |
Sheridan Rawlins
2011/09/20 19:23:19
Please move comment below.
flackr
2011/09/21 23:12:10
Done.
| |
132 */ | 134 */ |
133 runTest: function(testBody) { | 135 runTest: function(testBody) { |
134 testBody.call(this); | 136 testBody.call(this); |
135 }, | 137 }, |
136 | 138 |
137 /** | 139 /** |
138 * Create a closure function for continuing the test at a later time. May be | 140 * Create a closure function for continuing the test at a later time. May be |
139 * used as a listener function. | 141 * used as a listener function. |
140 * @param {WhenTestDone} whenTestDone Call testDone() at the appropriate | 142 * @param {WhenTestDone} whenTestDone Call testDone() at the appropriate |
141 * time. | 143 * time. |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 * testDone() when |isAsync| is not true, relying on async tests to call | 739 * testDone() when |isAsync| is not true, relying on async tests to call |
738 * testDone() when they complete. | 740 * testDone() when they complete. |
739 * @param {boolean} isAsync When false, call testDone() with the test result. | 741 * @param {boolean} isAsync When false, call testDone() with the test result. |
740 * @param {string} testFunction The function name to call. | 742 * @param {string} testFunction The function name to call. |
741 * @param {Array} testArguments The arguments to call |testFunction| with. | 743 * @param {Array} testArguments The arguments to call |testFunction| with. |
742 * @return {boolean} true always to signal successful execution (but not | 744 * @return {boolean} true always to signal successful execution (but not |
743 * necessarily successful results) of this test. | 745 * necessarily successful results) of this test. |
744 * @see errors | 746 * @see errors |
745 * @see runTestFunction | 747 * @see runTestFunction |
746 */ | 748 */ |
747 function runTest(isAsync, testFunction, testArguments) { | 749 function runTest(isAsync, testFunction, testArguments) { |
Sheridan Rawlins
2011/09/20 19:23:19
LGTM if you move the TODO(scr) to _this_ runTest.
flackr
2011/09/21 23:12:10
Done.
| |
748 // Avoid eval() if at all possible, since it will not work on pages | 750 // Avoid eval() if at all possible, since it will not work on pages |
749 // that have enabled content-security-policy. | 751 // that have enabled content-security-policy. |
750 var testBody = this[testFunction]; // global object -- not a method. | 752 var testBody = this[testFunction]; // global object -- not a method. |
751 var testName = testFunction; | 753 var testName = testFunction; |
752 if (typeof testBody === "undefined") { | 754 if (typeof testBody === "undefined") { |
753 testBody = eval(testFunction); | 755 testBody = eval(testFunction); |
754 testName = testBody.toString(); | 756 testName = testBody.toString(); |
755 } | 757 } |
756 if (testBody != RUN_TEST_F) { | 758 if (testBody != RUN_TEST_F) { |
757 console.log('Running test ' + testName); | 759 console.log('Running test ' + testName); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1285 window.SaveMockArguments = SaveMockArguments; | 1287 window.SaveMockArguments = SaveMockArguments; |
1286 window.DUMMY_URL = DUMMY_URL; | 1288 window.DUMMY_URL = DUMMY_URL; |
1287 window.TEST = TEST; | 1289 window.TEST = TEST; |
1288 window.TEST_F = TEST_F; | 1290 window.TEST_F = TEST_F; |
1289 window.GEN = GEN; | 1291 window.GEN = GEN; |
1290 window.WhenTestDone = WhenTestDone; | 1292 window.WhenTestDone = WhenTestDone; |
1291 | 1293 |
1292 // Import the Mock4JS helpers. | 1294 // Import the Mock4JS helpers. |
1293 Mock4JS.addMockSupport(window); | 1295 Mock4JS.addMockSupport(window); |
1294 })(('window' in this) ? window : this); | 1296 })(('window' in this) ? window : this); |
OLD | NEW |