| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/drag_drop/drag_drop_controller.h" | 8 #include "ash/drag_drop/drag_drop_controller.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| 11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 16 #include "ash/test/shelf_test_api.h" | 16 #include "ash/test/shelf_test_api.h" |
| 17 #include "ash/test/shelf_view_test_api.h" | 17 #include "ash/test/shelf_view_test_api.h" |
| 18 #include "ash/test/shell_test_api.h" | 18 #include "ash/test/shell_test_api.h" |
| 19 #include "ash/test/test_shelf_delegate.h" | 19 #include "ash/test/test_shelf_delegate.h" |
| 20 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 20 #include "ash/wm/mru_window_tracker.h" | 21 #include "ash/wm/mru_window_tracker.h" |
| 21 #include "ash/wm/overview/window_grid.h" | 22 #include "ash/wm/overview/window_grid.h" |
| 22 #include "ash/wm/overview/window_selector.h" | 23 #include "ash/wm/overview/window_selector.h" |
| 23 #include "ash/wm/overview/window_selector_controller.h" | 24 #include "ash/wm/overview/window_selector_controller.h" |
| 24 #include "ash/wm/overview/window_selector_item.h" | 25 #include "ash/wm/overview/window_selector_item.h" |
| 25 #include "ash/wm/panels/panel_layout_manager.h" | 26 #include "ash/wm/panels/panel_layout_manager.h" |
| 26 #include "ash/wm/window_state.h" | 27 #include "ash/wm/window_state.h" |
| 27 #include "ash/wm/window_util.h" | 28 #include "ash/wm/window_util.h" |
| 28 #include "ash/wm/wm_event.h" | 29 #include "ash/wm/wm_event.h" |
| 29 #include "base/basictypes.h" | 30 #include "base/basictypes.h" |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 wm::WindowState* window_state = wm::GetWindowState(window1.get()); | 428 wm::WindowState* window_state = wm::GetWindowState(window1.get()); |
| 428 window_state->Maximize(); | 429 window_state->Maximize(); |
| 429 ash::ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf(); | 430 ash::ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf(); |
| 430 EXPECT_TRUE(shelf->GetDimsShelf()); | 431 EXPECT_TRUE(shelf->GetDimsShelf()); |
| 431 ToggleOverview(); | 432 ToggleOverview(); |
| 432 EXPECT_FALSE(shelf->GetDimsShelf()); | 433 EXPECT_FALSE(shelf->GetDimsShelf()); |
| 433 ToggleOverview(); | 434 ToggleOverview(); |
| 434 EXPECT_TRUE(shelf->GetDimsShelf()); | 435 EXPECT_TRUE(shelf->GetDimsShelf()); |
| 435 } | 436 } |
| 436 | 437 |
| 438 // Tests that entering overview when a fullscreen window is active in maximized |
| 439 // mode correctly applies the transformations to the window and correctly |
| 440 // updates the window bounds on exiting overview mode: http://crbug.com/401664. |
| 441 TEST_F(WindowSelectorTest, FullscreenWindowMaximizeMode) { |
| 442 gfx::Rect bounds(0, 0, 400, 400); |
| 443 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 444 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 445 Shell::GetInstance()->maximize_mode_controller()-> |
| 446 EnableMaximizeModeWindowManager(true); |
| 447 wm::ActivateWindow(window2.get()); |
| 448 wm::ActivateWindow(window1.get()); |
| 449 gfx::Rect normal_window_bounds(window1->bounds()); |
| 450 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 451 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event); |
| 452 gfx::Rect fullscreen_window_bounds(window1->bounds()); |
| 453 EXPECT_NE(normal_window_bounds.ToString(), |
| 454 fullscreen_window_bounds.ToString()); |
| 455 EXPECT_EQ(fullscreen_window_bounds.ToString(), |
| 456 window2->GetTargetBounds().ToString()); |
| 457 ToggleOverview(); |
| 458 // Window 2 would normally resize to normal window bounds on showing the shelf |
| 459 // for overview but this is deferred until overview is exited. |
| 460 EXPECT_EQ(fullscreen_window_bounds.ToString(), |
| 461 window2->GetTargetBounds().ToString()); |
| 462 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); |
| 463 ToggleOverview(); |
| 464 |
| 465 // Since the fullscreen window is still active, window2 will still have the |
| 466 // larger bounds. |
| 467 EXPECT_EQ(fullscreen_window_bounds.ToString(), |
| 468 window2->GetTargetBounds().ToString()); |
| 469 |
| 470 // Enter overview again and select window 2. Selecting window 2 should show |
| 471 // the shelf bringing window2 back to the normal bounds. |
| 472 ToggleOverview(); |
| 473 ClickWindow(window2.get()); |
| 474 EXPECT_EQ(normal_window_bounds.ToString(), |
| 475 window2->GetTargetBounds().ToString()); |
| 476 } |
| 477 |
| 437 // Tests that beginning window selection hides the app list. | 478 // Tests that beginning window selection hides the app list. |
| 438 TEST_F(WindowSelectorTest, SelectingHidesAppList) { | 479 TEST_F(WindowSelectorTest, SelectingHidesAppList) { |
| 439 gfx::Rect bounds(0, 0, 400, 400); | 480 gfx::Rect bounds(0, 0, 400, 400); |
| 440 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 481 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 441 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 482 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 442 Shell::GetInstance()->ShowAppList(NULL); | 483 Shell::GetInstance()->ShowAppList(NULL); |
| 443 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 484 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
| 444 ToggleOverview(); | 485 ToggleOverview(); |
| 445 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 486 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
| 446 ToggleOverview(); | 487 ToggleOverview(); |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 // Switch to overview mode. | 1230 // Switch to overview mode. |
| 1190 ToggleOverview(); | 1231 ToggleOverview(); |
| 1191 ASSERT_TRUE(IsSelecting()); | 1232 ASSERT_TRUE(IsSelecting()); |
| 1192 | 1233 |
| 1193 // Tap should now exit overview mode. | 1234 // Tap should now exit overview mode. |
| 1194 generator.GestureTapAt(point_in_background_page); | 1235 generator.GestureTapAt(point_in_background_page); |
| 1195 EXPECT_FALSE(IsSelecting()); | 1236 EXPECT_FALSE(IsSelecting()); |
| 1196 } | 1237 } |
| 1197 | 1238 |
| 1198 } // namespace ash | 1239 } // namespace ash |
| OLD | NEW |