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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 808 |
809 // Verify that setting the size does not alter the origin. | 809 // Verify that setting the size does not alter the origin. |
810 gfx::Point original_origin = window->bounds().origin(); | 810 gfx::Point original_origin = window->bounds().origin(); |
811 view_->SetSize(gfx::Size(120, 120)); | 811 view_->SetSize(gfx::Size(120, 120)); |
812 gfx::Point new_origin = window->bounds().origin(); | 812 gfx::Point new_origin = window->bounds().origin(); |
813 EXPECT_EQ(original_origin.ToString(), new_origin.ToString()); | 813 EXPECT_EQ(original_origin.ToString(), new_origin.ToString()); |
814 | 814 |
815 aura::client::SetScreenPositionClient(root, NULL); | 815 aura::client::SetScreenPositionClient(root, NULL); |
816 } | 816 } |
817 | 817 |
| 818 // Checks that moving parent sends new screen bounds. |
| 819 TEST_F(RenderWidgetHostViewAuraTest, ParentMovementUpdatesScreenRect) { |
| 820 view_->InitAsChild(NULL); |
| 821 |
| 822 aura::Window* root = parent_view_->GetNativeView()->GetRootWindow(); |
| 823 |
| 824 aura::test::TestWindowDelegate delegate1, delegate2; |
| 825 scoped_ptr<aura::Window> parent1(new aura::Window(&delegate1)); |
| 826 parent1->Init(ui::LAYER_TEXTURED); |
| 827 parent1->Show(); |
| 828 scoped_ptr<aura::Window> parent2(new aura::Window(&delegate2)); |
| 829 parent2->Init(ui::LAYER_TEXTURED); |
| 830 parent2->Show(); |
| 831 |
| 832 root->AddChild(parent1.get()); |
| 833 parent1->AddChild(parent2.get()); |
| 834 parent2->AddChild(view_->GetNativeView()); |
| 835 |
| 836 root->SetBounds(gfx::Rect(0, 0, 400, 400)); |
| 837 parent1->SetBounds(gfx::Rect(1, 1, 300, 300)); |
| 838 parent2->SetBounds(gfx::Rect(2, 2, 200, 200)); |
| 839 view_->SetBounds(gfx::Rect(3, 3, 100, 100)); |
| 840 // view_ will be destroyed when parent is destroyed. |
| 841 view_ = NULL; |
| 842 |
| 843 // Flush the state after initial setup is done. |
| 844 widget_host_->OnMessageReceived( |
| 845 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
| 846 widget_host_->OnMessageReceived( |
| 847 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
| 848 sink_->ClearMessages(); |
| 849 |
| 850 // Move parents. |
| 851 parent2->SetBounds(gfx::Rect(20, 20, 200, 200)); |
| 852 ASSERT_EQ(1U, sink_->message_count()); |
| 853 const IPC::Message* msg = sink_->GetMessageAt(0); |
| 854 ASSERT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); |
| 855 ViewMsg_UpdateScreenRects::Param params; |
| 856 ViewMsg_UpdateScreenRects::Read(msg, ¶ms); |
| 857 EXPECT_EQ(gfx::Rect(24, 24, 100, 100), base::get<0>(params)); |
| 858 EXPECT_EQ(gfx::Rect(1, 1, 300, 300), base::get<1>(params)); |
| 859 sink_->ClearMessages(); |
| 860 widget_host_->OnMessageReceived( |
| 861 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
| 862 // There should not be any pending update. |
| 863 EXPECT_EQ(0U, sink_->message_count()); |
| 864 |
| 865 parent1->SetBounds(gfx::Rect(10, 10, 300, 300)); |
| 866 ASSERT_EQ(1U, sink_->message_count()); |
| 867 msg = sink_->GetMessageAt(0); |
| 868 ASSERT_EQ(ViewMsg_UpdateScreenRects::ID, msg->type()); |
| 869 ViewMsg_UpdateScreenRects::Read(msg, ¶ms); |
| 870 EXPECT_EQ(gfx::Rect(33, 33, 100, 100), base::get<0>(params)); |
| 871 EXPECT_EQ(gfx::Rect(10, 10, 300, 300), base::get<1>(params)); |
| 872 sink_->ClearMessages(); |
| 873 widget_host_->OnMessageReceived( |
| 874 ViewHostMsg_UpdateScreenRects_ACK(widget_host_->GetRoutingID())); |
| 875 // There should not be any pending update. |
| 876 EXPECT_EQ(0U, sink_->message_count()); |
| 877 } |
| 878 |
818 // Checks that a fullscreen view is destroyed when it loses the focus. | 879 // Checks that a fullscreen view is destroyed when it loses the focus. |
819 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { | 880 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { |
820 view_->InitAsFullscreen(parent_view_); | 881 view_->InitAsFullscreen(parent_view_); |
821 aura::Window* window = view_->GetNativeView(); | 882 aura::Window* window = view_->GetNativeView(); |
822 ASSERT_TRUE(window != NULL); | 883 ASSERT_TRUE(window != NULL); |
823 ASSERT_TRUE(window->HasFocus()); | 884 ASSERT_TRUE(window->HasFocus()); |
824 | 885 |
825 // After we create and focus another window, the RWHVA's window should be | 886 // After we create and focus another window, the RWHVA's window should be |
826 // destroyed. | 887 // destroyed. |
827 TestWindowObserver observer(window); | 888 TestWindowObserver observer(window); |
(...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3571 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); | 3632 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); |
3572 view_->InitAsChild(NULL); | 3633 view_->InitAsChild(NULL); |
3573 view_->Show(); | 3634 view_->Show(); |
3574 view_->SetSize(size); | 3635 view_->SetSize(size); |
3575 view_->OnSwapCompositorFrame(0, | 3636 view_->OnSwapCompositorFrame(0, |
3576 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); | 3637 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); |
3577 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); | 3638 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); |
3578 } | 3639 } |
3579 | 3640 |
3580 } // namespace content | 3641 } // namespace content |
OLD | NEW |