r68347 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68346‎ | r68347 | r68348 >
Date:10:23, 21 June 2010
Author:mglaser
Status:deferred (Comments)
Tags:
Comment:
* tests for lossiness in thumb file names
* check if caspian.tif ist uploaded
* make tests run with de and en locale
Modified paths:
  • /trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php
@@ -45,6 +45,35 @@
4646 echo "testImages/Multipage.tif cannot be found.\n";
4747 $this->preCheckError = true;
4848 }
 49+
 50+ $caspianTitle = Title::newFromText('Image:Caspian.tif');
 51+ $this->image = wfFindFile($caspianTitle);
 52+ if (!$this->image)
 53+ {
 54+ if ($autoUpload)
 55+ {
 56+ echo "testImages/caspian.tif seems not to be present in the wiki. Trying to upload.\n";
 57+ $this->image = wfLocalFile( $caspianTitle );
 58+ $archive = $this->image->publish( dirname(__FILE__) . '/testImages/caspian.tif' );
 59+ $this->image->recordUpload( $archive->value, "Test file used for PagedTiffHandler unit test", "No license" );
 60+ if( WikiError::isError( $archive ) || !$archive->isGood() )
 61+ {
 62+ echo "Something went wrong. Please manually upload testImages/caspian.tif\n";
 63+ $this->preCheckError = true;
 64+ }
 65+ else
 66+ {
 67+ echo "Upload was successful.\n";
 68+ }
 69+ }
 70+ else
 71+ {
 72+ echo "Please upload the image testImages/caspian.tif into the wiki\n";
 73+ $this->preCheckError = true;
 74+ }
 75+
 76+ }
 77+
4978 $multipageTitle = Title::newFromText( 'Image:Multipage.tiff' );
5079 $this->image = wfFindFile( $multipageTitle );
5180 if ( !$this->image ) {
@@ -70,6 +99,7 @@
71100 }
72101
73102 function runTest() {
 103+ global $wgLanguageCode;
74104 // do not execute test if preconditions check returned false;
75105 if ( $this->preCheckError ) {
76106 return false;
@@ -87,6 +117,13 @@
88118 $params = array( 'width' => '100', 'height' => '100', 'page' => '4' );
89119 $this->handler->normaliseParams( $this->image, $params );
90120 $this->assertEquals( $params['height'], 75 );
 121+ // lossy and lossless
 122+ $params = array('width'=>'100', 'height'=>'100', 'page'=>'1');
 123+ $this->handler->normaliseParams($this->image, $params );
 124+ $this->assertEquals($params['lossy'], '1');
 125+ $params = array('width'=>'100', 'height'=>'100', 'page'=>'2');
 126+ $this->handler->normaliseParams($this->image, $params );
 127+ $this->assertEquals($params['lossy'], '0');
91128 // makeParamString
92129 $this->assertEquals(
93130 $this->handler->makeParamString(
@@ -98,12 +135,10 @@
99136 ),
100137 'lossless-page4-100px'
101138 );
102 -
103139 // ---- File upload checks and Thumbnail transformation
104140 // check
105141 // TODO: check other images
106142 $this->assertTrue( $this->handler->check( 'multipage.tiff', $this->path, $error ) );
107 -
108143 $this->handler->check( 'Caspian.tif', dirname( __FILE__ ) . '/testImages/caspian.tif', $error );
109144 $this->assertEquals( $error, 'tiff_bad_file' );
110145 // doTransform
@@ -116,7 +151,12 @@
117152 // TODO: 0 is obviously the same as NULL
118153 $this->assertEquals( $this->handler->getThumbExtension( $this->image, 2, '0' ), '.png' );
119154 // getLongDesc
120 - $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1.024', '768', '2,64 MB', 'image/tiff', '1' ) );
 155+ if ( $wgLanguageCode == 'de' ) {
 156+ $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1.024', '768', '2,64 MB', 'image/tiff', '1' ) );
 157+ } else {
 158+ // English
 159+ $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1,024', '768', '2.64 MB', 'image/tiff', '1' ) );
 160+ }
121161 // pageCount
122162 $this->assertEquals( $this->handler->pageCount( $this->image ), 7 );
123163 // getPageDimensions
@@ -132,7 +172,7 @@
133173 $this->assertEquals( $this->handler->getPageDimensions( $this->image, 8 ), array( 'width' => 768, 'height' => 1024 ) );
134174 // isMultiPage
135175 $this->assertTrue( $this->handler->isMultiPage( $this->image ) );
136 -
 176+
137177 // ---- Metadata handling
138178 // getMetadata
139179 $metadata = $this->handler->getMetadata( false, $this->path );

Comments

#Comment by Tim Starling (talk | contribs)   04:01, 29 June 2010

A review of the whole of PagedTiffHandler up to this point is at bug 23258.

Status & tagging log