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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 DispatchEventUsingWindowDispatcher(&mouse); | 839 DispatchEventUsingWindowDispatcher(&mouse); |
840 | 840 |
841 EXPECT_TRUE(recorder_first.events().empty()); | 841 EXPECT_TRUE(recorder_first.events().empty()); |
842 EXPECT_EQ("MOUSE_ENTERED MOUSE_MOVED", | 842 EXPECT_EQ("MOUSE_ENTERED MOUSE_MOVED", |
843 EventTypesToString(recorder_second.events())); | 843 EventTypesToString(recorder_second.events())); |
844 ASSERT_EQ(2u, recorder_second.mouse_locations().size()); | 844 ASSERT_EQ(2u, recorder_second.mouse_locations().size()); |
845 EXPECT_EQ(gfx::Point(2, 3).ToString(), | 845 EXPECT_EQ(gfx::Point(2, 3).ToString(), |
846 recorder_second.mouse_locations()[0].ToString()); | 846 recorder_second.mouse_locations()[0].ToString()); |
847 } | 847 } |
848 | 848 |
849 // Verifies that a direct call to ProcessedTouchEvent() with a | 849 // Verifies that a direct call to ProcessedTouchEvent() does not cause a crash. |
850 // TOUCH_PRESSED event does not cause a crash. | |
851 TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { | 850 TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { |
852 test::TestWindowDelegate delegate; | 851 test::TestWindowDelegate delegate; |
853 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 852 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
854 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 853 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
855 | 854 |
856 ui::TouchEvent touch( | 855 host()->dispatcher()->ProcessedTouchEvent(window.get(), ui::ER_UNHANDLED); |
857 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, ui::EventTimeForNow()); | |
858 host()->dispatcher()->ProcessedTouchEvent( | |
859 &touch, window.get(), ui::ER_UNHANDLED); | |
860 } | 856 } |
861 | 857 |
862 // This event handler requests the dispatcher to start holding pointer-move | 858 // This event handler requests the dispatcher to start holding pointer-move |
863 // events when it receives the first scroll-update gesture. | 859 // events when it receives the first scroll-update gesture. |
864 class HoldPointerOnScrollHandler : public ui::test::TestEventHandler { | 860 class HoldPointerOnScrollHandler : public ui::test::TestEventHandler { |
865 public: | 861 public: |
866 HoldPointerOnScrollHandler(WindowEventDispatcher* dispatcher, | 862 HoldPointerOnScrollHandler(WindowEventDispatcher* dispatcher, |
867 EventFilterRecorder* filter) | 863 EventFilterRecorder* filter) |
868 : dispatcher_(dispatcher), | 864 : dispatcher_(dispatcher), |
869 filter_(filter), | 865 filter_(filter), |
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 : dispatcher_(dispatcher) {} | 2435 : dispatcher_(dispatcher) {} |
2440 | 2436 |
2441 void set_window(Window* window) { | 2437 void set_window(Window* window) { |
2442 window_ = window; | 2438 window_ = window; |
2443 } | 2439 } |
2444 private: | 2440 private: |
2445 void OnTouchEvent(ui::TouchEvent* event) override { | 2441 void OnTouchEvent(ui::TouchEvent* event) override { |
2446 // Convert touch event back to root window coordinates. | 2442 // Convert touch event back to root window coordinates. |
2447 event->ConvertLocationToTarget(window_, window_->GetRootWindow()); | 2443 event->ConvertLocationToTarget(window_, window_->GetRootWindow()); |
2448 event->DisableSynchronousHandling(); | 2444 event->DisableSynchronousHandling(); |
2449 dispatcher_->ProcessedTouchEvent(event, window_, ui::ER_UNHANDLED); | 2445 dispatcher_->ProcessedTouchEvent(window_, ui::ER_UNHANDLED); |
2450 event->StopPropagation(); | 2446 event->StopPropagation(); |
2451 } | 2447 } |
2452 | 2448 |
2453 WindowEventDispatcher* dispatcher_; | 2449 WindowEventDispatcher* dispatcher_; |
2454 Window* window_; | 2450 Window* window_; |
2455 | 2451 |
2456 DISALLOW_COPY_AND_ASSIGN(AsyncWindowDelegate); | 2452 DISALLOW_COPY_AND_ASSIGN(AsyncWindowDelegate); |
2457 }; | 2453 }; |
2458 | 2454 |
2459 // Tests that gesture events dispatched through the asynchronous flow have | 2455 // Tests that gesture events dispatched through the asynchronous flow have |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 0, | 2527 0, |
2532 ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1)); | 2528 ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1)); |
2533 DispatchEventUsingWindowDispatcher(&release); | 2529 DispatchEventUsingWindowDispatcher(&release); |
2534 EXPECT_FALSE(recorder.LastTouchMayCauseScrolling()); | 2530 EXPECT_FALSE(recorder.LastTouchMayCauseScrolling()); |
2535 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED)); | 2531 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED)); |
2536 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END)); | 2532 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END)); |
2537 | 2533 |
2538 root_window()->RemovePreTargetHandler(&recorder); | 2534 root_window()->RemovePreTargetHandler(&recorder); |
2539 } | 2535 } |
2540 } // namespace aura | 2536 } // namespace aura |
OLD | NEW |