Ensure the SettingsStore global is added in tests

This commit is contained in:
Max Brunsfeld 2023-05-10 16:39:59 -07:00
parent 68867fe2e1
commit cee7edabf9
10 changed files with 61 additions and 32 deletions

View file

@ -1174,7 +1174,7 @@ impl AppContext {
this.notify_global(type_id);
result
} else {
panic!("No global added for {}", std::any::type_name::<T>());
panic!("no global added for {}", std::any::type_name::<T>());
}
}
@ -1182,6 +1182,15 @@ impl AppContext {
self.globals.clear();
}
pub fn remove_global<T: 'static>(&mut self) -> T {
*self
.globals
.remove(&TypeId::of::<T>())
.unwrap_or_else(|| panic!("no global added for {}", std::any::type_name::<T>()))
.downcast()
.unwrap()
}
pub fn add_model<T, F>(&mut self, build_model: F) -> ModelHandle<T>
where
T: Entity,