Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/mouse_controller_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,25 @@ def test_scroll_down(self):
'Failed to send scroll down event',
on_scroll=lambda x, y, dx, dy: dy < 0):
self.controller.scroll(0, -1)

def test_scroll_no_duplicate(self):
"""Tests that a single scroll call yields a single scroll event.

Regression test for an issue where Windows ``Controller._scroll``
fired ``on_scroll`` twice: once via ``NotifierMixin._emit`` and once
via the ``WH_MOUSE_LL`` hook that already receives ``SendInput``
events.
"""
events = []
listener = self.listener(
on_scroll=lambda x, y, dx, dy: events.append((dx, dy)))
with listener:
time.sleep(0.2)
del events[:]
self.controller.scroll(0, 1)
time.sleep(0.5)

self.assertEqual(
1, len(events),
'Expected exactly one scroll event, got %d: %r' % (
len(events), events))