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

Issue 7237030: Added options browser_tests using the generator and js handler framework. (Closed)

Created:
9 years, 5 months ago by Sheridan Rawlins
Modified:
9 years, 5 months ago
CC:
chromium-reviews, Paweł Hajdan Jr., Mike Mammarella, James Hawkins
Visibility:
Public.

Description

Added options browser_tests using the generator and js handler framework. This patch turned out to be fairly large. Let me describe the ultimate goal: - To write WebUI tests in javascript, with as little C++ as possible for the simple case, yet powerful enough to support more complicated cases. options.js illustrates the simple case, and print_preview.js illustrates the complicated case. Original changes: - Refactored test_tab_strip_observer into test_navigation_observer so that it could be used by itself without needing the TabInsertedAt logic, which PrintPreview needs when there's no TabContentsWrapper available. - Added assertEqualsArray for comparing two arrays shallowly (javascript == fails). - Provided logic in WebUIBrowserTest and in the javascript2webui.js generation script to allow browsing to a url with preload of injected javascript. - Corrected test_navigation_observer to wait for the right notification before calling callback (which runs after the page's javascript is loaded but before its onload). - Added guts to define OS_* ifdefs for javascript to test for disabling tests. - Moved the handler from settings_browsertest.cc to settings.js - use __proto__ when overriding chrome to allow other members to be seen (commandLineString, e.g.) Additions made during review: - Switched to generative mechanism: TEST_F, GEN, which output during generation, and register during runtime. - JS fixtures provide configuration members - Add configuration hooks to generate in C++ test function - Output directly to .cc file rather than needing hand-made .cc file which includes the generated file. - Changed preload to take testFixture and testName. - include and use mock4js to ensure handler methods are called. - auto-generate the typedef WebUIBrowserTest testFixture unless overridden. R=jhawkins@chromium.org,dtseng@chromium.org BUG=82437 TEST=browser_tests --gtest_filter=SettingsWebUITest.* Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=92084 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=92111

Patch Set 1 #

Patch Set 2 : Use __proto__ to get the old_chrome's methods when overriding. #

Patch Set 3 : Remove unused headers. #

Patch Set 4 : More unused headers. #

Patch Set 5 : Fix OS_* insertions for javascript. #

Patch Set 6 : Windows doesn't allow OVERRIDE on destructors. #

Total comments: 15

Patch Set 7 : s/settings/options/, moved .cc into options dir, addressed JS readability. #

Total comments: 41

Patch Set 8 : Mike's nits. #

Patch Set 9 : Overhaul to TEST_F-style, ditch -inl.h, use mock4js. #

Patch Set 10 : Added documentation for newly added classes. #

Total comments: 12

Patch Set 11 : Removing quotes from attributes. #

Patch Set 12 : Fixed indentation and removed OVERRIDE from method definition. #

Patch Set 13 : Fixed indentation on options.js array assignment; added LICENSE file. #

Patch Set 14 : Use preamble to ditch awkward skipTest. Added typedef generation for simple C++ fixtures. #

Patch Set 15 : Added basic includes for auto-generation (gurl, gtest). #

Patch Set 16 : Full documentation, stuff testNames into testFixtures, handle no-preload case. #

Patch Set 17 : rebase. #

Total comments: 10

Patch Set 18 : Change (!('foo' in bar)) to (bar['foo'] === undefined); remove includes. #

Patch Set 19 : Fix indent & commenting capitalization. #

Total comments: 8

Patch Set 20 : TestNavigationController in ui_test_utils, renamed LoadStart->JsInjectionReady, reordered methods. #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+1828 lines, -654 lines) Patch
M chrome/browser/ui/webui/javascript2webui.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +50 lines, -25 lines 0 comments Download
D chrome/browser/ui/webui/print_preview_browsertest.cc View 1 2 3 4 5 6 7 8 1 chunk +0 lines, -80 lines 0 comments Download
M chrome/browser/ui/webui/settings_browsertest.cc View 1 2 3 4 5 6 1 chunk +0 lines, -126 lines 0 comments Download
M chrome/browser/ui/webui/web_ui_browsertest.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 6 chunks +33 lines, -7 lines 0 comments Download
M chrome/browser/ui/webui/web_ui_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 12 chunks +69 lines, -84 lines 0 comments Download
M chrome/chrome_tests.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 7 chunks +9 lines, -8 lines 0 comments Download
A chrome/test/data/webui/options.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +104 lines, -0 lines 0 comments Download
M chrome/test/data/webui/print_preview.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +123 lines, -76 lines 0 comments Download
M chrome/test/data/webui/sample_pass.js View 1 2 3 4 5 6 7 8 1 chunk +0 lines, -19 lines 0 comments Download
M chrome/test/data/webui/settings.js View 1 2 3 4 5 6 1 chunk +0 lines, -34 lines 0 comments Download
M chrome/test/data/webui/test_api.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +411 lines, -28 lines 0 comments Download
A chrome/test/test_navigation_observer.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +90 lines, -0 lines 2 comments Download
A chrome/test/test_navigation_observer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +83 lines, -0 lines 4 comments Download
M chrome/test/test_tab_strip_model_observer.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 chunks +6 lines, -42 lines 2 comments Download
M chrome/test/test_tab_strip_model_observer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 chunks +5 lines, -51 lines 0 comments Download
M chrome/test/ui_test_utils.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 5 chunks +6 lines, -69 lines 0 comments Download
A chrome/third_party/mock4js/LICENSE View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +19 lines, -0 lines 0 comments Download
A chrome/third_party/mock4js/README.chromium View 1 2 3 4 5 6 7 8 1 chunk +8 lines, -0 lines 0 comments Download
A chrome/third_party/mock4js/examples/PriceService.js View 1 2 3 4 5 6 7 8 1 chunk +43 lines, -0 lines 0 comments Download
A chrome/third_party/mock4js/examples/PriceServiceTest.html View 1 2 3 4 5 6 7 8 1 chunk +60 lines, -0 lines 0 comments Download
A chrome/third_party/mock4js/examples/Publisher.js View 1 2 3 4 5 6 7 8 1 chunk +29 lines, -0 lines 0 comments Download
A chrome/third_party/mock4js/examples/PublisherTest.html View 1 2 3 4 5 6 7 8 1 chunk +47 lines, -0 lines 0 comments Download
A chrome/third_party/mock4js/mock4js.js View 1 2 3 4 5 6 7 8 1 chunk +625 lines, -0 lines 0 comments Download
M tools/gypv8sh.py View 1 2 3 4 5 6 7 8 2 chunks +8 lines, -5 lines 0 comments Download

Messages

Total messages: 19 (0 generated)
Sheridan Rawlins
Provided some more framework to migrate settings webui tests to javascript handler with javascript2webui generation ...
9 years, 5 months ago (2011-07-07 05:26:26 UTC) #1
James Hawkins
webui/settings_browsertest.cc This file should be in webui/options and be renamed to options_browsertest.cc. Same goes for ...
9 years, 5 months ago (2011-07-07 18:28:23 UTC) #2
David Tseng
http://codereview.chromium.org/7237030/diff/7001/chrome/browser/ui/webui/javascript2webui.js File chrome/browser/ui/webui/javascript2webui.js (left): http://codereview.chromium.org/7237030/diff/7001/chrome/browser/ui/webui/javascript2webui.js#oldcode11 chrome/browser/ui/webui/javascript2webui.js:11: var outputfile = arguments[3]; outputFile http://codereview.chromium.org/7237030/diff/7001/chrome/browser/ui/webui/javascript2webui.js#oldcode12 chrome/browser/ui/webui/javascript2webui.js:12: var prevfuncs ...
9 years, 5 months ago (2011-07-07 19:26:28 UTC) #3
Sheridan Rawlins
Mike, can you take a look from a JS readability standpoint? http://codereview.chromium.org/7237030/diff/7001/chrome/browser/ui/webui/javascript2webui.js File chrome/browser/ui/webui/javascript2webui.js (left): ...
9 years, 5 months ago (2011-07-07 23:39:23 UTC) #4
Mike Mammarella
Two small comments. I'll let James look more thoroughly. http://codereview.chromium.org/7237030/diff/12001/chrome/test/data/webui/test_api.js File chrome/test/data/webui/test_api.js (right): http://codereview.chromium.org/7237030/diff/12001/chrome/test/data/webui/test_api.js#newcode48 chrome/test/data/webui/test_api.js:48: ...
9 years, 5 months ago (2011-07-07 23:48:07 UTC) #5
Sheridan Rawlins
Thanks, Mike. http://codereview.chromium.org/7237030/diff/12001/chrome/test/data/webui/test_api.js File chrome/test/data/webui/test_api.js (right): http://codereview.chromium.org/7237030/diff/12001/chrome/test/data/webui/test_api.js#newcode48 chrome/test/data/webui/test_api.js:48: throw new Error('Test Error. Actual length: ' ...
9 years, 5 months ago (2011-07-08 00:02:05 UTC) #6
James Hawkins
You're going to want to +pawel for the test file changes. http://codereview.chromium.org/7237030/diff/12001/chrome/browser/ui/webui/options/options_browsertest.cc File chrome/browser/ui/webui/options/options_browsertest.cc (right): ...
9 years, 5 months ago (2011-07-08 00:03:33 UTC) #7
Sheridan Rawlins
As James and I discussed, this is an overhaul to move to declarative-style generation much ...
9 years, 5 months ago (2011-07-08 22:45:48 UTC) #8
Evan Stade
reviewed js files for style http://codereview.chromium.org/7237030/diff/12020/chrome/test/data/webui/options.js File chrome/test/data/webui/options.js (right): http://codereview.chromium.org/7237030/diff/12020/chrome/test/data/webui/options.js#newcode35 chrome/test/data/webui/options.js:35: 'fetchPrefs': function() { I ...
9 years, 5 months ago (2011-07-08 23:04:46 UTC) #9
Sheridan Rawlins
http://codereview.chromium.org/7237030/diff/12020/chrome/test/data/webui/options.js File chrome/test/data/webui/options.js (right): http://codereview.chromium.org/7237030/diff/12020/chrome/test/data/webui/options.js#newcode35 chrome/test/data/webui/options.js:35: 'fetchPrefs': function() { On 2011/07/08 23:04:46, Evan Stade wrote: ...
9 years, 5 months ago (2011-07-08 23:47:24 UTC) #10
Sheridan Rawlins
Pawel, can you bless the portions in chrome/test?
9 years, 5 months ago (2011-07-09 00:21:00 UTC) #11
Evan Stade
great documentation http://codereview.chromium.org/7237030/diff/14009/chrome/test/data/webui/test_api.js File chrome/test/data/webui/test_api.js (right): http://codereview.chromium.org/7237030/diff/14009/chrome/test/data/webui/test_api.js#newcode116 chrome/test/data/webui/test_api.js:116: Mock4JS.verifyAllMocks(); wrong indent http://codereview.chromium.org/7237030/diff/14009/chrome/test/data/webui/test_api.js#newcode123 chrome/test/data/webui/test_api.js:123: * @param ...
9 years, 5 months ago (2011-07-11 18:33:55 UTC) #12
Sheridan Rawlins
http://codereview.chromium.org/7237030/diff/14009/chrome/test/data/webui/test_api.js File chrome/test/data/webui/test_api.js (right): http://codereview.chromium.org/7237030/diff/14009/chrome/test/data/webui/test_api.js#newcode116 chrome/test/data/webui/test_api.js:116: Mock4JS.verifyAllMocks(); On 2011/07/11 18:33:57, Evan Stade wrote: > wrong ...
9 years, 5 months ago (2011-07-11 20:36:08 UTC) #13
sky
http://codereview.chromium.org/7237030/diff/18001/chrome/browser/ui/webui/web_ui_browsertest.cc File chrome/browser/ui/webui/web_ui_browsertest.cc (right): http://codereview.chromium.org/7237030/diff/18001/chrome/browser/ui/webui/web_ui_browsertest.cc#newcode123 chrome/browser/ui/webui/web_ui_browsertest.cc:123: void WebUIBrowserTest::BrowsePreload(const GURL& browse_to, position of methods should match ...
9 years, 5 months ago (2011-07-11 20:50:21 UTC) #14
Sheridan Rawlins
http://codereview.chromium.org/7237030/diff/18001/chrome/browser/ui/webui/web_ui_browsertest.cc File chrome/browser/ui/webui/web_ui_browsertest.cc (right): http://codereview.chromium.org/7237030/diff/18001/chrome/browser/ui/webui/web_ui_browsertest.cc#newcode123 chrome/browser/ui/webui/web_ui_browsertest.cc:123: void WebUIBrowserTest::BrowsePreload(const GURL& browse_to, On 2011/07/11 20:50:22, sky wrote: ...
9 years, 5 months ago (2011-07-11 22:22:41 UTC) #15
sky
LGTM http://codereview.chromium.org/7237030/diff/18002/chrome/test/test_navigation_observer.cc File chrome/test/test_navigation_observer.cc (right): http://codereview.chromium.org/7237030/diff/18002/chrome/test/test_navigation_observer.cc#newcode31 chrome/test/test_navigation_observer.cc:31: TestNavigationObserver::TestNavigationObserver( nit: order of methods doesn't match header. ...
9 years, 5 months ago (2011-07-11 22:47:42 UTC) #16
Evan Stade
lgtm the code i reviewed
9 years, 5 months ago (2011-07-11 22:52:16 UTC) #17
Sheridan Rawlins
http://codereview.chromium.org/7237030/diff/18002/chrome/test/test_navigation_observer.cc File chrome/test/test_navigation_observer.cc (right): http://codereview.chromium.org/7237030/diff/18002/chrome/test/test_navigation_observer.cc#newcode31 chrome/test/test_navigation_observer.cc:31: TestNavigationObserver::TestNavigationObserver( On 2011/07/11 22:47:42, sky wrote: > nit: order ...
9 years, 5 months ago (2011-07-12 04:37:48 UTC) #18
Paweł Hajdan Jr.
9 years, 5 months ago (2011-07-19 21:07:27 UTC) #19
Tiny nit.

http://codereview.chromium.org/7237030/diff/25001/chrome/test/test_navigation...
File chrome/test/test_navigation_observer.cc (right):

http://codereview.chromium.org/7237030/diff/25001/chrome/test/test_navigation...
chrome/test/test_navigation_observer.cc:87: assert(false);
ADD_FAILURE please? We don't use assert in the Chromite land.

Powered by Google App Engine
This is Rietveld 408576698