Ejemplo n.º 1
0
/**
 * @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> &#8226; ";
        echo "<a href=\"" . $urlGenerator->downloadVideoFrames() . "\">Download Video Frames</a>";
        if ($useQuicklinks) {
            echo " &#8226; ";
        }
    }
    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";
    }
}
Ejemplo n.º 2
0
 /**
  * @param TestStepResult $testStepResult The test results of this step
  * @param UrlGenerator $urlGenerator For video frame URL generation for this tep
  * @param TestPaths $nameOnlyPaths To get the name of the video dir for this step
  * @return array Array with the additional information about this step
  */
 private function getAdditionalInfoArray($testStepResult, $urlGenerator, $nameOnlyPaths)
 {
     $ret = array();
     $progress = $testStepResult->getVisualProgress();
     if (array_key_exists('frames', $progress) && is_array($progress['frames']) && count($progress['frames'])) {
         $ret['videoFrames'] = array();
         foreach ($progress['frames'] as $ms => $frame) {
             $videoFrame = array('time' => $ms);
             $videoFrame['image'] = $urlGenerator->getFile($frame['file'], $nameOnlyPaths->videoDir());
             $videoFrame['VisuallyComplete'] = $frame['progress'];
             $ret['videoFrames'][] = $videoFrame;
         }
     }
     $requests = $testStepResult->getRequests();
     $ret['domains'] = $testStepResult->getDomainBreakdown();
     $ret['breakdown'] = $testStepResult->getMimeTypeBreakdown();
     // add requests
     if (!$this->hasInfoFlag(self::WITHOUT_REQUESTS)) {
         $ret['requests'] = $requests;
     }
     // Check to see if we're adding the console log
     if (!$this->hasInfoFlag(self::WITHOUT_CONSOLE)) {
         $console_log = $testStepResult->getConsoleLog();
         if (isset($console_log)) {
             $ret['consoleLog'] = $console_log;
         }
     }
     $statusMessages = $testStepResult->getStatusMessages();
     if ($statusMessages) {
         $ret['status'] = $statusMessages;
         return $ret;
     }
     return $ret;
 }
Ejemplo n.º 3
0
 /**
  * Print any logged browser status messages
  * @param TestStepResult $testResult Result data of affected run
  */
 private function printStatusMessages($testResult)
 {
     $messages = $testResult->getStatusMessages();
     if (!$messages) {
         return;
     }
     echo "<status>\n";
     foreach ($messages as $message) {
         echo "<entry>\n";
         echo "<time>" . xml_entities($message["time"]) . "</time>\n";
         echo "<message>" . xml_entities($message["message"]) . "</message>\n";
         echo "</entry>\n";
     }
     echo "</status>\n";
 }