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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 internal::kShellWindowId_SystemModalContainer)->layout_manager(), | 444 internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
445 controller->GetSystemModalLayoutManager( | 445 controller->GetSystemModalLayoutManager( |
446 session_modal_widget->GetNativeView())); | 446 session_modal_widget->GetNativeView())); |
447 session_modal_widget->Close(); | 447 session_modal_widget->Close(); |
448 | 448 |
449 lock_modal_widget->Close(); | 449 lock_modal_widget->Close(); |
450 UnblockUserSession(); | 450 UnblockUserSession(); |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 // Test that GetFullscreenWindow() returns a fullscreen window only if the | 454 TEST_F(RootWindowControllerTest, GetTopmostFullscreenWindow) { |
455 // fullscreen window is in the active workspace. | |
456 TEST_F(RootWindowControllerTest, GetFullscreenWindow) { | |
457 UpdateDisplay("600x600"); | 455 UpdateDisplay("600x600"); |
458 internal::RootWindowController* controller = | 456 internal::RootWindowController* controller = |
459 Shell::GetInstance()->GetPrimaryRootWindowController(); | 457 Shell::GetInstance()->GetPrimaryRootWindowController(); |
460 | 458 |
461 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 459 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
462 w1->Maximize(); | 460 w1->Maximize(); |
463 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 461 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
464 w2->SetFullscreen(true); | 462 w2->SetFullscreen(true); |
465 // |w3| is a transient child of |w2|. | 463 // |w3| is a transient child of |w2|. |
466 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, | 464 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, |
467 w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); | 465 w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); |
468 | 466 |
469 // Test that GetFullscreenWindow() finds the fullscreen window when one of | 467 // Test that GetTopmostFullscreenWindow() finds the fullscreen window when one |
470 // its transient children is active. | 468 // of its transient children is active. |
471 w3->Activate(); | 469 w3->Activate(); |
472 EXPECT_EQ(w2->GetNativeWindow(), controller->GetFullscreenWindow()); | 470 EXPECT_EQ(w2->GetNativeWindow(), controller->GetTopmostFullscreenWindow()); |
473 | 471 |
474 // Since there's only one desktop workspace, it always returns the same | 472 // Since there's only one desktop workspace, it always returns the same |
475 // fullscreen window. | 473 // fullscreen window. |
476 w1->Activate(); | 474 w1->Activate(); |
477 EXPECT_EQ(w2->GetNativeWindow(), controller->GetFullscreenWindow()); | 475 EXPECT_EQ(w2->GetNativeWindow(), controller->GetTopmostFullscreenWindow()); |
| 476 } |
| 477 |
| 478 TEST_F(RootWindowControllerTest, MultipleFullscreenWindows) { |
| 479 UpdateDisplay("600x600"); |
| 480 internal::RootWindowController* controller = |
| 481 Shell::GetInstance()->GetPrimaryRootWindowController(); |
| 482 |
| 483 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| 484 w1->Maximize(); |
| 485 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| 486 w2->SetFullscreen(true); |
| 487 Widget* w3 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| 488 w3->SetFullscreen(true); |
| 489 |
| 490 // Test that GetTopmostFullscreenWindow() finds the active fullscreen window. |
| 491 w2->Activate(); |
| 492 EXPECT_EQ(w2->GetNativeWindow(), controller->GetTopmostFullscreenWindow()); |
| 493 w3->Activate(); |
| 494 EXPECT_EQ(w3->GetNativeWindow(), controller->GetTopmostFullscreenWindow()); |
| 495 |
| 496 // If the active window is not fullscreen, it still returns the topmost |
| 497 // fullscreen window, which is the last active one. |
| 498 w1->Activate(); |
| 499 EXPECT_EQ(w3->GetNativeWindow(), controller->GetTopmostFullscreenWindow()); |
478 } | 500 } |
479 | 501 |
480 // Test that user session window can't be focused if user session blocked by | 502 // Test that user session window can't be focused if user session blocked by |
481 // some overlapping UI. | 503 // some overlapping UI. |
482 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { | 504 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { |
483 UpdateDisplay("600x600"); | 505 UpdateDisplay("600x600"); |
484 internal::RootWindowController* controller = | 506 internal::RootWindowController* controller = |
485 Shell::GetInstance()->GetPrimaryRootWindowController(); | 507 Shell::GetInstance()->GetPrimaryRootWindowController(); |
486 aura::Window* lock_container = | 508 aura::Window* lock_container = |
487 Shell::GetContainer(controller->root_window(), | 509 Shell::GetContainer(controller->root_window(), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); | 588 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
567 event_generator.ClickLeftButton(); | 589 event_generator.ClickLeftButton(); |
568 expected_mouse_presses++; | 590 expected_mouse_presses++; |
569 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses()); | 591 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses()); |
570 UnblockUserSession(); | 592 UnblockUserSession(); |
571 } | 593 } |
572 } | 594 } |
573 | 595 |
574 } // namespace test | 596 } // namespace test |
575 } // namespace ash | 597 } // namespace ash |
OLD | NEW |