Merge branch 'wip-mdl-44557' of git://github.com/rajeshtaneja/moodle

This commit is contained in:
Marina Glancy 2014-03-26 14:10:53 +08:00
commit f2bf88130d
3 changed files with 49 additions and 1 deletions

View File

@ -587,4 +587,38 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
return;
}
/**
* Change browser window size.
* - small: 640x480
* - medium: 1024x768
* - large: 2560x1600
*
* @param string $windowsize size of window.
* @throws ExpectationException
*/
protected function resize_window($windowsize) {
switch ($windowsize) {
case "small":
$width = 640;
$height = 480;
break;
case "medium":
$width = 1024;
$height = 768;
break;
case "large":
$width = 2560;
$height = 1600;
break;
default:
preg_match('/^(small|medium|large|\d+x\d+)$/', $windowsize, $matches);
if (empty($matches) || (count($matches) != 2)) {
throw new ExpectationException("Invalid screen size, can't resize", $this->getSession());
}
$size = explode('x', $windowsize);
$width = (int) $size[0];
$height = (int) $size[1];
}
$this->getSession()->getDriver()->resizeWindow($width, $height);
}
}

View File

@ -891,4 +891,17 @@ class behat_general extends behat_base {
return;
}
}
/**
* Change browser window size small: 640x480, medium: 1024x768, large: 2560x1600, custom: widthxheight
*
* Example: I change window size to "small" or I change window size to "1024x768"
*
* @throws ExpectationException
* @Then /^I change window size to "([^"](small|medium|large|\d+x\d+))"$/
* @param string $windowsize size of the window (small|medium|large|wxh).
*/
public function i_change_window_size_to($windowsize) {
$this->resize_window($windowsize);
}
}

View File

@ -230,7 +230,8 @@ class behat_hooks extends behat_base {
self::$initprocessesfinished = true;
}
// Run all test with medium (1024x768) screen size, to avoid responsive problems.
$this->resize_window('medium');
}
/**