Chromium Code Reviews| Index: chrome/test/base/js2gtest.js |
| diff --git a/chrome/browser/ui/webui/javascript2webui.js b/chrome/test/base/js2gtest.js |
| similarity index 74% |
| rename from chrome/browser/ui/webui/javascript2webui.js |
| rename to chrome/test/base/js2gtest.js |
| index e1e380f1a965a19fdc0f67800675ff4d2b968904..fe54db00423e15a472617ead51cc570e55a6c7e9 100644 |
| --- a/chrome/browser/ui/webui/javascript2webui.js |
| +++ b/chrome/test/base/js2gtest.js |
| @@ -1,21 +1,33 @@ |
| // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -if (arguments.length < 3) { |
| +if (arguments.length < 4) { |
| print('usage: ' + |
| - arguments[0] + ' path-to-testfile.js testfile.js [output.cc]'); |
| + arguments[0] + ' path-to-testfile.js testfile.js output.cc test-type'); |
| quit(-1); |
| } |
| var jsFile = arguments[1]; |
| var jsFileBase = arguments[2]; |
| var outputFile = arguments[3]; |
| +var testType = arguments[4]; |
| // Generate the file to stdout. |
| print('// GENERATED FILE'); |
| print('// ' + arguments.join(' ')); |
| print('// PLEASE DO NOT HAND EDIT!'); |
| print(); |
| -print('#include "chrome/browser/ui/webui/web_ui_browsertest.h"'); |
| + |
| +var testF; |
| + |
| +if (testType === 'unit') { |
| + print('#include "chrome/test/base/v8_unit_test.h"'); |
| + testing.Test.prototype.typedefCppFixture = 'V8UnitTest'; |
| + testF = 'TEST_F'; |
| +} else { |
| + print('#include "chrome/browser/ui/webui/web_ui_browsertest.h"'); |
| + testing.Test.prototype.typedefCppFixture = 'WebUIBrowserTest'; |
| + testF = 'IN_PROC_BROWSER_TEST_F'; |
| +} |
| print('#include "googleurl/src/gurl.h"'); |
| print('#include "testing/gtest/include/gtest/gtest.h"'); |
| print(); |
| @@ -32,7 +44,8 @@ function TEST_F(testFixture, testFunction, testBody) { |
| var testGenPreamble = this[testFixture].prototype.testGenPreamble; |
| var testGenPostamble = this[testFixture].prototype.testGenPostamble; |
| var typedefCppFixture = this[testFixture].prototype.typedefCppFixture; |
| - var isAsync = this[testFixture].prototype.isAsync; |
| + var isAsyncParam = (testType === 'unit') ? '' : |
|
arv (Not doing code reviews)
2011/10/28 23:16:56
useless parens are discouraged in js
Sheridan Rawlins
2011/10/28 23:50:21
Done.
|
| + (this[testFixture].prototype.isAsync + ', '); |
| var testShouldFail = this[testFixture].prototype.testShouldFail; |
| var testPredicate = testShouldFail ? 'ASSERT_FALSE' : 'ASSERT_TRUE'; |
| @@ -41,7 +54,7 @@ function TEST_F(testFixture, testFunction, testBody) { |
| typedeffedCppFixtures[testFixture] = typedefCppFixture; |
| } |
| - print('IN_PROC_BROWSER_TEST_F(' + testFixture + ', ' + testFunction + ') {'); |
| + print(testF + '(' + testFixture + ', ' + testFunction + ') {'); |
| if (testGenPreamble) |
| testGenPreamble(testFixture, testFunction); |
| print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + |
| @@ -55,7 +68,7 @@ function TEST_F(testFixture, testFunction, testBody) { |
| ' FILE_PATH_LITERAL("' + browsePrintPreload + '"))),\n' + |
| ' "' + testFixture + '", "' + testFunction + '");'); |
| } |
| - print(' ' + testPredicate + '(RunJavascriptTestF(' + isAsync + ', ' + |
| + print(' ' + testPredicate + '(RunJavascriptTestF(' + isAsyncParam + |
| '"' + testFixture + '", ' + |
| '"' + testFunction + '"));'); |
| if (testGenPostamble) |