Index: ash/aura/pointer_watcher_adapter_unittest.cc |
diff --git a/ash/aura/pointer_watcher_adapter_unittest.cc b/ash/aura/pointer_watcher_adapter_unittest.cc |
index c0a67685e9c08867d78d3c4f964dde6716aab63e..b4affceadda1c6980ebf885e38b4aeb4e96b5aa7 100644 |
--- a/ash/aura/pointer_watcher_adapter_unittest.cc |
+++ b/ash/aura/pointer_watcher_adapter_unittest.cc |
@@ -18,8 +18,8 @@ using PointerWatcherAdapterTest = test::AshTestBase; |
// calls to OnMouseCaptureChanged() to |capture_changed_count_|. |
class TestPointerWatcher : public views::PointerWatcher { |
public: |
- explicit TestPointerWatcher(bool wants_moves) { |
- WmShell::Get()->AddPointerWatcher(this, wants_moves); |
+ explicit TestPointerWatcher(views::RequestedEvents events) { |
+ WmShell::Get()->AddPointerWatcher(this, events); |
} |
~TestPointerWatcher() override { WmShell::Get()->RemovePointerWatcher(this); } |
@@ -43,17 +43,23 @@ class TestPointerWatcher : public views::PointerWatcher { |
DISALLOW_COPY_AND_ASSIGN(TestPointerWatcher); |
}; |
-// Creates two TestPointerWatchers, one that wants moves and one that doesn't. |
+// Creates three TestPointerWatchers, one that wants moves and one that wants |
+// drags, and one that does not want either. |
class TestHelper { |
public: |
- TestHelper() : non_move_watcher_(false), move_watcher_(true) {} |
+ TestHelper() |
+ : non_move_watcher_(views::RequestedEvents::BASIC), |
+ move_watcher_(views::RequestedEvents::MOVES), |
+ drag_watcher_(views::RequestedEvents::DRAGS) {} |
~TestHelper() {} |
// Used to verify call counts. |
void ExpectCallCount(int non_move_pointer_event_count, |
int non_move_capture_changed_count, |
int move_pointer_event_count, |
- int move_capture_changed_count) { |
+ int move_capture_changed_count, |
+ int drag_pointer_event_count, |
+ int drag_capture_changed_count) { |
EXPECT_EQ(non_move_pointer_event_count, |
non_move_watcher_.pointer_event_count()); |
EXPECT_EQ(non_move_capture_changed_count, |
@@ -61,14 +67,19 @@ class TestHelper { |
EXPECT_EQ(move_pointer_event_count, move_watcher_.pointer_event_count()); |
EXPECT_EQ(move_capture_changed_count, |
move_watcher_.capture_changed_count()); |
+ EXPECT_EQ(drag_pointer_event_count, drag_watcher_.pointer_event_count()); |
+ EXPECT_EQ(drag_capture_changed_count, |
+ drag_watcher_.capture_changed_count()); |
non_move_watcher_.ClearCounts(); |
move_watcher_.ClearCounts(); |
+ drag_watcher_.ClearCounts(); |
} |
private: |
TestPointerWatcher non_move_watcher_; |
TestPointerWatcher move_watcher_; |
+ TestPointerWatcher drag_watcher_; |
DISALLOW_COPY_AND_ASSIGN(TestHelper); |
}; |
@@ -76,41 +87,41 @@ class TestHelper { |
TEST_F(PointerWatcherAdapterTest, MouseEvents) { |
TestHelper helper; |
- // Move: only the move PointerWatcher should get the event. |
+ // Move: only the move and drag PointerWatcher should get the event. |
GetEventGenerator().MoveMouseTo(gfx::Point(10, 10)); |
- helper.ExpectCallCount(0, 0, 1, 0); |
+ helper.ExpectCallCount(0, 0, 1, 0, 1, 0); |
sky
2016/08/26 15:36:54
You can blame me for starting this, but this code
sammiequon
2016/08/26 18:34:20
Done.
|
- // Press: both. |
+ // Press: all. |
GetEventGenerator().PressLeftButton(); |
- helper.ExpectCallCount(1, 0, 1, 0); |
+ helper.ExpectCallCount(1, 0, 1, 0, 1, 0); |
- // Drag: none. |
+ // Drag: only drag PointerWatcher should get the event. |
GetEventGenerator().MoveMouseTo(gfx::Point(20, 30)); |
- helper.ExpectCallCount(0, 0, 0, 0); |
+ helper.ExpectCallCount(0, 0, 0, 0, 1, 0); |
- // Release: both (aura generates a capture event here). |
+ // Release: all (aura generates a capture event here). |
GetEventGenerator().ReleaseLeftButton(); |
- helper.ExpectCallCount(1, 1, 1, 1); |
+ helper.ExpectCallCount(1, 1, 1, 1, 1, 1); |
// Exit: none. |
GetEventGenerator().SendMouseExit(); |
- helper.ExpectCallCount(0, 0, 0, 0); |
+ helper.ExpectCallCount(0, 0, 0, 0, 0, 0); |
// Enter: none. |
ui::MouseEvent enter_event(ui::ET_MOUSE_ENTERED, gfx::Point(), gfx::Point(), |
ui::EventTimeForNow(), 0, 0); |
GetEventGenerator().Dispatch(&enter_event); |
- helper.ExpectCallCount(0, 0, 0, 0); |
+ helper.ExpectCallCount(0, 0, 0, 0, 0, 0); |
// Wheel: none |
GetEventGenerator().MoveMouseWheel(10, 11); |
- helper.ExpectCallCount(0, 0, 0, 0); |
+ helper.ExpectCallCount(0, 0, 0, 0, 0, 0); |
- // Capture: both. |
+ // Capture: all. |
ui::MouseEvent capture_event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), |
gfx::Point(), ui::EventTimeForNow(), 0, 0); |
GetEventGenerator().Dispatch(&capture_event); |
- helper.ExpectCallCount(0, 1, 0, 1); |
+ helper.ExpectCallCount(0, 1, 0, 1, 0, 1); |
} |
TEST_F(PointerWatcherAdapterTest, TouchEvents) { |
@@ -119,16 +130,16 @@ TEST_F(PointerWatcherAdapterTest, TouchEvents) { |
// Press: both. |
const int touch_id = 11; |
GetEventGenerator().PressTouchId(touch_id); |
- helper.ExpectCallCount(1, 0, 1, 0); |
+ helper.ExpectCallCount(1, 0, 1, 0, 1, 0); |
- // Drag: none. |
+ // Drag: only drag. |
GetEventGenerator().MoveTouchId(gfx::Point(20, 30), touch_id); |
- helper.ExpectCallCount(0, 0, 0, 0); |
+ helper.ExpectCallCount(0, 0, 0, 0, 1, 0); |
// Release: both (contrary to mouse above, touch does not implicitly generate |
// capture). |
GetEventGenerator().ReleaseTouchId(touch_id); |
- helper.ExpectCallCount(1, 0, 1, 0); |
+ helper.ExpectCallCount(1, 0, 1, 0, 1, 0); |
} |
} // namespace ash |