1 // flow-texpack: A program that will allow you to generate texture atlas.
2 // public domain License
4 use assert_cmd::cargo::*;
5 use std::path::PathBuf;
7 use flow_texpack::{Texture, exists_file, remove_dir_all, remove_file};
9 fn verify_texture_size(image_path: &PathBuf, width: u32, height: u32) {
10 let mut t1 = Texture::new();
11 t1.load(image_path, false, false, false, 0, 1024);
12 assert_eq!(t1.width, width);
13 assert_eq!(t1.height, height);
16 fn validate_descriptor_json(json_path: &PathBuf) {
17 let contents = std::fs::read_to_string(json_path).unwrap();
18 let mut lines = contents.lines();
20 assert_eq!(Some("{"), lines.next());
21 assert_eq!(Some("\t\"ImageAtlas\":"), lines.next());
22 assert_eq!(Some("\t{"), lines.next());
23 assert_eq!(Some("\t\t\"info\":"), lines.next());
24 assert_eq!(Some("\t\t{"), lines.next());
25 assert_eq!(Some("\t\t\t\"numberOfAtlasImages\": 1,"), lines.next());
27 Some("\t\t\t\"generatedWith\": \"https://luflow.net/git-repos/flow-texpack.git\""),
30 assert_eq!(Some("\t\t},"), lines.next());
31 assert_eq!(Some("\t\t\"AtlasImage\":"), lines.next());
32 assert_eq!(Some("\t\t["), lines.next());
35 assert_eq!(Some("\t\t\t{"), lines.next());
36 assert_eq!(Some("\t\t\t\t\"n\": \"atlas0.png\","), lines.next());
37 assert_eq!(Some("\t\t\t\t\"numImages\": 2,"), lines.next());
38 assert_eq!(Some("\t\t\t\t\"width\": 64,"), lines.next());
39 assert_eq!(Some("\t\t\t\t\"height\": 64,"), lines.next());
40 assert_eq!(Some("\t\t\t\t\"generateMipMaps\": 1,"), lines.next());
41 assert_eq!(Some("\t\t\t\t\"img\":"), lines.next());
42 assert_eq!(Some("\t\t\t\t["), lines.next());
43 assert_eq!(Some("\t\t\t\t\t{"), lines.next());
46 "\t\t\t\t\t\t\"n\": \"white_32x32.png\", \"x\": 0, \"y\": 0, \"w\": 32, \"h\": 32, \"trimmed\": 0, \"rotated\": 0, \"fx\": 0, \"fy\": 0, \"fw\": 32, \"fh\": 32"
50 assert_eq!(Some("\t\t\t\t\t},"), lines.next());
51 assert_eq!(Some("\t\t\t\t\t{"), lines.next());
54 "\t\t\t\t\t\t\"n\": \"white_32x16.png\", \"x\": 0, \"y\": 36, \"w\": 32, \"h\": 16, \"trimmed\": 0, \"rotated\": 0, \"fx\": 0, \"fy\": 0, \"fw\": 32, \"fh\": 16"
58 assert_eq!(Some("\t\t\t\t\t}"), lines.next());
59 assert_eq!(Some("\t\t\t\t]"), lines.next());
60 assert_eq!(Some("\t\t\t}"), lines.next());
62 assert_eq!(Some("\t\t]"), lines.next());
63 assert_eq!(Some("\t}"), lines.next());
64 assert_eq!(Some("}"), lines.next());
67 fn validate_descriptor_txt(txt_path: &PathBuf, with_header: bool) {
68 let contents = std::fs::read_to_string(txt_path).unwrap();
69 let mut lines = contents.lines();
72 assert_eq!(Some("/*"), lines.next());
74 Some("\t ************************************************"),
78 Some("\t * Generated with: https://luflow.net/git-repos/flow-texpack.git"),
82 Some("\t ************************************************"),
85 assert_eq!(Some(""), lines.next());
87 Some("\t ************************************************"),
90 assert_eq!(Some("\t * Format description:"), lines.next());
92 Some("\t ************************************************"),
95 assert_eq!(Some("\t [info]"), lines.next());
96 assert_eq!(Some("\t numberOfAtlasImages,generatedWith"), lines.next());
97 assert_eq!(Some(""), lines.next());
99 Some("\t [AtlasImage (repeated numberOfAtlasImages)]"),
104 "\t atlasImageName,numberOfImages,atlasImageWidth,atlasImageHeight,generateMipMaps"
108 assert_eq!(Some(""), lines.next());
109 assert_eq!(Some("\t [Image (repeated numberOfImages)]"), lines.next());
112 "\t name,x,y,w,h,trimmed,rotated,fx,fy,fw,fh (NOTE: fx,fy,fw,fh valid if trimmed==1)"
116 assert_eq!(Some(""), lines.next());
117 assert_eq!(Some("\t Text format example:"), lines.next());
118 assert_eq!(Some("\t [info]"), lines.next());
119 assert_eq!(Some("\t [AtlasImage]"), lines.next());
120 assert_eq!(Some("\t [Image]"), lines.next());
121 assert_eq!(Some("\t [Image]"), lines.next());
122 assert_eq!(Some("\t ..."), lines.next());
123 assert_eq!(Some("\t [AtlasImage]"), lines.next());
124 assert_eq!(Some("\t [Image]"), lines.next());
125 assert_eq!(Some("\t [Image]"), lines.next());
126 assert_eq!(Some("\t ..."), lines.next());
127 assert_eq!(Some("*/@"), lines.next());
131 Some("1,https://luflow.net/git-repos/flow-texpack.git"),
134 assert_eq!(Some("atlas0.png,2,64,64,1"), lines.next());
136 Some("white_32x32.png,0,0,32,32,0,0,0,0,32,32"),
140 Some("white_32x16.png,0,36,32,16,0,0,0,0,32,16"),
145 fn get_hash_value(hash_path: &PathBuf) -> u64 {
146 let result = std::fs::read_to_string(hash_path);
148 let old_hash_value = match result {
149 Ok(old_hash_value) => old_hash_value.parse().unwrap(),
153 return old_hash_value;
156 // *************************************************
157 // Integration tests that should fail:
158 // *************************************************
160 fn cli_error_no_arguments() -> Result<(), Box<dyn std::error::Error>> {
161 let mut cmd = cargo_bin_cmd!("flow-texpack");
163 cmd.assert().failure();
169 fn cli_error_no_input() -> Result<(), Box<dyn std::error::Error>> {
170 let mut cmd = cargo_bin_cmd!("flow-texpack");
173 cmd.assert().failure();
179 fn cli_error_no_input_v2() -> Result<(), Box<dyn std::error::Error>> {
180 let mut cmd = cargo_bin_cmd!("flow-texpack");
183 cmd.assert().failure();
189 fn cli_error_no_input_v3() -> Result<(), Box<dyn std::error::Error>> {
190 let mut cmd = cargo_bin_cmd!("flow-texpack");
192 cmd.arg("-i").arg("test_data2");
193 cmd.assert().failure();
199 fn cli_error_no_input_file() -> Result<(), Box<dyn std::error::Error>> {
200 let mut cmd = cargo_bin_cmd!("flow-texpack");
202 cmd.arg("--input-file");
203 cmd.assert().failure();
209 fn cli_error_no_input_file_v2() -> Result<(), Box<dyn std::error::Error>> {
210 let mut cmd = cargo_bin_cmd!("flow-texpack");
212 cmd.arg("--input-file").arg("test_data/input_not_found.txt");
213 cmd.assert().failure();
219 fn cli_error_no_exclude_file() -> Result<(), Box<dyn std::error::Error>> {
220 let mut cmd = cargo_bin_cmd!("flow-texpack");
222 cmd.arg("-i").arg("test_data").arg("--exclude-file");
223 cmd.assert().failure();
229 fn cli_error_no_exclude_file_v2() -> Result<(), Box<dyn std::error::Error>> {
230 let mut cmd = cargo_bin_cmd!("flow-texpack");
234 .arg("--exclude-file")
235 .arg("test_data/exclude_not_found.txt");
236 cmd.assert().failure();
242 fn cli_error_no_output() -> Result<(), Box<dyn std::error::Error>> {
243 let mut cmd = cargo_bin_cmd!("flow-texpack");
245 cmd.arg("-i").arg("test_data").arg("-o");
246 cmd.assert().failure();
252 fn cli_error_no_output_v2() -> Result<(), Box<dyn std::error::Error>> {
253 let mut cmd = cargo_bin_cmd!("flow-texpack");
255 cmd.arg("-i").arg("test_data").arg("--output");
256 cmd.assert().failure();
262 fn cli_error_invalid_atlas_descriptor() -> Result<(), Box<dyn std::error::Error>> {
263 let mut cmd = cargo_bin_cmd!("flow-texpack");
268 .arg("test_data/out/atlas")
269 .arg("--atlas-descriptor")
271 cmd.assert().failure();
277 fn cli_error_invalid_atlas_image() -> Result<(), Box<dyn std::error::Error>> {
278 let mut cmd = cargo_bin_cmd!("flow-texpack");
283 .arg("test_data/out/atlas")
284 .arg("--atlas-image")
286 cmd.assert().failure();
292 fn cli_error_invalid_atlas_size() -> Result<(), Box<dyn std::error::Error>> {
293 let mut cmd = cargo_bin_cmd!("flow-texpack");
298 .arg("test_data/out/atlas")
301 cmd.assert().failure();
307 fn cli_error_invalid_load_filter() -> Result<(), Box<dyn std::error::Error>> {
308 let mut cmd = cargo_bin_cmd!("flow-texpack");
313 .arg("test_data/out/atlas")
314 .arg("--load-filter")
316 cmd.assert().failure();
322 fn cli_error_invalid_max_atlases() -> Result<(), Box<dyn std::error::Error>> {
323 let mut cmd = cargo_bin_cmd!("flow-texpack");
328 .arg("test_data/out/atlas")
329 .arg("--max-atlases")
331 cmd.assert().failure();
337 fn cli_error_invalid_padding() -> Result<(), Box<dyn std::error::Error>> {
338 let mut cmd = cargo_bin_cmd!("flow-texpack");
343 .arg("test_data/out/atlas")
346 cmd.assert().failure();
352 fn cli_error_invalid_padding_v2() -> Result<(), Box<dyn std::error::Error>> {
353 let mut cmd = cargo_bin_cmd!("flow-texpack");
358 .arg("test_data/out/atlas")
361 cmd.assert().failure();
367 fn cli_error_invalid_rect_heuristic() -> Result<(), Box<dyn std::error::Error>> {
368 let mut cmd = cargo_bin_cmd!("flow-texpack");
373 .arg("test_data/out/atlas")
374 .arg("--rect-heuristic")
376 cmd.assert().failure();
381 // *************************************************
382 // Integration tests that should succeed:
383 // *************************************************
385 fn cli_success_input_defaults() -> Result<(), Box<dyn std::error::Error>> {
386 let mut cmd = cargo_bin_cmd!("flow-texpack");
387 let out_file_path = "test_data/cli_success_input_defaults/atlas";
388 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
391 .arg("test_data/white_32x32.png")
394 cmd.assert().success();
396 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
397 let json_path = PathBuf::from(format!("{}.json", out_file_path));
398 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
400 assert_eq!(exists_file(&hash_path), true);
401 assert_eq!(exists_file(&json_path), true);
402 assert_eq!(exists_file(&image_path), true);
403 assert_eq!(get_hash_value(&hash_path) > 0, true);
405 verify_texture_size(&image_path, 64, 64);
407 remove_dir_all(&parent_path);
409 assert_eq!(exists_file(&hash_path), false);
410 assert_eq!(exists_file(&json_path), false);
411 assert_eq!(exists_file(&image_path), false);
417 fn cli_success_input_defaults_v2() -> Result<(), Box<dyn std::error::Error>> {
418 let mut cmd = cargo_bin_cmd!("flow-texpack");
419 let out_file_path = "test_data/cli_success_input_defaults_v2/atlas";
420 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
423 .arg("test_data/white_32x32.png")
426 cmd.assert().success();
428 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
429 let json_path = PathBuf::from(format!("{}.json", out_file_path));
430 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
432 assert_eq!(exists_file(&hash_path), true);
433 assert_eq!(exists_file(&json_path), true);
434 assert_eq!(exists_file(&image_path), true);
435 assert_eq!(get_hash_value(&hash_path) > 0, true);
437 verify_texture_size(&image_path, 64, 64);
439 remove_dir_all(&parent_path);
441 assert_eq!(exists_file(&hash_path), false);
442 assert_eq!(exists_file(&json_path), false);
443 assert_eq!(exists_file(&image_path), false);
449 fn cli_success_input_with_exclude_defaults() -> Result<(), Box<dyn std::error::Error>> {
450 let mut cmd = cargo_bin_cmd!("flow-texpack");
451 let out_file_path = "test_data/cli_success_input_with_exclude_defaults/atlas";
452 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
455 .arg("test_data/white_32x32.png")
456 .arg("test_data/blue_32x32.png")
458 .arg("test_data/white_32x32.png")
461 cmd.assert().success();
463 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
464 let json_path = PathBuf::from(format!("{}.json", out_file_path));
465 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
467 assert_eq!(exists_file(&hash_path), true);
468 assert_eq!(exists_file(&json_path), true);
469 assert_eq!(exists_file(&image_path), true);
470 assert_eq!(get_hash_value(&hash_path) > 0, true);
472 verify_texture_size(&image_path, 64, 64);
474 remove_dir_all(&parent_path);
476 assert_eq!(exists_file(&hash_path), false);
477 assert_eq!(exists_file(&json_path), false);
478 assert_eq!(exists_file(&image_path), false);
484 fn cli_success_input_with_exclude_defaults_v2() -> Result<(), Box<dyn std::error::Error>> {
485 let mut cmd = cargo_bin_cmd!("flow-texpack");
486 let out_file_path = "test_data/cli_success_input_with_exclude_defaults_v2/atlas";
487 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
490 .arg("test_data/white_32x32.png")
491 .arg("test_data/blue_32x32.png")
493 .arg("test_data/white_32x32.png")
496 cmd.assert().success();
498 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
499 let json_path = PathBuf::from(format!("{}.json", out_file_path));
500 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
502 assert_eq!(exists_file(&hash_path), true);
503 assert_eq!(exists_file(&json_path), true);
504 assert_eq!(exists_file(&image_path), true);
505 assert_eq!(get_hash_value(&hash_path) > 0, true);
507 verify_texture_size(&image_path, 64, 64);
509 remove_dir_all(&parent_path);
511 assert_eq!(exists_file(&hash_path), false);
512 assert_eq!(exists_file(&json_path), false);
513 assert_eq!(exists_file(&image_path), false);
519 fn cli_success_input_defaults_verbose() -> Result<(), Box<dyn std::error::Error>> {
520 let mut cmd = cargo_bin_cmd!("flow-texpack");
521 let out_file_path = "test_data/cli_success_input_defaults_verbose/atlas";
522 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
525 .arg("test_data/white_32x32.png")
529 cmd.assert().success();
531 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
532 let json_path = PathBuf::from(format!("{}.json", out_file_path));
533 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
535 assert_eq!(exists_file(&hash_path), true);
536 assert_eq!(exists_file(&json_path), true);
537 assert_eq!(exists_file(&image_path), true);
538 assert_eq!(get_hash_value(&hash_path) > 0, true);
540 verify_texture_size(&image_path, 64, 64);
542 remove_dir_all(&parent_path);
544 assert_eq!(exists_file(&hash_path), false);
545 assert_eq!(exists_file(&json_path), false);
546 assert_eq!(exists_file(&image_path), false);
552 fn cli_success_input_defaults_verbose_v2() -> Result<(), Box<dyn std::error::Error>> {
553 let mut cmd = cargo_bin_cmd!("flow-texpack");
554 let out_file_path = "test_data/cli_success_input_defaults_verbose_v2/atlas";
555 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
558 .arg("test_data/white_32x32.png")
562 cmd.assert().success();
564 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
565 let json_path = PathBuf::from(format!("{}.json", out_file_path));
566 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
568 assert_eq!(exists_file(&hash_path), true);
569 assert_eq!(exists_file(&json_path), true);
570 assert_eq!(exists_file(&image_path), true);
571 assert_eq!(get_hash_value(&hash_path) > 0, true);
573 verify_texture_size(&image_path, 64, 64);
575 remove_dir_all(&parent_path);
577 assert_eq!(exists_file(&hash_path), false);
578 assert_eq!(exists_file(&json_path), false);
579 assert_eq!(exists_file(&image_path), false);
585 fn cli_success_input_defaults_log() -> Result<(), Box<dyn std::error::Error>> {
586 let mut cmd = cargo_bin_cmd!("flow-texpack");
587 let out_file_path = "test_data/cli_success_input_defaults_log/atlas";
588 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
591 .arg("test_data/white_32x32.png")
595 cmd.assert().success();
597 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
598 let json_path = PathBuf::from(format!("{}.json", out_file_path));
599 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
600 let log_path = PathBuf::from("flow-texpack.log");
602 assert_eq!(exists_file(&hash_path), true);
603 assert_eq!(exists_file(&json_path), true);
604 assert_eq!(exists_file(&image_path), true);
605 assert_eq!(get_hash_value(&hash_path) > 0, true);
606 assert_eq!(exists_file(&log_path), true);
608 verify_texture_size(&image_path, 64, 64);
610 remove_dir_all(&parent_path);
611 remove_file(&log_path);
613 assert_eq!(exists_file(&hash_path), false);
614 assert_eq!(exists_file(&json_path), false);
615 assert_eq!(exists_file(&image_path), false);
616 assert_eq!(exists_file(&log_path), false);
622 fn cli_success_input_defaults_version() -> Result<(), Box<dyn std::error::Error>> {
623 let mut cmd = cargo_bin_cmd!("flow-texpack");
626 cmd.assert().success();
632 fn cli_success_input_defaults_version_v2() -> Result<(), Box<dyn std::error::Error>> {
633 let mut cmd = cargo_bin_cmd!("flow-texpack");
635 cmd.arg("--version");
636 cmd.assert().success();
642 fn cli_success_input_defaults_help() -> Result<(), Box<dyn std::error::Error>> {
643 let mut cmd = cargo_bin_cmd!("flow-texpack");
646 cmd.assert().success();
652 fn cli_success_input_defaults_help_v2() -> Result<(), Box<dyn std::error::Error>> {
653 let mut cmd = cargo_bin_cmd!("flow-texpack");
656 cmd.assert().success();
662 fn cli_success_input_defaults_force() -> Result<(), Box<dyn std::error::Error>> {
663 let mut cmd = cargo_bin_cmd!("flow-texpack");
664 let out_file_path = "test_data/cli_success_input_defaults_force/atlas";
665 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
668 .arg("test_data/white_32x32.png")
672 cmd.assert().success();
674 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
675 let json_path = PathBuf::from(format!("{}.json", out_file_path));
676 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
678 assert_eq!(exists_file(&hash_path), true);
679 assert_eq!(exists_file(&json_path), true);
680 assert_eq!(exists_file(&image_path), true);
681 assert_eq!(get_hash_value(&hash_path) == 0, true);
683 verify_texture_size(&image_path, 64, 64);
685 remove_dir_all(&parent_path);
687 assert_eq!(exists_file(&hash_path), false);
688 assert_eq!(exists_file(&json_path), false);
689 assert_eq!(exists_file(&image_path), false);
695 fn cli_success_input_defaults_force_v2() -> Result<(), Box<dyn std::error::Error>> {
696 let mut cmd = cargo_bin_cmd!("flow-texpack");
697 let out_file_path = "test_data/cli_success_input_defaults_force_v2/atlas";
698 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
701 .arg("test_data/white_32x32.png")
705 cmd.assert().success();
707 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
708 let json_path = PathBuf::from(format!("{}.json", out_file_path));
709 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
711 assert_eq!(exists_file(&hash_path), true);
712 assert_eq!(exists_file(&json_path), true);
713 assert_eq!(exists_file(&image_path), true);
714 assert_eq!(get_hash_value(&hash_path) == 0, true);
716 verify_texture_size(&image_path, 64, 64);
718 remove_dir_all(&parent_path);
720 assert_eq!(exists_file(&hash_path), false);
721 assert_eq!(exists_file(&json_path), false);
722 assert_eq!(exists_file(&image_path), false);
728 fn cli_success_input_defaults_force_square() -> Result<(), Box<dyn std::error::Error>> {
729 let mut cmd = cargo_bin_cmd!("flow-texpack");
730 let out_file_path = "test_data/cli_success_input_defaults_force_square/atlas";
731 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
734 .arg("test_data/white_32x16.png")
737 .arg("--force-square");
738 cmd.assert().success();
740 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
741 let json_path = PathBuf::from(format!("{}.json", out_file_path));
742 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
744 assert_eq!(exists_file(&hash_path), true);
745 assert_eq!(exists_file(&json_path), true);
746 assert_eq!(exists_file(&image_path), true);
747 assert_eq!(get_hash_value(&hash_path) > 0, true);
749 verify_texture_size(&image_path, 1024, 1024);
751 remove_dir_all(&parent_path);
753 assert_eq!(exists_file(&hash_path), false);
754 assert_eq!(exists_file(&json_path), false);
755 assert_eq!(exists_file(&image_path), false);
761 fn cli_success_input_defaults_atlas_image_png() -> Result<(), Box<dyn std::error::Error>> {
762 let mut cmd = cargo_bin_cmd!("flow-texpack");
763 let out_file_path = "test_data/cli_success_input_defaults_atlas_image_png/atlas";
764 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
767 .arg("test_data/green_32x32.png")
770 .arg("--atlas-image")
772 cmd.assert().success();
774 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
775 let json_path = PathBuf::from(format!("{}.json", out_file_path));
776 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
778 assert_eq!(exists_file(&hash_path), true);
779 assert_eq!(exists_file(&json_path), true);
780 assert_eq!(exists_file(&image_path), true);
781 assert_eq!(get_hash_value(&hash_path) > 0, true);
783 verify_texture_size(&image_path, 64, 64);
785 remove_dir_all(&parent_path);
787 assert_eq!(exists_file(&hash_path), false);
788 assert_eq!(exists_file(&json_path), false);
789 assert_eq!(exists_file(&image_path), false);
795 fn cli_success_input_defaults_atlas_image_tga() -> Result<(), Box<dyn std::error::Error>> {
796 let mut cmd = cargo_bin_cmd!("flow-texpack");
797 let out_file_path = "test_data/cli_success_input_defaults_atlas_image_tga/atlas";
798 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
801 .arg("test_data/green_32x32.png")
804 .arg("--atlas-image")
806 cmd.assert().success();
808 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
809 let json_path = PathBuf::from(format!("{}.json", out_file_path));
810 let image_path = PathBuf::from(format!("{}0.tga", out_file_path));
812 assert_eq!(exists_file(&hash_path), true);
813 assert_eq!(exists_file(&json_path), true);
814 assert_eq!(exists_file(&image_path), true);
815 assert_eq!(get_hash_value(&hash_path) > 0, true);
817 verify_texture_size(&image_path, 64, 64);
819 remove_dir_all(&parent_path);
821 assert_eq!(exists_file(&hash_path), false);
822 assert_eq!(exists_file(&json_path), false);
823 assert_eq!(exists_file(&image_path), false);
829 fn cli_success_input_defaults_atlas_image_tiff() -> Result<(), Box<dyn std::error::Error>> {
830 let mut cmd = cargo_bin_cmd!("flow-texpack");
831 let out_file_path = "test_data/cli_success_input_defaults_atlas_image_tiff/atlas";
832 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
835 .arg("test_data/green_32x32.png")
838 .arg("--atlas-image")
840 cmd.assert().success();
842 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
843 let json_path = PathBuf::from(format!("{}.json", out_file_path));
844 let image_path = PathBuf::from(format!("{}0.tiff", out_file_path));
846 assert_eq!(exists_file(&hash_path), true);
847 assert_eq!(exists_file(&json_path), true);
848 assert_eq!(exists_file(&image_path), true);
849 assert_eq!(get_hash_value(&hash_path) > 0, true);
851 verify_texture_size(&image_path, 64, 64);
853 remove_dir_all(&parent_path);
855 assert_eq!(exists_file(&hash_path), false);
856 assert_eq!(exists_file(&json_path), false);
857 assert_eq!(exists_file(&image_path), false);
863 fn cli_success_input_defaults_atlas_image_webp() -> Result<(), Box<dyn std::error::Error>> {
864 let mut cmd = cargo_bin_cmd!("flow-texpack");
865 let out_file_path = "test_data/cli_success_input_defaults_atlas_image_webp/atlas";
866 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
869 .arg("test_data/green_32x32.png")
872 .arg("--atlas-image")
874 cmd.assert().success();
876 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
877 let json_path = PathBuf::from(format!("{}.json", out_file_path));
878 let image_path = PathBuf::from(format!("{}0.webp", out_file_path));
880 assert_eq!(exists_file(&hash_path), true);
881 assert_eq!(exists_file(&json_path), true);
882 assert_eq!(exists_file(&image_path), true);
883 assert_eq!(get_hash_value(&hash_path) > 0, true);
885 verify_texture_size(&image_path, 64, 64);
887 remove_dir_all(&parent_path);
889 assert_eq!(exists_file(&hash_path), false);
890 assert_eq!(exists_file(&json_path), false);
891 assert_eq!(exists_file(&image_path), false);
897 fn cli_success_input_defaults_atlas_descriptor_json() -> Result<(), Box<dyn std::error::Error>> {
898 let mut cmd = cargo_bin_cmd!("flow-texpack");
899 let out_file_path = "test_data/cli_success_input_defaults_atlas_descriptor_json/atlas";
900 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
903 .arg("test_data/green_32x32.png")
906 .arg("--atlas-descriptor")
908 cmd.assert().success();
910 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
911 let json_path = PathBuf::from(format!("{}.json", out_file_path));
912 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
914 assert_eq!(exists_file(&hash_path), true);
915 assert_eq!(exists_file(&json_path), true);
916 assert_eq!(exists_file(&image_path), true);
917 assert_eq!(get_hash_value(&hash_path) > 0, true);
919 verify_texture_size(&image_path, 64, 64);
921 remove_dir_all(&parent_path);
923 assert_eq!(exists_file(&hash_path), false);
924 assert_eq!(exists_file(&json_path), false);
925 assert_eq!(exists_file(&image_path), false);
931 fn cli_success_input_defaults_atlas_descriptor_txt() -> Result<(), Box<dyn std::error::Error>> {
932 let mut cmd = cargo_bin_cmd!("flow-texpack");
933 let out_file_path = "test_data/cli_success_input_defaults_atlas_descriptor_txt/atlas";
934 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
937 .arg("test_data/green_32x32.png")
940 .arg("--atlas-descriptor")
942 cmd.assert().success();
944 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
945 let json_path = PathBuf::from(format!("{}.txt", out_file_path));
946 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
948 assert_eq!(exists_file(&hash_path), true);
949 assert_eq!(exists_file(&json_path), true);
950 assert_eq!(exists_file(&image_path), true);
951 assert_eq!(get_hash_value(&hash_path) > 0, true);
953 verify_texture_size(&image_path, 64, 64);
955 remove_dir_all(&parent_path);
957 assert_eq!(exists_file(&hash_path), false);
958 assert_eq!(exists_file(&json_path), false);
959 assert_eq!(exists_file(&image_path), false);
965 fn cli_success_input_defaults_atlas_descriptor_txt_desc() -> Result<(), Box<dyn std::error::Error>>
967 let mut cmd = cargo_bin_cmd!("flow-texpack");
968 let out_file_path = "test_data/cli_success_input_defaults_atlas_descriptor_txt_desc/atlas";
969 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
972 .arg("test_data/green_32x32.png")
975 .arg("--atlas-descriptor")
977 cmd.assert().success();
979 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
980 let json_path = PathBuf::from(format!("{}.txt", out_file_path));
981 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
983 assert_eq!(exists_file(&hash_path), true);
984 assert_eq!(exists_file(&json_path), true);
985 assert_eq!(exists_file(&image_path), true);
986 assert_eq!(get_hash_value(&hash_path) > 0, true);
988 verify_texture_size(&image_path, 64, 64);
990 remove_dir_all(&parent_path);
992 assert_eq!(exists_file(&hash_path), false);
993 assert_eq!(exists_file(&json_path), false);
994 assert_eq!(exists_file(&image_path), false);
1000 fn cli_success_input_defaults_atlas_size_64() -> Result<(), Box<dyn std::error::Error>> {
1001 let mut cmd = cargo_bin_cmd!("flow-texpack");
1002 let out_file_path = "test_data/cli_success_input_defaults_atlas_size_64/atlas";
1003 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1006 .arg("test_data/white_32x32.png")
1009 .arg("--atlas-size")
1011 .arg("--force-square");
1012 cmd.assert().success();
1014 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1015 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1016 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1018 assert_eq!(exists_file(&hash_path), true);
1019 assert_eq!(exists_file(&json_path), true);
1020 assert_eq!(exists_file(&image_path), true);
1021 assert_eq!(get_hash_value(&hash_path) > 0, true);
1023 verify_texture_size(&image_path, 64, 64);
1025 remove_dir_all(&parent_path);
1027 assert_eq!(exists_file(&hash_path), false);
1028 assert_eq!(exists_file(&json_path), false);
1029 assert_eq!(exists_file(&image_path), false);
1035 fn cli_success_input_defaults_atlas_size_128() -> Result<(), Box<dyn std::error::Error>> {
1036 let mut cmd = cargo_bin_cmd!("flow-texpack");
1037 let out_file_path = "test_data/cli_success_input_defaults_atlas_size_128/atlas";
1038 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1041 .arg("test_data/white_32x32.png")
1044 .arg("--atlas-size")
1046 .arg("--force-square");
1047 cmd.assert().success();
1049 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1050 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1051 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1053 assert_eq!(exists_file(&hash_path), true);
1054 assert_eq!(exists_file(&json_path), true);
1055 assert_eq!(exists_file(&image_path), true);
1056 assert_eq!(get_hash_value(&hash_path) > 0, true);
1058 verify_texture_size(&image_path, 128, 128);
1060 remove_dir_all(&parent_path);
1062 assert_eq!(exists_file(&hash_path), false);
1063 assert_eq!(exists_file(&json_path), false);
1064 assert_eq!(exists_file(&image_path), false);
1070 fn cli_success_input_defaults_atlas_size_256() -> Result<(), Box<dyn std::error::Error>> {
1071 let mut cmd = cargo_bin_cmd!("flow-texpack");
1072 let out_file_path = "test_data/cli_success_input_defaults_atlas_size_256/atlas";
1073 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1076 .arg("test_data/white_32x32.png")
1079 .arg("--atlas-size")
1081 .arg("--force-square");
1082 cmd.assert().success();
1084 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1085 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1086 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1088 assert_eq!(exists_file(&hash_path), true);
1089 assert_eq!(exists_file(&json_path), true);
1090 assert_eq!(exists_file(&image_path), true);
1091 assert_eq!(get_hash_value(&hash_path) > 0, true);
1093 verify_texture_size(&image_path, 256, 256);
1095 remove_dir_all(&parent_path);
1097 assert_eq!(exists_file(&hash_path), false);
1098 assert_eq!(exists_file(&json_path), false);
1099 assert_eq!(exists_file(&image_path), false);
1105 fn cli_success_input_defaults_atlas_size_512() -> Result<(), Box<dyn std::error::Error>> {
1106 let mut cmd = cargo_bin_cmd!("flow-texpack");
1107 let out_file_path = "test_data/cli_success_input_defaults_atlas_size_512/atlas";
1108 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1111 .arg("test_data/white_32x32.png")
1114 .arg("--atlas-size")
1116 .arg("--force-square");
1117 cmd.assert().success();
1119 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1120 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1121 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1123 assert_eq!(exists_file(&hash_path), true);
1124 assert_eq!(exists_file(&json_path), true);
1125 assert_eq!(exists_file(&image_path), true);
1126 assert_eq!(get_hash_value(&hash_path) > 0, true);
1128 verify_texture_size(&image_path, 512, 512);
1130 remove_dir_all(&parent_path);
1132 assert_eq!(exists_file(&hash_path), false);
1133 assert_eq!(exists_file(&json_path), false);
1134 assert_eq!(exists_file(&image_path), false);
1140 fn cli_success_input_defaults_atlas_size_1024() -> Result<(), Box<dyn std::error::Error>> {
1141 let mut cmd = cargo_bin_cmd!("flow-texpack");
1142 let out_file_path = "test_data/cli_success_input_defaults_atlas_size_1024/atlas";
1143 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1146 .arg("test_data/white_32x32.png")
1149 .arg("--atlas-size")
1151 .arg("--force-square");
1152 cmd.assert().success();
1154 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1155 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1156 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1158 assert_eq!(exists_file(&hash_path), true);
1159 assert_eq!(exists_file(&json_path), true);
1160 assert_eq!(exists_file(&image_path), true);
1161 assert_eq!(get_hash_value(&hash_path) > 0, true);
1163 verify_texture_size(&image_path, 1024, 1024);
1165 remove_dir_all(&parent_path);
1167 assert_eq!(exists_file(&hash_path), false);
1168 assert_eq!(exists_file(&json_path), false);
1169 assert_eq!(exists_file(&image_path), false);
1175 fn cli_success_input_defaults_atlas_size_2048() -> Result<(), Box<dyn std::error::Error>> {
1176 let mut cmd = cargo_bin_cmd!("flow-texpack");
1177 let out_file_path = "test_data/cli_success_input_defaults_atlas_size_2048/atlas";
1178 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1181 .arg("test_data/white_32x32.png")
1184 .arg("--atlas-size")
1186 .arg("--force-square");
1187 cmd.assert().success();
1189 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1190 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1191 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1193 assert_eq!(exists_file(&hash_path), true);
1194 assert_eq!(exists_file(&json_path), true);
1195 assert_eq!(exists_file(&image_path), true);
1196 assert_eq!(get_hash_value(&hash_path) > 0, true);
1198 verify_texture_size(&image_path, 2048, 2048);
1200 remove_dir_all(&parent_path);
1202 assert_eq!(exists_file(&hash_path), false);
1203 assert_eq!(exists_file(&json_path), false);
1204 assert_eq!(exists_file(&image_path), false);
1210 fn cli_success_input_defaults_atlas_size_4096() -> Result<(), Box<dyn std::error::Error>> {
1211 let mut cmd = cargo_bin_cmd!("flow-texpack");
1212 let out_file_path = "test_data/cli_success_input_defaults_atlas_size_4096/atlas";
1213 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1216 .arg("test_data/white_32x32.png")
1219 .arg("--atlas-size")
1221 .arg("--force-square");
1222 cmd.assert().success();
1224 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1225 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1226 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1228 assert_eq!(exists_file(&hash_path), true);
1229 assert_eq!(exists_file(&json_path), true);
1230 assert_eq!(exists_file(&image_path), true);
1231 assert_eq!(get_hash_value(&hash_path) > 0, true);
1233 verify_texture_size(&image_path, 4096, 4096);
1235 remove_dir_all(&parent_path);
1237 assert_eq!(exists_file(&hash_path), false);
1238 assert_eq!(exists_file(&json_path), false);
1239 assert_eq!(exists_file(&image_path), false);
1245 fn cli_success_input_defaults_atlas_size_8192() -> Result<(), Box<dyn std::error::Error>> {
1246 let mut cmd = cargo_bin_cmd!("flow-texpack");
1247 let out_file_path = "test_data/cli_success_input_defaults_atlas_size_8192/atlas";
1248 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1251 .arg("test_data/white_32x32.png")
1254 .arg("--atlas-size")
1256 .arg("--force-square");
1257 cmd.assert().success();
1259 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1260 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1261 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1263 assert_eq!(exists_file(&hash_path), true);
1264 assert_eq!(exists_file(&json_path), true);
1265 assert_eq!(exists_file(&image_path), true);
1266 assert_eq!(get_hash_value(&hash_path) > 0, true);
1268 verify_texture_size(&image_path, 8192, 8192);
1270 remove_dir_all(&parent_path);
1272 assert_eq!(exists_file(&hash_path), false);
1273 assert_eq!(exists_file(&json_path), false);
1274 assert_eq!(exists_file(&image_path), false);
1280 fn cli_success_input_defaults_rect_heuristic_short_side_fit()
1281 -> Result<(), Box<dyn std::error::Error>> {
1282 let mut cmd = cargo_bin_cmd!("flow-texpack");
1283 let out_file_path = "test_data/cli_success_input_defaults_rect_heuristic_short_side_fit/atlas";
1284 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1287 .arg("test_data/white_32x32.png")
1288 .arg("test_data/red_32x32.png")
1289 .arg("test_data/green_32x32.png")
1290 .arg("test_data/blue_32x32.png")
1295 .arg("--atlas-size")
1297 .arg("--rect-heuristic")
1298 .arg("short-side-fit");
1299 cmd.assert().success();
1301 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1302 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1303 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1305 assert_eq!(exists_file(&hash_path), true);
1306 assert_eq!(exists_file(&json_path), true);
1307 assert_eq!(exists_file(&image_path), true);
1308 assert_eq!(get_hash_value(&hash_path) > 0, true);
1310 verify_texture_size(&image_path, 64, 64);
1312 remove_dir_all(&parent_path);
1314 assert_eq!(exists_file(&hash_path), false);
1315 assert_eq!(exists_file(&json_path), false);
1316 assert_eq!(exists_file(&image_path), false);
1322 fn cli_success_input_defaults_rect_heuristic_long_side_fit()
1323 -> Result<(), Box<dyn std::error::Error>> {
1324 let mut cmd = cargo_bin_cmd!("flow-texpack");
1325 let out_file_path = "test_data/cli_success_input_defaults_rect_heuristic_long_side_fit/atlas";
1326 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1329 .arg("test_data/white_32x32.png")
1330 .arg("test_data/red_32x32.png")
1331 .arg("test_data/green_32x32.png")
1332 .arg("test_data/blue_32x32.png")
1337 .arg("--atlas-size")
1339 .arg("--rect-heuristic")
1340 .arg("long-side-fit");
1341 cmd.assert().success();
1343 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1344 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1345 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1347 assert_eq!(exists_file(&hash_path), true);
1348 assert_eq!(exists_file(&json_path), true);
1349 assert_eq!(exists_file(&image_path), true);
1350 assert_eq!(get_hash_value(&hash_path) > 0, true);
1352 verify_texture_size(&image_path, 64, 64);
1354 remove_dir_all(&parent_path);
1356 assert_eq!(exists_file(&hash_path), false);
1357 assert_eq!(exists_file(&json_path), false);
1358 assert_eq!(exists_file(&image_path), false);
1364 fn cli_success_input_defaults_rect_heuristic_area_fit() -> Result<(), Box<dyn std::error::Error>> {
1365 let mut cmd = cargo_bin_cmd!("flow-texpack");
1366 let out_file_path = "test_data/cli_success_input_defaults_rect_heuristic_area_fit/atlas";
1367 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1370 .arg("test_data/white_32x32.png")
1371 .arg("test_data/red_32x32.png")
1372 .arg("test_data/green_32x32.png")
1373 .arg("test_data/blue_32x32.png")
1378 .arg("--atlas-size")
1380 .arg("--rect-heuristic")
1382 cmd.assert().success();
1384 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1385 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1386 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1388 assert_eq!(exists_file(&hash_path), true);
1389 assert_eq!(exists_file(&json_path), true);
1390 assert_eq!(exists_file(&image_path), true);
1391 assert_eq!(get_hash_value(&hash_path) > 0, true);
1393 verify_texture_size(&image_path, 64, 64);
1395 remove_dir_all(&parent_path);
1397 assert_eq!(exists_file(&hash_path), false);
1398 assert_eq!(exists_file(&json_path), false);
1399 assert_eq!(exists_file(&image_path), false);
1405 fn cli_success_input_defaults_rect_heuristic_bottom_left() -> Result<(), Box<dyn std::error::Error>>
1407 let mut cmd = cargo_bin_cmd!("flow-texpack");
1408 let out_file_path = "test_data/cli_success_input_defaults_rect_heuristic_bottom_left/atlas";
1409 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1412 .arg("test_data/white_32x32.png")
1413 .arg("test_data/red_32x32.png")
1414 .arg("test_data/green_32x32.png")
1415 .arg("test_data/blue_32x32.png")
1420 .arg("--atlas-size")
1422 .arg("--rect-heuristic")
1423 .arg("bottom-left");
1424 cmd.assert().success();
1426 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1427 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1428 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1430 assert_eq!(exists_file(&hash_path), true);
1431 assert_eq!(exists_file(&json_path), true);
1432 assert_eq!(exists_file(&image_path), true);
1433 assert_eq!(get_hash_value(&hash_path) > 0, true);
1435 verify_texture_size(&image_path, 64, 64);
1437 remove_dir_all(&parent_path);
1439 assert_eq!(exists_file(&hash_path), false);
1440 assert_eq!(exists_file(&json_path), false);
1441 assert_eq!(exists_file(&image_path), false);
1447 fn cli_success_input_defaults_rect_heuristic_contact_point()
1448 -> Result<(), Box<dyn std::error::Error>> {
1449 let mut cmd = cargo_bin_cmd!("flow-texpack");
1450 let out_file_path = "test_data/cli_success_input_defaults_rect_heuristic_contact_point/atlas";
1451 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1454 .arg("test_data/white_32x32.png")
1455 .arg("test_data/red_32x32.png")
1456 .arg("test_data/green_32x32.png")
1457 .arg("test_data/blue_32x32.png")
1462 .arg("--atlas-size")
1464 .arg("--rect-heuristic")
1465 .arg("contact-point");
1466 cmd.assert().success();
1468 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1469 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1470 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1472 assert_eq!(exists_file(&hash_path), true);
1473 assert_eq!(exists_file(&json_path), true);
1474 assert_eq!(exists_file(&image_path), true);
1475 assert_eq!(get_hash_value(&hash_path) > 0, true);
1477 verify_texture_size(&image_path, 64, 64);
1479 remove_dir_all(&parent_path);
1481 assert_eq!(exists_file(&hash_path), false);
1482 assert_eq!(exists_file(&json_path), false);
1483 assert_eq!(exists_file(&image_path), false);
1489 fn cli_success_input_defaults_premultiply() -> Result<(), Box<dyn std::error::Error>> {
1490 let mut cmd = cargo_bin_cmd!("flow-texpack");
1491 let out_file_path = "test_data/cli_success_input_defaults_premultiply/atlas";
1492 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1495 .arg("test_data/white_32x32.png")
1500 cmd.assert().success();
1502 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1503 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1504 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1506 assert_eq!(exists_file(&hash_path), true);
1507 assert_eq!(exists_file(&json_path), true);
1508 assert_eq!(exists_file(&image_path), true);
1509 assert_eq!(get_hash_value(&hash_path) > 0, true);
1511 verify_texture_size(&image_path, 32, 32);
1513 remove_dir_all(&parent_path);
1515 assert_eq!(exists_file(&hash_path), false);
1516 assert_eq!(exists_file(&json_path), false);
1517 assert_eq!(exists_file(&image_path), false);
1523 fn cli_success_input_defaults_trim() -> Result<(), Box<dyn std::error::Error>> {
1524 let mut cmd = cargo_bin_cmd!("flow-texpack");
1525 let out_file_path = "test_data/cli_success_input_defaults_trim/atlas";
1526 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1529 .arg("test_data/blue_trimmable_128x128.png")
1535 cmd.assert().success();
1537 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1538 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1539 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1541 assert_eq!(exists_file(&hash_path), true);
1542 assert_eq!(exists_file(&json_path), true);
1543 assert_eq!(exists_file(&image_path), true);
1544 assert_eq!(get_hash_value(&hash_path) > 0, true);
1546 verify_texture_size(&image_path, 32, 32);
1548 remove_dir_all(&parent_path);
1550 assert_eq!(exists_file(&hash_path), false);
1551 assert_eq!(exists_file(&json_path), false);
1552 assert_eq!(exists_file(&image_path), false);
1558 fn cli_success_input_defaults_unique() -> Result<(), Box<dyn std::error::Error>> {
1559 let mut cmd = cargo_bin_cmd!("flow-texpack");
1560 let out_file_path = "test_data/cli_success_input_defaults_unique/atlas";
1561 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1564 .arg("test_data/white_128x128.png")
1565 .arg("test_data/white_128x128_v2.png")
1571 cmd.assert().success();
1573 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1574 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1575 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1577 assert_eq!(exists_file(&hash_path), true);
1578 assert_eq!(exists_file(&json_path), true);
1579 assert_eq!(exists_file(&image_path), true);
1580 assert_eq!(get_hash_value(&hash_path) > 0, true);
1582 verify_texture_size(&image_path, 128, 128);
1584 remove_dir_all(&parent_path);
1586 assert_eq!(exists_file(&hash_path), false);
1587 assert_eq!(exists_file(&json_path), false);
1588 assert_eq!(exists_file(&image_path), false);
1594 fn cli_success_input_defaults_rotate() -> Result<(), Box<dyn std::error::Error>> {
1595 let mut cmd = cargo_bin_cmd!("flow-texpack");
1596 let out_file_path = "test_data/cli_success_input_defaults_rotate/atlas";
1597 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1600 .arg("test_data/white_128x64.png")
1601 .arg("test_data/white_32x16.png")
1604 .arg("--rect-heuristic")
1605 .arg("long-side-fit")
1607 cmd.assert().success();
1609 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1610 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1611 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1613 assert_eq!(exists_file(&hash_path), true);
1614 assert_eq!(exists_file(&json_path), true);
1615 assert_eq!(exists_file(&image_path), true);
1616 assert_eq!(get_hash_value(&hash_path) > 0, true);
1618 verify_texture_size(&image_path, 256, 128);
1620 remove_dir_all(&parent_path);
1622 assert_eq!(exists_file(&hash_path), false);
1623 assert_eq!(exists_file(&json_path), false);
1624 assert_eq!(exists_file(&image_path), false);
1630 fn cli_success_input_defaults_adjust_size() -> Result<(), Box<dyn std::error::Error>> {
1631 let mut cmd = cargo_bin_cmd!("flow-texpack");
1632 let out_file_path = "test_data/cli_success_input_defaults_adjust_size/atlas";
1633 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1636 .arg("test_data/white_128x128.png")
1639 .arg("--atlas-size")
1643 .arg("--adjust-size");
1644 cmd.assert().success();
1646 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1647 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1648 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1650 assert_eq!(exists_file(&hash_path), true);
1651 assert_eq!(exists_file(&json_path), true);
1652 assert_eq!(exists_file(&image_path), true);
1653 assert_eq!(get_hash_value(&hash_path) > 0, true);
1655 verify_texture_size(&image_path, 128, 128);
1657 remove_dir_all(&parent_path);
1659 assert_eq!(exists_file(&hash_path), false);
1660 assert_eq!(exists_file(&json_path), false);
1661 assert_eq!(exists_file(&image_path), false);
1667 fn cli_success_input_defaults_adjust_fit() -> Result<(), Box<dyn std::error::Error>> {
1668 let mut cmd = cargo_bin_cmd!("flow-texpack");
1669 let out_file_path = "test_data/cli_success_input_defaults_adjust_fit/atlas";
1670 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1673 .arg("test_data/white_128x128.png")
1676 .arg("--atlas-size")
1680 .arg("--adjust-fit");
1681 cmd.assert().success();
1683 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1684 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1685 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1687 assert_eq!(exists_file(&hash_path), true);
1688 assert_eq!(exists_file(&json_path), true);
1689 assert_eq!(exists_file(&image_path), true);
1690 assert_eq!(get_hash_value(&hash_path) > 0, true);
1692 verify_texture_size(&image_path, 64, 64);
1694 remove_dir_all(&parent_path);
1696 assert_eq!(exists_file(&hash_path), false);
1697 assert_eq!(exists_file(&json_path), false);
1698 assert_eq!(exists_file(&image_path), false);
1704 fn cli_success_input_defaults_validate_descriptor_json() -> Result<(), Box<dyn std::error::Error>> {
1705 let mut cmd = cargo_bin_cmd!("flow-texpack");
1706 let out_file_path = "test_data/cli_success_input_defaults_validate_descriptor_json/atlas";
1707 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1710 .arg("test_data/white_32x32.png")
1711 .arg("test_data/white_32x16.png")
1714 .arg("--atlas-size")
1716 .arg("--generate-mipmaps")
1719 cmd.assert().success();
1721 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1722 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1723 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1725 assert_eq!(exists_file(&hash_path), true);
1726 assert_eq!(exists_file(&json_path), true);
1727 assert_eq!(exists_file(&image_path), true);
1728 assert_eq!(get_hash_value(&hash_path) > 0, true);
1730 verify_texture_size(&image_path, 64, 64);
1731 validate_descriptor_json(&json_path);
1733 remove_dir_all(&parent_path);
1735 assert_eq!(exists_file(&hash_path), false);
1736 assert_eq!(exists_file(&json_path), false);
1737 assert_eq!(exists_file(&image_path), false);
1743 fn cli_success_input_defaults_validate_descriptor_txt() -> Result<(), Box<dyn std::error::Error>> {
1744 let mut cmd = cargo_bin_cmd!("flow-texpack");
1745 let out_file_path = "test_data/cli_success_input_defaults_validate_descriptor_txt/atlas";
1746 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1749 .arg("test_data/white_32x32.png")
1750 .arg("test_data/white_32x16.png")
1753 .arg("--atlas-size")
1755 .arg("--atlas-descriptor")
1757 .arg("--generate-mipmaps")
1760 cmd.assert().success();
1762 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1763 let txt_path = PathBuf::from(format!("{}.txt", out_file_path));
1764 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1766 assert_eq!(exists_file(&hash_path), true);
1767 assert_eq!(exists_file(&txt_path), true);
1768 assert_eq!(exists_file(&image_path), true);
1769 assert_eq!(get_hash_value(&hash_path) > 0, true);
1771 verify_texture_size(&image_path, 64, 64);
1772 validate_descriptor_txt(&txt_path, false);
1774 remove_dir_all(&parent_path);
1776 assert_eq!(exists_file(&hash_path), false);
1777 assert_eq!(exists_file(&txt_path), false);
1778 assert_eq!(exists_file(&image_path), false);
1784 fn cli_success_input_defaults_validate_descriptor_txt_header()
1785 -> Result<(), Box<dyn std::error::Error>> {
1786 let mut cmd = cargo_bin_cmd!("flow-texpack");
1787 let out_file_path = "test_data/cli_success_input_defaults_validate_descriptor_txt_header/atlas";
1788 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1791 .arg("test_data/white_32x32.png")
1792 .arg("test_data/white_32x16.png")
1795 .arg("--atlas-size")
1797 .arg("--atlas-descriptor")
1799 .arg("--generate-mipmaps")
1802 cmd.assert().success();
1804 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1805 let txt_path = PathBuf::from(format!("{}.txt", out_file_path));
1806 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1808 assert_eq!(exists_file(&hash_path), true);
1809 assert_eq!(exists_file(&txt_path), true);
1810 assert_eq!(exists_file(&image_path), true);
1811 assert_eq!(get_hash_value(&hash_path) > 0, true);
1813 verify_texture_size(&image_path, 64, 64);
1814 validate_descriptor_txt(&txt_path, true);
1816 remove_dir_all(&parent_path);
1818 assert_eq!(exists_file(&hash_path), false);
1819 assert_eq!(exists_file(&txt_path), false);
1820 assert_eq!(exists_file(&image_path), false);
1826 fn cli_success_input_defaults_load_filter_bmp() -> Result<(), Box<dyn std::error::Error>> {
1827 let mut cmd = cargo_bin_cmd!("flow-texpack");
1828 let out_file_path = "test_data/cli_success_input_defaults_load_filter_bmp/atlas";
1829 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1832 .arg("test_data/white_32x32.bmp")
1833 .arg("test_data/white_128x128.png")
1836 .arg("--load-filter")
1838 cmd.assert().success();
1840 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1841 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1842 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1844 assert_eq!(exists_file(&hash_path), true);
1845 assert_eq!(exists_file(&json_path), true);
1846 assert_eq!(exists_file(&image_path), true);
1847 assert_eq!(get_hash_value(&hash_path) > 0, true);
1849 verify_texture_size(&image_path, 64, 64);
1851 remove_dir_all(&parent_path);
1853 assert_eq!(exists_file(&hash_path), false);
1854 assert_eq!(exists_file(&json_path), false);
1855 assert_eq!(exists_file(&image_path), false);
1861 fn cli_success_input_defaults_load_filter_hdr() -> Result<(), Box<dyn std::error::Error>> {
1862 let mut cmd = cargo_bin_cmd!("flow-texpack");
1863 let out_file_path = "test_data/cli_success_input_defaults_load_filter_hdr/atlas";
1864 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1867 .arg("test_data/white_32x32.hdr")
1868 .arg("test_data/white_128x128.png")
1871 .arg("--load-filter")
1873 cmd.assert().success();
1875 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1876 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1877 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1879 assert_eq!(exists_file(&hash_path), true);
1880 assert_eq!(exists_file(&json_path), true);
1881 assert_eq!(exists_file(&image_path), true);
1882 assert_eq!(get_hash_value(&hash_path) > 0, true);
1884 verify_texture_size(&image_path, 64, 64);
1886 remove_dir_all(&parent_path);
1888 assert_eq!(exists_file(&hash_path), false);
1889 assert_eq!(exists_file(&json_path), false);
1890 assert_eq!(exists_file(&image_path), false);
1896 fn cli_success_input_defaults_load_filter_jpg() -> Result<(), Box<dyn std::error::Error>> {
1897 let mut cmd = cargo_bin_cmd!("flow-texpack");
1898 let out_file_path = "test_data/cli_success_input_defaults_load_filter_jpg/atlas";
1899 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1902 .arg("test_data/white_32x32.jpg")
1903 .arg("test_data/white_128x128.png")
1906 .arg("--load-filter")
1908 cmd.assert().success();
1910 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1911 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1912 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1914 assert_eq!(exists_file(&hash_path), true);
1915 assert_eq!(exists_file(&json_path), true);
1916 assert_eq!(exists_file(&image_path), true);
1917 assert_eq!(get_hash_value(&hash_path) > 0, true);
1919 verify_texture_size(&image_path, 64, 64);
1921 remove_dir_all(&parent_path);
1923 assert_eq!(exists_file(&hash_path), false);
1924 assert_eq!(exists_file(&json_path), false);
1925 assert_eq!(exists_file(&image_path), false);
1931 fn cli_success_input_defaults_load_filter_png() -> Result<(), Box<dyn std::error::Error>> {
1932 let mut cmd = cargo_bin_cmd!("flow-texpack");
1933 let out_file_path = "test_data/cli_success_input_defaults_load_filter_png/atlas";
1934 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1937 .arg("test_data/white_32x32.png")
1938 .arg("test_data/white_128x128.png")
1941 .arg("--load-filter")
1943 cmd.assert().success();
1945 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1946 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1947 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1949 assert_eq!(exists_file(&hash_path), true);
1950 assert_eq!(exists_file(&json_path), true);
1951 assert_eq!(exists_file(&image_path), true);
1952 assert_eq!(get_hash_value(&hash_path) > 0, true);
1954 verify_texture_size(&image_path, 256, 256);
1956 remove_dir_all(&parent_path);
1958 assert_eq!(exists_file(&hash_path), false);
1959 assert_eq!(exists_file(&json_path), false);
1960 assert_eq!(exists_file(&image_path), false);
1966 fn cli_success_input_defaults_load_filter_tga() -> Result<(), Box<dyn std::error::Error>> {
1967 let mut cmd = cargo_bin_cmd!("flow-texpack");
1968 let out_file_path = "test_data/cli_success_input_defaults_load_filter_tga/atlas";
1969 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
1972 .arg("test_data/white_32x32.tga")
1973 .arg("test_data/white_128x128.png")
1976 .arg("--load-filter")
1978 cmd.assert().success();
1980 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
1981 let json_path = PathBuf::from(format!("{}.json", out_file_path));
1982 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
1984 assert_eq!(exists_file(&hash_path), true);
1985 assert_eq!(exists_file(&json_path), true);
1986 assert_eq!(exists_file(&image_path), true);
1987 assert_eq!(get_hash_value(&hash_path) > 0, true);
1989 verify_texture_size(&image_path, 64, 64);
1991 remove_dir_all(&parent_path);
1993 assert_eq!(exists_file(&hash_path), false);
1994 assert_eq!(exists_file(&json_path), false);
1995 assert_eq!(exists_file(&image_path), false);
2001 fn cli_success_input_defaults_load_filter_tiff() -> Result<(), Box<dyn std::error::Error>> {
2002 let mut cmd = cargo_bin_cmd!("flow-texpack");
2003 let out_file_path = "test_data/cli_success_input_defaults_load_filter_tiff/atlas";
2004 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
2007 .arg("test_data/white_32x32.tiff")
2008 .arg("test_data/white_128x128.png")
2011 .arg("--load-filter")
2013 cmd.assert().success();
2015 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
2016 let json_path = PathBuf::from(format!("{}.json", out_file_path));
2017 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
2019 assert_eq!(exists_file(&hash_path), true);
2020 assert_eq!(exists_file(&json_path), true);
2021 assert_eq!(exists_file(&image_path), true);
2022 assert_eq!(get_hash_value(&hash_path) > 0, true);
2024 verify_texture_size(&image_path, 64, 64);
2026 remove_dir_all(&parent_path);
2028 assert_eq!(exists_file(&hash_path), false);
2029 assert_eq!(exists_file(&json_path), false);
2030 assert_eq!(exists_file(&image_path), false);
2036 fn cli_success_input_defaults_load_filter_webp() -> Result<(), Box<dyn std::error::Error>> {
2037 let mut cmd = cargo_bin_cmd!("flow-texpack");
2038 let out_file_path = "test_data/cli_success_input_defaults_load_filter_webp/atlas";
2039 let parent_path = PathBuf::from(PathBuf::from(out_file_path).parent().unwrap());
2042 .arg("test_data/white_32x32.webp")
2043 .arg("test_data/white_128x128.png")
2046 .arg("--load-filter")
2048 cmd.assert().success();
2050 let hash_path = PathBuf::from(format!("{}.hash", out_file_path));
2051 let json_path = PathBuf::from(format!("{}.json", out_file_path));
2052 let image_path = PathBuf::from(format!("{}0.png", out_file_path));
2054 assert_eq!(exists_file(&hash_path), true);
2055 assert_eq!(exists_file(&json_path), true);
2056 assert_eq!(exists_file(&image_path), true);
2057 assert_eq!(get_hash_value(&hash_path) > 0, true);
2059 verify_texture_size(&image_path, 64, 64);
2061 remove_dir_all(&parent_path);
2063 assert_eq!(exists_file(&hash_path), false);
2064 assert_eq!(exists_file(&json_path), false);
2065 assert_eq!(exists_file(&image_path), false);