From aced659499bd5b4ac3716104e256ed07d26abb0a Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Thu, 26 Sep 2024 00:30:12 +0800 Subject: [PATCH] fixed the testcase having faulty handling of extensions --- martin/src/sprites/mod.rs | 4 +-- .../fixtures/sprites/expected/all_1_sdf.json | 34 ++++++++++++++++++ tests/fixtures/sprites/expected/all_1_sdf.png | Bin 0 -> 785 bytes .../fixtures/sprites/expected/all_2_sdf.json | 34 ++++++++++++++++++ tests/fixtures/sprites/expected/all_2_sdf.png | Bin 0 -> 1567 bytes .../fixtures/sprites/expected/src1_1_sdf.json | 26 ++++++++++++++ .../fixtures/sprites/expected/src1_1_sdf.png | Bin 0 -> 758 bytes .../fixtures/sprites/expected/src1_2_sdf.json | 26 ++++++++++++++ .../fixtures/sprites/expected/src1_2_sdf.png | Bin 0 -> 1515 bytes .../fixtures/sprites/expected/src2_1_sdf.json | 10 ++++++ .../fixtures/sprites/expected/src2_1_sdf.png | Bin 0 -> 189 bytes .../fixtures/sprites/expected/src2_2_sdf.json | 10 ++++++ .../fixtures/sprites/expected/src2_2_sdf.png | Bin 0 -> 344 bytes 13 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/sprites/expected/all_1_sdf.json create mode 100644 tests/fixtures/sprites/expected/all_1_sdf.png create mode 100644 tests/fixtures/sprites/expected/all_2_sdf.json create mode 100644 tests/fixtures/sprites/expected/all_2_sdf.png create mode 100644 tests/fixtures/sprites/expected/src1_1_sdf.json create mode 100644 tests/fixtures/sprites/expected/src1_1_sdf.png create mode 100644 tests/fixtures/sprites/expected/src1_2_sdf.json create mode 100644 tests/fixtures/sprites/expected/src1_2_sdf.png create mode 100644 tests/fixtures/sprites/expected/src2_1_sdf.json create mode 100644 tests/fixtures/sprites/expected/src2_1_sdf.png create mode 100644 tests/fixtures/sprites/expected/src2_2_sdf.json create mode 100644 tests/fixtures/sprites/expected/src2_2_sdf.png diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index e78fb0902..5d96f13b7 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -255,7 +255,7 @@ mod tests { //.sdf => generate sdf from png, add sdf == true //- => does not generate sdf, omits sdf == true - for extension in [".sdf", ""] { + for extension in ["_sdf", ""] { test_src(sprites.values(), 1, "all_1", extension).await; test_src(sprites.values(), 2, "all_2", extension).await; @@ -276,7 +276,7 @@ mod tests { let path = PathBuf::from(format!( "../tests/fixtures/sprites/expected/{filename}{extension}" )); - let sprites = get_spritesheet(sources, pixel_ratio, extension == ".sdf") + let sprites = get_spritesheet(sources, pixel_ratio, extension == "_sdf") .await .unwrap(); let mut json = serde_json::to_string_pretty(sprites.get_index()).unwrap(); diff --git a/tests/fixtures/sprites/expected/all_1_sdf.json b/tests/fixtures/sprites/expected/all_1_sdf.json new file mode 100644 index 000000000..1ca1cd595 --- /dev/null +++ b/tests/fixtures/sprites/expected/all_1_sdf.json @@ -0,0 +1,34 @@ +{ + "another_bicycle": { + "height": 15, + "pixelRatio": 1, + "width": 15, + "x": 20, + "y": 16, + "sdf": true + }, + "bear": { + "height": 16, + "pixelRatio": 1, + "width": 16, + "x": 20, + "y": 0, + "sdf": true + }, + "bicycle": { + "height": 15, + "pixelRatio": 1, + "width": 15, + "x": 35, + "y": 16, + "sdf": true + }, + "sub/circle": { + "height": 20, + "pixelRatio": 1, + "width": 20, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/all_1_sdf.png b/tests/fixtures/sprites/expected/all_1_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..ffb3546925d2136c95e615982d07ad025b0077b1 GIT binary patch literal 785 zcmV+s1Md8ZP)=B?mot@{dB2B1GuLlM8yW9Oy`WDNkQ17yH(lJ_CT z7_uHse62o#Z%bwPR4Kwj#;g|1zF5%=AIm4AaU{NDAC6%R#-e6nYIuXoL`e_=^1kK) z&Mqc~e0%RA6wK(a{9qXV#+jkRKbPmOx$&s&kO`MLjZn#$4V>l0TjwZYe=g5W0cswP z>#M3Jl7gT}!>Rjcmrt$u8t@QTZGPf-1GOq9LV{}yMw%L-Fc`^Uf`OQbq*YfVt7<}C zm4}INEr4(TGheqGNKiBS$vxhn45Euxm$; zYoxFDfP3>}493n3hxe-*vA8$8Q(o`#SKM3s^Wr?*OpU>VtCz6t5-(0Xt~qY>BnRjxGi7bIscLKL$SqRqNPd5n~{m7;^am<6CWOBeqb4L8ZkImgEo9g5Rj#@ zqws3_41Po+@!i=QNGz=sr45vq%!l}GZbTJ!O)^3c#YayuO&m4bkEq- zX9WE7mi+Td+77`IOnTZ$N+zVF?EnnHI=x>PTop zB%Mg0rsan%Ewwvqe&cFdei&2|acak@t^18DX_+C<63|ok8&}f)M;GEZGHKe$PrH)| P00000NkvXXu0mjfNXl@1 literal 0 HcmV?d00001 diff --git a/tests/fixtures/sprites/expected/all_2_sdf.json b/tests/fixtures/sprites/expected/all_2_sdf.json new file mode 100644 index 000000000..5d1fb2e53 --- /dev/null +++ b/tests/fixtures/sprites/expected/all_2_sdf.json @@ -0,0 +1,34 @@ +{ + "another_bicycle": { + "height": 30, + "pixelRatio": 2, + "width": 30, + "x": 40, + "y": 32, + "sdf": true + }, + "bear": { + "height": 32, + "pixelRatio": 2, + "width": 32, + "x": 40, + "y": 0, + "sdf": true + }, + "bicycle": { + "height": 30, + "pixelRatio": 2, + "width": 30, + "x": 70, + "y": 32, + "sdf": true + }, + "sub/circle": { + "height": 40, + "pixelRatio": 2, + "width": 40, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/all_2_sdf.png b/tests/fixtures/sprites/expected/all_2_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..e1ce6514bfef7520f22e378a4d87aece82c7f688 GIT binary patch literal 1567 zcmaJ>dpOg37@s35w>IYxA|f(VM$F|Xmou?pw2dK`q1+v-gtBZo<(m5}vbl`Zazdt% z%amI#MVQVgJV&R<+>)Hk<@}zbJm;_TKF{}kKkw!9e&6@|$2Zv-V=FD8Bmn|}q)~QA zEMU(9=j0wyK!1c{RzV;UuCoK)25=YptBQ#5EdYT)9kkF}Zra;8*9Eo>xHm)SF4{mg z2mdWqK|}gu3g#+jv`-hudx!{CA96u$MZe(^F84C z?(j%|LavJrFarf=l8Vu~hSDIQt$;NnP9F3$RK)A;H`CWOh3i;p%32+kHPTRkX&!=W z9MDseKBgqCq9Cs+Cm|yxDYbVu@D!;ti~zupBe5792n>j-nwlCM4mY>3u(Y&9p`Dza zoe4ffVg!jqqEIMQDm5b`BQrCzfKgObT+Ax3s;aJT4KMI4CM^fHQ|@{ zrrkOGe1Uju$H4+~W7r)A(;Pvi;`ZD4&wziBIcn5iaJMx;TT14j?QxlgSH|Cr}!}7kn^^7{Pz#FMES^a6#NB!**tKQ#UpfuMZ)?0j}CP6jU$&H^R zBiU@=TkqPO%6rr@wS_tU=&x90!>%w}=8&JVU1pb+ zy6rm!ETYkY?W)+ZLN;_X-LU4TW1jNJspG?vk+r5>E4%#?246wzC1@aGh2y25Q_ZhM zF06^l;*&5>ZOSS>mt*-wDrOUXtf59-=zT}ASMzWBSU8d#RKzDf<*BKe7~yvLWG~Ll z#P;rF4U86#I3@QpfQc8A%4I|omys9};tm;eqc-J7#tUc>^O&sMP!tJKwz{smA?Ybm Ve{~mr*&O&LKqwmwveKFu{}0I}$vOZ4 literal 0 HcmV?d00001 diff --git a/tests/fixtures/sprites/expected/src1_1_sdf.json b/tests/fixtures/sprites/expected/src1_1_sdf.json new file mode 100644 index 000000000..05675714b --- /dev/null +++ b/tests/fixtures/sprites/expected/src1_1_sdf.json @@ -0,0 +1,26 @@ +{ + "another_bicycle": { + "height": 15, + "pixelRatio": 1, + "width": 15, + "x": 20, + "y": 16, + "sdf": true + }, + "bear": { + "height": 16, + "pixelRatio": 1, + "width": 16, + "x": 20, + "y": 0, + "sdf": true + }, + "sub/circle": { + "height": 20, + "pixelRatio": 1, + "width": 20, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/src1_1_sdf.png b/tests/fixtures/sprites/expected/src1_1_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..b3c301e8271c15e67ee8cc03248ad96fd6c5fe1e GIT binary patch literal 758 zcmV+ zBHA*&OvLt}ld(f`8KRd)JPZ%Ac^oJ|-!J@LiCIF7P1?(T@FjWg{oZ?@{NC^VB6t}H z!YGr<)MNsZPJJ1#d2jEI551f`z4|Oa05v(g@S}H%P(eN*N&bRP+#u> zUdb&Vt4I#V_j4dE?4;($_FlQts={9u=HO<23?5v)gl#UXfMS`jSLj@**PcwxrDANe zue7nJ-rPC=$?b<~h5%y<4pXGW#A0P~!wcr)WBDf@uN#mUW^^dARi3cw*im>reFlHF zD17I+gTf=ryFr!O`niT~1l4UAkK^;tDe@78U}nJtM3n46aGqG?Py zTRTTUF`-K)GU@bwooSt^!Bn8WjzQEZ5;{GrOa?`!NPR$lV$?9}^yF<|su7GxU?x+V z`_p?QrrQ=z(T&n<$JV6r0`+s~Mue54Wri)G!TzLZnVq0xBnMlW!p>~Ga oY2Wb(jejxFGwnORW&db@0M)*rOP_5XIsgCw07*qoM6N<$g3p#|H~;_u literal 0 HcmV?d00001 diff --git a/tests/fixtures/sprites/expected/src1_2_sdf.json b/tests/fixtures/sprites/expected/src1_2_sdf.json new file mode 100644 index 000000000..1430954ff --- /dev/null +++ b/tests/fixtures/sprites/expected/src1_2_sdf.json @@ -0,0 +1,26 @@ +{ + "another_bicycle": { + "height": 30, + "pixelRatio": 2, + "width": 30, + "x": 40, + "y": 32, + "sdf": true + }, + "bear": { + "height": 32, + "pixelRatio": 2, + "width": 32, + "x": 40, + "y": 0, + "sdf": true + }, + "sub/circle": { + "height": 40, + "pixelRatio": 2, + "width": 40, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/src1_2_sdf.png b/tests/fixtures/sprites/expected/src1_2_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..c291da9581d0adef937f54f08f1510c6b9526f73 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{bZmGxE%I`ocS9w{WHYb+$rQJ3LJK4WIe4@)9yK94Lu n8anw)-I_yM51;Ih`@r_@kyZWXw}R(^?qTqB^>bP0l+XkKf=NX( literal 0 HcmV?d00001 diff --git a/tests/fixtures/sprites/expected/src2_2_sdf.json b/tests/fixtures/sprites/expected/src2_2_sdf.json new file mode 100644 index 000000000..8cd9eaa1a --- /dev/null +++ b/tests/fixtures/sprites/expected/src2_2_sdf.json @@ -0,0 +1,10 @@ +{ + "bicycle": { + "height": 30, + "pixelRatio": 2, + "width": 30, + "x": 0, + "y": 0, + "sdf": true + } +} diff --git a/tests/fixtures/sprites/expected/src2_2_sdf.png b/tests/fixtures/sprites/expected/src2_2_sdf.png new file mode 100644 index 0000000000000000000000000000000000000000..7c947fd364eebb22bbc03f31683d44387bcec788 GIT binary patch literal 344 zcmV-e0jK_nP)7|On})+;BBS8uB27)~kG>If-{MVi+;39?h(zH_8>u3xVHZlT zQh2}@1oW81=bqmdcNDE*K*3Wc-upC(eYwTRf|h(Iym3*bGMtVTL><_S29&BOayOWP zfmxI9nX7^EXJnXZNhacgX3~oS!1zWI+C(yFQzxOICPfrH^jH+rD9~0W|MVs^iG}&6 z8RSp!ph>oZJvhQSL7)DRrr8KMrG*PdjL@3X#}&MNSrXbzo^Pb qX1BEnwUZCXnB`GsDR_(jS$qKT!s)}bPuy?-0000