| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/ws/event_dispatcher.h" | 5 #include "services/ui/ws/event_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 TEST_F(EventDispatcherTest, ProcessEvent) { | 334 TEST_F(EventDispatcherTest, ProcessEvent) { |
| 335 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 335 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 336 | 336 |
| 337 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 337 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 338 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 338 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 339 | 339 |
| 340 // Send event that is over child. | 340 // Send event that is over child. |
| 341 const ui::PointerEvent ui_event(ui::MouseEvent( | 341 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 342 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 342 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 343 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 343 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 344 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 344 event_dispatcher()->ProcessEvent(ui_event, | 345 event_dispatcher()->ProcessEvent(ui_event, |
| 345 EventDispatcher::AcceleratorMatchPhase::ANY); | 346 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 346 | 347 |
| 347 std::unique_ptr<DispatchedEventDetails> details = | 348 std::unique_ptr<DispatchedEventDetails> details = |
| 348 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 349 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 349 ASSERT_TRUE(details); | 350 ASSERT_TRUE(details); |
| 350 ASSERT_EQ(child.get(), details->window); | 351 ASSERT_EQ(child.get(), details->window); |
| 351 | 352 |
| 352 ASSERT_TRUE(details->event); | 353 ASSERT_TRUE(details->event); |
| 353 ASSERT_TRUE(details->event->IsPointerEvent()); | 354 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 546 |
| 546 TEST_F(EventDispatcherTest, Capture) { | 547 TEST_F(EventDispatcherTest, Capture) { |
| 547 ServerWindow* root = root_window(); | 548 ServerWindow* root = root_window(); |
| 548 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 549 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 549 | 550 |
| 550 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 551 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 551 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 552 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 552 | 553 |
| 553 MouseEventTest tests[] = { | 554 MouseEventTest tests[] = { |
| 554 // Send a mouse down event over child. | 555 // Send a mouse down event over child. |
| 555 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 556 {ui::MouseEvent( |
| 556 gfx::Point(20, 25), base::TimeTicks(), | 557 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 557 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 558 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 559 ui::EF_LEFT_MOUSE_BUTTON, |
| 560 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 558 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, | 561 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, |
| 559 gfx::Point(), gfx::Point()}, | 562 gfx::Point(), gfx::Point()}, |
| 560 | 563 |
| 561 // Capture should be activated. Let's send a mouse move outside the bounds | 564 // Capture should be activated. Let's send a mouse move outside the bounds |
| 562 // of the child. | 565 // of the child. |
| 563 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 566 {ui::MouseEvent( |
| 564 gfx::Point(50, 50), base::TimeTicks(), | 567 ui::ET_MOUSE_MOVED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 565 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 568 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 569 ui::EF_LEFT_MOUSE_BUTTON, |
| 570 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 566 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 571 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 567 gfx::Point(), gfx::Point()}, | 572 gfx::Point(), gfx::Point()}, |
| 568 // Release the mouse and verify that the mouse up event goes to the child. | 573 // Release the mouse and verify that the mouse up event goes to the child. |
| 569 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), | 574 {ui::MouseEvent( |
| 570 gfx::Point(50, 50), base::TimeTicks(), | 575 ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 571 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 576 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 577 ui::EF_LEFT_MOUSE_BUTTON, |
| 578 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 572 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 579 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 573 gfx::Point(), gfx::Point()}, | 580 gfx::Point(), gfx::Point()}, |
| 574 | 581 |
| 575 // A mouse move at (50, 50) should now go to the root window. As the | 582 // A mouse move at (50, 50) should now go to the root window. As the |
| 576 // move crosses between |child| and |root| |child| gets an exit, and | 583 // move crosses between |child| and |root| |child| gets an exit, and |
| 577 // |root| the move. | 584 // |root| the move. |
| 578 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 585 {ui::MouseEvent( |
| 579 gfx::Point(50, 50), base::TimeTicks(), | 586 ui::ET_MOUSE_MOVED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 580 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 587 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 588 ui::EF_LEFT_MOUSE_BUTTON, |
| 589 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 581 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), root, | 590 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), root, |
| 582 gfx::Point(50, 50), gfx::Point(50, 50)}, | 591 gfx::Point(50, 50), gfx::Point(50, 50)}, |
| 583 | 592 |
| 584 }; | 593 }; |
| 585 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 594 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 586 tests, arraysize(tests)); | 595 tests, arraysize(tests)); |
| 587 } | 596 } |
| 588 | 597 |
| 589 TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { | 598 TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { |
| 590 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 599 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 591 | 600 |
| 592 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 601 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 593 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 602 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 594 | 603 |
| 595 MouseEventTest tests[] = { | 604 MouseEventTest tests[] = { |
| 596 // Send a mouse down event over child with a left mouse button | 605 // Send a mouse down event over child with a left mouse button |
| 597 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 606 {ui::MouseEvent( |
| 598 gfx::Point(20, 25), base::TimeTicks(), | 607 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 599 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 608 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 609 ui::EF_LEFT_MOUSE_BUTTON, |
| 610 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 600 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, | 611 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, |
| 601 gfx::Point(), gfx::Point()}, | 612 gfx::Point(), gfx::Point()}, |
| 602 | 613 |
| 603 // Capture should be activated. Let's send a mouse move outside the bounds | 614 // Capture should be activated. Let's send a mouse move outside the bounds |
| 604 // of the child and press the right mouse button too. | 615 // of the child and press the right mouse button too. |
| 605 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 616 {ui::MouseEvent( |
| 606 gfx::Point(50, 50), base::TimeTicks(), | 617 ui::ET_MOUSE_MOVED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 607 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0), | 618 base::TimeTicks(), |
| 619 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0, |
| 620 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 608 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 621 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 609 gfx::Point(), gfx::Point()}, | 622 gfx::Point(), gfx::Point()}, |
| 610 | 623 |
| 611 // Release the left mouse button and verify that the mouse up event goes | 624 // Release the left mouse button and verify that the mouse up event goes |
| 612 // to the child. | 625 // to the child. |
| 613 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), | 626 {ui::MouseEvent( |
| 614 gfx::Point(50, 50), base::TimeTicks(), | 627 ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 615 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 628 base::TimeTicks(), |
| 616 ui::EF_RIGHT_MOUSE_BUTTON), | 629 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 630 ui::EF_RIGHT_MOUSE_BUTTON, |
| 631 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 617 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 632 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 618 gfx::Point(), gfx::Point()}, | 633 gfx::Point(), gfx::Point()}, |
| 619 | 634 |
| 620 // A mouse move at (50, 50) should still go to the child. | 635 // A mouse move at (50, 50) should still go to the child. |
| 621 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 636 {ui::MouseEvent( |
| 622 gfx::Point(50, 50), base::TimeTicks(), | 637 ui::ET_MOUSE_MOVED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 623 ui::EF_LEFT_MOUSE_BUTTON, 0), | 638 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 639 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 624 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 640 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 625 gfx::Point(), gfx::Point()}, | 641 gfx::Point(), gfx::Point()}, |
| 626 | 642 |
| 627 }; | 643 }; |
| 628 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 644 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 629 tests, arraysize(tests)); | 645 tests, arraysize(tests)); |
| 630 } | 646 } |
| 631 | 647 |
| 632 TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { | 648 TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| 633 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 649 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 634 | 650 |
| 635 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 651 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 636 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 652 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 637 | 653 |
| 638 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 654 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 639 | 655 |
| 640 TestEventDispatcherDelegate* event_dispatcher_delegate = | 656 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 641 test_event_dispatcher_delegate(); | 657 test_event_dispatcher_delegate(); |
| 642 EventDispatcher* dispatcher = event_dispatcher(); | 658 EventDispatcher* dispatcher = event_dispatcher(); |
| 643 | 659 |
| 644 // Start move loop by sending mouse event over non-client area. | 660 // Start move loop by sending mouse event over non-client area. |
| 645 const ui::PointerEvent press_event(ui::MouseEvent( | 661 const ui::PointerEvent press_event(ui::MouseEvent( |
| 646 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), | 662 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 647 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 663 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 664 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 648 dispatcher->ProcessEvent(press_event, | 665 dispatcher->ProcessEvent(press_event, |
| 649 EventDispatcher::AcceleratorMatchPhase::ANY); | 666 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 650 | 667 |
| 651 // Events should target child and be in the non-client area. | 668 // Events should target child and be in the non-client area. |
| 652 std::unique_ptr<DispatchedEventDetails> details = | 669 std::unique_ptr<DispatchedEventDetails> details = |
| 653 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 670 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 654 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 671 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 655 ASSERT_TRUE(details); | 672 ASSERT_TRUE(details); |
| 656 ASSERT_EQ(child.get(), details->window); | 673 ASSERT_EQ(child.get(), details->window); |
| 657 EXPECT_TRUE(details->IsNonclientArea()); | 674 EXPECT_TRUE(details->IsNonclientArea()); |
| 658 | 675 |
| 659 // Move the mouse 5,6 pixels and target is the same. | 676 // Move the mouse 5,6 pixels and target is the same. |
| 660 const ui::PointerEvent move_event( | 677 const ui::PointerEvent move_event(ui::MouseEvent( |
| 661 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(17, 18), gfx::Point(17, 18), | 678 ui::ET_MOUSE_MOVED, gfx::Point(17, 18), gfx::Point(17, 18), |
| 662 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); | 679 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 680 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 663 dispatcher->ProcessEvent(move_event, | 681 dispatcher->ProcessEvent(move_event, |
| 664 EventDispatcher::AcceleratorMatchPhase::ANY); | 682 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 665 | 683 |
| 666 // Still same target. | 684 // Still same target. |
| 667 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 685 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 668 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 686 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 669 ASSERT_EQ(child.get(), details->window); | 687 ASSERT_EQ(child.get(), details->window); |
| 670 EXPECT_TRUE(details->IsNonclientArea()); | 688 EXPECT_TRUE(details->IsNonclientArea()); |
| 671 | 689 |
| 672 // Release the mouse. | 690 // Release the mouse. |
| 673 const ui::PointerEvent release_event(ui::MouseEvent( | 691 const ui::PointerEvent release_event(ui::MouseEvent( |
| 674 ui::ET_MOUSE_RELEASED, gfx::Point(17, 18), gfx::Point(17, 18), | 692 ui::ET_MOUSE_RELEASED, gfx::Point(17, 18), gfx::Point(17, 18), |
| 675 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 693 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 694 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 676 dispatcher->ProcessEvent(release_event, | 695 dispatcher->ProcessEvent(release_event, |
| 677 EventDispatcher::AcceleratorMatchPhase::ANY); | 696 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 678 | 697 |
| 679 // The event should not have been dispatched to the delegate. | 698 // The event should not have been dispatched to the delegate. |
| 680 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 699 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 681 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 700 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 682 ASSERT_EQ(child.get(), details->window); | 701 ASSERT_EQ(child.get(), details->window); |
| 683 EXPECT_TRUE(details->IsNonclientArea()); | 702 EXPECT_TRUE(details->IsNonclientArea()); |
| 684 | 703 |
| 685 // Press in the client area and verify target/client area. The non-client area | 704 // Press in the client area and verify target/client area. The non-client area |
| 686 // should get an exit first. | 705 // should get an exit first. |
| 687 const ui::PointerEvent press_event2(ui::MouseEvent( | 706 const ui::PointerEvent press_event2(ui::MouseEvent( |
| 688 ui::ET_MOUSE_PRESSED, gfx::Point(21, 22), gfx::Point(21, 22), | 707 ui::ET_MOUSE_PRESSED, gfx::Point(21, 22), gfx::Point(21, 22), |
| 689 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 708 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 709 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 690 dispatcher->ProcessEvent(press_event2, | 710 dispatcher->ProcessEvent(press_event2, |
| 691 EventDispatcher::AcceleratorMatchPhase::ANY); | 711 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 692 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 712 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 693 EXPECT_TRUE(event_dispatcher_delegate->has_queued_events()); | 713 EXPECT_TRUE(event_dispatcher_delegate->has_queued_events()); |
| 694 ASSERT_EQ(child.get(), details->window); | 714 ASSERT_EQ(child.get(), details->window); |
| 695 EXPECT_TRUE(details->IsNonclientArea()); | 715 EXPECT_TRUE(details->IsNonclientArea()); |
| 696 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); | 716 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); |
| 697 | 717 |
| 698 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 718 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 699 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 719 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 710 | 730 |
| 711 std::vector<gfx::Rect> additional_client_areas; | 731 std::vector<gfx::Rect> additional_client_areas; |
| 712 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); | 732 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); |
| 713 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); | 733 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); |
| 714 | 734 |
| 715 TestEventDispatcherDelegate* event_dispatcher_delegate = | 735 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 716 test_event_dispatcher_delegate(); | 736 test_event_dispatcher_delegate(); |
| 717 // Press in the additional client area, it should go to the child. | 737 // Press in the additional client area, it should go to the child. |
| 718 const ui::PointerEvent press_event(ui::MouseEvent( | 738 const ui::PointerEvent press_event(ui::MouseEvent( |
| 719 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), | 739 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), |
| 720 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 740 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 741 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 721 event_dispatcher()->ProcessEvent(press_event, | 742 event_dispatcher()->ProcessEvent(press_event, |
| 722 EventDispatcher::AcceleratorMatchPhase::ANY); | 743 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 723 | 744 |
| 724 // Events should target child and be in the client area. | 745 // Events should target child and be in the client area. |
| 725 std::unique_ptr<DispatchedEventDetails> details = | 746 std::unique_ptr<DispatchedEventDetails> details = |
| 726 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 747 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 727 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 748 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 728 ASSERT_EQ(child.get(), details->window); | 749 ASSERT_EQ(child.get(), details->window); |
| 729 EXPECT_TRUE(details->IsClientArea()); | 750 EXPECT_TRUE(details->IsClientArea()); |
| 730 } | 751 } |
| 731 | 752 |
| 732 TEST_F(EventDispatcherTest, HitTestMask) { | 753 TEST_F(EventDispatcherTest, HitTestMask) { |
| 733 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 754 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 734 | 755 |
| 735 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 756 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 736 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 757 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 737 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16)); | 758 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16)); |
| 738 | 759 |
| 739 // Move in the masked area. | 760 // Move in the masked area. |
| 740 const ui::PointerEvent move1(ui::MouseEvent( | 761 const ui::PointerEvent move1(ui::MouseEvent( |
| 741 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11), | 762 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11), |
| 742 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); | 763 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 764 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 743 event_dispatcher()->ProcessEvent(move1, | 765 event_dispatcher()->ProcessEvent(move1, |
| 744 EventDispatcher::AcceleratorMatchPhase::ANY); | 766 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 745 | 767 |
| 746 // Event went through the child window and hit the root. | 768 // Event went through the child window and hit the root. |
| 747 std::unique_ptr<DispatchedEventDetails> details1 = | 769 std::unique_ptr<DispatchedEventDetails> details1 = |
| 748 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 770 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 749 EXPECT_EQ(root_window(), details1->window); | 771 EXPECT_EQ(root_window(), details1->window); |
| 750 EXPECT_TRUE(details1->IsClientArea()); | 772 EXPECT_TRUE(details1->IsClientArea()); |
| 751 | 773 |
| 752 child->ClearHitTestMask(); | 774 child->ClearHitTestMask(); |
| 753 | 775 |
| 754 // Move right in the same part of the window. | 776 // Move right in the same part of the window. |
| 755 const ui::PointerEvent move2(ui::MouseEvent( | 777 const ui::PointerEvent move2(ui::MouseEvent( |
| 756 ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12), | 778 ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12), |
| 757 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); | 779 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 780 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 758 event_dispatcher()->ProcessEvent(move2, | 781 event_dispatcher()->ProcessEvent(move2, |
| 759 EventDispatcher::AcceleratorMatchPhase::ANY); | 782 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 760 | 783 |
| 761 // Mouse exits the root. | 784 // Mouse exits the root. |
| 762 std::unique_ptr<DispatchedEventDetails> details2 = | 785 std::unique_ptr<DispatchedEventDetails> details2 = |
| 763 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 786 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 764 EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type()); | 787 EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type()); |
| 765 | 788 |
| 766 // Mouse hits the child. | 789 // Mouse hits the child. |
| 767 std::unique_ptr<DispatchedEventDetails> details3 = | 790 std::unique_ptr<DispatchedEventDetails> details3 = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 778 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 801 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 779 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 802 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); |
| 780 | 803 |
| 781 TestEventDispatcherDelegate* event_dispatcher_delegate = | 804 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 782 test_event_dispatcher_delegate(); | 805 test_event_dispatcher_delegate(); |
| 783 EventDispatcher* dispatcher = event_dispatcher(); | 806 EventDispatcher* dispatcher = event_dispatcher(); |
| 784 | 807 |
| 785 // Press on child1. First press event should change focus. | 808 // Press on child1. First press event should change focus. |
| 786 const ui::PointerEvent press_event(ui::MouseEvent( | 809 const ui::PointerEvent press_event(ui::MouseEvent( |
| 787 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), | 810 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 788 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 811 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 812 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 789 dispatcher->ProcessEvent(press_event, | 813 dispatcher->ProcessEvent(press_event, |
| 790 EventDispatcher::AcceleratorMatchPhase::ANY); | 814 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 791 std::unique_ptr<DispatchedEventDetails> details = | 815 std::unique_ptr<DispatchedEventDetails> details = |
| 792 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 816 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 793 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 817 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 794 EXPECT_EQ(child1.get(), details->window); | 818 EXPECT_EQ(child1.get(), details->window); |
| 795 EXPECT_EQ(child1.get(), | 819 EXPECT_EQ(child1.get(), |
| 796 event_dispatcher_delegate->GetAndClearLastFocusedWindow()); | 820 event_dispatcher_delegate->GetAndClearLastFocusedWindow()); |
| 797 | 821 |
| 798 // Press (with a different pointer id) on child2. Event should go to child2, | 822 // Press (with a different pointer id) on child2. Event should go to child2, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 944 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 921 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 945 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 922 | 946 |
| 923 TestEventDispatcherDelegate* event_dispatcher_delegate = | 947 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 924 test_event_dispatcher_delegate(); | 948 test_event_dispatcher_delegate(); |
| 925 EventDispatcher* dispatcher = event_dispatcher(); | 949 EventDispatcher* dispatcher = event_dispatcher(); |
| 926 | 950 |
| 927 // Send event that is not over child. | 951 // Send event that is not over child. |
| 928 const ui::PointerEvent ui_event(ui::MouseEvent( | 952 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 929 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), | 953 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), |
| 930 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 954 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 955 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 931 dispatcher->ProcessEvent(ui_event, | 956 dispatcher->ProcessEvent(ui_event, |
| 932 EventDispatcher::AcceleratorMatchPhase::ANY); | 957 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 933 std::unique_ptr<DispatchedEventDetails> details = | 958 std::unique_ptr<DispatchedEventDetails> details = |
| 934 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 959 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 935 ASSERT_EQ(root, details->window); | 960 ASSERT_EQ(root, details->window); |
| 936 | 961 |
| 937 // Release the mouse. | 962 // Release the mouse. |
| 938 const ui::PointerEvent release_event(ui::MouseEvent( | 963 const ui::PointerEvent release_event(ui::MouseEvent( |
| 939 ui::ET_MOUSE_RELEASED, gfx::Point(8, 9), gfx::Point(8, 9), | 964 ui::ET_MOUSE_RELEASED, gfx::Point(8, 9), gfx::Point(8, 9), |
| 940 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 965 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 966 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 941 dispatcher->ProcessEvent(release_event, | 967 dispatcher->ProcessEvent(release_event, |
| 942 EventDispatcher::AcceleratorMatchPhase::ANY); | 968 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 943 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 969 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 944 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 970 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 945 ASSERT_EQ(root, details->window); | 971 ASSERT_EQ(root, details->window); |
| 946 EXPECT_TRUE(details->IsClientArea()); | 972 EXPECT_TRUE(details->IsClientArea()); |
| 947 | 973 |
| 948 // Change the extended hit test region and send event in extended hit test | 974 // Change the extended hit test region and send event in extended hit test |
| 949 // region. Should result in exit for root, followed by press for child. | 975 // region. Should result in exit for root, followed by press for child. |
| 950 child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5)); | 976 child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 968 TEST_F(EventDispatcherTest, WheelWhileDown) { | 994 TEST_F(EventDispatcherTest, WheelWhileDown) { |
| 969 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 995 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 970 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 996 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 971 | 997 |
| 972 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 998 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 973 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 999 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 974 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 1000 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); |
| 975 | 1001 |
| 976 MouseEventTest tests[] = { | 1002 MouseEventTest tests[] = { |
| 977 // Send a mouse down event over child1. | 1003 // Send a mouse down event over child1. |
| 978 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), | 1004 {ui::MouseEvent( |
| 979 gfx::Point(15, 15), base::TimeTicks(), | 1005 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 980 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 1006 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 1007 ui::EF_LEFT_MOUSE_BUTTON, |
| 1008 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 981 child1.get(), gfx::Point(15, 15), gfx::Point(5, 5), nullptr, | 1009 child1.get(), gfx::Point(15, 15), gfx::Point(5, 5), nullptr, |
| 982 gfx::Point(), gfx::Point()}, | 1010 gfx::Point(), gfx::Point()}, |
| 983 // Send mouse wheel over child2, should go to child1 as it has capture. | 1011 // Send mouse wheel over child2, should go to child1 as it has capture. |
| 984 {ui::MouseWheelEvent(gfx::Vector2d(1, 0), gfx::Point(53, 54), | 1012 {ui::MouseWheelEvent(gfx::Vector2d(1, 0), gfx::Point(53, 54), |
| 985 gfx::Point(53, 54), base::TimeTicks(), ui::EF_NONE, | 1013 gfx::Point(53, 54), base::TimeTicks(), ui::EF_NONE, |
| 986 ui::EF_NONE), | 1014 ui::EF_NONE), |
| 987 child1.get(), gfx::Point(53, 54), gfx::Point(43, 44), nullptr, | 1015 child1.get(), gfx::Point(53, 54), gfx::Point(43, 44), nullptr, |
| 988 gfx::Point(), gfx::Point()}, | 1016 gfx::Point(), gfx::Point()}, |
| 989 }; | 1017 }; |
| 990 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 1018 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1006 EventDispatcher* dispatcher = event_dispatcher(); | 1034 EventDispatcher* dispatcher = event_dispatcher(); |
| 1007 | 1035 |
| 1008 { | 1036 { |
| 1009 // Send all pointer events to the child. | 1037 // Send all pointer events to the child. |
| 1010 dispatcher->SetCaptureWindow(child.get(), kClientAreaId); | 1038 dispatcher->SetCaptureWindow(child.get(), kClientAreaId); |
| 1011 | 1039 |
| 1012 // The mouse press should go to the child even though its outside its | 1040 // The mouse press should go to the child even though its outside its |
| 1013 // bounds. | 1041 // bounds. |
| 1014 const ui::PointerEvent left_press_event(ui::MouseEvent( | 1042 const ui::PointerEvent left_press_event(ui::MouseEvent( |
| 1015 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1043 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1016 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1044 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1045 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1017 dispatcher->ProcessEvent(left_press_event, | 1046 dispatcher->ProcessEvent(left_press_event, |
| 1018 EventDispatcher::AcceleratorMatchPhase::ANY); | 1047 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1019 | 1048 |
| 1020 // Events should target child. | 1049 // Events should target child. |
| 1021 std::unique_ptr<DispatchedEventDetails> details = | 1050 std::unique_ptr<DispatchedEventDetails> details = |
| 1022 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1051 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1023 | 1052 |
| 1024 ASSERT_TRUE(details); | 1053 ASSERT_TRUE(details); |
| 1025 ASSERT_EQ(child.get(), details->window); | 1054 ASSERT_EQ(child.get(), details->window); |
| 1026 EXPECT_TRUE(details->IsClientArea()); | 1055 EXPECT_TRUE(details->IsClientArea()); |
| 1027 EXPECT_TRUE(IsMouseButtonDown()); | 1056 EXPECT_TRUE(IsMouseButtonDown()); |
| 1028 | 1057 |
| 1029 // The mouse down state should update while capture is set. | 1058 // The mouse down state should update while capture is set. |
| 1030 const ui::PointerEvent right_press_event(ui::MouseEvent( | 1059 const ui::PointerEvent right_press_event(ui::MouseEvent( |
| 1031 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1060 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1032 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 1061 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 1033 ui::EF_RIGHT_MOUSE_BUTTON)); | 1062 ui::EF_RIGHT_MOUSE_BUTTON, |
| 1063 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1034 dispatcher->ProcessEvent(right_press_event, | 1064 dispatcher->ProcessEvent(right_press_event, |
| 1035 EventDispatcher::AcceleratorMatchPhase::ANY); | 1065 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1036 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1066 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1037 EXPECT_TRUE(IsMouseButtonDown()); | 1067 EXPECT_TRUE(IsMouseButtonDown()); |
| 1038 | 1068 |
| 1039 // One button released should not clear mouse down | 1069 // One button released should not clear mouse down |
| 1040 const ui::PointerEvent left_release_event(ui::MouseEvent( | 1070 const ui::PointerEvent left_release_event(ui::MouseEvent( |
| 1041 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5), | 1071 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1042 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 1072 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 1043 ui::EF_LEFT_MOUSE_BUTTON)); | 1073 ui::EF_LEFT_MOUSE_BUTTON, |
| 1074 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1044 dispatcher->ProcessEvent(left_release_event, | 1075 dispatcher->ProcessEvent(left_release_event, |
| 1045 EventDispatcher::AcceleratorMatchPhase::ANY); | 1076 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1046 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1077 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1047 EXPECT_TRUE(IsMouseButtonDown()); | 1078 EXPECT_TRUE(IsMouseButtonDown()); |
| 1048 | 1079 |
| 1049 // Touch Event while mouse is down should not affect state. | 1080 // Touch Event while mouse is down should not affect state. |
| 1050 const ui::PointerEvent touch_event(ui::TouchEvent( | 1081 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 1051 ui::ET_TOUCH_PRESSED, gfx::Point(15, 15), base::TimeTicks(), | 1082 ui::ET_TOUCH_PRESSED, gfx::Point(15, 15), base::TimeTicks(), |
| 1052 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); | 1083 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2))); |
| 1053 dispatcher->ProcessEvent(touch_event, | 1084 dispatcher->ProcessEvent(touch_event, |
| 1054 EventDispatcher::AcceleratorMatchPhase::ANY); | 1085 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1055 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1086 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1056 EXPECT_TRUE(IsMouseButtonDown()); | 1087 EXPECT_TRUE(IsMouseButtonDown()); |
| 1057 | 1088 |
| 1058 // Move event should not affect down | 1089 // Move event should not affect down |
| 1059 const ui::PointerEvent move_event( | 1090 const ui::PointerEvent move_event(ui::MouseEvent( |
| 1060 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(15, 5), gfx::Point(15, 5), | 1091 ui::ET_MOUSE_MOVED, gfx::Point(15, 5), gfx::Point(15, 5), |
| 1061 base::TimeTicks(), ui::EF_RIGHT_MOUSE_BUTTON, | 1092 base::TimeTicks(), ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON, |
| 1062 ui::EF_RIGHT_MOUSE_BUTTON)); | 1093 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1063 dispatcher->ProcessEvent(move_event, | 1094 dispatcher->ProcessEvent(move_event, |
| 1064 EventDispatcher::AcceleratorMatchPhase::ANY); | 1095 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1065 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1096 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1066 EXPECT_TRUE(IsMouseButtonDown()); | 1097 EXPECT_TRUE(IsMouseButtonDown()); |
| 1067 | 1098 |
| 1068 // All mouse buttons up should clear mouse down. | 1099 // All mouse buttons up should clear mouse down. |
| 1069 const ui::PointerEvent right_release_event( | 1100 const ui::PointerEvent right_release_event(ui::MouseEvent( |
| 1070 ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), | 1101 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1071 gfx::Point(5, 5), base::TimeTicks(), | 1102 base::TimeTicks(), ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON, |
| 1072 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); | 1103 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1073 dispatcher->ProcessEvent(right_release_event, | 1104 dispatcher->ProcessEvent(right_release_event, |
| 1074 EventDispatcher::AcceleratorMatchPhase::ANY); | 1105 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1075 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1106 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1076 EXPECT_FALSE(IsMouseButtonDown()); | 1107 EXPECT_FALSE(IsMouseButtonDown()); |
| 1077 } | 1108 } |
| 1078 | 1109 |
| 1079 { | 1110 { |
| 1080 // Releasing capture and sending the same event will go to the root. | 1111 // Releasing capture and sending the same event will go to the root. |
| 1081 dispatcher->SetCaptureWindow(nullptr, kClientAreaId); | 1112 dispatcher->SetCaptureWindow(nullptr, kClientAreaId); |
| 1082 const ui::PointerEvent press_event(ui::MouseEvent( | 1113 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1083 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1114 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1084 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1115 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1116 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1085 dispatcher->ProcessEvent(press_event, | 1117 dispatcher->ProcessEvent(press_event, |
| 1086 EventDispatcher::AcceleratorMatchPhase::ANY); | 1118 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1087 | 1119 |
| 1088 // Events should target the root. | 1120 // Events should target the root. |
| 1089 std::unique_ptr<DispatchedEventDetails> details = | 1121 std::unique_ptr<DispatchedEventDetails> details = |
| 1090 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1122 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1091 | 1123 |
| 1092 ASSERT_TRUE(details); | 1124 ASSERT_TRUE(details); |
| 1093 ASSERT_EQ(root, details->window); | 1125 ASSERT_EQ(root, details->window); |
| 1094 } | 1126 } |
| 1095 } | 1127 } |
| 1096 | 1128 |
| 1097 // This test verifies that explicit capture overrides and resets implicit | 1129 // This test verifies that explicit capture overrides and resets implicit |
| 1098 // capture. | 1130 // capture. |
| 1099 TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { | 1131 TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { |
| 1100 ServerWindow* root = root_window(); | 1132 ServerWindow* root = root_window(); |
| 1101 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1133 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1102 | 1134 |
| 1103 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1135 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1104 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1136 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1105 | 1137 |
| 1106 TestEventDispatcherDelegate* event_dispatcher_delegate = | 1138 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 1107 test_event_dispatcher_delegate(); | 1139 test_event_dispatcher_delegate(); |
| 1108 EventDispatcher* dispatcher = event_dispatcher(); | 1140 EventDispatcher* dispatcher = event_dispatcher(); |
| 1109 | 1141 |
| 1110 // Run some implicit capture tests. | 1142 // Run some implicit capture tests. |
| 1111 MouseEventTest tests[] = { | 1143 MouseEventTest tests[] = { |
| 1112 // Send a mouse down event over child with a left mouse button | 1144 // Send a mouse down event over child with a left mouse button |
| 1113 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 1145 {ui::MouseEvent( |
| 1114 gfx::Point(20, 25), base::TimeTicks(), | 1146 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1115 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 1147 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 1148 ui::EF_LEFT_MOUSE_BUTTON, |
| 1149 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1116 child.get(), gfx::Point(20, 25), gfx::Point(10, 15)}, | 1150 child.get(), gfx::Point(20, 25), gfx::Point(10, 15)}, |
| 1117 // Capture should be activated. Let's send a mouse move outside the bounds | 1151 // Capture should be activated. Let's send a mouse move outside the bounds |
| 1118 // of the child and press the right mouse button too. | 1152 // of the child and press the right mouse button too. |
| 1119 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 1153 {ui::MouseEvent( |
| 1120 gfx::Point(50, 50), base::TimeTicks(), | 1154 ui::ET_MOUSE_MOVED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 1121 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0), | 1155 base::TimeTicks(), |
| 1156 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0, |
| 1157 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1122 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, | 1158 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, |
| 1123 // Release the left mouse button and verify that the mouse up event goes | 1159 // Release the left mouse button and verify that the mouse up event goes |
| 1124 // to the child. | 1160 // to the child. |
| 1125 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), | 1161 {ui::MouseEvent( |
| 1126 gfx::Point(50, 50), base::TimeTicks(), | 1162 ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 1127 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 1163 base::TimeTicks(), |
| 1128 ui::EF_RIGHT_MOUSE_BUTTON), | 1164 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 1165 ui::EF_RIGHT_MOUSE_BUTTON, |
| 1166 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1129 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, | 1167 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, |
| 1130 // A mouse move at (50, 50) should still go to the child. | 1168 // A mouse move at (50, 50) should still go to the child. |
| 1131 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 1169 {ui::MouseEvent( |
| 1132 gfx::Point(50, 50), base::TimeTicks(), | 1170 ui::ET_MOUSE_MOVED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 1133 ui::EF_LEFT_MOUSE_BUTTON, 0), | 1171 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 1172 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1134 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, | 1173 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, |
| 1135 | 1174 |
| 1136 }; | 1175 }; |
| 1137 RunMouseEventTests(dispatcher, event_dispatcher_delegate, tests, | 1176 RunMouseEventTests(dispatcher, event_dispatcher_delegate, tests, |
| 1138 arraysize(tests)); | 1177 arraysize(tests)); |
| 1139 | 1178 |
| 1140 // Add a second pointer target to the child. | 1179 // Add a second pointer target to the child. |
| 1141 { | 1180 { |
| 1142 const ui::PointerEvent touch_event(ui::TouchEvent( | 1181 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 1143 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), | 1182 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), base::TimeTicks(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1167 EXPECT_EQ(ui::ET_POINTER_CANCELLED, details->event->type()); | 1206 EXPECT_EQ(ui::ET_POINTER_CANCELLED, details->event->type()); |
| 1168 | 1207 |
| 1169 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1208 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1170 ASSERT_TRUE(details); | 1209 ASSERT_TRUE(details); |
| 1171 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1210 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1172 EXPECT_EQ(child.get(), details->window); | 1211 EXPECT_EQ(child.get(), details->window); |
| 1173 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); | 1212 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); |
| 1174 | 1213 |
| 1175 const ui::PointerEvent press_event(ui::MouseEvent( | 1214 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1176 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1215 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1177 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1216 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1217 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1178 dispatcher->ProcessEvent(press_event, | 1218 dispatcher->ProcessEvent(press_event, |
| 1179 EventDispatcher::AcceleratorMatchPhase::ANY); | 1219 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1180 | 1220 |
| 1181 // Events should target the root. | 1221 // Events should target the root. |
| 1182 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1222 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1183 ASSERT_TRUE(details); | 1223 ASSERT_TRUE(details); |
| 1184 ASSERT_EQ(root, details->window); | 1224 ASSERT_EQ(root, details->window); |
| 1185 ASSERT_TRUE(details->IsNonclientArea()); | 1225 ASSERT_TRUE(details->IsNonclientArea()); |
| 1186 } | 1226 } |
| 1187 | 1227 |
| 1188 // Tests that setting capture does delete active pointer targets for the capture | 1228 // Tests that setting capture does delete active pointer targets for the capture |
| 1189 // window. | 1229 // window. |
| 1190 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { | 1230 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| 1191 ServerWindow* root = root_window(); | 1231 ServerWindow* root = root_window(); |
| 1192 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1232 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1193 | 1233 |
| 1194 EventDispatcher* dispatcher = event_dispatcher(); | 1234 EventDispatcher* dispatcher = event_dispatcher(); |
| 1195 { | 1235 { |
| 1196 const ui::PointerEvent press_event(ui::MouseEvent( | 1236 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1197 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1237 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1198 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1238 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1239 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1199 dispatcher->ProcessEvent(press_event, | 1240 dispatcher->ProcessEvent(press_event, |
| 1200 EventDispatcher::AcceleratorMatchPhase::ANY); | 1241 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1201 | 1242 |
| 1202 std::unique_ptr<DispatchedEventDetails> details = | 1243 std::unique_ptr<DispatchedEventDetails> details = |
| 1203 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1244 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1204 ASSERT_TRUE(details); | 1245 ASSERT_TRUE(details); |
| 1205 ASSERT_EQ(root, details->window); | 1246 ASSERT_EQ(root, details->window); |
| 1206 } | 1247 } |
| 1207 { | 1248 { |
| 1208 const ui::PointerEvent touch_event(ui::TouchEvent( | 1249 const ui::PointerEvent touch_event(ui::TouchEvent( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 | 1312 |
| 1272 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 1313 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 1273 EventDispatcher* dispatcher = event_dispatcher(); | 1314 EventDispatcher* dispatcher = event_dispatcher(); |
| 1274 dispatcher->SetCaptureWindow(root, kNonclientAreaId); | 1315 dispatcher->SetCaptureWindow(root, kNonclientAreaId); |
| 1275 | 1316 |
| 1276 TestEventDispatcherDelegate* event_dispatcher_delegate = | 1317 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 1277 test_event_dispatcher_delegate(); | 1318 test_event_dispatcher_delegate(); |
| 1278 // Press in the client area, it should be marked as non client. | 1319 // Press in the client area, it should be marked as non client. |
| 1279 const ui::PointerEvent press_event(ui::MouseEvent( | 1320 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1280 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), | 1321 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), |
| 1281 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1322 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1323 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1282 event_dispatcher()->ProcessEvent(press_event, | 1324 event_dispatcher()->ProcessEvent(press_event, |
| 1283 EventDispatcher::AcceleratorMatchPhase::ANY); | 1325 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1284 | 1326 |
| 1285 // Events should target child and be in the client area. | 1327 // Events should target child and be in the client area. |
| 1286 std::unique_ptr<DispatchedEventDetails> details = | 1328 std::unique_ptr<DispatchedEventDetails> details = |
| 1287 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1329 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1288 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1330 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1289 ASSERT_EQ(root, details->window); | 1331 ASSERT_EQ(root, details->window); |
| 1290 EXPECT_TRUE(details->IsNonclientArea()); | 1332 EXPECT_TRUE(details->IsNonclientArea()); |
| 1291 } | 1333 } |
| 1292 | 1334 |
| 1293 TEST_F(EventDispatcherTest, ProcessPointerEvents) { | 1335 TEST_F(EventDispatcherTest, ProcessPointerEvents) { |
| 1294 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1336 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1295 | 1337 |
| 1296 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1338 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1297 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1339 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1298 | 1340 |
| 1299 { | 1341 { |
| 1300 const ui::PointerEvent pointer_event(ui::MouseEvent( | 1342 const ui::PointerEvent pointer_event(ui::MouseEvent( |
| 1301 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 1343 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1302 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1344 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1345 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1303 event_dispatcher()->ProcessEvent( | 1346 event_dispatcher()->ProcessEvent( |
| 1304 pointer_event, EventDispatcher::AcceleratorMatchPhase::ANY); | 1347 pointer_event, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1305 | 1348 |
| 1306 std::unique_ptr<DispatchedEventDetails> details = | 1349 std::unique_ptr<DispatchedEventDetails> details = |
| 1307 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1350 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1308 ASSERT_TRUE(details); | 1351 ASSERT_TRUE(details); |
| 1309 ASSERT_EQ(child.get(), details->window); | 1352 ASSERT_EQ(child.get(), details->window); |
| 1310 | 1353 |
| 1311 ASSERT_TRUE(details->event); | 1354 ASSERT_TRUE(details->event); |
| 1312 ASSERT_TRUE(details->event->IsPointerEvent()); | 1355 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1342 | 1385 |
| 1343 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { | 1386 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { |
| 1344 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1387 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1345 | 1388 |
| 1346 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1389 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1347 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1390 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1348 | 1391 |
| 1349 // Send event that is over child. | 1392 // Send event that is over child. |
| 1350 const ui::PointerEvent ui_event(ui::MouseEvent( | 1393 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 1351 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 1394 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1352 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1395 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1396 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1353 event_dispatcher()->ProcessEvent(ui_event, | 1397 event_dispatcher()->ProcessEvent(ui_event, |
| 1354 EventDispatcher::AcceleratorMatchPhase::ANY); | 1398 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1355 | 1399 |
| 1356 std::unique_ptr<DispatchedEventDetails> details = | 1400 std::unique_ptr<DispatchedEventDetails> details = |
| 1357 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1401 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1358 ASSERT_TRUE(details); | 1402 ASSERT_TRUE(details); |
| 1359 ASSERT_EQ(child.get(), details->window); | 1403 ASSERT_EQ(child.get(), details->window); |
| 1360 | 1404 |
| 1361 EXPECT_TRUE(AreAnyPointersDown()); | 1405 EXPECT_TRUE(AreAnyPointersDown()); |
| 1362 | 1406 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1386 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1430 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1387 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1431 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1388 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1432 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1389 | 1433 |
| 1390 w1->AddTransientWindow(w2.get()); | 1434 w1->AddTransientWindow(w2.get()); |
| 1391 w2->SetModalType(MODAL_TYPE_WINDOW); | 1435 w2->SetModalType(MODAL_TYPE_WINDOW); |
| 1392 | 1436 |
| 1393 // Send event that is over |w1|. | 1437 // Send event that is over |w1|. |
| 1394 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1438 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1395 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1439 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1396 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1440 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1441 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1397 event_dispatcher()->ProcessEvent(mouse_pressed, | 1442 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1398 EventDispatcher::AcceleratorMatchPhase::ANY); | 1443 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1399 | 1444 |
| 1400 std::unique_ptr<DispatchedEventDetails> details = | 1445 std::unique_ptr<DispatchedEventDetails> details = |
| 1401 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1446 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1402 ASSERT_TRUE(details); | 1447 ASSERT_TRUE(details); |
| 1403 EXPECT_EQ(w2.get(), details->window); | 1448 EXPECT_EQ(w2.get(), details->window); |
| 1404 EXPECT_TRUE(details->IsNonclientArea()); | 1449 EXPECT_TRUE(details->IsNonclientArea()); |
| 1405 | 1450 |
| 1406 ASSERT_TRUE(details->event); | 1451 ASSERT_TRUE(details->event); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1419 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1464 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1420 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1465 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1421 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1466 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1422 | 1467 |
| 1423 w1->AddTransientWindow(w2.get()); | 1468 w1->AddTransientWindow(w2.get()); |
| 1424 w2->SetModalType(MODAL_TYPE_WINDOW); | 1469 w2->SetModalType(MODAL_TYPE_WINDOW); |
| 1425 | 1470 |
| 1426 // Send event that is over |w2|. | 1471 // Send event that is over |w2|. |
| 1427 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1472 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1428 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), | 1473 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), |
| 1429 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1474 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1475 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1430 event_dispatcher()->ProcessEvent(mouse_pressed, | 1476 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1431 EventDispatcher::AcceleratorMatchPhase::ANY); | 1477 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1432 | 1478 |
| 1433 std::unique_ptr<DispatchedEventDetails> details = | 1479 std::unique_ptr<DispatchedEventDetails> details = |
| 1434 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1480 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1435 ASSERT_TRUE(details); | 1481 ASSERT_TRUE(details); |
| 1436 EXPECT_EQ(w2.get(), details->window); | 1482 EXPECT_EQ(w2.get(), details->window); |
| 1437 EXPECT_TRUE(details->IsClientArea()); | 1483 EXPECT_TRUE(details->IsClientArea()); |
| 1438 | 1484 |
| 1439 ASSERT_TRUE(details->event); | 1485 ASSERT_TRUE(details->event); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1455 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1501 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1456 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1502 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1457 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); | 1503 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); |
| 1458 | 1504 |
| 1459 w1->AddTransientWindow(w2.get()); | 1505 w1->AddTransientWindow(w2.get()); |
| 1460 w2->SetModalType(MODAL_TYPE_WINDOW); | 1506 w2->SetModalType(MODAL_TYPE_WINDOW); |
| 1461 | 1507 |
| 1462 // Send event that is over |w3|. | 1508 // Send event that is over |w3|. |
| 1463 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1509 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1464 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), | 1510 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), |
| 1465 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1511 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1512 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1466 event_dispatcher()->ProcessEvent(mouse_pressed, | 1513 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1467 EventDispatcher::AcceleratorMatchPhase::ANY); | 1514 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1468 | 1515 |
| 1469 std::unique_ptr<DispatchedEventDetails> details = | 1516 std::unique_ptr<DispatchedEventDetails> details = |
| 1470 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1517 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1471 ASSERT_TRUE(details); | 1518 ASSERT_TRUE(details); |
| 1472 EXPECT_EQ(w3.get(), details->window); | 1519 EXPECT_EQ(w3.get(), details->window); |
| 1473 EXPECT_TRUE(details->IsClientArea()); | 1520 EXPECT_TRUE(details->IsClientArea()); |
| 1474 | 1521 |
| 1475 ASSERT_TRUE(details->event); | 1522 ASSERT_TRUE(details->event); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1492 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1539 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1493 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1540 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); |
| 1494 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1541 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1495 | 1542 |
| 1496 w1->AddTransientWindow(w2.get()); | 1543 w1->AddTransientWindow(w2.get()); |
| 1497 w2->SetModalType(MODAL_TYPE_WINDOW); | 1544 w2->SetModalType(MODAL_TYPE_WINDOW); |
| 1498 | 1545 |
| 1499 // Send event that is over |w11|. | 1546 // Send event that is over |w11|. |
| 1500 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1547 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1501 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), | 1548 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), |
| 1502 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1549 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1550 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1503 event_dispatcher()->ProcessEvent(mouse_pressed, | 1551 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1504 EventDispatcher::AcceleratorMatchPhase::ANY); | 1552 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1505 | 1553 |
| 1506 std::unique_ptr<DispatchedEventDetails> details = | 1554 std::unique_ptr<DispatchedEventDetails> details = |
| 1507 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1555 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1508 ASSERT_TRUE(details); | 1556 ASSERT_TRUE(details); |
| 1509 EXPECT_EQ(w2.get(), details->window); | 1557 EXPECT_EQ(w2.get(), details->window); |
| 1510 EXPECT_TRUE(details->IsNonclientArea()); | 1558 EXPECT_TRUE(details->IsNonclientArea()); |
| 1511 | 1559 |
| 1512 ASSERT_TRUE(details->event); | 1560 ASSERT_TRUE(details->event); |
| 1513 ASSERT_TRUE(details->event->IsPointerEvent()); | 1561 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1514 | 1562 |
| 1515 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1563 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1516 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); | 1564 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); |
| 1517 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); | 1565 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); |
| 1518 } | 1566 } |
| 1519 | 1567 |
| 1520 // Tests that events on a system modal window target the modal window itself. | 1568 // Tests that events on a system modal window target the modal window itself. |
| 1521 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { | 1569 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { |
| 1522 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1570 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1523 | 1571 |
| 1524 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1572 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1525 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1573 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1526 w1->SetModalType(MODAL_TYPE_SYSTEM); | 1574 w1->SetModalType(MODAL_TYPE_SYSTEM); |
| 1527 | 1575 |
| 1528 // Send event that is over |w1|. | 1576 // Send event that is over |w1|. |
| 1529 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1577 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1530 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1578 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1531 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1579 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1580 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1532 event_dispatcher()->ProcessEvent(mouse_pressed, | 1581 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1533 EventDispatcher::AcceleratorMatchPhase::ANY); | 1582 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1534 | 1583 |
| 1535 std::unique_ptr<DispatchedEventDetails> details = | 1584 std::unique_ptr<DispatchedEventDetails> details = |
| 1536 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1585 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1537 ASSERT_TRUE(details); | 1586 ASSERT_TRUE(details); |
| 1538 EXPECT_EQ(w1.get(), details->window); | 1587 EXPECT_EQ(w1.get(), details->window); |
| 1539 EXPECT_TRUE(details->IsClientArea()); | 1588 EXPECT_TRUE(details->IsClientArea()); |
| 1540 | 1589 |
| 1541 ASSERT_TRUE(details->event); | 1590 ASSERT_TRUE(details->event); |
| 1542 ASSERT_TRUE(details->event->IsPointerEvent()); | 1591 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1543 | 1592 |
| 1544 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1593 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1545 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); | 1594 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); |
| 1546 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); | 1595 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); |
| 1547 } | 1596 } |
| 1548 | 1597 |
| 1549 // Tests that events outside of system modal window target the modal window. | 1598 // Tests that events outside of system modal window target the modal window. |
| 1550 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { | 1599 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| 1551 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1600 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1552 | 1601 |
| 1553 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1602 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1554 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1603 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1555 w1->SetModalType(MODAL_TYPE_SYSTEM); | 1604 w1->SetModalType(MODAL_TYPE_SYSTEM); |
| 1556 event_dispatcher()->AddSystemModalWindow(w1.get()); | 1605 event_dispatcher()->AddSystemModalWindow(w1.get()); |
| 1557 | 1606 |
| 1558 // Send event that is over |w1|. | 1607 // Send event that is over |w1|. |
| 1559 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1608 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1560 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), | 1609 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), |
| 1561 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1610 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1611 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1562 event_dispatcher()->ProcessEvent(mouse_pressed, | 1612 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1563 EventDispatcher::AcceleratorMatchPhase::ANY); | 1613 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1564 | 1614 |
| 1565 std::unique_ptr<DispatchedEventDetails> details = | 1615 std::unique_ptr<DispatchedEventDetails> details = |
| 1566 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1616 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1567 ASSERT_TRUE(details); | 1617 ASSERT_TRUE(details); |
| 1568 EXPECT_EQ(w1.get(), details->window); | 1618 EXPECT_EQ(w1.get(), details->window); |
| 1569 EXPECT_TRUE(details->IsNonclientArea()); | 1619 EXPECT_TRUE(details->IsNonclientArea()); |
| 1570 | 1620 |
| 1571 ASSERT_TRUE(details->event); | 1621 ASSERT_TRUE(details->event); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 w2->set_event_targeting_policy(mojom::EventTargetingPolicy::DESCENDANTS_ONLY); | 1779 w2->set_event_targeting_policy(mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| 1730 | 1780 |
| 1731 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1781 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1732 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1782 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1733 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1783 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); |
| 1734 w2->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1784 w2->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1735 | 1785 |
| 1736 // Send event that is over |w11|. | 1786 // Send event that is over |w11|. |
| 1737 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1787 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1738 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1788 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1739 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1789 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 1790 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE))); |
| 1740 event_dispatcher()->ProcessEvent(mouse_pressed, | 1791 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1741 EventDispatcher::AcceleratorMatchPhase::ANY); | 1792 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1742 event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId); | 1793 event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId); |
| 1743 | 1794 |
| 1744 std::unique_ptr<DispatchedEventDetails> details = | 1795 std::unique_ptr<DispatchedEventDetails> details = |
| 1745 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1796 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1746 ASSERT_TRUE(details); | 1797 ASSERT_TRUE(details); |
| 1747 EXPECT_EQ(w11.get(), details->window); | 1798 EXPECT_EQ(w11.get(), details->window); |
| 1748 EXPECT_TRUE(details->IsClientArea()); | 1799 EXPECT_TRUE(details->IsClientArea()); |
| 1749 | 1800 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1775 root->set_event_targeting_policy( | 1826 root->set_event_targeting_policy( |
| 1776 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); | 1827 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| 1777 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1828 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1778 | 1829 |
| 1779 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1830 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1780 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1831 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1781 | 1832 |
| 1782 MouseEventTest tests[] = { | 1833 MouseEventTest tests[] = { |
| 1783 // Send a mouse down over the root, but not the child. No event should | 1834 // Send a mouse down over the root, but not the child. No event should |
| 1784 // be generated. | 1835 // be generated. |
| 1785 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(5, 5), gfx::Point(5, 5), | 1836 {ui::MouseEvent( |
| 1786 base::TimeTicks(), 0, 0), | 1837 ui::ET_MOUSE_MOVED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1838 base::TimeTicks(), 0, 0, |
| 1839 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1787 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), | 1840 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), |
| 1788 gfx::Point()}, | 1841 gfx::Point()}, |
| 1789 | 1842 |
| 1790 // Move into child. | 1843 // Move into child. |
| 1791 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(12, 12), | 1844 {ui::MouseEvent( |
| 1792 gfx::Point(12, 12), base::TimeTicks(), 0, 0), | 1845 ui::ET_MOUSE_MOVED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 1846 base::TimeTicks(), 0, 0, |
| 1847 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1793 child.get(), gfx::Point(12, 12), gfx::Point(2, 2), nullptr, gfx::Point(), | 1848 child.get(), gfx::Point(12, 12), gfx::Point(2, 2), nullptr, gfx::Point(), |
| 1794 gfx::Point()}}; | 1849 gfx::Point()}}; |
| 1795 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 1850 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 1796 tests, arraysize(tests)); | 1851 tests, arraysize(tests)); |
| 1797 } | 1852 } |
| 1798 | 1853 |
| 1799 TEST_F(EventDispatcherTest, NoTargetToTargetWithMouseDown) { | 1854 TEST_F(EventDispatcherTest, NoTargetToTargetWithMouseDown) { |
| 1800 ServerWindow* root = root_window(); | 1855 ServerWindow* root = root_window(); |
| 1801 root->set_event_targeting_policy( | 1856 root->set_event_targeting_policy( |
| 1802 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); | 1857 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| 1803 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1858 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1804 | 1859 |
| 1805 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1860 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1806 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1861 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1807 | 1862 |
| 1808 MouseEventTest tests[] = { | 1863 MouseEventTest tests[] = { |
| 1809 // Mouse over the root, but not the child. No event should be generated. | 1864 // Mouse over the root, but not the child. No event should be generated. |
| 1810 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(5, 5), gfx::Point(5, 5), | 1865 {ui::MouseEvent( |
| 1811 base::TimeTicks(), 0, 0), | 1866 ui::ET_MOUSE_MOVED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1867 base::TimeTicks(), 0, 0, |
| 1868 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1812 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), | 1869 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), |
| 1813 gfx::Point()}, | 1870 gfx::Point()}, |
| 1814 | 1871 |
| 1815 // Press in same location, still no target. | 1872 // Press in same location, still no target. |
| 1816 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1873 {ui::MouseEvent( |
| 1817 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, | 1874 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1818 ui::EF_LEFT_MOUSE_BUTTON), | 1875 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 1876 ui::EF_LEFT_MOUSE_BUTTON, |
| 1877 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1819 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), | 1878 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), |
| 1820 gfx::Point()}, | 1879 gfx::Point()}, |
| 1821 | 1880 |
| 1822 // Move into child, still no target. | 1881 // Move into child, still no target. |
| 1823 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(12, 12), | 1882 {ui::MouseEvent( |
| 1824 gfx::Point(12, 12), base::TimeTicks(), | 1883 ui::ET_MOUSE_MOVED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 1825 ui::EF_LEFT_MOUSE_BUTTON, 0), | 1884 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 1885 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1826 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), | 1886 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), |
| 1827 gfx::Point()}}; | 1887 gfx::Point()}}; |
| 1828 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 1888 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 1829 tests, arraysize(tests)); | 1889 tests, arraysize(tests)); |
| 1830 } | 1890 } |
| 1831 | 1891 |
| 1832 TEST_F(EventDispatcherTest, DontSendExitToSameClientWhenCaptureChanges) { | 1892 TEST_F(EventDispatcherTest, DontSendExitToSameClientWhenCaptureChanges) { |
| 1833 ServerWindow* root = root_window(); | 1893 ServerWindow* root = root_window(); |
| 1834 root->set_event_targeting_policy( | 1894 root->set_event_targeting_policy( |
| 1835 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); | 1895 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| 1836 std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); | 1896 std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); |
| 1837 std::unique_ptr<ServerWindow> c2 = CreateChildWindow(WindowId(1, 4)); | 1897 std::unique_ptr<ServerWindow> c2 = CreateChildWindow(WindowId(1, 4)); |
| 1838 | 1898 |
| 1839 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1899 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1840 c1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1900 c1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1841 c2->SetBounds(gfx::Rect(15, 15, 20, 20)); | 1901 c2->SetBounds(gfx::Rect(15, 15, 20, 20)); |
| 1842 | 1902 |
| 1843 MouseEventTest tests[] = { | 1903 MouseEventTest tests[] = { |
| 1844 // Mouse over |c2|. | 1904 // Mouse over |c2|. |
| 1845 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(16, 16), | 1905 {ui::MouseEvent( |
| 1846 gfx::Point(16, 16), base::TimeTicks(), 0, 0), | 1906 ui::ET_MOUSE_MOVED, gfx::Point(16, 16), gfx::Point(16, 16), |
| 1907 base::TimeTicks(), 0, 0, |
| 1908 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1847 c2.get(), gfx::Point(16, 16), gfx::Point(1, 1), nullptr, gfx::Point(), | 1909 c2.get(), gfx::Point(16, 16), gfx::Point(1, 1), nullptr, gfx::Point(), |
| 1848 gfx::Point()}, | 1910 gfx::Point()}, |
| 1849 | 1911 |
| 1850 // Press in same location. | 1912 // Press in same location. |
| 1851 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(16, 16), | 1913 {ui::MouseEvent( |
| 1852 gfx::Point(16, 16), base::TimeTicks(), | 1914 ui::ET_MOUSE_PRESSED, gfx::Point(16, 16), gfx::Point(16, 16), |
| 1853 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 1915 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, |
| 1916 ui::EF_LEFT_MOUSE_BUTTON, |
| 1917 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)), |
| 1854 c2.get(), gfx::Point(16, 16), gfx::Point(1, 1), nullptr, gfx::Point(), | 1918 c2.get(), gfx::Point(16, 16), gfx::Point(1, 1), nullptr, gfx::Point(), |
| 1855 gfx::Point()}}; | 1919 gfx::Point()}}; |
| 1856 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 1920 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 1857 tests, arraysize(tests)); | 1921 tests, arraysize(tests)); |
| 1858 | 1922 |
| 1859 // Set capture on |c1|. No events should be sent as |c1| is in the same | 1923 // Set capture on |c1|. No events should be sent as |c1| is in the same |
| 1860 // client. | 1924 // client. |
| 1861 event_dispatcher()->SetCaptureWindow(c1.get(), kClientAreaId); | 1925 event_dispatcher()->SetCaptureWindow(c1.get(), kClientAreaId); |
| 1862 EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); | 1926 EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); |
| 1863 } | 1927 } |
| 1864 | 1928 |
| 1865 TEST_F(EventDispatcherTest, MousePointerClearedOnDestroy) { | 1929 TEST_F(EventDispatcherTest, MousePointerClearedOnDestroy) { |
| 1866 root_window()->set_event_targeting_policy( | 1930 root_window()->set_event_targeting_policy( |
| 1867 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); | 1931 mojom::EventTargetingPolicy::DESCENDANTS_ONLY); |
| 1868 std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); | 1932 std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); |
| 1869 | 1933 |
| 1870 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1934 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1871 c1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1935 c1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1872 | 1936 |
| 1873 event_dispatcher()->SetMousePointerScreenLocation(gfx::Point(15, 15)); | 1937 event_dispatcher()->SetMousePointerScreenLocation(gfx::Point(15, 15)); |
| 1874 EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window()); | 1938 EXPECT_EQ(c1.get(), event_dispatcher()->mouse_cursor_source_window()); |
| 1875 c1.reset(); | 1939 c1.reset(); |
| 1876 EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window()); | 1940 EXPECT_EQ(nullptr, event_dispatcher()->mouse_cursor_source_window()); |
| 1877 } | 1941 } |
| 1878 | 1942 |
| 1879 } // namespace test | 1943 } // namespace test |
| 1880 } // namespace ws | 1944 } // namespace ws |
| 1881 } // namespace ui | 1945 } // namespace ui |
| OLD | NEW |