r70258 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70257‎ | r70258 | r70259 >
Date:08:02, 1 August 2010
Author:mglaser
Status:deferred
Tags:
Comment:
changed selenium tests in order to work with the new architecture of the selenium framework
Modified paths:
  • /trunk/extensions/PagedTiffHandler/PagedTiffHandler.php (modified) (history)
  • /trunk/extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestCases.php (added) (history)
  • /trunk/extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestSuite.php (added) (history)

Diff [purge]

Index: trunk/extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestSuite.php
@@ -0,0 +1,162 @@
 2+<?php
 3+/**
 4+ * To get this working you must
 5+ * - set a valid path to PEAR
 6+ * - check upload size in php.ini: Multipage.tiff needs at least 3M
 7+ * - Either upload multipage.tiff when PagedTiffHandler is active or
 8+ * - - set $egSeleniumTiffTestUploads = true.
 9+ * - if $wgSeleniumTiffTestsUploads = true, please remember to obtain
 10+ * - - all missing test images. See
 11+ * - - testImages/SOURCES.txt for further information
 12+ * - set the locale to English
 13+ */
 14+
 15+require_once(dirname( __FILE__ ) . '/PagedTiffHandlerTestCases.php');
 16+
 17+class PagedTiffHandlerSeleniumTestSuite extends SeleniumTestSuite {
 18+
 19+ public $egSeleniumTiffTestUploads = false;
 20+ public $egSeleniumTiffTestCheckPrerequistes = true;
 21+
 22+ public function __construct( $name = 'PagedTiffHandler Test Suite') {
 23+ parent::__construct( $name );
 24+ }
 25+
 26+ public function addTests() {
 27+ if ( $this->egSeleniumTiffTestCheckPrerequistes ) {
 28+ parent::addTest( new SeleniumCheckPrerequisites() );
 29+ }
 30+
 31+ if ( $this->egSeleniumTiffTestUploads ) {
 32+ parent::addTest( new SeleniumUploadBrokenTiffTest(
 33+ 'caspian.tif',
 34+ 'The uploaded file contains errors.' ) );
 35+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 36+ 'cramps.tif' ) );
 37+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 38+ 'cramps-tile.tif' ) );
 39+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 40+ 'dscf0013.tif' ) );
 41+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 42+ 'fax2d.tif' ) );
 43+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 44+ 'g3test.tif' ) );
 45+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 46+ 'Jello.tif' ) );
 47+ parent::addTest( new SeleniumUploadBrokenTiffTest(
 48+ 'jim___ah.tif',
 49+ 'The reported file size does not match' .
 50+ ' the actual file size.' ) );
 51+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 52+ 'jim___cg.tif' ) );
 53+ parent::addTest( new SeleniumUploadBrokenTiffTest(
 54+ 'jim___dg.tif', 'The reported file size does' .
 55+ ' not match the actual file size.' ) );
 56+ parent::addTest( new SeleniumUploadBrokenTiffTest(
 57+ 'jim___gg.tif', 'The reported file size does' .
 58+ ' not match the actual file size.' ) );
 59+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 60+ 'ladoga.tif' ) );
 61+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 62+ 'off_l16.tif' ) );
 63+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 64+ 'off_luv24.tif' ) );
 65+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 66+ 'off_luv24.tif' ) );
 67+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 68+ 'oxford.tif' ) );
 69+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 70+ 'pc260001.tif' ) );
 71+ parent::addTest( new SeleniumUploadBrokenTiffTest(
 72+ 'quad-jpeg.tif', 'The uploaded file could not' .
 73+ ' be processed. ImageMagick is not available.' ) );
 74+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 75+ 'quad-lzw.tif' ) );
 76+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 77+ 'quad-tile.tif' ) );
 78+ parent::addTest( new SeleniumUploadBrokenTiffTest(
 79+ 'smallliz.tif', 'The uploaded file could not' .
 80+ ' be processed. ImageMagick is not available.' ) );
 81+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 82+ 'strike.tif' ) );
 83+ parent::addTest( new SeleniumUploadBrokenTiffTest(
 84+ 'text.tif', 'The uploaded file contains errors.' ) );
 85+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 86+ 'ycbcr-cat.tif' ) );
 87+ parent::addTest( new SeleniumUploadBrokenTiffTest(
 88+ 'zackthecat.tif', 'The uploaded file could not' .
 89+ ' be processed. ImageMagick is not available.' ) );
 90+ parent::addTest( new SeleniumUploadWorkingTiffTest(
 91+ 'multipage.tiff' ) );
 92+ }
 93+ //parent::addTest( new SeleniumUploadWorkingTiffTest( 'multipage.tiff' ) );
 94+
 95+ parent::addTest( new SeleniumEmbedTiffInclusionTest() );
 96+ parent::addTest( new SeleniumEmbedTiffThumbRatioTest() );
 97+ parent::addTest( new SeleniumEmbedTiffBoxFitTest() );
 98+
 99+ parent::addTest( new SeleniumEmbedTiffPage2InclusionTest() );
 100+ parent::addTest( new SeleniumEmbedTiffPage2ThumbRatioTest() );
 101+ parent::addTest( new SeleniumEmbedTiffPage2BoxFitTest() );
 102+
 103+ parent::addTest( new SeleniumEmbedTiffNegativePageParameterTest() );
 104+ parent::addTest( new SeleniumEmbedTiffPageParameterTooHighTest() );
 105+
 106+ parent::addTest( new SeleniumDisplayInCategoryTest() );
 107+ parent::addTest( new SeleniumDisplayInGalleryTest() );
 108+
 109+ if ( $this->egSeleniumTiffTestUploads ) {
 110+ parent::addTest( new SeleniumDeleteTiffTest(
 111+ 'cramps.tif' ) );
 112+ parent::addTest( new SeleniumDeleteTiffTest(
 113+ 'cramps-tile.tif' ) );
 114+ parent::addTest( new SeleniumDeleteTiffTest(
 115+ 'dscf0013.tif' ) );
 116+ parent::addTest( new SeleniumDeleteTiffTest(
 117+ 'fax2d.tif' ) );
 118+ parent::addTest( new SeleniumDeleteTiffTest(
 119+ 'g3test.tif' ) );
 120+ parent::addTest( new SeleniumDeleteTiffTest(
 121+ 'Jello.tif' ) );
 122+ //parent::addTest( new SeleniumDeleteTiffTest(
 123+ //'jim___ah.tif' ) );
 124+ parent::addTest( new SeleniumDeleteTiffTest(
 125+ 'jim___cg.tif' ) );
 126+ //parent::addTest( new SeleniumDeleteTiffTest(
 127+ //'jim___dg.tif' ) );
 128+ //parent::addTest( new SeleniumDeleteTiffTest(
 129+ //'jim___gg.tif' ) );
 130+ parent::addTest( new SeleniumDeleteTiffTest(
 131+ 'ladoga.tif' ) );
 132+ parent::addTest( new SeleniumDeleteTiffTest(
 133+ 'off_l16.tif' ) );
 134+ parent::addTest( new SeleniumDeleteTiffTest(
 135+ 'off_luv24.tif' ) );
 136+ parent::addTest( new SeleniumDeleteTiffTest(
 137+ 'off_luv24.tif' ) );
 138+ parent::addTest( new SeleniumDeleteTiffTest(
 139+ 'oxford.tif' ) );
 140+ parent::addTest( new SeleniumDeleteTiffTest(
 141+ 'pc260001.tif' ) );
 142+ //parent::addTest( new SeleniumDeleteTiffTest(
 143+ //'quad-jpeg.tif' ) );
 144+ parent::addTest( new SeleniumDeleteTiffTest(
 145+ 'quad-lzw.tif' ) );
 146+ parent::addTest( new SeleniumDeleteTiffTest(
 147+ 'quad-tile.tif' ) );
 148+ //parent::addTest( new SeleniumDeleteTiffTest(
 149+ //'smallliz.tif' ) );
 150+ parent::addTest( new SeleniumDeleteTiffTest(
 151+ 'strike.tif' ) );
 152+ //parent::addTest( new SeleniumDeleteTiffTest(
 153+ //'text.tif' ) );
 154+ parent::addTest( new SeleniumDeleteTiffTest(
 155+ 'ycbcr-cat.tif' ) );
 156+ //parent::addTest( new SeleniumDeleteTiffTest(
 157+ //'zackthecat.tif' ) );
 158+ parent::addTest( new SeleniumDeleteTiffTest(
 159+ 'multipage.tiff' ) );
 160+ }
 161+ }
 162+}
 163+
Property changes on: trunk/extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestSuite.php
___________________________________________________________________
Added: svn:keywords
1164 + LastChangedDate LastChangedBy Revision Id
Index: trunk/extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestCases.php
@@ -0,0 +1,307 @@
 2+<?php
 3+
 4+class SeleniumCheckPrerequisites extends SeleniumTestCase {
 5+ public $name = 'Check prerequisites';
 6+ private $prerequisiteError = null;
 7+ public function runTest() {
 8+
 9+ // check whether Multipage.tiff is already uploaded
 10+ $this->open( Selenium::getBaseUrl() .
 11+ '/index.php?title=Image:Multipage.tiff' );
 12+
 13+ $source = $this->getAttribute( "//div[@id='bodyContent']//ul@id" );
 14+ if ( $source != 'filetoc' ) {
 15+ $this->prerequisiteError = 'Image:Multipage.tiff must exist.';
 16+ }
 17+
 18+ // Check for language
 19+ $this->open( Selenium::getBaseUrl() .
 20+ '/api.php?action=query&meta=userinfo&uiprop=options&format=xml');
 21+
 22+ $lang = $this->getAttribute( "//options/@language" );
 23+ if ( $lang != 'en' ) {
 24+ $this->prerequisiteError =
 25+ 'interface language must be set to' .
 26+ ' English (en), but was '.$lang.'.';
 27+ }
 28+ }
 29+
 30+ public function tearDown() {
 31+ if ( $this->prerequisiteError ) {
 32+ $this->selenium->stop();
 33+ die( 'failed: ' . $this->prerequisiteError . "\n" );
 34+ }
 35+ }
 36+}
 37+
 38+class SeleniumUploadTiffTest extends SeleniumTestCase {
 39+ public function uploadFile( $filename ) {
 40+
 41+ $this->open( Selenium::getBaseUrl() .
 42+ '/index.php?title=Special:Upload' );
 43+ $this->type( 'wpUploadFile', dirname( __FILE__ ) .
 44+ "\\testImages\\" . $filename );
 45+ $this->check( 'wpIgnoreWarning' );
 46+ $this->click( 'wpUpload' );
 47+ $this->waitForPageToLoad( 30000 );
 48+ }
 49+
 50+ public function assertUploaded( $filename ) {
 51+ $this->assertSeleniumHTMLContains(
 52+ '//h1[@class="firstHeading"]', ucfirst( $filename ) );
 53+ }
 54+
 55+ public function assertErrorMsg( $msg ) {
 56+ $this->assertSeleniumHTMLContains(
 57+ '//div[@id="bodyContent"]//span[@class="error"]', $msg );
 58+ }
 59+
 60+}
 61+
 62+class SeleniumUploadWorkingTiffTest extends SeleniumUploadTiffTest {
 63+ public $name = 'Upload working Tiff: ';
 64+ private $filename;
 65+
 66+ public function __construct( $filename ) {
 67+ parent::__construct();
 68+ $this->filename = $filename;
 69+ $this->name .= $filename;
 70+ }
 71+
 72+ public function runTest() {
 73+ $this->uploadFile( $this->filename );
 74+ $this->assertUploaded( str_replace( '_', ' ', $this->filename ) );
 75+ }
 76+}
 77+
 78+class SeleniumUploadBrokenTiffTest extends SeleniumUploadTiffTest {
 79+ public $name = 'Upload broken Tiff: ';
 80+ private $filename;
 81+ private $errorMsg;
 82+
 83+ public function __construct( $filename, $errorMsg ) {
 84+ parent::__construct();
 85+ $this->filename = $filename;
 86+ $this->name .= $filename;
 87+ $this->errorMsg = $errorMsg;
 88+ }
 89+
 90+ public function runTest() {
 91+ $this->uploadFile( $this->filename );
 92+ $this->assertErrorMsg( $this->errorMsg );
 93+ }
 94+}
 95+
 96+class SeleniumDeleteTiffTest extends SeleniumTestCase {
 97+ public $name = 'Delete Tiff: ';
 98+ private $filename;
 99+
 100+ public function __construct( $filename ) {
 101+ parent::__construct();
 102+ $this->filename = $filename;
 103+ $this->name .= $filename;
 104+ }
 105+
 106+ public function runTest() {
 107+
 108+ $this->open( Selenium::getBaseUrl() . '/index.php?title=Image:'
 109+ . ucfirst( $this->filename ) . '&action=delete' );
 110+ $this->type( 'wpReason', 'Remove test file' );
 111+ $this->click( 'mw-filedelete-submit' );
 112+ $this->waitForPageToLoad( 10000 );
 113+
 114+ // Todo: This message is localized
 115+ $this->assertSeleniumHTMLContains( '//div[@id="bodyContent"]/p',
 116+ ucfirst( $this->filename ) . '.*has been deleted.' );
 117+ }
 118+
 119+}
 120+
 121+class SeleniumEmbedTiffTest extends SeleniumTestCase { //PHPUnit_Extensions_SeleniumTestCase
 122+
 123+ public function tearDown() {
 124+
 125+ parent::tearDown();
 126+ // Clear EmbedTiffTest page for future tests
 127+ $this->open( Selenium::getBaseUrl() .
 128+ '/index.php?title=EmbedTiffTest&action=edit' );
 129+ $this->type( 'wpTextbox1', '' );
 130+ $this->click( 'wpSave' );
 131+ }
 132+
 133+ public function preparePage( $text ) {
 134+
 135+ $this->open( Selenium::getBaseUrl() .
 136+ '/index.php?title=EmbedTiffTest&action=edit' );
 137+ $this->type( 'wpTextbox1', $text );
 138+ $this->click( 'wpSave' );
 139+ $this->waitForPageToLoad( 10000 );
 140+ }
 141+
 142+}
 143+
 144+class SeleniumTiffPageTest extends SeleniumTestCase {
 145+ public function tearDown() {
 146+ parent::tearDown();
 147+ // Clear EmbedTiffTest page for future tests
 148+ $this->open( Selenium::getBaseUrl() . '/index.php?title=Image:'
 149+ . $this->image . '&action=edit' );
 150+ $this->type( 'wpTextbox1', '' );
 151+ $this->click( 'wpSave' );
 152+ }
 153+
 154+ public function prepareImagePage( $image, $text ) {
 155+
 156+ $this->image = $image;
 157+ $this->open( Selenium::getBaseUrl() . '/index.php?title=Image:'
 158+ . $image . '&action=edit' );
 159+ $this->type( 'wpTextbox1', $text );
 160+ $this->click( 'wpSave' );
 161+ $this->waitForPageToLoad( 10000 );
 162+
 163+ }
 164+}
 165+
 166+class SeleniumDisplayInCategoryTest extends SeleniumTiffPageTest {
 167+ public $name = 'Display in category';
 168+
 169+ public function runTest() {
 170+ $this->prepareImagePage( 'Multipage.tiff',
 171+ "[[Category:Wiki]]\n" );
 172+
 173+
 174+ $this->open( Selenium::getBaseUrl() . '/index.php?title=Category:Wiki' );
 175+
 176+ // Ergebnis chekcen
 177+ $source = $this->getAttribute(
 178+ "//div[@class='gallerybox']//a[@class='image']//img@src" );
 179+ $correct = strstr( $source, "-page1-" );
 180+ $this->assertEquals( $correct, true );
 181+ }
 182+}
 183+
 184+class SeleniumDisplayInGalleryTest extends SeleniumEmbedTiffTest {
 185+ public $name = 'Display in gallery';
 186+
 187+ public function runTest() {
 188+ $this->preparePage( "<gallery>\nImage:Multipage.tiff\n</gallery>\n" );
 189+
 190+ //
 191+ //$this->open( Selenium::getBaseUrl() . '/index.php?title=GalleryTest' );
 192+
 193+ // Ergebnis chekcen
 194+ //$source = $this->getAttribute(
 195+ //"//div[@class='gallerybox']//a[@title='Multipage.tiff']//img@src" );
 196+ $source = $this->getAttribute(
 197+ "//div[@class='gallerybox']//a[@class='image']//img@src" );
 198+ $correct = strstr( $source, "-page1-" );
 199+ $this->assertEquals( $correct, true );
 200+
 201+ }
 202+}
 203+
 204+class SeleniumEmbedTiffInclusionTest extends SeleniumEmbedTiffTest {
 205+ public $name = 'Include Tiff Images';
 206+
 207+ public function runTest() {
 208+ $this->preparePage( "[[Image:Multipage.tiff]]\n" );
 209+
 210+ $this->assertSeleniumAttributeEquals(
 211+ "//div[@id='bodyContent']//img@height", '768' );
 212+ $this->assertSeleniumAttributeEquals(
 213+ "//div[@id='bodyContent']//img@width", '1024' );
 214+ }
 215+}
 216+
 217+class SeleniumEmbedTiffThumbRatioTest extends SeleniumEmbedTiffTest {
 218+ public $name = "Include Tiff Thumbnail Aspect Ratio";
 219+
 220+ public function runTest() {
 221+ $this->preparePage( "[[Image:Multipage.tiff|200px]]\n" );
 222+ //$this->selenium->type( 'wpTextbox1',
 223+ // "[[Image:Pc260001.tif|thumb]]\n" );
 224+
 225+ $this->assertSeleniumAttributeEquals(
 226+ "//div[@id='bodyContent']//img@height", '150' );
 227+ $this->assertSeleniumAttributeEquals(
 228+ "//div[@id='bodyContent']//img@width", '200' );
 229+ }
 230+}
 231+
 232+class SeleniumEmbedTiffBoxFitTest extends SeleniumEmbedTiffTest {
 233+ public $name = 'Include Tiff Box Fit';
 234+
 235+ public function runTest() {
 236+ $this->preparePage( "[[Image:Multipage.tiff|200x75px]]\n" );
 237+
 238+ $this->assertSeleniumAttributeEquals(
 239+ "//div[@id='bodyContent']//img@height", '75' );
 240+ $this->assertSeleniumAttributeEquals(
 241+ "//div[@id='bodyContent']//img@width", '100' );
 242+ }
 243+}
 244+
 245+class SeleniumEmbedTiffPage2InclusionTest extends SeleniumEmbedTiffTest {
 246+ public $name = 'Include Tiff Images: Page 2';
 247+
 248+ public function runTest() {
 249+ $this->preparePage( "[[Image:Multipage.tiff|page=2]]\n" );
 250+ //$this->selenium->type( 'wpTextbox1', "[[Image:Pc260001.tif|thumb]]\n" );
 251+
 252+ $this->assertSeleniumAttributeEquals(
 253+ "//div[@id='bodyContent']//img@height", '564' );
 254+ $this->assertSeleniumAttributeEquals(
 255+ "//div[@id='bodyContent']//img@width", '640' );
 256+ }
 257+}
 258+
 259+class SeleniumEmbedTiffPage2ThumbRatioTest extends SeleniumEmbedTiffTest {
 260+ public $name = 'Include Tiff Thumbnail Aspect Ratio: Page 2';
 261+
 262+ public function runTest() {
 263+ $this->preparePage( "[[Image:Multipage.tiff|320px|page=2]]\n" );
 264+
 265+ $this->assertSeleniumAttributeEquals(
 266+ "//div[@id='bodyContent']//img@height", '282' );
 267+ $this->assertSeleniumAttributeEquals(
 268+ "//div[@id='bodyContent']//img@width", '320' );
 269+ }
 270+}
 271+
 272+class SeleniumEmbedTiffPage2BoxFitTest extends SeleniumEmbedTiffTest {
 273+ public $name = 'Include Tiff Box Fit: Page 2';
 274+
 275+ public function runTest() {
 276+ $this->preparePage( "[[Image:Multipage.tiff|200x108px|page=2]]\n" );
 277+
 278+ $this->assertSeleniumAttributeEquals(
 279+ "//div[@id='bodyContent']//img@height", '108' );
 280+ $this->assertSeleniumAttributeEquals(
 281+ "//div[@id='bodyContent']//img@width", '123' );
 282+ }
 283+}
 284+
 285+class SeleniumEmbedTiffNegativePageParameterTest extends SeleniumEmbedTiffTest {
 286+ public $name = 'Include Tiff: negative page parameter';
 287+
 288+ public function runTest() {
 289+ $this->preparePage( "[[Image:Multipage.tiff|page=-1]]\n" );
 290+
 291+ $source = $this->getAttribute( "//div[@id='bodyContent']//img@src" );
 292+ $correct = strstr( $source, "-page1-" );
 293+ $this->assertEquals( $correct, true );
 294+ }
 295+}
 296+
 297+class SeleniumEmbedTiffPageParameterTooHighTest extends SeleniumEmbedTiffTest {
 298+ public $name = 'Include Tiff: too high page parameter';
 299+
 300+ public function runTest() {
 301+ $this->preparePage( "[[Image:Multipage.tiff|page=8]]\n" );
 302+
 303+ $source = $this->getAttribute( "//div[@id='bodyContent']//img@src" );
 304+ $correct = strstr( $source, "-page7-" );
 305+ $this->assertEquals( $correct, true );
 306+ }
 307+}
 308+
Property changes on: trunk/extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestCases.php
___________________________________________________________________
Added: svn:keywords
1309 + LastChangedDate LastChangedBy Revision Id
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.php
@@ -102,6 +102,8 @@
103103 $wgAutoloadClasses['PagedTiffImage'] = $dir . 'PagedTiffHandler.image.php';
104104 $wgAutoloadClasses['PagedTiffHandler'] = $dir . 'PagedTiffHandler_body.php';
105105 $wgAutoloadClasses['TiffReader'] = $dir . 'TiffReader.php';
 106+$wgAutoloadClasses['PagedTiffHandlerSeleniumTestSuite'] = $dir . 'selenium/PagedTiffHandlerTestSuite.php';
 107+
106108 $wgMediaHandlers['image/tiff'] = 'PagedTiffHandler';
107109 $wgHooks['UploadVerification'][] = 'PagedTiffHandler::check';
108110 $wgHooks['LanguageGetMagic'][] = 'PagedTiffHandler::addTiffLossyMagicWordLang';

Status & tagging log