From 4aaf9fe071db4c64923fe50e6db8101c1abdc860 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sun, 21 Aug 2011 18:05:34 +0000 Subject: [PATCH] (follow-up r86169) Moar unit-tests!! (sorry for uttetly huge commit) This should be my last commit of unit tests for the media metadata stuff (hopefully). --- tests/phpunit/data/media/README | 5 +- tests/phpunit/data/media/animated-xmp.gif | Bin 0 -> 3864 bytes tests/phpunit/data/media/animated.gif | Bin 0 -> 497 bytes tests/phpunit/data/media/exif-gps.jpg | Bin 0 -> 665 bytes .../phpunit/data/media/exif-user-comment.jpg | Bin 0 -> 484 bytes .../data/media/iptc-timetest-invalid.jpg | Bin 0 -> 9573 bytes tests/phpunit/data/media/iptc-timetest.jpg | Bin 0 -> 9573 bytes .../phpunit/data/media/jpeg-iptc-bad-hash.jpg | Bin 0 -> 499 bytes .../data/media/jpeg-iptc-good-hash.jpg | Bin 0 -> 499 bytes tests/phpunit/data/media/jpeg-xmp-alt.jpg | Bin 0 -> 3255 bytes tests/phpunit/data/media/jpeg-xmp-psir.jpg | Bin 0 -> 3308 bytes tests/phpunit/data/media/jpeg-xmp-psir.xmp | 35 ++++ tests/phpunit/data/media/nonanimated.gif | Bin 0 -> 200 bytes tests/phpunit/data/media/xmp.png | Bin 0 -> 582 bytes tests/phpunit/data/xmp/1.result.php | 8 + tests/phpunit/data/xmp/1.xmp | 11 ++ tests/phpunit/data/xmp/2.result.php | 8 + tests/phpunit/data/xmp/2.xmp | 12 ++ tests/phpunit/data/xmp/3-invalid.result.php | 7 + tests/phpunit/data/xmp/3-invalid.xmp | 31 ++++ tests/phpunit/data/xmp/3.result.php | 8 + tests/phpunit/data/xmp/3.xmp | 29 ++++ tests/phpunit/data/xmp/4.result.php | 7 + tests/phpunit/data/xmp/4.xmp | 22 +++ tests/phpunit/data/xmp/5.result.php | 7 + tests/phpunit/data/xmp/5.xmp | 16 ++ tests/phpunit/data/xmp/6.result.php | 8 + tests/phpunit/data/xmp/6.xmp | 18 ++ tests/phpunit/data/xmp/7.result.php | 52 ++++++ tests/phpunit/data/xmp/7.xmp | 67 ++++++++ tests/phpunit/data/xmp/README | 3 + tests/phpunit/data/xmp/bag-for-seq.result.php | 10 ++ tests/phpunit/data/xmp/bag-for-seq.xmp | 1 + tests/phpunit/data/xmp/flash.result.php | 8 + tests/phpunit/data/xmp/flash.xmp | 11 ++ .../xmp/invalid-child-not-struct.result.php | 7 + .../data/xmp/invalid-child-not-struct.xmp | 12 ++ .../phpunit/data/xmp/no-namespace.result.php | 7 + tests/phpunit/data/xmp/no-namespace.xmp | 11 ++ .../data/xmp/no-recognized-props.result.php | 2 + .../phpunit/data/xmp/no-recognized-props.xmp | 8 + tests/phpunit/data/xmp/utf16BE.result.php | 12 ++ tests/phpunit/data/xmp/utf16BE.xmp | Bin 0 -> 930 bytes tests/phpunit/data/xmp/utf16LE.result.php | 12 ++ tests/phpunit/data/xmp/utf16LE.xmp | Bin 0 -> 930 bytes tests/phpunit/data/xmp/utf32BE.result.php | 12 ++ tests/phpunit/data/xmp/utf32BE.xmp | Bin 0 -> 1856 bytes tests/phpunit/data/xmp/utf32LE.result.php | 12 ++ tests/phpunit/data/xmp/utf32LE.xmp | Bin 0 -> 1856 bytes tests/phpunit/data/xmp/xmpExt.result.php | 8 + tests/phpunit/data/xmp/xmpExt.xmp | 13 ++ tests/phpunit/data/xmp/xmpExt2.xmp | 8 + .../media/BitmapMetadataHandlerTest.php | 74 +++++++++ .../phpunit/includes/media/ExifBitmapTest.php | 70 ++++++-- tests/phpunit/includes/media/ExifTest.php | 51 ++++++ .../media/GIFMetadataExtractorTest.php | 95 +++++++++++ tests/phpunit/includes/media/GIFTest.php | 85 ++++++++++ tests/phpunit/includes/media/IPTCTest.php | 55 +++++++ .../media/JpegMetadataExtractorTest.php | 47 ++++++ .../media/PNGMetadataExtractorTest.php | 1 - tests/phpunit/includes/media/PNGTest.php | 88 ++++++++++ tests/phpunit/includes/media/TiffTest.php | 7 +- tests/phpunit/includes/media/XMPTest.php | 154 ++++++++++++++++++ 63 files changed, 1217 insertions(+), 18 deletions(-) create mode 100644 tests/phpunit/data/media/animated-xmp.gif create mode 100644 tests/phpunit/data/media/animated.gif create mode 100644 tests/phpunit/data/media/exif-gps.jpg create mode 100644 tests/phpunit/data/media/exif-user-comment.jpg create mode 100644 tests/phpunit/data/media/iptc-timetest-invalid.jpg create mode 100644 tests/phpunit/data/media/iptc-timetest.jpg create mode 100644 tests/phpunit/data/media/jpeg-iptc-bad-hash.jpg create mode 100644 tests/phpunit/data/media/jpeg-iptc-good-hash.jpg create mode 100644 tests/phpunit/data/media/jpeg-xmp-alt.jpg create mode 100644 tests/phpunit/data/media/jpeg-xmp-psir.jpg create mode 100644 tests/phpunit/data/media/jpeg-xmp-psir.xmp create mode 100644 tests/phpunit/data/media/nonanimated.gif create mode 100644 tests/phpunit/data/media/xmp.png create mode 100644 tests/phpunit/data/xmp/1.result.php create mode 100644 tests/phpunit/data/xmp/1.xmp create mode 100644 tests/phpunit/data/xmp/2.result.php create mode 100644 tests/phpunit/data/xmp/2.xmp create mode 100644 tests/phpunit/data/xmp/3-invalid.result.php create mode 100644 tests/phpunit/data/xmp/3-invalid.xmp create mode 100644 tests/phpunit/data/xmp/3.result.php create mode 100644 tests/phpunit/data/xmp/3.xmp create mode 100644 tests/phpunit/data/xmp/4.result.php create mode 100644 tests/phpunit/data/xmp/4.xmp create mode 100644 tests/phpunit/data/xmp/5.result.php create mode 100644 tests/phpunit/data/xmp/5.xmp create mode 100644 tests/phpunit/data/xmp/6.result.php create mode 100644 tests/phpunit/data/xmp/6.xmp create mode 100644 tests/phpunit/data/xmp/7.result.php create mode 100644 tests/phpunit/data/xmp/7.xmp create mode 100644 tests/phpunit/data/xmp/README create mode 100644 tests/phpunit/data/xmp/bag-for-seq.result.php create mode 100644 tests/phpunit/data/xmp/bag-for-seq.xmp create mode 100644 tests/phpunit/data/xmp/flash.result.php create mode 100644 tests/phpunit/data/xmp/flash.xmp create mode 100644 tests/phpunit/data/xmp/invalid-child-not-struct.result.php create mode 100644 tests/phpunit/data/xmp/invalid-child-not-struct.xmp create mode 100644 tests/phpunit/data/xmp/no-namespace.result.php create mode 100644 tests/phpunit/data/xmp/no-namespace.xmp create mode 100644 tests/phpunit/data/xmp/no-recognized-props.result.php create mode 100644 tests/phpunit/data/xmp/no-recognized-props.xmp create mode 100644 tests/phpunit/data/xmp/utf16BE.result.php create mode 100644 tests/phpunit/data/xmp/utf16BE.xmp create mode 100644 tests/phpunit/data/xmp/utf16LE.result.php create mode 100644 tests/phpunit/data/xmp/utf16LE.xmp create mode 100644 tests/phpunit/data/xmp/utf32BE.result.php create mode 100644 tests/phpunit/data/xmp/utf32BE.xmp create mode 100644 tests/phpunit/data/xmp/utf32LE.result.php create mode 100644 tests/phpunit/data/xmp/utf32LE.xmp create mode 100644 tests/phpunit/data/xmp/xmpExt.result.php create mode 100644 tests/phpunit/data/xmp/xmpExt.xmp create mode 100644 tests/phpunit/data/xmp/xmpExt2.xmp create mode 100644 tests/phpunit/includes/media/ExifTest.php create mode 100644 tests/phpunit/includes/media/GIFMetadataExtractorTest.php create mode 100644 tests/phpunit/includes/media/GIFTest.php create mode 100644 tests/phpunit/includes/media/IPTCTest.php create mode 100644 tests/phpunit/includes/media/PNGTest.php create mode 100644 tests/phpunit/includes/media/XMPTest.php diff --git a/tests/phpunit/data/media/README b/tests/phpunit/data/media/README index 864e9ff48b..2e2c565d6b 100644 --- a/tests/phpunit/data/media/README +++ b/tests/phpunit/data/media/README @@ -22,7 +22,10 @@ TastyCakes on English Wikipedia greyscale-na-png.png, rgb-png.png, Xmp-exif-multilingual_test.jpg greyscale-png.png, 1bit-png.png, Png-native-test.png, rgb-na-png.png, test.tiff, test.jpg, jpeg-comment-multiple.jpg, jpeg-comment-utf.jpg, -jpeg-comment-iso8859-1.jpg, jpeg-comment-binary.jpg +jpeg-comment-iso8859-1.jpg, jpeg-comment-binary.jpg, jpeg-xmp-psir.jpg, +jpeg-xmp-alt.jpg, animated.gif, exif-user-comment.jpg, animated-xmp.gif, +iptc-timetest-invalid.jpg, jpeg-iptc-bad-hash.jpg, iptc-timetest.jpg, +xmp.png, nonanimated.gif, exif-gps.jpg, jpeg-xmp-psir.xmp, jpeg-iptc-good-hash.jpg Are all by Bawolff. I don't think they contain enough originality to claim copyright, but on the off chance they do, feel free to use them however you feel fit, without restriction. diff --git a/tests/phpunit/data/media/animated-xmp.gif b/tests/phpunit/data/media/animated-xmp.gif new file mode 100644 index 0000000000000000000000000000000000000000..fcba079d46f8f8bdd0c8e0018e5944498bd7d9b3 GIT binary patch literal 3864 zcmZ?wbhEHb)Mb!kXkcUjg8%>jEB@nk_iWx?l3HA{JuNdQl|k`8x1VcBu(M-;tC5}o zGf17{PZmxa21bxngl~X?OJYePkhZa}C`e4sPAySLN=?tqvsHh;d%wCuW{RzPxT&v! zZ-H}aMy5wqQEG6NUr2IQcCuxPy1gBjO@&oOZb5EpNuokUZcbjYRfVm3VoH8esuhq8 z64qB&04piUwpI7cO-xUmM7JO{57-wd2R8Z{|Nr~@=l8FlKfZta`sMSdk00K@d;8|~ ztCugHKYRM*@uPti4*$! zdV9LNIy>6iT3ec%8XM~CYHO;iDl5v%N=u513Jdb{a&xk?GBeWCQd5$X5)DC zA|t}XLPLUs0t5X0e0{vVJU!gqTwR=<93AZKY;CNqEG^8_3m%Tc*?H%{=Pd?YbofU=mxRCS(!SzLPZ(`g2Zhq;- zX%mtbFTAsJ$+=V05`A`lNxA=c&HIA?CuAM=&$!_5MmE*;n$SlPSLVy7w`4ul+z_cd z>9%TB;}w;kJ$|dNzcJf@=-44ylZs-E@BJ;UHy_m=W1H4dwQ=R6AVZG+`+puxc=us% z?8njuqoj$=hJI;EPaIDqbOoJTFsUmyHry?vr217;dGhq{(P!jEB@#9a}5c0b_{Se(lcNN2`m0nboX>qC`m0YQAo?o zNmbBOa4t$sEJ;mKD9`Ax~*E(ctz!BkKgL+ zZ_G9T{ebDbR1|A`?{8_n`Kb07+q90VjVm7o8FKXB|MOtNyAOL~KbAHaB~5HL^h;BE z;&>vVE9l&UNnN?I;cgiv)vub$lc#@=K5KVeP{g!W&Mf)k{V7MxUVi_x??1nUMn(`; zo6AvcUe255!=WeVl=rN1#r%##0;^A~mAxPvcYTN5qqB8~#Mzx~tQrJmFIN;Uo6`2& zc~;XeFT<>LH)0F(D2-v{lAm#=JZa8}f zND2rdfEXkv52Zn7gZQFQnjJz*xB}^4Kzsr!4p#U7ErU)#Mt(_taYlZDg0Y?fgN2i) zFN-Qr4FiJ!=g-d%+R}b^?%qGUL|1oh&i~sC&J1c&vWl`2YKroT+8S!QmhpC$CMK4p z!4ajKe5@ci+Wc+`GK>`@6kRSuQA4D*+urdQ> zlm!@=n3xz@5YmiH%z_L;iY&s0j!JA0vv(&i?w#l6CZu7y-rj)GuJZda*_2NXe0^_{`;!lSety!v^tJZe<@wtey$oGj c__K3CYg1b%N1)S{0=o@XiER?{|8H^u0MB>F-~a#s literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/media/exif-user-comment.jpg b/tests/phpunit/data/media/exif-user-comment.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9f23966ae0ff6fb700d6ce2cc77b42a42c959416 GIT binary patch literal 484 zcmex=ZK|Np!Hw?BM+12TkB zLtER@$g;rBuHenw*12y;2LBH*2y!rRF=#L|Dlsq#GBOJ?{y)MX!N9=G2=X5SFtV^R z17(y27?_xt7+Da~j7-de3_^-5!iJ7YffHGcfQm%W^a4!*i3*~c2ok-;z{AW4v=?ZE zJ;SAcP46#F*>&?m#Me)fYJXjdcP6-OYT*%SUjO@JO_lu4Wg!O37`pcrnq++6q@AO2 zW4DCh*}Ib$_s(;36VfnUZ*Rb8SNZ*zY|1AGzP>lf{mF+uKR;<-`da(#^8D?KUWTqM a{MosnwW+O>Bhcwef!zkH#5M`}|2F{!>9t1y literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/media/iptc-timetest-invalid.jpg b/tests/phpunit/data/media/iptc-timetest-invalid.jpg new file mode 100644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|jfo@s!5uUaux`t_lo@ zPqP2+{s&{y1SFPD0-Rg}7>s5(&6-`CfDL7na>}u`=2PX9)T1R{!>ceq>+lM%b5^+> zCe2+Vc%G_f9{;AFj0{(6)ibKG4zBQdP8i~xzhNva5^wKAe@?iYt5ZR`C7dC}k>254 zrcDQRZ(TTyfef_|bNU-y`gyCneXN!bUFMZ>dFgI}mb+wW_iQdlrpfksF8O~+=)qqL zDg1W{{V^kobD7i(DRW#{ciF9yG1-zaGeJ8(Vp=WsynRWL+Vhh`-~|rL^=FeB9j6M} zVSwz=o>i6+g~z%q8rQlQ*Xj|*i5jVn#;D*hRPb%Bcyga~pIXOXn`+PhME=iaaClzo z0d?vDRRkX~H8@PP`_JY9!ymFZpuRLTn1AKuNSt{H4-@?(D1N06_J?ZRxpl|>l=82o z3n?y>3zxYOe{J6Dxju{+?quvLaEj0Mo4P?O2CDohRM4h8O&6jKWqnS{l<&0j#}Br zoIqhlZ@oE#l=x_>yrk;fhnmQ1ztWgT-l#rB zS)D*G?^ZR}!prmOJ+D6z_>HD(p}q4R;_~hY^iNZ}$xQd;*O(E%$?(~-PHYvGxV2E9 z#Qz^kZB^q$|KFkicHRE>2mEQ||M4_kXZj~|1^D{{`DN~w*Z?SfBLDuq`Tte>c>F&A DnDW?q literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/media/iptc-timetest.jpg b/tests/phpunit/data/media/iptc-timetest.jpg new file mode 100644 index 0000000000000000000000000000000000000000..db9932ba6fde30331f3f075350f3ff0220e0f3ef GIT binary patch literal 9573 zcmeHrcU)83wr&E5ARxU8D1iW>1QM#$O$#J66PmP*ltgMER8c?_rS~4HLg-!TVxvik zs5C*a&;=<{r3n}J*?Yge&prE|ciy}AkN19OX8n>i=l9KTj4{_3Yp#{!vExqwCKLjR z004nNfZoXmaJ&Ne`I57zucwc*r`H7;s5C%P6KP0A1^Cf4cqtSBG_Z>o6{KaP;k*xgMOl$(|Y%DBnqI~>Z0@7k|n3Nb) zQdU|2Cs{?^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xAO^f;`5W|T9+uuZ0ex=bYea`z>B>7ji1uF`E zH+`rL-E}Sdg7{W3&CgSQ{mtX0-8+81#-4-exz)2g{*MwLO_i5ao%>J|dF@vk^T-?3 zrzoov$mQLt=301pUcKk_Cj!6GbS<=ZzC&Ez9fAI-Yd4wcp8RSv;x`#STh@uKq7t_j z>J$6_L$0lAoaq1C^xv-A|NeqMjr>1O({-kQk}JU93*?vFEwKSm`b7Tyd-MOR{p0cf E06yE;eEr1Ply~ zj7?0<%q=V(ot#}<-N14zU^xjHCP@aClGNf75Q8}_KVOE4fq{vE<^OF4X9hJXSw&e1 zHAQ(vZ4EVD%Xm9W6BEnQ;0V|FuF8r19hI%kGgjZ;HDl5FCC#n-{vSO5=;hZRU#D#U z|NsBH|F=JUeFHLtQA1nX(#W#F&aU9i+}62oNCy88FbHxma4~2wGb%AK2{JMZGX6ip zAi==E4D>xRU}Rxs2FfT4FfcJOF|r_}8JU;`8H5yBgbf{)0w=N>0Tqd$=>?ht5*0)> z5hQwxfrpt9XfMzRdxlH@n%-ZUvg_uBh_9a{)&9B^?@Vyn)WRduy#DvcnkxC7%R&s6 zF?8=MG|BkBNjpd5#%>A0vv(&i?w#l6CZu7y-rj)GuJZda*_2NXe0^_{`;!lSety!v o^tJZe<@wtey$oGj__K3CYg1b%N1)S{0=o@XiER?{|8H^u01dvoB>(^b literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/media/jpeg-iptc-good-hash.jpg b/tests/phpunit/data/media/jpeg-iptc-good-hash.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ef97085430877f2a178395e4e4bac1be16f4bc05 GIT binary patch literal 499 zcmex=r1UP?w ze$bZoyL0#c*(JKVYjePIEMPea874^vmXg%s5)gwqEk9p|iGhKMf#v^g24@B}DOp8X z2{lD|MQsf=UCVeoOA`~z(%=Z!_^!%{{T-F9%`;Zt-Zf*<`6bP*`~Dw1|LEn{A77_z z|NsC0yZ^U8e0>8lgi%9V+tSFgz|OAV&D_?xZ%79J4=@OFFmN$wFf%GKFbOg;3o`yc z!XUxGzzp;~GGJt3Wd_P93otM-F)^|rq#2o*1sQ}CS%eK8l>#TS8UYoFpy>sg0}>TP zH4!9wi-Cuk5oj;a2z!Q0|C-)knzHNWg@~`8B-Q@96z@!M+0?=#(!Bon$C@hnoy$TD zmN9hiD>TXYzDYYr)mBR*7vA^8asg0RYI0z{CIm literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/media/jpeg-xmp-alt.jpg b/tests/phpunit/data/media/jpeg-xmp-alt.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0e2c3f6330a8a9d5454954bf41db3bfb455aa68b GIT binary patch literal 3255 zcmex=#8IXksPAt^OIGtXB2{qFth3YjUk>fxro2EGN(sTr9bRYj@6RemAKRoTgw zDeCriTs9R}6}bhusU?XD6}dTi#a0!z>R`jIfNYSkzPbWfNlCV?x@T@;da9L`Yei;S zNPd2fg1MftfjZEPqLehNAQv~N2|%8$dPYe}0nn-C<>h+i#(Mch>H3D2mX`VkM*2oZ zx!*7iAWdWaj57fXqxx$}cUkRafUyfEt~W3^%!; zv?vE`Zc4I#YEEiyYF8VxRzLVzU2qp52&xJU{C zk`#}ouF>EkDFjGTJd9EoqJ^892W-}s1KY3vZ!2r04%8#*clPGmI#DiT4{3p58LDu`+#Nc0v14>KdsUZ4^7 z443{jy}vYN*UbwNUq4Bz{dFncnc%Xig-4`${qK)8Rq{KRg%~Vj=-yXolJR|$c8Cm;I!{G@&9Ywfqo^S3X08M?Oc bXXk>}rnXLwK&LAOb{nh`+a%=w-{b-S0R&-= literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/media/jpeg-xmp-psir.jpg b/tests/phpunit/data/media/jpeg-xmp-psir.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4d19fcbe213df3d6d1973b4b0620850424e4498f GIT binary patch literal 3308 zcmex=CI*)O54lA$N=gc>^!4+K^%7I^lT!7P^KTBRz;GCL~=}}db8eHWUl3bOYY?-2N zZ^va*VO5b^kegbPs8ErclUHn2VXF={+zQAB3G1sXfR&VF+p2r!CZ?xaS-DnZriJ9^ z=O~!#85^hr%_vGqvkG!?gPH*3*{VaGT3%kRS8lAAUzDzIXlZGwZ(yWvWTXpJp<7&; zSCUwvn^&w1G=WP2Y=%o}adJ^+K}lwQo&w0s#H9Sv5?gh3E(NI3Damk?3rdS}z~-hT z>!;?V=BDPA6axdoP#O=Z8@<0`u{eAGlQCxtfH)hnxed-wuYLnWxSoGiHT)taD;1o zSLMY1j>^{N8LMyanz88olIGTZ{|}yj^z!SEuT!@F|NsBp|JxtFz5yA+sG+TGX=GVo zXIJoMZtL7PB!mA47z8;OxEM5;8I>5A1R0qH8UG()kYHe7W@H4n>|q2W3oA2FMp=M? ziHV7k1tHDI#4N}lq{t#{=%^Gpk<|#ONCZtU&97a z{?e3PH!nnd{UoXO*QI!8g3G2B9+BqtzdzPg$?seiVz7*%dtaeR#`jIyIT|;1O9-C5 zJ9%;MJU2HX4b%1Z28?!<-;c?rd~)FHdz0LseCYG@llG;rwcjq!-@fQ&=-R@coeNr< V+B!J`ovswvZLmsglaT*^696ycZLt6V literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/media/jpeg-xmp-psir.xmp b/tests/phpunit/data/media/jpeg-xmp-psir.xmp new file mode 100644 index 0000000000..fee6ee18f5 --- /dev/null +++ b/tests/phpunit/data/media/jpeg-xmp-psir.xmp @@ -0,0 +1,35 @@ + + + + + + jpeg-xmp-psir.jpg + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/phpunit/data/media/nonanimated.gif b/tests/phpunit/data/media/nonanimated.gif new file mode 100644 index 0000000000000000000000000000000000000000..9e52a7f0d8a67f5efadab823420d4d9769e91955 GIT binary patch literal 200 zcmV;(05|_fNk%w1VJ!e20Du7i00030|NkNWBS%R_AarGObRcGFY-J$gft4Uba%Ew3 zWn>_CX>@2HM@dak03rDV0SW*C04x9i001oj9smFWcZ`pz%k2-NoU~dCvIb434Q5OT zE*?T|=6R@}h{6!7$gLgF9bVVCKH|-O!WRcaJUW089n*Mmrj&-~Lz;s6N-=7#*j;gN zUMu;U)Goo*ba?1hx6ADFj*gdDv2rxeWf#~q_2)*BCDwPb$k^!k2pK6kN$F4k06Pjf CTv2lX literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/media/xmp.png b/tests/phpunit/data/media/xmp.png new file mode 100644 index 0000000000000000000000000000000000000000..6b9f7a879fd92241c07a8c1306e451f7ba35ebc9 GIT binary patch literal 582 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_{3?x-PN__%SjKx9jP7LeL$-D$|*aCb)T>t<7 z4`hZOx?BgO{5@S9LnJOICrD^5=<9F)%Q#`(^T!kaGc1|>yHbaxp(M$^pV7l^<92mM z7xnMoRGOZ=t~}T9(rVrumI+NP7P-j`OLY~t^!#DwI9r!+pq7*22!qJc1Aond&S0FJ z84^(v;p=0SoS&RwL~E)H9a%WR{j0%{pt#tDYok2 zroINg1er{{GxPyLrY6beFGzXBO_g)3fxL7|@tbdtWIo`F74g+9 + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => '9' + ) +); diff --git a/tests/phpunit/data/xmp/1.xmp b/tests/phpunit/data/xmp/1.xmp new file mode 100644 index 0000000000..66e154273a --- /dev/null +++ b/tests/phpunit/data/xmp/1.xmp @@ -0,0 +1,11 @@ + + + + +True 0 1 False False + + diff --git a/tests/phpunit/data/xmp/2.result.php b/tests/phpunit/data/xmp/2.result.php new file mode 100644 index 0000000000..beead1bde1 --- /dev/null +++ b/tests/phpunit/data/xmp/2.result.php @@ -0,0 +1,8 @@ + + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => '9' + ) +); diff --git a/tests/phpunit/data/xmp/2.xmp b/tests/phpunit/data/xmp/2.xmp new file mode 100644 index 0000000000..0fa6a89473 --- /dev/null +++ b/tests/phpunit/data/xmp/2.xmp @@ -0,0 +1,12 @@ + + + + + +True 1 False False + + diff --git a/tests/phpunit/data/xmp/3-invalid.result.php b/tests/phpunit/data/xmp/3-invalid.result.php new file mode 100644 index 0000000000..5741b2c938 --- /dev/null +++ b/tests/phpunit/data/xmp/3-invalid.result.php @@ -0,0 +1,7 @@ + + array( + 'DigitalZoomRatio' => '0/10', + ) +); diff --git a/tests/phpunit/data/xmp/3-invalid.xmp b/tests/phpunit/data/xmp/3-invalid.xmp new file mode 100644 index 0000000000..2425e254f9 --- /dev/null +++ b/tests/phpunit/data/xmp/3-invalid.xmp @@ -0,0 +1,31 @@ + + + + + + + + +0/10 + +fred + + + + + + + + +1 +False + + False False + + diff --git a/tests/phpunit/data/xmp/3.result.php b/tests/phpunit/data/xmp/3.result.php new file mode 100644 index 0000000000..beead1bde1 --- /dev/null +++ b/tests/phpunit/data/xmp/3.result.php @@ -0,0 +1,8 @@ + + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => '9' + ) +); diff --git a/tests/phpunit/data/xmp/3.xmp b/tests/phpunit/data/xmp/3.xmp new file mode 100644 index 0000000000..2cf19883f7 --- /dev/null +++ b/tests/phpunit/data/xmp/3.xmp @@ -0,0 +1,29 @@ + + + + + + + +0/10 + +fred + + + + + + + +True + +1 +False + + False False + + diff --git a/tests/phpunit/data/xmp/4.result.php b/tests/phpunit/data/xmp/4.result.php new file mode 100644 index 0000000000..5741b2c938 --- /dev/null +++ b/tests/phpunit/data/xmp/4.result.php @@ -0,0 +1,7 @@ + + array( + 'DigitalZoomRatio' => '0/10', + ) +); diff --git a/tests/phpunit/data/xmp/4.xmp b/tests/phpunit/data/xmp/4.xmp new file mode 100644 index 0000000000..29eb614bac --- /dev/null +++ b/tests/phpunit/data/xmp/4.xmp @@ -0,0 +1,22 @@ + + + + + + + +0/10 + + +True 0 1 False False + + + + + + diff --git a/tests/phpunit/data/xmp/5.result.php b/tests/phpunit/data/xmp/5.result.php new file mode 100644 index 0000000000..5741b2c938 --- /dev/null +++ b/tests/phpunit/data/xmp/5.result.php @@ -0,0 +1,7 @@ + + array( + 'DigitalZoomRatio' => '0/10', + ) +); diff --git a/tests/phpunit/data/xmp/5.xmp b/tests/phpunit/data/xmp/5.xmp new file mode 100644 index 0000000000..3cc61d6862 --- /dev/null +++ b/tests/phpunit/data/xmp/5.xmp @@ -0,0 +1,16 @@ + + + + + + +True 0 1 False False + + + + + + diff --git a/tests/phpunit/data/xmp/6.result.php b/tests/phpunit/data/xmp/6.result.php new file mode 100644 index 0000000000..beead1bde1 --- /dev/null +++ b/tests/phpunit/data/xmp/6.result.php @@ -0,0 +1,8 @@ + + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => '9' + ) +); diff --git a/tests/phpunit/data/xmp/6.xmp b/tests/phpunit/data/xmp/6.xmp new file mode 100644 index 0000000000..f435ab23a1 --- /dev/null +++ b/tests/phpunit/data/xmp/6.xmp @@ -0,0 +1,18 @@ + + + + +0/10 + + + + + +True 0 1 False False + + diff --git a/tests/phpunit/data/xmp/7.result.php b/tests/phpunit/data/xmp/7.result.php new file mode 100644 index 0000000000..0efcfa363d --- /dev/null +++ b/tests/phpunit/data/xmp/7.result.php @@ -0,0 +1,52 @@ + + array ( + 'CameraOwnerName' => 'Me!', + ), + 'xmp-general' => + array ( + 'LicenseUrl' => 'http://creativecommons.com/cc-by-2.9', + 'ImageDescription' => + array ( + 'x-default' => 'Test image for the cc: xmp: xmpRights: namespaces in xmp', + '_type' => 'lang', + ), + 'ObjectName' => + array ( + 'x-default' => 'xmp core/xmp rights/cc ns test', + '_type' => 'lang', + ), + 'DateTimeDigitized' => '2005:04:03', + 'Software' => 'The one true editor: Vi (ok i used gimp)', + 'Identifier' => + array ( + 0 => 'http://example.com/identifierurl', + 1 => 'urn:sha1:342524abcdef', + '_type' => 'ul', + ), + 'Label' => 'Test image', + 'DateTimeMetadata' => '2011:05:12', + 'DateTime' => '2007:03:04 06:34:10', + 'Nickname' => 'My little xmp test image', + 'Rating' => '5', + 'RightsCertificate' => 'http://example.com/rights-certificate/', + 'Copyrighted' => 'True', + 'CopyrightOwner' => + array ( + 0 => 'Bawolff is copyright owner', + '_type' => 'ul', + ), + 'UsageTerms' => + array ( + 'x-default' => 'do whatever you want', + 'en-gb' => 'Do whatever you want in british english', + '_type' => 'lang', + ), + 'WebStatement' => 'http://example.com/web_statement', + ), + 'xmp-deprecated' => + array ( + 'Identifier' => 'http://example.com/identifierurl/wrong', + ), +); diff --git a/tests/phpunit/data/xmp/7.xmp b/tests/phpunit/data/xmp/7.xmp new file mode 100644 index 0000000000..e18e13d906 --- /dev/null +++ b/tests/phpunit/data/xmp/7.xmp @@ -0,0 +1,67 @@ + + + + + + Me! + + + + http://creativecommons.com/cc-by-2.9 + + + + + + Test image for the cc: xmp: xmpRights: namespaces in xmp + + + http://example.com/identifierurl/wrong + + + xmp core/xmp rights/cc ns test + + + + + + 2005-04-03 + The one true editor: Vi (ok i used gimp) + + + http://example.com/identifierurl + + urn:sha1:342524abcdef + + + Test image + 2011-05-12 + 2007-03-04T12:34:10-06:00 + My little xmp test image + 7 + + + + http://example.com/rights-certificate/ + True + + + Bawolff is copyright owner + + + + + do whatever you want + Do whatever you want in british english + + + http://example.com/web_statement + + + + diff --git a/tests/phpunit/data/xmp/README b/tests/phpunit/data/xmp/README new file mode 100644 index 0000000000..bd94917609 --- /dev/null +++ b/tests/phpunit/data/xmp/README @@ -0,0 +1,3 @@ +This directory contains a bunch of XMP files +as well as a bunch of php files containing what the +parsed version of the XMP looks like. diff --git a/tests/phpunit/data/xmp/bag-for-seq.result.php b/tests/phpunit/data/xmp/bag-for-seq.result.php new file mode 100644 index 0000000000..b5244f8840 --- /dev/null +++ b/tests/phpunit/data/xmp/bag-for-seq.result.php @@ -0,0 +1,10 @@ + array( + 'Artist' => array( + '_type' => 'ul', + 0 => 'The author', + ) + ) +); diff --git a/tests/phpunit/data/xmp/bag-for-seq.xmp b/tests/phpunit/data/xmp/bag-for-seq.xmp new file mode 100644 index 0000000000..c6ed5b7c56 --- /dev/null +++ b/tests/phpunit/data/xmp/bag-for-seq.xmp @@ -0,0 +1 @@ + The author diff --git a/tests/phpunit/data/xmp/flash.result.php b/tests/phpunit/data/xmp/flash.result.php new file mode 100644 index 0000000000..018c0ac1d2 --- /dev/null +++ b/tests/phpunit/data/xmp/flash.result.php @@ -0,0 +1,8 @@ + + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => '127' + ) +); diff --git a/tests/phpunit/data/xmp/flash.xmp b/tests/phpunit/data/xmp/flash.xmp new file mode 100644 index 0000000000..b1373cc2e0 --- /dev/null +++ b/tests/phpunit/data/xmp/flash.xmp @@ -0,0 +1,11 @@ + + + + +True 3 3 True True + + diff --git a/tests/phpunit/data/xmp/invalid-child-not-struct.result.php b/tests/phpunit/data/xmp/invalid-child-not-struct.result.php new file mode 100644 index 0000000000..5741b2c938 --- /dev/null +++ b/tests/phpunit/data/xmp/invalid-child-not-struct.result.php @@ -0,0 +1,7 @@ + + array( + 'DigitalZoomRatio' => '0/10', + ) +); diff --git a/tests/phpunit/data/xmp/invalid-child-not-struct.xmp b/tests/phpunit/data/xmp/invalid-child-not-struct.xmp new file mode 100644 index 0000000000..6aa0c10b1e --- /dev/null +++ b/tests/phpunit/data/xmp/invalid-child-not-struct.xmp @@ -0,0 +1,12 @@ + + + +True 0 1 False False + + + + diff --git a/tests/phpunit/data/xmp/no-namespace.result.php b/tests/phpunit/data/xmp/no-namespace.result.php new file mode 100644 index 0000000000..3ff692012f --- /dev/null +++ b/tests/phpunit/data/xmp/no-namespace.result.php @@ -0,0 +1,7 @@ + + array( + 'FNumber' => '28/10', + ) +); diff --git a/tests/phpunit/data/xmp/no-namespace.xmp b/tests/phpunit/data/xmp/no-namespace.xmp new file mode 100644 index 0000000000..7d6cdb2fcc --- /dev/null +++ b/tests/phpunit/data/xmp/no-namespace.xmp @@ -0,0 +1,11 @@ + + + + + + diff --git a/tests/phpunit/data/xmp/no-recognized-props.result.php b/tests/phpunit/data/xmp/no-recognized-props.result.php new file mode 100644 index 0000000000..b3ca9f5a10 --- /dev/null +++ b/tests/phpunit/data/xmp/no-recognized-props.result.php @@ -0,0 +1,2 @@ + + + + + diff --git a/tests/phpunit/data/xmp/utf16BE.result.php b/tests/phpunit/data/xmp/utf16BE.result.php new file mode 100644 index 0000000000..ac7ea5062f --- /dev/null +++ b/tests/phpunit/data/xmp/utf16BE.result.php @@ -0,0 +1,12 @@ + + array( + 'DigitalZoomRatio' => '0/10', + ), + 'xmp-general' => + array( + 'Label' => '􊯍' + ), +); diff --git a/tests/phpunit/data/xmp/utf16BE.xmp b/tests/phpunit/data/xmp/utf16BE.xmp new file mode 100644 index 0000000000000000000000000000000000000000..0cf60d60e4e856522025ed1c01f45828bbc3d92c GIT binary patch literal 930 zcmb7@%}&Bl5QWd0ryzAJEk#9b5JNP^g&3nI8h3~Yjr^t7fV`tm;KIERp?-5~vHon# z&FyXH=ggTiw`yotb4}GzS9j_uRaw`ZeZ?AUN8a1JJZ!OU>`NEgP+L{@RC~k?@EmHP zg!ePfW1WMv0IREQay;;xMT%8V9`yNu~-uVo_L(ar8h(7Ikbl`Y=p`_HX zjMg%vtV?*EfV&5VF)H!CE?*&gO%*s*S)sFTW2QwtWAgb7D<}>aC^iHW2DPYaq@_DYo%{u5~4Pj?1 zaBKqD)aWF`sG!^KmLz%|8-EcVgjp6(N-H6=QBeVRHs&kmYT^nlNJc}}?^ z=N|Ym9sOo)HT}ZeeCkY?Ye3B`$9nK#ZxghdMcg@=(|@6689y=eS`m83?)I7{LtVke z*qri}^=%y(7n@(s$2defBF66i(D*#RzC7V?IvsUZvDEm`CZODzyG`* O6U_dz8MW=tDSZHG+LQSJ literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/xmp/utf16LE.result.php b/tests/phpunit/data/xmp/utf16LE.result.php new file mode 100644 index 0000000000..ac7ea5062f --- /dev/null +++ b/tests/phpunit/data/xmp/utf16LE.result.php @@ -0,0 +1,12 @@ + + array( + 'DigitalZoomRatio' => '0/10', + ), + 'xmp-general' => + array( + 'Label' => '􊯍' + ), +); diff --git a/tests/phpunit/data/xmp/utf16LE.xmp b/tests/phpunit/data/xmp/utf16LE.xmp new file mode 100644 index 0000000000000000000000000000000000000000..66d71f4cab3407c65765f9bf474ac966bb5da23f GIT binary patch literal 930 zcmb7@%}&Bl5QWd0ryzAJ{Q*U7{E5*R7h;T>XxvprXapez1M-eOfeZIOg!;{`#VT&h z&FyVx=FFTqbGxY>O*K@a8{Mm|v8uY}>?qZPw&dyK-NTmZ)_q-QRV{_=q4tRD;yKhz z8SiJD$2up|j9fR`0OOH=8~i3!Vs;-~-_=R5+INpSBj>Yf37COn5P#W==m4)FiY#Ml z7-DyhsOl14Cq(U$!x&X~Uy-kf-B1lqAuDp$4QzF-vzst&Y8h(_+ymz>EHlm!Z#h_EuUutZq`8uYXm!6 zfnyWErcNh$jvC56!FY^rQ>>=s5_wJWGK+n*7}0&kw1z~du1`~^;F+NLK#%y0m*7k>Ta)T($f`O zjLj)udEeH7ak2Roe2hb^BVz3C_Z*+Mm*-bg(sT^wI{mHW@2Gt0h4uT+7I!)KEdF_I OCYb+c6S&!*Q_&~*Vw3p* literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/xmp/utf32BE.result.php b/tests/phpunit/data/xmp/utf32BE.result.php new file mode 100644 index 0000000000..ac7ea5062f --- /dev/null +++ b/tests/phpunit/data/xmp/utf32BE.result.php @@ -0,0 +1,12 @@ + + array( + 'DigitalZoomRatio' => '0/10', + ), + 'xmp-general' => + array( + 'Label' => '􊯍' + ), +); diff --git a/tests/phpunit/data/xmp/utf32BE.xmp b/tests/phpunit/data/xmp/utf32BE.xmp new file mode 100644 index 0000000000000000000000000000000000000000..06afdf9245da501cb3265748b23f2fdaeada8ab7 GIT binary patch literal 1856 zcmcK5$!b(V6vpvdyYdkV-D;di90-cIFd|7naTjON7;(Vim3$UoN&SAEd$70|yIr{W zbL!S`hVN8$x7Mz-)~<)o;ceInkHf3*G<*m>JPN*_hnL|^xEhYM_T%TiUF@^=S6k+zhuu4+r&hJXgBAdwKzN@uzqAG(aog zbTzIXcnkKbjdq2((#DuJ(33F_-|pO(Kx29A1T|PQXZ>hcMGHE(4Sl*V}_%@b1 zzjb%UeAF+#dv4#y;9Th?hdOtV&f;4WOONX8-?Xke*Ro&y`CBlr9y#p>n$F{x(+7KL z?|YSe(Uc_rDy&2);;mN^)T#B&}K8JXY6;?Rl3m0c&<{-lf%eW|jXtXWdJ8 OvGnsBpl;_E{(b>VY?2TF literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/xmp/utf32LE.result.php b/tests/phpunit/data/xmp/utf32LE.result.php new file mode 100644 index 0000000000..ac7ea5062f --- /dev/null +++ b/tests/phpunit/data/xmp/utf32LE.result.php @@ -0,0 +1,12 @@ + + array( + 'DigitalZoomRatio' => '0/10', + ), + 'xmp-general' => + array( + 'Label' => '􊯍' + ), +); diff --git a/tests/phpunit/data/xmp/utf32LE.xmp b/tests/phpunit/data/xmp/utf32LE.xmp new file mode 100644 index 0000000000000000000000000000000000000000..bf2097fec90542a4207c2cdbda2338c95b9b4fe1 GIT binary patch literal 1856 zcmcK5%T8256oug)JMs}KG8IHryaX{sV;G1rXrgh(RShBrHHxpqv+zpj`r_H7aw5as6uS9LE6A1vlZ)Z zHzzK=SiWm)Z@UBe+!?(W%iB^L-^Oz1x9(1# zkNU-T&+YpboGZQLQ0LCmS$u0^=~11%Nb9O|F8jqFzXkK^k<)&l={Sx#eXy7IzNg7o zu42;Yf92Z8xGc|cU3#Lg^sL|Bx+i|O-iCt#+N=ll^!={7N*6jAkM$`X#C#Tfy9;s> ztNffCUp>2z^)A&lzDxgdAHDO7e5s2+?|i(MzH(-1pqH$?ORN6OH2-(bx|i-^)$KQc JX7zs~-{1Zgk`Mp@ literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/xmp/xmpExt.result.php b/tests/phpunit/data/xmp/xmpExt.result.php new file mode 100644 index 0000000000..beead1bde1 --- /dev/null +++ b/tests/phpunit/data/xmp/xmpExt.result.php @@ -0,0 +1,8 @@ + + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => '9' + ) +); diff --git a/tests/phpunit/data/xmp/xmpExt.xmp b/tests/phpunit/data/xmp/xmpExt.xmp new file mode 100644 index 0000000000..da0383f8e1 --- /dev/null +++ b/tests/phpunit/data/xmp/xmpExt.xmp @@ -0,0 +1,13 @@ + + + + +True 0 1 False False + + diff --git a/tests/phpunit/data/xmp/xmpExt2.xmp b/tests/phpunit/data/xmp/xmpExt2.xmp new file mode 100644 index 0000000000..060abb2c65 --- /dev/null +++ b/tests/phpunit/data/xmp/xmpExt2.xmp @@ -0,0 +1,8 @@ + + + + + diff --git a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php index 148b90ac09..1e11d50399 100644 --- a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php +++ b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php @@ -47,4 +47,78 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase { $this->assertEquals( 'UTF-8 JPEG Comment — ¼', $meta['JPEGFileComment'][0] ); } + + public function testIPTCDates() { + $meta = BitmapMetadataHandler::Jpeg( $this->filePath . + 'iptc-timetest.jpg' ); + + $this->assertEquals( '2020:07:14 01:36:05', $meta['DateTimeDigitized'] ); + $this->assertEquals( '1997:03:02 00:01:02', $meta['DateTimeOriginal'] ); + } + /* File has an invalid time (+ one valid but really weird time) + * that shouldn't be included + */ + public function testIPTCDatesInvalid() { + $meta = BitmapMetadataHandler::Jpeg( $this->filePath . + 'iptc-timetest-invalid.jpg' ); + + $this->assertEquals( '1845:03:02 00:01:02', $meta['DateTimeOriginal'] ); + $this->assertFalse( isset( $meta['DateTimeDigitized'] ) ); + } + + /** + * XMP data should take priority over iptc data + * when hash has been updated, but not when + * the hash is wrong. + */ + public function testMerging() { + $merger = new BitmapMetadataHandler(); + $merger->addMetadata( array( 'foo' => 'xmp' ), 'xmp-general' ); + $merger->addMetadata( array( 'bar' => 'xmp' ), 'xmp-general' ); + $merger->addMetadata( array( 'baz' => 'xmp' ), 'xmp-general' ); + $merger->addMetadata( array( 'fred' => 'xmp' ), 'xmp-general' ); + $merger->addMetadata( array( 'foo' => 'iptc (hash)' ), 'iptc-good-hash' ); + $merger->addMetadata( array( 'bar' => 'iptc (bad hash)' ), 'iptc-bad-hash' ); + $merger->addMetadata( array( 'baz' => 'iptc (bad hash)' ), 'iptc-bad-hash' ); + $merger->addMetadata( array( 'fred' => 'iptc (no hash)' ), 'iptc-no-hash' ); + $merger->addMetadata( array( 'baz' => 'exif' ), 'exif' ); + + $actual = $merger->getMetadataArray(); + $expected = array( + 'foo' => 'xmp', + 'bar' => 'iptc (bad hash)', + 'baz' => 'exif', + 'fred' => 'xmp', + ); + $this->assertEquals( $expected, $actual ); + } + + public function testPNGXMP() { + $handler = new BitmapMetadataHandler(); + $result = $handler->png( $this->filePath . 'xmp.png' ); + $expected = array ( + 'frameCount' => 0, + 'loopCount' => 1, + 'duration' => 0, + 'bitDepth' => 1, + 'colorType' => 'index-coloured', + 'metadata' => array ( + 'SerialNumber' => '123456789', + '_MW_PNG_VERSION' => 1, + ), + ); + $this->assertEquals( $expected, $result ); + } + public function testPNGNative() { + $handler = new BitmapMetadataHandler(); + $result = $handler->png( $this->filePath . 'Png-native-test.png' ); + $expected = 'http://example.com/url'; + $this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] ); + } + public function testTiffByteOrder() { + $handler = new BitmapMetadataHandler(); + $res = $handler->getTiffByteOrder( $this->filePath . 'test.tiff' ); + $this->assertEquals( 'LE', $res ); + } + } diff --git a/tests/phpunit/includes/media/ExifBitmapTest.php b/tests/phpunit/includes/media/ExifBitmapTest.php index b39bfc34d5..d6bca82701 100644 --- a/tests/phpunit/includes/media/ExifBitmapTest.php +++ b/tests/phpunit/includes/media/ExifBitmapTest.php @@ -6,6 +6,7 @@ class ExifBitmapTest extends MediaWikiTestCase { global $wgShowEXIF; $this->showExif = $wgShowEXIF; $wgShowEXIF = true; + $this->handler = new ExifBitmapHandler; } public function tearDown() { @@ -17,42 +18,37 @@ class ExifBitmapTest extends MediaWikiTestCase { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } - $handler = new ExifBitmapHandler; - $res = $handler->isMetadataValid( null, ExifBitmapHandler::OLD_BROKEN_FILE ); + $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::OLD_BROKEN_FILE ); $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res ); } public function testIsBrokenFile() { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } - $handler = new ExifBitmapHandler; - $res = $handler->isMetadataValid( null, ExifBitmapHandler::BROKEN_FILE ); + $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::BROKEN_FILE ); $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res ); } public function testIsInvalid() { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } - $handler = new ExifBitmapHandler; - $res = $handler->isMetadataValid( null, 'Something Invalid Here.' ); + $res = $this->handler->isMetadataValid( null, 'Something Invalid Here.' ); $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res ); } public function testGoodMetadata() { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } - $handler = new ExifBitmapHandler; $meta = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}'; - $res = $handler->isMetadataValid( null, $meta ); + $res = $this->handler->isMetadataValid( null, $meta ); $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res ); } public function testIsOldGood() { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } - $handler = new ExifBitmapHandler; $meta = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:1;}'; - $res = $handler->isMetadataValid( null, $meta ); + $res = $this->handler->isMetadataValid( null, $meta ); $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res ); } // Handle metadata from paged tiff handler (gotten via instant commons) @@ -61,9 +57,59 @@ class ExifBitmapTest extends MediaWikiTestCase { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } - $handler = new ExifBitmapHandler; $meta = 'a:6:{s:9:"page_data";a:1:{i:1;a:5:{s:5:"width";i:643;s:6:"height";i:448;s:5:"alpha";s:4:"true";s:4:"page";i:1;s:6:"pixels";i:288064;}}s:10:"page_count";i:1;s:10:"first_page";i:1;s:9:"last_page";i:1;s:4:"exif";a:9:{s:10:"ImageWidth";i:643;s:11:"ImageLength";i:448;s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:4;s:12:"RowsPerStrip";i:50;s:19:"PlanarConfiguration";i:1;s:22:"MEDIAWIKI_EXIF_VERSION";i:1;}s:21:"TIFF_METADATA_VERSION";s:3:"1.4";}'; - $res = $handler->isMetadataValid( null, $meta ); + $res = $this->handler->isMetadataValid( null, $meta ); $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res ); } + + function testConvertMetadataLatest() { + $metadata = array( + 'foo' => array( 'First', 'Second', '_type' => 'ol' ), + 'MEDIAWIKI_EXIF_VERSION' => 2 + ); + $res = $this->handler->convertMetadataVersion( $metadata, 2 ); + $this->assertEquals( $metadata, $res ); + } + function testConvertMetadataToOld() { + $metadata = array( + 'foo' => array( 'First', 'Second', '_type' => 'ol' ), + 'bar' => array( 'First', 'Second', '_type' => 'ul' ), + 'baz' => array( 'First', 'Second' ), + 'fred' => 'Single', + 'MEDIAWIKI_EXIF_VERSION' => 2, + ); + $expected = array( + 'foo' => "\n#First\n#Second", + 'bar' => "\n*First\n*Second", + 'baz' => "\n*First\n*Second", + 'fred' => 'Single', + 'MEDIAWIKI_EXIF_VERSION' => 1, + ); + $res = $this->handler->convertMetadataVersion( $metadata, 1 ); + $this->assertEquals( $expected, $res ); + } + function testConvertMetadataSoftware() { + $metadata = array( + 'Software' => array( array('GIMP', '1.1' ) ), + 'MEDIAWIKI_EXIF_VERSION' => 2, + ); + $expected = array( + 'Software' => 'GIMP (Version 1.1)', + 'MEDIAWIKI_EXIF_VERSION' => 1, + ); + $res = $this->handler->convertMetadataVersion( $metadata, 1 ); + $this->assertEquals( $expected, $res ); + } + function testConvertMetadataSoftwareNormal() { + $metadata = array( + 'Software' => array( "GIMP 1.2", "vim" ), + 'MEDIAWIKI_EXIF_VERSION' => 2, + ); + $expected = array( + 'Software' => "\n*GIMP 1.2\n*vim", + 'MEDIAWIKI_EXIF_VERSION' => 1, + ); + $res = $this->handler->convertMetadataVersion( $metadata, 1 ); + $this->assertEquals( $expected, $res ); + } } diff --git a/tests/phpunit/includes/media/ExifTest.php b/tests/phpunit/includes/media/ExifTest.php new file mode 100644 index 0000000000..9b490e92dc --- /dev/null +++ b/tests/phpunit/includes/media/ExifTest.php @@ -0,0 +1,51 @@ +mediaPath = dirname( __FILE__ ) . '/../../data/media/'; + + global $wgShowEXIF; + $this->showExif = $wgShowEXIF; + $wgShowEXIF = true; + } + public function tearDown() { + global $wgShowEXIF; + $wgShowEXIF = $this->showExif; + } + + public function testGPSExtraction() { + if ( !wfDl( 'exif' ) ) { + $this->markTestIncomplete( "This test needs the exif extension." ); + } + + $filename = $this->mediaPath . 'exif-gps.jpg'; + $seg = JpegMetadataExtractor::segmentSplitter( $filename ); + $exif = new Exif( $filename, $seg['byteOrder'] ); + $data = $exif->getFilteredData(); + $expected = array( + 'GPSLatitude' => 88.5180555556, + 'GPSLongitude' => -21.12357, + 'GPSAltitude' => -200, + 'GPSDOP' => '5/1', + 'GPSVersionID' => '2.2.0.0', + ); + $this->assertEquals( $expected, $data, '', 0.0000000001 ); + } + public function testUnicodeUserComment() { + if ( !wfDl( 'exif' ) ) { + $this->markTestIncomplete( "This test needs the exif extension." ); + } + + $filename = $this->mediaPath . 'exif-user-comment.jpg'; + $seg = JpegMetadataExtractor::segmentSplitter( $filename ); + $exif = new Exif( $filename, $seg['byteOrder'] ); + $data = $exif->getFilteredData(); + + $expected = array( + 'UserComment' => 'test⁔comment' + ); + $this->assertEquals( $expected, $data ); + } + + +} diff --git a/tests/phpunit/includes/media/GIFMetadataExtractorTest.php b/tests/phpunit/includes/media/GIFMetadataExtractorTest.php new file mode 100644 index 0000000000..59b30441a7 --- /dev/null +++ b/tests/phpunit/includes/media/GIFMetadataExtractorTest.php @@ -0,0 +1,95 @@ +mediaPath = dirname( __FILE__ ) . '/../../data/media/'; + } + /** + * Put in a file, and see if the metadata coming out is as expected. + * @param $filename String + * @param $expected Array The extracted metadata. + * @dataProvider dataGetMetadata + */ + public function testGetMetadata( $filename, $expected ) { + $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename ); + $this->assertEquals( $expected, $actual ); + } + public function dataGetMetadata() { + + $xmpNugget = << + + + + + The interwebs + + + + Bawolff + + + A file to test GIF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOF; + + return array( + array( 'nonanimated.gif', array( + 'comment' => array( 'GIF test file ⁕ Created with GIMP' ), + 'duration' => 0.1, + 'frameCount' => 1, + 'looped' => false, + 'xmp' => '', + ) + ), + array( 'animated.gif', array( + 'comment' => array( 'GIF test file . Created with GIMP' ), + 'duration' => 2.4, + 'frameCount' => 4, + 'looped' => true, + 'xmp' => '', + ) + ), + + array( 'animated-xmp.gif', array( + 'xmp' => $xmpNugget, + 'duration' => 2.4, + 'frameCount' => 4, + 'looped' => true, + 'comment' => array( 'GIƒ·test·file' ), + ) + ), + ); + } +} diff --git a/tests/phpunit/includes/media/GIFTest.php b/tests/phpunit/includes/media/GIFTest.php new file mode 100644 index 0000000000..42c25ca56d --- /dev/null +++ b/tests/phpunit/includes/media/GIFTest.php @@ -0,0 +1,85 @@ +filePath = dirname( __FILE__ ) . '/../../data/media/'; + $this->handler = new GIFHandler(); + } + + public function testInvalidFile() { + $res = $this->handler->getMetadata( null, $this->filePath . 'README' ); + $this->assertEquals( GIFHandler::BROKEN_FILE, $res ); + } + /** + * @param $filename String basename of the file to check + * @param $expected boolean Expected result. + * @dataProvider dataIsAnimated + */ + public function testIsAnimanted( $filename, $expected ) { + $file = UnregisteredLocalFile::newFromPath( $this->filePath . $filename, + 'image/gif' ); + $actual = $this->handler->isAnimatedImage( $file ); + $this->assertEquals( $expected, $actual ); + } + public function dataIsAnimated() { + return array( + array( 'animated.gif', true ), + array( 'nonanimated.gif', false ), + ); + } + + /** + * @param $filename String + * @param $expected Integer Total image area + * @dataProvider dataGetImageArea + */ + public function testGetImageArea( $filename, $expected ) { + $file = UnregisteredLocalFile::newFromPath( $this->filePath . $filename, + 'image/gif' ); + $actual = $this->handler->getImageArea( $file, $file->getWidth(), $file->getHeight() ); + $this->assertEquals( $expected, $actual ); + } + public function dataGetImageArea() { + return array( + array( 'animated.gif', 5400 ), + array( 'nonanimated.gif', 1350 ), + ); + } + + /** + * @param $metadata String Serialized metadata + * @param $expected Integer One of the class constants of GIFHandler + * @dataProvider dataIsMetadataValid + */ + public function testIsMetadataValid( $metadata, $expected ) { + $actual = $this->handler->isMetadataValid( null, $metadata ); + $this->assertEquals( $expected, $actual ); + } + public function dataIsMetadataValid() { + return array( + array( GIFHandler::BROKEN_FILE, GIFHandler::METADATA_GOOD ), + array( '', GIFHandler::METADATA_BAD ), + array( null, GIFHandler::METADATA_BAD ), + array( 'Something invalid!', GIFHandler::METADATA_BAD ), + array( 'a:4:{s:10:"frameCount";i:1;s:6:"looped";b:0;s:8:"duration";d:0.1000000000000000055511151231257827021181583404541015625;s:8:"metadata";a:2:{s:14:"GIFFileComment";a:1:{i:0;s:35:"GIF test file ⁕ Created with GIMP";}s:15:"_MW_GIF_VERSION";i:1;}}', GIFHandler::METADATA_GOOD ), + ); + } + + /** + * @param $filename String + * @param $expected String Serialized array + * @dataProvider dataGetMetadata + */ + public function testGetMetadata( $filename, $expected ) { + $file = UnregisteredLocalFile::newFromPath( $this->filePath . $filename, + 'image/gif' ); + $actual = $this->handler->getMetadata( $file, $this->filePath . $filename ); + $this->assertEquals( unserialize( $expected ), unserialize( $actual ) ); + } + public function dataGetMetadata() { + return array( + array( 'nonanimated.gif', 'a:4:{s:10:"frameCount";i:1;s:6:"looped";b:0;s:8:"duration";d:0.1000000000000000055511151231257827021181583404541015625;s:8:"metadata";a:2:{s:14:"GIFFileComment";a:1:{i:0;s:35:"GIF test file ⁕ Created with GIMP";}s:15:"_MW_GIF_VERSION";i:1;}}' ), + array( 'animated-xmp.gif', 'a:4:{s:10:"frameCount";i:4;s:6:"looped";b:1;s:8:"duration";d:2.399999999999999911182158029987476766109466552734375;s:8:"metadata";a:5:{s:6:"Artist";s:7:"Bawolff";s:16:"ImageDescription";a:2:{s:9:"x-default";s:18:"A file to test GIF";s:5:"_type";s:4:"lang";}s:15:"SublocationDest";s:13:"The interwebs";s:14:"GIFFileComment";a:1:{i:0;s:16:"GIƒ·test·file";}s:15:"_MW_GIF_VERSION";i:1;}}' ), + ); + } +} diff --git a/tests/phpunit/includes/media/IPTCTest.php b/tests/phpunit/includes/media/IPTCTest.php new file mode 100644 index 0000000000..ec6deeb854 --- /dev/null +++ b/tests/phpunit/includes/media/IPTCTest.php @@ -0,0 +1,55 @@ +assertEquals( 'UTF-8', $res ); + } + + public function testIPTCParseNoCharset88591() { + // basically IPTC for keyword with value of 0xBC which is 1/4 in iso-8859-1 + // This data doesn't specify a charset. We're supposed to guess + // (which basically means utf-8 if valid, windows 1252 (iso 8859-1) if not) + $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x06\x1c\x02\x19\x00\x01\xBC"; + $res = IPTC::Parse( $iptcData ); + $this->assertEquals( array( '¼' ), $res['Keywords'] ); + } + /* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */ + /* \xC3 = Ã, \xB8 = ¸ */ + public function testIPTCParseNoCharset88591b() { + $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x09\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8"; + $res = IPTC::Parse( $iptcData ); + $this->assertEquals( array( 'ÃÃø' ), $res['Keywords'] ); + } + /* Same as testIPTCParseNoCharset88591b, but forcing the charset to utf-8. + * What should happen is the first "\xC3\xC3" should be dropped as invalid, + * leaving \xC3\xB8, which is ø + */ + public function testIPTCParseForcedUTFButInvalid() { + $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x11\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8" + . "\x1c\x01\x5A\x00\x03\x1B\x25\x47"; + $res = IPTC::Parse( $iptcData ); + $this->assertEquals( array( 'ø' ), $res['Keywords'] ); + } + public function testIPTCParseNoCharsetUTF8() { + $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x07\x1c\x02\x19\x00\x02¼"; + $res = IPTC::Parse( $iptcData ); + $this->assertEquals( array( '¼' ), $res['Keywords'] ); + } + // Testing something that has 2 values for keyword + public function testIPTCParseMulti() { + $iptcData = /* identifier */ "Photoshop 3.0\08BIM\4\4" + /* length */ . "\0\0\0\0\0\x0D" + . "\x1c\x02\x19" . "\x00\x01" . "\xBC" + . "\x1c\x02\x19" . "\x00\x02" . "\xBC\xBD"; + $res = IPTC::Parse( $iptcData ); + $this->assertEquals( array( '¼', '¼½' ), $res['Keywords'] ); + } + public function testIPTCParseUTF8() { + // This has the magic "\x1c\x01\x5A\x00\x03\x1B\x25\x47" which marks content as UTF8. + $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x0F\x1c\x02\x19\x00\x02¼\x1c\x01\x5A\x00\x03\x1B\x25\x47"; + $res = IPTC::Parse( $iptcData ); + $this->assertEquals( array( '¼' ), $res['Keywords'] ); + } + +} diff --git a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php index cc57925622..99c4384bb5 100644 --- a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php @@ -1,4 +1,11 @@ filePath . 'jpeg-comment-multiple.jpg' ); $this->assertEquals( array( 'foo', 'bar' ), $res['COM'] ); } + public function testXMPExtraction() { + $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-psir.jpg' ); + $expected = file_get_contents( $this->filePath . 'jpeg-xmp-psir.xmp' ); + $this->assertEquals( $expected, $res['XMP'] ); + } + public function testPSIRExtraction() { + $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-psir.jpg' ); + $expected = '50686f746f73686f7020332e30003842494d04040000000000181c02190004746573741c02190003666f6f1c020000020004'; + $this->assertEquals( $expected, bin2hex( $res['PSIR'] ) ); + } + public function testXMPExtractionAltAppId() { + $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-alt.jpg' ); + $expected = file_get_contents( $this->filePath . 'jpeg-xmp-psir.xmp' ); + $this->assertEquals( $expected, $res['XMP'] ); + } + + + public function testIPTCHashComparisionNoHash() { + $segments = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-psir.jpg' ); + $res = JpegMetadataExtractor::doPSIR( $segments['PSIR'] ); + + $this->assertEquals( 'iptc-no-hash', $res ); + } + public function testIPTCHashComparisionBadHash() { + $segments = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-iptc-bad-hash.jpg' ); + $res = JpegMetadataExtractor::doPSIR( $segments['PSIR'] ); + + $this->assertEquals( 'iptc-bad-hash', $res ); + } + public function testIPTCHashComparisionGoodHash() { + $segments = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-iptc-good-hash.jpg' ); + $res = JpegMetadataExtractor::doPSIR( $segments['PSIR'] ); + + $this->assertEquals( 'iptc-good-hash', $res ); + } + public function testExifByteOrder() { + $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'exif-user-comment.jpg' ); + $expected = 'BE'; + $this->assertEquals( $expected, $res['byteOrder'] ); + } } diff --git a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php index 1671a620d6..9f702c504d 100644 --- a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php @@ -138,5 +138,4 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { $this->assertEquals( 'greyscale', $meta['colorType'] ); } - } diff --git a/tests/phpunit/includes/media/PNGTest.php b/tests/phpunit/includes/media/PNGTest.php new file mode 100644 index 0000000000..b782918cb6 --- /dev/null +++ b/tests/phpunit/includes/media/PNGTest.php @@ -0,0 +1,88 @@ +filePath = dirname( __FILE__ ) . '/../../data/media/'; + $this->handler = new PNGHandler(); + } + + public function testInvalidFile() { + $res = $this->handler->getMetadata( null, $this->filePath . 'README' ); + $this->assertEquals( PNGHandler::BROKEN_FILE, $res ); + } + /** + * @param $filename String basename of the file to check + * @param $expected boolean Expected result. + * @dataProvider dataIsAnimated + */ + public function testIsAnimanted( $filename, $expected ) { + $file = UnregisteredLocalFile::newFromPath( $this->filePath . $filename, + 'image/png' ); + $actual = $this->handler->isAnimatedImage( $file ); + $this->assertEquals( $expected, $actual ); + } + public function dataIsAnimated() { + return array( + array( 'Animated_PNG_example_bouncing_beach_ball.png', true ), + array( '1bit-png.png', false ), + ); + } + + /** + * @param $filename String + * @param $expected Integer Total image area + * @dataProvider dataGetImageArea + */ + public function testGetImageArea( $filename, $expected ) { + $file = UnregisteredLocalFile::newFromPath( $this->filePath . $filename, + 'image/png' ); + $actual = $this->handler->getImageArea( $file, $file->getWidth(), $file->getHeight() ); + $this->assertEquals( $expected, $actual ); + } + public function dataGetImageArea() { + return array( + array( '1bit-png.png', 2500 ), + array( 'greyscale-png.png', 2500 ), + array( 'Png-native-test.png', 126000 ), + array( 'Animated_PNG_example_bouncing_beach_ball.png', 10000 ), + ); + } + + /** + * @param $metadata String Serialized metadata + * @param $expected Integer One of the class constants of PNGHandler + * @dataProvider dataIsMetadataValid + */ + public function testIsMetadataValid( $metadata, $expected ) { + $actual = $this->handler->isMetadataValid( null, $metadata ); + $this->assertEquals( $expected, $actual ); + } + public function dataIsMetadataValid() { + return array( + array( PNGHandler::BROKEN_FILE, PNGHandler::METADATA_GOOD ), + array( '', PNGHandler::METADATA_BAD ), + array( null, PNGHandler::METADATA_BAD ), + array( 'Something invalid!', PNGHandler::METADATA_BAD ), + array( 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:8;s:9:"colorType";s:10:"truecolour";s:8:"metadata";a:1:{s:15:"_MW_PNG_VERSION";i:1;}}', PNGHandler::METADATA_GOOD ), + ); + } + + /** + * @param $filename String + * @param $expected String Serialized array + * @dataProvider dataGetMetadata + */ + public function testGetMetadata( $filename, $expected ) { + $file = UnregisteredLocalFile::newFromPath( $this->filePath . $filename, + 'image/png' ); + $actual = $this->handler->getMetadata( $file, $this->filePath . $filename ); +// $this->assertEquals( unserialize( $expected ), unserialize( $actual ) ); + $this->assertEquals( ( $expected ), ( $actual ) ); + } + public function dataGetMetadata() { + return array( + array( 'rgb-na-png.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:8;s:9:"colorType";s:10:"truecolour";s:8:"metadata";a:1:{s:15:"_MW_PNG_VERSION";i:1;}}' ), + array( 'xmp.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:1;s:9:"colorType";s:14:"index-coloured";s:8:"metadata";a:2:{s:12:"SerialNumber";s:9:"123456789";s:15:"_MW_PNG_VERSION";i:1;}}' ), + ); + } +} diff --git a/tests/phpunit/includes/media/TiffTest.php b/tests/phpunit/includes/media/TiffTest.php index 3a6dc356ec..d4cf503b93 100644 --- a/tests/phpunit/includes/media/TiffTest.php +++ b/tests/phpunit/includes/media/TiffTest.php @@ -6,6 +6,7 @@ class TiffTest extends MediaWikiTestCase { $this->showExif = $wgShowEXIF; $wgShowEXIF = true; $this->filePath = dirname( __FILE__ ) . '/../../data/media/'; + $this->handler = new TiffHandler; } public function tearDown() { @@ -17,8 +18,7 @@ class TiffTest extends MediaWikiTestCase { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } - $tiff = new TiffHandler; - $res = $tiff->getMetadata( null, $this->filePath . 'README' ); + $res = $this->handler->getMetadata( null, $this->filePath . 'README' ); $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res ); } @@ -26,8 +26,7 @@ class TiffTest extends MediaWikiTestCase { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } - $tiff = new TiffHandler; - $res = $tiff->getMetadata( null, $this->filePath . 'test.tiff' ); + $res = $this->handler->getMetadata( null, $this->filePath . 'test.tiff' ); $expected = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}'; // Re-unserialize in case there are subtle differences between how versions // of php serialize stuff. diff --git a/tests/phpunit/includes/media/XMPTest.php b/tests/phpunit/includes/media/XMPTest.php new file mode 100644 index 0000000000..d1ec4767df --- /dev/null +++ b/tests/phpunit/includes/media/XMPTest.php @@ -0,0 +1,154 @@ +markIncomplete( 'Requires libxml to do XMP parsing' ); + } + if ( !is_string( $xmp ) || !is_array( $expected ) ) { + throw new Exception( "Invalid data provided to " . __METHOD__ ); + } + $reader = new XMPReader; + $reader->parse( $xmp ); + $this->assertEquals( $expected, $reader->getResults(), $info ); + } + + public function dataXMPParse() { + $xmpPath = dirname( __FILE__ ) . '/../../data/xmp/' ; + $data = array(); + + // $xmpFiles format: array of arrays with first arg file base name, + // with the actual file having .xmp on the end for the xmp + // and .result.php on the end for a php file containing the result + // array. Second argument is some info on what's being tested. + $xmpFiles = array( + array( '1', 'parseType=Resource test' ), + array( '2', 'Structure with mixed attribute and element props' ), + array( '3', 'Extra qualifiers (that should be ignored)' ), + array( '3-invalid', 'Test ignoring qualifiers that look like normal props' ), + array( '4', 'Flash as qualifier' ), + array( '5', 'Flash as qualifier 2' ), + array( '6', 'Multiple rdf:Description' ), + array( '7', 'Generic test of several property types' ), + array( 'flash', 'Test of Flash property' ), + array( 'invalid-child-not-struct', 'Test child props not in struct or ignored' ), + array( 'no-recognized-props', 'Test namespace and no recognized props' ), + array( 'no-namespace', 'Test non-namespaced attributes are ignored' ), + array( 'bag-for-seq', "Allow bag's instead of seq's. (bug 27105)" ), + array( 'utf16BE', 'UTF-16BE encoding' ), + array( 'utf16LE', 'UTF-16LE encoding' ), + array( 'utf32BE', 'UTF-32BE encoding' ), + array( 'utf32LE', 'UTF-32LE encoding' ), + array( 'xmpExt', 'Extended XMP missing second part' ), + ); + foreach( $xmpFiles as $file ) { + $xmp = file_get_contents( $xmpPath . $file[0] . '.xmp' ); + // I'm not sure if this is the best way to handle getting the + // result array, but it seems kind of big to put directly in the test + // file. + $result = null; + include( $xmpPath . $file[0] . '.result.php' ); + $data[] = array( $xmp, $result, '[' . $file[0] . '.xmp] ' . $file[1] ); + } + return $data; + } + + /** Test ExtendedXMP block support. (Used when the XMP has to be split + * over multiple jpeg segments, due to 64k size limit on jpeg segments. + * + * @todo This is based on what the standard says. Need to find a real + * world example file to double check the support for this is right. + */ + function testExtendedXMP() { + $xmpPath = dirname( __FILE__ ) . '/../../data/xmp/'; + $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' ); + $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' ); + + $md5sum = '28C74E0AC2D796886759006FBE2E57B7'; // of xmpExt2.xmp + $length = pack( 'N', strlen( $extendedXMP ) ); + $offset = pack( 'N', 0 ); + $extendedPacket = $md5sum . $length . $offset . $extendedXMP; + + $reader = new XMPReader(); + $reader->parse( $standardXMP ); + $reader->parseExtended( $extendedPacket ); + $actual = $reader->getResults(); + + $expected = array( 'xmp-exif' => + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => 9, + 'FNumber' => '2/10', + ) + ); + + $this->assertEquals( $expected, $actual ); + } + + /** + * This test has an extended XMP block with a wrong guid (md5sum) + * and thus should only return the StandardXMP, not the ExtendedXMP. + */ + function testExtendedXMPWithWrongGUID() { + $xmpPath = dirname( __FILE__ ) . '/../../data/xmp/'; + $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' ); + $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' ); + + $md5sum = '28C74E0AC2D796886759006FBE2E57B9'; // Note last digit. + $length = pack( 'N', strlen( $extendedXMP ) ); + $offset = pack( 'N', 0 ); + $extendedPacket = $md5sum . $length . $offset . $extendedXMP; + + $reader = new XMPReader(); + $reader->parse( $standardXMP ); + $reader->parseExtended( $extendedPacket ); + $actual = $reader->getResults(); + + $expected = array( 'xmp-exif' => + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => 9, + ) + ); + + $this->assertEquals( $expected, $actual ); + } + /** + * Have a high offset to simulate a missing packet, + * which should cause it to ignore the ExtendedXMP packet. + */ + function testExtendedXMPMissingPacket() { + $xmpPath = dirname( __FILE__ ) . '/../../data/xmp/'; + $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' ); + $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' ); + + $md5sum = '28C74E0AC2D796886759006FBE2E57B7'; // of xmpExt2.xmp + $length = pack( 'N', strlen( $extendedXMP ) ); + $offset = pack( 'N', 2048 ); + $extendedPacket = $md5sum . $length . $offset . $extendedXMP; + + $reader = new XMPReader(); + $reader->parse( $standardXMP ); + $reader->parseExtended( $extendedPacket ); + $actual = $reader->getResults(); + + $expected = array( 'xmp-exif' => + array( + 'DigitalZoomRatio' => '0/10', + 'Flash' => 9, + ) + ); + + $this->assertEquals( $expected, $actual ); + } + +} -- 2.20.1