Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: chrome/test/base/js2gtest.js

Issue 8440060: Revert 108391 - Broke 'compile' on Mac clobber builder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/base/v8_unit_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 < 4) {
5 print('usage: ' +
6 arguments[0] + ' path-to-testfile.js testfile.js output.cc test-type');
7 quit(-1);
8 }
9 var jsFile = arguments[1];
10 var jsFileBase = arguments[2];
11 var outputFile = arguments[3];
12 var testType = arguments[4];
13
14 // Generate the file to stdout.
15 print('// GENERATED FILE');
16 print('// ' + arguments.join(' '));
17 print('// PLEASE DO NOT HAND EDIT!');
18 print();
19
20 var testF;
21
22 if (testType === 'unit') {
23 print('#include "chrome/test/base/v8_unit_test.h"');
24 testing.Test.prototype.typedefCppFixture = 'V8UnitTest';
25 testF = 'TEST_F';
26 } else {
27 print('#include "chrome/browser/ui/webui/web_ui_browsertest.h"');
28 testing.Test.prototype.typedefCppFixture = 'WebUIBrowserTest';
29 testF = 'IN_PROC_BROWSER_TEST_F';
30 }
31 print('#include "googleurl/src/gurl.h"');
32 print('#include "testing/gtest/include/gtest/gtest.h"');
33 print();
34
35 function GEN(code) {
36 print(code);
37 }
38
39 var typedeffedCppFixtures = {};
40
41 function TEST_F(testFixture, testFunction, testBody) {
42 var browsePreload = this[testFixture].prototype.browsePreload;
43 var browsePrintPreload = this[testFixture].prototype.browsePrintPreload;
44 var testGenPreamble = this[testFixture].prototype.testGenPreamble;
45 var testGenPostamble = this[testFixture].prototype.testGenPostamble;
46 var typedefCppFixture = this[testFixture].prototype.typedefCppFixture;
47 var isAsyncParam = testType === 'unit' ? '' :
48 this[testFixture].prototype.isAsync + ', ';
49 var testShouldFail = this[testFixture].prototype.testShouldFail;
50 var testPredicate = testShouldFail ? 'ASSERT_FALSE' : 'ASSERT_TRUE';
51
52 if (typedefCppFixture && !(testFixture in typedeffedCppFixtures)) {
53 print('typedef ' + typedefCppFixture + ' ' + testFixture + ';');
54 typedeffedCppFixtures[testFixture] = typedefCppFixture;
55 }
56
57 print(testF + '(' + testFixture + ', ' + testFunction + ') {');
58 if (testGenPreamble)
59 testGenPreamble(testFixture, testFunction);
60 print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' +
61 jsFileBase.replace(/\\/g, '/') + '")));');
62 if (browsePreload) {
63 print(' BrowsePreload(GURL("' + browsePreload + '"), "' + testFixture +
64 '", "' + testFunction + '");');
65 }
66 if (browsePrintPreload) {
67 print(' BrowsePrintPreload(GURL(WebUITestDataPathToURL(\n' +
68 ' FILE_PATH_LITERAL("' + browsePrintPreload + '"))),\n' +
69 ' "' + testFixture + '", "' + testFunction + '");');
70 }
71 print(' ' + testPredicate + '(RunJavascriptTestF(' + isAsyncParam +
72 '"' + testFixture + '", ' +
73 '"' + testFunction + '"));');
74 if (testGenPostamble)
75 testGenPostamble(testFixture, testFunction);
76 print('}');
77 print();
78 }
79
80 var js = read(jsFile);
81 eval(js);
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/base/v8_unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698