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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 EXPECT_EQ(gfx::Point(12, 23).ToString(), | 934 EXPECT_EQ(gfx::Point(12, 23).ToString(), |
935 recorder.mouse_locations()[0].ToString()); | 935 recorder.mouse_locations()[0].ToString()); |
936 } | 936 } |
937 | 937 |
938 // Verifies that a direct call to ProcessedTouchEvent() does not cause a crash. | 938 // Verifies that a direct call to ProcessedTouchEvent() does not cause a crash. |
939 TEST_P(WindowEventDispatcherTest, CallToProcessedTouchEvent) { | 939 TEST_P(WindowEventDispatcherTest, CallToProcessedTouchEvent) { |
940 test::TestWindowDelegate delegate; | 940 test::TestWindowDelegate delegate; |
941 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 941 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
942 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 942 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
943 | 943 |
944 host()->dispatcher()->ProcessedTouchEvent( | 944 host()->dispatcher()->ProcessedTouchEvent(0, window.get(), ui::ER_UNHANDLED); |
945 0, window.get(), ui::ER_UNHANDLED, | |
946 false /* is_source_touch_event_set_non_blocking */); | |
947 } | 945 } |
948 | 946 |
949 // This event handler requests the dispatcher to start holding pointer-move | 947 // This event handler requests the dispatcher to start holding pointer-move |
950 // events when it receives the first scroll-update gesture. | 948 // events when it receives the first scroll-update gesture. |
951 class HoldPointerOnScrollHandler : public ui::test::TestEventHandler { | 949 class HoldPointerOnScrollHandler : public ui::test::TestEventHandler { |
952 public: | 950 public: |
953 HoldPointerOnScrollHandler(WindowEventDispatcher* dispatcher, | 951 HoldPointerOnScrollHandler(WindowEventDispatcher* dispatcher, |
954 EventFilterRecorder* filter) | 952 EventFilterRecorder* filter) |
955 : dispatcher_(dispatcher), | 953 : dispatcher_(dispatcher), |
956 filter_(filter), | 954 filter_(filter), |
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2599 : dispatcher_(dispatcher), window_(nullptr) {} | 2597 : dispatcher_(dispatcher), window_(nullptr) {} |
2600 | 2598 |
2601 void set_window(Window* window) { | 2599 void set_window(Window* window) { |
2602 window_ = window; | 2600 window_ = window; |
2603 } | 2601 } |
2604 private: | 2602 private: |
2605 void OnTouchEvent(ui::TouchEvent* event) override { | 2603 void OnTouchEvent(ui::TouchEvent* event) override { |
2606 // Convert touch event back to root window coordinates. | 2604 // Convert touch event back to root window coordinates. |
2607 event->ConvertLocationToTarget(window_, window_->GetRootWindow()); | 2605 event->ConvertLocationToTarget(window_, window_->GetRootWindow()); |
2608 event->DisableSynchronousHandling(); | 2606 event->DisableSynchronousHandling(); |
2609 dispatcher_->ProcessedTouchEvent( | 2607 dispatcher_->ProcessedTouchEvent(event->unique_event_id(), window_, |
2610 event->unique_event_id(), window_, ui::ER_UNHANDLED, | 2608 ui::ER_UNHANDLED); |
2611 false /* is_source_touch_event_set_non_blocking */); | |
2612 event->StopPropagation(); | 2609 event->StopPropagation(); |
2613 } | 2610 } |
2614 | 2611 |
2615 WindowEventDispatcher* dispatcher_; | 2612 WindowEventDispatcher* dispatcher_; |
2616 Window* window_; | 2613 Window* window_; |
2617 | 2614 |
2618 DISALLOW_COPY_AND_ASSIGN(AsyncWindowDelegate); | 2615 DISALLOW_COPY_AND_ASSIGN(AsyncWindowDelegate); |
2619 }; | 2616 }; |
2620 | 2617 |
2621 // Tests that gesture events dispatched through the asynchronous flow have | 2618 // Tests that gesture events dispatched through the asynchronous flow have |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2952 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); | 2949 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); |
2953 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); | 2950 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); |
2954 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); | 2951 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); |
2955 | 2952 |
2956 // After dispatch the location should fallback to that of the | 2953 // After dispatch the location should fallback to that of the |
2957 // WindowTreeClient, which defaults to 0,0. | 2954 // WindowTreeClient, which defaults to 0,0. |
2958 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); | 2955 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); |
2959 } | 2956 } |
2960 | 2957 |
2961 } // namespace aura | 2958 } // namespace aura |
OLD | NEW |