feat(driver): add Driver.double_tap via W3C actions

This commit is contained in:
2026-07-15 19:12:10 +08:00
parent c25ccb491d
commit 8a73edf4db
8 changed files with 51 additions and 0 deletions
+17
View File
@@ -105,6 +105,7 @@ def test_connect_failure_raises_device_offline_and_clears_client() -> None:
("disconnect", {}),
("long_press", {"x": 1, "y": 2}),
("swipe_path", {"waypoints": [(0, 0), (1, 1)], "duration_ms": 100}),
("double_tap", {"x": 1, "y": 2}),
],
)
def test_operation_before_connect_raises_device_offline(
@@ -247,6 +248,22 @@ def test_swipe_path_wraps_exception_into_driver_error() -> None:
driver.swipe_path([(0, 0), (1, 1)], 100)
def test_double_tap_sends_w3c_actions() -> None:
from driver._w3c_actions import build_double_tap_actions
driver = _connected_driver()
driver.double_tap(15, 25, interval_ms=90)
args = driver._client.execute.call_args.args
assert args[1] == {"actions": build_double_tap_actions(15, 25, 90)}
def test_double_tap_wraps_exception_into_driver_error() -> None:
driver = _connected_driver()
driver._client.execute.side_effect = RuntimeError("boom")
with pytest.raises(DriverError):
driver.double_tap(1, 2)
def test_swipe_uses_drag_gesture_with_converted_speed() -> None:
driver = _connected_driver()
# 100px horizontal drag over 100ms => 100 / 0.1 = 1000 px/s