summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/tab/unit/tab_tests.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2022-12-14 22:26:48 +0100
committerGitHub <noreply@github.com>2022-12-14 22:26:48 +0100
commitc3115a428ed5c990cc5ead5629dabb624ae90453 (patch)
treefe1a3c0f344b6d1056789861d6d28ca5196f838d /zellij-server/src/tab/unit/tab_tests.rs
parent177cd20beaf7a89d54b295f1aab498b7ab2c04c1 (diff)
fix(panes): show visual error when unable to split panes vertically/horizontally (#2025)
* fix(panes): show visual error when failing to split pane vertically/horizontally * fix: lockfile
Diffstat (limited to 'zellij-server/src/tab/unit/tab_tests.rs')
-rw-r--r--zellij-server/src/tab/unit/tab_tests.rs84
1 files changed, 83 insertions, 1 deletions
diff --git a/zellij-server/src/tab/unit/tab_tests.rs b/zellij-server/src/tab/unit/tab_tests.rs
index a676f3c68..192c55e3e 100644
--- a/zellij-server/src/tab/unit/tab_tests.rs
+++ b/zellij-server/src/tab/unit/tab_tests.rs
@@ -10,7 +10,7 @@ use crate::{
use std::path::PathBuf;
use zellij_utils::data::{Direction, Resize, ResizeStrategy};
use zellij_utils::errors::prelude::*;
-use zellij_utils::input::layout::PaneLayout;
+use zellij_utils::input::layout::{PaneLayout, SplitDirection, SplitSize};
use zellij_utils::ipc::IpcReceiverWithContext;
use zellij_utils::pane_size::{Size, SizeInPixels};
@@ -187,6 +187,62 @@ fn create_new_tab(size: Size) -> Tab {
tab
}
+fn create_new_tab_with_layout(size: Size, layout: PaneLayout) -> Tab {
+ let index = 0;
+ let position = 0;
+ let name = String::new();
+ let os_api = Box::new(FakeInputOutput {});
+ let senders = ThreadSenders::default().silently_fail_on_send();
+ let max_panes = None;
+ let mode_info = ModeInfo::default();
+ let style = Style::default();
+ let draw_pane_frames = true;
+ let client_id = 1;
+ let session_is_mirrored = true;
+ let mut connected_clients = HashSet::new();
+ let character_cell_info = Rc::new(RefCell::new(None));
+ connected_clients.insert(client_id);
+ let connected_clients = Rc::new(RefCell::new(connected_clients));
+ let terminal_emulator_colors = Rc::new(RefCell::new(Palette::default()));
+ let copy_options = CopyOptions::default();
+ let sixel_image_store = Rc::new(RefCell::new(SixelImageStore::default()));
+ let terminal_emulator_color_codes = Rc::new(RefCell::new(HashMap::new()));
+ let mut tab = Tab::new(
+ index,
+ position,
+ name,
+ size,
+ character_cell_info,
+ sixel_image_store,
+ os_api,
+ senders,
+ max_panes,
+ style,
+ mode_info,
+ draw_pane_frames,
+ connected_clients,
+ session_is_mirrored,
+ client_id,
+ copy_options,
+ terminal_emulator_colors,
+ terminal_emulator_color_codes,
+ );
+ let mut new_terminal_ids = vec![];
+ for i in 0..layout.extract_run_instructions().len() {
+ new_terminal_ids.push((i as u32, None));
+ }
+ tab.apply_layout(
+ layout,
+ // vec![(1, None), (2, None)],
+ new_terminal_ids,
+ HashMap::new(),
+ index,
+ client_id,
+ )
+ .unwrap();
+ tab
+}
+
fn create_new_tab_with_cell_size(
size: Size,
character_cell_size: Rc<RefCell<Option<SizeInPixels>>>,
@@ -678,6 +734,32 @@ pub fn cannot_split_largest_pane_when_there_is_no_room() {
}
#[test]
+pub fn cannot_split_panes_vertically_when_active_pane_has_fixed_columns() {
+ let size = Size { cols: 50, rows: 20 };
+ let mut initial_layout = PaneLayout::default();
+ initial_layout.children_split_direction = SplitDirection::Vertical;
+ let mut fixed_child = PaneLayout::default();
+ fixed_child.split_size = Some(SplitSize::Fixed(30));
+ initial_layout.children = vec![fixed_child, PaneLayout::default()];
+ let mut tab = create_new_tab_with_layout(size, initial_layout);
+ tab.vertical_split(PaneId::Terminal(3), None, 1).unwrap();
+ assert_eq!(tab.tiled_panes.panes.len(), 2, "Tab still has two panes");
+}
+
+#[test]
+pub fn cannot_split_panes_horizontally_when_active_pane_has_fixed_rows() {
+ let size = Size { cols: 50, rows: 20 };
+ let mut initial_layout = PaneLayout::default();
+ initial_layout.children_split_direction = SplitDirection::Horizontal;
+ let mut fixed_child = PaneLayout::default();
+ fixed_child.split_size = Some(SplitSize::Fixed(12));
+ initial_layout.children = vec![fixed_child, PaneLayout::default()];
+ let mut tab = create_new_tab_with_layout(size, initial_layout);
+ tab.horizontal_split(PaneId::Terminal(3), None, 1).unwrap();
+ assert_eq!(tab.tiled_panes.panes.len(), 2, "Tab still has two panes");
+}
+
+#[test]
pub fn toggle_focused_pane_fullscreen() {
let size = Size {
cols: 121,