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

Unified Diff: chrome/browser/renderer_host/render_widget_host_unittest.cc

Issue 506075: Revert 34951 - Combine ViewHostMsg_{Paint,Scroll}Rect into one IPC.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years 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: chrome/browser/renderer_host/render_widget_host_unittest.cc
===================================================================
--- chrome/browser/renderer_host/render_widget_host_unittest.cc (revision 34952)
+++ chrome/browser/renderer_host/render_widget_host_unittest.cc (working copy)
@@ -21,9 +21,9 @@
public:
explicit RenderWidgetHostProcess(Profile* profile)
: MockRenderProcessHost(profile),
- current_update_buf_(NULL),
- update_msg_should_reply_(false),
- update_msg_reply_flags_(0) {
+ current_paint_buf_(NULL),
+ paint_msg_should_reply_(false),
+ paint_msg_reply_flags_(0) {
// DANGER! This is a hack. The RenderWidgetHost checks the channel to see
// if the process is still alive, but it doesn't actually dereference it.
// An IPC::SyncChannel is nontrivial, so we just fake it here. If you end up
@@ -34,65 +34,64 @@
// We don't want to actually delete the channel, since it's not a real
// pointer.
channel_.release();
- delete current_update_buf_;
+ if (current_paint_buf_)
+ delete current_paint_buf_;
}
- void set_update_msg_should_reply(bool reply) {
- update_msg_should_reply_ = reply;
+ void set_paint_msg_should_reply(bool reply) {
+ paint_msg_should_reply_ = reply;
}
- void set_update_msg_reply_flags(int flags) {
- update_msg_reply_flags_ = flags;
+ void set_paint_msg_reply_flags(int flags) {
+ paint_msg_reply_flags_ = flags;
}
// Fills the given paint parameters with resonable default values.
- void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params);
+ void InitPaintRectParams(ViewHostMsg_PaintRect_Params* params);
protected:
- virtual bool WaitForUpdateMsg(int render_widget_id,
- const base::TimeDelta& max_delay,
- IPC::Message* msg);
+ virtual bool WaitForPaintMsg(int render_widget_id,
+ const base::TimeDelta& max_delay,
+ IPC::Message* msg);
- TransportDIB* current_update_buf_;
+ TransportDIB* current_paint_buf_;
// Set to true when WaitForPaintMsg should return a successful paint messaage
// reply. False implies timeout.
- bool update_msg_should_reply_;
+ bool paint_msg_should_reply_;
// Indicates the flags that should be sent with a the repaint request. This
// only has an effect when paint_msg_should_reply_ is true.
- int update_msg_reply_flags_;
+ int paint_msg_reply_flags_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostProcess);
};
-void RenderWidgetHostProcess::InitUpdateRectParams(
- ViewHostMsg_UpdateRect_Params* params) {
+void RenderWidgetHostProcess::InitPaintRectParams(
+ ViewHostMsg_PaintRect_Params* params) {
// Create the shared backing store.
const int w = 100, h = 100;
const size_t pixel_size = w * h * 4;
- if (!current_update_buf_)
- current_update_buf_ = TransportDIB::Create(pixel_size, 0);
- params->bitmap = current_update_buf_->id();
+ if (!current_paint_buf_)
+ current_paint_buf_ = TransportDIB::Create(pixel_size, 0);
+ params->bitmap = current_paint_buf_->id();
params->bitmap_rect = gfx::Rect(0, 0, w, h);
- params->dx = 0;
- params->dy = 0;
- params->copy_rects.push_back(params->bitmap_rect);
+ params->update_rects.push_back(params->bitmap_rect);
params->view_size = gfx::Size(w, h);
- params->flags = update_msg_reply_flags_;
+ params->flags = paint_msg_reply_flags_;
}
-bool RenderWidgetHostProcess::WaitForUpdateMsg(int render_widget_id,
- const base::TimeDelta& max_delay,
- IPC::Message* msg) {
- if (!update_msg_should_reply_)
+bool RenderWidgetHostProcess::WaitForPaintMsg(int render_widget_id,
+ const base::TimeDelta& max_delay,
+ IPC::Message* msg) {
+ if (!paint_msg_should_reply_)
return false;
// Construct a fake paint reply.
- ViewHostMsg_UpdateRect_Params params;
- InitUpdateRectParams(&params);
+ ViewHostMsg_PaintRect_Params params;
+ InitPaintRectParams(&params);
- ViewHostMsg_UpdateRect message(render_widget_id, params);
+ ViewHostMsg_PaintRect message(render_widget_id, params);
*msg = message;
return true;
}
@@ -252,9 +251,9 @@
// Send out a paint that's not a resize ack. This should not clean the
// resize ack pending flag.
- ViewHostMsg_UpdateRect_Params params;
- process_->InitUpdateRectParams(&params);
- host_->OnMsgUpdateRect(params);
+ ViewHostMsg_PaintRect_Params params;
+ process_->InitPaintRectParams(&params);
+ host_->OnMsgPaintRect(params);
EXPECT_TRUE(host_->resize_ack_pending_);
EXPECT_EQ(original_size.size(), host_->in_flight_size_);
@@ -272,9 +271,9 @@
// this isn't the second_size, the message handler should immediately send
// a new resize message for the new size to the renderer.
process_->sink().ClearMessages();
- params.flags = ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
+ params.flags = ViewHostMsg_PaintRect_Flags::IS_RESIZE_ACK;
params.view_size = original_size.size();
- host_->OnMsgUpdateRect(params);
+ host_->OnMsgPaintRect(params);
EXPECT_TRUE(host_->resize_ack_pending_);
EXPECT_EQ(second_size.size(), host_->in_flight_size_);
ASSERT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
@@ -282,7 +281,7 @@
// Send the resize ack for the latest size.
process_->sink().ClearMessages();
params.view_size = second_size.size();
- host_->OnMsgUpdateRect(params);
+ host_->OnMsgPaintRect(params);
EXPECT_FALSE(host_->resize_ack_pending_);
EXPECT_EQ(gfx::Size(), host_->in_flight_size_);
ASSERT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID));
@@ -399,42 +398,42 @@
TEST_F(RenderWidgetHostTest, GetBackingStore_NoRepaintAck) {
// We don't currently have a backing store, and if the renderer doesn't send
// one in time, we should get nothing.
- process_->set_update_msg_should_reply(false);
+ process_->set_paint_msg_should_reply(false);
BackingStore* backing = host_->GetBackingStore(true);
EXPECT_FALSE(backing);
// The widget host should have sent a request for a repaint, and there should
// be no paint ACK.
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Repaint::ID));
EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(
- ViewMsg_UpdateRect_ACK::ID));
+ ViewMsg_PaintRect_ACK::ID));
// Allowing the renderer to reply in time should give is a backing store.
process_->sink().ClearMessages();
- process_->set_update_msg_should_reply(true);
- process_->set_update_msg_reply_flags(0);
+ process_->set_paint_msg_should_reply(true);
+ process_->set_paint_msg_reply_flags(0);
backing = host_->GetBackingStore(true);
EXPECT_TRUE(backing);
// The widget host should NOT have sent a request for a repaint, since there
// was an ACK already pending.
EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Repaint::ID));
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
- ViewMsg_UpdateRect_ACK::ID));
+ ViewMsg_PaintRect_ACK::ID));
}
// Tests getting the backing store with the renderer sending a repaint ack.
TEST_F(RenderWidgetHostTest, GetBackingStore_RepaintAck) {
// Doing a request request with the paint message allowed should work and
// the repaint ack should work.
- process_->set_update_msg_should_reply(true);
- process_->set_update_msg_reply_flags(
- ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK);
+ process_->set_paint_msg_should_reply(true);
+ process_->set_paint_msg_reply_flags(
+ ViewHostMsg_PaintRect_Flags::IS_REPAINT_ACK);
BackingStore* backing = host_->GetBackingStore(true);
EXPECT_TRUE(backing);
// We still should not have sent out a repaint request since the last flags
// didn't have the repaint ack set, and the pending flag will still be set.
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Repaint::ID));
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
- ViewMsg_UpdateRect_ACK::ID));
+ ViewMsg_PaintRect_ACK::ID));
// Asking again for the backing store should just re-use the existing one
// and not send any messagse.
@@ -443,7 +442,7 @@
EXPECT_TRUE(backing);
EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Repaint::ID));
EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(
- ViewMsg_UpdateRect_ACK::ID));
+ ViewMsg_PaintRect_ACK::ID));
}
// Test that we don't paint when we're hidden, but we still send the ACK. Most
@@ -457,13 +456,13 @@
// Send it a paint as from the renderer.
process_->sink().ClearMessages();
- ViewHostMsg_UpdateRect_Params params;
- process_->InitUpdateRectParams(&params);
- host_->OnMsgUpdateRect(params);
+ ViewHostMsg_PaintRect_Params params;
+ process_->InitPaintRectParams(&params);
+ host_->OnMsgPaintRect(params);
// It should have sent out the ACK.
EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
- ViewMsg_UpdateRect_ACK::ID));
+ ViewMsg_PaintRect_ACK::ID));
// Now unhide.
process_->sink().ClearMessages();
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host.cc ('k') | chrome/browser/renderer_host/render_widget_host_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698