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 50876783ec58f35f14291ee6a767b5da6e292ee6..1a293cad83baee522a50764e7ae23be9f5b9e774 100644 |
--- a/chrome/browser/ui/webui/web_ui_browsertest.h |
+++ b/chrome/browser/ui/webui/web_ui_browsertest.h |
@@ -21,14 +21,32 @@ namespace base { |
class Value; |
} |
-// This macro simplifies the declaration of simple javascript unit tests. |
+// These macros simplify the declaration of simple javascript unit tests. |
Sheridan Rawlins
2011/09/09 15:47:50
We shouldn't need any WEB_UI macros.
These macros
flackr
2011/09/15 18:41:52
Done.
|
// Use: |
// WEB_UI_UNITTEST_F(MyWebUIPageTest, myJavascriptUnittest); |
+// WEB_UI_UNITTEST_F1(MyWebUIPageTest, myJavascriptUnittest, myArg); |
+// WEB_UI_ASYNC_UNITTEST_F(MyWebUIPageTest, myJavascriptUnittest); |
+// WEB_UI_ASYNC_UNITTEST_F1(MyWebUIPageTest, myJavascriptUnittest, myArg); |
#define WEB_UI_UNITTEST_F(x, y) \ |
IN_PROC_BROWSER_TEST_F(x, y) { \ |
ASSERT_TRUE(RunJavascriptTest(#y)); \ |
} |
+#define WEB_UI_UNITTEST_F1(x, y, z) \ |
+ IN_PROC_BROWSER_TEST_F(x, y) { \ |
+ ASSERT_TRUE(RunJavascriptTest(#y, z)); \ |
+ } |
+ |
+#define WEB_UI_ASYNC_UNITTEST_F(x, y) \ |
+ IN_PROC_BROWSER_TEST_F(x, y) { \ |
+ ASSERT_TRUE(RunJavascriptAsyncTest(#y)); \ |
+ } |
+ |
+#define WEB_UI_ASYNC_UNITTEST_F1(x, y, z) \ |
+ IN_PROC_BROWSER_TEST_F(x, y) { \ |
+ ASSERT_TRUE(RunJavascriptAsyncTest(#y, z)); \ |
+ } |
+ |
// The runner of WebUI javascript based tests. |
// See chrome/test/data/webui/test_api.js for the javascript side test API's. |
// |
@@ -37,7 +55,8 @@ class Value; |
// and the lone test within this class. |
class WebUIBrowserTest |
: public InProcessBrowserTest, |
- public TestNavigationObserver::JsInjectionReadyObserver { |
+ public TestNavigationObserver::JsInjectionReadyObserver, |
+ public NotificationObserver { |
public: |
typedef std::vector<const base::Value*> ConstValueVector; |
virtual ~WebUIBrowserTest(); |
@@ -76,7 +95,7 @@ class WebUIBrowserTest |
const ConstValueVector& test_arguments); |
// Runs a test that may include calls to functions in test_api.js, and waits |
- // for call to asyncTestDone(). Takes ownership of Value arguments. |
+ // for call to testDone(). Takes ownership of Value arguments. |
bool RunJavascriptAsyncTest(const std::string& test_name); |
bool RunJavascriptAsyncTest(const std::string& test_name, |
base::Value* arg); |
@@ -125,6 +144,12 @@ class WebUIBrowserTest |
// Tear down override for |kDummyURL|. |
virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; |
+ // Observes the next HtmlDialog to be created. |
+ virtual void ObserveNextHtmlDialog(); |
+ |
+ // Wait for HtmlDialog to have loaded. |
+ virtual void WaitForHtmlDialogLoad(); |
+ |
// Returns a mock WebUI object under test (if any). |
virtual WebUIMessageHandler* GetMockMessageHandler(); |
@@ -136,6 +161,11 @@ class WebUIBrowserTest |
// TestNavigationObserver::JsInjectionReadyObserver implementation. |
virtual void OnJsInjectionReady(RenderViewHost* render_view_host) OVERRIDE; |
+ // NotificationObserver implementation. |
+ virtual void Observe(int type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details); |
+ |
// Builds a string containing all added javascript libraries. |
void BuildJavascriptLibraries(string16* content); |
@@ -178,6 +208,17 @@ class WebUIBrowserTest |
// PreloadJavascriptLibraries(). |
std::string preload_test_fixture_; |
std::string preload_test_name_; |
+ |
+ // The WebUI instance used for testing. |
+ WebUI* web_ui_instance_; |
+ |
+ // Track whether the custom WebUI instance has loaded. |
+ bool web_ui_instance_ready_; |
+ |
+ // Track if a message loop is running waiting on notification. |
+ bool message_loop_running_; |
+ |
+ NotificationRegistrar registrar_; |
}; |
#endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ |