@@ -410,65 +410,78 @@ mod test {
410
410
assert_eq ! ( layers_after_copy[ 5 ] , shape_id) ;
411
411
}
412
412
413
- #[ tokio :: test]
413
+ #[ test]
414
414
/// This test will fail when you make changes to the underlying serialization format for a document.
415
- async fn check_if_demo_art_opens ( ) {
416
- use crate :: messages:: layout:: utility_types:: widget_prelude:: * ;
417
-
418
- let print_problem_to_terminal_on_failure = |value : & String | {
419
- println ! ( ) ;
420
- println ! ( "-------------------------------------------------" ) ;
421
- println ! ( "Failed test due to receiving a DisplayDialogError while loading a Graphite demo file." ) ;
422
- println ! ( ) ;
423
- println ! ( "DisplayDialogError details:" ) ;
424
- println ! ( ) ;
425
- println ! ( "Description: {value}" ) ;
426
- println ! ( "-------------------------------------------------" ) ;
427
- println ! ( ) ;
428
-
429
- panic ! ( )
430
- } ;
431
-
432
- init_logger ( ) ;
433
- let mut editor = Editor :: create ( ) ;
434
-
435
- for ( document_name, _, file_name) in crate :: messages:: dialog:: simple_dialogs:: ARTWORK {
436
- let document_serialized_content = std:: fs:: read_to_string ( format ! ( "../demo-artwork/{file_name}" ) ) . unwrap ( ) ;
437
-
438
- assert_eq ! (
439
- document_serialized_content. lines( ) . count( ) ,
440
- 1 ,
441
- "Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)" ,
442
- ) ;
443
-
444
- let responses = editor. handle_message ( PortfolioMessage :: OpenDocumentFile {
445
- document_name : document_name. into ( ) ,
446
- document_serialized_content,
447
- } ) ;
448
- println ! ( "Responses:\n {responses:#?}" ) ;
449
-
450
- // Check if the graph renders
451
- let portfolio = & mut editor. dispatcher . message_handlers . portfolio_message_handler ;
452
- portfolio
453
- . executor
454
- . submit_node_graph_evaluation ( portfolio. documents . get_mut ( & portfolio. active_document_id . unwrap ( ) ) . unwrap ( ) , glam:: UVec2 :: ONE )
455
- . expect ( "submit_node_graph_evaluation failed" ) ;
456
- crate :: node_graph_executor:: run_node_graph ( ) . await ;
457
- let mut messages = VecDeque :: new ( ) ;
458
- editor. poll_node_graph_evaluation ( & mut messages) . expect ( "Graph should render" ) ;
459
-
460
- for response in responses {
461
- // Check for the existence of the file format incompatibility warning dialog after opening the test file
462
- if let FrontendMessage :: UpdateDialogColumn1 { layout_target : _, diff } = response {
463
- if let DiffUpdate :: SubLayout ( sub_layout) = & diff[ 0 ] . new_value {
464
- if let LayoutGroup :: Row { widgets } = & sub_layout[ 0 ] {
465
- if let Widget :: TextLabel ( TextLabel { value, .. } ) = & widgets[ 0 ] . widget {
466
- print_problem_to_terminal_on_failure ( value) ;
415
+ fn check_if_demo_art_opens ( ) {
416
+ futures:: executor:: block_on ( async {
417
+ use crate :: messages:: layout:: utility_types:: widget_prelude:: * ;
418
+
419
+ let print_problem_to_terminal_on_failure = |value : & String | {
420
+ println ! ( ) ;
421
+ println ! ( "-------------------------------------------------" ) ;
422
+ println ! ( "Failed test due to receiving a DisplayDialogError while loading a Graphite demo file." ) ;
423
+ println ! ( ) ;
424
+ println ! ( "DisplayDialogError details:" ) ;
425
+ println ! ( ) ;
426
+ println ! ( "Description: {value}" ) ;
427
+ println ! ( "-------------------------------------------------" ) ;
428
+ println ! ( ) ;
429
+
430
+ panic ! ( )
431
+ } ;
432
+
433
+ init_logger ( ) ;
434
+ let mut editor = Editor :: create ( ) ;
435
+
436
+ // UNCOMMENT THIS FOR RUNNING UNDER MIRI
437
+ //
438
+ // let files = [
439
+ // include_str!("../../demo-artwork/isometric-fountain.graphite"),
440
+ // include_str!("../../demo-artwork/just-a-potted-cactus.graphite"),
441
+ // include_str!("../../demo-artwork/procedural-string-lights.graphite"),
442
+ // include_str!("../../demo-artwork/red-dress.graphite"),
443
+ // include_str!("../../demo-artwork/valley-of-spires.graphite"),
444
+ // ];
445
+ // for (id, document_serialized_content) in files.iter().enumerate() {
446
+ // let document_name = format!("document {id}");
447
+
448
+ for ( document_name, _, file_name) in crate :: messages:: dialog:: simple_dialogs:: ARTWORK {
449
+ let document_serialized_content = std:: fs:: read_to_string ( format ! ( "../demo-artwork/{file_name}" ) ) . unwrap ( ) ;
450
+
451
+ assert_eq ! (
452
+ document_serialized_content. lines( ) . count( ) ,
453
+ 1 ,
454
+ "Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)" ,
455
+ ) ;
456
+
457
+ let responses = editor. handle_message ( PortfolioMessage :: OpenDocumentFile {
458
+ document_name : document_name. into ( ) ,
459
+ document_serialized_content : document_serialized_content. into ( ) ,
460
+ } ) ;
461
+
462
+ // Check if the graph renders
463
+ let portfolio = & mut editor. dispatcher . message_handlers . portfolio_message_handler ;
464
+ portfolio
465
+ . executor
466
+ . submit_node_graph_evaluation ( portfolio. documents . get_mut ( & portfolio. active_document_id . unwrap ( ) ) . unwrap ( ) , glam:: UVec2 :: ONE )
467
+ . expect ( "submit_node_graph_evaluation failed" ) ;
468
+ crate :: node_graph_executor:: run_node_graph ( ) . await ;
469
+ let mut messages = VecDeque :: new ( ) ;
470
+ editor. poll_node_graph_evaluation ( & mut messages) . expect ( "Graph should render" ) ;
471
+
472
+ for response in responses {
473
+ // Check for the existence of the file format incompatibility warning dialog after opening the test file
474
+ if let FrontendMessage :: UpdateDialogColumn1 { layout_target : _, diff } = response {
475
+ if let DiffUpdate :: SubLayout ( sub_layout) = & diff[ 0 ] . new_value {
476
+ if let LayoutGroup :: Row { widgets } = & sub_layout[ 0 ] {
477
+ if let Widget :: TextLabel ( TextLabel { value, .. } ) = & widgets[ 0 ] . widget {
478
+ print_problem_to_terminal_on_failure ( value) ;
479
+ }
467
480
}
468
481
}
469
482
}
470
483
}
471
484
}
472
- }
485
+ } ) ;
473
486
}
474
487
}
0 commit comments