OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SHELL_LAYOUT_TEST_CONTROLLER_HOST_H_ | 5 #ifndef CONTENT_SHELL_WEBKIT_TEST_RUNNER_HOST_H_ |
6 #define CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_HOST_H_ | 6 #define CONTENT_SHELL_WEBKIT_TEST_RUNNER_HOST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
12 #include "content/public/browser/render_view_host_observer.h" | 12 #include "content/public/browser/render_view_host_observer.h" |
13 | 13 |
14 class SkBitmap; | 14 class SkBitmap; |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 class LayoutTestControllerHost : public RenderViewHostObserver { | 18 class WebKitTestRunnerHost : public RenderViewHostObserver { |
19 public: | 19 public: |
20 static LayoutTestControllerHost* FromRenderViewHost( | 20 static WebKitTestRunnerHost* FromRenderViewHost( |
21 RenderViewHost* render_view_host); | 21 RenderViewHost* render_view_host); |
22 | 22 |
23 // Initialize the LayoutTestControllerHost for a given test. | 23 // Initialize the WebKitTestRunnerHost for a given test. |
24 static void Init(const std::string& expected_pixel_hash); | 24 static void Init(const std::string& expected_pixel_hash); |
25 | 25 |
26 explicit LayoutTestControllerHost(RenderViewHost* render_view_host); | 26 explicit WebKitTestRunnerHost(RenderViewHost* render_view_host); |
27 virtual ~LayoutTestControllerHost(); | 27 virtual ~WebKitTestRunnerHost(); |
28 | 28 |
29 bool should_stay_on_page_after_handling_before_unload() const { | 29 bool should_stay_on_page_after_handling_before_unload() const { |
30 return should_stay_on_page_after_handling_before_unload_; | 30 return should_stay_on_page_after_handling_before_unload_; |
31 } | 31 } |
32 | 32 |
33 // RenderViewHostObserver implementation. | 33 // RenderViewHostObserver implementation. |
34 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 34 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
35 | 35 |
36 private: | 36 private: |
37 void CaptureDump(); | 37 void CaptureDump(); |
38 void TimeoutHandler(); | 38 void TimeoutHandler(); |
39 | 39 |
40 // Message handlers. | 40 // Message handlers. |
41 void OnDidFinishLoad(); | 41 void OnDidFinishLoad(); |
42 void OnTextDump(const std::string& dump); | 42 void OnTextDump(const std::string& dump); |
43 void OnImageDump(const std::string& actual_pixel_hash, const SkBitmap& image); | 43 void OnImageDump(const std::string& actual_pixel_hash, const SkBitmap& image); |
44 | 44 |
45 // testRunner handlers. | 45 // testRunner handlers. |
46 void OnNotifyDone(); | 46 void OnNotifyDone(); |
47 void OnDumpAsText(); | 47 void OnDumpAsText(); |
48 void OnDumpChildFramesAsText(); | 48 void OnDumpChildFramesAsText(); |
49 void OnSetPrinting(); | 49 void OnSetPrinting(); |
50 void OnSetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page); | 50 void OnSetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page); |
51 void OnWaitUntilDone(); | 51 void OnWaitUntilDone(); |
52 | 52 |
53 void OnNotImplemented(const std::string& object_name, | 53 void OnNotImplemented(const std::string& object_name, |
54 const std::string& method_name); | 54 const std::string& method_name); |
55 | 55 |
56 static std::map<RenderViewHost*, LayoutTestControllerHost*> controllers_; | 56 static std::map<RenderViewHost*, WebKitTestRunnerHost*> controllers_; |
57 static std::string expected_pixel_hash_; | 57 static std::string expected_pixel_hash_; |
58 | 58 |
59 bool captured_dump_; | 59 bool captured_dump_; |
60 | 60 |
61 bool dump_as_text_; | 61 bool dump_as_text_; |
62 bool dump_child_frames_; | 62 bool dump_child_frames_; |
63 bool is_printing_; | 63 bool is_printing_; |
64 bool should_stay_on_page_after_handling_before_unload_; | 64 bool should_stay_on_page_after_handling_before_unload_; |
65 bool wait_until_done_; | 65 bool wait_until_done_; |
66 | 66 |
67 base::CancelableClosure watchdog_; | 67 base::CancelableClosure watchdog_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(LayoutTestControllerHost); | 69 DISALLOW_COPY_AND_ASSIGN(WebKitTestRunnerHost); |
70 }; | 70 }; |
71 | 71 |
72 } // namespace content | 72 } // namespace content |
73 | 73 |
74 #endif // CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_HOST_H_ | 74 #endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_HOST_H_ |
OLD | NEW |