Automatically include all demo artwork in test

This commit is contained in:
Keavon Chambers 2024-02-08 01:07:47 -08:00
parent 9edd9233db
commit 1bf62d92c2
3 changed files with 11 additions and 7 deletions

View File

@ -469,13 +469,15 @@ mod test {
init_logger(); init_logger();
let mut editor = Editor::create(); let mut editor = Editor::create();
let test_files = [ for (document_name, _, file_name) in crate::messages::dialog::simple_dialogs::ARTWORK {
("Just a Potted Cactus", include_str!("../../demo-artwork/just-a-potted-cactus.graphite")), let document_serialized_content = std::fs::read_to_string(format!("../demo-artwork/{file_name}")).unwrap();
("Valley of Spires", include_str!("../../demo-artwork/procedural-string-lights.graphite")),
("Valley of Spires", include_str!("../../demo-artwork/valley-of-spires.graphite")), assert_eq!(
]; document_serialized_content.lines().count(),
1,
"Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)",
);
for (document_name, document_serialized_content) in test_files {
let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile { let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile {
document_name: document_name.into(), document_name: document_name.into(),
document_serialized_content: document_serialized_content.into(), document_serialized_content: document_serialized_content.into(),

View File

@ -5,7 +5,7 @@ use crate::messages::prelude::*;
pub struct DemoArtworkDialog; pub struct DemoArtworkDialog;
/// `(name, thumbnail, filename)` /// `(name, thumbnail, filename)`
const ARTWORK: [(&str, &str, &str); 4] = [ pub const ARTWORK: [(&str, &str, &str); 4] = [
("Valley of Spires", "ThumbnailValleyOfSpires", "valley-of-spires.graphite"), ("Valley of Spires", "ThumbnailValleyOfSpires", "valley-of-spires.graphite"),
("Red Dress", "ThumbnailRedDress", "red-dress.graphite"), ("Red Dress", "ThumbnailRedDress", "red-dress.graphite"),
("Just a Potted Cactus", "ThumbnailJustAPottedCactus", "just-a-potted-cactus.graphite"), ("Just a Potted Cactus", "ThumbnailJustAPottedCactus", "just-a-potted-cactus.graphite"),

View File

@ -13,3 +13,5 @@ pub use coming_soon_dialog::ComingSoonDialog;
pub use demo_artwork_dialog::DemoArtworkDialog; pub use demo_artwork_dialog::DemoArtworkDialog;
pub use error_dialog::ErrorDialog; pub use error_dialog::ErrorDialog;
pub use licenses_dialog::LicensesDialog; pub use licenses_dialog::LicensesDialog;
pub use demo_artwork_dialog::ARTWORK;