@@ -205,8 +205,8 @@ pub fn run(
205205mod tests {
206206 use crate :: { frontend:: Console , run, Config } ;
207207 use afrish:: { self , TkPackLayout } ;
208- use rdev:: { self , Button , EventType :: * , Key :: * } ;
209- use std:: sync:: mpsc:: { self , Sender } ;
208+ use rdev:: { self , EventType :: * , Key :: * } ;
209+ use std:: sync:: mpsc:: { self } ;
210210 use std:: { thread, time:: Duration } ;
211211
212212 macro_rules! input {
@@ -255,11 +255,7 @@ mod tests {
255255 input_field
256256 }
257257
258- fn end_sandbox ( ) {
259- afrish:: end_wish ( ) ;
260- }
261-
262- fn start_simulation ( signal : Sender < ( ) > ) {
258+ fn start_simulation ( ) {
263259 let typing_speed_ms = Duration :: from_millis ( 500 ) ;
264260
265261 // To detect excessive backspace
@@ -268,15 +264,10 @@ mod tests {
268264 // Start the sandbox
269265 let textfield = start_sandbox ( LIMIT ) ;
270266
271- // Send the ready signal.
272- signal. send ( ( ) ) . unwrap ( ) ;
273-
274- rdev:: simulate ( & MouseMove { x : 100.0 , y : 100.0 } ) . unwrap ( ) ;
275- thread:: sleep ( typing_speed_ms) ;
276- rdev:: simulate ( & ButtonPress ( Button :: Left ) ) . unwrap ( ) ;
277- thread:: sleep ( typing_speed_ms) ;
278- rdev:: simulate ( & ButtonRelease ( Button :: Left ) ) . unwrap ( ) ;
279- thread:: sleep ( typing_speed_ms) ;
267+ rdev:: simulate ( & KeyPress ( Alt ) ) . unwrap ( ) ;
268+ rdev:: simulate ( & KeyPress ( Tab ) ) . unwrap ( ) ;
269+ rdev:: simulate ( & KeyRelease ( Alt ) ) . unwrap ( ) ;
270+ rdev:: simulate ( & KeyRelease ( Tab ) ) . unwrap ( ) ;
280271
281272 input ! ( KeyU , typing_speed_ms) ;
282273 #[ cfg( not( feature = "inhibit" ) ) ]
@@ -378,8 +369,6 @@ mod tests {
378369 rdev:: simulate ( & KeyPress ( ShiftLeft ) ) . unwrap ( ) ;
379370 input ! ( Minus , typing_speed_ms) ;
380371 rdev:: simulate ( & KeyRelease ( ShiftLeft ) ) . unwrap ( ) ;
381-
382- end_sandbox ( ) ;
383372 }
384373
385374 #[ test]
@@ -388,16 +377,20 @@ mod tests {
388377
389378 let ( tx, rx) = mpsc:: channel ( ) ;
390379
391- // TODO: handle simulation errors.
392- let simulation_thread = thread:: spawn ( move || start_simulation ( tx) ) ;
380+ let afrim_thread = thread:: spawn ( move || {
381+ let test_config = Config :: from_file ( Path :: new ( "./data/test.toml" ) ) . unwrap ( ) ;
382+ // Send the ready signal.
383+ tx. send ( ( ) ) . unwrap ( ) ;
384+
385+ assert ! ( run( test_config, Console :: default ( ) ) . is_ok( ) ) ;
386+ } ) ;
393387
394388 // Wait the ready signal.
395389 rx. recv ( ) . unwrap ( ) ;
396390
397- let test_config = Config :: from_file ( Path :: new ( "./data/test.toml" ) ) . unwrap ( ) ;
398- assert ! ( run( test_config, Console :: default ( ) ) . is_ok( ) ) ;
391+ start_simulation ( ) ;
399392
400- // Wait the simulation to end properly.
401- simulation_thread . join ( ) . unwrap ( ) ;
393+ // Wait the afrim to end properly.
394+ afrim_thread . join ( ) . unwrap ( ) ;
402395 }
403396}
0 commit comments