summaryrefslogtreecommitdiff
path: root/test/behaviour/placement.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour/placement.zig')
-rw-r--r--test/behaviour/placement.zig37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/behaviour/placement.zig b/test/behaviour/placement.zig
index 350e94f8..079b5a5e 100644
--- a/test/behaviour/placement.zig
+++ b/test/behaviour/placement.zig
@@ -22,3 +22,40 @@ test "placement: an empty active column takes the new pane whole, a look from an
const made = try s.focused();
try std.testing.expectEqualStrings(s.at("{d}:{d} {d}:{d}", .{ try s.column(0), first, try s.column(1), made }), try s.columns());
}
+
+/// The screen row the tag starting `name` is drawn on.
+fn tagRow(s: *Session, name: []const u8) !usize {
+ return (try s.where(s.at("{s} Save", .{name})))[1];
+}
+
+test "placement: New and 9P's new take the bottom half of the column's last pane" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const first = try s.focused();
+ try s.write(s.at("/pane/{d}/exec", .{first}), "New\n");
+ const last = try s.focused();
+ try s.write(s.at("/pane/{d}/name", .{last}), "/last\n");
+ const was = try tagRow(&s, "/last");
+ const made = try s.newPane();
+ try s.write(s.at("/pane/{d}/name", .{made}), "/made\n");
+ try std.testing.expectEqualStrings(s.at("{d}:{d},{d},{d}", .{ try s.column(0), first, last, made }), try s.columns());
+ // The last pane keeps its top and gives up its bottom half.
+ try std.testing.expectEqual(was, try tagRow(&s, "/last"));
+ const rows = std.mem.count(u8, try s.screen(), "\n") + 1;
+ try std.testing.expect(try tagRow(&s, "/made") >= was + (rows - was) / 2);
+}
+
+test "placement: Placement pardes puts a new pane right under the asking one, and bare it steps back to acme" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write("/ctl", "Placement pardes\n");
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPlacement pardes\n") != null);
+ const top = try s.focused();
+ try s.write(s.at("/pane/{d}/exec", .{top}), "New\n");
+ const below = try s.focused();
+ // Directly under the asking pane, as New always put it.
+ try s.write(s.at("/pane/{d}/exec", .{top}), "New\n");
+ try std.testing.expectEqualStrings(s.at("{d}:{d},{d},{d}", .{ try s.column(0), top, try s.focused(), below }), try s.columns());
+ try s.write("/ctl", "Placement\n");
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPlacement acme\n") != null);
+}