From f4aac3b53db6b43458f00a5d00607b551be0059e Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Wed, 2 Feb 2022 20:38:47 -0800 Subject: [PATCH] fix failing test --- src/editor/window.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/editor/window.rs b/src/editor/window.rs index 29a54a5..b58906d 100644 --- a/src/editor/window.rs +++ b/src/editor/window.rs @@ -324,31 +324,28 @@ impl Window { #[cfg(test)] mod tests { - use super::*; use std::collections::HashMap; - use std::sync::mpsc::*; - - fn build_test_channels() -> (Receiver>, Arc) { - let (_batched_draw_command_sender, batched_draw_command_receiver) = channel(); - let draw_command_batcher = Arc::new(DrawCommandBatcher::new()); - - (batched_draw_command_receiver, draw_command_batcher) - } + use super::*; + use crate::event_aggregator::EVENT_AGGREGATOR; #[test] fn window_separator_modifies_grid_and_sends_draw_command() { - let (batched_receiver, batched_sender) = build_test_channels(); + let mut draw_command_receiver = EVENT_AGGREGATOR.register_event::>(); + let draw_command_batcher = Arc::new(DrawCommandBatcher::new()); + let mut window = Window::new( 1, WindowType::Editor, None, (0.0, 0.0), (114, 64), - batched_sender.clone(), + draw_command_batcher.clone(), ); - batched_sender.send_batch(); - batched_receiver.recv().expect("Could not receive commands"); + + draw_command_batcher.send_batch(); + + draw_command_receiver.try_recv().expect("Could not receive commands"); window.draw_grid_line( 1, @@ -363,9 +360,9 @@ mod tests { assert_eq!(window.grid.get_cell(70, 1), Some(&("|".to_owned(), None))); - batched_sender.send_batch(); + draw_command_batcher.send_batch(); - let sent_commands = batched_receiver.recv().expect("Could not receive commands"); + let sent_commands = draw_command_receiver.try_recv().expect("Could not receive commands"); assert!(sent_commands.len() != 0); } }