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

Unified Diff: chrome/browser/ui/webui/javascript2webui.js

Issue 7237030: Added options browser_tests using the generator and js handler framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TestNavigationController in ui_test_utils, renamed LoadStart->JsInjectionReady, reordered methods. Created 9 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/javascript2webui.js
diff --git a/chrome/browser/ui/webui/javascript2webui.js b/chrome/browser/ui/webui/javascript2webui.js
index 3f748cf6bb349c5dfbf835323915be9b9d7d4f96..4543d2ee1912d016ffab812c5e1f1c8a81b7bf9d 100644
--- a/chrome/browser/ui/webui/javascript2webui.js
+++ b/chrome/browser/ui/webui/javascript2webui.js
@@ -4,36 +4,61 @@
if (arguments.length < 3) {
print('usage: ' +
arguments[0] + ' path-to-testfile.js testfile.js [output.cc]');
- quit();
-}
-var js_file = arguments[1];
-var js_file_base = arguments[2];
-var outputfile = arguments[3];
-var prevfuncs = {};
-for (var func in this) {
- if (this[func] instanceof Function)
- prevfuncs[func] = func;
-}
-var js = load(js_file);
-if (!('test_fixture' in this)) {
- print(js_file + ' did not define test_fixture.');
quit(-1);
}
-if (!('test_add_library' in this)) {
- this['test_add_library'] = true;
-}
+var jsFile = arguments[1];
+var jsFileBase = arguments[2];
+var outputFile = arguments[3];
+var prevFunctions = {};
+
+// Generate the file to stdout.
print('// GENERATED FILE');
print('// ' + arguments.join(' '));
print('// PLEASE DO NOT HAND EDIT!');
print();
-for (var func in this) {
- if (!prevfuncs[func] && this[func] instanceof Function) {
- print('IN_PROC_BROWSER_TEST_F(' + test_fixture + ', ' + func + ') {');
- if (test_add_library)
- print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + js_file_base +
- '")));');
- print(' ASSERT_TRUE(RunJavascriptTest("' + func + '"));');
- print('}');
- print();
+print('#include "chrome/browser/ui/webui/web_ui_browsertest.h"');
+print('#include "googleurl/src/gurl.h"');
+print('#include "testing/gtest/include/gtest/gtest.h"');
+print();
+
+function GEN(code) {
+ print(code);
+}
+
+var typedeffedCppFixtures = {};
+
+function TEST_F(testFixture, testFunction, testBody) {
+ var browsePreload = this[testFixture].prototype.browsePreload;
+ var browsePrintPreload = this[testFixture].prototype.browsePrintPreload;
+ var testGenPreamble = this[testFixture].prototype.testGenPreamble;
+ var testGenPostamble = this[testFixture].prototype.testGenPostamble;
+ var typedefCppFixture = this[testFixture].prototype.typedefCppFixture;
+
+ if (typedefCppFixture && !(testFixture in typedeffedCppFixtures)) {
+ print('typedef ' + typedefCppFixture + ' ' + testFixture + ';');
+ typedeffedCppFixtures[testFixture] = typedefCppFixture;
+ }
+
+ print('IN_PROC_BROWSER_TEST_F(' + testFixture + ', ' + testFunction + ') {');
+ if (testGenPreamble)
+ testGenPreamble(testFixture, testFunction);
+ print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + jsFileBase + '")));');
+ if (browsePreload) {
+ print(' BrowsePreload(GURL("' + browsePreload + '"), "' + testFixture +
+ '", "' + testFunction + '");');
+ }
+ if (browsePrintPreload) {
+ print(' BrowsePrintPreload(GURL(WebUITestDataPathToURL(\n' +
+ ' FILE_PATH_LITERAL("' + browsePrintPreload + '"))),\n' +
+ ' "' + testFixture + '", "' + testFunction + '");');
}
+ print(' ASSERT_TRUE(RunJavascriptTestF("' + testFixture + '", "' +
+ testFunction + '"));');
+ if (testGenPostamble)
+ testGenPostamble(testFixture, testFunction);
+ print('}');
+ print();
}
+
+var js = read(jsFile);
+eval(js);
« no previous file with comments | « no previous file | chrome/browser/ui/webui/print_preview_browsertest.cc » ('j') | chrome/test/test_navigation_observer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698