OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 #include "ash/root_window_controller.h" | 6 #include "ash/root_window_controller.h" |
7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 }; | 105 }; |
106 | 106 |
107 TEST_F(LockLayoutManagerTest, NorwmalWindowBoundsArePreserved) { | 107 TEST_F(LockLayoutManagerTest, NorwmalWindowBoundsArePreserved) { |
108 gfx::Rect screen_bounds = | 108 gfx::Rect screen_bounds = |
109 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 109 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
110 | 110 |
111 views::Widget::InitParams widget_params( | 111 views::Widget::InitParams widget_params( |
112 views::Widget::InitParams::TYPE_WINDOW); | 112 views::Widget::InitParams::TYPE_WINDOW); |
113 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); | 113 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); |
114 widget_params.bounds = bounds; | 114 widget_params.bounds = bounds; |
115 scoped_ptr<aura::Window> window( | 115 std::unique_ptr<aura::Window> window( |
116 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 116 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
117 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); | 117 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); |
118 | 118 |
119 gfx::Rect work_area = | 119 gfx::Rect work_area = |
120 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); | 120 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); |
121 window->SetBounds(work_area); | 121 window->SetBounds(work_area); |
122 | 122 |
123 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 123 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
124 EXPECT_NE(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 124 EXPECT_NE(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
125 | 125 |
126 const gfx::Rect bounds2 = gfx::Rect(100, 100, 200, 200); | 126 const gfx::Rect bounds2 = gfx::Rect(100, 100, 200, 200); |
127 window->SetBounds(bounds2); | 127 window->SetBounds(bounds2); |
128 EXPECT_EQ(bounds2.ToString(), window->GetBoundsInScreen().ToString()); | 128 EXPECT_EQ(bounds2.ToString(), window->GetBoundsInScreen().ToString()); |
129 } | 129 } |
130 | 130 |
131 TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) { | 131 TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) { |
132 if (!SupportsHostWindowResize()) | 132 if (!SupportsHostWindowResize()) |
133 return; | 133 return; |
134 | 134 |
135 gfx::Rect screen_bounds = | 135 gfx::Rect screen_bounds = |
136 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 136 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
137 | 137 |
138 views::Widget::InitParams widget_params( | 138 views::Widget::InitParams widget_params( |
139 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 139 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
140 widget_params.show_state = ui::SHOW_STATE_MAXIMIZED; | 140 widget_params.show_state = ui::SHOW_STATE_MAXIMIZED; |
141 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); | 141 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); |
142 widget_params.bounds = bounds; | 142 widget_params.bounds = bounds; |
143 // Maximized TYPE_WINDOW_FRAMELESS windows needs a delegate defined otherwise | 143 // Maximized TYPE_WINDOW_FRAMELESS windows needs a delegate defined otherwise |
144 // it won't get initial SetBounds event. | 144 // it won't get initial SetBounds event. |
145 scoped_ptr<aura::Window> maximized_window( | 145 std::unique_ptr<aura::Window> maximized_window( |
146 CreateTestLoginWindow(widget_params, true /* use_delegate */)); | 146 CreateTestLoginWindow(widget_params, true /* use_delegate */)); |
147 | 147 |
148 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; | 148 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; |
149 widget_params.delegate = NULL; | 149 widget_params.delegate = NULL; |
150 scoped_ptr<aura::Window> fullscreen_window( | 150 std::unique_ptr<aura::Window> fullscreen_window( |
151 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 151 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
152 | 152 |
153 EXPECT_EQ(screen_bounds.ToString(), | 153 EXPECT_EQ(screen_bounds.ToString(), |
154 maximized_window->GetBoundsInScreen().ToString()); | 154 maximized_window->GetBoundsInScreen().ToString()); |
155 EXPECT_EQ(screen_bounds.ToString(), | 155 EXPECT_EQ(screen_bounds.ToString(), |
156 fullscreen_window->GetBoundsInScreen().ToString()); | 156 fullscreen_window->GetBoundsInScreen().ToString()); |
157 | 157 |
158 gfx::Rect work_area = | 158 gfx::Rect work_area = |
159 ScreenUtil::GetDisplayWorkAreaBoundsInParent(maximized_window.get()); | 159 ScreenUtil::GetDisplayWorkAreaBoundsInParent(maximized_window.get()); |
160 maximized_window->SetBounds(work_area); | 160 maximized_window->SetBounds(work_area); |
161 | 161 |
(...skipping 22 matching lines...) Expand all Loading... |
184 TEST_F(LockLayoutManagerTest, KeyboardBounds) { | 184 TEST_F(LockLayoutManagerTest, KeyboardBounds) { |
185 if (!SupportsHostWindowResize()) | 185 if (!SupportsHostWindowResize()) |
186 return; | 186 return; |
187 | 187 |
188 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); | 188 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
189 gfx::Rect screen_bounds = primary_display.bounds(); | 189 gfx::Rect screen_bounds = primary_display.bounds(); |
190 | 190 |
191 views::Widget::InitParams widget_params( | 191 views::Widget::InitParams widget_params( |
192 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 192 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
193 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; | 193 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; |
194 scoped_ptr<aura::Window> window( | 194 std::unique_ptr<aura::Window> window( |
195 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 195 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
196 | 196 |
197 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 197 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
198 | 198 |
199 // When virtual keyboard overscroll is enabled keyboard bounds should not | 199 // When virtual keyboard overscroll is enabled keyboard bounds should not |
200 // affect window bounds. | 200 // affect window bounds. |
201 keyboard::SetKeyboardOverscrollOverride( | 201 keyboard::SetKeyboardOverscrollOverride( |
202 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED); | 202 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED); |
203 ShowKeyboard(true); | 203 ShowKeyboard(true); |
204 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 204 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 return; | 253 return; |
254 | 254 |
255 UpdateDisplay("300x400,400x500"); | 255 UpdateDisplay("300x400,400x500"); |
256 gfx::Rect screen_bounds = | 256 gfx::Rect screen_bounds = |
257 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 257 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
258 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 258 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
259 | 259 |
260 views::Widget::InitParams widget_params( | 260 views::Widget::InitParams widget_params( |
261 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 261 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
262 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; | 262 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; |
263 scoped_ptr<aura::Window> window( | 263 std::unique_ptr<aura::Window> window( |
264 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 264 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
265 window->SetProperty(aura::client::kCanMaximizeKey, true); | 265 window->SetProperty(aura::client::kCanMaximizeKey, true); |
266 | 266 |
267 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 267 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
268 | 268 |
269 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 269 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
270 | 270 |
271 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 271 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
272 window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); | 272 window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); |
273 | 273 |
(...skipping 20 matching lines...) Expand all Loading... |
294 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); | 294 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); |
295 window->SetBounds(work_area); | 295 window->SetBounds(work_area); |
296 // Usually work_area takes Shelf into account but that doesn't affect | 296 // Usually work_area takes Shelf into account but that doesn't affect |
297 // LockScreen container windows. | 297 // LockScreen container windows. |
298 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 298 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
299 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 299 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
300 } | 300 } |
301 | 301 |
302 } // namespace test | 302 } // namespace test |
303 } // namespace ash | 303 } // namespace ash |
OLD | NEW |