diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/panes.zig | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig index fb8adc36..34c81801 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -4178,6 +4178,63 @@ const PdfAddon = struct { try std.testing.expect(notch > 0 and first > at[0] and first < at[1]); try std.testing.expectApproxEqRel(notch / 4, at[2] - at[1], 0.05); } + + test "a window client the size of its session's window shows a PDF's pages where the session's window shows them, a fraction of a pixel scrolled and all" { + 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(); + const win = try R.Replica.init(gpa, 2, try a.unit(0, 0), false); + defer win.deinit(); + const land = struct { + a: *R.Authority, + r: *R.Replica, + fn step(l: @This(), ev: pardes.Event) !void { + l.r.confirm(try l.a.local(ev)); + } + }{ .a = a, .r = win }; + // The session's window, and the client's of its size on a view of its own. + const window: pardes.Event = .{ .frontend = .{ .windowed = true, .native_images = true } }; + try land.step(window); + // The client has the addon (a test's replica finds no library of + // its own: it is handed the session's, loaded in this process). + 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 } }); + const kind = a.core.kinds.n - 1; + win.core().kinds.ops[kind] = a.core.kinds.ops[kind]; + const id = try opened(a, land); + const k = try a.openView(2); + win.confirm(k.unit); + win.view = k.view; + win.confirm(try a.take(try win.input(window))); + try land.step(.tick); + // A touchpad's 0.6 of a notch in the client: its view's top a + // fraction of a pixel past a row (as a glide's half steps leave it). + const r = win.core().view().rects[id]; + win.confirm(try a.take(try win.input(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = r.x + 4, .row = r.y + r.h - 2, .amount = 0.6 } }))); + for (0..2) |_| { + try land.step(.tick); + try jobs(a.core, land); + } + win.settle(); + try std.testing.expect(win.diverged == null); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + var at: [2][8][4]u32 = @splat(@splat(@splat(0))); + for ([_]*Pardes{ a.core, win.core() }, [_]u8{ 0, k.view }, &at) |core, view, *rows| { + core.toView(view); + var n: usize = 0; + for ((try core.render(arena.allocator())).placements.items) |pl| if (pl.pane == id and pl.raster.w > 1 and n < rows.len) { + rows[n] = if (pl.at) |x| .{ x.y, x.h, pl.src.y, pl.src.h } else .{ 0, 0, pl.src.y, pl.src.h }; + n += 1; + }; + try std.testing.expect(n > 0); + } + try std.testing.expectEqualSlices([4]u32, &at[0], &at[1]); + } }; test { |
