diff options
Diffstat (limited to 'test/behaviour/keys.zig')
| -rw-r--r-- | test/behaviour/keys.zig | 25 |
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); |
