| 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 Generator script for creating gtest-style JavaScript | 6 * @fileoverview Generator script for creating gtest-style JavaScript |
| 7 * tests for WebUI and unit tests. Generates C++ gtest wrappers | 7 * tests for WebUI and unit tests. Generates C++ gtest wrappers |
| 8 * which will invoke the appropriate JavaScript for each test. | 8 * which will invoke the appropriate JavaScript for each test. |
| 9 * @author scr@chromium.org (Sheridan Rawlins) | 9 * @author scr@chromium.org (Sheridan Rawlins) |
| 10 * @see WebUI testing: http://goo.gl/ZWFXF | 10 * @see WebUI testing: http://goo.gl/ZWFXF |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 * @param {Function} testBody The function body to execute for this test. | 145 * @param {Function} testBody The function body to execute for this test. |
| 146 */ | 146 */ |
| 147 function TEST_F(testFixture, testFunction, testBody) { | 147 function TEST_F(testFixture, testFunction, testBody) { |
| 148 var browsePreload = this[testFixture].prototype.browsePreload; | 148 var browsePreload = this[testFixture].prototype.browsePreload; |
| 149 var browsePrintPreload = this[testFixture].prototype.browsePrintPreload; | 149 var browsePrintPreload = this[testFixture].prototype.browsePrintPreload; |
| 150 var testGenPreamble = this[testFixture].prototype.testGenPreamble; | 150 var testGenPreamble = this[testFixture].prototype.testGenPreamble; |
| 151 var testGenPostamble = this[testFixture].prototype.testGenPostamble; | 151 var testGenPostamble = this[testFixture].prototype.testGenPostamble; |
| 152 var typedefCppFixture = this[testFixture].prototype.typedefCppFixture; | 152 var typedefCppFixture = this[testFixture].prototype.typedefCppFixture; |
| 153 var isAsyncParam = testType === 'unit' ? '' : | 153 var isAsyncParam = testType === 'unit' ? '' : |
| 154 this[testFixture].prototype.isAsync + ', '; | 154 this[testFixture].prototype.isAsync + ', '; |
| 155 var testShouldFail = this[testFixture].prototype.testShouldFail; | 155 var testShouldFail = this[testFixture].prototype.testShouldFail || |
| 156 testFunction.match(/_shouldFail$/); |
| 156 var testPredicate = testShouldFail ? 'ASSERT_FALSE' : 'ASSERT_TRUE'; | 157 var testPredicate = testShouldFail ? 'ASSERT_FALSE' : 'ASSERT_TRUE'; |
| 157 var extraLibraries = genIncludes.concat( | 158 var extraLibraries = genIncludes.concat( |
| 158 this[testFixture].prototype.extraLibraries.map( | 159 this[testFixture].prototype.extraLibraries.map( |
| 159 function(includeFile) { | 160 function(includeFile) { |
| 160 return includeFileToPaths(includeFile).base; | 161 return includeFileToPaths(includeFile).base; |
| 161 })); | 162 })); |
| 162 | 163 |
| 163 if (typedefCppFixture && !(testFixture in typedeffedCppFixtures)) { | 164 if (typedefCppFixture && !(testFixture in typedeffedCppFixtures)) { |
| 164 print('typedef ' + typedefCppFixture + ' ' + testFixture + ';'); | 165 print('typedef ' + typedefCppFixture + ' ' + testFixture + ';'); |
| 165 typedeffedCppFixtures[testFixture] = typedefCppFixture; | 166 typedeffedCppFixtures[testFixture] = typedefCppFixture; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 189 '"' + testFunction + '"));'); | 190 '"' + testFunction + '"));'); |
| 190 if (testGenPostamble) | 191 if (testGenPostamble) |
| 191 testGenPostamble(testFixture, testFunction); | 192 testGenPostamble(testFixture, testFunction); |
| 192 print('}'); | 193 print('}'); |
| 193 print(); | 194 print(); |
| 194 } | 195 } |
| 195 | 196 |
| 196 // Now that generation functions are defined, load in |jsFile|. | 197 // Now that generation functions are defined, load in |jsFile|. |
| 197 var js = read(jsFile); | 198 var js = read(jsFile); |
| 198 eval(js); | 199 eval(js); |
| OLD | NEW |