diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 08:26:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 08:53:11 -0300 |
| commit | b7eb31674e01c992cafc91518e161258b921bd33 (patch) | |
| tree | a55a358f2753b470ffdad261c8dd375aea6a069b /test/pdf.zig | |
| parent | f3070c04d3eaa0e0d3965478781c2d0b456446bf (diff) | |
| download | pardes-b7eb31674e01c992cafc91518e161258b921bd33.tar.gz pardes-b7eb31674e01c992cafc91518e161258b921bd33.zip | |
A pane's ctl read says Collapse and a PDF's PdfFit and PdfTint (`collapsed`, `fit:height tint:full`), and a Dump keeps the PDF's two
Neither showed in the tag or the ctl, and a Restore brought a PDF back
at width fit and the default tint. The ctl read ends with `collapsed`
when it is, and a PDF's `fit:` and `tint:` in the words PdfFit and
PdfTint take; the dump's image record carries pdf_fit and pdf_tint
(empty in older dumps: the defaults).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/pdf.zig')
| -rw-r--r-- | test/pdf.zig | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/test/pdf.zig b/test/pdf.zig index 00d678d4..a0eb8154 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -1081,9 +1081,8 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { panes.Pdf.setPage(p, pane, next_page); try std.testing.expectEqualStrings(long_query, pane.pdf.?.search_query); - // PDF dumps intentionally retain the existing image-compatible schema: - // page/path and the exact editable tail are restored, while pane-local - // tint starts from the fresh-PDF default rather than being serialized. + // PDF dumps keep the image-compatible schema: page/path, the exact + // editable tail, and the pane's fit and tint (pdf_fit, pdf_tint). panes.Pdf.toggleTint(pane); try std.testing.expectEqual(PdfTintMode.full, pane.pdf.?.tint); pane.pdf.?.fit = .height; @@ -1095,8 +1094,8 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { defer restored.deinit(); try std.testing.expect(hasPdf(restored.panes[0].?)); try std.testing.expectEqual(pane.pdf.?.page, restored.panes[0].?.pdf.?.page); - try std.testing.expectEqual(PdfFitMode.width, restored.panes[0].?.pdf.?.fit); - try std.testing.expectEqual(PdfTintMode.filtered, restored.panes[0].?.pdf.?.tint); + try std.testing.expectEqual(PdfFitMode.height, restored.panes[0].?.pdf.?.fit); + try std.testing.expectEqual(PdfTintMode.full, restored.panes[0].?.pdf.?.tint); const restored_pane = restored.panes[0].?; try std.testing.expect(restored_pane.tag.own != null); try std.testing.expectEqualStrings( @@ -2416,3 +2415,30 @@ test "PDF Back and Forward clear selections and land on recorded pages" { try std.testing.expect(state.drag_anchor == null and state.drag_head == null); } } + +test "a PDF's fit and tint, and Collapse, read in its ctl and come back from a Dump" { + if (!pdf_enabled or platform == .web) return; + const gpa = std.testing.allocator; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const fixture = try pdf_impl.makeOutlineTestPdf(gpa); + defer gpa.free(fixture); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "outline.pdf", .data = fixture }); + var path_buf: [256]u8 = undefined; + const path = try std.fmt.bufPrint(&path_buf, ".zig-cache/tmp/{s}/outline.pdf", .{tmp.sub_path}); + const p = try Pardes.init(gpa, .{ .file = path, .cols = 80, .rows = 28 }); + defer p.deinit(); + const doc = p.panes[0].?; + try std.testing.expect(p.executeBuiltinLine(0, "PdfFit height")); + try std.testing.expect(p.executeBuiltinLine(0, "PdfTint full")); + const ctlfs = pardes.ctlfs; + const ctl_node = ctlfs.Node.of(doc.serial, .ctl); + const read = p.fsPayload(p.serveFs(.{ .tag = 1, .op = .read, .node = ctl_node, .size = 4096 })); + try std.testing.expect(std.mem.endsWith(u8, read, "fit:height tint:full ")); + try pardes.dump.dumpState(p); + const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); + defer restored.deinit(); + const pv = &restored.panes[0].?.pdf.?; + try std.testing.expectEqualStrings("height", @tagName(pv.fit)); + try std.testing.expectEqualStrings("full", @tagName(pv.tint)); +} |
