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/common/wm/workspace_controller.h" | 5 #include "ash/common/wm/workspace_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "ash/common/session/session_controller.h" | 9 #include "ash/common/session/session_controller.h" |
10 #include "ash/common/shelf/shelf_layout_manager.h" | 10 #include "ash/common/shelf/shelf_layout_manager.h" |
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate( | 1474 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate( |
1475 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL)); | 1475 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL)); |
1476 ParentWindowInPrimaryRootWindow(first.get()); | 1476 ParentWindowInPrimaryRootWindow(first.get()); |
1477 first->Show(); | 1477 first->Show(); |
1478 | 1478 |
1479 std::unique_ptr<Window> second(aura::test::CreateTestWindowWithDelegate( | 1479 std::unique_ptr<Window> second(aura::test::CreateTestWindowWithDelegate( |
1480 &d_second, 234, gfx::Rect(30, 40, 40, 10), NULL)); | 1480 &d_second, 234, gfx::Rect(30, 40, 40, 10), NULL)); |
1481 ParentWindowInPrimaryRootWindow(second.get()); | 1481 ParentWindowInPrimaryRootWindow(second.get()); |
1482 second->Show(); | 1482 second->Show(); |
1483 | 1483 |
1484 ui::EventTarget* root = first->GetRootWindow(); | 1484 aura::Window* root = first->GetRootWindow(); |
1485 ui::EventTargeter* targeter = root->GetEventTargeter(); | 1485 ui::EventTargeter* targeter = |
| 1486 root->GetHost()->dispatcher()->GetDefaultEventTargeter(); |
1486 | 1487 |
1487 // The windows overlap, and |second| is on top of |first|. Events targeted | 1488 // The windows overlap, and |second| is on top of |first|. Events targeted |
1488 // slightly outside the edges of the |second| window should still be targeted | 1489 // slightly outside the edges of the |second| window should still be targeted |
1489 // to |second| to allow resizing the windows easily. | 1490 // to |second| to allow resizing the windows easily. |
1490 | 1491 |
1491 const int kNumPoints = 4; | 1492 const int kNumPoints = 4; |
1492 struct { | 1493 struct { |
1493 const char* direction; | 1494 const char* direction; |
1494 gfx::Point location; | 1495 gfx::Point location; |
1495 } points[kNumPoints] = { | 1496 } points[kNumPoints] = { |
(...skipping 27 matching lines...) Expand all Loading... |
1523 transform.Translate(70, 40); | 1524 transform.Translate(70, 40); |
1524 second->SetTransform(transform); | 1525 second->SetTransform(transform); |
1525 } | 1526 } |
1526 } | 1527 } |
1527 | 1528 |
1528 // Verifies mouse event targeting just outside the window edges for panels. | 1529 // Verifies mouse event targeting just outside the window edges for panels. |
1529 TEST_F(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) { | 1530 TEST_F(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) { |
1530 aura::test::TestWindowDelegate delegate; | 1531 aura::test::TestWindowDelegate delegate; |
1531 std::unique_ptr<Window> window( | 1532 std::unique_ptr<Window> window( |
1532 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); | 1533 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); |
1533 ui::EventTarget* root = window->GetRootWindow(); | 1534 aura::Window* root = window->GetRootWindow(); |
1534 ui::EventTargeter* targeter = root->GetEventTargeter(); | 1535 ui::EventTargeter* targeter = |
| 1536 root->GetHost()->dispatcher()->GetDefaultEventTargeter(); |
1535 const gfx::Rect bounds = window->bounds(); | 1537 const gfx::Rect bounds = window->bounds(); |
1536 const int kNumPoints = 5; | 1538 const int kNumPoints = 5; |
1537 struct { | 1539 struct { |
1538 const char* direction; | 1540 const char* direction; |
1539 gfx::Point location; | 1541 gfx::Point location; |
1540 bool is_target_hit; | 1542 bool is_target_hit; |
1541 } points[kNumPoints] = { | 1543 } points[kNumPoints] = { |
1542 {"left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true}, | 1544 {"left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true}, |
1543 {"top", gfx::Point(bounds.x() + 10, bounds.y() - 2), true}, | 1545 {"top", gfx::Point(bounds.x() + 10, bounds.y() - 2), true}, |
1544 {"right", gfx::Point(bounds.right() + 2, bounds.y() + 10), true}, | 1546 {"right", gfx::Point(bounds.right() + 2, bounds.y() + 10), true}, |
(...skipping 14 matching lines...) Expand all Loading... |
1559 } | 1561 } |
1560 | 1562 |
1561 // Verifies touch event targeting just outside the window edges for panels. | 1563 // Verifies touch event targeting just outside the window edges for panels. |
1562 // The shelf is aligned to the bottom by default, and so touches just below | 1564 // The shelf is aligned to the bottom by default, and so touches just below |
1563 // the bottom edge of the panel should not target the panel itself because | 1565 // the bottom edge of the panel should not target the panel itself because |
1564 // an AttachedPanelWindowTargeter is installed on the panel container. | 1566 // an AttachedPanelWindowTargeter is installed on the panel container. |
1565 TEST_F(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) { | 1567 TEST_F(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) { |
1566 aura::test::TestWindowDelegate delegate; | 1568 aura::test::TestWindowDelegate delegate; |
1567 std::unique_ptr<Window> window( | 1569 std::unique_ptr<Window> window( |
1568 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); | 1570 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); |
1569 ui::EventTarget* root = window->GetRootWindow(); | 1571 aura::Window* root = window->GetRootWindow(); |
1570 ui::EventTargeter* targeter = root->GetEventTargeter(); | 1572 ui::EventTargeter* targeter = |
| 1573 root->GetHost()->dispatcher()->GetDefaultEventTargeter(); |
1571 const gfx::Rect bounds = window->bounds(); | 1574 const gfx::Rect bounds = window->bounds(); |
1572 const int kNumPoints = 5; | 1575 const int kNumPoints = 5; |
1573 struct { | 1576 struct { |
1574 const char* direction; | 1577 const char* direction; |
1575 gfx::Point location; | 1578 gfx::Point location; |
1576 bool is_target_hit; | 1579 bool is_target_hit; |
1577 } points[kNumPoints] = { | 1580 } points[kNumPoints] = { |
1578 {"left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true}, | 1581 {"left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true}, |
1579 {"top", gfx::Point(bounds.x() + 10, bounds.y() - 2), true}, | 1582 {"top", gfx::Point(bounds.x() + 10, bounds.y() - 2), true}, |
1580 {"right", gfx::Point(bounds.right() + 2, bounds.y() + 10), true}, | 1583 {"right", gfx::Point(bounds.right() + 2, bounds.y() + 10), true}, |
(...skipping 19 matching lines...) Expand all Loading... |
1600 // Make window smaller than the minimum docked area so that the window edges | 1603 // Make window smaller than the minimum docked area so that the window edges |
1601 // are exposed. | 1604 // are exposed. |
1602 delegate.set_maximum_size(gfx::Size(180, 200)); | 1605 delegate.set_maximum_size(gfx::Size(180, 200)); |
1603 std::unique_ptr<Window> window(aura::test::CreateTestWindowWithDelegate( | 1606 std::unique_ptr<Window> window(aura::test::CreateTestWindowWithDelegate( |
1604 &delegate, 123, gfx::Rect(20, 10, 100, 50), NULL)); | 1607 &delegate, 123, gfx::Rect(20, 10, 100, 50), NULL)); |
1605 ParentWindowInPrimaryRootWindow(window.get()); | 1608 ParentWindowInPrimaryRootWindow(window.get()); |
1606 aura::Window* docked_container = Shell::GetContainer( | 1609 aura::Window* docked_container = Shell::GetContainer( |
1607 window->GetRootWindow(), kShellWindowId_DockedContainer); | 1610 window->GetRootWindow(), kShellWindowId_DockedContainer); |
1608 docked_container->AddChild(window.get()); | 1611 docked_container->AddChild(window.get()); |
1609 window->Show(); | 1612 window->Show(); |
1610 ui::EventTarget* root = window->GetRootWindow(); | 1613 aura::Window* root = window->GetRootWindow(); |
1611 ui::EventTargeter* targeter = root->GetEventTargeter(); | 1614 ui::EventTargeter* targeter = |
| 1615 root->GetHost()->dispatcher()->GetDefaultEventTargeter(); |
1612 const gfx::Rect bounds = window->bounds(); | 1616 const gfx::Rect bounds = window->bounds(); |
1613 const int kNumPoints = 5; | 1617 const int kNumPoints = 5; |
1614 struct { | 1618 struct { |
1615 const char* direction; | 1619 const char* direction; |
1616 gfx::Point location; | 1620 gfx::Point location; |
1617 bool is_target_hit; | 1621 bool is_target_hit; |
1618 } points[kNumPoints] = { | 1622 } points[kNumPoints] = { |
1619 {"left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true}, | 1623 {"left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true}, |
1620 {"top", gfx::Point(bounds.x() + 10, bounds.y() - 2), true}, | 1624 {"top", gfx::Point(bounds.x() + 10, bounds.y() - 2), true}, |
1621 {"right", gfx::Point(bounds.right() + 2, bounds.y() + 10), true}, | 1625 {"right", gfx::Point(bounds.right() + 2, bounds.y() + 10), true}, |
(...skipping 15 matching lines...) Expand all Loading... |
1637 ui::EventTimeForNow()); | 1641 ui::EventTimeForNow()); |
1638 target = targeter->FindTargetForEvent(root, &touch); | 1642 target = targeter->FindTargetForEvent(root, &touch); |
1639 if (points[i].is_target_hit) | 1643 if (points[i].is_target_hit) |
1640 EXPECT_EQ(window.get(), target); | 1644 EXPECT_EQ(window.get(), target); |
1641 else | 1645 else |
1642 EXPECT_NE(window.get(), target); | 1646 EXPECT_NE(window.get(), target); |
1643 } | 1647 } |
1644 } | 1648 } |
1645 | 1649 |
1646 } // namespace ash | 1650 } // namespace ash |
OLD | NEW |