diff options
author | scr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-18 17:47:35 +0000 |
---|---|---|
committer | scr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-18 17:47:35 +0000 |
commit | 0395d7a8d1d6c4e969fffd44edf0ad2bb0f29731 (patch) | |
tree | 625b62ab8465fb0c7e431ef150564d6ca19bb54b | |
parent | ce24f5b5407b15f0500392731064f95e7217697f (diff) | |
download | chromium_src-0395d7a8d1d6c4e969fffd44edf0ad2bb0f29731.zip chromium_src-0395d7a8d1d6c4e969fffd44edf0ad2bb0f29731.tar.gz chromium_src-0395d7a8d1d6c4e969fffd44edf0ad2bb0f29731.tar.bz2 |
Revert 89605 - Support automatic javascript test registry in gtest when creating WebUI tests.
The goal was to support something as simple as the following, where the tests in the
javascript files would be 1st class GTESTs, supporting FLAKY_, DISABLED_, etc, and
registered at linker_initialization time.
WEB_UI_BROWSER_TEST_JS(WebUIBrowserTest, TestJSPass,
FILE_PATH_LITERAL("sample_passing.js")) {
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL));
}
WEB_UI_BROWSER_TEST_JS_FALSE(WebUIBrowserTest, TestJSFail,
FILE_PATH_LITERAL("sample_failing.js")) {
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL));
}
http://www.chromium.org/Home/domui-testing
In order to support linker init time, I had to modify path_service to support
Unregistration, and chrome_paths to allow multiple invocations.
BUG=82437
R=estade@chromium.org,jhawkins@chromium.org
TEST=browser_tests --gtest_filter=WebUIBrowserTest*
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=89453
Review URL: http://codereview.chromium.org/7087014
TBR=scr@chromium.org
Review URL: http://codereview.chromium.org/7189052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89607 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | chrome/browser/ui/webui/web_ui_browsertest.cc | 48 | ||||
-rw-r--r-- | chrome/browser/ui/webui/web_ui_browsertest.h | 6 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 21 | ||||
-rw-r--r-- | chrome/test/data/webui/sample_pass.js | 17 | ||||
-rw-r--r-- | tools/gypv8sh.py | 74 |
6 files changed, 6 insertions, 161 deletions
@@ -46,7 +46,6 @@ v8.log /chrome/app/theme/google_chrome /chrome/browser/autofill/internal /chrome/browser/extensions/default_extensions/chromeos -/chrome/browser/ui/webui/web_ui_browsertest-inl.h /chrome/installer/linux /chrome/installer/mac/internal /chrome/installer/mac/third_party/xz/xz diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc index 4e8e959..66815d0 100644 --- a/chrome/browser/ui/webui/web_ui_browsertest.cc +++ b/chrome/browser/ui/webui/web_ui_browsertest.cc @@ -11,7 +11,6 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" #include "chrome/test/ui_test_utils.h" @@ -22,8 +21,9 @@ namespace { -const FilePath::CharType kWebUILibraryJS[] = FILE_PATH_LITERAL("test_api.js"); -const FilePath::CharType kWebUITestFolder[] = FILE_PATH_LITERAL("webui"); +const FilePath::StringType kWebUILibraryJS = + FILE_PATH_LITERAL("test_api.js"); +const FilePath::StringType kWebUITestFolder = FILE_PATH_LITERAL("webui"); base::LazyInstance<std::vector<std::string> > error_messages_( base::LINKER_INITIALIZED); @@ -244,45 +244,3 @@ IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest, TestFailsFast) { EXPECT_FATAL_FAILURE(RunJavascriptTestNoReturn("FAILS_BogusFunctionName"), "WebUITestHandler::Observe"); } - - -// This test framework is used in the generated tests, which are included -// below. WebUIBrowserTest requires being on a page which is a WebUI page. Using -// the TestChromeWebUIFactory, we use a dummy URL |kChromeTestBrowserTestPass|, -// which we force to be a WebUI page. -class WebUIBrowserTestPass - : public WebUIBrowserTest, - public TestChromeWebUIFactory::WebUIProvider { - private: - // TestChromeWebUIFactory::WebUIProvider: - virtual WebUI* NewWebUI(TabContents* tab_contents, - const GURL& url) OVERRIDE { - return new WebUI(tab_contents); - } - - // InProcessBrowserTest: - virtual void SetUpOnMainThread() OVERRIDE { - WebUIBrowserTest::SetUpOnMainThread(); - ui_test_utils::NavigateToURL(browser(), - GURL(kChromeTestBrowserTestPass)); - } - - virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - WebUIBrowserTest::SetUpInProcessBrowserTestFixture(); - TestChromeWebUIFactory::AddFactoryOverride( - GURL(kChromeTestBrowserTestPass).host(), this); - } - - virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { - WebUIBrowserTest::TearDownInProcessBrowserTestFixture(); - TestChromeWebUIFactory::RemoveFactoryOverride( - GURL(kChromeTestBrowserTestPass).host()); - } - - static const char kChromeTestBrowserTestPass[]; -}; - -const char WebUIBrowserTestPass::kChromeTestBrowserTestPass[] = - "chrome://WebUIBrowserTestPass"; - -#include "chrome/browser/ui/webui/web_ui_browsertest-inl.h" diff --git a/chrome/browser/ui/webui/web_ui_browsertest.h b/chrome/browser/ui/webui/web_ui_browsertest.h index a8e9f96..001ae7a 100644 --- a/chrome/browser/ui/webui/web_ui_browsertest.h +++ b/chrome/browser/ui/webui/web_ui_browsertest.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ -#define CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ +#ifndef CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_ +#define CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_ #pragma once #include <string> @@ -98,4 +98,4 @@ class WebUIBrowserTest : public InProcessBrowserTest { std::vector<FilePath> user_libraries; }; -#endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ +#endif // CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_ diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index cc751b1..cf87f75 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2292,7 +2292,6 @@ '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', '../v8/tools/gyp/v8.gyp:v8', - '../v8/tools/gyp/v8.gyp:v8_shell', '../webkit/webkit.gyp:test_shell_test_support', # Runtime dependencies '../third_party/mesa/mesa.gyp:osmesa', @@ -2557,26 +2556,6 @@ '../content/renderer/render_widget_browsertest.h', '../content/renderer/v8_value_converter_browsertest.cc', ], - 'actions': [ - { - 'action_name': 'js2webui', - 'variables': { - 'gypv8sh': '../tools/gypv8sh.py', - 'js2webui': 'browser/ui/webui/javascript2webui.js', - }, - 'inputs': [ - '<(gypv8sh)', - '<(js2webui)', - '<!@(python <(gypv8sh) -i)', - ], - 'outputs': [ - '<!@(python <(gypv8sh) -o)', - ], - 'action': [ - 'python', '<(gypv8sh)', '-p', '<(PRODUCT_DIR)', '<(js2webui)', - ], - }, - ], 'conditions': [ ['chromeos==0', { 'sources/': [ diff --git a/chrome/test/data/webui/sample_pass.js b/chrome/test/data/webui/sample_pass.js deleted file mode 100644 index ca9b88c4..0000000 --- a/chrome/test/data/webui/sample_pass.js +++ /dev/null @@ -1,17 +0,0 @@ -// 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. - -// Sample tests that exercise the test JS library and show how this framework -// could be used to test the downloads page. -function testAssertFalse() { - assertFalse(false); -} - -function testAssertTrue() { - assertTrue(true); -} - -function testAssertEquals() { - assertEquals(5, 5, "fives"); -} diff --git a/tools/gypv8sh.py b/tools/gypv8sh.py deleted file mode 100644 index fddd6b2..0000000 --- a/tools/gypv8sh.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python -# 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. - -"""This script is used by chrome_tests.gypi's js2webui action to maintain the -argument lists and to generate inlinable tests. - -Usage: - python tools/gypv8sh.py -p product_dir path/to/javascript2webui.js - python tools/gypv8sh.py -t # print test_harnesses - python tools/gypv8sh.py -i # print inputs - python tools/gypv8sh.py -o # print outputs -""" - -try: - import json -except ImportError: - import simplejson as json -import optparse -import os -import subprocess -import sys - -# Please adjust the following to edit or add new javascript webui tests. -rules = [ - [ - 'WebUIBrowserTestPass', - 'test/data/webui/sample_pass.js', - 'browser/ui/webui/web_ui_browsertest-inl.h', - ], -] - -def main (): - """Run the program""" - # For options -t, -i, & -o, we print the "column" of the |rules|. We keep a - # set of indices to print in |print_rule_indices| and print them in sorted - # order if non-empty. - parser = optparse.OptionParser() - parser.set_usage( - "%prog [-v][-n] --product_dir PRODUCT_DIR -or- " - "%prog [-v][-n] (-i|-t|-o)") - parser.add_option('-v', '--verbose', action='store_true') - parser.add_option('-n', '--impotent', action='store_true', - help="don't execute; just print (as if verbose)") - parser.add_option( - '-p', '--product_dir', - help='for gyp to set the <(PRODUCT_DIR) for running v8_shell') - parser.add_option('-t', '--test_fixture', action='store_const', const=0, - dest='print_rule_index', help='print test_fixtures') - parser.add_option('-i', '--in', action='store_const', const=1, - dest='print_rule_index', help='print inputs') - parser.add_option('-o', '--out', action='store_const', const=2, - dest='print_rule_index', help='print outputs') - (opts, args) = parser.parse_args() - - if (opts.print_rule_index != None): - for rule in rules: - print rule[opts.print_rule_index] - else: - if not opts.product_dir: - parser.error("--product_dir option is required") - v8_shell = os.path.join(opts.product_dir, 'v8_shell') - jsfilename = args[0] - for rule in rules: - arguments = [jsfilename, rule[0], rule[1], os.path.basename(rule[1])] - cmd = [v8_shell, '-e', "arguments=" + json.dumps(arguments), jsfilename] - if opts.verbose or opts.impotent: - print cmd - if not opts.impotent: - sys.exit(subprocess.call(cmd, stdout=open(rule[2],'w+'))) - -if __name__ == '__main__': - sys.exit(main()) |