Skip to content

Commit

Permalink
Merge branch 'main' into feat/fill-size
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 authored Nov 2, 2023
2 parents 6ffe4e1 + 63a49c7 commit 9c45732
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions crates/testing/src/test_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use torin::geometry::{Area, Size2D};

pub use freya_core::events::FreyaEvent;
pub use freya_elements::events::mouse::MouseButton;
use tokio::time::{sleep, timeout};
use tokio::time::{interval, timeout};

use crate::test_node::TestNode;
use crate::test_utils::TestUtils;
Expand Down Expand Up @@ -71,7 +71,11 @@ impl TestingHandler {

self.provide_vdom_contexts();

let vdom = &mut self.vdom;
let mut ticker = if self.config.run_ticker {
Some(interval(Duration::from_millis(16)))
} else {
None
};

// Handle platform and VDOM events
loop {
Expand All @@ -85,9 +89,12 @@ impl TestingHandler {
if let Ok(ev) = platform_ev {
match ev {
EventMessage::RequestRerender => {
if self.config.run_ticker {
sleep(Duration::from_millis(16)).await;
if let Some(ticker) = ticker.as_mut() {
ticker.tick().await;
self.ticker_sender.send(()).unwrap();
timeout(self.config.vdom_timeout(), self.vdom.wait_for_work())
.await
.ok();
}
}
EventMessage::FocusAccessibilityNode(node_id) => {
Expand All @@ -101,12 +108,13 @@ impl TestingHandler {
}

if let Ok(ev) = vdom_ev {
vdom.handle_event(&ev.name, ev.data.any(), ev.element_id, false);
vdom.process_events();
self.vdom
.handle_event(&ev.name, ev.data.any(), ev.element_id, false);
self.vdom.process_events();
}
}

timeout(self.config.vdom_timeout(), vdom.wait_for_work())
timeout(self.config.vdom_timeout(), self.vdom.wait_for_work())
.await
.ok();

Expand Down

0 comments on commit 9c45732

Please sign in to comment.