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/base_layout_manager.h" | 5 #include "ash/wm/base_layout_manager.h" |
6 | 6 |
7 #include "ash/screen_ash.h" | 7 #include "ash/screen_ash.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 class BaseLayoutManagerTest : public test::AshTestBase { | 25 class BaseLayoutManagerTest : public test::AshTestBase { |
26 public: | 26 public: |
27 BaseLayoutManagerTest() {} | 27 BaseLayoutManagerTest() {} |
28 virtual ~BaseLayoutManagerTest() {} | 28 virtual ~BaseLayoutManagerTest() {} |
29 | 29 |
30 virtual void SetUp() OVERRIDE { | 30 virtual void SetUp() OVERRIDE { |
31 test::AshTestBase::SetUp(); | 31 test::AshTestBase::SetUp(); |
32 Shell::GetInstance()->SetMonitorWorkAreaInsets( | 32 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
33 Shell::GetPrimaryRootWindow(), | 33 Shell::GetPrimaryRootWindow(), |
34 gfx::Insets(1, 2, 3, 4)); | 34 gfx::Insets(1, 2, 3, 4)); |
35 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); | 35 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); |
36 aura::Window* default_container = Shell::GetContainer( | 36 aura::Window* default_container = Shell::GetContainer( |
37 Shell::GetPrimaryRootWindow(), | 37 Shell::GetPrimaryRootWindow(), |
38 internal::kShellWindowId_DefaultContainer); | 38 internal::kShellWindowId_DefaultContainer); |
39 default_container->SetLayoutManager(new internal::BaseLayoutManager( | 39 default_container->SetLayoutManager(new internal::BaseLayoutManager( |
40 Shell::GetPrimaryRootWindow())); | 40 Shell::GetPrimaryRootWindow())); |
41 } | 41 } |
42 | 42 |
43 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 43 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
44 return aura::test::CreateTestWindowWithBounds(bounds, NULL); | 44 return aura::test::CreateTestWindowWithBounds(bounds, NULL); |
45 } | 45 } |
46 | 46 |
47 private: | 47 private: |
48 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManagerTest); | 48 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManagerTest); |
49 }; | 49 }; |
50 | 50 |
51 // Tests normal->maximize->normal. | 51 // Tests normal->maximize->normal. |
52 TEST_F(BaseLayoutManagerTest, Maximize) { | 52 TEST_F(BaseLayoutManagerTest, Maximize) { |
53 gfx::Rect bounds(100, 100, 200, 200); | 53 gfx::Rect bounds(100, 100, 200, 200); |
54 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 54 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
55 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 55 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
56 // Maximized window fills the work area, not the whole monitor. | 56 // Maximized window fills the work area, not the whole display. |
57 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString(), | 57 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString(), |
58 window->bounds().ToString()); | 58 window->bounds().ToString()); |
59 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 59 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
60 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 60 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
61 } | 61 } |
62 | 62 |
63 // Tests normal->minimize->normal. | 63 // Tests normal->minimize->normal. |
64 TEST_F(BaseLayoutManagerTest, Minimize) { | 64 TEST_F(BaseLayoutManagerTest, Minimize) { |
65 gfx::Rect bounds(100, 100, 200, 200); | 65 gfx::Rect bounds(100, 100, 200, 200); |
66 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 66 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
(...skipping 19 matching lines...) Expand all Loading... |
86 window->bounds().ToString()); | 86 window->bounds().ToString()); |
87 EXPECT_NE(initial_work_area_bounds.ToString(), | 87 EXPECT_NE(initial_work_area_bounds.ToString(), |
88 ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString()); | 88 ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString()); |
89 } | 89 } |
90 | 90 |
91 // Tests normal->fullscreen->normal. | 91 // Tests normal->fullscreen->normal. |
92 TEST_F(BaseLayoutManagerTest, Fullscreen) { | 92 TEST_F(BaseLayoutManagerTest, Fullscreen) { |
93 gfx::Rect bounds(100, 100, 200, 200); | 93 gfx::Rect bounds(100, 100, 200, 200); |
94 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 94 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
95 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 95 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
96 // Fullscreen window fills the whole monitor. | 96 // Fullscreen window fills the whole display. |
97 EXPECT_EQ( | 97 EXPECT_EQ( |
98 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), | 98 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), |
99 window->bounds().ToString()); | 99 window->bounds().ToString()); |
100 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 100 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
101 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 101 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
102 } | 102 } |
103 | 103 |
104 // Tests fullscreen window size during root window resize. | 104 // Tests fullscreen window size during root window resize. |
105 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { | 105 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { |
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 // Fullscreen window fills the whole monitor. | 108 // Fullscreen window fills the whole display. |
109 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 109 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
110 EXPECT_EQ( | 110 EXPECT_EQ( |
111 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), | 111 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), |
112 window->bounds().ToString()); | 112 window->bounds().ToString()); |
113 // Enlarge the root window. We should still match the monitor size. | 113 // Enlarge the root window. We should still match the display size. |
114 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); | 114 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); |
115 EXPECT_EQ( | 115 EXPECT_EQ( |
116 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), | 116 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), |
117 window->bounds().ToString()); | 117 window->bounds().ToString()); |
118 } | 118 } |
119 | 119 |
120 // Fails on Mac only. Need to be implemented. http://crbug.com/111279. | 120 // Fails on Mac only. Need to be implemented. http://crbug.com/111279. |
121 #if defined(OS_MACOSX) | 121 #if defined(OS_MACOSX) |
122 #define MAYBE_RootWindowResizeShrinksWindows \ | 122 #define MAYBE_RootWindowResizeShrinksWindows \ |
123 FAILS_RootWindowResizeShrinksWindows | 123 FAILS_RootWindowResizeShrinksWindows |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // It should have the default maximized window bounds, inset by the grid size. | 167 // It should have the default maximized window bounds, inset by the grid size. |
168 int grid_size = ash::Shell::GetInstance()->GetGridSize(); | 168 int grid_size = ash::Shell::GetInstance()->GetGridSize(); |
169 gfx::Rect max_bounds = ash::ScreenAsh::GetMaximizedWindowBounds(window.get()); | 169 gfx::Rect max_bounds = ash::ScreenAsh::GetMaximizedWindowBounds(window.get()); |
170 max_bounds.Inset(grid_size, grid_size); | 170 max_bounds.Inset(grid_size, grid_size); |
171 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); | 171 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); |
172 } | 172 } |
173 | 173 |
174 } // namespace | 174 } // namespace |
175 | 175 |
176 } // namespace ash | 176 } // namespace ash |
OLD | NEW |