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 CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "content/browser/webui/web_ui.h" | 10 #include "content/browser/webui/web_ui.h" |
11 #include "content/common/notification_observer.h" | 11 #include "content/common/notification_observer.h" |
12 | 12 |
13 namespace base { | |
14 | |
15 class ListValue; | |
16 | |
17 } // namespace base | |
18 | |
13 // This class registers test framework specific handlers on WebUI objects. | 19 // This class registers test framework specific handlers on WebUI objects. |
14 class WebUITestHandler : public WebUIMessageHandler, | 20 class WebUITestHandler : public WebUIMessageHandler, |
15 public NotificationObserver { | 21 public NotificationObserver { |
16 public: | 22 public: |
23 WebUITestHandler(); | |
24 | |
17 // Sends a message through |preload_host| with the |js_text| to preload at the | 25 // Sends a message through |preload_host| with the |js_text| to preload at the |
18 // appropriate time before the onload call is made. | 26 // appropriate time before the onload call is made. |
19 void PreloadJavaScript(const string16& js_text, | 27 void PreloadJavaScript(const string16& js_text, |
20 RenderViewHost* preload_host); | 28 RenderViewHost* preload_host); |
21 | 29 |
22 // Runs |js_text| in this object's WebUI frame. Does not wait for any result. | 30 // Runs |js_text| in this object's WebUI frame. Does not wait for any result. |
23 void RunJavaScript(const string16& js_text); | 31 void RunJavaScript(const string16& js_text); |
24 | 32 |
25 // Runs |js_text| in this object's WebUI frame. Waits for result, logging an | 33 // Runs |js_text| in this object's WebUI frame. Waits for result, logging an |
26 // error message on failure. Returns test pass/fail. | 34 // error message on failure. Returns test pass/fail. |
27 bool RunJavaScriptTestWithResult(const string16& js_text); | 35 bool RunJavaScriptTestWithResult(const string16& js_text); |
28 | 36 |
29 private: | 37 private: |
30 // WebUIMessageHandler overrides. | 38 // WebUIMessageHandler overrides. |
31 // Add test handlers to the current WebUI object. | 39 // Add test handlers to the current WebUI object. |
32 virtual void RegisterMessages() OVERRIDE {} | 40 virtual void RegisterMessages() OVERRIDE; |
41 | |
42 // Receives testResult messages. | |
43 void HandleTestResult(const base::ListValue* test_result); | |
33 | 44 |
34 // From NotificationObserver. | 45 // From NotificationObserver. |
35 virtual void Observe(int type, | 46 virtual void Observe(int type, |
36 const NotificationSource& source, | 47 const NotificationSource& source, |
37 const NotificationDetails& details) OVERRIDE; | 48 const NotificationDetails& details) OVERRIDE; |
38 | 49 |
39 // Runs a message loop until test finishes. Returns the result of the test. | 50 // Runs a message loop until test finishes. Returns the result of the |
51 // test. | |
40 bool WaitForResult(); | 52 bool WaitForResult(); |
41 | 53 |
42 // Pass fail result of current tests. | 54 // Received test pass/fail; |
55 bool test_done_; | |
56 | |
57 // Pass fail result of current test. | |
43 bool test_succeeded_; | 58 bool test_succeeded_; |
44 | 59 |
60 // Test code finished executing. | |
mmenke
2011/08/12 14:28:17
nit: Might want a note that if the test is unable
Sheridan Rawlins
2011/08/12 18:02:09
Done.
| |
61 bool run_test_done_; | |
62 | |
63 // Test code was able to execute successfully. This is *NOT* the test | |
64 // pass/fail. | |
65 bool run_test_succeeded_; | |
66 | |
45 // Waiting for a test to finish. | 67 // Waiting for a test to finish. |
46 bool is_waiting_; | 68 bool is_waiting_; |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(WebUITestHandler); | |
47 }; | 71 }; |
48 | 72 |
49 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ | 73 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_TEST_HANDLER_H_ |
OLD | NEW |