Source for file treemap_reporter.php

Documentation is available at treemap_reporter.php

  1. <?php
  2. /**
  3.  *    extension file for SimpleTest
  4.  *    @version    $Id: treemap_reporter.php 1579 2007-11-02 04:17:44Z maetl_ $
  5.  */
  6. require_once(dirname(__FILE__'/../scorer.php');
  7. require_once(dirname(__FILE__'/treemap_reporter/treemap_recorder.php');
  8.  
  9. /**
  10.  * Constructs and renders a treemap visualization of a test run
  11.  */
  12.  
  13.     function TreemapReporter({
  14.         $this->SimpleReporterDecorator(new TreemapRecorder());
  15.     }
  16.  
  17.     /**
  18.      * basic CSS for floating nested divs
  19.      * @todo checkout some weird border bugs
  20.      */
  21.     function _getCss({
  22.         $css ".pass{background-color:green;}.fail{background-color:red;}";
  23.         $css .= "body {background-color:white;margin:0;padding:1em;}";
  24.         $css .= "div{float:right;margin:0;color:black;}";
  25.         $css .= "div{border-left:1px solid white;border-bottom:1px solid white;}";
  26.         $css .= "h1 {font:normal 1.8em Arial;color:black;margin:0 0 0.3em 0.1em;}";
  27.         $css .= ".clear { clear:both; }";
  28.         return $css;
  29.     }    
  30.     
  31.     /**
  32.      * paints the HTML header and sets up results
  33.      */
  34.     function paintResultsHeader({
  35.         $title $this->_reporter->getTitle();
  36.         echo "<html><head>";
  37.         echo "<title>{$title}</title>";
  38.         echo "<style type=\"text/css\">" $this->_getCss("</style>";
  39.         echo "</head><body>";
  40.         echo "<h1>{$title}</h1>";
  41.     }    
  42.     
  43.     /**
  44.      * places a clearing break below the end of the test nodes
  45.      */
  46.     function paintResultsFooter({
  47.         echo "<br clear=\"all\">";
  48.         echo "</body></html>";
  49.     }
  50.      
  51.     /**
  52.      * paints start tag for div representing a test node
  53.      */
  54.     function paintRectangleStart($node$horiz$vert{
  55.         $name $node->getName();
  56.         $description $node->getDescription();
  57.         $status $node->getStatus();
  58.         echo "<div title=\"$name$description\" class=\"$status\" style=\"width:{$horiz}%;height:{$vert}%\">";
  59.     }
  60.     
  61.     /**
  62.      * paints end tag for test node div
  63.      */
  64.     function paintRectangleEnd({
  65.         echo "</div>";
  66.     }    
  67.     
  68.     /**
  69.      * paints wrapping treemap divs
  70.      * @todo how to configure aspect and other parameters?
  71.      */
  72.     function paintFooter($group{
  73.         $aspect 1;
  74.         $this->paintResultsHeader();
  75.         $this->paintRectangleStart($this->_reporter->getGraph()100100);
  76.         $this->divideMapNodes($this->_reporter->getGraph()$aspect);
  77.         $this->paintRectangleEnd();
  78.         $this->paintResultsFooter();
  79.     }
  80.     
  81.     /**
  82.      * divides the test results based on a slice and dice algorithm
  83.      *
  84.      * @param TreemapNode $map sorted
  85.      * @param boolean $aspect flips the aspect between horizontal and vertical
  86.      * @private
  87.      */
  88.     function divideMapNodes($map$aspect{
  89.         $aspect !$aspect;
  90.         $divisions $map->getSize();
  91.         $total $map->getTotalSize();
  92.         foreach($map->getChildren(as $node{
  93.             if (!$node->isLeaf()) {
  94.                 $dist $node->getTotalSize($total 100;
  95.             else {
  96.                 $dist $total 100;
  97.             }
  98.             if ($aspect{
  99.                 $horiz $dist;
  100.                 $vert 100;
  101.             else {
  102.                 $horiz 100;
  103.                 $vert $dist;
  104.             }
  105.             $this->paintRectangleStart($node$horiz$vert);
  106.             $this->divideMapNodes($node$aspect);
  107.             $this->paintRectangleEnd();
  108.         }
  109.     }
  110.     
  111.     function paintGroupEnd($group{
  112.         $this->_reporter->paintGroupEnd($group);
  113.         if ($this->_reporter->isComplete()) {
  114.             $this->paintFooter($group);
  115.         }
  116.     }
  117.     
  118. }
  119.  
  120. ?>

Documentation generated on Sun, 04 May 2008 09:22:20 -0500 by phpDocumentor 1.3.0