r94867 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94866‎ | r94867 | r94868 >
Date:05:45, 18 August 2011
Author:bawolff
Status:ok
Tags:
Comment:
follow-up r86169: unit tests for extraction of JPEG comment (COM) segments.
Modified paths:
  • /trunk/phase3/tests/phpunit/data/media/README (modified) (history)
  • /trunk/phase3/tests/phpunit/data/media/jpeg-comment-binary.jpg (added) (history)
  • /trunk/phase3/tests/phpunit/data/media/jpeg-comment-iso8859-1.jpg (added) (history)
  • /trunk/phase3/tests/phpunit/data/media/jpeg-comment-multiple.jpg (added) (history)
  • /trunk/phase3/tests/phpunit/data/media/jpeg-comment-utf.jpg (added) (history)
  • /trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/JpegMetadataExtractorTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
@@ -32,4 +32,19 @@
3333
3434 $this->assertEquals( $expected, $meta['ImageDescription'] );
3535 }
 36+
 37+ /**
 38+ * Test for jpeg comments are being handled by
 39+ * BitmapMetadataHandler correctly.
 40+ *
 41+ * There's more extensive tests of comment extraction in
 42+ * JpegMetadataExtractorTests.php
 43+ */
 44+ public function testJpegComment() {
 45+ $meta = BitmapMetadataHandler::Jpeg( $this->filePath .
 46+ 'jpeg-comment-utf.jpg' );
 47+
 48+ $this->assertEquals( 'UTF-8 JPEG Comment — ¼',
 49+ $meta['JPEGFileComment'][0] );
 50+ }
3651 }
Index: trunk/phase3/tests/phpunit/includes/media/JpegMetadataExtractorTest.php
@@ -0,0 +1,32 @@
 2+<?php
 3+class JpegMetadataExtractorTest extends MediaWikiTestCase {
 4+
 5+ public function setUp() {
 6+ $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
 7+ }
 8+
 9+ public function testUtf8Comment() {
 10+ $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-utf.jpg' );
 11+ $this->assertEquals( array( 'UTF-8 JPEG Comment — ¼' ), $res['COM'] );
 12+ }
 13+ /** The file is iso-8859-1, but it should get auto converted */
 14+ public function testIso88591Comment() {
 15+ $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-iso8859-1.jpg' );
 16+ $this->assertEquals( array( 'ISO-8859-1 JPEG Comment - ¼' ), $res['COM'] );
 17+ }
 18+ /** Comment values that are non-textual (random binary junk) should not be shown.
 19+ * The example test file has a comment with a 0x5 byte in it which is a control character
 20+ * and considered binary junk for our purposes.
 21+ */
 22+ public function testBinaryCommentStripped() {
 23+ $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-binary.jpg' );
 24+ $this->assertEmpty( $res['COM'] );
 25+ }
 26+ /* Very rarely a file can have multiple comments.
 27+ * Order of comments is based on order inside the file.
 28+ */
 29+ public function testMultipleComment() {
 30+ $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-multiple.jpg' );
 31+ $this->assertEquals( array( 'foo', 'bar' ), $res['COM'] );
 32+ }
 33+}
Property changes on: trunk/phase3/tests/phpunit/includes/media/JpegMetadataExtractorTest.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/phase3/tests/phpunit/data/media/jpeg-comment-binary.jpg
Cannot display: file marked as a binary type.
svn:mime-type = image/jpeg
Property changes on: trunk/phase3/tests/phpunit/data/media/jpeg-comment-binary.jpg
___________________________________________________________________
Added: svn:mime-type
235 + image/jpeg
Index: trunk/phase3/tests/phpunit/data/media/jpeg-comment-iso8859-1.jpg
Cannot display: file marked as a binary type.
svn:mime-type = image/jpeg
Property changes on: trunk/phase3/tests/phpunit/data/media/jpeg-comment-iso8859-1.jpg
___________________________________________________________________
Added: svn:mime-type
336 + image/jpeg
Index: trunk/phase3/tests/phpunit/data/media/README
@@ -21,7 +21,8 @@
2222
2323 greyscale-na-png.png, rgb-png.png, Xmp-exif-multilingual_test.jpg
2424 greyscale-png.png, 1bit-png.png, Png-native-test.png, rgb-na-png.png,
25 -test.tiff, test.jpg
 25+test.tiff, test.jpg, jpeg-comment-multiple.jpg, jpeg-comment-utf.jpg,
 26+jpeg-comment-iso8859-1.jpg, jpeg-comment-binary.jpg
2627 Are all by Bawolff. I don't think they contain enough originality to
2728 claim copyright, but on the off chance they do, feel free to use them
2829 however you feel fit, without restriction.
Index: trunk/phase3/tests/phpunit/data/media/jpeg-comment-multiple.jpg
Cannot display: file marked as a binary type.
svn:mime-type = image/jpeg
Property changes on: trunk/phase3/tests/phpunit/data/media/jpeg-comment-multiple.jpg
___________________________________________________________________
Added: svn:mime-type
2930 + image/jpeg
Index: trunk/phase3/tests/phpunit/data/media/jpeg-comment-utf.jpg
Cannot display: file marked as a binary type.
svn:mime-type = image/jpeg
Property changes on: trunk/phase3/tests/phpunit/data/media/jpeg-comment-utf.jpg
___________________________________________________________________
Added: svn:mime-type
3031 + image/jpeg

Follow-up revisions

RevisionCommit summaryAuthorDate
r102528REL1_18 MFT r94867, r95163, r100576reedy16:22, 9 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86169Merge to trunk everything in img_metadata branch....bawolff01:23, 16 April 2011

Status & tagging log