By moving the call to Load() up in SearchProvider::Start(), we are giving a chance...
[chromium-blink-merge.git] / content / browser / browser_plugin / test_browser_plugin_guest.h
blob81fe77f4d78cd55b48965d738aab9322156aae50
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.
5 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_TEST_BROWSER_PLUGIN_GUEST_H_
6 #define CONTENT_BROWSER_BROWSER_PLUGIN_TEST_BROWSER_PLUGIN_GUEST_H_
8 #include "base/compiler_specific.h"
9 #include "base/process_util.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest.h"
11 #include "content/public/test/test_utils.h"
12 #include "ui/gfx/size.h"
14 namespace content {
16 class RenderProcessHost;
17 class RenderViewHost;
18 class WebContentsImpl;
20 // Test class for BrowserPluginGuest.
22 // Provides utilities to wait for certain state/messages in BrowserPluginGuest
23 // to be used in tests.
24 class TestBrowserPluginGuest : public BrowserPluginGuest {
25 public:
26 TestBrowserPluginGuest(int instance_id,
27 WebContentsImpl* web_contents,
28 const BrowserPluginHostMsg_CreateGuest_Params& params);
29 virtual ~TestBrowserPluginGuest();
31 WebContentsImpl* web_contents() const;
33 // NotificationObserver method override.
34 virtual void Observe(int type,
35 const NotificationSource& source,
36 const NotificationDetails& details) OVERRIDE;
38 // Overridden methods from BrowserPluginGuest to intercept in test objects.
39 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
40 virtual void OnHandleInputEvent(int instance_id,
41 const gfx::Rect& guest_window_rect,
42 const WebKit::WebInputEvent* event) OVERRIDE;
43 virtual void OnSetFocus(int instance_id, bool focused) OVERRIDE;
44 virtual void OnTakeFocus(bool reverse) OVERRIDE;
45 virtual void OnReload(int instance_id) OVERRIDE;
46 virtual void OnStop(int instance_id) OVERRIDE;
47 virtual void SetDamageBuffer(
48 const BrowserPluginHostMsg_ResizeGuest_Params& params) OVERRIDE;
49 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE;
51 // Test utilities to wait for a event we are interested in.
52 // Waits until UpdateRect message is sent from the guest, meaning it is
53 // ready/rendered.
54 void WaitForUpdateRectMsg();
55 void ResetUpdateRectCount();
56 // Waits until a guest receives a damage buffer of the specified |size|.
57 void WaitForDamageBufferWithSize(const gfx::Size& size);
58 // Waits for focus to reach this guest.
59 void WaitForFocus();
60 // Waits for blur to reach this guest.
61 void WaitForBlur();
62 // Waits for focus to move out of this guest.
63 void WaitForAdvanceFocus();
64 // Waits until the guest is hidden.
65 void WaitUntilHidden();
66 // Waits until guest exits.
67 void WaitForExit();
68 // Waits until a reload request is observed.
69 void WaitForReload();
70 // Waits until a stop request is observed.
71 void WaitForStop();
72 // Waits until input is observed.
73 void WaitForInput();
74 // Waits until 'loadstop' is observed.
75 void WaitForLoadStop();
76 // Waits until UpdateRect with a particular |view_size| is observed.
77 void WaitForViewSize(const gfx::Size& view_size);
79 private:
80 // Overridden methods from BrowserPluginGuest to intercept in test objects.
81 virtual void SendMessageToEmbedder(IPC::Message* msg) OVERRIDE;
83 int update_rect_count_;
84 int damage_buffer_call_count_;
85 bool exit_observed_;
86 bool focus_observed_;
87 bool blur_observed_;
88 bool advance_focus_observed_;
89 bool was_hidden_observed_;
90 bool stop_observed_;
91 bool reload_observed_;
92 bool set_damage_buffer_observed_;
93 bool input_observed_;
94 bool load_stop_observed_;
95 gfx::Size last_view_size_observed_;
96 gfx::Size expected_auto_view_size_;
98 // For WaitForDamageBufferWithSize().
99 bool waiting_for_damage_buffer_with_size_;
100 gfx::Size expected_damage_buffer_size_;
101 gfx::Size last_damage_buffer_size_;
103 scoped_refptr<MessageLoopRunner> send_message_loop_runner_;
104 scoped_refptr<MessageLoopRunner> crash_message_loop_runner_;
105 scoped_refptr<MessageLoopRunner> focus_message_loop_runner_;
106 scoped_refptr<MessageLoopRunner> blur_message_loop_runner_;
107 scoped_refptr<MessageLoopRunner> advance_focus_message_loop_runner_;
108 scoped_refptr<MessageLoopRunner> was_hidden_message_loop_runner_;
109 scoped_refptr<MessageLoopRunner> reload_message_loop_runner_;
110 scoped_refptr<MessageLoopRunner> stop_message_loop_runner_;
111 scoped_refptr<MessageLoopRunner> damage_buffer_message_loop_runner_;
112 scoped_refptr<MessageLoopRunner> input_message_loop_runner_;
113 scoped_refptr<MessageLoopRunner> load_stop_message_loop_runner_;
114 scoped_refptr<MessageLoopRunner> auto_view_size_message_loop_runner_;
116 DISALLOW_COPY_AND_ASSIGN(TestBrowserPluginGuest);
119 } // namespace content
121 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_TEST_BROWSER_PLUGIN_GUEST_H_