Start on test cases for bug 6672 (Exif orientation support), follow up to r79845.
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 13 Jun 2011 22:13:38 +0000 (22:13 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 13 Jun 2011 22:13:38 +0000 (22:13 +0000)
Unfortunately seem to be hitting a wall right off at checking width & height; BitmapHandler reports back the pre-rotation width & height, leading to the oddity that a file that's clearly 1024px tall and 768px wide reports itself as 1024px wide and 768px tall.
Haven't gotten to generating rotated output to confirm file size. :)

Marked test case as broken pending fix so it doesn't add to surprise regressions in test reports.

tests/phpunit/includes/media/ExifRotationTest.php [new file with mode: 0644]
tests/phpunit/includes/media/landscape-plain.jpg [new file with mode: 0644]
tests/phpunit/includes/media/portrait-rotated.jpg [new file with mode: 0644]

diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php
new file mode 100644 (file)
index 0000000..b3e2aae
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * @group Broken
+ */
+class ExifRotationTest extends MediaWikiTestCase {
+
+       function setUp() {
+       }
+
+       /**
+        *
+        * @dataProvider providerFiles
+        */
+       function testMetadata( $name, $type, $info ) {
+               $handler = new BitmapHandler();
+
+               $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) . '/' . $name, $type );
+               $this->assertEquals( $file->getWidth(), $info['width'], "$name: width check" );
+               $this->assertEquals( $file->getHeight(), $info['height'], "$name: height check" );
+       }
+
+       function providerFiles() {
+               return array(
+                       array(
+                               'landscape-plain.jpg',
+                               'image/jpeg',
+                               array(
+                                       'width' => 1024,
+                                       'height' => 768,
+                               )
+                       ),
+                       array(
+                               'portrait-rotated.jpg',
+                               'image/jpeg',
+                               array(
+                                       'width' => 768, // as rotated
+                                       'height' => 1024, // as rotated
+                               )
+                       )
+               );
+       }
+}
+
diff --git a/tests/phpunit/includes/media/landscape-plain.jpg b/tests/phpunit/includes/media/landscape-plain.jpg
new file mode 100644 (file)
index 0000000..cf29655
Binary files /dev/null and b/tests/phpunit/includes/media/landscape-plain.jpg differ
diff --git a/tests/phpunit/includes/media/portrait-rotated.jpg b/tests/phpunit/includes/media/portrait-rotated.jpg
new file mode 100644 (file)
index 0000000..445feae
Binary files /dev/null and b/tests/phpunit/includes/media/portrait-rotated.jpg differ