| 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" |
| 11 #include "ash/wm/common/window_state.h" | 11 #include "ash/wm/common/window_state.h" |
| 12 #include "ash/wm/window_state_aura.h" | 12 #include "ash/wm/window_state_aura.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/gfx/screen.h" | 16 #include "ui/display/screen.h" |
| 17 #include "ui/keyboard/keyboard_controller.h" | 17 #include "ui/keyboard/keyboard_controller.h" |
| 18 #include "ui/keyboard/keyboard_switches.h" | 18 #include "ui/keyboard/keyboard_switches.h" |
| 19 #include "ui/keyboard/keyboard_ui.h" | 19 #include "ui/keyboard/keyboard_ui.h" |
| 20 #include "ui/keyboard/keyboard_util.h" | 20 #include "ui/keyboard/keyboard_util.h" |
| 21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 22 #include "ui/views/widget/widget_delegate.h" | 22 #include "ui/views/widget/widget_delegate.h" |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 namespace test { | 25 namespace test { |
| 26 | 26 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } else { | 100 } else { |
| 101 keyboard->HideKeyboard(keyboard::KeyboardController::HIDE_REASON_MANUAL); | 101 keyboard->HideKeyboard(keyboard::KeyboardController::HIDE_REASON_MANUAL); |
| 102 } | 102 } |
| 103 | 103 |
| 104 DCHECK_EQ(show, keyboard->keyboard_visible()); | 104 DCHECK_EQ(show, keyboard->keyboard_visible()); |
| 105 } | 105 } |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 TEST_F(LockLayoutManagerTest, NorwmalWindowBoundsArePreserved) { | 108 TEST_F(LockLayoutManagerTest, NorwmalWindowBoundsArePreserved) { |
| 109 gfx::Rect screen_bounds = | 109 gfx::Rect screen_bounds = |
| 110 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 110 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 111 | 111 |
| 112 views::Widget::InitParams widget_params( | 112 views::Widget::InitParams widget_params( |
| 113 views::Widget::InitParams::TYPE_WINDOW); | 113 views::Widget::InitParams::TYPE_WINDOW); |
| 114 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); | 114 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); |
| 115 widget_params.bounds = bounds; | 115 widget_params.bounds = bounds; |
| 116 std::unique_ptr<aura::Window> window( | 116 std::unique_ptr<aura::Window> window( |
| 117 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 117 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
| 118 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); | 118 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 119 | 119 |
| 120 gfx::Rect work_area = | 120 gfx::Rect work_area = |
| 121 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); | 121 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); |
| 122 window->SetBounds(work_area); | 122 window->SetBounds(work_area); |
| 123 | 123 |
| 124 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 124 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
| 125 EXPECT_NE(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 125 EXPECT_NE(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 126 | 126 |
| 127 const gfx::Rect bounds2 = gfx::Rect(100, 100, 200, 200); | 127 const gfx::Rect bounds2 = gfx::Rect(100, 100, 200, 200); |
| 128 window->SetBounds(bounds2); | 128 window->SetBounds(bounds2); |
| 129 EXPECT_EQ(bounds2.ToString(), window->GetBoundsInScreen().ToString()); | 129 EXPECT_EQ(bounds2.ToString(), window->GetBoundsInScreen().ToString()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) { | 132 TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) { |
| 133 if (!SupportsHostWindowResize()) | 133 if (!SupportsHostWindowResize()) |
| 134 return; | 134 return; |
| 135 | 135 |
| 136 gfx::Rect screen_bounds = | 136 gfx::Rect screen_bounds = |
| 137 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 137 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 138 | 138 |
| 139 views::Widget::InitParams widget_params( | 139 views::Widget::InitParams widget_params( |
| 140 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 140 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 141 widget_params.show_state = ui::SHOW_STATE_MAXIMIZED; | 141 widget_params.show_state = ui::SHOW_STATE_MAXIMIZED; |
| 142 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); | 142 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); |
| 143 widget_params.bounds = bounds; | 143 widget_params.bounds = bounds; |
| 144 // Maximized TYPE_WINDOW_FRAMELESS windows needs a delegate defined otherwise | 144 // Maximized TYPE_WINDOW_FRAMELESS windows needs a delegate defined otherwise |
| 145 // it won't get initial SetBounds event. | 145 // it won't get initial SetBounds event. |
| 146 std::unique_ptr<aura::Window> maximized_window( | 146 std::unique_ptr<aura::Window> maximized_window( |
| 147 CreateTestLoginWindow(widget_params, true /* use_delegate */)); | 147 CreateTestLoginWindow(widget_params, true /* use_delegate */)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 EXPECT_EQ(screen_bounds.ToString(), | 179 EXPECT_EQ(screen_bounds.ToString(), |
| 180 maximized_window->GetBoundsInScreen().ToString()); | 180 maximized_window->GetBoundsInScreen().ToString()); |
| 181 EXPECT_EQ(screen_bounds.ToString(), | 181 EXPECT_EQ(screen_bounds.ToString(), |
| 182 fullscreen_window->GetBoundsInScreen().ToString()); | 182 fullscreen_window->GetBoundsInScreen().ToString()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 TEST_F(LockLayoutManagerTest, KeyboardBounds) { | 185 TEST_F(LockLayoutManagerTest, KeyboardBounds) { |
| 186 if (!SupportsHostWindowResize()) | 186 if (!SupportsHostWindowResize()) |
| 187 return; | 187 return; |
| 188 | 188 |
| 189 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); | 189 display::Display primary_display = |
| 190 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 190 gfx::Rect screen_bounds = primary_display.bounds(); | 191 gfx::Rect screen_bounds = primary_display.bounds(); |
| 191 | 192 |
| 192 views::Widget::InitParams widget_params( | 193 views::Widget::InitParams widget_params( |
| 193 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 194 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 194 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; | 195 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; |
| 195 std::unique_ptr<aura::Window> window( | 196 std::unique_ptr<aura::Window> window( |
| 196 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 197 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
| 197 | 198 |
| 198 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 199 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 199 | 200 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 213 // Repro steps for http://crbug.com/401667: | 214 // Repro steps for http://crbug.com/401667: |
| 214 // 1. Set up login screen defaults: VK override disabled | 215 // 1. Set up login screen defaults: VK override disabled |
| 215 // 2. Show/hide keyboard, make sure that no stale keyboard bounds are cached. | 216 // 2. Show/hide keyboard, make sure that no stale keyboard bounds are cached. |
| 216 keyboard::SetKeyboardOverscrollOverride( | 217 keyboard::SetKeyboardOverscrollOverride( |
| 217 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | 218 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
| 218 ShowKeyboard(true); | 219 ShowKeyboard(true); |
| 219 ShowKeyboard(false); | 220 ShowKeyboard(false); |
| 220 ash::DisplayManager* display_manager = | 221 ash::DisplayManager* display_manager = |
| 221 Shell::GetInstance()->display_manager(); | 222 Shell::GetInstance()->display_manager(); |
| 222 display_manager->SetDisplayRotation(primary_display.id(), | 223 display_manager->SetDisplayRotation(primary_display.id(), |
| 223 gfx::Display::ROTATE_90, | 224 display::Display::ROTATE_90, |
| 224 gfx::Display::ROTATION_SOURCE_ACTIVE); | 225 display::Display::ROTATION_SOURCE_ACTIVE); |
| 225 primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); | 226 primary_display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 226 screen_bounds = primary_display.bounds(); | 227 screen_bounds = primary_display.bounds(); |
| 227 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 228 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 228 display_manager->SetDisplayRotation(primary_display.id(), | 229 display_manager->SetDisplayRotation(primary_display.id(), |
| 229 gfx::Display::ROTATE_0, | 230 display::Display::ROTATE_0, |
| 230 gfx::Display::ROTATION_SOURCE_ACTIVE); | 231 display::Display::ROTATION_SOURCE_ACTIVE); |
| 231 | 232 |
| 232 // When virtual keyboard overscroll is disabled keyboard bounds do | 233 // When virtual keyboard overscroll is disabled keyboard bounds do |
| 233 // affect window bounds. | 234 // affect window bounds. |
| 234 keyboard::SetKeyboardOverscrollOverride( | 235 keyboard::SetKeyboardOverscrollOverride( |
| 235 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | 236 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
| 236 ShowKeyboard(true); | 237 ShowKeyboard(true); |
| 237 keyboard::KeyboardController* keyboard = | 238 keyboard::KeyboardController* keyboard = |
| 238 keyboard::KeyboardController::GetInstance(); | 239 keyboard::KeyboardController::GetInstance(); |
| 239 primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); | 240 primary_display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 240 screen_bounds = primary_display.bounds(); | 241 screen_bounds = primary_display.bounds(); |
| 241 gfx::Rect target_bounds(screen_bounds); | 242 gfx::Rect target_bounds(screen_bounds); |
| 242 target_bounds.set_height( | 243 target_bounds.set_height( |
| 243 target_bounds.height() - | 244 target_bounds.height() - |
| 244 keyboard->ui()->GetKeyboardWindow()->bounds().height()); | 245 keyboard->ui()->GetKeyboardWindow()->bounds().height()); |
| 245 EXPECT_EQ(target_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 246 EXPECT_EQ(target_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 246 ShowKeyboard(false); | 247 ShowKeyboard(false); |
| 247 | 248 |
| 248 keyboard::SetKeyboardOverscrollOverride( | 249 keyboard::SetKeyboardOverscrollOverride( |
| 249 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); | 250 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); |
| 250 } | 251 } |
| 251 | 252 |
| 252 TEST_F(LockLayoutManagerTest, MultipleMonitors) { | 253 TEST_F(LockLayoutManagerTest, MultipleMonitors) { |
| 253 if (!SupportsMultipleDisplays()) | 254 if (!SupportsMultipleDisplays()) |
| 254 return; | 255 return; |
| 255 | 256 |
| 256 UpdateDisplay("300x400,400x500"); | 257 UpdateDisplay("300x400,400x500"); |
| 257 gfx::Rect screen_bounds = | 258 gfx::Rect screen_bounds = |
| 258 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 259 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 259 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 260 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 260 | 261 |
| 261 views::Widget::InitParams widget_params( | 262 views::Widget::InitParams widget_params( |
| 262 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 263 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 263 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; | 264 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; |
| 264 std::unique_ptr<aura::Window> window( | 265 std::unique_ptr<aura::Window> window( |
| 265 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 266 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
| 266 window->SetProperty(aura::client::kCanMaximizeKey, true); | 267 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 267 | 268 |
| 268 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 269 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 295 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); | 296 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); |
| 296 window->SetBounds(work_area); | 297 window->SetBounds(work_area); |
| 297 // Usually work_area takes Shelf into account but that doesn't affect | 298 // Usually work_area takes Shelf into account but that doesn't affect |
| 298 // LockScreen container windows. | 299 // LockScreen container windows. |
| 299 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 300 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
| 300 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 301 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 301 } | 302 } |
| 302 | 303 |
| 303 } // namespace test | 304 } // namespace test |
| 304 } // namespace ash | 305 } // namespace ash |
| OLD | NEW |