Chromium Code Reviews| Index: chrome/browser/ui/webui/web_ui_browsertest.h |
| diff --git a/chrome/browser/ui/webui/web_ui_browsertest.h b/chrome/browser/ui/webui/web_ui_browsertest.h |
| index 001ae7a8483efa43a75b6f7e4f3cd27f52e372d2..0d31b181f074a31af58d8db59ecb2ca02ee8713c 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 CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_ |
| -#define CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_ |
| +#ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ |
| +#define CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ |
| #pragma once |
| #include <string> |
| @@ -23,6 +23,54 @@ class WebUIMessageHandler; |
| ASSERT_TRUE(RunJavascriptTest(#y)); \ |
| } |
| +#define WEB_UI_BROWSER_TEST_JS_(test_case_name, test_name, parent_class, \ |
|
Paweł Hajdan Jr.
2011/05/28 08:03:55
Wait, are you trying to do parametrized browser te
Sheridan Rawlins
2011/05/28 14:26:30
Thanks for the drive by, Pawel. So here's the jus
Paweł Hajdan Jr.
2011/05/30 17:17:58
Well, it wasn't really about multiple macros, but
Sheridan Rawlins
2011/05/31 23:15:00
Short answer: This macro seemed to be the best sol
|
| + parent_id, assertion, jsfile) \ |
| +class GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\ |
| + : public parent_class, public ::testing::WithParamInterface<std::string> {\ |
| + public:\ |
| + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\ |
| + protected:\ |
| + virtual void PrepForJSOnMainThread();\ |
| + virtual void RunTestOnMainThread() {\ |
| + AddLibrary(FilePath(jsfile));\ |
| + PrepForJSOnMainThread();\ |
| + assertion(RunJavascriptTest(GetParam()));\ |
| + }\ |
| + private:\ |
| + static ::testing::internal::TestMetaFactory< \ |
| + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)> meta_factory_; \ |
| + virtual void TestBody() {}\ |
| + static int const gtest_registering_dummy_;\ |
| + GTEST_DISALLOW_COPY_AND_ASSIGN_(\ |
| + GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\ |
| +};\ |
| +\ |
| +::testing::internal::TestMetaFactory< \ |
| + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>\ |
| + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::meta_factory_; \ |
| +int const GTEST_TEST_CLASS_NAME_(test_case_name, \ |
| + test_name)::gtest_registering_dummy_ = \ |
| + ::parent_class::AddJSToRegistry(\ |
| + FilePath(jsfile),\ |
| + #test_case_name, #test_name, "", "",\ |
| + (parent_id),\ |
| + parent_class::SetUpTestCase,\ |
| + parent_class::TearDownTestCase,\ |
| + &meta_factory_);\ |
| +void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::PrepForJSOnMainThread() |
| + |
| +#define WEB_UI_BROWSER_TEST_JS_TRUE(test_fixture, test_name, jsfile) \ |
| + WEB_UI_BROWSER_TEST_JS_(test_fixture, test_name, test_fixture, \ |
| + ::testing::internal::GetTypeId<test_fixture>(), \ |
| + ASSERT_TRUE, jsfile) |
| + |
| +#define WEB_UI_BROWSER_TEST_JS_FALSE(test_fixture, test_name, jsfile) \ |
| + WEB_UI_BROWSER_TEST_JS_(test_fixture, test_name, test_fixture, \ |
| + ::testing::internal::GetTypeId<test_fixture>(), \ |
| + ASSERT_FALSE, jsfile) |
| + |
| +#define WEB_UI_BROWSER_TEST_JS WEB_UI_BROWSER_TEST_JS_TRUE |
| + |
| // The runner of WebUI javascript based tests. |
| // See chrome/test/data/webui/test_api.js for the javascript side test API's. |
| // |
| @@ -69,9 +117,19 @@ class WebUIBrowserTest : public InProcessBrowserTest { |
| // Returns a mock WebUI object under test (if any). |
| virtual WebUIMessageHandler* GetMockMessageHandler(); |
| + static int AddJSToRegistry( |
| + const FilePath& library_path, |
| + const char* test_case_name, const char* name, |
| + const char* type_param, |
| + const char* value_param, |
| + ::testing::internal::TypeId fixture_class_id, |
| + ::testing::internal::SetUpTestCaseFunc set_up_tc, |
| + ::testing::internal::TearDownTestCaseFunc tear_down_tc, |
| + ::testing::internal::TestMetaFactoryBase<std::string>* meta_factory); |
| + |
| private: |
| // Builds a string containing all added javascript libraries. |
| - void BuildJavascriptLibraries(std::string* content); |
| + void BuildJavascriptLibraries(std::string* content) const; |
| // Builds a string with a call to the runTest JS function, passing the |
| // given test and its arguments. |
| @@ -95,7 +153,7 @@ class WebUIBrowserTest : public InProcessBrowserTest { |
| FilePath test_data_directory_; |
| // User added libraries |
| - std::vector<FilePath> user_libraries; |
| + std::vector<FilePath> user_libraries_; |
| }; |
| -#endif // CONTENT_BROWSER_WEBUI_WEB_UI_BROWSERTEST_H_ |
| +#endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ |