summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/ctl.zig40
1 files changed, 8 insertions, 32 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 9b87d9aa..42d9f3bd 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1539,7 +1539,7 @@ test "an address looked at in an image pane names the image, never an empty subj
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const id = p.freeSlot().?;
- const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, id, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
_ = wr(p, Node.of(doc.serial, .look), ":/x/\n");
try testing.expect(th.logHas(p, "look: /tmp/pardes-pic.ppm is no text to address"));
}
@@ -1548,7 +1548,7 @@ test "Save and Save path on an image pane are refused with why, never a silent s
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const id = p.freeSlot().?;
- const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, id, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
for ([_][]const u8{ "Save\n", "Save /tmp/pardes-copy.ppm\n" }) |line| {
const r = wr(p, Node.of(doc.serial, .ctl), line);
try testing.expectEqual(Status.err, r.reply.status);
@@ -1579,9 +1579,7 @@ test "a builtin for one kind of pane is refused on another, and still acts on it
};
const id = p.freeSlot().?;
// A picture shown: the core's art words follow the kind's prefix.
- pardes.image.start(testing.io, testing.allocator);
- defer pardes.image.stop();
- const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", "P6\n1 1\n255\n\x01\x02\x03");
+ const doc = try pardes.Kind.open(p, id, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", "P6\n1 1\n255\n\x01\x02\x03");
while (p.nextEffect()) |e| p.perform(e);
pardes.exec.placeNew(p, 0, 0, id, .doc);
_ = try p.render(p.scratch.allocator());
@@ -2158,32 +2156,10 @@ test "a language server question that finds nothing, cannot be answered, or is a
try testing.expectEqual(@as(u16, 0), p.fs.late_failure_len);
// An image's body takes no write.
const slot = p.freeSlot().?;
- const img = try pardes.Kind.open(p, slot, pardes.Kind.image, "/tmp/pardes-no-such.png", "not a png");
+ const img = try pardes.Kind.open(p, slot, pardes.Kind.test_kind.of(p), "/tmp/pardes-no-such.png", "not a png");
try testing.expectEqual(E.INVAL, wr(p, Node.of(img.serial, .body), "text\n").errno());
}
-test "a corrupt image fails its look with an err, and no pane is made" {
- pardes.image.start(testing.io, testing.allocator);
- defer pardes.image.stop();
- const p = try withFile(testing.allocator, "x\n");
- defer p.deinit();
- var tmp = testing.tmpDir(.{});
- defer tmp.cleanup();
- try tmp.dir.writeFile(testing.io, .{ .sub_path = "bad.png", .data = "\x89PNG not really" });
- var dir_buf: [4096]u8 = undefined;
- const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
- var line: [4200]u8 = undefined;
- var count: usize = 0;
- for (p.panes) |slot| count += @intFromBool(slot != null);
- const r = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/bad.png\n", .{dir}));
- try testing.expectEqual(E.IO, r.errno());
- try testing.expect(std.mem.endsWith(u8, r.reply.ename, "bad.png: not an image pardes can read"));
- p.sync();
- var after: usize = 0;
- for (p.panes) |slot| after += @intFromBool(slot != null);
- try testing.expectEqual(count, after);
-}
-
test "a truncated PDF fails its look with its path and why" {
if (comptime !pardes.pdf_enabled) return;
const p = try withFile(testing.allocator, "x\n");
@@ -2800,7 +2776,7 @@ test "a Save whose directory is missing because one above refuses says permissio
test "a body write to an image pane says its body takes none, not that terminals have no text" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
try testing.expectEqualStrings(pane_files.e_no_body, wr(p, Node.of(doc.serial, .body), "x").reply.ename);
}
@@ -2830,7 +2806,7 @@ test "a Rename that reaches other files previews them, says so, and is the pane
test "Edit on an image pane is refused as a data write there is, EINVAL, before it runs" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
const edit = wr(p, Node.of(doc.serial, .ctl), "Edit ,d\n");
const data = wr(p, Node.of(doc.serial, .data), "x");
try testing.expectEqual(E.INVAL, edit.errno());
@@ -2841,7 +2817,7 @@ test "Edit on an image pane is refused as a data write there is, EINVAL, before
test "Petscii, Palette and Ascii take the state their tag word names, set rather than flipped" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
const ctl_node = Node.of(doc.serial, .ctl);
for ([_][]const u8{ "Petscii on\n", "Petscii on\n" }) |line| {
try testing.expectEqual(Status.ok, wr(p, ctl_node, line).reply.status);
@@ -2851,7 +2827,7 @@ test "Petscii, Palette and Ascii take the state their tag word names, set rather
try testing.expect(!doc.addon.?.art.glyph);
_ = wr(p, ctl_node, "Palette terminal\n");
_ = wr(p, ctl_node, "Palette terminal\n");
- try testing.expectEqual(pardes.panes.Image.PaletteMode.terminal, doc.addon.?.art.palette);
+ try testing.expectEqual(pardes.Placement.Art.Palette.terminal, doc.addon.?.art.palette);
_ = wr(p, ctl_node, "Ascii off\n");
_ = wr(p, ctl_node, "Ascii off\n");
try testing.expect(!doc.addon.?.art.ascii);