summaryrefslogtreecommitdiff
path: root/test/session.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/session.zig')
-rw-r--r--test/session.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/session.zig b/test/session.zig
index 8b3c5c41..f11a4c7f 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -182,6 +182,26 @@ pub const Session = struct {
fn pardesOf(s: *Session) *Pardes {
return @ptrCast(@alignCast(s.core));
}
+
+ // pdf:
+
+ /// A Look of `path` at the root (one relative to the working directory
+ /// made absolute first); the serial of the pane with the keyboard after.
+ pub fn lookFile(s: *Session, path: []const u8) !u32 {
+ var buf: [4096]u8 = undefined;
+ const abs = if (std.fs.path.isAbsolute(path)) path else s.at("{s}/{s}", .{ buf[0..try std.Io.Dir.cwd().realPath(std.testing.io, &buf)], path });
+ try s.write("/look", s.at("{s}\n", .{abs}));
+ return s.focused();
+ }
+
+ /// The page a PDF pane shows and its pages, from its tag's `[page/pages]`.
+ pub fn pdfPage(s: *Session, n: u32) !struct { u32, u32 } {
+ const tag = try s.read(s.at("/pane/{d}/tag", .{n}));
+ const lo = std.mem.indexOf(u8, tag, " [") orelse return error.NoPage;
+ const close = std.mem.indexOfScalarPos(u8, tag, lo, ']') orelse return error.NoPage;
+ var it = std.mem.splitScalar(u8, tag[lo + 2 .. close], '/');
+ return .{ try std.fmt.parseInt(u32, it.next().?, 10), try std.fmt.parseInt(u32, it.next() orelse return error.NoPage, 10) };
+ }
};
fn refusal(path: []const u8, r: Reply) error{Refused} {