summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/appearance_gallery.py31
-rw-r--r--test/behaviour/settings.zig25
2 files changed, 54 insertions, 2 deletions
diff --git a/test/appearance_gallery.py b/test/appearance_gallery.py
index 0d3ab1fa..636c0f69 100644
--- a/test/appearance_gallery.py
+++ b/test/appearance_gallery.py
@@ -1,10 +1,12 @@
#!/usr/bin/env python3
-"""Review native palettes, compact tags and sized fonts in an owned SDL session."""
+"""Review native palettes, compact tags, sized fonts and pets in an owned SDL session."""
import argparse
+import hashlib
import json
import os
from pathlib import Path
import subprocess
+import time
from fs import session
from ui_review import capture, command, panes, require, wait_for
@@ -27,6 +29,9 @@ Native palettes
spectrum vivid syntax
harvest warm earth
clay soft rose and pine
+
+Pet cat / Pet frog / Pet off
+Companions stay in unused workspace-tag space.
'''
PREFERENCE_NOTES = b'''Pardes / contrast studies
@@ -68,7 +73,7 @@ def run(args):
if args.live_window:
inherited = {'SDL_VIDEODRIVER': 'x11'}
handles = {}
- report = {'themes': [], 'os_windows': []}
+ report = {'themes': [], 'pets': [], 'os_windows': []}
with session('/bin/sh', root, name, socket_name=name, tty=True,
launch=launch, inherited=inherited, terminal=handles) as (client, _):
source = next(serial for serial, tag in panes(client).items() if str(source_path) in tag)
@@ -168,6 +173,27 @@ def run(args):
report['native_themes_first'] = True
client.write(f'/pane/{selector}/exec', b'Del\n')
command(client, terminal, 'Collapse')
+ for pet in (() if args.skip_pets else ('cat', 'frog', 'off')):
+ command(client, right, 'Pet ' + pet)
+ settings = config_report()
+ require('\nPet ' + pet + '\n' in settings, 'pet setting not applied')
+ # Returning focus to the source closes all transient report state.
+ client.write(f'/pane/{source}/look', f'{source_path}:1\n'.encode())
+ take_frame('pet-' + pet)
+ if pet != 'off':
+ frame = client.screen()
+ original_tag = frame['cells'][:frame['cols']]
+ time.sleep(1)
+ take_frame('pet-' + pet + '-later')
+ frame = client.screen()
+ require(original_tag == frame['cells'][:frame['cols']], 'pet animation changed tag text or styles')
+ def band_digest(label):
+ pixels = subprocess.check_output(['magick', str(root / (label + '.png')),
+ '-crop', '1500x20+0+0', '-depth', '8', 'RGB:-'])
+ return hashlib.sha256(pixels).hexdigest()
+ require(band_digest('pet-' + pet) != band_digest('pet-' + pet + '-later'),
+ 'pet did not animate in workspace tag')
+ report['pets'].append(pet)
require(client.read(f'/pane/{source}/body') == original == source_path.read_bytes(), 'Agave source changed')
report['source_unchanged'] = True
client.write(f'/pane/{terminal}/pty/data', b'exit\r')
@@ -182,5 +208,6 @@ if __name__ == '__main__':
parser.add_argument('--project', required=True, type=Path)
parser.add_argument('--live-window', action='store_true', help='capture the owned OS window without offscreen test mode')
parser.add_argument('--themes', nargs='+', default=THEMES, help='themes to compare in order')
+ parser.add_argument('--skip-pets', action='store_true', help='review palettes without repeating pet animation tests')
parser.add_argument('--theme-selector', action='store_true', help='capture native-first picker and focused source gutter')
run(parser.parse_args())
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig
index 3a9d42df..d87e8191 100644
--- a/test/behaviour/settings.zig
+++ b/test/behaviour/settings.zig
@@ -43,6 +43,31 @@ test "settings: Shell refuses a path that is no executable, and bare it goes bac
try std.testing.expectEqualStrings(default, try setting(&s, "Shell"));
}
+test "settings: Pet is the window's: a terminal's view refuses it; a window takes only its pets, and /ctl reads it back" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ // Which build, from its options, not from the answer: a terminal's view
+ // taking Pet must fail here, not pass as a window.
+ if (comptime @import("pardes_config").platform == .gui) {
+ try std.testing.expectEqualStrings("Pet off", try setting(&s, "Pet"));
+ try s.write("/ctl", "Pet cat\n");
+ try std.testing.expectEqualStrings("Pet cat", try setting(&s, "Pet"));
+ // A window's: dog is no pet of its.
+ _ = try s.refused("/ctl", "Pet dog\n");
+ try std.testing.expectEqualStrings("Pet cat", try setting(&s, "Pet"));
+ try s.write("/ctl", "Pet frog\n");
+ try std.testing.expectEqualStrings("Pet frog", try setting(&s, "Pet"));
+ try s.write("/ctl", "Pet off\n");
+ try std.testing.expectEqualStrings("Pet off", try setting(&s, "Pet"));
+ return;
+ }
+ _ = try s.refused("/ctl", "Pet cat\n");
+ try std.testing.expectEqualStrings("Pet is GUI-only, invalid here \"Pet\"", s.said);
+ try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/exec", .{try s.focused()}), "Pet cat\n"));
+ try std.testing.expectEqualStrings("Pet is GUI-only, invalid here", s.said);
+ try std.testing.expect(has(try s.read("/ctl"), "\n# Pet unsupported\n"));
+}
+
fn expectHas(text: []const u8, part: []const u8) !void {
if (std.mem.indexOf(u8, text, part) == null) {
std.debug.print("not in it: {s}\n", .{part});