Add randomized test for DisplayMap

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-07-30 09:50:28 -07:00
co-authored by Nathan Sobo
parent 576cabea93
commit c1808d09ef
3 changed files with 161 additions and 26 deletions
+1 -24
View File
@@ -875,11 +875,10 @@ mod tests {
display_map::{fold_map::FoldMap, tab_map::TabMap},
Buffer,
},
test::Observer,
util::RandomCharIter,
};
use gpui::ModelHandle;
use rand::prelude::*;
use smol::channel;
use std::env;
#[gpui::test(iterations = 100)]
@@ -1077,26 +1076,4 @@ mod tests {
}
}
}
struct Observer;
impl Entity for Observer {
type Event = ();
}
impl Observer {
fn new(
handle: &ModelHandle<WrapMap>,
cx: &mut gpui::TestAppContext,
) -> (ModelHandle<Self>, channel::Receiver<()>) {
let (notify_tx, notify_rx) = channel::unbounded();
let observer = cx.add_model(|cx| {
cx.observe(handle, move |_, _, _| {
let _ = notify_tx.try_send(());
});
Observer
});
(observer, notify_rx)
}
}
}