From 61ec3342348a4059ede0bea0e0b050126c0f44a0 Mon Sep 17 00:00:00 2001 From: K Simmons Date: Tue, 13 Sep 2022 19:26:07 -0700 Subject: [PATCH] Minor tweak to dock tests --- crates/workspace/src/dock.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 0fd92695fbd4afa63610a67c72c5bedaab5bfc8d..2db2d49917dde878c40f200049dbd1ba728567b5 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -460,11 +460,13 @@ mod tests { center_item.update(&mut cx, |_, cx| cx.focus_self()); cx.assert_dock_position(DockPosition::Shown(DockAnchor::Right)); cx.assert_dock_pane_inactive(); + cx.assert_workspace_pane_active(); - // Focus dock item + // Focusing an item in the dock activates it's pane dock_item.update(&mut cx, |_, cx| cx.focus_self()); cx.assert_dock_position(DockPosition::Shown(DockAnchor::Right)); cx.assert_dock_pane_active(); + cx.assert_workspace_pane_inactive(); } struct DockTestContext<'a> { @@ -541,6 +543,15 @@ mod tests { }) } + pub fn center_pane_handle(&self) -> ViewHandle { + self.workspace(|workspace, _| { + workspace + .last_active_center_pane + .clone() + .unwrap_or_else(|| workspace.center.panes()[0].clone()) + }) + } + pub fn add_item_to_center_pane(&mut self) -> ViewHandle { self.update_workspace(|workspace, cx| { let item = cx.add_view(|_| TestItem::new()); @@ -614,6 +625,18 @@ mod tests { assert!(!self.sidebar(sidebar_side, |sidebar, _| sidebar.is_open())); } + pub fn assert_workspace_pane_active(&self) { + assert!(self + .center_pane_handle() + .read_with(self.cx, |pane, _| pane.is_active())); + } + + pub fn assert_workspace_pane_inactive(&self) { + assert!(!self + .center_pane_handle() + .read_with(self.cx, |pane, _| pane.is_active())); + } + pub fn assert_dock_pane_active(&self) { assert!(self.dock_pane(|pane, _| pane.is_active())) }