OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/window_event_dispatcher.h" | 5 #include "ui/aura/window_event_dispatcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 2724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2735 ui::EF_LEFT_MOUSE_BUTTON); | 2735 ui::EF_LEFT_MOUSE_BUTTON); |
2736 DispatchEventUsingWindowDispatcher(&mouse); | 2736 DispatchEventUsingWindowDispatcher(&mouse); |
2737 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); | 2737 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); |
2738 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); | 2738 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); |
2739 | 2739 |
2740 // After dispatch the location should fallback to that of the | 2740 // After dispatch the location should fallback to that of the |
2741 // WindowTreeClient, which defaults to 0,0. | 2741 // WindowTreeClient, which defaults to 0,0. |
2742 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); | 2742 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); |
2743 } | 2743 } |
2744 | 2744 |
2745 TEST_F(WindowEventDispatcherMusTest, UseDefaultTargeterToFindTarget) { | |
2746 LastEventLocationDelegate last_event_location_delegate1; | |
2747 std::unique_ptr<Window> child1( | |
2748 CreateTestWindowWithDelegate(&last_event_location_delegate1, 123, | |
2749 gfx::Rect(10, 10, 100, 100), root_window())); | |
2750 LastEventLocationDelegate last_event_location_delegate2; | |
2751 std::unique_ptr<Window> child2( | |
2752 CreateTestWindowWithDelegate(&last_event_location_delegate2, 124, | |
2753 gfx::Rect(20, 30, 100, 100), child1.get())); | |
2754 | |
2755 const gfx::Point mouse_location(30, 40); | |
2756 ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location, | |
2757 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | |
2758 ui::EF_LEFT_MOUSE_BUTTON); | |
2759 DispatchEventUsingWindowDispatcher(&mouse); | |
2760 EXPECT_EQ(0, last_event_location_delegate1.mouse_event_count()); | |
2761 EXPECT_EQ(1, last_event_location_delegate2.mouse_event_count()); | |
2762 EXPECT_EQ(gfx::Point(), last_event_location_delegate1.last_mouse_location()); | |
2763 EXPECT_EQ(mouse_location, | |
2764 last_event_location_delegate2.last_mouse_location()); | |
2765 } | |
2766 | |
2767 TEST_F(WindowEventDispatcherMusTest, UseDefaultTargeterToFindTarget2) { | |
2768 LastEventLocationDelegate last_event_location_delegate1; | |
2769 std::unique_ptr<Window> child1( | |
2770 CreateTestWindowWithDelegate(&last_event_location_delegate1, 123, | |
2771 gfx::Rect(10, 10, 100, 100), root_window())); | |
2772 LastEventLocationDelegate last_event_location_delegate2; | |
2773 std::unique_ptr<Window> child2( | |
2774 CreateTestWindowWithDelegate(&last_event_location_delegate2, 124, | |
2775 gfx::Rect(20, 30, 100, 100), child1.get())); | |
2776 | |
2777 const gfx::Point mouse_location(15, 25); | |
2778 ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location, | |
2779 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | |
2780 ui::EF_LEFT_MOUSE_BUTTON); | |
2781 DispatchEventUsingWindowDispatcher(&mouse); | |
2782 EXPECT_EQ(1, last_event_location_delegate1.mouse_event_count()); | |
2783 EXPECT_EQ(0, last_event_location_delegate2.mouse_event_count()); | |
2784 EXPECT_EQ(mouse_location, | |
2785 last_event_location_delegate1.last_mouse_location()); | |
2786 EXPECT_EQ(gfx::Point(), last_event_location_delegate2.last_mouse_location()); | |
2787 } | |
2788 | |
2789 class NestedLocationDelegate : public test::TestWindowDelegate { | 2745 class NestedLocationDelegate : public test::TestWindowDelegate { |
2790 public: | 2746 public: |
2791 NestedLocationDelegate() {} | 2747 NestedLocationDelegate() {} |
2792 ~NestedLocationDelegate() override {} | 2748 ~NestedLocationDelegate() override {} |
2793 | 2749 |
2794 int mouse_event_count() const { return mouse_event_count_; } | 2750 int mouse_event_count() const { return mouse_event_count_; } |
2795 int nested_message_loop_count() const { return nested_message_loop_count_; } | 2751 int nested_message_loop_count() const { return nested_message_loop_count_; } |
2796 const gfx::Point& last_mouse_location() const { return last_mouse_location_; } | 2752 const gfx::Point& last_mouse_location() const { return last_mouse_location_; } |
2797 | 2753 |
2798 // TestWindowDelegate: | 2754 // TestWindowDelegate: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2864 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); | 2820 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); |
2865 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); | 2821 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); |
2866 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); | 2822 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); |
2867 | 2823 |
2868 // After dispatch the location should fallback to that of the | 2824 // After dispatch the location should fallback to that of the |
2869 // WindowTreeClient, which defaults to 0,0. | 2825 // WindowTreeClient, which defaults to 0,0. |
2870 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); | 2826 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); |
2871 } | 2827 } |
2872 | 2828 |
2873 } // namespace aura | 2829 } // namespace aura |
OLD | NEW |