Skip to content

Commit

Permalink
Make SwitchProbe.press an async method
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Apr 3, 2023
1 parent 32b612b commit eb62795
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gtk/tests_backend/widgets/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def assert_height(self, min_height, max_height):
min_height <= switch_height <= max_height
), f"Switch height ({switch_height}) not in range ({min_height}, {max_height})"

def press(self):
async def press(self):
# This isn't really a "click" - it's just changing the value.
# However, Gtk doesn't seem to have a way to send a click to a switch,
# and the underlying event on Gtk *is* a value change event.
Expand Down
2 changes: 1 addition & 1 deletion iOS/tests_backend/widgets/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ def assert_height(self, min_height, max_height):
30 <= switch_height <= 40
), f"Switch height ({switch_height}) not in range (30, 40)"

def press(self):
async def press(self):
self.native_switch.sendActionsForControlEvents(UIControlEventValueChanged)
4 changes: 2 additions & 2 deletions testbed/tests/widgets/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ async def test_text(widget, probe):

async def test_press(widget, probe):
# Press the button before installing a handler
probe.press()
await probe.press()
await probe.redraw()

# Set up a mock handler, and press the button again.
handler = Mock()
widget.on_change = handler

probe.press()
await probe.press()
await probe.redraw()
handler.assert_called_once_with(widget)

Expand Down

0 comments on commit eb62795

Please sign in to comment.