Avoid holding RefCell borrow while calling TestAppContext::spawn callback

This commit is contained in:
Max Brunsfeld 2022-05-31 15:31:47 -07:00
parent 7ef9de32b1
commit 8d46edd26c

View file

@ -499,7 +499,14 @@ impl TestAppContext {
Fut: 'static + Future<Output = T>,
T: 'static,
{
self.cx.borrow_mut().spawn(f)
let foreground = self.foreground();
let future = f(self.to_async());
let cx = self.to_async();
foreground.spawn(async move {
let result = future.await;
cx.0.borrow_mut().flush_effects();
result
})
}
pub fn simulate_new_path_selection(&self, result: impl FnOnce(PathBuf) -> Option<PathBuf>) {