| 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/wm/toplevel_layout_manager.h" | 5 #include "ash/wm/toplevel_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/screen_ash.h" |
| 7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 9 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/shelf_layout_manager.h" | 11 #include "ash/wm/shelf_layout_manager.h" |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 15 #include "ui/aura/screen_aura.h" | |
| 16 #include "ui/aura/test/test_windows.h" | 16 #include "ui/aura/test/test_windows.h" |
| 17 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class ToplevelLayoutManagerTest : public test::AshTestBase { | 25 class ToplevelLayoutManagerTest : public test::AshTestBase { |
| 26 public: | 26 public: |
| 27 ToplevelLayoutManagerTest() : layout_manager_(NULL) {} | 27 ToplevelLayoutManagerTest() : layout_manager_(NULL) {} |
| 28 virtual ~ToplevelLayoutManagerTest() {} | 28 virtual ~ToplevelLayoutManagerTest() {} |
| 29 | 29 |
| 30 internal::ToplevelLayoutManager* layout_manager() { | 30 internal::ToplevelLayoutManager* layout_manager() { |
| 31 return layout_manager_; | 31 return layout_manager_; |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual void SetUp() OVERRIDE { | 34 virtual void SetUp() OVERRIDE { |
| 35 test::AshTestBase::SetUp(); | 35 test::AshTestBase::SetUp(); |
| 36 Shell::GetRootWindow()->SetScreenWorkAreaInsets( | 36 Shell::GetInstance()->SetScreenWorkAreaInsets( |
| 37 gfx::Insets(1, 2, 3, 4)); | 37 gfx::Insets(1, 2, 3, 4)); |
| 38 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); | 38 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); |
| 39 aura::Window* default_container = Shell::GetInstance()->GetContainer( | 39 aura::Window* default_container = Shell::GetInstance()->GetContainer( |
| 40 internal::kShellWindowId_DefaultContainer); | 40 internal::kShellWindowId_DefaultContainer); |
| 41 layout_manager_ = new internal::ToplevelLayoutManager(); | 41 layout_manager_ = new internal::ToplevelLayoutManager(); |
| 42 default_container->SetLayoutManager(layout_manager_); | 42 default_container->SetLayoutManager(layout_manager_); |
| 43 } | 43 } |
| 44 | 44 |
| 45 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 45 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
| 46 return aura::test::CreateTestWindowWithBounds(bounds, NULL); | 46 return aura::test::CreateTestWindowWithBounds(bounds, NULL); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 window->bounds()); | 98 window->bounds()); |
| 99 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 99 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 100 EXPECT_EQ(bounds, window->bounds()); | 100 EXPECT_EQ(bounds, window->bounds()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Tests maximized window resizing on work area insets change. | 103 // Tests maximized window resizing on work area insets change. |
| 104 TEST_F(ToplevelLayoutManagerTest, | 104 TEST_F(ToplevelLayoutManagerTest, |
| 105 ResizeMaximizedWindowOnWorkAreaInsetsChange) { | 105 ResizeMaximizedWindowOnWorkAreaInsetsChange) { |
| 106 gfx::Rect bounds(100, 100, 200, 200); | 106 gfx::Rect bounds(100, 100, 200, 200); |
| 107 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 107 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 108 Shell::GetRootWindow()->SetScreenWorkAreaInsets( | 108 Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets(0, 0, 30, 0)); |
| 109 gfx::Insets(0, 0, 30, 0)); | |
| 110 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 109 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 111 // Maximized window fills the work area. | 110 // Maximized window fills the work area. |
| 112 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), | 111 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), |
| 113 window->bounds()); | 112 window->bounds()); |
| 114 | 113 |
| 115 // Change work area insets. | 114 // Change work area insets. |
| 116 Shell::GetRootWindow()->SetScreenWorkAreaInsets( | 115 Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets(0, 0, 60, 0)); |
| 117 gfx::Insets(0, 0, 60, 0)); | |
| 118 // Maximized window fills the changed work area. | 116 // Maximized window fills the changed work area. |
| 119 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), | 117 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), |
| 120 window->bounds()); | 118 window->bounds()); |
| 121 } | 119 } |
| 122 | 120 |
| 123 // Tests fullscreen window size during root window resize. | 121 // Tests fullscreen window size during root window resize. |
| 124 TEST_F(ToplevelLayoutManagerTest, FullscreenRootWindowResize) { | 122 TEST_F(ToplevelLayoutManagerTest, FullscreenRootWindowResize) { |
| 125 gfx::Rect bounds(100, 100, 200, 200); | 123 gfx::Rect bounds(100, 100, 200, 200); |
| 126 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 124 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 127 // Fullscreen window fills the whole monitor. | 125 // Fullscreen window fills the whole monitor. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 window.reset(); | 220 window.reset(); |
| 223 // shelf_layout_manager is observing these animations so clean them up first. | 221 // shelf_layout_manager is observing these animations so clean them up first. |
| 224 launcher->GetNativeView()->layer()->GetAnimator()->StopAnimating(); | 222 launcher->GetNativeView()->layer()->GetAnimator()->StopAnimating(); |
| 225 status->GetNativeView()->layer()->GetAnimator()->StopAnimating(); | 223 status->GetNativeView()->layer()->GetAnimator()->StopAnimating(); |
| 226 shelf_layout_manager.reset(); | 224 shelf_layout_manager.reset(); |
| 227 } | 225 } |
| 228 | 226 |
| 229 } // namespace | 227 } // namespace |
| 230 | 228 |
| 231 } // namespace ash | 229 } // namespace ash |
| OLD | NEW |