Skip to content
Snippets Groups Projects

dialog-ui: Try to load fonts provided by Steam

Merged Simon McVittie requested to merge wip/task462 into main
1 file
+ 61
0
Compare changes
  • Side-by-side
  • Inline
+ 72
6
@@ -4,8 +4,11 @@
import logging
import os
import os.path
import shutil
import subprocess
import sys
import tempfile
import time
from pathlib import Path
@@ -38,6 +41,8 @@ class TestDialogUi(BaseTest):
),
]
self.home = Path(os.path.expanduser('~'))
def test_error(self) -> None:
proc = subprocess.Popen(
self.dialog_ui + [
@@ -135,16 +140,77 @@ class TestDialogUi(BaseTest):
stdin = proc.stdin
assert stdin is not None
with stdin:
time.sleep(5)
stdin.write(b'pulsate:false\n')
stdin.write(b'100\n')
stdin.write(b'#Press any key or mouse or gamepad button to exit\n')
stdin.flush()
try:
with stdin:
time.sleep(5)
stdin.write(b'pulsate:false\n')
stdin.write(b'100\n')
stdin.write(
b'#Press any key or mouse or gamepad button to exit\n'
)
stdin.flush()
except BrokenPipeError:
pass
proc.wait()
self.assertEqual(proc.returncode, 0)
def test_steam_fonts(self) -> None:
fonts_rel = '.steam/steam/clientui/fonts'
regular_base = 'GoNotoKurrent-Regular.ttf'
bold_base = 'GoNotoKurrent-Bold.ttf'
regular_src = self.home / fonts_rel / regular_base
bold_src = self.home / fonts_rel / bold_base
if not regular_src.exists():
self.skipTest(
'Please copy ~/%s/%s from a Steam installation' % (
fonts_rel, regular_base,
)
)
if not bold_src.exists():
self.skipTest(
'Please copy ~/%s/%s from a Steam installation' % (
fonts_rel, bold_base,
)
)
with tempfile.TemporaryDirectory() as temp_str:
temp = Path(temp_str)
fonts_dir = temp / fonts_rel
fonts_dir.mkdir(parents=True)
regular = fonts_dir / regular_base
bold = fonts_dir / bold_base
shutil.copy(regular_src, regular)
shutil.copy(bold_src, bold)
for test_case in [
"Using Steam's fonts",
"Using Steam's regular font only",
'Using system sans-serif font',
]:
if test_case == "Using Steam's regular font only":
bold.unlink()
if test_case == 'Using system sans-serif font':
regular.unlink()
proc = subprocess.Popen(
[
'env',
'HOME=' + temp_str,
] + self.dialog_ui + [
'--info',
"--text=%s [\u0d9e]" % test_case,
"--title=%s [\u0d9e]" % test_case,
],
stdout=STDERR_FILENO,
stderr=STDERR_FILENO,
)
proc.wait()
self.assertEqual(proc.returncode, 0)
def tearDown(self) -> None:
super().tearDown()
Loading