diff options
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/addons.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index 4a624c22..b64a6974 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -174,6 +174,29 @@ test "addons: the image addon opens the pictures a Look names, fitted, with the try std.testing.expect(has(try s.read("/screen"), "\"src\":[0,0,4,2]")); } +test "addons: a Plumb rule to a loaded kind opens that kind's pane, is refused naming one not loaded, and with its kind gone the look falls through to text" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try load(&s, Session.image_addon); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var buf: [4096]u8 = undefined; + const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; + // A PNG under a name no kind claims. + const png = "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDATx\x9cc\xf8\xcf\xc0\x00\x00\x03\x01\x01\x00\xc9\xfe\x92\xef\x00\x00\x00\x00IEND\xaeB`\x82"; + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "red.pic", .data = png }); + try std.testing.expect(try s.refused("/ctl", "Plumb suffix .pic to nokind\n") != 0); + try std.testing.expect(has(s.said, "Plumb: invalid port: url, dir, file or a loaded kind")); + try s.write("/ctl", "Plumb suffix .pic to image\n"); + try s.write("/look", s.at("{s}/red.pic\n", .{dir})); + try std.testing.expectEqual(try paneOf(&s, "image"), try s.focused()); + try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n"); + try s.write("/ctl", "Addon unload image\n"); + try s.write("/look", s.at("{s}/red.pic\n", .{dir})); + try std.testing.expect(has(try s.read(s.at("/pane/{d}/tag", .{try s.focused()})), "red.pic")); + try std.testing.expectError(error.NoSuchPane, paneOf(&s, "image")); +} + test "addons: a dump keeps an addon's pane; restored without its addon it waits as a placeholder, and opens in place when the addon comes" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); |
