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