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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 DispatchEventUsingWindowDispatcher(&touch_moved_event3); | 808 DispatchEventUsingWindowDispatcher(&touch_moved_event3); |
809 DispatchEventUsingWindowDispatcher(&touch_released_event); | 809 DispatchEventUsingWindowDispatcher(&touch_released_event); |
810 EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP GESTURE_END", | 810 EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP GESTURE_END", |
811 EventTypesToString(recorder.events())); | 811 EventTypesToString(recorder.events())); |
812 recorder.Reset(); | 812 recorder.Reset(); |
813 host()->dispatcher()->ReleasePointerMoves(); | 813 host()->dispatcher()->ReleasePointerMoves(); |
814 RunAllPendingInMessageLoop(); | 814 RunAllPendingInMessageLoop(); |
815 EXPECT_TRUE(recorder.events().empty()); | 815 EXPECT_TRUE(recorder.events().empty()); |
816 } | 816 } |
817 | 817 |
| 818 // Tests that mouse move event has a right location |
| 819 // when there isn't the target window |
| 820 TEST_F(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) { |
| 821 EventFilterRecorder recorder_first; |
| 822 EventFilterRecorder recorder_second; |
| 823 |
| 824 test::TestWindowDelegate delegate; |
| 825 scoped_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( |
| 826 &delegate, 1, gfx::Rect(20, 10, 10, 20), root_window())); |
| 827 window_first->Show(); |
| 828 window_first->AddPreTargetHandler(&recorder_first); |
| 829 |
| 830 scoped_ptr<aura::Window> window_second(CreateTestWindowWithDelegate( |
| 831 &delegate, 2, gfx::Rect(20, 30, 10, 20), root_window())); |
| 832 window_second->Show(); |
| 833 window_second->AddPreTargetHandler(&recorder_second); |
| 834 |
| 835 const gfx::Point event_location(22, 33); |
| 836 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 0, |
| 837 0); |
| 838 DispatchEventUsingWindowDispatcher(&mouse); |
| 839 |
| 840 EXPECT_TRUE(recorder_first.events().empty()); |
| 841 EXPECT_EQ("MOUSE_ENTERED MOUSE_MOVED", |
| 842 EventTypesToString(recorder_second.events())); |
| 843 ASSERT_EQ(2u, recorder_second.mouse_locations().size()); |
| 844 EXPECT_EQ(gfx::Point(2, 3).ToString(), |
| 845 recorder_second.mouse_locations()[0].ToString()); |
| 846 } |
| 847 |
818 // Verifies that a direct call to ProcessedTouchEvent() with a | 848 // Verifies that a direct call to ProcessedTouchEvent() with a |
819 // TOUCH_PRESSED event does not cause a crash. | 849 // TOUCH_PRESSED event does not cause a crash. |
820 TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { | 850 TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { |
821 test::TestWindowDelegate delegate; | 851 test::TestWindowDelegate delegate; |
822 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 852 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
823 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 853 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
824 | 854 |
825 ui::TouchEvent touch( | 855 ui::TouchEvent touch( |
826 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, ui::EventTimeForNow()); | 856 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, ui::EventTimeForNow()); |
827 host()->dispatcher()->ProcessedTouchEvent( | 857 host()->dispatcher()->ProcessedTouchEvent( |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 0, | 2457 0, |
2428 ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1)); | 2458 ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1)); |
2429 DispatchEventUsingWindowDispatcher(&release); | 2459 DispatchEventUsingWindowDispatcher(&release); |
2430 EXPECT_FALSE(recorder.LastTouchMayCauseScrolling()); | 2460 EXPECT_FALSE(recorder.LastTouchMayCauseScrolling()); |
2431 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED)); | 2461 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED)); |
2432 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END)); | 2462 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END)); |
2433 | 2463 |
2434 root_window()->RemovePreTargetHandler(&recorder); | 2464 root_window()->RemovePreTargetHandler(&recorder); |
2435 } | 2465 } |
2436 } // namespace aura | 2466 } // namespace aura |
OLD | NEW |