Skip to content

Commit

Permalink
Add a test for the system monospace font
Browse files Browse the repository at this point in the history
See #5663
  • Loading branch information
The-Compiler committed Nov 24, 2020
1 parent ffa1563 commit 6e64a91
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qutebrowser/config/configutils.py
Expand Up @@ -282,6 +282,9 @@ def __init__(self, families: Sequence[str]) -> None:
def __iter__(self) -> Iterator[str]:
yield from self._families

def __len__(self) -> int:
return len(self._families)

def __repr__(self) -> str:
return utils.get_repr(self, families=self._families, constructor=True)

Expand Down
24 changes: 24 additions & 0 deletions tests/unit/config/test_configutils.py
Expand Up @@ -21,6 +21,7 @@
from hypothesis import strategies
import pytest
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QLabel

from qutebrowser.config import configutils, configdata, configtypes, configexc
from qutebrowser.utils import urlmatch, usertypes, qtutils
Expand Down Expand Up @@ -364,3 +365,26 @@ def test_from_str_hypothesis(self, family_str):
assert family

str(families)

def test_system_default_basics(self, qapp):
families = configutils.FontFamilies.from_system_default()
assert len(families) == 1
assert str(families)

def test_system_default_rendering(self, qtbot):
families = configutils.FontFamilies.from_system_default()

label = QLabel()
qtbot.add_widget(label)
label.setText("Hello World")

stylesheet = f'font-family: {families.to_str(quote=True)}'
print(stylesheet)
label.setStyleSheet(stylesheet)

with qtbot.waitExposed(label):
# Needed so the font gets calculated
label.show()

info = label.fontInfo()
assert info.fixedPitch(), info.family()

0 comments on commit 6e64a91

Please sign in to comment.