| Index: ash/pointer_watcher_delegate_aura_unittest.cc
|
| diff --git a/ash/pointer_watcher_delegate_aura_unittest.cc b/ash/pointer_watcher_delegate_aura_unittest.cc
|
| index a6c99cb511dd851fdfdc969955f2e07ba88a1238..9fa4b16aa00f598992f42a8846c7f055e2bd8da5 100644
|
| --- a/ash/pointer_watcher_delegate_aura_unittest.cc
|
| +++ b/ash/pointer_watcher_delegate_aura_unittest.cc
|
| @@ -14,8 +14,9 @@ namespace ash {
|
|
|
| using PointerWatcherDelegateAuraTest = test::AshTestBase;
|
|
|
| -// Records calls to OnPointerEventObserved() in |pointer_event_count_| and
|
| -// calls to OnMouseCaptureChanged() to |capture_changed_count_|.
|
| +// Records calls to OnPointerEventObserved() in |mouse_wheel_event_count| for a
|
| +// mouse wheel event, in |capture_changed_count_| for a mouse capture change
|
| +// event and in |pointer_event_count_| for all other pointer events.
|
| class TestPointerWatcher : public views::PointerWatcher {
|
| public:
|
| explicit TestPointerWatcher(bool wants_moves) {
|
| @@ -25,22 +26,31 @@ class TestPointerWatcher : public views::PointerWatcher {
|
| Shell::GetInstance()->RemovePointerWatcher(this);
|
| }
|
|
|
| - void ClearCounts() { pointer_event_count_ = capture_changed_count_ = 0; }
|
| + void ClearCounts() {
|
| + pointer_event_count_ = capture_changed_count_ = mouse_wheel_event_count_ =
|
| + 0;
|
| + }
|
|
|
| int pointer_event_count() const { return pointer_event_count_; }
|
| int capture_changed_count() const { return capture_changed_count_; }
|
| + int mouse_wheel_event_count() const { return mouse_wheel_event_count_; }
|
|
|
| // views::PointerWatcher:
|
| void OnPointerEventObserved(const ui::PointerEvent& event,
|
| const gfx::Point& location_in_screen,
|
| views::Widget* target) override {
|
| - pointer_event_count_++;
|
| + if (event.type() == ui::ET_POINTER_WHEEL_CHANGED)
|
| + mouse_wheel_event_count_++;
|
| + else if (event.type() == ui::ET_POINTER_CAPTURE_CHANGED)
|
| + capture_changed_count_++;
|
| + else
|
| + pointer_event_count_++;
|
| }
|
| - void OnMouseCaptureChanged() override { capture_changed_count_++; }
|
|
|
| private:
|
| int pointer_event_count_ = 0;
|
| int capture_changed_count_ = 0;
|
| + int mouse_wheel_event_count_ = 0;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TestPointerWatcher);
|
| };
|
| @@ -54,15 +64,21 @@ class TestHelper {
|
| // Used to verify call counts.
|
| void ExpectCallCount(int non_move_pointer_event_count,
|
| int non_move_capture_changed_count,
|
| + int non_move_mouse_wheel_event_count,
|
| int move_pointer_event_count,
|
| - int move_capture_changed_count) {
|
| + int move_capture_changed_count,
|
| + int move_mouse_wheel_event_count) {
|
| EXPECT_EQ(non_move_pointer_event_count,
|
| non_move_watcher_.pointer_event_count());
|
| EXPECT_EQ(non_move_capture_changed_count,
|
| non_move_watcher_.capture_changed_count());
|
| + EXPECT_EQ(non_move_mouse_wheel_event_count,
|
| + non_move_watcher_.mouse_wheel_event_count());
|
| EXPECT_EQ(move_pointer_event_count, move_watcher_.pointer_event_count());
|
| EXPECT_EQ(move_capture_changed_count,
|
| move_watcher_.capture_changed_count());
|
| + EXPECT_EQ(move_mouse_wheel_event_count,
|
| + move_watcher_.mouse_wheel_event_count());
|
|
|
| non_move_watcher_.ClearCounts();
|
| move_watcher_.ClearCounts();
|
| @@ -80,39 +96,39 @@ TEST_F(PointerWatcherDelegateAuraTest, MouseEvents) {
|
|
|
| // Move: only the move PointerWatcher should get the event.
|
| GetEventGenerator().MoveMouseTo(gfx::Point(10, 10));
|
| - helper.ExpectCallCount(0, 0, 1, 0);
|
| + helper.ExpectCallCount(0, 0, 0, 1, 0, 0);
|
|
|
| // Press: both.
|
| GetEventGenerator().PressLeftButton();
|
| - helper.ExpectCallCount(1, 0, 1, 0);
|
| + helper.ExpectCallCount(1, 0, 0, 1, 0, 0);
|
|
|
| // Drag: none.
|
| GetEventGenerator().MoveMouseTo(gfx::Point(20, 30));
|
| - helper.ExpectCallCount(0, 0, 0, 0);
|
| + helper.ExpectCallCount(0, 0, 0, 0, 0, 0);
|
|
|
| // Release: both (aura generates a capture event here).
|
| GetEventGenerator().ReleaseLeftButton();
|
| - helper.ExpectCallCount(1, 1, 1, 1);
|
| + helper.ExpectCallCount(1, 1, 0, 1, 1, 0);
|
|
|
| // 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
|
| + // Wheel: both
|
| GetEventGenerator().MoveMouseWheel(10, 11);
|
| - helper.ExpectCallCount(0, 0, 0, 0);
|
| + helper.ExpectCallCount(0, 0, 1, 0, 0, 1);
|
|
|
| // Capture: both.
|
| 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, 0, 1, 0);
|
| }
|
|
|
| TEST_F(PointerWatcherDelegateAuraTest, TouchEvents) {
|
| @@ -121,16 +137,16 @@ TEST_F(PointerWatcherDelegateAuraTest, TouchEvents) {
|
| // Press: both.
|
| const int touch_id = 11;
|
| GetEventGenerator().PressTouchId(touch_id);
|
| - helper.ExpectCallCount(1, 0, 1, 0);
|
| + helper.ExpectCallCount(1, 0, 0, 1, 0, 0);
|
|
|
| // Drag: none.
|
| GetEventGenerator().MoveTouchId(gfx::Point(20, 30), touch_id);
|
| - helper.ExpectCallCount(0, 0, 0, 0);
|
| + helper.ExpectCallCount(0, 0, 0, 0, 0, 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, 0, 1, 0, 0);
|
| }
|
|
|
| } // namespace ash
|
|
|