summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 07:22:41 -0300
committerGabriel Schneider <[email protected]>2026-11-18 09:44:10 -0300
commitb2f709d7130571658220636f33b5f89414a5101a (patch)
treed90c39668caec2fb08bc4bfc9e0ef8c18c9cbe02 /test
parentf0e6eb0de0b5ac9f81ba2c728f3040c4a51ab284 (diff)
downloadpardes-b2f709d7130571658220636f33b5f89414a5101a.tar.gz
pardes-b2f709d7130571658220636f33b5f89414a5101a.zip
pdf: the PDF kind runs where its pane is shown (PA_PLAIN): its state is one plain block of 840 bytes with no padding (the place, each view's layout, fit, tint, the state jobs out, the search, the selection made, the press, the pointer's word, the glide and the fling, the count), changed only by its calls from the block and taped values; the document, the pages' sizes, what the state jobs answered, the strips and the pictures are each process's own, found by the block's address and made again where a client joined late lacks them; its pages are draws asked as each view is painted, never jobs on the tape; its keys, mouse and ticks read no picture (a pan, a click and a revealed hit take MuPDF's measure of the raster); the glide and the fling run on the ticks' clock, never on frames painted (.scratch/sketch/reorg/pardes-addons-3/design-glide.md); with no workers a draw done at once is painted the same frame; a client's joined pane keeps the session's place; a window client wheeling the PDF to page 2 reads 80.4 MB -> 0.18 MB and waits a round trip on 0 of 36 inputs (34 before), its join reads 7.4 -> 26.8 MB (it now maps pdf.so); tui core-test 820/959 (139 skipped), shell-test 994/997, behaviour-test 274/274 and --replay 0 failures, pane-test 180/181 (the PDF Shadow test is now the line's), addon-test 1/1 (pdf.out unchanged), replicas pass, process-test 2 of 144 failed (lspcomplete, lspcompletemoved: the base's), image-harness passes, test/daemon.py plain, --far, --games, --window-clients pass; gui unit-test 1588/1592 (its perf check's BaselineBuildMismatch, known); the frame corpus 74/77 Debug and ReleaseFast: frames 58-60 differ, InactiveDim's announcement now replaced by WindowOpacity's instead of stacked, because a PDF render's answer is no longer a core event between the two 9P writes (the PDF's own frames are identical); corpus2x -0.247%; pdf-scroll-bench 18,394M -> 19,214M instructions (its clock never advances, so its slow scroll counts as a fling)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/behaviour/addons_pdf.zig3
-rw-r--r--test/panes.zig48
-rw-r--r--test/session.zig15
3 files changed, 24 insertions, 42 deletions
diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig
index af194a5b..cf5c8009 100644
--- a/test/behaviour/addons_pdf.zig
+++ b/test/behaviour/addons_pdf.zig
@@ -273,8 +273,9 @@ test "addons: a PDF whose file changes on disk while a page of it renders: the p
try std.testing.expect((try shown(&s, n)).len >= 1);
// A page drawn again (another tint), its render done on a worker but
// not yet answered as the file changes and the pane opens it again.
- s.hold_jobs = true;
+ s.holdJobs();
try s.write(s.at("/pane/{d}/ctl", .{n}), "PdfTint full\n");
+ _ = try shown(&s, n);
s.runJobs();
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "doc.pdf", .data = outline });
try std.testing.expect(try s.filesChanged());
diff --git a/test/panes.zig b/test/panes.zig
index d47136a5..fb8adc36 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -3783,15 +3783,12 @@ const PdfAddon = struct {
}.f,
};
- test "a client without the pdf addon shows a PDF pane as the session's frames of it, its pages by key, and its wheel goes to the session" {
+ test "a client without the pdf addon shows its PDF pane as a line, its page in its tag, and its wheel goes to the session" {
if (!addons.has_pdf) return error.SkipZigTest;
const R = pardes.replica;
const gpa = std.testing.allocator;
const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false);
defer a.deinit();
- var screens: R.Screens = .init(gpa);
- defer screens.deinit(a.core);
- const peer = try screens.addPeer();
const r = try R.Replica.init(gpa, 1, try a.unit(0, 0), false);
defer r.deinit();
const Land = struct {
@@ -3802,61 +3799,30 @@ const PdfAddon = struct {
}
};
const land: Land = .{ .a = a, .r = r };
- var words: [64]pardes.Kind.LoadedWord = undefined;
- var why: pardes.Kind.Buf(160) = .{};
- const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why);
- try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } });
// A frontend with pictures (a terminal without them is shown the
// page's text layer).
try land.step(.{ .frontend = .{ .windowed = false, .native_images = true } });
+ const id = try opened(a, land);
try std.testing.expect(r.core().kinds.ops[r.core().kinds.n - 1] == null);
- var buf: [4096]u8 = undefined;
- const real = try std.Io.Dir.cwd().realPathFile(std.testing.io, "docs/design.pdf", &buf);
- var line: [4200]u8 = undefined;
- try land.step(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{buf[0..real]}) });
- for (0..3) |_| {
- try land.step(.tick);
- try jobs(a.core, land);
- }
- // Its frame crosses: the replica draws the pane as the session
- // painted it, its pages placed by key, its page in its tag.
var arena: std.heap.ArenaAllocator = .init(gpa);
defer arena.deinit();
- const deliver = struct {
- fn f(au: *R.Authority, sc: *R.Screens, pe: u16, re: *R.Replica) !void {
- var msgs: std.ArrayListUnmanaged([]u8) = .empty;
- defer {
- for (msgs.items) |m| std.testing.allocator.free(m);
- msgs.deinit(std.testing.allocator);
- }
- try sc.flush(au.core, pe, re.view, &msgs);
- for (msgs.items) |m| if (re.screen(m)) |reply| {
- _ = try sc.take(au.core, pe, reply);
- };
- }
- }.f;
_ = try a.core.render(arena.allocator());
- // (A kind's prefix is its last frame's, and the tag a step's: a
- // Shadow's is the authority's last step's.)
try land.step(.tick);
- try deliver(a, &screens, peer, r);
- const id = for (r.core().panes, 0..) |slot, i| {
- if (slot) |pane| if (pane.addon != null) break i;
- } else return error.NoPdfPane;
+ // No picture crosses: the client shows the line saying the addon
+ // does not run here, and the session's page in its tag.
const shown = try r.core().render(arena.allocator());
var placed: usize = 0;
for (shown.placements.items) |pl| placed += @intFromBool(pl.pane == id);
- try std.testing.expect(placed >= 1);
+ try std.testing.expectEqual(@as(usize, 0), placed);
try std.testing.expect(std.mem.startsWith(u8, try pardes.tagline.tagPrefix(r.core(), r.core().panes[id].?), "[1/16]"));
- // A wheel at the replica: the session's kind takes it, and the
- // replica shows where the session's strip went.
+ // A wheel at the replica: the session's kind takes it.
const before = a.core.panes[id].?.addon.?.thumb_at;
const rect = r.core().view().rects[id];
for (0..20) |_| r.confirm(try a.take(try r.input(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = rect.x + rect.w / 2, .row = rect.y + rect.h / 2 } })));
+ for (0..4) |_| try land.step(.tick);
try jobs(a.core, land);
_ = try a.core.render(arena.allocator());
try std.testing.expect(a.core.panes[id].?.addon.?.thumb_at > before);
- try deliver(a, &screens, peer, r);
r.settle();
try std.testing.expect(r.diverged == null);
}
diff --git a/test/session.zig b/test/session.zig
index 06cd3a32..cd04ecb8 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -107,6 +107,7 @@ pub const Session = struct {
pub fn deinit(s: *Session) void {
s.held.deinit(pardesOf(s).gpa);
+ if (s.hold_jobs) pardes.Kind.drawer = null;
if (s.watch_fd >= 0) {
pardes.file_watch.unwatchAll(s.watch_fd, &s.watches);
_ = std.c.close(s.watch_fd);
@@ -310,6 +311,19 @@ pub const Session = struct {
return true;
}
+ /// Kinds' jobs and draws held from now on (`hold_jobs`), until
+ /// `releaseJobs`.
+ pub fn holdJobs(s: *Session) void {
+ s.hold_jobs = true;
+ pardes.Kind.drawer = .{ .ctx = s, .go = struct {
+ fn go(ctx: ?*anyopaque, j: *pardes.host_io.KindJob) bool {
+ const ss: *Session = @ptrCast(@alignCast(ctx));
+ ss.held.append(pardesOf(ss).gpa, j) catch return false;
+ return true;
+ }
+ }.go };
+ }
+
/// The jobs held run now, as a worker runs them, their answers held
/// still: what a test does next happens while they are under way.
pub fn runJobs(s: *Session) void {
@@ -320,6 +334,7 @@ pub const Session = struct {
/// The jobs held, run now and answered as the host's workers would.
pub fn releaseJobs(s: *Session) void {
s.hold_jobs = false;
+ pardes.Kind.drawer = null;
for (s.held.items, 0..) |j, i| {
if (i >= s.ran) j.run();
j.land(pardesOf(s));