Index: trunk/phase3/tests/phpunit/includes/media/README |
— | — | @@ -16,7 +16,8 @@ |
17 | 17 | |
18 | 18 | |
19 | 19 | greyscale-na-png.png, rgb-png.png, Xmp-exif-multilingual_test.jpg |
20 | | -greyscale-png.png, 1bit-png.png, Png-native-test.png, rgb-na-png.png |
| 20 | +greyscale-png.png, 1bit-png.png, Png-native-test.png, rgb-na-png.png, |
| 21 | +test.tiff, test.jpg |
21 | 22 | Are all by Bawolff. I don't think they contain enough originality to |
22 | 23 | claim copyright, but on the off chance they do, feel free to use them |
23 | 24 | however you feel fit, without restriction. |
Index: trunk/phase3/tests/phpunit/includes/media/test.jpg |
Cannot display: file marked as a binary type. |
svn:mime-type = image/jpeg |
Property changes on: trunk/phase3/tests/phpunit/includes/media/test.jpg |
___________________________________________________________________ |
Added: svn:mime-type |
24 | 25 | + image/jpeg |
Index: trunk/phase3/tests/phpunit/includes/media/test.tiff |
Cannot display: file marked as a binary type. |
svn:mime-type = image/tiff |
Property changes on: trunk/phase3/tests/phpunit/includes/media/test.tiff |
___________________________________________________________________ |
Added: svn:mime-type |
25 | 26 | + image/tiff |
Index: trunk/phase3/tests/phpunit/includes/media/JpegTest.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | +class JpegTest extends MediaWikiTestCase { |
| 4 | + |
| 5 | + public function testInvalidFile() { |
| 6 | + global $wgShowEXIF; |
| 7 | + if ( !$wgShowEXIF ) { |
| 8 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 9 | + } |
| 10 | + $jpeg = new JpegHandler; |
| 11 | + $res = $jpeg->getMetadata( null, dirname( __FILE__ ) . '/README' ); |
| 12 | + $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res ); |
| 13 | + } |
| 14 | + public function testTiffFile() { |
| 15 | + global $wgShowEXIF; |
| 16 | + if ( !$wgShowEXIF ) { |
| 17 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 18 | + } |
| 19 | + $h = new JpegHandler; |
| 20 | + $res = $h->getMetadata( null, dirname( __FILE__ ) . '/test.jpg' ); |
| 21 | + $expected = 'a:7:{s:16:"ImageDescription";s:9:"Test file";s:11:"XResolution";s:4:"72/1";s:11:"YResolution";s:4:"72/1";s:14:"ResolutionUnit";i:2;s:16:"YCbCrPositioning";i:1;s:15:"JPEGFileComment";a:1:{i:0;s:17:"Created with GIMP";}s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}'; |
| 22 | + // Hopefully php always serializes things in the same order. |
| 23 | + $this->assertEquals( $expected, $res ); |
| 24 | + } |
| 25 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/media/JpegTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 26 | + native |
Index: trunk/phase3/tests/phpunit/includes/media/TiffTest.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | +class TiffTest extends MediaWikiTestCase { |
| 4 | + |
| 5 | + public function testInvalidFile() { |
| 6 | + global $wgShowEXIF; |
| 7 | + if ( !$wgShowEXIF ) { |
| 8 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 9 | + } |
| 10 | + $tiff = new TiffHandler; |
| 11 | + $res = $tiff->getMetadata( null, dirname( __FILE__ ) . '/README' ); |
| 12 | + $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res ); |
| 13 | + } |
| 14 | + public function testTiffFile() { |
| 15 | + global $wgShowEXIF; |
| 16 | + if ( !$wgShowEXIF ) { |
| 17 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 18 | + } |
| 19 | + $tiff = new TiffHandler; |
| 20 | + $res = $tiff->getMetadata( null, dirname( __FILE__ ) . '/test.tiff' ); |
| 21 | + $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;}'; |
| 22 | + // Hopefully php always serializes things in the same order. |
| 23 | + $this->assertEquals( $expected, $res ); |
| 24 | + } |
| 25 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/media/TiffTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 26 | + native |
Index: trunk/phase3/tests/phpunit/includes/media/ExifBitmapTest.php |
— | — | @@ -0,0 +1,63 @@ |
| 2 | +<?php |
| 3 | +class ExifBitmapTest extends MediaWikiTestCase { |
| 4 | + |
| 5 | + public function testIsOldBroken() { |
| 6 | + global $wgShowEXIF; |
| 7 | + if ( !$wgShowEXIF ) { |
| 8 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 9 | + } |
| 10 | + $handler = new ExifBitmapHandler; |
| 11 | + $res = $handler->isMetadataValid( null, ExifBitmapHandler::OLD_BROKEN_FILE ); |
| 12 | + $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res ); |
| 13 | + } |
| 14 | + public function testIsBrokenFile() { |
| 15 | + global $wgShowEXIF; |
| 16 | + if ( !$wgShowEXIF ) { |
| 17 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 18 | + } |
| 19 | + $handler = new ExifBitmapHandler; |
| 20 | + $res = $handler->isMetadataValid( null, ExifBitmapHandler::BROKEN_FILE ); |
| 21 | + $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res ); |
| 22 | + } |
| 23 | + public function testIsInvalid() { |
| 24 | + global $wgShowEXIF; |
| 25 | + if ( !$wgShowEXIF ) { |
| 26 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 27 | + } |
| 28 | + $handler = new ExifBitmapHandler; |
| 29 | + $res = $handler->isMetadataValid( null, 'Something Invalid Here.' ); |
| 30 | + $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res ); |
| 31 | + } |
| 32 | + public function testGoodMetadata() { |
| 33 | + global $wgShowEXIF; |
| 34 | + if ( !$wgShowEXIF ) { |
| 35 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 36 | + } |
| 37 | + $handler = new ExifBitmapHandler; |
| 38 | + $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;}'; |
| 39 | + $res = $handler->isMetadataValid( null, $meta ); |
| 40 | + $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res ); |
| 41 | + } |
| 42 | + public function testIsOldGood() { |
| 43 | + global $wgShowEXIF; |
| 44 | + if ( !$wgShowEXIF ) { |
| 45 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 46 | + } |
| 47 | + $handler = new ExifBitmapHandler; |
| 48 | + $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;}'; |
| 49 | + $res = $handler->isMetadataValid( null, $meta ); |
| 50 | + $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res ); |
| 51 | + } |
| 52 | + // Handle metadata from paged tiff handler (gotten via instant commons) |
| 53 | + // gracefully. |
| 54 | + public function testPagedTiffHandledGracefully() { |
| 55 | + global $wgShowEXIF; |
| 56 | + if ( !$wgShowEXIF ) { |
| 57 | + $this->markTestIncomplete( "This test needs the exif extension." ); |
| 58 | + } |
| 59 | + $handler = new ExifBitmapHandler; |
| 60 | + $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";}'; |
| 61 | + $res = $handler->isMetadataValid( null, $meta ); |
| 62 | + $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res ); |
| 63 | + } |
| 64 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/media/ExifBitmapTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 65 | + native |