OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 | 799 |
800 // Verify that setting the size does not alter the origin. | 800 // Verify that setting the size does not alter the origin. |
801 gfx::Point original_origin = window->bounds().origin(); | 801 gfx::Point original_origin = window->bounds().origin(); |
802 view_->SetSize(gfx::Size(120, 120)); | 802 view_->SetSize(gfx::Size(120, 120)); |
803 gfx::Point new_origin = window->bounds().origin(); | 803 gfx::Point new_origin = window->bounds().origin(); |
804 EXPECT_EQ(original_origin.ToString(), new_origin.ToString()); | 804 EXPECT_EQ(original_origin.ToString(), new_origin.ToString()); |
805 | 805 |
806 aura::client::SetScreenPositionClient(root, NULL); | 806 aura::client::SetScreenPositionClient(root, NULL); |
807 } | 807 } |
808 | 808 |
809 // Checks that moving parent sends new screen bounds. | |
810 TEST_F(RenderWidgetHostViewAuraTest, ParentMovementUpdatesScreenRect) { | |
811 view_->InitAsChild(NULL); | |
812 | |
813 aura::Window* root = parent_view_->GetNativeView()->GetRootWindow(); | |
814 | |
815 aura::test::TestWindowDelegate delegate1, delegate2; | |
816 scoped_ptr<aura::Window> parent2(new aura::Window(&delegate2)); | |
817 parent2->Init(ui::LAYER_TEXTURED); | |
818 parent2->Show(); | |
819 scoped_ptr<aura::Window> parent1(new aura::Window(&delegate1)); | |
820 parent1->Init(ui::LAYER_TEXTURED); | |
821 parent1->Show(); | |
822 | |
823 root->AddChild(parent1.get()); | |
824 parent1->AddChild(parent2.get()); | |
825 parent2->AddChild(view_->GetNativeView()); | |
826 | |
827 root->SetBounds(gfx::Rect(0, 0, 400, 400)); | |
828 parent1->SetBounds(gfx::Rect(1, 1, 300, 300)); | |
829 parent2->SetBounds(gfx::Rect(2, 2, 200, 200)); | |
830 view_->SetBounds(gfx::Rect(3, 3, 100, 100)); | |
831 | |
832 // Flush the state after initial setup is done. | |
833 widget_host_->OnMessageReceived( | |
834 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | |
835 widget_host_->OnMessageReceived( | |
836 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | |
837 sink_->ClearMessages(); | |
838 | |
839 // Move parents. | |
840 parent2->SetBounds(gfx::Rect(20, 20, 200, 200)); | |
841 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.
| |
842 const IPC::Message* msg = NULL; | |
843 ViewMsg_UpdateScreenRects::Param params; | |
844 if (sink_->message_count() == 1U) { | |
845 const IPC::Message* msg = sink_->GetMessageAt(0); | |
846 ViewMsg_UpdateScreenRects::Read(msg, ¶ms); | |
847 EXPECT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); | |
848 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/
| |
849 EXPECT_EQ(gfx::Rect(1, 1, 300, 300), get<1>(params)); | |
850 } | |
851 sink_->ClearMessages(); | |
852 widget_host_->OnMessageReceived( | |
853 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | |
854 // There should not be any pending update. | |
855 EXPECT_EQ(0U, sink_->message_count()); | |
856 | |
857 parent1->SetBounds(gfx::Rect(10, 10, 300, 300)); | |
858 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.
| |
859 if (sink_->message_count() == 1U) { | |
860 msg = sink_->GetMessageAt(0); | |
861 ViewMsg_UpdateScreenRects::Read(msg, ¶ms); | |
862 EXPECT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); | |
863 EXPECT_EQ(gfx::Rect(33, 33, 100, 100), get<0>(params)); | |
864 EXPECT_EQ(gfx::Rect(10, 10, 300, 300), get<1>(params)); | |
865 } | |
866 sink_->ClearMessages(); | |
867 widget_host_->OnMessageReceived( | |
868 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); | |
869 // There should not be any pending update. | |
870 EXPECT_EQ(0U, sink_->message_count()); | |
871 | |
872 parent2->RemoveChild(view_->GetNativeView()); | |
873 parent1->RemoveChild(parent2.get()); | |
874 root->RemoveChild(parent1.get()); | |
875 } | |
876 | |
809 // Checks that a fullscreen view is destroyed when it loses the focus. | 877 // Checks that a fullscreen view is destroyed when it loses the focus. |
810 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { | 878 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { |
811 view_->InitAsFullscreen(parent_view_); | 879 view_->InitAsFullscreen(parent_view_); |
812 aura::Window* window = view_->GetNativeView(); | 880 aura::Window* window = view_->GetNativeView(); |
813 ASSERT_TRUE(window != NULL); | 881 ASSERT_TRUE(window != NULL); |
814 ASSERT_TRUE(window->HasFocus()); | 882 ASSERT_TRUE(window->HasFocus()); |
815 | 883 |
816 // After we create and focus another window, the RWHVA's window should be | 884 // After we create and focus another window, the RWHVA's window should be |
817 // destroyed. | 885 // destroyed. |
818 TestWindowObserver observer(window); | 886 TestWindowObserver observer(window); |
(...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3497 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); | 3565 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); |
3498 view_->InitAsChild(NULL); | 3566 view_->InitAsChild(NULL); |
3499 view_->Show(); | 3567 view_->Show(); |
3500 view_->SetSize(size); | 3568 view_->SetSize(size); |
3501 view_->OnSwapCompositorFrame(0, | 3569 view_->OnSwapCompositorFrame(0, |
3502 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); | 3570 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); |
3503 EXPECT_EQ(view_->GetSurfaceIdNamespace(), get<0>(params)); | 3571 EXPECT_EQ(view_->GetSurfaceIdNamespace(), get<0>(params)); |
3504 } | 3572 } |
3505 | 3573 |
3506 } // namespace content | 3574 } // namespace content |
OLD | NEW |