OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 if (arguments.length < 3) { | |
5 print('usage: ' + | |
6 arguments[0] + ' path-to-testfile.js testfile.js [output.cc]'); | |
7 quit(-1); | |
8 } | |
9 var jsFile = arguments[1]; | |
10 var jsFileBase = arguments[2]; | |
11 var outputFile = arguments[3]; | |
12 | |
13 // Generate the file to stdout. | |
14 print('// GENERATED FILE'); | |
15 print('// ' + arguments.join(' ')); | |
16 print('// PLEASE DO NOT HAND EDIT!'); | |
17 print(); | |
18 print('#include "chrome/browser/ui/webui/web_ui_browsertest.h"'); | |
19 print('#include "googleurl/src/gurl.h"'); | |
20 print('#include "testing/gtest/include/gtest/gtest.h"'); | |
21 print(); | |
22 | |
23 function GEN(code) { | |
24 print(code); | |
25 } | |
26 | |
27 var typedeffedCppFixtures = {}; | |
28 | |
29 function TEST_F(testFixture, testFunction, testBody) { | |
30 var browsePreload = this[testFixture].prototype.browsePreload; | |
31 var browsePrintPreload = this[testFixture].prototype.browsePrintPreload; | |
32 var testGenPreamble = this[testFixture].prototype.testGenPreamble; | |
33 var testGenPostamble = this[testFixture].prototype.testGenPostamble; | |
34 var typedefCppFixture = this[testFixture].prototype.typedefCppFixture; | |
35 var isAsync = this[testFixture].prototype.isAsync; | |
36 var testShouldFail = this[testFixture].prototype.testShouldFail; | |
37 var testPredicate = testShouldFail ? 'ASSERT_FALSE' : 'ASSERT_TRUE'; | |
38 | |
39 if (typedefCppFixture && !(testFixture in typedeffedCppFixtures)) { | |
40 print('typedef ' + typedefCppFixture + ' ' + testFixture + ';'); | |
41 typedeffedCppFixtures[testFixture] = typedefCppFixture; | |
42 } | |
43 | |
44 print('IN_PROC_BROWSER_TEST_F(' + testFixture + ', ' + testFunction + ') {'); | |
45 if (testGenPreamble) | |
46 testGenPreamble(testFixture, testFunction); | |
47 print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + | |
48 jsFileBase.replace(/\\/g, '/') + '")));'); | |
49 if (browsePreload) { | |
50 print(' BrowsePreload(GURL("' + browsePreload + '"), "' + testFixture + | |
51 '", "' + testFunction + '");'); | |
52 } | |
53 if (browsePrintPreload) { | |
54 print(' BrowsePrintPreload(GURL(WebUITestDataPathToURL(\n' + | |
55 ' FILE_PATH_LITERAL("' + browsePrintPreload + '"))),\n' + | |
56 ' "' + testFixture + '", "' + testFunction + '");'); | |
57 } | |
58 print(' ' + testPredicate + '(RunJavascriptTestF(' + isAsync + ', ' + | |
59 '"' + testFixture + '", ' + | |
60 '"' + testFunction + '"));'); | |
61 if (testGenPostamble) | |
62 testGenPostamble(testFixture, testFunction); | |
63 print('}'); | |
64 print(); | |
65 } | |
66 | |
67 var js = read(jsFile); | |
68 eval(js); | |
OLD | NEW |