fixed pytest test for dpi font auto calculation
parent
7ff4f5d059
commit
0563c91b33
|
|
@ -8,27 +8,27 @@ class MockScreen:
|
||||||
self._name = name
|
self._name = name
|
||||||
|
|
||||||
def physicalDotsPerInch(self):
|
def physicalDotsPerInch(self):
|
||||||
return self._pdpi
|
return self._pdpi
|
||||||
|
|
||||||
def logicalDotsPerInch(self):
|
def logicalDotsPerInch(self):
|
||||||
return self._ldpi
|
return self._ldpi
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"pdpi, ldpi",
|
"pdpi, ldpi, expected_px",
|
||||||
[
|
[
|
||||||
(96, 96), # normal DPI
|
(96, 96, 9), # normal DPI
|
||||||
(169, 96), # HiDPI
|
(169, 96, 15), # HiDPI
|
||||||
(120, 96), # mid-DPI
|
(120, 96, 10), # mid-DPI
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_font_px_size(pdpi, ldpi):
|
def test_font_px_size(pdpi, ldpi, expected_px):
|
||||||
font = DpiAwareFont()
|
font = DpiAwareFont()
|
||||||
font.configure_to_dpi(screen=MockScreen(pdpi, ldpi))
|
font.configure_to_dpi(screen=MockScreen(pdpi, ldpi))
|
||||||
|
|
||||||
px = font.px_size
|
px = font.px_size
|
||||||
print(f"{pdpi}x{ldpi} DPI -> Computed pixel size: {px}")
|
print(f"{pdpi}x{ldpi} DPI -> Computed pixel size: {px}")
|
||||||
|
|
||||||
assert 12 <= px <= 24
|
assert px == expected_px
|
||||||
Loading…
Reference in New Issue