summaryrefslogtreecommitdiff
path: root/test/behaviour/keys.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 11:38:06 -0300
committerGabriel Schneider <[email protected]>2026-11-06 12:03:00 -0300
commitf922f8b5db1f3b92d954c43860c32cd251d5bc55 (patch)
tree25f1dacb589db526060c2e4dd11b8cbcf5121123 /test/behaviour/keys.zig
parent0b4142e6704c851f395da2cd8b74954272dadf45 (diff)
downloadpardes-f922f8b5db1f3b92d954c43860c32cd251d5bc55.tar.gz
pardes-f922f8b5db1f3b92d954c43860c32cd251d5bc55.zip
kinds #20, their tests and docs: T1's sessions are a terminal without graphics, so a PDF's key test is the base's text-layer one again beside the strip's (Session.graphics gives a frontend pictures), /addons says 2.2; pane cases for the hand over a link and a touchpad's fraction; reference.typ and the changelog say what a PDF does with and without graphics and what 2.2 added
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/keys.zig')
-rw-r--r--test/behaviour/keys.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig
index 879ff441..118681cd 100644
--- a/test/behaviour/keys.zig
+++ b/test/behaviour/keys.zig
@@ -136,9 +136,34 @@ test "keys: a count or a prefix a click or a change of pane cancels leaves nothi
}
}
+test "keys: a PDF shown as text turns pages for the moving keys, counted, and the editing keys do nothing" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const n = try s.lookFile("docs/design.pdf");
+ const pages = (try s.pdfPage(n))[1];
+ try std.testing.expect(pages > 3);
+ // j k, Ctrl-d Ctrl-u, Ctrl-f Ctrl-b: a page each, counted.
+ for ([_][]const u8{ "2j", "2k", "2\x04", "2\x15", "2\x06", "2\x02" }, 0..) |keys, i| {
+ try s.keys(keys);
+ try std.testing.expectEqual(@as(u32, if (i % 2 == 0) 3 else 1), (try s.pdfPage(n))[0]);
+ }
+ for ([_]struct { []const u8, u32 }{ .{ "ge", pages }, .{ "gg", 1 }, .{ "3gg", 3 }, .{ "2G", 2 } }) |step| {
+ try s.keys(step[0]);
+ try std.testing.expectEqual(step[1], (try s.pdfPage(n))[0]);
+ }
+ // Consumed, with their count: the page stays, no selection begins, and
+ // the next j is one page.
+ try s.keys("4dv|");
+ try std.testing.expectEqual(@as(u32, 2), (try s.pdfPage(n))[0]);
+ try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal "));
+ try s.keys("j");
+ try std.testing.expectEqual(@as(u32, 3), (try s.pdfPage(n))[0]);
+}
+
test "keys: a PDF's moving keys scroll its strip, counted, gg G and ge go to pages, and the editing keys do nothing" {
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();
+ s.graphics();
const n = try s.lookFile("docs/design.pdf");
const pages = (try s.pdfPage(n))[1];
try std.testing.expect(pages > 3);