r68793 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68792‎ | r68793 | r68794 >
Date:21:44, 30 June 2010
Author:papyromancer
Status:deferred
Tags:
Comment:
moving selenium testing framework to avoid possible directory collision
Modified paths:
  • /branches/MwEmbedStandAlone/tests/RunSeleniumTests.php (modified) (history)
  • /branches/MwEmbedStandAlone/tests/commandLine.inc (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/LocalSeleniumSettings.php.sample (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/NewSeleniumTest.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/Selenium.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/SeleniumTestCase.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/SeleniumTestConsoleLogger.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/SeleniumTestHTMLLogger.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/SeleniumTestListener.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/SeleniumTestSuite.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium/SimpleSeleniumTest.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/LocalSeleniumSettings.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/LocalSeleniumSettings.php.sample (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/NewSeleniumTest.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/Selenium.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestCase.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestConsoleLogger.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestHTMLLogger.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestListener.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestSuite.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/SimpleSeleniumTest.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_framework/commandLine.inc (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_tests/EmbedPlayerLoadsTest.php (added) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_tests/amw-all-providers.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_tests/api-proxy.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_tests/audio-player-menu.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_tests/audio-player-playback-progress.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_tests/player-themable-display.php (deleted) (history)
  • /branches/MwEmbedStandAlone/tests/selenium_tests/player-timed-text.php (deleted) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/tests/commandLine.inc
@@ -1,48 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Backwards-compatibility wrapper for old-style maintenance scripts
6 - */
7 -#require( dirname( __FILE__ ) . '/Maintenance.php' );
8 -
9 -if ( !isset( $optionsWithArgs ) ) {
10 - $optionsWithArgs = array();
11 -}
12 -
13 -abstract class Maintenance {};
14 -
15 -class CommandLineInc extends Maintenance {
16 - public function __construct() {
17 - global $optionsWithArgs;
18 - parent::__construct();
19 - foreach ( $optionsWithArgs as $name ) {
20 - $this->addOption( $name, '', false, true );
21 - }
22 - }
23 -
24 - public function getDbType() {
25 - global $wgUseNormalUser;
26 -
27 - return ( isset( $wgUseNormalUser ) && $wgUseNormalUser ) ?
28 - Maintenance::DB_STD : Maintenance::DB_ADMIN;
29 - }
30 -
31 - /**
32 - * No help, it would just be misleading since it misses custom options
33 - */
34 - protected function maybeHelp( $force = false ) {
35 - if ( !$force )
36 - return;
37 - parent::maybeHelp( true );
38 - }
39 -
40 - public function execute() {
41 - global $args, $options;
42 - $args = $this->mArgs;
43 - $options = $this->mOptions;
44 - }
45 -}
46 -
47 -$maintClass = 'CommandLineInc';
48 -#require( DO_MAINTENANCE );
49 -
Index: branches/MwEmbedStandAlone/tests/RunSeleniumTests.php
@@ -26,8 +26,8 @@
2727 define( 'SELENIUMTEST', true );
2828
2929 // Here, you can override standard setting
30 -if ( file_exists( 'selenium/LocalSeleniumSettings.php' ) ) {
31 - include_once 'selenium/LocalSeleniumSettings.php';
 30+if ( file_exists( 'selenium_framework/LocalSeleniumSettings.php' ) ) {
 31+ include_once 'selenium_framework/LocalSeleniumSettings.php';
3232 } else {
3333 echo "You must provide local settings in LocalSeleniumSettings.php\n";
3434 die( -1 );
@@ -41,7 +41,7 @@
4242
4343 // Get command line parameters
4444 if ( $wgSeleniumTestsRunMode == 'cli' ) {
45 - require_once( dirname( __FILE__ ) . '/commandLine.inc' );
 45+ require_once( dirname( __FILE__ ) . '/selenium_framework/commandLine.inc' );
4646 if ( isset( $options['help'] ) ) {
4747 echo <<<ENDS
4848 MediaWiki $wgVersion Selenium Framework tester
@@ -64,12 +64,12 @@
6565 require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
6666
6767 // include seleniumTestsuite
68 -require_once 'selenium/SeleniumTestHTMLLogger.php';
69 -require_once 'selenium/SeleniumTestConsoleLogger.php';
70 -require_once 'selenium/SeleniumTestListener.php';
71 -require_once 'selenium/Selenium.php';
72 -require_once 'selenium/SeleniumTestSuite.php';
73 -require_once 'selenium/SeleniumTestCase.php';
 68+require_once 'selenium_framework/SeleniumTestHTMLLogger.php';
 69+require_once 'selenium_framework/SeleniumTestConsoleLogger.php';
 70+require_once 'selenium_framework/SeleniumTestListener.php';
 71+require_once 'selenium_framework/Selenium.php';
 72+require_once 'selenium_framework/SeleniumTestSuite.php';
 73+require_once 'selenium_framework/SeleniumTestCase.php';
7474
7575 $result = new PHPUnit_Framework_TestResult;
7676 switch ( $wgSeleniumTestsRunMode ) {
Index: branches/MwEmbedStandAlone/tests/selenium/NewSeleniumTest.php
@@ -1,31 +0,0 @@
2 -<?php
3 -
4 -if (!defined('MEDIAWIKI') || !defined('SELENIUMTEST')) {
5 - echo "This script cannot be run standalone";
6 - exit(1);
7 -}
8 -
9 -// create test suite
10 -$wgSeleniumTestSuites['SimpleSeleniumTest'] = new SeleniumTestSuite('Simple Selenium Test');
11 -$wgSeleniumTestSuites['SimpleSeleniumTest']->addTest(new SimpleSeleniumTest());
12 -
13 -class SimpleSeleniumTest extends SeleniumTestCase
14 -{
15 - public $name = "Basic selenium test";
16 -
17 - public function runTest()
18 - {
19 - global $wgSeleniumTestsWikiUrl;
20 - $this->open($wgSeleniumTestsWikiUrl.'/tests/mwEmbed_Demo.html');
21 - // $this->type("wpTextbox1", "This is a basic test");
22 - // $this->click("wpPreview");
23 - $this->waitForPageToLoad(10000);
24 -
25 - // check result
26 - // $source = $this->getText("//div[@id='wikiPreview']/p");
27 - //$correct = strstr($source, "This is a basic test");
28 - //$this->assertEquals($correct, true);
29 -
30 - }
31 -
32 -}
Index: branches/MwEmbedStandAlone/tests/selenium/SeleniumTestSuite.php
@@ -1,34 +0,0 @@
2 -<?php
3 -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
4 - echo "This script cannot be run standalone";
5 - exit( 1 );
6 -}
7 -
8 -// Do not add line break after test output
9 -define( 'MW_TESTLOGGER_CONTINUE_LINE', 1 );
10 -define( 'MW_TESTLOGGER_RESULT_OK', 2 );
11 -define( 'MW_TESTLOGGER_RESULT_ERROR', 3 );
12 -
13 -class SeleniumTestSuite extends PHPUnit_Framework_TestSuite {
14 - private $selenium;
15 -
16 - public function setUp() {
17 - $this->selenium = Selenium::getInstance();
18 - $this->selenium->start();
19 - $this->login();
20 - // $this->loadPage( 'Testpage', 'edit' );
21 - }
22 -
23 - public function tearDown() {
24 - $this->selenium->stop();
25 - }
26 -
27 - public function login() {
28 - $this->selenium->login();
29 - }
30 -
31 - public function loadPage( $title, $action ) {
32 - $this->selenium->loadPage( $title, $action );
33 - }
34 -}
35 -
Index: branches/MwEmbedStandAlone/tests/selenium/SimpleSeleniumTest.php
@@ -1,31 +0,0 @@
2 -<?php
3 -
4 -if (!defined('MEDIAWIKI') || !defined('SELENIUMTEST')) {
5 - echo "This script cannot be run standalone";
6 - exit(1);
7 -}
8 -
9 -// create test suite
10 -$wgSeleniumTestSuites['SimpleSeleniumTest'] = new SeleniumTestSuite('Simple Selenium Test');
11 -$wgSeleniumTestSuites['SimpleSeleniumTest']->addTest(new SimpleSeleniumTest());
12 -
13 -class SimpleSeleniumTest extends SeleniumTestCase
14 -{
15 - public $name = "Basic selenium test";
16 -
17 - public function runTest()
18 - {
19 - global $wgSeleniumTestsWikiUrl;
20 - $this->open($wgSeleniumTestsWikiUrl.'/index.php?title=Selenium&action=edit');
21 - $this->type("wpTextbox1", "This is a basic test");
22 - $this->click("wpPreview");
23 - $this->waitForPageToLoad(10000);
24 -
25 - // check result
26 - $source = $this->getText("//div[@id='wikiPreview']/p");
27 - $correct = strstr($source, "This is a basic test");
28 - $this->assertEquals($correct, true);
29 -
30 - }
31 -
32 -}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/tests/selenium/LocalSeleniumSettings.php.sample
@@ -1,51 +0,0 @@
2 -<?php
3 -// This template file contains variables that should be localized.
4 -// The line (specifying the location of the PHP/PEAR libraries) must be
5 -// first. Moving it to a position later in the file will almost certainly
6 -// cause an error.
7 -
8 -// In order to use this file, first copy it to LocalSeleniumSettings.php.
9 -// Then edit the information to conform to the local environment. You
10 -// will almost certainly have to uncomment the line set_include_path ... and
11 -// change the string 'PEAR' to the path to your PEAR library, e.g.,
12 -// '/usr/share/php/PEAR' for a Debian based Linux system.
13 -// The edited file must appear in the same directory as does RunSeleniumTests.php.
14 -
15 -// include path. Set 'PEAR" to '/path/to/PEAR/library'
16 -
17 -// URL: http://localhost/tests/RunSeleniumTests.php
18 -#set_include_path( get_include_path() . PATH_SEPARATOR . 'PEAR' );
19 -
20 -// Hostname of selenium server
21 -$wgSeleniumTestsSeleniumHost = 'grid.tesla.usability.wikimedia.org';
22 -
23 -// URL of the wiki to be tested. Consult web server configuration.
24 -$wgSeleniumTestsWikiUrl = 'http://prototype.wikimedia.org/mwe-gadget-testing';
25 -
26 -// Port used by selenium server (optional - default is 4444)
27 -$wgSeleniumServerPort = 4444;
28 -
29 -// Wiki login. Used by Selenium to log onto the wiki
30 -$wgSeleniumTestsWikiUser = 'Wikisysop';
31 -$wgSeleniumTestsWikiPassword = 'password';
32 -
33 -// Common browsers on Windows platform. Modify for other platforms or
34 -// other Windows browsers
35 -// Use the *chrome handler in order to be able to test file uploads
36 -// further solution suggestions: http://www.brokenbuild.com/blog/2007/06/07/testing-file-uploads-with-selenium-rc-and-firefoxor-reducing-javascript-security-in-firefox-for-fun-and-profit/
37 -// $wgSeleniumTestsBrowsers['firefox'] = '*firefox c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe';
38 -$wgSeleniumTestsBrowsers['firefox'] = '*firefox /usr/bin/firefox';
39 -$wgSeleniumTestsBrowsers['iexplorer'] = '*iexploreproxy';
40 -$wgSeleniumTestsBrowsers['opera'] = '*chrome /usr/bin/opera';
41 -
42 -// Actually, use this browser
43 -$wgSeleniumTestsUseBrowser = 'firefox';
44 -
45 -// Set command line mode
46 -$wgSeleniumTestsRunMode = 'cli';
47 -
48 -// List of tests to be included by default
49 -$wgSeleniumTestIncludes = array(
50 - 'selenium/SimpleSeleniumTest.php'
51 -);
52 -?>
Index: branches/MwEmbedStandAlone/tests/selenium/SeleniumTestCase.php
@@ -1,34 +0,0 @@
2 -<?php
3 -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
4 - echo "This script cannot be run standalone";
5 - exit( 1 );
6 -}
7 -
8 -class SeleniumTestCase extends PHPUnit_Framework_TestCase { // PHPUnit_Extensions_SeleniumTestCase
9 - protected $selenium;
10 -
11 - public function setUp() {
12 - set_time_limit( 60 );
13 - $this->selenium = Selenium::getInstance();
14 - }
15 -
16 - public function tearDown() {
17 -
18 - }
19 -
20 - public function __call( $method, $args ) {
21 - return call_user_func_array( array( $this->selenium, $method ), $args );
22 - }
23 -
24 - public function assertSeleniumAttributeEquals( $attribute, $value ) {
25 - $attr = $this->getAttribute( $attribute );
26 - $this->assertEquals( $attr, $value );
27 - }
28 -
29 - public function assertSeleniumHTMLContains( $element, $text ) {
30 - $innerHTML = $this->getText( $element );
31 - // or assertContains
32 - $this->assertRegExp( "/$text/", $innerHTML );
33 - }
34 -
35 -}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/tests/selenium/Selenium.php
@@ -1,59 +0,0 @@
2 -<?php
3 -/**
4 - * Selenium connector
5 - * This is implemented as a singleton.
6 - */
7 -
8 -# if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
9 -if ( !defined( 'SELENIUMTEST' ) ) {
10 - echo "This script cannot be run standalone";
11 - exit( 1 );
12 -}
13 -
14 -class Selenium extends Testing_Selenium {
15 - protected static $_instance = null;
16 - public $isStarted = false;
17 -
18 - public static function getInstance() {
19 - global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser;
20 - global $wgSeleniumTestsWikiUrl, $wgSeleniumServerPort;
21 - if ( null === self::$_instance ) {
22 - self::$_instance = new self( $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser],
23 - $wgSeleniumTestsWikiUrl,
24 - $wgSeleniumTestsSeleniumHost,
25 - $wgSeleniumServerPort );
26 - }
27 - return self::$_instance;
28 - }
29 -
30 - public function start() {
31 - global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost;
32 - parent::start();
33 - $this->isStarted = true;
34 - }
35 -
36 - public function stop() {
37 - parent::stop();
38 - $this->isStarted = false;
39 - }
40 -
41 - public function login() {
42 - global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword, $wgSeleniumTestsWikiUrl;
43 -
44 - $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=Special:Userlogin' );
45 - $this->type( 'wpName1', $wgSeleniumTestsWikiUser );
46 - $this->type( 'wpPassword1', $wgSeleniumTestsWikiPassword );
47 - $this->click( "//input[@id='wpLoginAttempt']" );
48 - $value = $this->doCommand( 'assertTitle', array( 'Login successful*' ) );
49 - }
50 -
51 - public function loadPage( $title, $action ) {
52 - global $wgSeleniumTestsWikiUrl;
53 - $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=' . $title . '&action=' . $action );
54 - }
55 -
56 - // Prevent external cloning
57 - protected function __clone() { }
58 - // Prevent external construction
59 - // protected function __construct() {}
60 -}
Index: branches/MwEmbedStandAlone/tests/selenium/SeleniumTestConsoleLogger.php
@@ -1,29 +0,0 @@
2 -<?php
3 -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
4 - echo "This script cannot be run standalone";
5 - exit( 1 );
6 -}
7 -
8 -class SeleniumTestConsoleLogger {
9 - public function __construct() {
10 - // Prepare testsuite for immediate output
11 - @ini_set( 'zlib.output_compression', 0 );
12 - @ini_set( 'implicit_flush', 1 );
13 - for ( $i = 0; $i < ob_get_level(); $i++ ) {
14 - ob_end_flush();
15 - }
16 - ob_implicit_flush( 1 );
17 - }
18 -
19 - public function write( $message, $mode = false ) {
20 - $out = '';
21 - // if ( $mode == MW_TESTLOGGER_RESULT_OK ) $out .= '<font color="green">';
22 - $out .= htmlentities( $message );
23 - // if ( $mode == MW_TESTLOGGER_RESULT_OK ) $out .= '</font>';
24 - if ( $mode != MW_TESTLOGGER_CONTINUE_LINE ) {
25 - $out .= "\n";
26 - }
27 -
28 - echo $out;
29 - }
30 -}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/tests/selenium/SeleniumTestHTMLLogger.php
@@ -1,46 +0,0 @@
2 -<?php
3 -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
4 - echo "This script cannot be run standalone";
5 - exit( 1 );
6 -}
7 -
8 -class SeleniumTestHTMLLogger {
9 - public function __construct() {
10 - // Prepare testsuite for immediate output
11 - @ini_set( 'zlib.output_compression', 0 );
12 - @ini_set( 'implicit_flush', 1 );
13 - for ( $i = 0; $i < ob_get_level(); $i++ ) {
14 - ob_end_flush();
15 - }
16 - ob_implicit_flush( 1 );
17 -
18 - // Output some style information
19 - echo '<style>
20 - pre {
21 - overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
22 - white-space: pre-wrap; /* css-3 */
23 - white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
24 - white-space: -pre-wrap; /* Opera 4-6 */
25 - white-space: -o-pre-wrap; /* Opera 7 */
26 - /* width: 99%; */
27 - word-wrap: break-word; /* Internet Explorer 5.5+ */
28 - }
29 - </style>';
30 - }
31 -
32 - public function write( $message, $mode = false ) {
33 - $out = '';
34 - if ( $mode == MW_TESTLOGGER_RESULT_OK ) {
35 - $out .= '<font color="green">';
36 - }
37 - $out .= htmlentities( $message );
38 - if ( $mode == MW_TESTLOGGER_RESULT_OK ) {
39 - $out .= '</font>';
40 - }
41 - if ( $mode != MW_TESTLOGGER_CONTINUE_LINE ) {
42 - $out .= '<br />';
43 - }
44 -
45 - echo $out;
46 - }
47 -}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/tests/selenium/SeleniumTestListener.php
@@ -1,69 +0,0 @@
2 -<?php
3 -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
4 - echo "This script cannot be run standalone";
5 - exit( 1 );
6 -}
7 -
8 -class SeleniumTestListener implements PHPUnit_Framework_TestListener {
9 - private $logger;
10 - private $tests_ok = 0;
11 - private $tests_failed = 0;
12 -
13 - public function __construct( $loggerInstance ) {
14 - $this->logger = $loggerInstance;
15 - }
16 -
17 - public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
18 - $this->logger->write( 'Error: ' . $e->getMessage() );
19 - $this->tests_failed++;
20 - }
21 -
22 - public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time )
23 - {
24 - $this->logger->write( 'Failed: ' . $e->getMessage() );
25 - $this->tests_failed++;
26 - }
27 -
28 - public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time )
29 - {
30 - $this->logger->write( 'Incomplete.' );
31 - $this->tests_failed++;
32 - }
33 -
34 - public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time )
35 - {
36 - $this->logger->write( 'Skipped.' );
37 - $this->tests_failed++;
38 - }
39 -
40 - public function startTest( PHPUnit_Framework_Test $test ) {
41 - $this->logger->write(
42 - 'Testing ' . $test->getName() . ' ... ',
43 - MW_TESTLOGGER_CONTINUE_LINE
44 - );
45 - }
46 -
47 - public function endTest( PHPUnit_Framework_Test $test, $time ) {
48 - if ( !$test->hasFailed() ) {
49 - $this->logger->write( 'OK', MW_TESTLOGGER_RESULT_OK );
50 - $this->tests_ok++;
51 - }
52 - }
53 -
54 - public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
55 - $this->logger->write( 'Testsuite ' . $suite->getName() . ' started.' );
56 - $this->tests_ok = 0;
57 - }
58 -
59 - public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
60 - $this->logger->write(
61 - 'Testsuite ' . $suite->getName() . ' ended. OK: ' .
62 - $this->tests_ok . ' Failed: ' . $this->tests_failed
63 - );
64 - }
65 -
66 - public function statusMessage( $message ) {
67 - $this->logger->write( $message );
68 - }
69 -}
70 -
Index: branches/MwEmbedStandAlone/tests/selenium_tests/audio-player-menu.php
@@ -1,82 +0,0 @@
2 -<?xml version="1.0" encoding="UTF-8"?>
3 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 -<head profile="http://selenium-ide.openqa.org/profiles/test-case">
6 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7 -<link rel="selenium.base" href="http://mwembed/tests/" />
8 -<title>audio-player-menu.html</title>
9 -</head>
10 -<body>
11 -<table cellpadding="1" cellspacing="1" border="1">
12 -<thead>
13 -<tr><td rowspan="1" colspan="3">audio-player-menu.html</td></tr>
14 -</thead><tbody>
15 -<tr>
16 - <td>open</td>
17 - <td>Player_Audio.html</td>
18 - <td></td>
19 -</tr>
20 -<tr>
21 - <td>waitForElementPresent</td>
22 - <td>//div[@class='interface_wrap k-player']</td>
23 - <td>9000</td>
24 -</tr>
25 -<tr>
26 - <td>click</td>
27 - <td>//span</td>
28 - <td></td>
29 -</tr>
30 -<tr>
31 - <td>waitForElementPresent</td>
32 - <td>//div[@class='overlay-win k-menu ui-widget-content']</td>
33 - <td></td>
34 -</tr>
35 -<tr>
36 - <td>click</td>
37 - <td>//a[contains(@title, 'Players')]</td>
38 - <td></td>
39 -</tr>
40 -<tr>
41 - <td>waitForElementPresent</td>
42 - <td>//div[@class='menu-screen menu-playerSelect']</td>
43 - <td></td>
44 -</tr>
45 -<tr>
46 - <td>click</td>
47 - <td>//a[contains(@title, 'Download')]</td>
48 - <td></td>
49 -</tr>
50 -<tr>
51 - <td>waitForElementPresent</td>
52 - <td>//div[@class='menu-screen menu-download']</td>
53 - <td></td>
54 -</tr>
55 -<tr>
56 - <td>click</td>
57 - <td>//a[contains(@title, 'Share')]</td>
58 - <td></td>
59 -</tr>
60 -<tr>
61 - <td>waitForElementPresent</td>
62 - <td>//div[@class='menu-screen menu-share']</td>
63 - <td></td>
64 -</tr>
65 -<tr>
66 - <td>click</td>
67 - <td>//a[contains(@title, 'Credits')]</td>
68 - <td></td>
69 -</tr>
70 -<tr>
71 - <td>waitForElementPresent</td>
72 - <td>//div[@class='menu-screen menu-credits']</td>
73 - <td></td>
74 -</tr>
75 -<tr>
76 - <td>click</td>
77 - <td>//span</td>
78 - <td></td>
79 -</tr>
80 -
81 -</tbody></table>
82 -</body>
83 -</html>
Index: branches/MwEmbedStandAlone/tests/selenium_tests/player-themable-display.php
@@ -1,37 +0,0 @@
2 -<?xml version="1.0" encoding="UTF-8"?>
3 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 -<head profile="http://selenium-ide.openqa.org/profiles/test-case">
6 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7 -<link rel="selenium.base" href="" />
8 -<title>player-themable-display</title>
9 -</head>
10 -<body>
11 -<table cellpadding="1" cellspacing="1" border="1">
12 -<thead>
13 -<tr><td rowspan="1" colspan="3">player-themable-display</td></tr>
14 -</thead><tbody>
15 -<tr>
16 - <td>open</td>
17 - <td>Player_Themable.html</td>
18 - <td></td>
19 -</tr>
20 -<tr>
21 - <td>waitForElementPresent</td>
22 - <td>//div[@class=&quot;interface_wrap k-player&quot;]</td>
23 - <td>9000</td>
24 -</tr>
25 -<tr>
26 - <td>waitForElementPresent</td>
27 - <td>//div[@class=&quot;interface_wrap mv-player&quot;]</td>
28 - <td>9000</td>
29 -</tr>
30 -<tr>
31 - <td>waitForElementPresent</td>
32 - <td>//div[@class=&quot;ui-state-default play-btn-large&quot;]</td>
33 - <td>9000</td>
34 -</tr>
35 -
36 -</tbody></table>
37 -</body>
38 -</html>
Index: branches/MwEmbedStandAlone/tests/selenium_tests/player-timed-text.php
@@ -1,63 +0,0 @@
2 -<?xml version="1.0" encoding="UTF-8"?>
3 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 -<head profile="http://selenium-ide.openqa.org/profiles/test-case">
6 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7 -<link rel="selenium.base" href="" />
8 -<title>player-timed-text</title>
9 -</head>
10 -<body>
11 -<table cellpadding="1" cellspacing="1" border="1">
12 -<thead>
13 -<tr><td rowspan="1" colspan="3">player-timed-text</td></tr>
14 -</thead><tbody>
15 -<tr>
16 - <td>open</td>
17 - <td>Player_Timed_Text.html</td>
18 - <td></td>
19 -</tr>
20 -<tr>
21 - <td>waitForElementPresent</td>
22 - <td>//div[@id='v0']</td>
23 - <td>9000</td>
24 -</tr>
25 -<tr>
26 - <td>click</td>
27 - <td>//div[4]/span</td>
28 - <td></td>
29 -</tr>
30 -<tr>
31 - <td>waitForElementPresent</td>
32 - <td>//li[@role='menuitem']</td>
33 - <td>9000</td>
34 -</tr>
35 -<tr>
36 - <td>click</td>
37 - <td>//a[@class="ui-corner-all fg-menu-indicator"]</td>
38 - <td></td>
39 -</tr>
40 -<tr>
41 - <td>click</td>
42 - <td>//a[@class="ui-corner-all"]</td>
43 - <td></td>
44 -</tr>
45 -<tr>
46 - <td>waitForElementPresent</td>
47 - <td>//div[@class='itext itext_SUB']</td>
48 - <td>9000</td>
49 -</tr>
50 -<tr>
51 - <td>click</td>
52 - <td>//div[@class="ui-state-default play-btn-large"]</td>
53 - <td></td>
54 -</tr>
55 -<tr>
56 - <td>waitForCondition</td>
57 - <td>var value = selenium.getText("//div[@class='itext itext_SUB']");
58 - value == "When I say user autonomy, what I\'m talking about"</td>
59 - <td>20000</td>
60 -</tr>
61 -
62 -</tbody></table>
63 -</body>
64 -</html>
Index: branches/MwEmbedStandAlone/tests/selenium_tests/audio-player-playback-progress.php
@@ -1,42 +0,0 @@
2 -<?xml version="1.0" encoding="UTF-8"?>
3 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 -<head profile="http://selenium-ide.openqa.org/profiles/test-case">
6 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7 -<link rel="selenium.base" href="" />
8 -<title>audio-player-playback-progress</title>
9 -</head>
10 -<body>
11 -<table cellpadding="1" cellspacing="1" border="1">
12 -<thead>
13 -<tr><td rowspan="1" colspan="3">audio-player-playback-progress</td></tr>
14 -</thead><tbody>
15 -<tr>
16 - <td>open</td>
17 - <td>Player_Audio.html</td>
18 - <td></td>
19 -</tr>
20 -<tr>
21 - <td>waitForElementPresent</td>
22 - <td>//div[@class='interface_wrap k-player']</td>
23 - <td>9000</td>
24 -</tr>
25 -<tr>
26 - <td>click</td>
27 - <td>//div[2]/span</td>
28 - <td></td>
29 -</tr>
30 -<tr>
31 - <td>waitForElementPresent</td>
32 - <td>//div[@class='ui-widget time-disp']</td>
33 - <td>1000</td>
34 -</tr>
35 -<tr>
36 - <td>waitForCondition</td>
37 - <td>var value = selenium.getText(&quot;//div[@class='ui-widget time-disp']&quot;); value == '0:00:01'</td>
38 - <td>9000</td>
39 -</tr>
40 -
41 -</tbody></table>
42 -</body>
43 -</html>
Index: branches/MwEmbedStandAlone/tests/selenium_tests/amw-all-providers.php
@@ -1,112 +0,0 @@
2 -<?xml version="1.0" encoding="UTF-8"?>
3 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 -<head profile="http://selenium-ide.openqa.org/profiles/test-case">
6 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7 -<link rel="selenium.base" href="http://localhost/js2-work/" />
8 -<title>amw-all-providers</title>
9 -</head>
10 -<body>
11 -<table cellpadding="1" cellspacing="1" border="1">
12 -<thead>
13 -<tr><td rowspan="1" colspan="3">amw-all-providers</td></tr>
14 -</thead><tbody>
15 -<tr>
16 - <td>open</td>
17 - <td>Add_Media_Wizard.html</td>
18 - <td></td>
19 -</tr>
20 -<tr>
21 - <td>click</td>
22 - <td>add_media_link</td>
23 - <td></td>
24 -</tr>
25 -<tr>
26 - <td>waitForCondition</td>
27 - <td>selenium.browserbot.getCurrentWindow().document.getElementById( 'res_kaltura__0' )</td>
28 - <td>9000</td>
29 -</tr>
30 -<tr>
31 - <td>click</td>
32 - <td>res_kaltura__0</td>
33 - <td></td>
34 -</tr>
35 -<tr>
36 - <td>click</td>
37 - <td>//div[3]/a[1]/span[2]</td>
38 - <td></td>
39 -</tr>
40 -<tr>
41 - <td>click</td>
42 - <td>add_media_link</td>
43 - <td></td>
44 -</tr>
45 -<tr>
46 - <td>click</td>
47 - <td>//div[@id='rsd_media_filter']/div</td>
48 - <td></td>
49 -</tr>
50 -<tr>
51 - <td>waitForCondition</td>
52 - <td>selenium.browserbot.getCurrentWindow().document.getElementById( 'rsd_media_filter' )</td>
53 - <td>9000</td>
54 -</tr>
55 -<tr>
56 - <td>click</td>
57 - <td>rsd_media_filter_Media_movie</td>
58 - <td></td>
59 -</tr>
60 -<tr>
61 - <td>type</td>
62 - <td>rsd_q</td>
63 - <td>cats</td>
64 -</tr>
65 -<tr>
66 - <td>click</td>
67 - <td>//form[@id='rsd_form']/a/span[1]</td>
68 - <td></td>
69 -</tr>
70 -<tr>
71 - <td>click</td>
72 - <td>//div[@name='wiki_commons']</td>
73 - <td></td>
74 -</tr>
75 -<tr>
76 - <td>waitForCondition</td>
77 - <td>selenium.browserbot.getCurrentWindow().document.getElementById( 'rsd_search_description' )</td>
78 - <td>9000</td>
79 -</tr>
80 -<tr>
81 - <td>click</td>
82 - <td>//div[@name='archive_org']</td>
83 - <td></td>
84 -</tr>
85 -<tr>
86 - <td>waitForCondition</td>
87 - <td>selenium.browserbot.getCurrentWindow().document.getElementById( 'rsd_search_description' )</td>
88 - <td>9000</td>
89 -</tr>
90 -<tr>
91 - <td>click</td>
92 - <td>//div[@name='flickr']</td>
93 - <td></td>
94 -</tr>
95 -<tr>
96 - <td>waitForCondition</td>
97 - <td>selenium.browserbot.getCurrentWindow().document.getElementById( 'rsd_search_description' )</td>
98 - <td>9000</td>
99 -</tr>
100 -<tr>
101 - <td>click</td>
102 - <td>//div[@name='metavid']</td>
103 - <td></td>
104 -</tr>
105 -<tr>
106 - <td>waitForCondition</td>
107 - <td>selenium.browserbot.getCurrentWindow().document.getElementById( 'rsd_search_description' )</td>
108 - <td>9000</td>
109 -</tr>
110 -
111 -</tbody></table>
112 -</body>
113 -</html>
Index: branches/MwEmbedStandAlone/tests/selenium_tests/api-proxy.php
@@ -1,37 +0,0 @@
2 -<?xml version="1.0" encoding="UTF-8"?>
3 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 -<head profile="http://selenium-ide.openqa.org/profiles/test-case">
6 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7 -<link rel="selenium.base" href="" />
8 -<title>api-proxy</title>
9 -<!--
10 -TODO: Api proxy testing requires selenium test browsers be logged in to commons
11 -this file is removed from full test Suite temporarily.
12 -</head>
13 -<body>
14 -<table cellpadding="1" cellspacing="1" border="1">
15 -<thead>
16 -<tr><td rowspan="1" colspan="3">api-proxy</td></tr>
17 -</thead><tbody>
18 -<!--todo: setup test login account-->
19 -<tr>
20 - <td>open</td>
21 - <td>testApiProxy.html</td>
22 - <td></td>
23 -</tr>
24 -<tr>
25 - <td>click</td>
26 - <td>//a[@class='doHello']</td>
27 - <td></td>
28 -</tr>
29 -<tr>
30 - <td>waitForElementPresent</td>
31 - <td>//span[@class='UserNameFound']</td>
32 - <td>12000</td>
33 -</tr>
34 -
35 -</tbody></table>
36 -</body>
37 -</html>
Index: branches/MwEmbedStandAlone/tests/selenium_tests/EmbedPlayerLoadsTest.php
@@ -0,0 +1,31 @@
 2+<?php
 3+
 4+if (!defined('MEDIAWIKI') || !defined('SELENIUMTEST')) {
 5+ echo "This script cannot be run standalone";
 6+ exit(1);
 7+}
 8+
 9+// create test suite
 10+$wgSeleniumTestSuites['SimpleSeleniumTest'] = new SeleniumTestSuite('Simple Selenium Test');
 11+$wgSeleniumTestSuites['SimpleSeleniumTest']->addTest(new SimpleSeleniumTest());
 12+
 13+class SimpleSeleniumTest extends SeleniumTestCase
 14+{
 15+ public $name = "Basic selenium test";
 16+
 17+ public function runTest()
 18+ {
 19+ global $wgSeleniumTestsWikiUrl;
 20+ $this->open($wgSeleniumTestsWikiUrl.'/tests/mwEmbed_Demo.html');
 21+ // $this->type("wpTextbox1", "This is a basic test");
 22+ // $this->click("wpPreview");
 23+ $this->waitForPageToLoad(10000);
 24+
 25+ // check result
 26+ //$source = $this->getText("//div[@id='wikiPreview']/p");
 27+ //$correct = strstr($source, "This is a basic test");
 28+ //$this->assertEquals($correct, true);
 29+
 30+ }
 31+
 32+}
Index: branches/MwEmbedStandAlone/tests/selenium_framework/NewSeleniumTest.php
@@ -0,0 +1,31 @@
 2+<?php
 3+
 4+if (!defined('MEDIAWIKI') || !defined('SELENIUMTEST')) {
 5+ echo "This script cannot be run standalone";
 6+ exit(1);
 7+}
 8+
 9+// create test suite
 10+$wgSeleniumTestSuites['SimpleSeleniumTest'] = new SeleniumTestSuite('Simple Selenium Test');
 11+$wgSeleniumTestSuites['SimpleSeleniumTest']->addTest(new SimpleSeleniumTest());
 12+
 13+class SimpleSeleniumTest extends SeleniumTestCase
 14+{
 15+ public $name = "Basic selenium test";
 16+
 17+ public function runTest()
 18+ {
 19+ global $wgSeleniumTestsWikiUrl;
 20+ $this->open($wgSeleniumTestsWikiUrl.'/tests/mwEmbed_Demo.html');
 21+ // $this->type("wpTextbox1", "This is a basic test");
 22+ // $this->click("wpPreview");
 23+ $this->waitForPageToLoad(10000);
 24+
 25+ // check result
 26+ // $source = $this->getText("//div[@id='wikiPreview']/p");
 27+ //$correct = strstr($source, "This is a basic test");
 28+ //$this->assertEquals($correct, true);
 29+
 30+ }
 31+
 32+}
Index: branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestSuite.php
@@ -0,0 +1,34 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
 4+ echo "This script cannot be run standalone";
 5+ exit( 1 );
 6+}
 7+
 8+// Do not add line break after test output
 9+define( 'MW_TESTLOGGER_CONTINUE_LINE', 1 );
 10+define( 'MW_TESTLOGGER_RESULT_OK', 2 );
 11+define( 'MW_TESTLOGGER_RESULT_ERROR', 3 );
 12+
 13+class SeleniumTestSuite extends PHPUnit_Framework_TestSuite {
 14+ private $selenium;
 15+
 16+ public function setUp() {
 17+ $this->selenium = Selenium::getInstance();
 18+ $this->selenium->start();
 19+ $this->login();
 20+ // $this->loadPage( 'Testpage', 'edit' );
 21+ }
 22+
 23+ public function tearDown() {
 24+ $this->selenium->stop();
 25+ }
 26+
 27+ public function login() {
 28+ $this->selenium->login();
 29+ }
 30+
 31+ public function loadPage( $title, $action ) {
 32+ $this->selenium->loadPage( $title, $action );
 33+ }
 34+}
 35+
Index: branches/MwEmbedStandAlone/tests/selenium_framework/SimpleSeleniumTest.php
@@ -0,0 +1,31 @@
 2+<?php
 3+
 4+if (!defined('MEDIAWIKI') || !defined('SELENIUMTEST')) {
 5+ echo "This script cannot be run standalone";
 6+ exit(1);
 7+}
 8+
 9+// create test suite
 10+$wgSeleniumTestSuites['SimpleSeleniumTest'] = new SeleniumTestSuite('Simple Selenium Test');
 11+$wgSeleniumTestSuites['SimpleSeleniumTest']->addTest(new SimpleSeleniumTest());
 12+
 13+class SimpleSeleniumTest extends SeleniumTestCase
 14+{
 15+ public $name = "Basic selenium test";
 16+
 17+ public function runTest()
 18+ {
 19+ global $wgSeleniumTestsWikiUrl;
 20+ $this->open($wgSeleniumTestsWikiUrl.'/index.php?title=Selenium&action=edit');
 21+ $this->type("wpTextbox1", "This is a basic test");
 22+ $this->click("wpPreview");
 23+ $this->waitForPageToLoad(10000);
 24+
 25+ // check result
 26+ $source = $this->getText("//div[@id='wikiPreview']/p");
 27+ $correct = strstr($source, "This is a basic test");
 28+ $this->assertEquals($correct, true);
 29+
 30+ }
 31+
 32+}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/tests/selenium_framework/LocalSeleniumSettings.php
@@ -0,0 +1,51 @@
 2+<?php
 3+// This template file contains variables that should be localized.
 4+// The line (specifying the location of the PHP/PEAR libraries) must be
 5+// first. Moving it to a position later in the file will almost certainly
 6+// cause an error.
 7+
 8+// In order to use this file, first copy it to LocalSeleniumSettings.php.
 9+// Then edit the information to conform to the local environment. You
 10+// will almost certainly have to uncomment the line set_include_path ... and
 11+// change the string 'PEAR' to the path to your PEAR library, e.g.,
 12+// '/usr/share/php/PEAR' for a Debian based Linux system.
 13+// The edited file must appear in the same directory as does RunSeleniumTests.php.
 14+
 15+// include path. Set 'PEAR" to '/path/to/PEAR/library'
 16+
 17+// URL: http://localhost/tests/RunSeleniumTests.php
 18+#set_include_path( get_include_path() . PATH_SEPARATOR . 'PEAR' );
 19+
 20+// Hostname of selenium server
 21+$wgSeleniumTestsSeleniumHost = 'grid.tesla.usability.wikimedia.org';
 22+
 23+// URL of the wiki to be tested. Consult web server configuration.
 24+$wgSeleniumTestsWikiUrl = 'http://prototype.wikimedia.org/mwe-gadget-testing';
 25+
 26+// Port used by selenium server (optional - default is 4444)
 27+$wgSeleniumServerPort = 4444;
 28+
 29+// Wiki login. Used by Selenium to log onto the wiki
 30+$wgSeleniumTestsWikiUser = 'Wikisysop';
 31+$wgSeleniumTestsWikiPassword = 'password';
 32+
 33+// Common browsers on Windows platform. Modify for other platforms or
 34+// other Windows browsers
 35+// Use the *chrome handler in order to be able to test file uploads
 36+// further solution suggestions: http://www.brokenbuild.com/blog/2007/06/07/testing-file-uploads-with-selenium-rc-and-firefoxor-reducing-javascript-security-in-firefox-for-fun-and-profit/
 37+// $wgSeleniumTestsBrowsers['firefox'] = '*firefox c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe';
 38+$wgSeleniumTestsBrowsers['firefox'] = '*firefox /usr/bin/firefox';
 39+$wgSeleniumTestsBrowsers['iexplorer'] = '*iexploreproxy';
 40+$wgSeleniumTestsBrowsers['opera'] = '*chrome /usr/bin/opera';
 41+
 42+// Actually, use this browser
 43+$wgSeleniumTestsUseBrowser = 'firefox';
 44+
 45+// Set command line mode
 46+$wgSeleniumTestsRunMode = 'cli';
 47+
 48+// List of tests to be included by default
 49+$wgSeleniumTestIncludes = array(
 50+ 'selenium_tests/EmbedPlayerLoadsTest.php'
 51+);
 52+?>
Index: branches/MwEmbedStandAlone/tests/selenium_framework/LocalSeleniumSettings.php.sample
@@ -0,0 +1,51 @@
 2+<?php
 3+// This template file contains variables that should be localized.
 4+// The line (specifying the location of the PHP/PEAR libraries) must be
 5+// first. Moving it to a position later in the file will almost certainly
 6+// cause an error.
 7+
 8+// In order to use this file, first copy it to LocalSeleniumSettings.php.
 9+// Then edit the information to conform to the local environment. You
 10+// will almost certainly have to uncomment the line set_include_path ... and
 11+// change the string 'PEAR' to the path to your PEAR library, e.g.,
 12+// '/usr/share/php/PEAR' for a Debian based Linux system.
 13+// The edited file must appear in the same directory as does RunSeleniumTests.php.
 14+
 15+// include path. Set 'PEAR" to '/path/to/PEAR/library'
 16+
 17+// URL: http://localhost/tests/RunSeleniumTests.php
 18+#set_include_path( get_include_path() . PATH_SEPARATOR . 'PEAR' );
 19+
 20+// Hostname of selenium server
 21+$wgSeleniumTestsSeleniumHost = 'grid.tesla.usability.wikimedia.org';
 22+
 23+// URL of the wiki to be tested. Consult web server configuration.
 24+$wgSeleniumTestsWikiUrl = 'http://prototype.wikimedia.org/mwe-gadget-testing';
 25+
 26+// Port used by selenium server (optional - default is 4444)
 27+$wgSeleniumServerPort = 4444;
 28+
 29+// Wiki login. Used by Selenium to log onto the wiki
 30+$wgSeleniumTestsWikiUser = 'Wikisysop';
 31+$wgSeleniumTestsWikiPassword = 'password';
 32+
 33+// Common browsers on Windows platform. Modify for other platforms or
 34+// other Windows browsers
 35+// Use the *chrome handler in order to be able to test file uploads
 36+// further solution suggestions: http://www.brokenbuild.com/blog/2007/06/07/testing-file-uploads-with-selenium-rc-and-firefoxor-reducing-javascript-security-in-firefox-for-fun-and-profit/
 37+// $wgSeleniumTestsBrowsers['firefox'] = '*firefox c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe';
 38+$wgSeleniumTestsBrowsers['firefox'] = '*firefox /usr/bin/firefox';
 39+$wgSeleniumTestsBrowsers['iexplorer'] = '*iexploreproxy';
 40+$wgSeleniumTestsBrowsers['opera'] = '*chrome /usr/bin/opera';
 41+
 42+// Actually, use this browser
 43+$wgSeleniumTestsUseBrowser = 'firefox';
 44+
 45+// Set command line mode
 46+$wgSeleniumTestsRunMode = 'cli';
 47+
 48+// List of tests to be included by default
 49+$wgSeleniumTestIncludes = array(
 50+ 'selenium/SimpleSeleniumTest.php'
 51+);
 52+?>
Index: branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestCase.php
@@ -0,0 +1,34 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
 4+ echo "This script cannot be run standalone";
 5+ exit( 1 );
 6+}
 7+
 8+class SeleniumTestCase extends PHPUnit_Framework_TestCase { // PHPUnit_Extensions_SeleniumTestCase
 9+ protected $selenium;
 10+
 11+ public function setUp() {
 12+ set_time_limit( 60 );
 13+ $this->selenium = Selenium::getInstance();
 14+ }
 15+
 16+ public function tearDown() {
 17+
 18+ }
 19+
 20+ public function __call( $method, $args ) {
 21+ return call_user_func_array( array( $this->selenium, $method ), $args );
 22+ }
 23+
 24+ public function assertSeleniumAttributeEquals( $attribute, $value ) {
 25+ $attr = $this->getAttribute( $attribute );
 26+ $this->assertEquals( $attr, $value );
 27+ }
 28+
 29+ public function assertSeleniumHTMLContains( $element, $text ) {
 30+ $innerHTML = $this->getText( $element );
 31+ // or assertContains
 32+ $this->assertRegExp( "/$text/", $innerHTML );
 33+ }
 34+
 35+}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/tests/selenium_framework/Selenium.php
@@ -0,0 +1,59 @@
 2+<?php
 3+/**
 4+ * Selenium connector
 5+ * This is implemented as a singleton.
 6+ */
 7+
 8+# if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
 9+if ( !defined( 'SELENIUMTEST' ) ) {
 10+ echo "This script cannot be run standalone";
 11+ exit( 1 );
 12+}
 13+
 14+class Selenium extends Testing_Selenium {
 15+ protected static $_instance = null;
 16+ public $isStarted = false;
 17+
 18+ public static function getInstance() {
 19+ global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser;
 20+ global $wgSeleniumTestsWikiUrl, $wgSeleniumServerPort;
 21+ if ( null === self::$_instance ) {
 22+ self::$_instance = new self( $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser],
 23+ $wgSeleniumTestsWikiUrl,
 24+ $wgSeleniumTestsSeleniumHost,
 25+ $wgSeleniumServerPort );
 26+ }
 27+ return self::$_instance;
 28+ }
 29+
 30+ public function start() {
 31+ global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost;
 32+ parent::start();
 33+ $this->isStarted = true;
 34+ }
 35+
 36+ public function stop() {
 37+ parent::stop();
 38+ $this->isStarted = false;
 39+ }
 40+
 41+ public function login() {
 42+ global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword, $wgSeleniumTestsWikiUrl;
 43+
 44+ $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=Special:Userlogin' );
 45+ $this->type( 'wpName1', $wgSeleniumTestsWikiUser );
 46+ $this->type( 'wpPassword1', $wgSeleniumTestsWikiPassword );
 47+ $this->click( "//input[@id='wpLoginAttempt']" );
 48+ $value = $this->doCommand( 'assertTitle', array( 'Login successful*' ) );
 49+ }
 50+
 51+ public function loadPage( $title, $action ) {
 52+ global $wgSeleniumTestsWikiUrl;
 53+ $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=' . $title . '&action=' . $action );
 54+ }
 55+
 56+ // Prevent external cloning
 57+ protected function __clone() { }
 58+ // Prevent external construction
 59+ // protected function __construct() {}
 60+}
Index: branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestConsoleLogger.php
@@ -0,0 +1,29 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
 4+ echo "This script cannot be run standalone";
 5+ exit( 1 );
 6+}
 7+
 8+class SeleniumTestConsoleLogger {
 9+ public function __construct() {
 10+ // Prepare testsuite for immediate output
 11+ @ini_set( 'zlib.output_compression', 0 );
 12+ @ini_set( 'implicit_flush', 1 );
 13+ for ( $i = 0; $i < ob_get_level(); $i++ ) {
 14+ ob_end_flush();
 15+ }
 16+ ob_implicit_flush( 1 );
 17+ }
 18+
 19+ public function write( $message, $mode = false ) {
 20+ $out = '';
 21+ // if ( $mode == MW_TESTLOGGER_RESULT_OK ) $out .= '<font color="green">';
 22+ $out .= htmlentities( $message );
 23+ // if ( $mode == MW_TESTLOGGER_RESULT_OK ) $out .= '</font>';
 24+ if ( $mode != MW_TESTLOGGER_CONTINUE_LINE ) {
 25+ $out .= "\n";
 26+ }
 27+
 28+ echo $out;
 29+ }
 30+}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestHTMLLogger.php
@@ -0,0 +1,46 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
 4+ echo "This script cannot be run standalone";
 5+ exit( 1 );
 6+}
 7+
 8+class SeleniumTestHTMLLogger {
 9+ public function __construct() {
 10+ // Prepare testsuite for immediate output
 11+ @ini_set( 'zlib.output_compression', 0 );
 12+ @ini_set( 'implicit_flush', 1 );
 13+ for ( $i = 0; $i < ob_get_level(); $i++ ) {
 14+ ob_end_flush();
 15+ }
 16+ ob_implicit_flush( 1 );
 17+
 18+ // Output some style information
 19+ echo '<style>
 20+ pre {
 21+ overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
 22+ white-space: pre-wrap; /* css-3 */
 23+ white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
 24+ white-space: -pre-wrap; /* Opera 4-6 */
 25+ white-space: -o-pre-wrap; /* Opera 7 */
 26+ /* width: 99%; */
 27+ word-wrap: break-word; /* Internet Explorer 5.5+ */
 28+ }
 29+ </style>';
 30+ }
 31+
 32+ public function write( $message, $mode = false ) {
 33+ $out = '';
 34+ if ( $mode == MW_TESTLOGGER_RESULT_OK ) {
 35+ $out .= '<font color="green">';
 36+ }
 37+ $out .= htmlentities( $message );
 38+ if ( $mode == MW_TESTLOGGER_RESULT_OK ) {
 39+ $out .= '</font>';
 40+ }
 41+ if ( $mode != MW_TESTLOGGER_CONTINUE_LINE ) {
 42+ $out .= '<br />';
 43+ }
 44+
 45+ echo $out;
 46+ }
 47+}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/tests/selenium_framework/SeleniumTestListener.php
@@ -0,0 +1,69 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
 4+ echo "This script cannot be run standalone";
 5+ exit( 1 );
 6+}
 7+
 8+class SeleniumTestListener implements PHPUnit_Framework_TestListener {
 9+ private $logger;
 10+ private $tests_ok = 0;
 11+ private $tests_failed = 0;
 12+
 13+ public function __construct( $loggerInstance ) {
 14+ $this->logger = $loggerInstance;
 15+ }
 16+
 17+ public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
 18+ $this->logger->write( 'Error: ' . $e->getMessage() );
 19+ $this->tests_failed++;
 20+ }
 21+
 22+ public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time )
 23+ {
 24+ $this->logger->write( 'Failed: ' . $e->getMessage() );
 25+ $this->tests_failed++;
 26+ }
 27+
 28+ public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time )
 29+ {
 30+ $this->logger->write( 'Incomplete.' );
 31+ $this->tests_failed++;
 32+ }
 33+
 34+ public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time )
 35+ {
 36+ $this->logger->write( 'Skipped.' );
 37+ $this->tests_failed++;
 38+ }
 39+
 40+ public function startTest( PHPUnit_Framework_Test $test ) {
 41+ $this->logger->write(
 42+ 'Testing ' . $test->getName() . ' ... ',
 43+ MW_TESTLOGGER_CONTINUE_LINE
 44+ );
 45+ }
 46+
 47+ public function endTest( PHPUnit_Framework_Test $test, $time ) {
 48+ if ( !$test->hasFailed() ) {
 49+ $this->logger->write( 'OK', MW_TESTLOGGER_RESULT_OK );
 50+ $this->tests_ok++;
 51+ }
 52+ }
 53+
 54+ public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
 55+ $this->logger->write( 'Testsuite ' . $suite->getName() . ' started.' );
 56+ $this->tests_ok = 0;
 57+ }
 58+
 59+ public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
 60+ $this->logger->write(
 61+ 'Testsuite ' . $suite->getName() . ' ended. OK: ' .
 62+ $this->tests_ok . ' Failed: ' . $this->tests_failed
 63+ );
 64+ }
 65+
 66+ public function statusMessage( $message ) {
 67+ $this->logger->write( $message );
 68+ }
 69+}
 70+
Index: branches/MwEmbedStandAlone/tests/selenium_framework/commandLine.inc
@@ -0,0 +1,48 @@
 2+<?php
 3+
 4+/**
 5+ * Backwards-compatibility wrapper for old-style maintenance scripts
 6+ */
 7+#require( dirname( __FILE__ ) . '/Maintenance.php' );
 8+
 9+if ( !isset( $optionsWithArgs ) ) {
 10+ $optionsWithArgs = array();
 11+}
 12+
 13+abstract class Maintenance {};
 14+
 15+class CommandLineInc extends Maintenance {
 16+ public function __construct() {
 17+ global $optionsWithArgs;
 18+ parent::__construct();
 19+ foreach ( $optionsWithArgs as $name ) {
 20+ $this->addOption( $name, '', false, true );
 21+ }
 22+ }
 23+
 24+ public function getDbType() {
 25+ global $wgUseNormalUser;
 26+
 27+ return ( isset( $wgUseNormalUser ) && $wgUseNormalUser ) ?
 28+ Maintenance::DB_STD : Maintenance::DB_ADMIN;
 29+ }
 30+
 31+ /**
 32+ * No help, it would just be misleading since it misses custom options
 33+ */
 34+ protected function maybeHelp( $force = false ) {
 35+ if ( !$force )
 36+ return;
 37+ parent::maybeHelp( true );
 38+ }
 39+
 40+ public function execute() {
 41+ global $args, $options;
 42+ $args = $this->mArgs;
 43+ $options = $this->mOptions;
 44+ }
 45+}
 46+
 47+$maintClass = 'CommandLineInc';
 48+#require( DO_MAINTENANCE );
 49+

Status & tagging log