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 "ash/session_state_delegate.h" | 7 #include "ash/session_state_delegate.h" |
8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 controller->GetSystemModalLayoutManager(NULL)); | 350 controller->GetSystemModalLayoutManager(NULL)); |
351 | 351 |
352 views::Widget* session_modal_widget = | 352 views::Widget* session_modal_widget = |
353 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 353 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
354 EXPECT_EQ(Shell::GetContainer(controller->root_window(), | 354 EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
355 internal::kShellWindowId_SystemModalContainer)->layout_manager(), | 355 internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
356 controller->GetSystemModalLayoutManager( | 356 controller->GetSystemModalLayoutManager( |
357 session_modal_widget->GetNativeView())); | 357 session_modal_widget->GetNativeView())); |
358 } | 358 } |
359 | 359 |
| 360 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { |
| 361 UpdateDisplay("600x600"); |
| 362 Shell* shell = Shell::GetInstance(); |
| 363 internal::RootWindowController* controller = |
| 364 shell->GetPrimaryRootWindowController(); |
| 365 aura::Window* lock_container = |
| 366 Shell::GetContainer(controller->root_window(), |
| 367 internal::kShellWindowId_LockScreenContainer); |
| 368 for (int block_reason = FIRST_BLOCK_REASON; |
| 369 block_reason < NUMBER_OF_BLOCK_REASONS; |
| 370 ++block_reason) { |
| 371 views::Widget* session_modal_widget = |
| 372 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 373 EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 374 internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
| 375 controller->GetSystemModalLayoutManager( |
| 376 session_modal_widget->GetNativeView())); |
| 377 EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 378 internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
| 379 controller->GetSystemModalLayoutManager(NULL)); |
| 380 session_modal_widget->Close(); |
| 381 |
| 382 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
| 383 |
| 384 EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 385 internal::kShellWindowId_LockSystemModalContainer)->layout_manager(), |
| 386 controller->GetSystemModalLayoutManager(NULL)); |
| 387 |
| 388 views::Widget* lock_modal_widget = |
| 389 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), |
| 390 lock_container); |
| 391 EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 392 internal::kShellWindowId_LockSystemModalContainer)->layout_manager(), |
| 393 controller->GetSystemModalLayoutManager( |
| 394 lock_modal_widget->GetNativeView())); |
| 395 |
| 396 session_modal_widget = |
| 397 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 398 EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 399 internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
| 400 controller->GetSystemModalLayoutManager( |
| 401 session_modal_widget->GetNativeView())); |
| 402 session_modal_widget->Close(); |
| 403 |
| 404 lock_modal_widget->Close(); |
| 405 UnblockUserSession(); |
| 406 } |
| 407 } |
| 408 |
360 // Test that GetFullscreenWindow() returns a fullscreen window only if the | 409 // Test that GetFullscreenWindow() returns a fullscreen window only if the |
361 // fullscreen window is in the active workspace. | 410 // fullscreen window is in the active workspace. |
362 TEST_F(RootWindowControllerTest, GetFullscreenWindow) { | 411 TEST_F(RootWindowControllerTest, GetFullscreenWindow) { |
363 UpdateDisplay("600x600"); | 412 UpdateDisplay("600x600"); |
364 internal::RootWindowController* controller = | 413 internal::RootWindowController* controller = |
365 Shell::GetInstance()->GetPrimaryRootWindowController(); | 414 Shell::GetInstance()->GetPrimaryRootWindowController(); |
366 | 415 |
367 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 416 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
368 w1->Maximize(); | 417 w1->Maximize(); |
369 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 418 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
(...skipping 26 matching lines...) Expand all Loading... |
396 aura::Window* lock_container = | 445 aura::Window* lock_container = |
397 Shell::GetContainer(controller->root_window(), | 446 Shell::GetContainer(controller->root_window(), |
398 internal::kShellWindowId_LockScreenContainer); | 447 internal::kShellWindowId_LockScreenContainer); |
399 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, | 448 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, |
400 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 449 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
401 lock_window->Show(); | 450 lock_window->Show(); |
402 aura::Window* session_window = | 451 aura::Window* session_window = |
403 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 452 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
404 session_window->Show(); | 453 session_window->Show(); |
405 | 454 |
406 // Lock screen. | 455 for (int block_reason = FIRST_BLOCK_REASON; |
407 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 456 block_reason < NUMBER_OF_BLOCK_REASONS; |
408 lock_window->Focus(); | 457 ++block_reason) { |
409 EXPECT_TRUE(lock_window->HasFocus()); | 458 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
410 session_window->Focus(); | 459 lock_window->Focus(); |
411 EXPECT_FALSE(session_window->HasFocus()); | 460 EXPECT_TRUE(lock_window->HasFocus()); |
412 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 461 session_window->Focus(); |
413 | 462 EXPECT_FALSE(session_window->HasFocus()); |
414 // Session not started yet. | 463 UnblockUserSession(); |
415 SetSessionStarted(false); | 464 } |
416 lock_window->Focus(); | |
417 EXPECT_TRUE(lock_window->HasFocus()); | |
418 session_window->Focus(); | |
419 EXPECT_FALSE(session_window->HasFocus()); | |
420 SetSessionStarted(true); | |
421 } | 465 } |
422 | 466 |
423 } // namespace test | 467 } // namespace test |
424 } // namespace ash | 468 } // namespace ash |
OLD | NEW |