Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse event constructor Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 Window child(&window_delegate); 586 Window child(&window_delegate);
587 child.Init(ui::LAYER_NOT_DRAWN); 587 child.Init(ui::LAYER_NOT_DRAWN);
588 top_level->AddChild(&child); 588 top_level->AddChild(&child);
589 child.SetBounds(gfx::Rect(10, 10, 100, 100)); 589 child.SetBounds(gfx::Rect(10, 10, 100, 100));
590 child.Show(); 590 child.Show();
591 EXPECT_FALSE(window_delegate.got_move()); 591 EXPECT_FALSE(window_delegate.got_move());
592 EXPECT_FALSE(window_delegate.was_acked()); 592 EXPECT_FALSE(window_delegate.was_acked());
593 const gfx::Point event_location_in_child(2, 3); 593 const gfx::Point event_location_in_child(2, 3);
594 const uint32_t event_id = 1; 594 const uint32_t event_id = 1;
595 window_delegate.set_event_id(event_id); 595 window_delegate.set_event_id(event_id);
596 std::unique_ptr<ui::Event> ui_event( 596 std::unique_ptr<ui::Event> ui_event(new ui::MouseEvent(
597 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child, 597 ui::ET_MOUSE_MOVED, event_location_in_child, gfx::Point(),
598 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0)); 598 ui::EventTimeForNow(), ui::EF_NONE, 0,
599 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
599 window_tree_client()->OnWindowInputEvent( 600 window_tree_client()->OnWindowInputEvent(
600 event_id, server_id(&child), window_tree_host.display_id(), 601 event_id, server_id(&child), window_tree_host.display_id(),
601 ui::Event::Clone(*ui_event.get()), 0); 602 ui::Event::Clone(*ui_event.get()), 0);
602 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 603 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
603 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 604 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
604 window_tree()->GetEventResult(event_id)); 605 window_tree()->GetEventResult(event_id));
605 EXPECT_TRUE(window_delegate.got_move()); 606 EXPECT_TRUE(window_delegate.got_move());
606 EXPECT_FALSE(window_delegate.was_acked()); 607 EXPECT_FALSE(window_delegate.was_acked());
607 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); 608 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location());
608 } 609 }
(...skipping 24 matching lines...) Expand all
633 634
634 EXPECT_FALSE(window_delegate1.got_move()); 635 EXPECT_FALSE(window_delegate1.got_move());
635 EXPECT_FALSE(window_delegate2.got_move()); 636 EXPECT_FALSE(window_delegate2.got_move());
636 637
637 // child1 has a targeter set and event_location is (50, 60), child2 638 // child1 has a targeter set and event_location is (50, 60), child2
638 // should get the event even though mus-ws wants to send to child1. 639 // should get the event even though mus-ws wants to send to child1.
639 const gfx::Point event_location(50, 60); 640 const gfx::Point event_location(50, 60);
640 uint32_t event_id = 1; 641 uint32_t event_id = 1;
641 window_delegate1.set_event_id(event_id); 642 window_delegate1.set_event_id(event_id);
642 window_delegate2.set_event_id(event_id); 643 window_delegate2.set_event_id(event_id);
643 std::unique_ptr<ui::Event> ui_event( 644 std::unique_ptr<ui::Event> ui_event(new ui::MouseEvent(
644 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(), 645 ui::ET_MOUSE_MOVED, event_location, gfx::Point(), ui::EventTimeForNow(),
645 ui::EventTimeForNow(), ui::EF_NONE, 0)); 646 ui::EF_NONE, 0,
647 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
646 window_tree_client()->OnWindowInputEvent( 648 window_tree_client()->OnWindowInputEvent(
647 event_id, server_id(&child1), window_tree_host.display_id(), 649 event_id, server_id(&child1), window_tree_host.display_id(),
648 ui::Event::Clone(*ui_event.get()), 0); 650 ui::Event::Clone(*ui_event.get()), 0);
649 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 651 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
650 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 652 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
651 window_tree()->GetEventResult(event_id)); 653 window_tree()->GetEventResult(event_id));
652 EXPECT_FALSE(window_delegate1.got_move()); 654 EXPECT_FALSE(window_delegate1.got_move());
653 EXPECT_TRUE(window_delegate2.got_move()); 655 EXPECT_TRUE(window_delegate2.got_move());
654 EXPECT_EQ(gfx::Point(30, 30), window_delegate2.last_event_location()); 656 EXPECT_EQ(gfx::Point(30, 30), window_delegate2.last_event_location());
655 window_delegate1.reset(); 657 window_delegate1.reset();
656 window_delegate2.reset(); 658 window_delegate2.reset();
657 659
658 // Remove the targeter for child1 and specify the event to go to child1. This 660 // Remove the targeter for child1 and specify the event to go to child1. This
659 // time child1 should receive the event not child2. 661 // time child1 should receive the event not child2.
660 child1.SetEventTargeter(nullptr); 662 child1.SetEventTargeter(nullptr);
661 event_id = 2; 663 event_id = 2;
662 window_delegate1.set_event_id(event_id); 664 window_delegate1.set_event_id(event_id);
663 window_delegate2.set_event_id(event_id); 665 window_delegate2.set_event_id(event_id);
664 std::unique_ptr<ui::Event> ui_event1( 666 std::unique_ptr<ui::Event> ui_event1(new ui::MouseEvent(
665 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(), 667 ui::ET_MOUSE_MOVED, event_location, gfx::Point(), ui::EventTimeForNow(),
666 ui::EventTimeForNow(), ui::EF_NONE, 0)); 668 ui::EF_NONE, 0,
669 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
667 window_tree_client()->OnWindowInputEvent( 670 window_tree_client()->OnWindowInputEvent(
668 event_id, server_id(&child1), window_tree_host.display_id(), 671 event_id, server_id(&child1), window_tree_host.display_id(),
669 ui::Event::Clone(*ui_event1.get()), 0); 672 ui::Event::Clone(*ui_event1.get()), 0);
670 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 673 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
671 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 674 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
672 window_tree()->GetEventResult(event_id)); 675 window_tree()->GetEventResult(event_id));
673 EXPECT_TRUE(window_delegate1.got_move()); 676 EXPECT_TRUE(window_delegate1.got_move());
674 EXPECT_FALSE(window_delegate2.got_move()); 677 EXPECT_FALSE(window_delegate2.got_move());
675 EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location()); 678 EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location());
676 } 679 }
(...skipping 24 matching lines...) Expand all
701 EXPECT_FALSE(window_delegate1.got_move()); 704 EXPECT_FALSE(window_delegate1.got_move());
702 EXPECT_FALSE(window_delegate2.got_move()); 705 EXPECT_FALSE(window_delegate2.got_move());
703 706
704 // child1 has a custom targeter set which would always return itself as the 707 // child1 has a custom targeter set which would always return itself as the
705 // target window therefore event should go to child1 unlike 708 // target window therefore event should go to child1 unlike
706 // WindowTreeClientClientTest.InputEventFindTargetAndConversion. 709 // WindowTreeClientClientTest.InputEventFindTargetAndConversion.
707 const gfx::Point event_location(50, 60); 710 const gfx::Point event_location(50, 60);
708 uint32_t event_id = 1; 711 uint32_t event_id = 1;
709 window_delegate1.set_event_id(event_id); 712 window_delegate1.set_event_id(event_id);
710 window_delegate2.set_event_id(event_id); 713 window_delegate2.set_event_id(event_id);
711 std::unique_ptr<ui::Event> ui_event( 714 std::unique_ptr<ui::Event> ui_event(new ui::MouseEvent(
712 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(), 715 ui::ET_MOUSE_MOVED, event_location, gfx::Point(), ui::EventTimeForNow(),
713 ui::EventTimeForNow(), ui::EF_NONE, 0)); 716 ui::EF_NONE, 0,
717 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
714 window_tree_client()->OnWindowInputEvent( 718 window_tree_client()->OnWindowInputEvent(
715 event_id, server_id(&child1), window_tree_host.display_id(), 719 event_id, server_id(&child1), window_tree_host.display_id(),
716 ui::Event::Clone(*ui_event.get()), 0); 720 ui::Event::Clone(*ui_event.get()), 0);
717 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 721 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
718 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 722 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
719 window_tree()->GetEventResult(event_id)); 723 window_tree()->GetEventResult(event_id));
720 EXPECT_TRUE(window_delegate1.got_move()); 724 EXPECT_TRUE(window_delegate1.got_move());
721 EXPECT_FALSE(window_delegate2.got_move()); 725 EXPECT_FALSE(window_delegate2.got_move());
722 EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location()); 726 EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location());
723 window_delegate1.reset(); 727 window_delegate1.reset();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 773
770 EXPECT_FALSE(window_delegate1->got_move()); 774 EXPECT_FALSE(window_delegate1->got_move());
771 EXPECT_FALSE(window_delegate2->got_move()); 775 EXPECT_FALSE(window_delegate2->got_move());
772 776
773 // child1 has a custom targeter set which would always return itself as the 777 // child1 has a custom targeter set which would always return itself as the
774 // target window therefore event should go to child1. 778 // target window therefore event should go to child1.
775 const gfx::Point event_location(50, 60); 779 const gfx::Point event_location(50, 60);
776 uint32_t event_id = 1; 780 uint32_t event_id = 1;
777 window_delegate1->set_event_id(event_id); 781 window_delegate1->set_event_id(event_id);
778 window_delegate2->set_event_id(event_id); 782 window_delegate2->set_event_id(event_id);
779 std::unique_ptr<ui::Event> ui_event( 783 std::unique_ptr<ui::Event> ui_event(new ui::MouseEvent(
780 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(), 784 ui::ET_MOUSE_MOVED, event_location, gfx::Point(), ui::EventTimeForNow(),
781 ui::EventTimeForNow(), ui::EF_NONE, 0)); 785 ui::EF_NONE, 0,
786 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
782 window_tree_client()->OnWindowInputEvent( 787 window_tree_client()->OnWindowInputEvent(
783 event_id, server_id(child1.get()), window_tree_host->display_id(), 788 event_id, server_id(child1.get()), window_tree_host->display_id(),
784 ui::Event::Clone(*ui_event.get()), 0); 789 ui::Event::Clone(*ui_event.get()), 0);
785 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 790 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
786 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 791 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
787 window_tree()->GetEventResult(event_id)); 792 window_tree()->GetEventResult(event_id));
788 EXPECT_TRUE(window_delegate1->got_move()); 793 EXPECT_TRUE(window_delegate1->got_move());
789 EXPECT_FALSE(window_delegate2->got_move()); 794 EXPECT_FALSE(window_delegate2->got_move());
790 EXPECT_EQ(gfx::Point(50, 60), window_delegate1->last_event_location()); 795 EXPECT_EQ(gfx::Point(50, 60), window_delegate1->last_event_location());
791 window_delegate1->reset(); 796 window_delegate1->reset();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 child.SetBounds(gfx::Rect(10, 10, 100, 100)); 838 child.SetBounds(gfx::Rect(10, 10, 100, 100));
834 child.Show(); 839 child.Show();
835 840
836 EXPECT_FALSE(root_handler.got_move()); 841 EXPECT_FALSE(root_handler.got_move());
837 EXPECT_FALSE(child_delegate.got_move()); 842 EXPECT_FALSE(child_delegate.got_move());
838 843
839 const gfx::Point event_location_in_child(20, 30); 844 const gfx::Point event_location_in_child(20, 30);
840 const uint32_t event_id = 1; 845 const uint32_t event_id = 1;
841 root_handler.set_event_id(event_id); 846 root_handler.set_event_id(event_id);
842 child_delegate.set_event_id(event_id); 847 child_delegate.set_event_id(event_id);
843 std::unique_ptr<ui::Event> ui_event( 848 std::unique_ptr<ui::Event> ui_event(new ui::MouseEvent(
844 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child, 849 ui::ET_MOUSE_MOVED, event_location_in_child, gfx::Point(),
845 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0)); 850 ui::EventTimeForNow(), ui::EF_NONE, 0,
851 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
846 window_tree_client()->OnWindowInputEvent( 852 window_tree_client()->OnWindowInputEvent(
847 event_id, server_id(top_level), window_tree_host.display_id(), 853 event_id, server_id(top_level), window_tree_host.display_id(),
848 ui::Event::Clone(*ui_event.get()), 0); 854 ui::Event::Clone(*ui_event.get()), 0);
849 855
850 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 856 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
851 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 857 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
852 window_tree()->GetEventResult(event_id)); 858 window_tree()->GetEventResult(event_id));
853 EXPECT_TRUE(root_handler.got_move()); 859 EXPECT_TRUE(root_handler.got_move());
854 EXPECT_EQ(gfx::Point(20, 30), root_handler.last_event_location()); 860 EXPECT_EQ(gfx::Point(20, 30), root_handler.last_event_location());
855 EXPECT_FALSE(child_delegate.got_move()); 861 EXPECT_FALSE(child_delegate.got_move());
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 1998
1993 EXPECT_FALSE(window_delegate1.got_move()); 1999 EXPECT_FALSE(window_delegate1.got_move());
1994 EXPECT_FALSE(window_delegate2.got_move()); 2000 EXPECT_FALSE(window_delegate2.got_move());
1995 2001
1996 // child1 has a custom targeter set which would always return itself as the 2002 // child1 has a custom targeter set which would always return itself as the
1997 // target window therefore event should go to child1 and should be in dip. 2003 // target window therefore event should go to child1 and should be in dip.
1998 const gfx::Point event_location_in_pixels(50, 60); 2004 const gfx::Point event_location_in_pixels(50, 60);
1999 uint32_t event_id = 1; 2005 uint32_t event_id = 1;
2000 window_delegate1.set_event_id(event_id); 2006 window_delegate1.set_event_id(event_id);
2001 window_delegate2.set_event_id(event_id); 2007 window_delegate2.set_event_id(event_id);
2002 std::unique_ptr<ui::Event> ui_event( 2008 std::unique_ptr<ui::Event> ui_event(new ui::MouseEvent(
2003 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_pixels, 2009 ui::ET_MOUSE_MOVED, event_location_in_pixels, gfx::Point(),
2004 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0)); 2010 ui::EventTimeForNow(), ui::EF_NONE, 0,
2011 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
2005 window_tree_client()->OnWindowInputEvent( 2012 window_tree_client()->OnWindowInputEvent(
2006 event_id, server_id(&child1), window_tree_host.display_id(), 2013 event_id, server_id(&child1), window_tree_host.display_id(),
2007 ui::Event::Clone(*ui_event.get()), 0); 2014 ui::Event::Clone(*ui_event.get()), 0);
2008 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 2015 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
2009 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 2016 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
2010 window_tree()->GetEventResult(event_id)); 2017 window_tree()->GetEventResult(event_id));
2011 EXPECT_TRUE(window_delegate1.got_move()); 2018 EXPECT_TRUE(window_delegate1.got_move());
2012 EXPECT_FALSE(window_delegate2.got_move()); 2019 EXPECT_FALSE(window_delegate2.got_move());
2013 const gfx::Point event_location_in_dip(25, 30); 2020 const gfx::Point event_location_in_dip(25, 30);
2014 EXPECT_EQ(event_location_in_dip, window_delegate1.last_event_location()); 2021 EXPECT_EQ(event_location_in_dip, window_delegate1.last_event_location());
(...skipping 12 matching lines...) Expand all
2027 window_tree()->GetEventResult(event_id)); 2034 window_tree()->GetEventResult(event_id));
2028 EXPECT_TRUE(window_delegate1.got_move()); 2035 EXPECT_TRUE(window_delegate1.got_move());
2029 EXPECT_FALSE(window_delegate2.got_move()); 2036 EXPECT_FALSE(window_delegate2.got_move());
2030 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, 2037 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20,
2031 event_location_in_dip.y() + 30); 2038 event_location_in_dip.y() + 30);
2032 EXPECT_EQ(transformed_event_location_in_dip, 2039 EXPECT_EQ(transformed_event_location_in_dip,
2033 window_delegate1.last_event_location()); 2040 window_delegate1.last_event_location());
2034 } 2041 }
2035 2042
2036 } // namespace aura 2043 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698