OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/shell_port.h" |
5 #include "ash/test/ash_test_base.h" | 6 #include "ash/test/ash_test_base.h" |
6 #include "ash/wm_shell.h" | |
7 #include "ui/events/base_event_utils.h" | 7 #include "ui/events/base_event_utils.h" |
8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
9 #include "ui/events/test/event_generator.h" | 9 #include "ui/events/test/event_generator.h" |
10 #include "ui/views/pointer_watcher.h" | 10 #include "ui/views/pointer_watcher.h" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 | 14 |
15 using PointerWatcherAdapterTest = test::AshTestBase; | 15 using PointerWatcherAdapterTest = test::AshTestBase; |
16 | 16 |
17 enum TestPointerCaptureEvents { | 17 enum TestPointerCaptureEvents { |
18 NONE = 0x01, | 18 NONE = 0x01, |
19 CAPTURE = 0x02, | 19 CAPTURE = 0x02, |
20 WHEEL = 0x04, | 20 WHEEL = 0x04, |
21 PRESS_OR_RELEASE = 0x08, | 21 PRESS_OR_RELEASE = 0x08, |
22 MOVE = 0x10, | 22 MOVE = 0x10, |
23 DRAG = 0x20 | 23 DRAG = 0x20 |
24 }; | 24 }; |
25 | 25 |
26 // Records calls to OnPointerEventObserved() in |mouse_wheel_event_count| for a | 26 // Records calls to OnPointerEventObserved() in |mouse_wheel_event_count| for a |
27 // mouse wheel event, in |capture_changed_count_| for a mouse capture change | 27 // mouse wheel event, in |capture_changed_count_| for a mouse capture change |
28 // event and in |pointer_event_count_| for all other pointer events. | 28 // event and in |pointer_event_count_| for all other pointer events. |
29 class TestPointerWatcher : public views::PointerWatcher { | 29 class TestPointerWatcher : public views::PointerWatcher { |
30 public: | 30 public: |
31 explicit TestPointerWatcher(views::PointerWatcherEventTypes events) { | 31 explicit TestPointerWatcher(views::PointerWatcherEventTypes events) { |
32 WmShell::Get()->AddPointerWatcher(this, events); | 32 ShellPort::Get()->AddPointerWatcher(this, events); |
33 } | 33 } |
34 ~TestPointerWatcher() override { WmShell::Get()->RemovePointerWatcher(this); } | 34 ~TestPointerWatcher() override { |
| 35 ShellPort::Get()->RemovePointerWatcher(this); |
| 36 } |
35 | 37 |
36 void ClearCounts() { | 38 void ClearCounts() { |
37 pointer_event_count_ = capture_changed_count_ = mouse_wheel_event_count_ = | 39 pointer_event_count_ = capture_changed_count_ = mouse_wheel_event_count_ = |
38 move_changed_count_ = drag_changed_count_ = 0; | 40 move_changed_count_ = drag_changed_count_ = 0; |
39 } | 41 } |
40 | 42 |
41 int pointer_event_count() const { return pointer_event_count_; } | 43 int pointer_event_count() const { return pointer_event_count_; } |
42 int capture_changed_count() const { return capture_changed_count_; } | 44 int capture_changed_count() const { return capture_changed_count_; } |
43 int mouse_wheel_event_count() const { return mouse_wheel_event_count_; } | 45 int mouse_wheel_event_count() const { return mouse_wheel_event_count_; } |
44 int move_changed_count() const { return move_changed_count_; } | 46 int move_changed_count() const { return move_changed_count_; } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 GetEventGenerator().MoveTouchId(gfx::Point(20, 30), touch_id); | 203 GetEventGenerator().MoveTouchId(gfx::Point(20, 30), touch_id); |
202 helper.ExpectCallCount(NONE, NONE, DRAG); | 204 helper.ExpectCallCount(NONE, NONE, DRAG); |
203 | 205 |
204 // Release: both (contrary to mouse above, touch does not implicitly generate | 206 // Release: both (contrary to mouse above, touch does not implicitly generate |
205 // capture). | 207 // capture). |
206 GetEventGenerator().ReleaseTouchId(touch_id); | 208 GetEventGenerator().ReleaseTouchId(touch_id); |
207 helper.ExpectCallCount(PRESS_OR_RELEASE, PRESS_OR_RELEASE, PRESS_OR_RELEASE); | 209 helper.ExpectCallCount(PRESS_OR_RELEASE, PRESS_OR_RELEASE, PRESS_OR_RELEASE); |
208 } | 210 } |
209 | 211 |
210 } // namespace ash | 212 } // namespace ash |
OLD | NEW |