Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit19bad37

Browse files
committed
feat: add XVFB_RESOLUTION
1 parentbaa79ae commit19bad37

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

‎src/ffpuppet/display.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
fromcontextlibimportsuppress
99
fromenumimportEnum,auto,unique
1010
fromloggingimportgetLogger
11+
fromosimportenviron
1112
fromplatformimportsystem
1213
fromtypesimportMappingProxyType
1314
fromtypingimportTYPE_CHECKING
@@ -74,8 +75,18 @@ class XvfbDisplay(Display):
7475
def__init__(self)->None:
7576
super().__init__()
7677
self.env=MappingProxyType({"MOZ_ENABLE_WAYLAND":"0"})
78+
resolution=environ.get("XVFB_RESOLUTION")
79+
width=1280
80+
height=1024
81+
ifresolutionisnotNone:
82+
try:
83+
w_str,h_str=resolution.lower().split("x")
84+
width,height=int(w_str),int(h_str)
85+
exceptValueError:
86+
LOG.warning("Invalid XVFB_RESOLUTION '%s'",resolution)
87+
LOG.debug("xvfb resolution: %dx%d",width,height)
7788
try:
78-
self._xvfb:Xvfb|None=Xvfb(width=1280,height=1024)
89+
self._xvfb:Xvfb|None=Xvfb(width=width,height=height)
7990
exceptNameError:
8091
LOG.error("Missing xvfbwrapper")
8192
raise

‎src/ffpuppet/test_display.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,23 @@ def test_xvfb_missing_deps(mocker):
3636
mocker.patch("ffpuppet.display.Xvfb",side_effect=NameError("test"))
3737
withraises(NameError):
3838
XvfbDisplay()
39+
40+
41+
@mark.skipif(system()!="Linux",reason="Only supported on Linux")
42+
@mark.parametrize(
43+
"resolution, expected_width, expected_height",
44+
(
45+
(None,1280,1024),
46+
("1920x1080",1920,1080),
47+
("a",1280,1024),
48+
),
49+
)
50+
deftest_xvfb_resolution(mocker,resolution,expected_width,expected_height):
51+
"""test XvfbDisplay() XVFB_RESOLUTION"""
52+
xvfb=mocker.patch("ffpuppet.display.Xvfb",autospec=True)
53+
mocker.patch.dict(
54+
"ffpuppet.display.environ",
55+
{}ifresolutionisNoneelse {"XVFB_RESOLUTION":resolution},
56+
)
57+
XvfbDisplay()
58+
xvfb.assert_called_with(width=expected_width,height=expected_height)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp