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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 DispatchEventUsingWindowDispatcher(&touch_moved_event3); | 800 DispatchEventUsingWindowDispatcher(&touch_moved_event3); |
801 DispatchEventUsingWindowDispatcher(&touch_released_event); | 801 DispatchEventUsingWindowDispatcher(&touch_released_event); |
802 EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP GESTURE_END", | 802 EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP GESTURE_END", |
803 EventTypesToString(recorder.events())); | 803 EventTypesToString(recorder.events())); |
804 recorder.Reset(); | 804 recorder.Reset(); |
805 host()->dispatcher()->ReleasePointerMoves(); | 805 host()->dispatcher()->ReleasePointerMoves(); |
806 RunAllPendingInMessageLoop(); | 806 RunAllPendingInMessageLoop(); |
807 EXPECT_TRUE(recorder.events().empty()); | 807 EXPECT_TRUE(recorder.events().empty()); |
808 } | 808 } |
809 | 809 |
810 // Tests that mouse move event has a right location | |
811 // when there isn't the target window | |
812 TEST_F(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) { | |
813 EventFilterRecorder recorder_first; | |
814 EventFilterRecorder recorder_second; | |
815 | |
816 test::TestWindowDelegate delegate; | |
817 scoped_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( | |
818 &delegate, 1, gfx::Rect(20, 10, 10, 20), root_window())); | |
819 window_first->Show(); | |
820 window_first->AddPreTargetHandler(&recorder_first); | |
821 | |
822 scoped_ptr<aura::Window> window_second(CreateTestWindowWithDelegate( | |
823 &delegate, 2, gfx::Rect(20, 30, 10, 20), root_window())); | |
824 window_second->Show(); | |
825 window_second->AddPreTargetHandler(&recorder_second); | |
826 | |
827 const gfx::Point event_location(22, 33); | |
828 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, | |
829 event_location, 0, 0); | |
830 DispatchEventUsingWindowDispatcher(&mouse); | |
831 | |
832 EXPECT_TRUE(recorder_first.events().empty()); | |
833 EXPECT_FALSE(recorder_second.events().empty()); | |
sky
2014/12/18 20:29:29
Doesn't 834 handle this assertion?
| |
834 EXPECT_EQ("MOUSE_ENTERED MOUSE_MOVED", | |
835 EventTypesToString(recorder_second.events())); | |
836 EXPECT_EQ(gfx::Point(2, 3).ToString(), | |
sky
2014/12/18 20:29:29
You need to assert mouse_locations() is non-empty,
| |
837 recorder_second.mouse_locations()[0].ToString()); | |
838 } | |
839 | |
810 // Verifies that a direct call to ProcessedTouchEvent() with a | 840 // Verifies that a direct call to ProcessedTouchEvent() with a |
811 // TOUCH_PRESSED event does not cause a crash. | 841 // TOUCH_PRESSED event does not cause a crash. |
812 TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { | 842 TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { |
813 test::TestWindowDelegate delegate; | 843 test::TestWindowDelegate delegate; |
814 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 844 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
815 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 845 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
816 | 846 |
817 ui::TouchEvent touch( | 847 ui::TouchEvent touch( |
818 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, ui::EventTimeForNow()); | 848 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, ui::EventTimeForNow()); |
819 host()->dispatcher()->ProcessedTouchEvent( | 849 host()->dispatcher()->ProcessedTouchEvent( |
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2372 ASSERT_EQ(1u, recorder.touch_locations().size()); | 2402 ASSERT_EQ(1u, recorder.touch_locations().size()); |
2373 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), | 2403 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), |
2374 recorder.touch_locations()[0].ToString()); | 2404 recorder.touch_locations()[0].ToString()); |
2375 | 2405 |
2376 ASSERT_EQ(2u, recorder.gesture_locations().size()); | 2406 ASSERT_EQ(2u, recorder.gesture_locations().size()); |
2377 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), | 2407 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), |
2378 recorder.gesture_locations()[0].ToString()); | 2408 recorder.gesture_locations()[0].ToString()); |
2379 } | 2409 } |
2380 | 2410 |
2381 } // namespace aura | 2411 } // namespace aura |
OLD | NEW |