Don't require a path in TestAppContext::dispatch_action

Instead, derive it from the presenter. This makes tests easier to write and more reliable since we'll be accurately simulating the actual relationship between parent and child views.
This commit is contained in:
Nathan Sobo 2022-04-05 12:08:25 -06:00
parent 3da8f7f944
commit e2bf89b1e8
3 changed files with 21 additions and 26 deletions

View file

@ -426,15 +426,17 @@ impl TestAppContext {
cx
}
pub fn dispatch_action<A: Action>(
&self,
window_id: usize,
responder_chain: Vec<usize>,
action: A,
) {
self.cx
.borrow_mut()
.dispatch_action_any(window_id, &responder_chain, &action);
pub fn dispatch_action<A: Action>(&self, window_id: usize, action: A) {
let mut cx = self.cx.borrow_mut();
let responder_chain = cx
.presenters_and_platform_windows
.get(&window_id)
.unwrap()
.0
.borrow()
.dispatch_path(cx.as_ref());
cx.dispatch_action_any(window_id, &responder_chain, &action);
}
pub fn dispatch_global_action<A: Action>(&self, action: A) {