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 "ash/wm/system_gesture_event_filter.h" | 5 #include "ash/wm/system_gesture_event_filter.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "ui/aura/event.h" | 10 #include "ui/aura/event.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 shell_test.system_gesture_event_filter()); | 40 shell_test.system_gesture_event_filter()); |
41 | 41 |
42 aura::GestureEvent* event2 = new aura::GestureEvent( | 42 aura::GestureEvent* event2 = new aura::GestureEvent( |
43 ui::ET_GESTURE_TAP, 0, 0, 0, base::Time::Now(), 0, 0, 1 << kTouchId); | 43 ui::ET_GESTURE_TAP, 0, 0, 0, base::Time::Now(), 0, 0, 1 << kTouchId); |
44 consumed = root_window->DispatchGestureEvent(event2); | 44 consumed = root_window->DispatchGestureEvent(event2); |
45 | 45 |
46 // The event filter doesn't exist, so the touch won't be consumed. | 46 // The event filter doesn't exist, so the touch won't be consumed. |
47 EXPECT_FALSE(consumed); | 47 EXPECT_FALSE(consumed); |
48 } | 48 } |
49 | 49 |
| 50 // Ensure that a three fingered swipe is consumed by the system event handler. |
| 51 TEST_F(SystemGestureEventFilterTest, ThreeFingerSwipe) { |
| 52 aura::RootWindow* root_window = Shell::GetRootWindow(); |
| 53 |
| 54 const int kTouchId = 5; |
| 55 |
| 56 // Get a target for kTouchId |
| 57 aura::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(100, 100), kTouchId, |
| 58 base::Time::NowFromSystemTime() - base::Time()); |
| 59 root_window->DispatchTouchEvent(&press); |
| 60 |
| 61 aura::GestureEvent* event = new aura::GestureEvent( |
| 62 ui::ET_GESTURE_THREE_FINGER_SWIPE, 0, 0, 0, base::Time::Now(), |
| 63 0, 0, 1 << kTouchId); |
| 64 bool consumed = root_window->DispatchGestureEvent(event); |
| 65 |
| 66 EXPECT_TRUE(consumed); |
| 67 |
| 68 // The system event filter shouldn't filter out events like tap downs. |
| 69 aura::GestureEvent* event2 = new aura::GestureEvent( |
| 70 ui::ET_GESTURE_TAP_DOWN, 0, 0, 0, base::Time::Now(), |
| 71 0, 0, 1 << kTouchId); |
| 72 consumed = root_window->DispatchGestureEvent(event2); |
| 73 |
| 74 EXPECT_FALSE(consumed); |
| 75 } |
| 76 |
50 } // namespace ash | 77 } // namespace ash |
OLD | NEW |