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/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
11 #include "ash/session/session_controller.h" | 11 #include "ash/session/session_controller.h" |
| 12 #include "ash/shelf/shelf.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | 13 #include "ash/shelf/shelf_layout_manager.h" |
13 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
14 #include "ash/shelf/wm_shelf.h" | |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
16 #include "ash/system/status_area_widget.h" | 16 #include "ash/system/status_area_widget.h" |
17 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
18 #include "ash/test/shell_test_api.h" | 18 #include "ash/test/shell_test_api.h" |
19 #include "ash/wm/panels/panel_layout_manager.h" | 19 #include "ash/wm/panels/panel_layout_manager.h" |
20 #include "ash/wm/window_state.h" | 20 #include "ash/wm/window_state.h" |
21 #include "ash/wm/window_util.h" | 21 #include "ash/wm/window_util.h" |
22 #include "ash/wm/wm_event.h" | 22 #include "ash/wm/wm_event.h" |
23 #include "ash/wm/workspace/workspace_window_resizer.h" | 23 #include "ash/wm/workspace/workspace_window_resizer.h" |
24 #include "ash/wm_window.h" | 24 #include "ash/wm_window.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 // updated. | 354 // updated. |
355 TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { | 355 TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { |
356 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 356 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
357 // it isn't over the shelf. | 357 // it isn't over the shelf. |
358 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 358 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
359 gfx::Point()); | 359 gfx::Point()); |
360 generator.MoveMouseTo(0, 0); | 360 generator.MoveMouseTo(0, 0); |
361 | 361 |
362 std::unique_ptr<Window> w1(CreateTestWindow()); | 362 std::unique_ptr<Window> w1(CreateTestWindow()); |
363 const gfx::Rect w1_bounds(0, 1, 101, 102); | 363 const gfx::Rect w1_bounds(0, 1, 101, 102); |
364 WmShelf* shelf = GetPrimaryShelf(); | 364 Shelf* shelf = GetPrimaryShelf(); |
365 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 365 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
366 const gfx::Rect touches_shelf_bounds( | 366 const gfx::Rect touches_shelf_bounds( |
367 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102); | 367 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102); |
368 // Move |w1| to overlap the shelf. | 368 // Move |w1| to overlap the shelf. |
369 w1->SetBounds(touches_shelf_bounds); | 369 w1->SetBounds(touches_shelf_bounds); |
370 EXPECT_FALSE(GetWindowOverlapsShelf()); | 370 EXPECT_FALSE(GetWindowOverlapsShelf()); |
371 | 371 |
372 // A visible ignored window should not trigger the overlap. | 372 // A visible ignored window should not trigger the overlap. |
373 std::unique_ptr<Window> w_ignored(CreateTestWindow()); | 373 std::unique_ptr<Window> w_ignored(CreateTestWindow()); |
374 w_ignored->SetBounds(touches_shelf_bounds); | 374 w_ignored->SetBounds(touches_shelf_bounds); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 | 654 |
655 } // namespace | 655 } // namespace |
656 | 656 |
657 // Exercises possible crash in W2. Here's the sequence: | 657 // Exercises possible crash in W2. Here's the sequence: |
658 // . minimize a maximized window. | 658 // . minimize a maximized window. |
659 // . remove the window (which happens when switching displays). | 659 // . remove the window (which happens when switching displays). |
660 // . add the window back. | 660 // . add the window back. |
661 // . show the window and during the bounds change activate it. | 661 // . show the window and during the bounds change activate it. |
662 TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { | 662 TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { |
663 // Force the shelf | 663 // Force the shelf |
664 WmShelf* shelf = GetPrimaryShelf(); | 664 Shelf* shelf = GetPrimaryShelf(); |
665 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 665 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
666 | 666 |
667 DontCrashOnChangeAndActivateDelegate delegate; | 667 DontCrashOnChangeAndActivateDelegate delegate; |
668 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( | 668 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( |
669 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); | 669 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); |
670 | 670 |
671 w1->Show(); | 671 w1->Show(); |
672 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); | 672 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); |
673 w1_state->Activate(); | 673 w1_state->Activate(); |
674 w1_state->Maximize(); | 674 w1_state->Maximize(); |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 | 1384 |
1385 // Verifies that when dragging a window autohidden shelf stays hidden during | 1385 // Verifies that when dragging a window autohidden shelf stays hidden during |
1386 // and after the drag. | 1386 // and after the drag. |
1387 TEST_F(WorkspaceControllerTest, DragWindowKeepsShelfAutohidden) { | 1387 TEST_F(WorkspaceControllerTest, DragWindowKeepsShelfAutohidden) { |
1388 aura::test::TestWindowDelegate delegate; | 1388 aura::test::TestWindowDelegate delegate; |
1389 delegate.set_window_component(HTCAPTION); | 1389 delegate.set_window_component(HTCAPTION); |
1390 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( | 1390 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
1391 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); | 1391 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
1392 ParentWindowInPrimaryRootWindow(w1.get()); | 1392 ParentWindowInPrimaryRootWindow(w1.get()); |
1393 | 1393 |
1394 WmShelf* shelf = GetPrimaryShelf(); | 1394 Shelf* shelf = GetPrimaryShelf(); |
1395 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1395 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1396 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 1396 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
1397 | 1397 |
1398 // Drag very little. | 1398 // Drag very little. |
1399 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1399 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1400 gfx::Point()); | 1400 gfx::Point()); |
1401 generator.MoveMouseTo(10, 10); | 1401 generator.MoveMouseTo(10, 10); |
1402 generator.PressLeftButton(); | 1402 generator.PressLeftButton(); |
1403 generator.MoveMouseTo(12, 12); | 1403 generator.MoveMouseTo(12, 12); |
1404 | 1404 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0)); | 1533 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0)); |
1534 ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch); | 1534 ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch); |
1535 if (points[i].is_target_hit) | 1535 if (points[i].is_target_hit) |
1536 EXPECT_EQ(window.get(), target); | 1536 EXPECT_EQ(window.get(), target); |
1537 else | 1537 else |
1538 EXPECT_NE(window.get(), target); | 1538 EXPECT_NE(window.get(), target); |
1539 } | 1539 } |
1540 } | 1540 } |
1541 | 1541 |
1542 } // namespace ash | 1542 } // namespace ash |
OLD | NEW |