getImageSrc('); if ($start === false || $end === false) { echo "FAIL - scale code not found in frame.php\n"; exit(1); } $chunk = substr($src, $start, $end - $start); function run($request, $default = 0) { global $chunk, $scales; $_REQUEST = $request; $_COOKIE = array(); $Event = new \ZM\Event(); $Monitor = new class($default) { private $d; public function __construct($d) { $this->d = $d; } public function Id() { return 1; } public function DefaultScale() { return $this->d; } }; eval($chunk); return array( 'width' => reScale($Event->Width(), $scale), 'height' => reScale($Event->Height(), $scale), 'selected' => isset($scaleSelected) ? $scaleSelected : null, ); } echo "480px caps the width:\n"; $r = run(array('scale' => '480px')); check('width is 480', $r['width'], 480); check('height keeps the aspect ratio', $r['height'], 270); check('select keeps 480px', $r['selected'], '480px'); $r = run(array('scale' => '1600px')); check('1600px stays within 1600 and close to it', $r['width'] <= 1600 && $r['width'] > 1550, true); echo "fit_to_width is sized by frame.js, not read as a percentage:\n"; $r = run(array('scale' => 'fit_to_width')); check('server leaves the full size', $r['width'], 1920); check('select keeps fit_to_width', $r['selected'], 'fit_to_width'); echo "percentages are unchanged:\n"; $r = run(array('scale' => '50')); check('50 halves the width', $r['width'], 960); check('select keeps 50', $r['selected'], '50'); $r = run(array('scale' => '0')); check('0 (Auto) is the full size', $r['width'], 1920); $r = run(array(), '480px'); check('monitor default 480px caps the width', $r['width'], 480); echo "the select is given the raw selected value:\n"; check('htmlSelect uses $scaleSelected', strpos($src, "htmlSelect('scale', \$scales, \$scaleSelected") !== false, true); exit($failures ? 1 : 0); }