summaryrefslogtreecommitdiff
path: root/test/font_size.py
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-11 12:38:56 -0300
committerGabriel Schneider <[email protected]>2026-09-15 17:24:42 -0300
commit682e237df7e8b22f820d14a4adee58e6e2f84268 (patch)
tree5d888cb46f1a49e89fc55e2a4c232d3af0265b1d /test/font_size.py
parent6878e1c309172d624c0d7a3555f6f0217ae6770e (diff)
downloadpardes-682e237df7e8b22f820d14a4adee58e6e2f84268.tar.gz
pardes-682e237df7e8b22f820d14a4adee58e6e2f84268.zip
trunk: resume before the Reload experiment
Empty marker on the last pre-Reload change. Keep the Reload experiment on reload (3801914), its first change on reload-start (200a1fc), and the unfinished performance investigation on reload-perf-wip.
Diffstat (limited to 'test/font_size.py')
-rw-r--r--test/font_size.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/font_size.py b/test/font_size.py
new file mode 100644
index 00000000..e40b7b3a
--- /dev/null
+++ b/test/font_size.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+"""Check startup/runtime SDL Font name:size requests through an isolated 9P session."""
+import argparse
+from pathlib import Path
+
+from fs import execute, new_pane, session
+from ui_review import capture, panes, require, wait_for
+
+
+def run(args):
+ root = args.output.resolve()
+ root.mkdir(parents=True, mode=0o700, exist_ok=True)
+ root.chmod(0o700)
+ config = root / 'config/pardes'
+ config.mkdir(parents=True, exist_ok=True)
+ (config / 'init').write_text(f'Shell /bin/sh\nTheme orchard\nFont {args.font}:18\nTaglineSize 80\n')
+ name = 'font-size'
+ launch = ['-c', 'stty cols 150 rows 48; exec "$@"', name,
+ str(args.binary.resolve()), '--9p=' + name]
+ inherited = {'PARDES_TEST': '1', 'PARDES_TEST_CAPTURE_DIR': str(root),
+ 'PARDES_TEST_COLS': '150', 'PARDES_TEST_ROWS': '48',
+ 'SDL_VIDEODRIVER': 'x11'}
+ with session('/bin/sh', root, name, socket_name=name, tty=True,
+ launch=launch, inherited=inherited) as (client, _):
+ control = new_pane(client, b'')
+
+ def report(size):
+ execute(client, control, 'Config')
+ def ready():
+ for serial, tag in panes(client).items():
+ if '/+Config ' in tag:
+ body = client.read(f'/self/pane/{serial}/body').decode()
+ if f'Font effective size: {size:.2f} pixels' in body:
+ return body
+ return None
+ return require(wait_for(ready), f'Font did not become {size} pixels')
+
+ initial = report(18)
+ require('Font requested size: 18.00' in initial, 'startup size suffix ignored')
+ require(args.font in initial, 'requested font missing')
+ execute(client, control, f'Font {args.font}:20.5')
+ require('Font requested size: 20.50' in report(20.5), 'fractional size ignored')
+ execute(client, control, f'Font {args.font}')
+ report(20.5) # no suffix preserves current size
+ execute(client, control, f'Font {args.font}:900')
+ report(20.5) # invalid request cannot partially change the font
+ execute(client, control, 'Font DefinitelyMissingPardesFont:12')
+ report(20.5)
+ execute(client, control, f'Font {args.font}:18')
+ final = report(18)
+ (root / 'font-report.txt').write_text(final)
+ capture(client, root, 'font-size-18', True)
+ print('Font startup, fractional size, omitted size and invalid requests passed')
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('binary', type=Path)
+ parser.add_argument('output', type=Path)
+ parser.add_argument('--font', default='MartianMono-NrRg')
+ run(parser.parse_args())