/** * Gather all of the data that we collect for a single run * * @param TestStepResult $testStepResult * @return array Array with run information which can be serialized as JSON */ private function stepDataArray($testStepResult) { if (!$testStepResult) { return null; } $ret = $testStepResult->getRawResults(); $run = $testStepResult->getRunNumber(); $cached = $testStepResult->isCachedRun(); $step = $testStepResult->getStepNumber(); $localPaths = new TestPaths($this->testInfo->getRootDirectory(), $run, $cached, $step); $nameOnlyPaths = new TestPaths("", $run, $cached, $step); $urlGenerator = UrlGenerator::create(false, $this->urlStart, $this->testInfo->getId(), $run, $cached, $step); $friendlyUrlGenerator = UrlGenerator::create(true, $this->urlStart, $this->testInfo->getId(), $run, $cached, $step); $urlPaths = new TestPaths($this->urlStart . substr($this->testInfo->getRootDirectory(), 1), $run, $cached, $step); $basic_results = $this->hasInfoFlag(self::BASIC_INFO_ONLY); if (!$basic_results && $this->fileHandler->gzFileExists($localPaths->pageSpeedFile())) { $ret['PageSpeedScore'] = $testStepResult->getPageSpeedScore(); $ret['PageSpeedData'] = $urlGenerator->getGZip($nameOnlyPaths->pageSpeedFile()); } $ret['pages'] = array(); $ret['pages']['details'] = $urlGenerator->resultPage("details"); $ret['pages']['checklist'] = $urlGenerator->resultPage("performance_optimization"); $ret['pages']['breakdown'] = $urlGenerator->resultPage("breakdown"); $ret['pages']['domains'] = $urlGenerator->resultPage("domains"); $ret['pages']['screenShot'] = $urlGenerator->resultPage("screen_shot"); $ret['thumbnails'] = array(); $ret['thumbnails']['waterfall'] = $friendlyUrlGenerator->thumbnail("waterfall.png"); $ret['thumbnails']['checklist'] = $friendlyUrlGenerator->thumbnail("optimization.png"); $ret['thumbnails']['screenShot'] = $friendlyUrlGenerator->thumbnail("screen.png"); $ret['images'] = array(); $ret['images']['waterfall'] = $friendlyUrlGenerator->generatedImage("waterfall"); $ret['images']['connectionView'] = $friendlyUrlGenerator->generatedImage("connection"); $ret['images']['checklist'] = $friendlyUrlGenerator->optimizationChecklistImage(); $ret['images']['screenShot'] = $urlGenerator->getFile($nameOnlyPaths->screenShotFile()); if ($this->fileHandler->fileExists($localPaths->screenShotPngFile())) { $ret['images']['screenShotPng'] = $urlGenerator->getFile($nameOnlyPaths->screenShotPngFile()); } $ret['rawData'] = array(); if ($this->fileHandler->gzFileExists($localPaths->devtoolsScriptTimingFile())) { $ret['rawData']['scriptTiming'] = $urlGenerator->getGZip($nameOnlyPaths->devtoolsScriptTimingFile()); } $ret['rawData']['headers'] = $urlPaths->headersFile(); $ret['rawData']['pageData'] = $urlPaths->pageDataFile(); $ret['rawData']['requestsData'] = $urlPaths->requestDataFile(); $ret['rawData']['utilization'] = $urlPaths->utilizationFile(); if ($this->fileHandler->fileExists($localPaths->bodiesFile())) { $ret['rawData']['bodies'] = $urlPaths->bodiesFile(); } if ($this->fileHandler->gzFileExists($localPaths->devtoolsTraceFile())) { $ret['rawData']['trace'] = $urlGenerator->getGZip($nameOnlyPaths->devtoolsTraceFile() . ".gz"); } if (!$basic_results) { $ret = array_merge($ret, $this->getAdditionalInfoArray($testStepResult, $urlGenerator, $nameOnlyPaths)); } return $ret; }
/** * @param TestStepResult $stepResult */ protected function __construct($stepResult) { $this->breakdownId = "breakdown_" . ($stepResult->isCachedRun() ? "rv" : "fv") . "_step_" . $stepResult->getStepNumber(); }
/** * @param TestStepResult $stepResult * @param bool $even * @return string The created markup */ private function _createScreenshotCell($stepResult, $even) { $urlGenerator = $stepResult->createUrlGenerator("", FRIENDLY_URLS); $class = $even ? 'class="even"' : ''; $onload = $this->screenshotDisplayed ? "" : " onload=\"markUserTime('aft.First Screen Shot')\""; $screenShotUrl = $urlGenerator->resultPage("screen_shot") . "#step_" . $stepResult->getStepNumber(); $thumbnailUrl = $urlGenerator->thumbnail("screen.jpg"); $out = "<td align=\"center\" valign=\"middle\" {$class}>\n"; $out .= "<a href=\"{$screenShotUrl}\"><img class=\"progress\"{$onload} width=\"250\" src=\"{$thumbnailUrl}\"></a>\n"; $out .= "</td>\n"; return $out; }
/** * @param TestStepResult $stepResult * @return string */ private function _labelColumnText($stepResult) { $runNumber = $stepResult->getRunNumber(); if (!$this->isMultistep) { return $this->_rvLabel($stepResult->isCachedRun(), $runNumber); } $label = FitText($stepResult->readableIdentifier(), 30); if ($this->enableLabelLinks) { $label = "<a href='#run" . $runNumber . "_step" . $stepResult->getStepNumber() . "'>" . $label . "</a>"; } return $label; }
/** * @param FileHandler $fileHandler FileHandler to use * @param TestInfo $testInfo Information about the test * @param TestStepResult $testStepResult Results of the specific test * @param bool $useQuicklinks True if quicklinks are used, false otherwise */ function printStep($fileHandler, $testInfo, $testStepResult, $useQuicklinks) { $pageRunData = $testStepResult->getRawResults(); $localPaths = $testStepResult->createTestPaths(); $urlPaths = $testStepResult->createTestPaths(substr($testInfo->getRootDirectory(), 1)); $urlGenerator = $testStepResult->createUrlGenerator("", FRIENDLY_URLS); echo "<a name=\"step_" . $testStepResult->getStepNumber() . "\">"; echo "<h1 class='stepName'>" . $testStepResult->readableIdentifier() . "</h1>"; echo "</a>"; if ($fileHandler->dirExists($localPaths->videoDir())) { echo "<a href=\"" . $urlGenerator->createVideo() . "\">Create Video</a> • "; echo "<a href=\"" . $urlGenerator->downloadVideoFrames() . "\">Download Video Frames</a>"; if ($useQuicklinks) { echo " • "; } } if ($useQuicklinks) { echo '<a href="#quicklinks">Back to Quicklinks</a>'; } $screenShotUrl = null; if ($fileHandler->fileExists($localPaths->screenShotPngFile())) { $screenShotUrl = $urlPaths->screenShotPngFile(); } else { if ($fileHandler->fileExists($localPaths->screenShotFile())) { $screenShotUrl = $urlPaths->screenShotFile(); } } if ($screenShotUrl) { echo '<h2>Fully Loaded</h2>'; echo '<a href="' . $screenShotUrl . '">'; echo '<img class="center" alt="Screen Shot" style="max-width:930px; -ms-interpolation-mode: bicubic;" src="' . $screenShotUrl . '">'; echo '</a>'; } // display the last status message if we have one $messages = $testStepResult->getStatusMessages(); if (count($messages)) { $lastMessage = end($messages); if (strlen($lastMessage['message'])) { echo "\n<br>Last Status Message: \"{$lastMessage['message']}\"\n"; } } $stepNumber = $testStepResult->getStepNumber(); $linkSuffix = $stepNumber > 1 ? "_" . $stepNumber : ""; if ($fileHandler->fileExists($localPaths->additionalScreenShotFile("render"))) { echo '<br><br><a name="start_render' . $linkSuffix . '"><h2>Start Render'; if (isset($pageRunData) && isset($pageRunData['render'])) { echo ' (' . number_format($pageRunData['render'] / 1000.0, 3) . ' sec)'; } echo '</h2></a>'; echo '<img class="center" alt="Start Render Screen Shot" src="' . $urlPaths->additionalScreenShotFile("render") . '">'; } if ($fileHandler->fileExists($localPaths->additionalScreenShotFile("dom"))) { echo '<br><br><a name="dom_element' . $linkSuffix . '"><h2>DOM Element'; if (isset($pageRunData) && isset($pageRunData['domTime'])) { echo ' (' . number_format($pageRunData['domTime'] / 1000.0, 3) . ' sec)'; } echo '</h2></a>'; echo '<img class="center" alt="DOM Element Screen Shot" src="' . $urlPaths->additionalScreenShotFile("dom") . '">'; } if ($fileHandler->fileExists($localPaths->additionalScreenShotFile("doc"))) { echo '<br><br><a name="doc_complete' . $linkSuffix . '"><h2>Document Complete'; if (isset($pageRunData) && isset($pageRunData['docTime'])) { echo ' (' . number_format($pageRunData['docTime'] / 1000.0, 3) . ' sec)'; } echo '</h2></a>'; echo '<img class="center" alt="Document Complete Screen Shot" src="' . $urlPaths->additionalScreenShotFile("doc") . '">'; } if ($fileHandler->fileExists($localPaths->aftDiagnosticImageFile())) { echo '<br><br><a name="aft' . $linkSuffix . '"><h2>AFT Details'; if (isset($pageRunData) && isset($pageRunData['aft'])) { echo ' (' . number_format($pageRunData['aft'] / 1000.0, 3) . ' sec)'; } echo '</h2></a>'; echo 'White = Stabilized Early, Blue = Dynamic, Red = Late Static (failed AFT), Green = AFT<br>'; echo '<img class="center" alt="AFT Diagnostic image" src="' . $urlPaths->aftDiagnosticImageFile() . '">'; } if ($fileHandler->fileExists($localPaths->additionalScreenShotFile("responsive"))) { echo '<br><br><h2 id="responsive">Responsive Site Check</h2>'; echo '<img class="center" alt="Responsive Site Check image" src="' . $urlPaths->additionalScreenShotFile("responsive") . '">'; } // display all of the status messages if (count($messages)) { echo "\n<br><br><a name=\"status_messages" . $linkSuffix . "\"><h2>Status Messages</h2></a>\n"; echo "<table id=\"messages\" class=\"translucent\"><tr><th>Time</th><th>Message</th></tr>\n"; foreach ($messages as $message) { $time = $message['time'] / 1000.0; if ($time > 0.0) { echo "<tr><td class=\"time\">{$time} sec.</td><td>{$message['message']}</td></tr>"; } } echo "</table>\n"; } $row = 0; $console_log = $testStepResult->getConsoleLog(); if (isset($console_log) && count($console_log)) { echo "\n<br><br><a name=\"console-log" . $linkSuffix . "\"><h2>Console Log</h2></a>\n"; echo "<table id=\"console-log\" class=\"translucent\"><tr><th>Source</th><th>Level</th><th>Message</th><th>URL</th><th>Line</th></tr>\n"; foreach ($console_log as &$log_entry) { $row++; $rowClass = ''; if ($row % 2 == 0) { $rowClass = ' class="even"'; } echo "<tr{$rowClass}><td class=\"source\">" . htmlspecialchars($log_entry['source']) . "</td><td class=\"level\">" . htmlspecialchars($log_entry['level']) . "</td><td class=\"message\"><div>" . htmlspecialchars($log_entry['text']) . "</div></td><td class=\"url\"><div><a href=\"" . htmlspecialchars($log_entry['url']) . "\">" . htmlspecialchars($log_entry['url']) . "</a></div></td><td class=\"line\">" . htmlspecialchars($log_entry['line']) . "</td></tr>\n"; } echo "</table>\n"; } }
/** * @param TestStepResult $stepResult Results for the step to be printed */ private function printStepResults($stepResult) { if (empty($stepResult)) { return; } $run = $stepResult->getRunNumber(); $cached = $stepResult->isCachedRun() ? 1 : 0; $step = $stepResult->getStepNumber(); $testRoot = $this->testInfo->getRootDirectory(); $testId = $this->testInfo->getId(); $localPaths = new TestPaths($testRoot, $run, $cached, $step); $nameOnlyPaths = new TestPaths("", $run, $cached, $step); $urlPaths = new TestPaths($this->baseUrl . substr($testRoot, 1), $run, $cached, $step); echo "<results>\n"; echo ArrayToXML($stepResult->getRawResults()); $this->printPageSpeed($stepResult); echo "</results>\n"; // links to the relevant pages $urlGenerator = UrlGenerator::create($this->friendlyUrls, $this->baseUrl, $testId, $run, $cached, $step); echo "<pages>\n"; echo "<details>" . htmlspecialchars($urlGenerator->resultPage("details")) . "</details>\n"; echo "<checklist>" . htmlspecialchars($urlGenerator->resultPage("performance_optimization")) . "</checklist>\n"; echo "<breakdown>" . htmlspecialchars($urlGenerator->resultPage("breakdown")) . "</breakdown>\n"; echo "<domains>" . htmlspecialchars($urlGenerator->resultPage("domains")) . "</domains>\n"; echo "<screenShot>" . htmlspecialchars($urlGenerator->resultPage("screen_shot")) . "</screenShot>\n"; echo "</pages>\n"; // urls for the relevant images echo "<thumbnails>\n"; echo "<waterfall>" . htmlspecialchars($urlGenerator->thumbnail("waterfall.png")) . "</waterfall>\n"; echo "<checklist>" . htmlspecialchars($urlGenerator->thumbnail("optimization.png")) . "</checklist>\n"; if ($this->fileHandler->fileExists($localPaths->screenShotFile())) { echo "<screenShot>" . htmlspecialchars($urlGenerator->thumbnail("screen.jpg")) . "</screenShot>\n"; } echo "</thumbnails>\n"; echo "<images>\n"; echo "<waterfall>" . htmlspecialchars($urlGenerator->generatedImage("waterfall")) . "</waterfall>\n"; echo "<connectionView>" . htmlspecialchars($urlGenerator->generatedImage("connection")) . "</connectionView>\n"; echo "<checklist>" . htmlspecialchars($urlGenerator->optimizationChecklistImage()) . "</checklist>\n"; if ($this->fileHandler->fileExists($localPaths->screenShotFile())) { echo "<screenShot>" . htmlspecialchars($urlGenerator->getFile($nameOnlyPaths->screenShotFile())) . "</screenShot>\n"; } if ($this->fileHandler->fileExists($localPaths->screenShotPngFile())) { echo "<screenShotPng>" . htmlspecialchars($urlGenerator->getFile($nameOnlyPaths->screenShotPngFile())) . "</screenShotPng>\n"; } echo "</images>\n"; // raw results (files accessed directly on the file system, but via URL) echo "<rawData>\n"; if ($this->fileHandler->gzFileExists($localPaths->devtoolsScriptTimingFile())) { echo "<scriptTiming>" . htmlspecialchars($urlGenerator->getGZip($nameOnlyPaths->devtoolsScriptTimingFile())) . "</scriptTiming>\n"; } if ($this->fileHandler->gzFileExists($localPaths->headersFile())) { echo "<headers>" . $urlPaths->headersFile() . "</headers>\n"; } if ($this->fileHandler->gzFileExists($localPaths->bodiesFile())) { echo "<bodies>" . $urlPaths->bodiesFile() . "</bodies>\n"; } if ($this->fileHandler->gzFileExists($localPaths->pageDataFile())) { echo "<pageData>" . $urlPaths->pageDataFile() . "</pageData>\n"; } if ($this->fileHandler->gzFileExists($localPaths->requestDataFile())) { echo "<requestsData>" . $urlPaths->requestDataFile() . "</requestsData>\n"; } if ($this->fileHandler->gzFileExists($localPaths->utilizationFile())) { echo "<utilization>" . $urlPaths->utilizationFile() . "</utilization>\n"; } $this->printPageSpeedData($stepResult); echo "</rawData>\n"; // video frames $progress = $stepResult->getVisualProgress(); if (array_key_exists('frames', $progress) && is_array($progress['frames']) && count($progress['frames'])) { echo "<videoFrames>\n"; foreach ($progress['frames'] as $ms => $frame) { echo "<frame>\n"; echo "<time>{$ms}</time>\n"; echo "<image>" . htmlspecialchars($urlGenerator->getFile($frame['file'], $nameOnlyPaths->videoDir())) . "</image>\n"; echo "<VisuallyComplete>{$frame['progress']}</VisuallyComplete>\n"; echo "</frame>\n"; } echo "</videoFrames>\n"; } $this->printAdditionalInformation($stepResult, false); }