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_EMBEDDER_H_
6 #define CONTENT_BROWSER_BROWSER_PLUGIN_TEST_BROWSER_PLUGIN_EMBEDDER_H_
8 #include "base/compiler_specific.h"
9 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
10 #include "content/public/test/test_utils.h"
14 class BrowserPluginGuest
;
16 class WebContentsImpl
;
18 // Test class for BrowserPluginEmbedder.
20 // Provides utilities to wait for certain state/messages in
21 // BrowserPluginEmbedder to be used in tests.
22 class TestBrowserPluginEmbedder
: public BrowserPluginEmbedder
{
24 TestBrowserPluginEmbedder(WebContentsImpl
* web_contents
,
25 RenderViewHost
* render_view_host
);
26 virtual ~TestBrowserPluginEmbedder();
28 const ContainerInstanceMap
& guest_web_contents_for_testing() const {
29 return guest_web_contents_by_instance_id_
;
32 // Waits until at least one guest is added to this embedder.
33 void WaitForGuestAdded();
34 // Asks the renderer process for RenderViewHost at (|x|, |y|) and waits until
35 // the response arrives.
36 void WaitForRenderViewHostAtPosition(int x
, int y
);
37 RenderViewHost
* last_rvh_at_position_response() {
38 return last_rvh_at_position_response_
;
41 WebContentsImpl
* web_contents() const;
44 // Overridden to intercept in test.
45 virtual void AddGuest(int instance_id
,
46 WebContents
* guest_web_contents
) OVERRIDE
;
48 void GetRenderViewHostCallback(RenderViewHost
* rvh
, int x
, int y
);
50 scoped_refptr
<MessageLoopRunner
> message_loop_runner_
;
51 RenderViewHost
* last_rvh_at_position_response_
;
53 DISALLOW_COPY_AND_ASSIGN(TestBrowserPluginEmbedder
);
56 } // namespace content
58 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_TEST_BROWSER_PLUGIN_EMBEDDER_H_