Skip to content

Commit b257e60

Browse files
committed
test all cases
1 parent ef0492a commit b257e60

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

py/test/selenium/webdriver/common/bidi_emulation_tests.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,30 @@ def test_set_screen_orientation_override_with_contexts(driver, pages):
485485
assert get_screen_orientation(driver, context_id) == initial_orientation
486486

487487

488-
def test_set_screen_orientation_override_with_user_contexts(driver, pages):
488+
@pytest.mark.parametrize(
489+
"natural,orientation_type,expected_angle",
490+
[
491+
# Portrait natural orientations
492+
("portrait", "portrait-primary", 0),
493+
("portrait", "portrait-secondary", 180),
494+
("portrait", "landscape-primary", 90),
495+
("portrait", "landscape-secondary", 270),
496+
# Landscape natural orientations
497+
("landscape", "portrait-primary", 90),
498+
("landscape", "portrait-secondary", 270),
499+
("landscape", "landscape-primary", 0),
500+
("landscape", "landscape-secondary", 180),
501+
],
502+
)
503+
def test_set_screen_orientation_override_with_user_contexts(driver, pages, natural, orientation_type, expected_angle):
489504
user_context = driver.browser.create_user_context()
490505
try:
491506
context_id = driver.browsing_context.create(type=WindowTypes.TAB, user_context=user_context)
492507
try:
493508
driver.switch_to.window(context_id)
494509

495-
# Set landscape-secondary orientation on portrait natural using string
496-
orientation = ScreenOrientation(
497-
natural="portrait",
498-
type="landscape-secondary",
499-
)
510+
# Set the specified orientation
511+
orientation = ScreenOrientation(natural=natural, type=orientation_type)
500512
driver.emulation.set_screen_orientation_override(
501513
screen_orientation=orientation, user_contexts=[user_context]
502514
)
@@ -506,10 +518,9 @@ def test_set_screen_orientation_override_with_user_contexts(driver, pages):
506518

507519
# Verify the orientation was set
508520
current_orientation = get_screen_orientation(driver, context_id)
509-
assert current_orientation["type"] == "landscape-secondary", (
510-
f"Expected landscape-secondary, got {current_orientation}"
511-
)
512-
assert current_orientation["angle"] == 270, f"Expected angle 270, got {current_orientation['angle']}"
521+
522+
assert current_orientation["type"] == orientation_type
523+
assert current_orientation["angle"] == expected_angle
513524

514525
driver.emulation.set_screen_orientation_override(screen_orientation=None, user_contexts=[user_context])
515526
finally:

0 commit comments

Comments
 (0)