Attempt to write test
This commit is contained in:
parent
0684369734
commit
27d4d727c3
2 changed files with 103 additions and 7 deletions
|
@ -114,14 +114,26 @@ impl ActionRegistry {
|
|||
pub(crate) fn load_actions(&mut self) {
|
||||
for builder in __GPUI_ACTIONS {
|
||||
let action = builder();
|
||||
//todo(remove)
|
||||
let name: SharedString = action.name.into();
|
||||
self.builders_by_name.insert(name.clone(), action.build);
|
||||
self.names_by_type_id.insert(action.type_id, name.clone());
|
||||
self.all_names.push(name);
|
||||
self.insert_action(action);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn load_action<A: Action>(&mut self) {
|
||||
self.insert_action(ActionData {
|
||||
name: A::debug_name(),
|
||||
type_id: TypeId::of::<A>(),
|
||||
build: A::build,
|
||||
});
|
||||
}
|
||||
|
||||
fn insert_action(&mut self, action: ActionData) {
|
||||
let name: SharedString = action.name.into();
|
||||
self.builders_by_name.insert(name.clone(), action.build);
|
||||
self.names_by_type_id.insert(action.type_id, name.clone());
|
||||
self.all_names.push(name);
|
||||
}
|
||||
|
||||
/// Construct an action based on its name and optional JSON parameters sourced from the keymap.
|
||||
pub fn build_action_type(&self, type_id: &TypeId) -> Result<Box<dyn Action>> {
|
||||
let name = self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue