diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/panes.zig | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig index 15eca652..d16de109 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -3917,6 +3917,75 @@ const PdfAddon = struct { try std.testing.expect(r.stats.stopped >= 1); } + test "the tag a step lays out for a PDF's pane is of the frame its tick left, not the frame before it" { + 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(); + const Land = struct { + a: *R.Authority, + fn step(l: @This(), ev: pardes.Event) !void { + _ = try l.a.local(ev); + } + }; + const land: Land = .{ .a = a }; + const id = try opened(a, land); + const slot = a.core.panes[id].?.addon.?; + // A view without graphics: the page's text layer, no picture. + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") == null); + // A window's: its tick lays the pages out as pictures and asks + // for them; the step their answers land in ticks it again, and its + // tag says what that tick placed, as the next step's will (a + // replica's guess of its next input is the tag this step laid out). + try land.step(.{ .frontend = .{ .windowed = true, .native_images = true } }); + try jobs(a.core, land); + try std.testing.expect(slot.placed); + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") != null); + } + + test "a PDF's pane in a window's view and a terminal's in turn: each one's step lays its tag out as its frame shows it" { + 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(); + // A terminal's client on the session's view, a window's on its own. + const tty = try R.Replica.init(gpa, 1, try a.unit(0, 0), false); + defer tty.deinit(); + const Land = struct { + a: *R.Authority, + fn step(l: @This(), ev: pardes.Event) !void { + _ = try l.a.local(ev); + } + }; + const land: Land = .{ .a = a }; + const id = try opened(a, land); + const slot = a.core.panes[id].?.addon.?; + const k = (try a.openView(2)).view; + const was = pardes.tape.on; + pardes.tape.on = &a.t; + const bytes = try pardes.dump.byteDump(a.core); + pardes.tape.resync(&a.t); + pardes.tape.on = was; + defer a.core.gpa.free(bytes); + const win = try R.Replica.initDump(gpa, 2, k, bytes, .{ .cols = 80, .rows = 24 }); + defer win.deinit(); + _ = try a.take(try win.input(.{ .frontend = .{ .windowed = true, .native_images = true } })); + try jobs(a.core, land); + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") != null); + for (0..2) |_| { + // The terminal's key: its view's tick, the page's text layer. + _ = try a.take(try tty.input(.{ .key = .{ .cp = 'j', .text = "j" } })); + try jobs(a.core, land); + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") == null); + // The window's: the pages as pictures again, in its tag at once. + _ = try a.take(try win.input(.{ .key = .{ .cp = 'j', .text = "j" } })); + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") != null); + try jobs(a.core, land); + } + } + test "a PDF pane whose file changes on disk opens again from it at its page, its fit kept" { if (!addons.has_pdf) return error.SkipZigTest; const gpa = std.testing.allocator; |
