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

Side by Side 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: Fix indent & commenting capitalization. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 if (arguments.length < 3) { 4 if (arguments.length < 3) {
5 print('usage: ' + 5 print('usage: ' +
6 arguments[0] + ' path-to-testfile.js testfile.js [output.cc]'); 6 arguments[0] + ' path-to-testfile.js testfile.js [output.cc]');
7 quit();
8 }
9 var js_file = arguments[1];
10 var js_file_base = arguments[2];
11 var outputfile = arguments[3];
12 var prevfuncs = {};
13 for (var func in this) {
14 if (this[func] instanceof Function)
15 prevfuncs[func] = func;
16 }
17 var js = load(js_file);
18 if (!('test_fixture' in this)) {
19 print(js_file + ' did not define test_fixture.');
20 quit(-1); 7 quit(-1);
21 } 8 }
22 if (!('test_add_library' in this)) { 9 var jsFile = arguments[1];
23 this['test_add_library'] = true; 10 var jsFileBase = arguments[2];
24 } 11 var outputFile = arguments[3];
12 var prevFunctions = {};
13
14 // Generate the file to stdout.
25 print('// GENERATED FILE'); 15 print('// GENERATED FILE');
26 print('// ' + arguments.join(' ')); 16 print('// ' + arguments.join(' '));
27 print('// PLEASE DO NOT HAND EDIT!'); 17 print('// PLEASE DO NOT HAND EDIT!');
28 print(); 18 print();
29 for (var func in this) { 19 print('#include "chrome/browser/ui/webui/web_ui_browsertest.h"');
30 if (!prevfuncs[func] && this[func] instanceof Function) { 20 print('#include "googleurl/src/gurl.h"');
31 print('IN_PROC_BROWSER_TEST_F(' + test_fixture + ', ' + func + ') {'); 21 print('#include "testing/gtest/include/gtest/gtest.h"');
32 if (test_add_library) 22 print();
33 print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + js_file_base + 23
34 '")));'); 24 function GEN(code) {
35 print(' ASSERT_TRUE(RunJavascriptTest("' + func + '"));'); 25 print(code);
36 print('}'); 26 }
37 print(); 27
28 var typedeffedCppFixtures = {};
29
30 function TEST_F(testFixture, testFunction, testBody) {
31 var browsePreload = this[testFixture].prototype.browsePreload;
32 var browsePrintPreload = this[testFixture].prototype.browsePrintPreload;
33 var testGenPreamble = this[testFixture].prototype.testGenPreamble;
34 var testGenPostamble = this[testFixture].prototype.testGenPostamble;
35 var typedefCppFixture = this[testFixture].prototype.typedefCppFixture;
36
37 if (typedefCppFixture && !(testFixture in typedeffedCppFixtures)) {
38 print('typedef ' + typedefCppFixture + ' ' + testFixture + ';');
39 typedeffedCppFixtures[testFixture] = typedefCppFixture;
38 } 40 }
41
42 print('IN_PROC_BROWSER_TEST_F(' + testFixture + ', ' + testFunction + ') {');
43 if (testGenPreamble)
44 testGenPreamble(testFixture, testFunction);
45 print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + jsFileBase + '")));');
46 if (browsePreload) {
47 print(' BrowsePreload(GURL("' + browsePreload + '"), "' + testFixture +
48 '", "' + testFunction + '");');
49 }
50 if (browsePrintPreload) {
51 print(' BrowsePrintPreload(GURL(WebUITestDataPathToURL(\n' +
52 ' FILE_PATH_LITERAL("' + browsePrintPreload + '"))),\n' +
53 ' "' + testFixture + '", "' + testFunction + '");');
54 }
55 print(' ASSERT_TRUE(RunJavascriptTestF("' + testFixture + '", "' +
56 testFunction + '"));');
57 if (testGenPostamble)
58 testGenPostamble(testFixture, testFunction);
59 print('}');
60 print();
39 } 61 }
62
63 var js = read(jsFile);
64 eval(js);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/print_preview_browsertest.cc » ('j') | chrome/browser/ui/webui/web_ui_browsertest.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698