mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'wip-mdl-44557' of git://github.com/rajeshtaneja/moodle
This commit is contained in:
commit
f2bf88130d
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user