Index: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
index 0d4b114830fda38bc15d6e03cf2e023db45b4cf8..6a9c33be41ac5b39b64451bf334cda73c075692c 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
@@ -806,6 +806,74 @@ TEST_F(RenderWidgetHostViewAuraTest, PositionChildPopup) { |
aura::client::SetScreenPositionClient(root, NULL); |
} |
+// Checks that moving parent sends new screen bounds. |
+TEST_F(RenderWidgetHostViewAuraTest, ParentMovementUpdatesScreenRect) { |
+ view_->InitAsChild(NULL); |
+ |
+ aura::Window* root = parent_view_->GetNativeView()->GetRootWindow(); |
+ |
+ aura::test::TestWindowDelegate delegate1, delegate2; |
+ scoped_ptr<aura::Window> parent2(new aura::Window(&delegate2)); |
+ parent2->Init(ui::LAYER_TEXTURED); |
+ parent2->Show(); |
+ scoped_ptr<aura::Window> parent1(new aura::Window(&delegate1)); |
+ parent1->Init(ui::LAYER_TEXTURED); |
+ parent1->Show(); |
+ |
+ root->AddChild(parent1.get()); |
+ parent1->AddChild(parent2.get()); |
+ parent2->AddChild(view_->GetNativeView()); |
+ |
+ root->SetBounds(gfx::Rect(0, 0, 400, 400)); |
+ parent1->SetBounds(gfx::Rect(1, 1, 300, 300)); |
+ parent2->SetBounds(gfx::Rect(2, 2, 200, 200)); |
+ view_->SetBounds(gfx::Rect(3, 3, 100, 100)); |
+ |
+ // Flush the state after initial setup is done. |
+ widget_host_->OnMessageReceived( |
+ ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
+ widget_host_->OnMessageReceived( |
+ ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
+ sink_->ClearMessages(); |
+ |
+ // Move parents. |
+ parent2->SetBounds(gfx::Rect(20, 20, 200, 200)); |
+ EXPECT_EQ(1U, sink_->message_count()); |
sadrul
2015/06/03 18:51:41
Do an ASSERT_EQ here instead, and remove the condi
mharanczyk
2015/06/08 11:56:31
Done.
mharanczyk
2015/06/08 11:56:31
Done.
|
+ const IPC::Message* msg = NULL; |
+ ViewMsg_UpdateScreenRects::Param params; |
+ if (sink_->message_count() == 1U) { |
+ const IPC::Message* msg = sink_->GetMessageAt(0); |
+ ViewMsg_UpdateScreenRects::Read(msg, ¶ms); |
+ EXPECT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); |
+ EXPECT_EQ(gfx::Rect(24, 24, 100, 100), get<0>(params)); |
sadrul
2015/06/03 18:51:41
base::get<>? (everywhere else in this test too)
mharanczyk
2015/06/08 11:56:31
get is not defined in any namespace.
mharanczyk
2015/06/08 11:56:31
get<> is placed outside of base namespace in base/
|
+ EXPECT_EQ(gfx::Rect(1, 1, 300, 300), get<1>(params)); |
+ } |
+ sink_->ClearMessages(); |
+ widget_host_->OnMessageReceived( |
+ ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
+ // There should not be any pending update. |
+ EXPECT_EQ(0U, sink_->message_count()); |
+ |
+ parent1->SetBounds(gfx::Rect(10, 10, 300, 300)); |
+ EXPECT_EQ(1U, sink_->message_count()); |
sadrul
2015/06/03 18:51:41
ditto
mharanczyk
2015/06/08 11:56:31
Done.
mharanczyk
2015/06/08 11:56:31
Done.
|
+ if (sink_->message_count() == 1U) { |
+ msg = sink_->GetMessageAt(0); |
+ ViewMsg_UpdateScreenRects::Read(msg, ¶ms); |
+ EXPECT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); |
+ EXPECT_EQ(gfx::Rect(33, 33, 100, 100), get<0>(params)); |
+ EXPECT_EQ(gfx::Rect(10, 10, 300, 300), get<1>(params)); |
+ } |
+ sink_->ClearMessages(); |
+ widget_host_->OnMessageReceived( |
+ ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
+ // There should not be any pending update. |
+ EXPECT_EQ(0U, sink_->message_count()); |
+ |
+ parent2->RemoveChild(view_->GetNativeView()); |
+ parent1->RemoveChild(parent2.get()); |
+ root->RemoveChild(parent1.get()); |
+} |
+ |
// Checks that a fullscreen view is destroyed when it loses the focus. |
TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { |
view_->InitAsFullscreen(parent_view_); |