diff options
Diffstat (limited to 'tests.zig')
| -rw-r--r-- | tests.zig | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -26,6 +26,15 @@ fn writeAll(fd: c_int, bytes: []const u8) !void { } } +fn writeFileE2E(path: [*:0]const u8, data: []const u8) !void { + const rc = linux.open(path, .{ .ACCMODE = .WRONLY, .CREAT = true, .TRUNC = true }, 0o644); + const sfd: isize = @bitCast(rc); + if (sfd < 0) return error.OpenFailed; + const fd: c_int = @intCast(sfd); + defer _ = linux.close(fd); + try writeAll(fd, data); +} + // TIOCSWINSZ on the pty master: changes the size and makes the kernel raise // SIGWINCH in the slave's foreground process group (i.e. the app under test). fn setWinsize(fd: c_int, rows: u16, cols: u16) !void { @@ -218,6 +227,32 @@ pub fn main(init: std.process.Init) !void { return error.RightClickDirFailed; } + // 8. Right-click a "path:line" opens a line-numbered FILE pane SCROLLED to + // that line. Build a tall file whose deep marker (line 150) is only + // reachable by scrolling, type the path:line on a blank row of the right + // column, then right-click it. Typed text renders starting at the click + // column, so the right-click lands on the path without knowing any pane + // geometry. The file pane opens, scrolls to line 150 -> the marker shows. + var fbuf: std.ArrayList(u8) = .empty; + defer fbuf.deinit(gpa); + { + var ln: usize = 1; + while (ln <= 200) : (ln += 1) + try fbuf.appendSlice(gpa, if (ln == 150) "ZZDEEPMARK\n" else "filler\n"); + } + try writeFileE2E("/tmp/pardesE2Efile.txt", fbuf.items); + try setWinsize(master, 50, 200); // clean, known geometry (col 149 is in the right column) + try drainFor(gpa, master, &output, 700); // settle the reflow + output.clearRetainingCapacity(); + try writeAll(master, "\x1b[<0;150;11M\x1b[<0;150;11m"); // left-click blank row, right column -> text mode + pin + try writeAll(master, "/tmp/pardesE2Efile.txt:150"); // type the path:line (char mode) + _ = try pollFor(gpa, master, &output, "ZZNEVERZZ", 8); // settle (build the run) + try writeAll(master, "\x1b[<2;156;11M\x1b[<2;156;11m"); // right-click on the typed path + if (!try pollFor(gpa, master, &output, "ZZDEEPMARK", 120)) { + dump(output.items, "right-click 'path:150' did not open the file scrolled to line 150"); + return error.RightClickFileFailed; + } + // Tell the app to quit (ctrl-c is the app's own exit key). try writeAll(master, "\x03"); } |
