Resolve more todos

This commit is contained in:
Mikayla 2024-01-09 15:08:05 -08:00
parent 80790d921d
commit ed263a7b5c
No known key found for this signature in database
8 changed files with 47 additions and 29 deletions

View file

@ -25,6 +25,7 @@ pub struct TestAppContext {
pub dispatcher: TestDispatcher,
test_platform: Rc<TestPlatform>,
text_system: Arc<TextSystem>,
fn_name: Option<&'static str>,
}
impl Context for TestAppContext {
@ -85,7 +86,7 @@ impl Context for TestAppContext {
impl TestAppContext {
/// Creates a new `TestAppContext`. Usually you can rely on `#[gpui::test]` to do this for you.
pub fn new(dispatcher: TestDispatcher) -> Self {
pub fn new(dispatcher: TestDispatcher, fn_name: Option<&'static str>) -> Self {
let arc_dispatcher = Arc::new(dispatcher.clone());
let background_executor = BackgroundExecutor::new(arc_dispatcher.clone());
let foreground_executor = ForegroundExecutor::new(arc_dispatcher);
@ -101,12 +102,18 @@ impl TestAppContext {
dispatcher: dispatcher.clone(),
test_platform: platform,
text_system,
fn_name,
}
}
/// The name of the test function that created this `TestAppContext`
pub fn test_function_name(&self) -> Option<&'static str> {
self.fn_name
}
/// returns a new `TestAppContext` re-using the same executors to interleave tasks.
pub fn new_app(&self) -> TestAppContext {
Self::new(self.dispatcher.clone())
Self::new(self.dispatcher.clone(), self.fn_name)
}
/// Simulates quitting the app.