summaryrefslogtreecommitdiff
path: root/test/pdf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-31 06:28:48 -0300
committerGabriel Schneider <[email protected]>2026-10-31 06:28:48 -0300
commita479792a1ab2b593642d7f648194bfa23ce01dba (patch)
tree96ddee7d879a9084daa07db43b0b7910b072a785 /test/pdf.zig
parente179cc44fe5060c76a5b00c41e53f11209f5acd9 (diff)
parent4c761893e5b3fdae422622cfa02104ab36633045 (diff)
downloadpardes-a479792a1ab2b593642d7f648194bfa23ce01dba.tar.gz
pardes-a479792a1ab2b593642d7f648194bfa23ce01dba.zip
Merge the upstream daemon and replicated client/server refactor
Diffstat (limited to 'test/pdf.zig')
-rw-r--r--test/pdf.zig68
1 files changed, 23 insertions, 45 deletions
diff --git a/test/pdf.zig b/test/pdf.zig
index 3f84195c..3bb751e2 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -278,45 +278,6 @@ test "PDF feature gates keep argv and builtin behavior coherent" {
}
}
-test "PDF dump fallback remains a byte-preserving file" {
- const gpa = std.testing.allocator;
- const path = "/definitely/missing/pardes-dump-fallback.PDF";
- const source = "%PDF embedded fallback bytes\x00\xff";
- const encoded = try dump.encodeBytes(gpa, source);
- defer gpa.free(encoded);
- const ids = [_]usize{0};
- const columns = [_]dump.Column{.{ .panes = &ids }};
- const saved_panes = [_]dump.Pane{.{
- .kind = .image,
- .tag = "pdf 3/9 height PdfFit full PdfTint PdfSections " ++ path ++ " Keep Del",
- .tag_tail = " Keep Del",
- .body = "",
- .scroll = 2,
- .cols = 80,
- .rows = 24,
- .image = .{ .path = path, .bytes_b64 = encoded },
- }};
- const state = dump.State{
- .screen = .{ .cols = 80, .rows = 24 },
- .columns = &columns,
- .panes = &saved_panes,
- };
- var out: std.Io.Writer.Allocating = .init(gpa);
- defer out.deinit();
- try std.zon.stringify.serialize(state, .{ .whitespace = true }, &out.writer);
-
- const restored = try pardes.dump.initFromDump(gpa, .{ .tty_only = true }, out.written());
- defer restored.deinit();
- const pane = restored.panes[0].?;
- try std.testing.expect(pane.file != null);
- try std.testing.expect(pane.image == null);
- try std.testing.expect(!hasPdf(pane));
- try std.testing.expectEqualStrings(path, pane.file.?.path);
- try std.testing.expectEqualSlices(u8, source, pane.file.?.content);
- try std.testing.expect(pane.tag.own != null);
- try std.testing.expectEqualStrings(" Keep Del", pane.tag.own.?);
-}
-
test "a +PdfSections row's first number is the page: a section not there, or on another page, is a miss said" {
if (!pdf_enabled or platform == .web) return;
const gpa = std.testing.allocator;
@@ -1454,7 +1415,7 @@ test "PDF normal adapter consumes unsupported actions and navigates page fallbac
try std.testing.expect(pane.prompt == .none);
}
-test "Escape cancels PDF chrome in place and Shift-Escape leaves the pane" {
+test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape leaves at once" {
if (!pdf_enabled or platform == .web) return;
const gpa = std.testing.allocator;
@@ -1507,15 +1468,32 @@ test "Escape cancels PDF chrome in place and Shift-Escape leaves the pane" {
try std.testing.expectEqual(scroll_before, pv.document_scroll_y);
try std.testing.expectEqual(@as(u32, 0), pane.body.normal.count);
try std.testing.expectEqual(.none, pane.body.normal.prefix);
- // A second Escape on a bare document is inert rather than an exit.
+ // With nothing left to drop, Escape goes back a pane as anywhere else,
+ // and leaves the document as it found it.
p.update(.{ .key = .{ .cp = Key.escape } });
- try std.testing.expectEqual(@as(usize, 0), p.active);
-
- // Shift-Escape is the way out, and it leaves the document as it found it.
- p.update(.{ .key = .{ .cp = Key.escape, .shift = true } });
try std.testing.expectEqual(@as(usize, 1), p.active);
try std.testing.expectEqual(page_before, pv.page);
try std.testing.expectEqual(scroll_before, pv.document_scroll_y);
+
+ // Shift-Escape goes at once, over a selection too.
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(
+ panes.Pdf.SelectionUpdate.changed,
+ pv.setSelection(p.pdf_gpa, quad.ul, quad.lr, false),
+ );
+ p.update(.{ .key = .{ .cp = Key.escape, .shift = true } });
+ try std.testing.expectEqual(@as(usize, 1), p.active);
+ try std.testing.expect(pv.selection != null);
+
+ // A text-only page shows neither: one Escape drops them and goes.
+ p.native_images = false;
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(@as(usize, 0), p.active);
+ try pv.setSearchQuery(p.pdf_gpa, "Pardes");
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(@as(usize, 1), p.active);
+ try std.testing.expect(pv.selection == null and pv.search_query.len == 0);
}
test "PDF continuous strip renders every intersecting short page" {