public function testFromFiles()
 {
     $testInfo = TestInfo::fromFiles($this->resultDir);
     $firstStep = TestStepResult::fromFiles($testInfo, 1, false, 1);
     $this->assertEquals("google", $firstStep->getEventName());
     $this->assertTrue($firstStep->hasCustomEventName());
     $this->assertNotEmpty($firstStep->getRawResults());
     $this->assertEquals("http://google.com", $firstStep->getUrl());
     $this->assertEquals("google", $firstStep->readableIdentifier());
     $secondStep = TestStepResult::fromFiles($testInfo, 1, true, 2);
     $this->assertEquals("Step 2", $secondStep->getEventName());
     $this->assertFalse($secondStep->hasCustomEventName());
     $this->assertNotEmpty($secondStep->getRawResults());
     $this->assertEquals("http://duckduckgo.com", $secondStep->getUrl());
     $this->assertEquals("http://duckduckgo.com", $secondStep->readableIdentifier());
 }
 public function testWithSinglestepResults()
 {
     $this->tempDir = TestUtil::extractToTemp(__DIR__ . '/data/singlestepResults.zip');
     $resultdir = $this->tempDir . '/singlestepResults';
     $testInfo = TestInfo::fromFiles($resultdir);
     $this->assertTrue($testInfo->isComplete());
     $this->assertTrue($testInfo->isFirstViewOnly());
     $this->assertEquals(1, $testInfo->getRuns());
     $this->assertTrue($testInfo->isRunComplete(1));
     $this->assertFalse($testInfo->isRunComplete(2));
     $this->assertEquals(1, $testInfo->stepsInRun(1));
     $this->assertEquals($resultdir, $testInfo->getRootDirectory());
     // these values are static from a test, but the assertions make sure we don't break the methods
     $this->assertEquals("160620_DQ_7", $testInfo->getId());
     $this->assertEquals("http://www.google.de", $testInfo->getUrl());
     $this->assertEquals("Firefox, Internet Explorer and Chrome - <b>Chrome</b> - <b>Cable</b>", $testInfo->getTestLocation());
     $this->assertEquals("ITERAHH-VBOX-01-192.168.188.112", $testInfo->getTester(1));
 }
 public function testJsonResultArrayGeneration()
 {
     global $SINGLESTEP_JSON_RESULT_ARRAY;
     $this->tempDir = TestUtil::extractToTemp(__DIR__ . '/data/singlestepResults.zip');
     $testInfo = TestInfo::fromFiles($this->tempDir . '/singlestepResults');
     $imitatedPath = $this->imitatedResultPath($testInfo->getId());
     // we need to move the results to a directory structure that equal to the real one.
     // Then, we can go into the parent directory, so the relatece "testRoot" is the same as it would be in production
     // This is important, as during XML generation, some URLs contain the test path
     mkdir($this->tempDir . $imitatedPath, 0777, true);
     rename($this->tempDir . '/singlestepResults', $this->tempDir . $imitatedPath);
     $this->orgDir = getcwd();
     chdir($this->tempDir);
     $testRoot = "." . $imitatedPath;
     $testInfo = TestInfo::fromFiles($testRoot);
     $testResults = TestResults::fromFiles($testInfo);
     $jsonGenerator = new JsonResultGenerator($testInfo, "http://wpt-test-vm", new FileHandler());
     $resultArray = $jsonGenerator->resultDataArray($testResults, "loadTime");
     $this->assertThat($resultArray, new IsArraySubsetConstraint($SINGLESTEP_JSON_RESULT_ARRAY));
 }
 public function testCompleteXmlGeneration()
 {
     $this->tempDir = TestUtil::extractToTemp(__DIR__ . '/data/singlestepResults.zip');
     $testInfo = TestInfo::fromFiles($this->tempDir . '/singlestepResults');
     $imitatedPath = $this->imitatedResultPath($testInfo->getId());
     // we need to move the results to a directory structure that equal to the real one.
     // Then, we can go into the parent directory, so the relatece "testRoot" is the same as it would be in production
     // This is important, as during XML generation, some URLs contain the test path
     mkdir($this->tempDir . $imitatedPath, 0777, true);
     rename($this->tempDir . '/singlestepResults', $this->tempDir . $imitatedPath);
     $this->orgDir = getcwd();
     chdir($this->tempDir);
     $testRoot = "." . $imitatedPath;
     $testInfo = TestInfo::fromFiles($testRoot);
     $expectedXmlFile = __DIR__ . '/data/singlestepXmlResult.xml.gz';
     $testResults = TestResults::fromFiles($testInfo);
     $xmlGenerator = new XmlResultGenerator($testInfo, "http://wpt-test-vm", new FileHandler(), $this->allAdditionalInfo, true);
     $xmlGenerator->printAllResults($testResults, "loadTime", null);
     $this->assertThat(ob_get_contents(), IsCompatibleXMLConstraint::fromFile($expectedXmlFile));
 }
     if (array_key_exists('discard', $info) && $info['discard'] >= 1 && array_key_exists('priority', $info) && $info['priority'] >= 1) {
         $defaultInterval = 100;
     }
     $test['url'] = $info['url'];
     if (isset($info['medianMetric'])) {
         $test_median_metric = $info['medianMetric'];
     }
 }
 $testInfo = parse_ini_file("./{$test['path']}/testinfo.ini", true);
 if ($testInfo !== FALSE) {
     if (array_key_exists('test', $testInfo) && array_key_exists('location', $testInfo['test'])) {
         $test['location'] = $testInfo['test']['location'];
     }
     if (isset($testInfo['test']) && isset($testInfo['test']['completeTime'])) {
         $test['done'] = true;
         $testInfoObject = TestInfo::fromFiles("./" . $test['path']);
         if (!array_key_exists('run', $test) || !$test['run']) {
             $testResults = TestResults::fromFiles($testInfoObject);
             $test['run'] = $testResults->getMedianRunNumber($test_median_metric, $test['cached']);
             $runResults = $testResults->getRunResult($test['run'], $test['cached']);
             $stepResult = $runResults->getStepResult($test['step']);
         } else {
             $stepResult = TestStepResult::fromFiles($testInfoObject, $test['run'], $test['cached'], $test['step']);
         }
         $test['stepResult'] = $stepResult;
         $test['aft'] = (int) $stepResult->getMetric('aft');
         $loadTime = $stepResult->getMetric('fullyLoaded');
         if (isset($loadTime) && (!isset($fastest) || $loadTime < $fastest)) {
             $fastest = $loadTime;
         }
         // figure out the real end time (in ms)
Beispiel #6
0
 global $testPath, $run, $cached, $step;
 // from common.inc
 $file = $_GET['file'];
 // make sure nobody is trying to use us to pull down external images from somewhere else
 if (strpos($file, ':') === FALSE && strpos($file, '//') === FALSE && strpos($file, '\\') === FALSE) {
     $fileParts = explode('.', $file);
     $parts = pathinfo($file);
     $type = $parts['extension'];
     $fit = max(min(@$_REQUEST['fit'], 1000), 0);
     $newWidth = 250;
     $w = @$_REQUEST['width'];
     if ($w && $w > 20 && $w < 1000) {
         $newWidth = $w;
     }
     $img = null;
     $testStepResult = TestStepResult::fromFiles(TestInfo::fromFiles($testPath), $run, $cached, $step);
     // see if it is a waterfall image
     if (strstr($parts['basename'], 'waterfall') !== false) {
         tbnDrawWaterfall($testStepResult, $img);
     } elseif (strstr($parts['basename'], 'optimization') !== false) {
         tbnDrawChecklist($testStepResult, $img);
     } else {
         if (!is_file("{$testPath}/{$file}")) {
             $file = str_ireplace('.jpg', '.png', $file);
             $parts = pathinfo($file);
             $type = $parts['extension'];
         }
         if (is_file("{$testPath}/{$file}")) {
             if (!strcasecmp($type, 'jpg')) {
                 $img = imagecreatefromjpeg("{$testPath}/{$file}");
             } elseif (!strcasecmp($type, 'gif')) {
Beispiel #7
0
<?php

include __DIR__ . '/common.inc';
require_once __DIR__ . '/object_detail.inc';
require_once __DIR__ . '/page_data.inc';
require_once __DIR__ . '/include/TestInfo.php';
require_once __DIR__ . '/include/TestPaths.php';
require_once __DIR__ . '/include/TestStepResult.php';
require_once __DIR__ . '/include/UrlGenerator.php';
global $testPath, $id, $run, $cached, $step;
// defined in common.inc
$secure = false;
$haveLocations = false;
$testInfo = TestInfo::fromFiles($testPath);
$localPaths = new TestPaths($testPath, $run, $cached, $step);
$urlGenerator = UrlGenerator::create(false, "", $id, $run, $cached, $step);
$requests = getRequestsForStep($localPaths, $urlGenerator, $secure, $haveLocations, true);
$page_keywords = array('Images', 'Webpagetest', 'Website Speed Test', 'Page Speed');
$page_description = "Website speed test images{$testLabel}.";
$userImages = true;
?>
<!DOCTYPE html>
<html>
  <head>
    <title>WebPagetest Page Images<?php 
echo $testLabel;
?>
</title>
    <?php 
$gaTemplate = 'Page Images';
include 'head.inc';