diff options
Diffstat (limited to 'test/pdf.zig')
| -rw-r--r-- | test/pdf.zig | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/pdf.zig b/test/pdf.zig index 7a05447e..beeb0b40 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -2055,3 +2055,30 @@ test "Esc back into a PDF keeps the offset within its page" { // snap, so a test that watched the offset alone would not see it coming. try std.testing.expect(!pv.scroll_to_page_pending); } + +test "PDF Back and Forward clear selections and land on recorded pages" { + if (!pdf_enabled or platform == .web) return error.SkipZigTest; + const p = try Pardes.init(std.testing.allocator, .{ .file = "docs/design.pdf", .cols = 80, .rows = 28 }); + defer p.deinit(); + p.native_images = true; + p.presentation.enabled = false; + const pane = p.panes[0].?; + const state = &pane.pdf.?; + try std.testing.expect(state.page_count > 1); + try std.testing.expect(state.focusLocation(p.pdf_gpa, 2, 0)); + p.njumps = 2; + p.jcur = 1; + p.jumps[0] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 0 }; + p.jumps[1] = .{ .pane = 0, .serial = pane.serial, .line = 2, .col = 0 }; + for ([_]u21{ 'o', 'i' }, 0..) |key, destination| { + try std.testing.expectEqual(panes.Pdf.SelectionUpdate.changed, state.setSelection(p.pdf_gpa, .{ .x = 0, .y = 0 }, .{ .x = 1, .y = 1 }, true)); + try std.testing.expect(state.selection != null and state.selection_text.len > 0); + p.update(.{ .key = .{ .cp = key, .ctrl = true } }); + try std.testing.expectEqual(destination, p.jcur); + try std.testing.expectEqual(destination, state.page); + try std.testing.expect(state.selection == null); + try std.testing.expect(state.selection_page == null); + try std.testing.expectEqual(@as(usize, 0), state.selection_text.len); + try std.testing.expect(state.drag_anchor == null and state.drag_head == null); + } +} |
