import pytest
from piker.ui._style import DpiAwareFont


class MockScreen:
    def __init__(self, pdpi, ldpi, name="MockScreen"):
        self._pdpi = pdpi
        self._ldpi = ldpi
        self._name = name

    def physicalDotsPerInch(self):
        return self._pdpi

    def logicalDotsPerInch(self):
        return self._ldpi

    def name(self):
        return self._name


@pytest.mark.parametrize(
    "pdpi, ldpi, expected_px",
    [
        (96, 96, 9),       # normal DPI
        (169, 96, 15),     # HiDPI
        (120, 96, 10),     # mid-DPI
    ]
)
def test_font_px_size(pdpi, ldpi, expected_px):
    font = DpiAwareFont()
    font.configure_to_dpi(screen=MockScreen(pdpi, ldpi))

    px = font.px_size
    print(f"{pdpi}x{ldpi} DPI -> Computed pixel size: {px}")

    assert px == expected_px
