http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97659

Revision: 97659
Author:   brion
Date:     2011-09-20 20:04:26 +0000 (Tue, 20 Sep 2011)
Log Message:
-----------
Further tweaks to r96687, r90016, r97398, r97656 etc tests: try several 
thumbnail resolutions so we test both width-only and width & height requests

Modified Paths:
--------------
    trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php

Modified: trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php      
2011-09-20 20:00:05 UTC (rev 97658)
+++ trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php      
2011-09-20 20:04:26 UTC (rev 97659)
@@ -32,27 +32,45 @@
         */
        function testMetadata( $name, $type, $info ) {
                $file = UnregisteredLocalFile::newFromPath( $this->filePath . 
$name, $type );
-               $this->assertEquals( $file->getWidth(), $info['width'], "$name: 
width check" );
-               $this->assertEquals( $file->getHeight(), $info['height'], 
"$name: height check" );
+               $this->assertEquals( $info['width'], $file->getWidth(), "$name: 
width check" );
+               $this->assertEquals( $info['height'], $file->getHeight(), 
"$name: height check" );
        }
 
        /**
         *
         * @dataProvider providerFiles
         */
-       function testRotationRendering( $name, $type, $info ) {
-               $file = $this->localFile( $name, $type );
-               $thumb = $file->transform( array(
-                       'width' => 800,
-                       'height' => 600,
-               ), File::RENDER_NOW );
+       function testRotationRendering( $name, $type, $info, $thumbs ) {
+               foreach( $thumbs as $size => $out ) {
+                       if( preg_match('/^(\d+)px$/', $size, $matches ) ) {
+                               $params = array(
+                                       'width' => $matches[1],
+                               );
+                       } elseif ( preg_match( '/^(\d+)x(\d+)px$/', $size, 
$matches ) ) {
+                               $params = array(
+                                       'width' => $matches[1],
+                                       'height' => $matches[2]
+                               );
+                       } else {
+                               throw new MWException('bogus test data format ' 
. $size);
+                       }
 
-               $this->assertEquals( $thumb->getWidth(), $info['thumbWidth'], 
"$name: thumb reported width check" );
-               $this->assertEquals( $thumb->getHeight(), $info['thumbHeight'], 
"$name: thumb reported height check" );
+                       $file = $this->localFile( $name, $type );
+                       $thumb = $file->transform( $params, File::RENDER_NOW );
 
-               $gis = getimagesize( $thumb->getPath() );
-               $this->assertEquals( $gis[0], $info['thumbWidth'], "$name: 
thumb actual width check");
-               $this->assertEquals( $gis[0], $info['thumbWidth'], "$name: 
thumb actual height check");
+                       $this->assertEquals( $out[0], $thumb->getWidth(), 
"$name: thumb reported width check for $size" );
+                       $this->assertEquals( $out[1], $thumb->getHeight(), 
"$name: thumb reported height check for $size" );
+
+                       $gis = getimagesize( $thumb->getPath() );
+                       if ($out[0] > $info['width']) {
+                               // Physical image won't be scaled bigger than 
the original.
+                               $this->assertEquals( $info['width'], $gis[0], 
"$name: thumb actual width check for $size");
+                               $this->assertEquals( $info['height'], $gis[1], 
"$name: thumb actual height check for $size");
+                       } else {
+                               $this->assertEquals( $out[0], $gis[0], "$name: 
thumb actual width check for $size");
+                               $this->assertEquals( $out[1], $gis[1], "$name: 
thumb actual height check for $size");
+                       }
+               }
        }
 
        private function localFile( $name, $type ) {
@@ -67,8 +85,12 @@
                                array(
                                        'width' => 1024,
                                        'height' => 768,
-                                       'thumbWidth' => 800,
-                                       'thumbHeight' => 600,
+                               ),
+                               array(
+                                       '800x600px' => array( 800, 600 ),
+                                       '9999x800px' => array( 1067, 800 ),
+                                       '800px' => array( 800, 600 ),
+                                       '600px' => array( 600, 450 ),
                                )
                        ),
                        array(
@@ -77,8 +99,12 @@
                                array(
                                        'width' => 768, // as rotated
                                        'height' => 1024, // as rotated
-                                       'thumbWidth' => 450,
-                                       'thumbHeight' => 600,
+                               ),
+                               array(
+                                       '800x600px' => array( 450, 600 ),
+                                       '9999x800px' => array( 600, 800 ),
+                                       '800px' => array( 800, 1067 ),
+                                       '600px' => array( 600, 800 ),
                                )
                        )
                );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to