| 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 // Enable fetching mouse location from mouse. |
| 2756 test::EnvTestHelper().SetAlwaysUseLastMouseLocation(false); |
| 2757 EXPECT_EQ(gfx::Point(0, 0), |
| 2758 window_tree_client_impl()->GetCursorScreenPoint()); |
| 2759 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); |
| 2760 |
| 2761 const gfx::Point mouse_location(30, 40); |
| 2762 ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location, |
| 2763 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 2764 ui::EF_LEFT_MOUSE_BUTTON); |
| 2765 DispatchEventUsingWindowDispatcher(&mouse); |
| 2766 EXPECT_EQ(0, last_event_location_delegate1.mouse_event_count()); |
| 2767 EXPECT_EQ(1, last_event_location_delegate2.mouse_event_count()); |
| 2768 EXPECT_EQ(gfx::Point(), last_event_location_delegate1.last_mouse_location()); |
| 2769 EXPECT_EQ(mouse_location, |
| 2770 last_event_location_delegate2.last_mouse_location()); |
| 2771 } |
| 2772 |
| 2773 TEST_F(WindowEventDispatcherMusTest, UseDefaultTargeterToFindTarget2) { |
| 2774 LastEventLocationDelegate last_event_location_delegate1; |
| 2775 std::unique_ptr<Window> child1( |
| 2776 CreateTestWindowWithDelegate(&last_event_location_delegate1, 123, |
| 2777 gfx::Rect(10, 10, 100, 100), root_window())); |
| 2778 LastEventLocationDelegate last_event_location_delegate2; |
| 2779 std::unique_ptr<Window> child2( |
| 2780 CreateTestWindowWithDelegate(&last_event_location_delegate2, 124, |
| 2781 gfx::Rect(20, 30, 100, 100), child1.get())); |
| 2782 |
| 2783 // Enable fetching mouse location from mouse. |
| 2784 test::EnvTestHelper().SetAlwaysUseLastMouseLocation(false); |
| 2785 EXPECT_EQ(gfx::Point(0, 0), |
| 2786 window_tree_client_impl()->GetCursorScreenPoint()); |
| 2787 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); |
| 2788 |
| 2789 const gfx::Point mouse_location(15, 25); |
| 2790 ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location, |
| 2791 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 2792 ui::EF_LEFT_MOUSE_BUTTON); |
| 2793 DispatchEventUsingWindowDispatcher(&mouse); |
| 2794 EXPECT_EQ(1, last_event_location_delegate1.mouse_event_count()); |
| 2795 EXPECT_EQ(0, last_event_location_delegate2.mouse_event_count()); |
| 2796 EXPECT_EQ(mouse_location, |
| 2797 last_event_location_delegate1.last_mouse_location()); |
| 2798 EXPECT_EQ(gfx::Point(), last_event_location_delegate2.last_mouse_location()); |
| 2799 } |
| 2800 |
| 2745 class NestedLocationDelegate : public test::TestWindowDelegate { | 2801 class NestedLocationDelegate : public test::TestWindowDelegate { |
| 2746 public: | 2802 public: |
| 2747 NestedLocationDelegate() {} | 2803 NestedLocationDelegate() {} |
| 2748 ~NestedLocationDelegate() override {} | 2804 ~NestedLocationDelegate() override {} |
| 2749 | 2805 |
| 2750 int mouse_event_count() const { return mouse_event_count_; } | 2806 int mouse_event_count() const { return mouse_event_count_; } |
| 2751 int nested_message_loop_count() const { return nested_message_loop_count_; } | 2807 int nested_message_loop_count() const { return nested_message_loop_count_; } |
| 2752 const gfx::Point& last_mouse_location() const { return last_mouse_location_; } | 2808 const gfx::Point& last_mouse_location() const { return last_mouse_location_; } |
| 2753 | 2809 |
| 2754 // TestWindowDelegate: | 2810 // TestWindowDelegate: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2820 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); | 2876 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); |
| 2821 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); | 2877 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); |
| 2822 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); | 2878 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); |
| 2823 | 2879 |
| 2824 // After dispatch the location should fallback to that of the | 2880 // After dispatch the location should fallback to that of the |
| 2825 // WindowTreeClient, which defaults to 0,0. | 2881 // WindowTreeClient, which defaults to 0,0. |
| 2826 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); | 2882 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); |
| 2827 } | 2883 } |
| 2828 | 2884 |
| 2829 } // namespace aura | 2885 } // namespace aura |
| OLD | NEW |