r97659 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97658‎ | r97659 | r97660 >
Date:20:04, 20 September 2011
Author:brion
Status:ok
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php
@@ -32,27 +32,45 @@
3333 */
3434 function testMetadata( $name, $type, $info ) {
3535 $file = UnregisteredLocalFile::newFromPath( $this->filePath . $name, $type );
36 - $this->assertEquals( $file->getWidth(), $info['width'], "$name: width check" );
37 - $this->assertEquals( $file->getHeight(), $info['height'], "$name: height check" );
 36+ $this->assertEquals( $info['width'], $file->getWidth(), "$name: width check" );
 37+ $this->assertEquals( $info['height'], $file->getHeight(), "$name: height check" );
3838 }
3939
4040 /**
4141 *
4242 * @dataProvider providerFiles
4343 */
44 - function testRotationRendering( $name, $type, $info ) {
45 - $file = $this->localFile( $name, $type );
46 - $thumb = $file->transform( array(
47 - 'width' => 800,
48 - 'height' => 600,
49 - ), File::RENDER_NOW );
 44+ function testRotationRendering( $name, $type, $info, $thumbs ) {
 45+ foreach( $thumbs as $size => $out ) {
 46+ if( preg_match('/^(\d+)px$/', $size, $matches ) ) {
 47+ $params = array(
 48+ 'width' => $matches[1],
 49+ );
 50+ } elseif ( preg_match( '/^(\d+)x(\d+)px$/', $size, $matches ) ) {
 51+ $params = array(
 52+ 'width' => $matches[1],
 53+ 'height' => $matches[2]
 54+ );
 55+ } else {
 56+ throw new MWException('bogus test data format ' . $size);
 57+ }
5058
51 - $this->assertEquals( $thumb->getWidth(), $info['thumbWidth'], "$name: thumb reported width check" );
52 - $this->assertEquals( $thumb->getHeight(), $info['thumbHeight'], "$name: thumb reported height check" );
 59+ $file = $this->localFile( $name, $type );
 60+ $thumb = $file->transform( $params, File::RENDER_NOW );
5361
54 - $gis = getimagesize( $thumb->getPath() );
55 - $this->assertEquals( $gis[0], $info['thumbWidth'], "$name: thumb actual width check");
56 - $this->assertEquals( $gis[0], $info['thumbWidth'], "$name: thumb actual height check");
 62+ $this->assertEquals( $out[0], $thumb->getWidth(), "$name: thumb reported width check for $size" );
 63+ $this->assertEquals( $out[1], $thumb->getHeight(), "$name: thumb reported height check for $size" );
 64+
 65+ $gis = getimagesize( $thumb->getPath() );
 66+ if ($out[0] > $info['width']) {
 67+ // Physical image won't be scaled bigger than the original.
 68+ $this->assertEquals( $info['width'], $gis[0], "$name: thumb actual width check for $size");
 69+ $this->assertEquals( $info['height'], $gis[1], "$name: thumb actual height check for $size");
 70+ } else {
 71+ $this->assertEquals( $out[0], $gis[0], "$name: thumb actual width check for $size");
 72+ $this->assertEquals( $out[1], $gis[1], "$name: thumb actual height check for $size");
 73+ }
 74+ }
5775 }
5876
5977 private function localFile( $name, $type ) {
@@ -67,8 +85,12 @@
6886 array(
6987 'width' => 1024,
7088 'height' => 768,
71 - 'thumbWidth' => 800,
72 - 'thumbHeight' => 600,
 89+ ),
 90+ array(
 91+ '800x600px' => array( 800, 600 ),
 92+ '9999x800px' => array( 1067, 800 ),
 93+ '800px' => array( 800, 600 ),
 94+ '600px' => array( 600, 450 ),
7395 )
7496 ),
7597 array(
@@ -77,8 +99,12 @@
78100 array(
79101 'width' => 768, // as rotated
80102 'height' => 1024, // as rotated
81 - 'thumbWidth' => 450,
82 - 'thumbHeight' => 600,
 103+ ),
 104+ array(
 105+ '800x600px' => array( 450, 600 ),
 106+ '9999x800px' => array( 600, 800 ),
 107+ '800px' => array( 800, 1067 ),
 108+ '600px' => array( 600, 800 ),
83109 )
84110 )
85111 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r97671* (bug 6672, 31024) Fixes for handling of images with an EXIF orientation...brion22:13, 20 September 2011
r97675MFT r97651, r97656, r97659 updated test cases for bug 6672, 31024...brion22:40, 20 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90016Start on test cases for bug 6672 (Exif orientation support), follow up to r79......brion22:13, 13 June 2011
r96687(bug 30640; follow-up r92279) Rotating images was making skewed images...bawolff20:13, 9 September 2011
r97398Follow-up r92635 Make sure the Exif related tests handle not having the Exif ...bawolff01:53, 18 September 2011
r97656Further tweaks to r96687, r90016, r97398 etc tests: actually produce a thumbn...brion19:39, 20 September 2011

Status & tagging log