diff options
Diffstat (limited to 'test/panes.zig')
| -rw-r--r-- | test/panes.zig | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/test/panes.zig b/test/panes.zig index d47136a5..fb8adc36 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -3783,15 +3783,12 @@ const PdfAddon = struct { }.f, }; - test "a client without the pdf addon shows a PDF pane as the session's frames of it, its pages by key, and its wheel goes to the session" { + test "a client without the pdf addon shows its PDF pane as a line, its page in its tag, and its wheel goes to the session" { if (!addons.has_pdf) return error.SkipZigTest; const R = pardes.replica; const gpa = std.testing.allocator; const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); defer a.deinit(); - var screens: R.Screens = .init(gpa); - defer screens.deinit(a.core); - const peer = try screens.addPeer(); const r = try R.Replica.init(gpa, 1, try a.unit(0, 0), false); defer r.deinit(); const Land = struct { @@ -3802,61 +3799,30 @@ const PdfAddon = struct { } }; const land: Land = .{ .a = a, .r = r }; - var words: [64]pardes.Kind.LoadedWord = undefined; - var why: pardes.Kind.Buf(160) = .{}; - const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why); - try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } }); // A frontend with pictures (a terminal without them is shown the // page's text layer). try land.step(.{ .frontend = .{ .windowed = false, .native_images = true } }); + const id = try opened(a, land); try std.testing.expect(r.core().kinds.ops[r.core().kinds.n - 1] == null); - var buf: [4096]u8 = undefined; - const real = try std.Io.Dir.cwd().realPathFile(std.testing.io, "docs/design.pdf", &buf); - var line: [4200]u8 = undefined; - try land.step(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{buf[0..real]}) }); - for (0..3) |_| { - try land.step(.tick); - try jobs(a.core, land); - } - // Its frame crosses: the replica draws the pane as the session - // painted it, its pages placed by key, its page in its tag. var arena: std.heap.ArenaAllocator = .init(gpa); defer arena.deinit(); - const deliver = struct { - fn f(au: *R.Authority, sc: *R.Screens, pe: u16, re: *R.Replica) !void { - var msgs: std.ArrayListUnmanaged([]u8) = .empty; - defer { - for (msgs.items) |m| std.testing.allocator.free(m); - msgs.deinit(std.testing.allocator); - } - try sc.flush(au.core, pe, re.view, &msgs); - for (msgs.items) |m| if (re.screen(m)) |reply| { - _ = try sc.take(au.core, pe, reply); - }; - } - }.f; _ = try a.core.render(arena.allocator()); - // (A kind's prefix is its last frame's, and the tag a step's: a - // Shadow's is the authority's last step's.) try land.step(.tick); - try deliver(a, &screens, peer, r); - const id = for (r.core().panes, 0..) |slot, i| { - if (slot) |pane| if (pane.addon != null) break i; - } else return error.NoPdfPane; + // No picture crosses: the client shows the line saying the addon + // does not run here, and the session's page in its tag. const shown = try r.core().render(arena.allocator()); var placed: usize = 0; for (shown.placements.items) |pl| placed += @intFromBool(pl.pane == id); - try std.testing.expect(placed >= 1); + try std.testing.expectEqual(@as(usize, 0), placed); try std.testing.expect(std.mem.startsWith(u8, try pardes.tagline.tagPrefix(r.core(), r.core().panes[id].?), "[1/16]")); - // A wheel at the replica: the session's kind takes it, and the - // replica shows where the session's strip went. + // A wheel at the replica: the session's kind takes it. const before = a.core.panes[id].?.addon.?.thumb_at; const rect = r.core().view().rects[id]; for (0..20) |_| r.confirm(try a.take(try r.input(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = rect.x + rect.w / 2, .row = rect.y + rect.h / 2 } }))); + for (0..4) |_| try land.step(.tick); try jobs(a.core, land); _ = try a.core.render(arena.allocator()); try std.testing.expect(a.core.panes[id].?.addon.?.thumb_at > before); - try deliver(a, &screens, peer, r); r.settle(); try std.testing.expect(r.diverged == null); } |
