| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 11 #include "ash/common/system/tray/system_tray_delegate.h" | 12 #include "ash/common/system/tray/system_tray_delegate.h" |
| 12 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 13 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 14 #include "ash/display/display_manager.h" | 15 #include "ash/display/display_manager.h" |
| 15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/test/ash_md_test_base.h" |
| 16 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
| 17 #include "ash/test/display_manager_test_api.h" | 19 #include "ash/test/display_manager_test_api.h" |
| 18 #include "ash/wm/system_modal_container_layout_manager.h" | 20 #include "ash/wm/system_modal_container_layout_manager.h" |
| 19 #include "ash/wm/window_properties.h" | 21 #include "ash/wm/window_properties.h" |
| 20 #include "ash/wm/window_state_aura.h" | 22 #include "ash/wm/window_state_aura.h" |
| 21 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
| 22 #include "base/command_line.h" | 24 #include "base/command_line.h" |
| 23 #include "ui/aura/client/focus_change_observer.h" | 25 #include "ui/aura/client/focus_change_observer.h" |
| 24 #include "ui/aura/client/focus_client.h" | 26 #include "ui/aura/client/focus_client.h" |
| 25 #include "ui/aura/client/window_tree_client.h" | 27 #include "ui/aura/client/window_tree_client.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 92 |
| 91 aura::Window* window_; | 93 aura::Window* window_; |
| 92 | 94 |
| 93 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); | 95 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 } // namespace | 98 } // namespace |
| 97 | 99 |
| 98 namespace test { | 100 namespace test { |
| 99 | 101 |
| 100 class RootWindowControllerTest : public test::AshTestBase { | 102 class RootWindowControllerTest : public AshMDTestBase { |
| 101 public: | 103 public: |
| 102 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { | 104 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
| 103 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 105 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| 104 NULL, CurrentContext(), bounds); | 106 NULL, CurrentContext(), bounds); |
| 105 widget->Show(); | 107 widget->Show(); |
| 106 return widget; | 108 return widget; |
| 107 } | 109 } |
| 108 | 110 |
| 109 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { | 111 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { |
| 110 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 112 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 122 widget->Show(); | 124 widget->Show(); |
| 123 return widget; | 125 return widget; |
| 124 } | 126 } |
| 125 | 127 |
| 126 aura::Window* GetModalContainer(aura::Window* root_window) { | 128 aura::Window* GetModalContainer(aura::Window* root_window) { |
| 127 return Shell::GetContainer(root_window, | 129 return Shell::GetContainer(root_window, |
| 128 ash::kShellWindowId_SystemModalContainer); | 130 ash::kShellWindowId_SystemModalContainer); |
| 129 } | 131 } |
| 130 }; | 132 }; |
| 131 | 133 |
| 132 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 134 INSTANTIATE_TEST_CASE_P( |
| 135 /* prefix intentionally left blank due to only one parameterization */, |
| 136 RootWindowControllerTest, |
| 137 testing::Values(MaterialDesignController::NON_MATERIAL, |
| 138 MaterialDesignController::MATERIAL_NORMAL, |
| 139 MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 140 |
| 141 TEST_P(RootWindowControllerTest, MoveWindows_Basic) { |
| 133 if (!SupportsMultipleDisplays()) | 142 if (!SupportsMultipleDisplays()) |
| 134 return; | 143 return; |
| 144 const int height_offset = GetMdMaximizedWindowHeightOffset(); |
| 145 |
| 135 // Windows origin should be doubled when moved to the 1st display. | 146 // Windows origin should be doubled when moved to the 1st display. |
| 136 UpdateDisplay("600x600,300x300"); | 147 UpdateDisplay("600x600,300x300"); |
| 137 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 148 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 138 | 149 |
| 139 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 150 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
| 140 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 151 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
| 141 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 152 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
| 142 EXPECT_EQ("50,10 100x100", | 153 EXPECT_EQ("50,10 100x100", |
| 143 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 154 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 144 | 155 |
| 145 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); | 156 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); |
| 146 maximized->Maximize(); | 157 maximized->Maximize(); |
| 147 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); | 158 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); |
| 148 EXPECT_EQ("600,0 300x253", maximized->GetWindowBoundsInScreen().ToString()); | 159 EXPECT_EQ(gfx::Rect(600, 0, 300, 253 + height_offset).ToString(), |
| 149 EXPECT_EQ("0,0 300x253", | 160 maximized->GetWindowBoundsInScreen().ToString()); |
| 161 EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(), |
| 150 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 162 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 151 | 163 |
| 152 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | 164 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
| 153 minimized->Minimize(); | 165 minimized->Minimize(); |
| 154 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); | 166 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); |
| 155 EXPECT_EQ("800,10 100x100", | 167 EXPECT_EQ("800,10 100x100", |
| 156 minimized->GetWindowBoundsInScreen().ToString()); | 168 minimized->GetWindowBoundsInScreen().ToString()); |
| 157 | 169 |
| 158 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); | 170 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); |
| 159 fullscreen->SetFullscreen(true); | 171 fullscreen->SetFullscreen(true); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 EXPECT_EQ("100,20 100x100", | 212 EXPECT_EQ("100,20 100x100", |
| 201 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 213 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 202 | 214 |
| 203 // Maximized area on primary display has 47px for non-md and 48px for md | 215 // Maximized area on primary display has 47px for non-md and 48px for md |
| 204 // (defined in ash::SHELF_SIZE) inset at the bottom. | 216 // (defined in ash::SHELF_SIZE) inset at the bottom. |
| 205 | 217 |
| 206 // First clear fullscreen status, since both fullscreen and maximized windows | 218 // First clear fullscreen status, since both fullscreen and maximized windows |
| 207 // share the same desktop workspace, which cancels the shelf status. | 219 // share the same desktop workspace, which cancels the shelf status. |
| 208 fullscreen->SetFullscreen(false); | 220 fullscreen->SetFullscreen(false); |
| 209 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 221 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
| 210 EXPECT_EQ("0,0 600x553", maximized->GetWindowBoundsInScreen().ToString()); | 222 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
| 211 EXPECT_EQ("0,0 600x553", | 223 maximized->GetWindowBoundsInScreen().ToString()); |
| 224 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
| 212 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 225 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 213 | 226 |
| 214 // Set fullscreen to true, but maximized window's size won't change because | 227 // Set fullscreen to true, but maximized window's size won't change because |
| 215 // it's not visible. see crbug.com/504299. | 228 // it's not visible. see crbug.com/504299. |
| 216 fullscreen->SetFullscreen(true); | 229 fullscreen->SetFullscreen(true); |
| 217 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 230 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
| 218 EXPECT_EQ("0,0 600x553", maximized->GetWindowBoundsInScreen().ToString()); | 231 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
| 219 EXPECT_EQ("0,0 600x553", | 232 maximized->GetWindowBoundsInScreen().ToString()); |
| 233 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
| 220 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 234 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 221 | 235 |
| 222 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); | 236 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); |
| 223 EXPECT_EQ("400,20 100x100", | 237 EXPECT_EQ("400,20 100x100", |
| 224 minimized->GetWindowBoundsInScreen().ToString()); | 238 minimized->GetWindowBoundsInScreen().ToString()); |
| 225 | 239 |
| 226 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); | 240 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); |
| 227 EXPECT_TRUE(fullscreen->IsFullscreen()); | 241 EXPECT_TRUE(fullscreen->IsFullscreen()); |
| 228 EXPECT_EQ("0,0 600x600", | 242 EXPECT_EQ("0,0 600x600", |
| 229 fullscreen->GetWindowBoundsInScreen().ToString()); | 243 fullscreen->GetWindowBoundsInScreen().ToString()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 246 EXPECT_EQ(root_windows[0], | 260 EXPECT_EQ(root_windows[0], |
| 247 unparented_control->GetNativeView()->GetRootWindow()); | 261 unparented_control->GetNativeView()->GetRootWindow()); |
| 248 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, | 262 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, |
| 249 unparented_control->GetNativeView()->parent()->id()); | 263 unparented_control->GetNativeView()->parent()->id()); |
| 250 | 264 |
| 251 // Test if the panel has moved. | 265 // Test if the panel has moved. |
| 252 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); | 266 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); |
| 253 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); | 267 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); |
| 254 } | 268 } |
| 255 | 269 |
| 256 TEST_F(RootWindowControllerTest, MoveWindows_Modal) { | 270 TEST_P(RootWindowControllerTest, MoveWindows_Modal) { |
| 257 if (!SupportsMultipleDisplays()) | 271 if (!SupportsMultipleDisplays()) |
| 258 return; | 272 return; |
| 259 | 273 |
| 260 UpdateDisplay("500x500,500x500"); | 274 UpdateDisplay("500x500,500x500"); |
| 261 | 275 |
| 262 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 276 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 263 // Emulate virtual screen coordinate system. | 277 // Emulate virtual screen coordinate system. |
| 264 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); | 278 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 265 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); | 279 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); |
| 266 | 280 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 279 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 293 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 280 | 294 |
| 281 UpdateDisplay("500x500"); | 295 UpdateDisplay("500x500"); |
| 282 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); | 296 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
| 283 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 297 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 284 generator_1st.ClickLeftButton(); | 298 generator_1st.ClickLeftButton(); |
| 285 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 299 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 286 } | 300 } |
| 287 | 301 |
| 288 // Make sure lock related windows moves. | 302 // Make sure lock related windows moves. |
| 289 TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { | 303 TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { |
| 290 if (!SupportsMultipleDisplays()) | 304 if (!SupportsMultipleDisplays()) |
| 291 return; | 305 return; |
| 292 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); | 306 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); |
| 293 | 307 |
| 294 UpdateDisplay("500x500"); | 308 UpdateDisplay("500x500"); |
| 295 const int kLockScreenWindowId = 1000; | 309 const int kLockScreenWindowId = 1000; |
| 296 const int kLockBackgroundWindowId = 1001; | 310 const int kLockBackgroundWindowId = 1001; |
| 297 | 311 |
| 298 RootWindowController* controller = | 312 RootWindowController* controller = |
| 299 Shell::GetInstance()->GetPrimaryRootWindowController(); | 313 Shell::GetInstance()->GetPrimaryRootWindowController(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 375 |
| 362 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); | 376 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); |
| 363 | 377 |
| 364 ASSERT_EQ(lock_screen->GetNativeWindow(), | 378 ASSERT_EQ(lock_screen->GetNativeWindow(), |
| 365 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); | 379 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); |
| 366 ASSERT_EQ(lock_background->GetNativeWindow(), | 380 ASSERT_EQ(lock_background->GetNativeWindow(), |
| 367 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); | 381 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); |
| 368 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); | 382 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); |
| 369 } | 383 } |
| 370 | 384 |
| 371 TEST_F(RootWindowControllerTest, ModalContainer) { | 385 TEST_P(RootWindowControllerTest, ModalContainer) { |
| 372 UpdateDisplay("600x600"); | 386 UpdateDisplay("600x600"); |
| 373 Shell* shell = Shell::GetInstance(); | 387 Shell* shell = Shell::GetInstance(); |
| 374 WmShell* wm_shell = WmShell::Get(); | 388 WmShell* wm_shell = WmShell::Get(); |
| 375 RootWindowController* controller = shell->GetPrimaryRootWindowController(); | 389 RootWindowController* controller = shell->GetPrimaryRootWindowController(); |
| 376 EXPECT_EQ(LoginStatus::USER, | 390 EXPECT_EQ(LoginStatus::USER, |
| 377 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 391 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
| 378 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 392 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
| 379 ->layout_manager(), | 393 ->layout_manager(), |
| 380 controller->GetSystemModalLayoutManager(NULL)); | 394 controller->GetSystemModalLayoutManager(NULL)); |
| 381 | 395 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 402 controller->GetSystemModalLayoutManager( | 416 controller->GetSystemModalLayoutManager( |
| 403 lock_modal_widget->GetNativeView())); | 417 lock_modal_widget->GetNativeView())); |
| 404 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 418 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
| 405 ->layout_manager(), | 419 ->layout_manager(), |
| 406 controller->GetSystemModalLayoutManager( | 420 controller->GetSystemModalLayoutManager( |
| 407 session_modal_widget->GetNativeView())); | 421 session_modal_widget->GetNativeView())); |
| 408 | 422 |
| 409 shell->session_state_delegate()->UnlockScreen(); | 423 shell->session_state_delegate()->UnlockScreen(); |
| 410 } | 424 } |
| 411 | 425 |
| 412 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { | 426 TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { |
| 413 UpdateDisplay("600x600"); | 427 UpdateDisplay("600x600"); |
| 414 Shell* shell = Shell::GetInstance(); | 428 Shell* shell = Shell::GetInstance(); |
| 415 WmShell* wm_shell = WmShell::Get(); | 429 WmShell* wm_shell = WmShell::Get(); |
| 416 | 430 |
| 417 // Configure login screen environment. | 431 // Configure login screen environment. |
| 418 SetUserLoggedIn(false); | 432 SetUserLoggedIn(false); |
| 419 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, | 433 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, |
| 420 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 434 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
| 421 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); | 435 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); |
| 422 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); | 436 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 448 controller->GetSystemModalLayoutManager(NULL)); | 462 controller->GetSystemModalLayoutManager(NULL)); |
| 449 | 463 |
| 450 views::Widget* session_modal_widget = | 464 views::Widget* session_modal_widget = |
| 451 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 465 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 452 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 466 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
| 453 ->layout_manager(), | 467 ->layout_manager(), |
| 454 controller->GetSystemModalLayoutManager( | 468 controller->GetSystemModalLayoutManager( |
| 455 session_modal_widget->GetNativeView())); | 469 session_modal_widget->GetNativeView())); |
| 456 } | 470 } |
| 457 | 471 |
| 458 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { | 472 TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) { |
| 459 UpdateDisplay("600x600"); | 473 UpdateDisplay("600x600"); |
| 460 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 474 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
| 461 aura::Window* lock_container = | 475 aura::Window* lock_container = |
| 462 controller->GetContainer(kShellWindowId_LockScreenContainer); | 476 controller->GetContainer(kShellWindowId_LockScreenContainer); |
| 463 for (int block_reason = FIRST_BLOCK_REASON; | 477 for (int block_reason = FIRST_BLOCK_REASON; |
| 464 block_reason < NUMBER_OF_BLOCK_REASONS; | 478 block_reason < NUMBER_OF_BLOCK_REASONS; |
| 465 ++block_reason) { | 479 ++block_reason) { |
| 466 views::Widget* session_modal_widget = | 480 views::Widget* session_modal_widget = |
| 467 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 481 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 468 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 482 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 494 ->layout_manager(), | 508 ->layout_manager(), |
| 495 controller->GetSystemModalLayoutManager( | 509 controller->GetSystemModalLayoutManager( |
| 496 session_modal_widget->GetNativeView())); | 510 session_modal_widget->GetNativeView())); |
| 497 session_modal_widget->Close(); | 511 session_modal_widget->Close(); |
| 498 | 512 |
| 499 lock_modal_widget->Close(); | 513 lock_modal_widget->Close(); |
| 500 UnblockUserSession(); | 514 UnblockUserSession(); |
| 501 } | 515 } |
| 502 } | 516 } |
| 503 | 517 |
| 504 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) { | 518 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) { |
| 505 UpdateDisplay("600x600"); | 519 UpdateDisplay("600x600"); |
| 506 RootWindowController* controller = | 520 RootWindowController* controller = |
| 507 Shell::GetInstance()->GetPrimaryRootWindowController(); | 521 Shell::GetInstance()->GetPrimaryRootWindowController(); |
| 508 | 522 |
| 509 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 523 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| 510 w1->Maximize(); | 524 w1->Maximize(); |
| 511 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 525 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| 512 w2->SetFullscreen(true); | 526 w2->SetFullscreen(true); |
| 513 // |w3| is a transient child of |w2|. | 527 // |w3| is a transient child of |w2|. |
| 514 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, | 528 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 526 w3->Close(); | 540 w3->Close(); |
| 527 | 541 |
| 528 // Only w2 remains, if minimized GetWindowForFullscreenMode should return | 542 // Only w2 remains, if minimized GetWindowForFullscreenMode should return |
| 529 // NULL. | 543 // NULL. |
| 530 w2->Activate(); | 544 w2->Activate(); |
| 531 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); | 545 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); |
| 532 w2->Minimize(); | 546 w2->Minimize(); |
| 533 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); | 547 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); |
| 534 } | 548 } |
| 535 | 549 |
| 536 TEST_F(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) { | 550 TEST_P(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) { |
| 537 if (!SupportsMultipleDisplays()) | 551 if (!SupportsMultipleDisplays()) |
| 538 return; | 552 return; |
| 539 | 553 |
| 540 UpdateDisplay("600x600,600x600"); | 554 UpdateDisplay("600x600,600x600"); |
| 541 Shell::RootWindowControllerList controllers = | 555 Shell::RootWindowControllerList controllers = |
| 542 Shell::GetInstance()->GetAllRootWindowControllers(); | 556 Shell::GetInstance()->GetAllRootWindowControllers(); |
| 543 | 557 |
| 544 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 558 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| 545 w1->Maximize(); | 559 w1->Maximize(); |
| 546 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 560 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 566 // Verify that the first root window controller remains in fullscreen mode | 580 // Verify that the first root window controller remains in fullscreen mode |
| 567 // when a window on the other display is activated. | 581 // when a window on the other display is activated. |
| 568 w3->Activate(); | 582 w3->Activate(); |
| 569 EXPECT_EQ(w2->GetNativeWindow(), | 583 EXPECT_EQ(w2->GetNativeWindow(), |
| 570 controllers[0]->GetWindowForFullscreenMode()); | 584 controllers[0]->GetWindowForFullscreenMode()); |
| 571 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); | 585 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); |
| 572 } | 586 } |
| 573 | 587 |
| 574 // Test that GetRootWindowController() works with multiple displays and | 588 // Test that GetRootWindowController() works with multiple displays and |
| 575 // child widgets. | 589 // child widgets. |
| 576 TEST_F(RootWindowControllerTest, GetRootWindowController) { | 590 TEST_P(RootWindowControllerTest, GetRootWindowController) { |
| 577 if (!SupportsMultipleDisplays()) | 591 if (!SupportsMultipleDisplays()) |
| 578 return; | 592 return; |
| 579 UpdateDisplay("600x600,600x600"); | 593 UpdateDisplay("600x600,600x600"); |
| 580 Shell::RootWindowControllerList controllers = | 594 Shell::RootWindowControllerList controllers = |
| 581 Shell::GetInstance()->GetAllRootWindowControllers(); | 595 Shell::GetInstance()->GetAllRootWindowControllers(); |
| 582 ASSERT_EQ(2u, controllers.size()); | 596 ASSERT_EQ(2u, controllers.size()); |
| 583 | 597 |
| 584 // Test null. | 598 // Test null. |
| 585 EXPECT_FALSE(GetRootWindowController(nullptr)); | 599 EXPECT_FALSE(GetRootWindowController(nullptr)); |
| 586 | 600 |
| 587 // Test a widget on the first display. | 601 // Test a widget on the first display. |
| 588 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 602 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| 589 EXPECT_EQ(controllers[0], | 603 EXPECT_EQ(controllers[0], |
| 590 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); | 604 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); |
| 591 | 605 |
| 592 // Test a child widget. | 606 // Test a child widget. |
| 593 Widget* w2 = Widget::CreateWindowWithParentAndBounds( | 607 Widget* w2 = Widget::CreateWindowWithParentAndBounds( |
| 594 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); | 608 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); |
| 595 EXPECT_EQ(controllers[0], | 609 EXPECT_EQ(controllers[0], |
| 596 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); | 610 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); |
| 597 | 611 |
| 598 // Test a widget on the second display. | 612 // Test a widget on the second display. |
| 599 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); | 613 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); |
| 600 EXPECT_EQ(controllers[1], | 614 EXPECT_EQ(controllers[1], |
| 601 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); | 615 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); |
| 602 } | 616 } |
| 603 | 617 |
| 604 // Test that user session window can't be focused if user session blocked by | 618 // Test that user session window can't be focused if user session blocked by |
| 605 // some overlapping UI. | 619 // some overlapping UI. |
| 606 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { | 620 TEST_P(RootWindowControllerTest, FocusBlockedWindow) { |
| 607 UpdateDisplay("600x600"); | 621 UpdateDisplay("600x600"); |
| 608 RootWindowController* controller = | 622 RootWindowController* controller = |
| 609 Shell::GetInstance()->GetPrimaryRootWindowController(); | 623 Shell::GetInstance()->GetPrimaryRootWindowController(); |
| 610 aura::Window* lock_container = | 624 aura::Window* lock_container = |
| 611 controller->GetContainer(kShellWindowId_LockScreenContainer); | 625 controller->GetContainer(kShellWindowId_LockScreenContainer); |
| 612 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, | 626 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, |
| 613 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 627 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
| 614 lock_window->Show(); | 628 lock_window->Show(); |
| 615 aura::Window* session_window = | 629 aura::Window* session_window = |
| 616 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 630 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 window_ = NULL; | 669 window_ = NULL; |
| 656 } | 670 } |
| 657 | 671 |
| 658 bool destroyed_; | 672 bool destroyed_; |
| 659 Window* window_; | 673 Window* window_; |
| 660 | 674 |
| 661 DISALLOW_COPY_AND_ASSIGN(DestroyedWindowObserver); | 675 DISALLOW_COPY_AND_ASSIGN(DestroyedWindowObserver); |
| 662 }; | 676 }; |
| 663 | 677 |
| 664 // Verifies shutdown doesn't delete windows that are not owned by the parent. | 678 // Verifies shutdown doesn't delete windows that are not owned by the parent. |
| 665 TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { | 679 TEST_P(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { |
| 666 DestroyedWindowObserver observer1; | 680 DestroyedWindowObserver observer1; |
| 667 aura::test::TestWindowDelegate delegate1; | 681 aura::test::TestWindowDelegate delegate1; |
| 668 aura::Window* window1 = new aura::Window(&delegate1); | 682 aura::Window* window1 = new aura::Window(&delegate1); |
| 669 window1->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 683 window1->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
| 670 window1->set_owned_by_parent(false); | 684 window1->set_owned_by_parent(false); |
| 671 observer1.SetWindow(window1); | 685 observer1.SetWindow(window1); |
| 672 window1->Init(ui::LAYER_NOT_DRAWN); | 686 window1->Init(ui::LAYER_NOT_DRAWN); |
| 673 aura::client::ParentWindowWithContext( | 687 aura::client::ParentWindowWithContext( |
| 674 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect()); | 688 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect()); |
| 675 | 689 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1060 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1047 gfx::Rect(0, 400, 800, 200)); | 1061 gfx::Rect(0, 400, 800, 200)); |
| 1048 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1062 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1049 | 1063 |
| 1050 UpdateDisplay("600x800"); | 1064 UpdateDisplay("600x800"); |
| 1051 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1065 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1052 } | 1066 } |
| 1053 | 1067 |
| 1054 } // namespace test | 1068 } // namespace test |
| 1055 } // namespace ash | 1069 } // namespace ash |
| OLD | NEW |