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

Unified Diff: chrome/browser/ui/webui/web_ui_browsertest.cc

Issue 7087014: Support automatic javascript test registry in gtest when creating WebUI tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove need for secondary javascript script by parsing the ast in python. Created 9 years, 6 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/web_ui_browsertest.cc
diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc
index 66815d09790993d9a732771998e07d185b67631d..4e8e959572ec49c61e3ef431958e78055dde4307 100644
--- a/chrome/browser/ui/webui/web_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/web_ui_browsertest.cc
@@ -11,6 +11,7 @@
#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"
@@ -21,9 +22,8 @@
namespace {
-const FilePath::StringType kWebUILibraryJS =
- FILE_PATH_LITERAL("test_api.js");
-const FilePath::StringType kWebUITestFolder = FILE_PATH_LITERAL("webui");
+const FilePath::CharType kWebUILibraryJS[] = FILE_PATH_LITERAL("test_api.js");
+const FilePath::CharType kWebUITestFolder[] = FILE_PATH_LITERAL("webui");
base::LazyInstance<std::vector<std::string> > error_messages_(
base::LINKER_INITIALIZED);
@@ -244,3 +244,45 @@ 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"

Powered by Google App Engine
This is Rietveld 408576698