| 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 "ash/wm/workspace_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/shelf/shelf.h" | |
| 11 #include "ash/common/shelf/shelf_layout_manager.h" | 10 #include "ash/common/shelf/shelf_layout_manager.h" |
| 12 #include "ash/common/shelf/shelf_widget.h" | 11 #include "ash/common/shelf/shelf_widget.h" |
| 12 #include "ash/common/shelf/wm_shelf.h" |
| 13 #include "ash/common/shell_window_ids.h" | 13 #include "ash/common/shell_window_ids.h" |
| 14 #include "ash/common/system/status_area_widget.h" | 14 #include "ash/common/system/status_area_widget.h" |
| 15 #include "ash/common/wm/panels/panel_layout_manager.h" | 15 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 16 #include "ash/common/wm/window_state.h" | 16 #include "ash/common/wm/window_state.h" |
| 17 #include "ash/common/wm/workspace/workspace_window_resizer.h" | 17 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
| 18 #include "ash/root_window_controller.h" | 18 #include "ash/root_window_controller.h" |
| 19 #include "ash/screen_util.h" | 19 #include "ash/screen_util.h" |
| 20 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 21 #include "ash/test/ash_md_test_base.h" | 21 #include "ash/test/ash_md_test_base.h" |
| 22 #include "ash/test/shell_test_api.h" | 22 #include "ash/test/shell_test_api.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // updated. | 372 // updated. |
| 373 TEST_P(WorkspaceControllerTest, ShelfStateUpdated) { | 373 TEST_P(WorkspaceControllerTest, ShelfStateUpdated) { |
| 374 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 374 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 375 // it isn't over the shelf. | 375 // it isn't over the shelf. |
| 376 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 376 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 377 gfx::Point()); | 377 gfx::Point()); |
| 378 generator.MoveMouseTo(0, 0); | 378 generator.MoveMouseTo(0, 0); |
| 379 | 379 |
| 380 std::unique_ptr<Window> w1(CreateTestWindow()); | 380 std::unique_ptr<Window> w1(CreateTestWindow()); |
| 381 const gfx::Rect w1_bounds(0, 1, 101, 102); | 381 const gfx::Rect w1_bounds(0, 1, 101, 102); |
| 382 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 382 WmShelf* shelf = GetPrimaryShelf(); |
| 383 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 383 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 384 const gfx::Rect touches_shelf_bounds( | 384 const gfx::Rect touches_shelf_bounds( |
| 385 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102); | 385 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102); |
| 386 // Move |w1| to overlap the shelf. | 386 // Move |w1| to overlap the shelf. |
| 387 w1->SetBounds(touches_shelf_bounds); | 387 w1->SetBounds(touches_shelf_bounds); |
| 388 EXPECT_FALSE(GetWindowOverlapsShelf()); | 388 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 389 | 389 |
| 390 // A visible ignored window should not trigger the overlap. | 390 // A visible ignored window should not trigger the overlap. |
| 391 std::unique_ptr<Window> w_ignored(CreateTestWindow()); | 391 std::unique_ptr<Window> w_ignored(CreateTestWindow()); |
| 392 w_ignored->SetBounds(touches_shelf_bounds); | 392 w_ignored->SetBounds(touches_shelf_bounds); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 // Verifies going from maximized to minimized sets the right state for painting | 512 // Verifies going from maximized to minimized sets the right state for painting |
| 513 // the background of the launcher. | 513 // the background of the launcher. |
| 514 TEST_P(WorkspaceControllerTest, MinimizeResetsVisibility) { | 514 TEST_P(WorkspaceControllerTest, MinimizeResetsVisibility) { |
| 515 std::unique_ptr<Window> w1(CreateTestWindow()); | 515 std::unique_ptr<Window> w1(CreateTestWindow()); |
| 516 w1->Show(); | 516 w1->Show(); |
| 517 wm::ActivateWindow(w1.get()); | 517 wm::ActivateWindow(w1.get()); |
| 518 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 518 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 519 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType()); | 519 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType()); |
| 520 | 520 |
| 521 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 521 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 522 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 522 EXPECT_EQ(SHELF_VISIBLE, GetPrimaryShelf()->GetVisibilityState()); |
| 523 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | |
| 524 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); | 523 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); |
| 525 } | 524 } |
| 526 | 525 |
| 527 // Verifies window visibility during various workspace changes. | 526 // Verifies window visibility during various workspace changes. |
| 528 TEST_P(WorkspaceControllerTest, VisibilityTests) { | 527 TEST_P(WorkspaceControllerTest, VisibilityTests) { |
| 529 std::unique_ptr<Window> w1(CreateTestWindow()); | 528 std::unique_ptr<Window> w1(CreateTestWindow()); |
| 530 w1->Show(); | 529 w1->Show(); |
| 531 EXPECT_TRUE(w1->IsVisible()); | 530 EXPECT_TRUE(w1->IsVisible()); |
| 532 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 531 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 533 | 532 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 | 668 |
| 670 } // namespace | 669 } // namespace |
| 671 | 670 |
| 672 // Exercises possible crash in W2. Here's the sequence: | 671 // Exercises possible crash in W2. Here's the sequence: |
| 673 // . minimize a maximized window. | 672 // . minimize a maximized window. |
| 674 // . remove the window (which happens when switching displays). | 673 // . remove the window (which happens when switching displays). |
| 675 // . add the window back. | 674 // . add the window back. |
| 676 // . show the window and during the bounds change activate it. | 675 // . show the window and during the bounds change activate it. |
| 677 TEST_P(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { | 676 TEST_P(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { |
| 678 // Force the shelf | 677 // Force the shelf |
| 679 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 678 WmShelf* shelf = GetPrimaryShelf(); |
| 680 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 679 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 681 | 680 |
| 682 DontCrashOnChangeAndActivateDelegate delegate; | 681 DontCrashOnChangeAndActivateDelegate delegate; |
| 683 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( | 682 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( |
| 684 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); | 683 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); |
| 685 | 684 |
| 686 w1->Show(); | 685 w1->Show(); |
| 687 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); | 686 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); |
| 688 w1_state->Activate(); | 687 w1_state->Activate(); |
| 689 w1_state->Maximize(); | 688 w1_state->Maximize(); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 | 1394 |
| 1396 // Verifies that when dragging a window over the shelf overlap is detected | 1395 // Verifies that when dragging a window over the shelf overlap is detected |
| 1397 // during and after the drag. | 1396 // during and after the drag. |
| 1398 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { | 1397 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { |
| 1399 aura::test::TestWindowDelegate delegate; | 1398 aura::test::TestWindowDelegate delegate; |
| 1400 delegate.set_window_component(HTCAPTION); | 1399 delegate.set_window_component(HTCAPTION); |
| 1401 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( | 1400 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
| 1402 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); | 1401 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
| 1403 ParentWindowInPrimaryRootWindow(w1.get()); | 1402 ParentWindowInPrimaryRootWindow(w1.get()); |
| 1404 | 1403 |
| 1405 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 1404 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1406 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
| 1407 | 1405 |
| 1408 // Drag near the shelf. | 1406 // Drag near the shelf. |
| 1409 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1407 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1410 gfx::Point()); | 1408 gfx::Point()); |
| 1411 generator.MoveMouseTo(10, 10); | 1409 generator.MoveMouseTo(10, 10); |
| 1412 generator.PressLeftButton(); | 1410 generator.PressLeftButton(); |
| 1413 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 70); | 1411 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 70); |
| 1414 | 1412 |
| 1415 // Shelf should not be in overlapped state. | 1413 // Shelf should not be in overlapped state. |
| 1416 EXPECT_FALSE(GetWindowOverlapsShelf()); | 1414 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 1417 | 1415 |
| 1418 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 20); | 1416 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 20); |
| 1419 | 1417 |
| 1420 // Shelf should detect overlap. Overlap state stays after mouse is released. | 1418 // Shelf should detect overlap. Overlap state stays after mouse is released. |
| 1421 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1419 EXPECT_TRUE(GetWindowOverlapsShelf()); |
| 1422 generator.ReleaseLeftButton(); | 1420 generator.ReleaseLeftButton(); |
| 1423 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1421 EXPECT_TRUE(GetWindowOverlapsShelf()); |
| 1424 } | 1422 } |
| 1425 | 1423 |
| 1426 // Verifies that when dragging a window autohidden shelf stays hidden during | 1424 // Verifies that when dragging a window autohidden shelf stays hidden during |
| 1427 // and after the drag. | 1425 // and after the drag. |
| 1428 TEST_P(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { | 1426 TEST_P(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { |
| 1429 aura::test::TestWindowDelegate delegate; | 1427 aura::test::TestWindowDelegate delegate; |
| 1430 delegate.set_window_component(HTCAPTION); | 1428 delegate.set_window_component(HTCAPTION); |
| 1431 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( | 1429 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
| 1432 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); | 1430 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
| 1433 ParentWindowInPrimaryRootWindow(w1.get()); | 1431 ParentWindowInPrimaryRootWindow(w1.get()); |
| 1434 | 1432 |
| 1435 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 1433 WmShelf* shelf = GetPrimaryShelf(); |
| 1436 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1434 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1437 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 1435 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 1438 | 1436 |
| 1439 // Drag very little. | 1437 // Drag very little. |
| 1440 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1438 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1441 gfx::Point()); | 1439 gfx::Point()); |
| 1442 generator.MoveMouseTo(10, 10); | 1440 generator.MoveMouseTo(10, 10); |
| 1443 generator.PressLeftButton(); | 1441 generator.PressLeftButton(); |
| 1444 generator.MoveMouseTo(12, 12); | 1442 generator.MoveMouseTo(12, 12); |
| 1445 | 1443 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 ui::EventTimeForNow()); | 1616 ui::EventTimeForNow()); |
| 1619 target = targeter->FindTargetForEvent(root, &touch); | 1617 target = targeter->FindTargetForEvent(root, &touch); |
| 1620 if (points[i].is_target_hit) | 1618 if (points[i].is_target_hit) |
| 1621 EXPECT_EQ(window.get(), target); | 1619 EXPECT_EQ(window.get(), target); |
| 1622 else | 1620 else |
| 1623 EXPECT_NE(window.get(), target); | 1621 EXPECT_NE(window.get(), target); |
| 1624 } | 1622 } |
| 1625 } | 1623 } |
| 1626 | 1624 |
| 1627 } // namespace ash | 1625 } // namespace ash |
| OLD | NEW |