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

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: Added documentation for newly added classes. 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();
31 print('IN_PROC_BROWSER_TEST_F(' + test_fixture + ', ' + func + ') {'); 21
32 if (test_add_library) 22 function GEN(code) {
33 print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + js_file_base + 23 print(code);
34 '")));'); 24 }
35 print(' ASSERT_TRUE(RunJavascriptTest("' + func + '"));'); 25
36 print('}'); 26 function TEST_F(testFixture, testFunction, testBody) {
37 print(); 27 var testBrowsePreload = this[testFixture].prototype.browsePreload;
28 var testBrowsePrintPreload = this[testFixture].prototype.browsePrintPreload;
29
30 print('IN_PROC_BROWSER_TEST_F(' + testFixture + ', ' + testFunction + ') {');
31 print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + jsFileBase + '")));');
32 if (testBrowsePreload) {
33 print(' BrowsePreload(GURL("' + testBrowsePreload + '"), "' + testFixture +
34 '", "' + testFunction + '");');
35 }
36 if (testBrowsePrintPreload) {
37 print(' BrowsePrintPreload(GURL(WebUITestDataPathToURL(\n' +
38 ' FILE_PATH_LITERAL("' + testBrowsePrintPreload + '"))),\n' +
39 ' "' + testFixture + '", "' + testFunction + '");');
38 } 40 }
41 print(' ASSERT_TRUE(RunJavascriptTestF("' + testFixture + '", "' +
42 testFunction + '"));');
43 print('}');
44 print();
39 } 45 }
46
47 var js = read(jsFile);
48 eval(js);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/print_preview_browsertest.cc » ('j') | chrome/test/data/webui/options.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698