| 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 extensions, WebUI and unit tests. Generates C++ gtest wrappers |    7  *     tests for extensions, 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  317 /** |  317 /** | 
|  318  * Generate gtest-style TEST_F definitions for C++ with a body that |  318  * Generate gtest-style TEST_F definitions for C++ with a body that | 
|  319  * will invoke the |testBody| for |testFixture|.|testFunction|. |  319  * will invoke the |testBody| for |testFixture|.|testFunction|. | 
|  320  * @param {string} testFixture The name of this test's fixture. |  320  * @param {string} testFixture The name of this test's fixture. | 
|  321  * @param {string} testFunction The name of this test's function. |  321  * @param {string} testFunction The name of this test's function. | 
|  322  * @param {Function} testBody The function body to execute for this test. |  322  * @param {Function} testBody The function body to execute for this test. | 
|  323  */ |  323  */ | 
|  324 function TEST_F(testFixture, testFunction, testBody) { |  324 function TEST_F(testFixture, testFunction, testBody) { | 
|  325   maybeGenHeader(testFixture); |  325   maybeGenHeader(testFixture); | 
|  326   var browsePreload = this[testFixture].prototype.browsePreload; |  326   var browsePreload = this[testFixture].prototype.browsePreload; | 
 |  327   var browsePreloadAndWaitForMain = | 
 |  328       this[testFixture].prototype.browsePreloadAndWaitForMain; | 
|  327   var browsePrintPreload = this[testFixture].prototype.browsePrintPreload; |  329   var browsePrintPreload = this[testFixture].prototype.browsePrintPreload; | 
|  328   var testGenPreamble = this[testFixture].prototype.testGenPreamble; |  330   var testGenPreamble = this[testFixture].prototype.testGenPreamble; | 
|  329   var testGenPostamble = this[testFixture].prototype.testGenPostamble; |  331   var testGenPostamble = this[testFixture].prototype.testGenPostamble; | 
|  330   var typedefCppFixture = this[testFixture].prototype.typedefCppFixture; |  332   var typedefCppFixture = this[testFixture].prototype.typedefCppFixture; | 
|  331   var isAsyncParam = testType === 'unit' ? '' : |  333   var isAsyncParam = testType === 'unit' ? '' : | 
|  332       this[testFixture].prototype.isAsync + ', '; |  334       this[testFixture].prototype.isAsync + ', '; | 
|  333   var testShouldFail = this[testFixture].prototype.testShouldFail; |  335   var testShouldFail = this[testFixture].prototype.testShouldFail; | 
|  334   var testPredicate = testShouldFail ? 'ASSERT_FALSE' : 'ASSERT_TRUE'; |  336   var testPredicate = testShouldFail ? 'ASSERT_FALSE' : 'ASSERT_TRUE'; | 
|  335   var extraLibraries = genIncludes.concat( |  337   var extraLibraries = genIncludes.concat( | 
|  336       this[testFixture].prototype.extraLibraries.map( |  338       this[testFixture].prototype.extraLibraries.map( | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  352   print('  AddLibrary(base::FilePath(FILE_PATH_LITERAL("' + |  354   print('  AddLibrary(base::FilePath(FILE_PATH_LITERAL("' + | 
|  353       jsFileBase.replace(/\\/g, '/') + '")));'); |  355       jsFileBase.replace(/\\/g, '/') + '")));'); | 
|  354   if (addSetPreloadInfo) { |  356   if (addSetPreloadInfo) { | 
|  355     print('  set_preload_test_fixture("' + testFixture + '");'); |  357     print('  set_preload_test_fixture("' + testFixture + '");'); | 
|  356     print('  set_preload_test_name("' + testFunction + '");'); |  358     print('  set_preload_test_name("' + testFunction + '");'); | 
|  357   } |  359   } | 
|  358   if (testGenPreamble) |  360   if (testGenPreamble) | 
|  359     testGenPreamble(testFixture, testFunction); |  361     testGenPreamble(testFixture, testFunction); | 
|  360   if (browsePreload) |  362   if (browsePreload) | 
|  361     print('  BrowsePreload(GURL("' + browsePreload + '"));'); |  363     print('  BrowsePreload(GURL("' + browsePreload + '"));'); | 
 |  364   if (browsePreloadAndWaitForMain) { | 
 |  365     print('  BrowsePreloadAndWaitForMain(GURL("' + browsePreloadAndWaitForMain + | 
 |  366           '"));'); | 
 |  367   } | 
|  362   if (browsePrintPreload) { |  368   if (browsePrintPreload) { | 
|  363     print('  BrowsePrintPreload(GURL(WebUITestDataPathToURL(\n' + |  369     print('  BrowsePrintPreload(GURL(WebUITestDataPathToURL(\n' + | 
|  364           '      FILE_PATH_LITERAL("' + browsePrintPreload + '"))));'); |  370           '      FILE_PATH_LITERAL("' + browsePrintPreload + '"))));'); | 
|  365   } |  371   } | 
|  366   print('  ' + testPredicate + '(RunJavascriptTestF(' + isAsyncParam + |  372   print('  ' + testPredicate + '(RunJavascriptTestF(' + isAsyncParam + | 
|  367         '"' + testFixture + '", ' + |  373         '"' + testFixture + '", ' + | 
|  368         '"' + testFunction + '"));'); |  374         '"' + testFunction + '"));'); | 
|  369   if (testGenPostamble) |  375   if (testGenPostamble) | 
|  370     testGenPostamble(testFixture, testFunction); |  376     testGenPostamble(testFixture, testFunction); | 
|  371   print('}'); |  377   print('}'); | 
|  372   print(); |  378   print(); | 
|  373 } |  379 } | 
|  374  |  380  | 
|  375 // Now that generation functions are defined, load in |jsFile|. |  381 // Now that generation functions are defined, load in |jsFile|. | 
|  376 var js = read(jsFile); |  382 var js = read(jsFile); | 
|  377 eval(js); |  383 eval(js); | 
| OLD | NEW |