Commit da05552e authored by jbauman's avatar jbauman Committed by Commit bot

Make RenderWidgetHostViewAuraTest.Resize robust to different IPC orderings

The precise order (or number) of some of these messages doesn't matter, so just handle them in a loop.

Review URL: https://codereview.chromium.org/888693004

Cr-Commit-Position: refs/heads/master@{#314024}
parent 7cf6cbe2
...@@ -1531,31 +1531,38 @@ TEST_F(RenderWidgetHostViewAuraTest, Resize) { ...@@ -1531,31 +1531,38 @@ TEST_F(RenderWidgetHostViewAuraTest, Resize) {
ui::DrawWaiterForTest::WaitForCommit( ui::DrawWaiterForTest::WaitForCommit(
root_window->GetHost()->compositor()); root_window->GetHost()->compositor());
// On some platforms, the call to view_->Show() causes a posted task to call bool has_resize = false;
// ui::WindowEventDispatcher::SynthesizeMouseMoveAfterChangeToWindow, which for (uint32 i = 0; i < sink_->message_count(); ++i) {
// the above WaitForCommit may cause to be picked up. Be robust to this extra const IPC::Message* msg = sink_->GetMessageAt(i);
// IPC coming in. switch (msg->type()) {
bool has_extra_ipc = (sink_->message_count() == 3); case InputMsg_HandleInputEvent::ID: {
if (has_extra_ipc) { // On some platforms, the call to view_->Show() causes a posted task to
const IPC::Message* msg = sink_->GetMessageAt(0); // call
EXPECT_EQ(InputMsg_HandleInputEvent::ID, msg->type()); // ui::WindowEventDispatcher::SynthesizeMouseMoveAfterChangeToWindow,
InputMsg_HandleInputEvent::Param params; // which the above WaitForCommit may cause to be picked up. Be robust
InputMsg_HandleInputEvent::Read(msg, &params); // to this extra IPC coming in.
const blink::WebInputEvent* event = get<0>(params); InputMsg_HandleInputEvent::Param params;
EXPECT_EQ(blink::WebInputEvent::MouseMove, event->type); InputMsg_HandleInputEvent::Read(msg, &params);
} const blink::WebInputEvent* event = get<0>(params);
else { EXPECT_EQ(blink::WebInputEvent::MouseMove, event->type);
EXPECT_EQ(2u, sink_->message_count()); break;
} }
EXPECT_EQ(ViewMsg_SwapCompositorFrameAck::ID, case ViewMsg_SwapCompositorFrameAck::ID:
sink_->GetMessageAt(has_extra_ipc ? 1 : 0)->type()); break;
{ case ViewMsg_Resize::ID: {
const IPC::Message* msg = sink_->GetMessageAt(has_extra_ipc ? 2 : 1); EXPECT_FALSE(has_resize);
EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); ViewMsg_Resize::Param params;
ViewMsg_Resize::Param params; ViewMsg_Resize::Read(msg, &params);
ViewMsg_Resize::Read(msg, &params); EXPECT_EQ(size3.ToString(), get<0>(params).new_size.ToString());
EXPECT_EQ(size3.ToString(), get<0>(params).new_size.ToString()); has_resize = true;
break;
}
default:
ADD_FAILURE() << "Unexpected message " << msg->type();
break;
}
} }
EXPECT_TRUE(has_resize);
update_params.view_size = size3; update_params.view_size = size3;
widget_host_->OnMessageReceived( widget_host_->OnMessageReceived(
ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params)); ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment