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