Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: content/browser/browser_plugin/test_browser_plugin_guest.cc

Issue 10868012: Browser Plugin: New Implementation (Browser Side) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-trial-obrowser
Patch Set: Clean up BrowserPluginHostTest, remove unused var, use constants for str. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bcf8ab1a428bcbdfcb08d46f8b596f48ddcf4ec7
--- /dev/null
+++ b/content/browser/browser_plugin/test_browser_plugin_guest.cc
@@ -0,0 +1,103 @@
+// 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"
+#include "ui/gfx/size.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),
+ last_update_rect_width_(-1),
+ last_update_rect_height_(-1) {
+}
+
+TestBrowserPluginGuest::~TestBrowserPluginGuest() {
+}
+
+void TestBrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
+ if (msg->type() == BrowserPluginMsg_UpdateRect::ID) {
+ PickleIterator iter(*msg);
+
+ int instance_id;
+ int message_id;
+ BrowserPluginMsg_UpdateRect_Params update_rect_params;
+
+ if (!IPC::ReadParam(msg, &iter, &instance_id) ||
+ !IPC::ReadParam(msg, &iter, &message_id) ||
+ !IPC::ReadParam(msg, &iter, &update_rect_params)) {
+ NOTREACHED() <<
+ "Cannot read BrowserPluginMsg_UpdateRect params from ipc message";
+ }
+ last_update_rect_width_ = update_rect_params.view_size.width();
+ last_update_rect_height_ = update_rect_params.view_size.height();
+ update_rect_count_++;
+ if (waiting_for_update_rect_msg_with_size_ &&
+ expected_width_ == last_update_rect_width_ &&
+ expected_height_ == last_update_rect_height_) {
+ waiting_for_update_rect_msg_with_size_ = false;
+ if (send_message_loop_runner_)
+ send_message_loop_runner_->Quit();
+ } else if (!waiting_for_update_rect_msg_with_size_) {
+ 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::WaitForUpdateRectMsgWithSize(int width,
+ int height) {
+ if (update_rect_count_ > 0 &&
+ last_update_rect_width_ == width &&
+ last_update_rect_height_ == height) {
+ // We already saw this message.
+ return;
+ }
+ waiting_for_update_rect_msg_with_size_ = true;
+ expected_width_ = width;
+ expected_height_ = height;
+ 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

Powered by Google App Engine
This is Rietveld 408576698