diff --git a/crates/voelin-gpui/src/app.rs b/crates/voelin-gpui/src/app.rs index 7888206..415c690 100644 --- a/crates/voelin-gpui/src/app.rs +++ b/crates/voelin-gpui/src/app.rs @@ -566,6 +566,12 @@ impl AppState { std::mem::take(&mut *self.sent.borrow_mut()) } + /// The folder the sample pictures were written to, while there is one. + #[cfg(test)] + pub(crate) fn demo_dir(&self) -> Option<&PathBuf> { + self.demo_dir.as_ref() + } + /// A command for the session on screen. fn command(&self, f: impl FnOnce(u64) -> Command) { if let Some(id) = self.vm.current { diff --git a/crates/voelin-gpui/src/view.rs b/crates/voelin-gpui/src/view.rs index efd1888..748fb09 100644 --- a/crates/voelin-gpui/src/view.rs +++ b/crates/voelin-gpui/src/view.rs @@ -1289,6 +1289,14 @@ mod tests { assert!(!tinted(cx, second)); click(cx, &format!("tree-channel-{second}")); assert!(tinted(cx, second) && !tinted(cx, first), "and the tint follows the selection"); + + // The sample pictures are files of a folder of the state's own in the + // temporary directory; the window's close, as the app ends, removes it + // (the entity of a test is not released when the test ends). + let folder = shell.app.read_with(cx, |app, _| app.demo_dir().cloned()); + assert!(folder.as_ref().is_some_and(|folder| folder.is_dir()), "{folder:?}"); + shell.app.update(cx, |app, cx| app.shutdown(cx)); + assert!(!folder.is_some_and(|folder| folder.exists()), "the close removes it"); } /// A person who changes channel makes the rows between the two places