| 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 "ash/screen_ash.h" | 5 #include "ash/screen_ash.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 14 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
| 15 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/widget/widget_delegate.h" | 18 #include "ui/views/widget/widget_delegate.h" |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 namespace test { | 21 namespace test { |
| 22 | 22 |
| 23 typedef test::AshTestBase ScreenAshTest; | 23 typedef test::AshTestBase ScreenAshTest; |
| 24 | 24 |
| 25 TEST_F(ScreenAshTest, Bounds) { | 25 TEST_F(ScreenAshTest, Bounds) { |
| 26 if (!SupportsMultipleDisplays()) |
| 27 return; |
| 28 |
| 26 UpdateDisplay("600x600,500x500"); | 29 UpdateDisplay("600x600,500x500"); |
| 27 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> | 30 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> |
| 28 SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 31 SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 29 | 32 |
| 30 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( | 33 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( |
| 31 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); | 34 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); |
| 32 primary->Show(); | 35 primary->Show(); |
| 33 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( | 36 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( |
| 34 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); | 37 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); |
| 35 secondary->Show(); | 38 secondary->Show(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 55 ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 58 ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 56 primary->GetNativeView()).ToString()); | 59 primary->GetNativeView()).ToString()); |
| 57 EXPECT_EQ("0,0 500x452", | 60 EXPECT_EQ("0,0 500x452", |
| 58 ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 61 ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 59 secondary->GetNativeView()).ToString()); | 62 secondary->GetNativeView()).ToString()); |
| 60 } | 63 } |
| 61 | 64 |
| 62 // Test verifies a stable handling of secondary screen widget changes | 65 // Test verifies a stable handling of secondary screen widget changes |
| 63 // (crbug.com/226132). | 66 // (crbug.com/226132). |
| 64 TEST_F(ScreenAshTest, StabilityTest) { | 67 TEST_F(ScreenAshTest, StabilityTest) { |
| 68 if (!SupportsMultipleDisplays()) |
| 69 return; |
| 70 |
| 65 UpdateDisplay("600x600,500x500"); | 71 UpdateDisplay("600x600,500x500"); |
| 66 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( | 72 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( |
| 67 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); | 73 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); |
| 68 EXPECT_EQ(Shell::GetAllRootWindows()[1], | 74 EXPECT_EQ(Shell::GetAllRootWindows()[1], |
| 69 secondary->GetNativeView()->GetRootWindow()); | 75 secondary->GetNativeView()->GetRootWindow()); |
| 70 secondary->Show(); | 76 secondary->Show(); |
| 71 secondary->Maximize(); | 77 secondary->Maximize(); |
| 72 secondary->Show(); | 78 secondary->Show(); |
| 73 secondary->SetFullscreen(true); | 79 secondary->SetFullscreen(true); |
| 74 secondary->Hide(); | 80 secondary->Hide(); |
| 75 secondary->Close(); | 81 secondary->Close(); |
| 76 } | 82 } |
| 77 | 83 |
| 78 TEST_F(ScreenAshTest, ConvertRect) { | 84 TEST_F(ScreenAshTest, ConvertRect) { |
| 85 if (!SupportsMultipleDisplays()) |
| 86 return; |
| 87 |
| 79 UpdateDisplay("600x600,500x500"); | 88 UpdateDisplay("600x600,500x500"); |
| 80 | 89 |
| 81 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( | 90 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( |
| 82 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); | 91 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); |
| 83 primary->Show(); | 92 primary->Show(); |
| 84 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( | 93 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( |
| 85 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); | 94 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); |
| 86 secondary->Show(); | 95 secondary->Show(); |
| 87 | 96 |
| 88 EXPECT_EQ( | 97 EXPECT_EQ( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 ScreenAsh::ConvertRectToScreen( | 108 ScreenAsh::ConvertRectToScreen( |
| 100 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); | 109 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); |
| 101 EXPECT_EQ( | 110 EXPECT_EQ( |
| 102 "650,50 100x100", | 111 "650,50 100x100", |
| 103 ScreenAsh::ConvertRectToScreen( | 112 ScreenAsh::ConvertRectToScreen( |
| 104 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); | 113 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); |
| 105 } | 114 } |
| 106 | 115 |
| 107 } // namespace test | 116 } // namespace test |
| 108 } // namespace ash | 117 } // namespace ash |
| OLD | NEW |