| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_WEBUI_WEB_UI_HANDLER_BROWSERTEST_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_WEBUI_WEB_UI_HANDLER_BROWSERTEST_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "content/browser/webui/web_ui.h" | 11 #include "content/browser/webui/web_ui.h" |
| 12 #include "content/common/notification_observer.h" |
| 12 | 13 |
| 13 // This class registers test framework specific handlers on WebUI objects. | 14 // This class registers test framework specific handlers on WebUI objects. |
| 14 class WebUITestHandler : public WebUIMessageHandler { | 15 class WebUITestHandler : public WebUIMessageHandler, |
| 16 public NotificationObserver { |
| 15 public: | 17 public: |
| 16 // Runs a string of javascript. Returns pass fail. | 18 // Runs a string of javascript. Returns pass fail. |
| 17 bool RunJavascript(const std::string& js_test, bool is_test); | 19 bool RunJavascript(const std::string& js_test, bool is_test); |
| 18 | 20 |
| 19 protected: | 21 private: |
| 20 // WebUI handlers which deliver results to any waiting message loops. | |
| 21 // |args| is currently ignored. | |
| 22 void HandlePass(const ListValue* args); | |
| 23 void HandleFail(const ListValue* args); | |
| 24 | |
| 25 // WebUIMessageHandler overrides. | 22 // WebUIMessageHandler overrides. |
| 26 // Add test handlers to the current WebUI object. | 23 // Add test handlers to the current WebUI object. |
| 27 virtual void RegisterMessages(); | 24 virtual void RegisterMessages() {} |
| 28 | 25 |
| 29 private: | 26 // From NotificationObserver. |
| 27 virtual void Observe(NotificationType type, |
| 28 const NotificationSource& source, |
| 29 const NotificationDetails& details) OVERRIDE; |
| 30 |
| 30 // Runs a message loop until test finishes. Returns the result of the test. | 31 // Runs a message loop until test finishes. Returns the result of the test. |
| 31 bool WaitForResult(); | 32 bool WaitForResult(); |
| 32 | 33 |
| 33 // Pass fail result of current tests. | 34 // Pass fail result of current tests. |
| 34 bool test_succeeded_; | 35 bool test_succeeded_; |
| 35 | 36 |
| 36 // Waiting for a test to finish. | 37 // Waiting for a test to finish. |
| 37 bool is_waiting_; | 38 bool is_waiting_; |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_HANDLER_BROWSERTEST_H_ | 41 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ |
| OLD | NEW |