Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebDriver BiDi] Update tilt tests #42360

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
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
40 changes: 2 additions & 38 deletions webdriver/tests/bidi/input/perform_actions/invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def create_pointer_action(pointer_action, overrides=None, removals=None):
"pressure": 0.0,
"tangentialPressure": 0.0,
"twist": 0,
"tiltX": 0,
"tiltY": 0,
"altitudeAngle": 0,
"azimuthAngle": 0,
}

if pointer_action == "pointerMove":
Expand Down Expand Up @@ -574,42 +574,6 @@ async def test_params_pointer_action_common_properties_angle_invalid_type(
await perform_actions([{"type": "pointer", "id": "foo", "actions": [action]}])


@pytest.mark.parametrize("pointer_action", ["pointerDown", "pointerMove", "pointerUp"])
@pytest.mark.parametrize("tilt", ["tiltX", "tiltY"])
@pytest.mark.parametrize("value", [None, "foo", True, 0.1, [], {}])
async def test_params_pointer_action_common_properties_tilt_invalid_type(
perform_actions, pointer_action, tilt, value
):
action = create_pointer_action(
pointer_action,
{
"tiltX": value if tilt == "tiltX" else 0,
"tiltY": value if tilt == "tiltY" else 0,
},
)

with pytest.raises(InvalidArgumentException):
await perform_actions([{"type": "pointer", "id": "foo", "actions": [action]}])


@pytest.mark.parametrize("pointer_action", ["pointerDown", "pointerMove", "pointerUp"])
@pytest.mark.parametrize("tilt", ["tiltX", "tiltY"])
@pytest.mark.parametrize("value", [-91, 91])
async def test_params_pointer_action_common_properties_tilt_invalid_value(
perform_actions, pointer_action, tilt, value
):
action = create_pointer_action(
pointer_action,
{
"tiltX": value if tilt == "tiltX" else 0,
"tiltY": value if tilt == "tiltY" else 0,
},
)

with pytest.raises(InvalidArgumentException):
await perform_actions([{"type": "pointer", "id": "foo", "actions": [action]}])


@pytest.mark.parametrize("coordinate", ["x", "y"])
@pytest.mark.parametrize("value", [None, "foo", True, 0.1, [], {}])
async def test_params_wheel_action_scroll_coordinate_invalid_type(
Expand Down
6 changes: 3 additions & 3 deletions webdriver/tests/bidi/input/perform_actions/pointer_pen.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def test_pen_pointer_properties(
(
actions.add_pointer(pointer_type="pen")
.pointer_move(x=0, y=0, origin=get_element_origin(pointerArea))
.pointer_down(button=0, pressure=0.36, tilt_x=-72, tilt_y=9, twist=86)
.pointer_down(button=0, pressure=0.36, altitude_angle=0.3, azimuth_angle=0.2419, twist=86)
.pointer_move(x=10, y=10, origin=get_element_origin(pointerArea))
.pointer_up(button=0)
.pointer_move(x=80, y=50, origin=get_element_origin(pointerArea))
Expand Down Expand Up @@ -110,8 +110,8 @@ async def test_pen_pointer_properties(
assert round(events[3]["width"], 2) == 1
assert round(events[3]["height"], 2) == 1
assert round(events[3]["pressure"], 2) == 0.36
assert events[3]["tiltX"] == -72
assert events[3]["tiltY"] == 9
assert events[3]["tiltX"] == 72
assert events[3]["tiltY"] == 38
assert events[3]["twist"] == 86
assert events[6]["type"] == "pointermove"
assert events[6]["pageX"] == pytest.approx(center["x"] + 10, abs=1.0)
Expand Down
26 changes: 9 additions & 17 deletions webdriver/tests/bidi/input/perform_actions/pointer_touch.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ async def test_touch_pointer_properties(
width=23,
height=31,
pressure=0.78,
tilt_x=21,
tilt_y=-8,
twist=355,
)
.pointer_move(
Expand All @@ -92,8 +90,6 @@ async def test_touch_pointer_properties(
width=39,
height=35,
pressure=0.91,
tilt_x=-19,
tilt_y=62,
twist=345,
)
.pointer_up(button=0)
Expand Down Expand Up @@ -135,13 +131,9 @@ async def test_touch_pointer_properties(
assert round(events[3]["pressure"], 2) == 0.91


async def test_touch_pointer_properties_tilt_twist(
async def test_touch_pointer_properties_angle_twist(
bidi_session, top_context, get_element, load_static_test_page
):
# This test only covers the tilt/twist properties which are
# more specific to pen-type pointers, but which the spec allows
# for generic touch pointers. Seperating this out gives better
# coverage of the basic properties in test_touch_pointer_properties
await load_static_test_page(page="test_actions_pointer.html")

pointerArea = await get_element("#pointerArea")
Expand All @@ -158,8 +150,8 @@ async def test_touch_pointer_properties_tilt_twist(
width=23,
height=31,
pressure=0.78,
tilt_x=21,
tilt_y=-8,
altitude_angle=1.2,
azimuth_angle=6,
twist=355,
)
.pointer_move(
Expand All @@ -169,8 +161,8 @@ async def test_touch_pointer_properties_tilt_twist(
width=39,
height=35,
pressure=0.91,
tilt_x=-19,
tilt_y=62,
altitude_angle=0.5,
azimuth_angle=1.8,
twist=345,
)
.pointer_up(button=0)
Expand All @@ -195,10 +187,10 @@ async def test_touch_pointer_properties_tilt_twist(
"pointerleave",
] == event_types
assert events[2]["type"] == "pointerdown"
assert events[2]["tiltX"] == 21
assert events[2]["tiltY"] == -8
assert events[2]["tiltX"] == 20
assert events[2]["tiltY"] == -6
assert events[2]["twist"] == 355
assert events[3]["type"] == "pointermove"
assert events[3]["tiltX"] == -19
assert events[3]["tiltY"] == 62
assert events[3]["tiltX"] == -23
assert events[3]["tiltY"] == 61
assert events[3]["twist"] == 345
6 changes: 3 additions & 3 deletions webdriver/tests/classic/perform_actions/pointer_pen.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_pen_pointer_properties(session, test_actions_pointer_page, pen_chain):
pointerArea = session.find.css("#pointerArea", all=False)
center = get_inview_center(pointerArea.rect, get_viewport_rect(session))
pen_chain.pointer_move(0, 0, origin=pointerArea) \
.pointer_down(pressure=0.36, tilt_x=-72, tilt_y=9, twist=86) \
.pointer_down(pressure=0.36, altitude_angle=0.3, azimuth_angle=0.2419, twist=86) \
.pointer_move(10, 10, origin=pointerArea) \
.pointer_up() \
.pointer_move(80, 50, origin=pointerArea) \
Expand All @@ -98,8 +98,8 @@ def test_pen_pointer_properties(session, test_actions_pointer_page, pen_chain):
assert round(events[3]["width"], 2) == 1
assert round(events[3]["height"], 2) == 1
assert round(events[3]["pressure"], 2) == 0.36
assert events[3]["tiltX"] == -72
assert events[3]["tiltY"] == 9
assert events[3]["tiltX"] == 72
assert events[3]["tiltY"] == 38
assert events[3]["twist"] == 86
assert events[6]["type"] == "pointermove"
assert events[6]["pageX"] == pytest.approx(center["x"]+10, abs=1.0)
Expand Down
32 changes: 25 additions & 7 deletions webdriver/tests/classic/perform_actions/pointer_touch.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def test_touch_pointer_properties(session, test_actions_pointer_page, touch_chai
pointerArea = session.find.css("#pointerArea", all=False)
center = get_inview_center(pointerArea.rect, get_viewport_rect(session))
touch_chain.pointer_move(0, 0, origin=pointerArea) \
.pointer_down(width=23, height=31, pressure=0.78, tilt_x=21, tilt_y=-8, twist=355) \
.pointer_move(10, 10, origin=pointerArea, width=39, height=35, pressure=0.91, tilt_x=-19, tilt_y=62, twist=345) \
.pointer_down(width=23, height=31, pressure=0.78, twist=355) \
.pointer_move(10, 10, origin=pointerArea, width=39, height=35, pressure=0.91, twist=345) \
.pointer_up() \
.pointer_move(80, 50, origin=pointerArea) \
.perform()
Expand All @@ -101,13 +101,31 @@ def test_touch_pointer_properties(session, test_actions_pointer_page, touch_chai
assert round(events[3]["pressure"], 2) == 0.91


def test_touch_pointer_properties_angle_twist(session, test_actions_pointer_page, touch_chain):
pointerArea = session.find.css("#pointerArea", all=False)
touch_chain.pointer_move(0, 0, origin=pointerArea) \
.pointer_down(width=23, height=31, pressure=0.78, altitude_angle=1.2, azimuth_angle=6, twist=355) \
.pointer_move(10, 10, origin=pointerArea, width=39, height=35, pressure=0.91, altitude_angle=0.5, azimuth_angle=1.8, twist=345) \
.pointer_up() \
.pointer_move(80, 50, origin=pointerArea) \
.perform()
events = get_events(session)
assert len(events) == 7
event_types = [e["type"] for e in events]
assert ["pointerover", "pointerenter", "pointerdown", "pointermove",
"pointerup", "pointerout", "pointerleave"] == event_types
assert events[2]["type"] == "pointerdown"
assert events[2]["tiltX"] == 20
whimboo marked this conversation as resolved.
Show resolved Hide resolved
assert events[2]["tiltY"] == -6
assert events[2]["twist"] == 355
assert events[3]["type"] == "pointermove"
assert events[3]["tiltX"] == -23
assert events[3]["tiltY"] == 61
assert events[3]["twist"] == 345


def test_touch_pointer_properties_tilt_twist(session, test_actions_pointer_page, touch_chain):
# This test only covers the tilt/twist properties which are
# more specific to pen-type pointers, but which the spec allows
# for generic touch pointers. Seperating this out gives better
# coverage of the basic properties in test_touch_pointer_properties
pointerArea = session.find.css("#pointerArea", all=False)
center = get_inview_center(pointerArea.rect, get_viewport_rect(session))
touch_chain.pointer_move(0, 0, origin=pointerArea) \
.pointer_down(width=23, height=31, pressure=0.78, tilt_x=21, tilt_y=-8, twist=355) \
.pointer_move(10, 10, origin=pointerArea, width=39, height=35, pressure=0.91, tilt_x=-19, tilt_y=62, twist=345) \
Expand Down