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_BROWSER_BROWSER_PLUGIN_TEST_BROWSER_PLUGIN_GUEST_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_TEST_BROWSER_PLUGIN_GUEST_H_ |
| 7 |
| 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 "ipc/ipc_channel_handle.h" |
| 13 |
| 14 class WebContentsImpl; |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class RenderProcessHost; |
| 19 class RenderViewHost; |
| 20 |
| 21 // Test class for BrowserPluginGuest. |
| 22 // |
| 23 // Provides utilities to wait for certain state/messages in BrowserPluginGuest |
| 24 // to be used in tests. |
| 25 class TestBrowserPluginGuest : public BrowserPluginGuest { |
| 26 public: |
| 27 TestBrowserPluginGuest(int instance_id, |
| 28 WebContentsImpl* web_contents, |
| 29 RenderViewHost* render_view_host); |
| 30 virtual ~TestBrowserPluginGuest(); |
| 31 |
| 32 // Test utilities. |
| 33 // Waits until UpdateRect message is sent from the guest, meaning it is |
| 34 // ready/rendered. |
| 35 void WaitForUpdateRectMsg(); |
| 36 // Waits until UpdateRect message with a specific size is sent from the guest. |
| 37 void WaitForUpdateRectMsgWithSize(int width, int height); |
| 38 // Waits until guest crashes. |
| 39 void WaitForCrashed(); |
| 40 |
| 41 private: |
| 42 // Overriden methods from BrowserPluginGuest to intercept in test objects. |
| 43 virtual void SendMessageToEmbedder(IPC::Message* msg) OVERRIDE; |
| 44 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 45 |
| 46 int update_rect_count_; |
| 47 bool crash_observed_; |
| 48 |
| 49 // For WaitForUpdateRectMsgWithSize(). |
| 50 bool waiting_for_update_rect_msg_with_size_; |
| 51 int expected_width_; |
| 52 int expected_height_; |
| 53 |
| 54 int last_update_rect_width_; |
| 55 int last_update_rect_height_; |
| 56 |
| 57 scoped_refptr<MessageLoopRunner> send_message_loop_runner_; |
| 58 scoped_refptr<MessageLoopRunner> crash_message_loop_runner_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(TestBrowserPluginGuest); |
| 61 }; |
| 62 |
| 63 } // namespace content |
| 64 |
| 65 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_TEST_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |