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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 monitor. |
97 EXPECT_EQ( | 97 EXPECT_EQ( |
98 gfx::Screen::GetMonitorNearestWindow(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 monitor. |
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::GetMonitorNearestWindow(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 monitor 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::GetMonitorNearestWindow(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 |
124 #else | 124 #else |
125 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows | 125 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows |
126 #endif | 126 #endif |
127 // Tests that when the screen gets smaller the windows aren't bigger than | 127 // Tests that when the screen gets smaller the windows aren't bigger than |
128 // the screen. | 128 // the screen. |
129 TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) { | 129 TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) { |
130 scoped_ptr<aura::Window> window( | 130 scoped_ptr<aura::Window> window( |
131 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); | 131 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); |
132 gfx::Rect work_area = | 132 gfx::Rect work_area = |
133 gfx::Screen::GetMonitorNearestWindow(window.get()).work_area(); | 133 gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); |
134 // Invariant: Window is smaller than work area. | 134 // Invariant: Window is smaller than work area. |
135 EXPECT_LE(window->bounds().width(), work_area.width()); | 135 EXPECT_LE(window->bounds().width(), work_area.width()); |
136 EXPECT_LE(window->bounds().height(), work_area.height()); | 136 EXPECT_LE(window->bounds().height(), work_area.height()); |
137 | 137 |
138 // Make the root window narrower than our window. | 138 // Make the root window narrower than our window. |
139 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 400)); | 139 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 400)); |
140 work_area = gfx::Screen::GetMonitorNearestWindow(window.get()).work_area(); | 140 work_area = gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); |
141 EXPECT_LE(window->bounds().width(), work_area.width()); | 141 EXPECT_LE(window->bounds().width(), work_area.width()); |
142 EXPECT_LE(window->bounds().height(), work_area.height()); | 142 EXPECT_LE(window->bounds().height(), work_area.height()); |
143 | 143 |
144 // Make the root window shorter than our window. | 144 // Make the root window shorter than our window. |
145 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 200)); | 145 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 200)); |
146 work_area = gfx::Screen::GetMonitorNearestWindow(window.get()).work_area(); | 146 work_area = gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); |
147 EXPECT_LE(window->bounds().width(), work_area.width()); | 147 EXPECT_LE(window->bounds().width(), work_area.width()); |
148 EXPECT_LE(window->bounds().height(), work_area.height()); | 148 EXPECT_LE(window->bounds().height(), work_area.height()); |
149 | 149 |
150 // Enlarging the root window does not change the window bounds. | 150 // Enlarging the root window does not change the window bounds. |
151 gfx::Rect old_bounds = window->bounds(); | 151 gfx::Rect old_bounds = window->bounds(); |
152 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); | 152 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); |
153 EXPECT_EQ(old_bounds.width(), window->bounds().width()); | 153 EXPECT_EQ(old_bounds.width(), window->bounds().width()); |
154 EXPECT_EQ(old_bounds.height(), window->bounds().height()); | 154 EXPECT_EQ(old_bounds.height(), window->bounds().height()); |
155 } | 155 } |
156 | 156 |
157 // Tests that a maximized window with too-large restore bounds will be restored | 157 // Tests that a maximized window with too-large restore bounds will be restored |
158 // to smaller than the full work area. | 158 // to smaller than the full work area. |
159 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { | 159 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { |
160 // Create a window with bounds that fill the screen. | 160 // Create a window with bounds that fill the screen. |
161 gfx::Rect bounds = gfx::Screen::GetPrimaryMonitor().bounds(); | 161 gfx::Rect bounds = gfx::Screen::GetPrimaryDisplay().bounds(); |
162 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 162 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
163 // Maximize it, which writes the old bounds to restore bounds. | 163 // Maximize it, which writes the old bounds to restore bounds. |
164 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 164 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
165 // Restore it. | 165 // Restore it. |
166 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 166 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
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 |