| Index: content/browser/browser_plugin/test_browser_plugin_guest.cc
|
| diff --git a/content/browser/browser_plugin/test_browser_plugin_guest.cc b/content/browser/browser_plugin/test_browser_plugin_guest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..223d44fa8fd797ef366b935cabde99c24437ffc8
|
| --- /dev/null
|
| +++ b/content/browser/browser_plugin/test_browser_plugin_guest.cc
|
| @@ -0,0 +1,63 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/browser_plugin/test_browser_plugin_guest.h"
|
| +
|
| +#include "content/browser/browser_plugin/browser_plugin_guest.h"
|
| +#include "content/browser/renderer_host/render_view_host_impl.h"
|
| +#include "content/browser/web_contents/web_contents_impl.h"
|
| +#include "content/common/browser_plugin_messages.h"
|
| +#include "content/public/test/test_utils.h"
|
| +#include "ipc/ipc_channel_handle.h"
|
| +#include "ipc/ipc_sync_message.h"
|
| +
|
| +namespace content {
|
| +
|
| +class BrowserPluginGuest;
|
| +
|
| +TestBrowserPluginGuest::TestBrowserPluginGuest(
|
| + int instance_id,
|
| + WebContentsImpl* web_contents,
|
| + RenderViewHost* render_view_host)
|
| + : BrowserPluginGuest(instance_id, web_contents, render_view_host),
|
| + update_rect_count_(0),
|
| + crash_observed_(false) {
|
| +}
|
| +
|
| +TestBrowserPluginGuest::~TestBrowserPluginGuest() {
|
| +}
|
| +
|
| +void TestBrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
|
| + if (msg->type() == BrowserPluginMsg_UpdateRect::ID) {
|
| + update_rect_count_++;
|
| + if (send_message_loop_runner_)
|
| + send_message_loop_runner_->Quit();
|
| + }
|
| + BrowserPluginGuest::SendMessageToEmbedder(msg);
|
| +}
|
| +
|
| +void TestBrowserPluginGuest::WaitForUpdateRectMsg() {
|
| + // Check if we already got any UpdateRect message.
|
| + if (update_rect_count_ > 0)
|
| + return;
|
| + send_message_loop_runner_= new MessageLoopRunner();
|
| + send_message_loop_runner_->Run();
|
| +}
|
| +
|
| +void TestBrowserPluginGuest::RenderViewGone(base::TerminationStatus status) {
|
| + crash_observed_ = true;
|
| + if (crash_message_loop_runner_)
|
| + crash_message_loop_runner_->Quit();
|
| + BrowserPluginGuest::RenderViewGone(status);
|
| +}
|
| +
|
| +void TestBrowserPluginGuest::WaitForCrashed() {
|
| + // Check if we already observed a guest crash, return immediately if so.
|
| + if (crash_observed_)
|
| + return;
|
| + crash_message_loop_runner_ = new MessageLoopRunner();
|
| + crash_message_loop_runner_->Run();
|
| +}
|
| +
|
| +} // namespace content
|
|
|