Cleaned the XSL style a bit.
authorMarkus Kauppila <markus.kauppila@gmail.com>
Thu, 30 Jun 2011 16:08:37 +0300
changeset 5727 390fdae0a318
parent 5726 6e82c70f9c83
child 5728 7cf47cdaf4ab
Cleaned the XSL style a bit.
test/test-automation/runner.c
test/test-automation/style.xsl
--- a/test/test-automation/runner.c	Wed Jun 29 22:23:06 2011 +0300
+++ b/test/test-automation/runner.c	Thu Jun 30 16:08:37 2011 +0300
@@ -736,5 +736,5 @@
 	RunEnded(totalTestPassCount + totalTestfailureCount, suiteCounter,
 			 totalTestPassCount, totalTestfailureCount, time(0), totalRunTime);
 
-	return 0;
+	return (totalTestfailureCount ? 1 : 0);
 }
--- a/test/test-automation/style.xsl	Wed Jun 29 22:23:06 2011 +0300
+++ b/test/test-automation/style.xsl	Thu Jun 30 16:08:37 2011 +0300
@@ -12,95 +12,88 @@
 
 <script type="text/javascript">
 
+var hideTests = '[Hide tests]';
+var showTests = '[Show tests]';
+
+var hideAsserts = '[Hide Assert Summary]';
+var showAsserts = '[Show Assert Summary]';
+
+var hideAllTests = '[Hide All Tests]';
+var showAllTests = '[Show All Tests]';
+
+var hideEverything = '[Hide Everything]';
+var showEverything = '[Show Everything]';
+
+var animationSpeed = 'fast';
+
 $(document).ready(function() {
 	$("span.show-tests").click(function() {
 		var content = $(this).html();
 		var id = $(this).attr('uid');
-	
 		var searchString = "div.tests[uid="+id+"]";
 	
-		if(content == '[Hide tests]') {
-			$(searchString).hide("fast");
-			$(this).text('[Show tests]');
+		if(content == hideTests) {
+			$(searchString).hide(animationSpeed);
+			$(this).text(showTests);
 		} else {
-			$(searchString).show("fast");
-			$(this).text('[Hide tests]');
+			$(searchString).show(animationSpeed);
+			$(this).text(hideTests);
 		}
 	});
 
 	$("span.show-asserts").click(function() {
 		var content = $(this).html();
 		var id = $(this).attr('uid');
-		
-		console.log("assert uid" + id);
-		
 		var searchString = "div.asserts[uid="+id+"]";
 		
-		if(content == '[Hide Assert Summary]') {
-			console.log("hide now");
-		
-			$(searchString).hide("fast");
-			$(this).text('[Show Assert Summary]');
+		if(content == hideAsserts) {
+			$(searchString).hide(animationSpeed);
+			$(this).text(showAsserts);
 		} else {
-			console.log("show now");
-		
-			$(searchString).show("fast");
-			$(this).text('[Hide Assert Summary]');
+			$(searchString).show(animationSpeed);
+			$(this).text(hideAsserts);
 		}
 	});
 	
 	$("span.show-all-tests").click(function() {
 		var content = $(this).html();
- 		
 		var searchString = "div.tests";
 		
-		if(content == '[Hide All Tests]') {
-			console.log("hide now");
-		
-			$(searchString).hide("fast");
-			$(this).text('[Show All Tests]');
+		if(content == hideAllTests) {
+			$(searchString).hide(animationSpeed);
+			$(this).text(showAllTests);
 			
 			/* handle the individual '[show tests]' switcher */
-			$("span.show-tests[uid]").text('[Show tests]');
-			
-			
+			$("span.show-tests[uid]").text(showTests);
 		} else {
-			console.log("show now");
-		
-			$(searchString).show("fast");
-			$(this).text('[Hide All Tests]');
+			$(searchString).show(animationSpeed);
+			$(this).text(hideAllTests);
 			
 			/* handle the individual '[show tests]' switcher */
-			$("span.show-tests[uid]").text('[Hide tests]');
+			$("span.show-tests[uid]").text(hideTests);
 		}
 	});
 	
 	$("span.show-everything").click(function() {
 		var content = $(this).html();
- 		
 		var searchString = "div.tests";
 		
-		if(content == '[Hide Everything]') {
-			console.log("hide now");
-		
-			$("div.tests").hide("fast");
-			$("div.asserts").hide("fast");
-			$(this).text('[Show Everything]');
+		if(content == hideEverything) {
+			$("div.tests").hide(animationSpeed);
+			$("div.asserts").hide(animationSpeed);
+			$(this).text(showEverything);
 			
 			/* handle the individual switchers */
-			$("span.show-tests[uid]").text('[Show tests]');
-			$("span.show-asserts[uid]").text('[Show Assert Summary]');
+			$("span.show-tests[uid]").text(showTests);
+			$("span.show-asserts[uid]").text(showAsserts);
 		} else {
-			console.log("show now");
-		
-			$("div.tests").show("fast");
-			$("div.asserts").show("fast");
-			$(this).text('[Hide Everything]');
+			$("div.tests").show(animationSpeed);
+			$("div.asserts").show(animationSpeed);
+			$(this).text(hideEverything);
 			
 			/* handle the individual switchers */
-			$("span.show-tests[uid]").text('[Hide tests]');
-			$("span.show-asserts[uid]").text('[Hide Assert Summary]');
-			
+			$("span.show-tests[uid]").text(hideTests);
+			$("span.show-asserts[uid]").text(hideAsserts);
 		}
 	});
 
@@ -108,8 +101,13 @@
 	$("div.tests").hide();
 	$("div.asserts").hide();
 	
-	$("div.test[result='passed']").addClass('passedTest');
-	$("div.test[result='failed']").addClass('failedTest');
+	/* Color the tests based on the result */
+	$("div.test[result='passed']").addClass('passed');
+	$("div.test[result='failed']").addClass('failed');
+	
+	/* Color the asserts based on the result */
+	$("div.assert[result='pass']").addClass('passed');
+	$("div.assert[result='failure']").addClass('failed');
 });
 
 </script>
@@ -146,17 +144,14 @@
   cursor: pointer;
 }	
 	
-.passedTest {
+.passed {
  background-color: #64AA2B;
 }
 
-.failedTest {
+.failed {
  background-color: #FF6E40;
 }
-	
-.statistics {
-}
-	
+
 </style>
 
 </head>
@@ -174,7 +169,7 @@
     <span class="title">Statistics:</span><br/>
     <div class="statistics">
       <span>Executed </span> <xsl:value-of select="testlog/numSuites"/> test suites. <br/>
-      <span>Tests in total: </span> <xsl:value-of select="testlog/numTests"/> (passed: <xsl:value-of select="testlog/numPassedTests"/> , failed: <xsl:value-of select="testlog/numFailedTests"/>)
+      <span>Tests in total: </span> <xsl:value-of select="testlog/numTests"/> (passed: <xsl:value-of select="testlog/numPassedTests"/>, failed: <xsl:value-of select="testlog/numFailedTests"/>)
     </div>
   </div>
 
@@ -208,19 +203,22 @@
 		      
 		      <span class="switch show-asserts" uid="{generate-id(assertSummary)}">[Show Assert Summary]</span><br/>
 			  <div class="asserts" uid="{generate-id(assertSummary)}">
-		      <xsl:for-each select="assert"> 
-			   <div id="assert">
-		        Assert name: <xsl:value-of select="name"/> <br/>
-		        Result: <xsl:value-of select="result"/> <br/>
-		        Message <xsl:value-of select="message"/> <br/>
-		        Time <xsl:value-of select="time"/> <br/>
+		        <xsl:for-each select="assert"> 
+			      <div class="assert">
+  			        <xsl:attribute name="result">
+				      <xsl:value-of select="result"/>
+				    </xsl:attribute>
+		            Assert name: <xsl:value-of select="name"/> <br/>
+		            Result: <xsl:value-of select="result"/> <br/>
+		            Message <xsl:value-of select="message"/> <br/>
+		            Time <xsl:value-of select="time"/> <br/>
+		          </div>
+		        </xsl:for-each>
+		        AssertSummary:
+		        Assert count: <xsl:value-of select="assertSummary/assertCount"/> <br/>
+		        Asserts Passed <xsl:value-of select="assertSummary/assertsPassed"/> <br/>
+		        Asserts Failed <xsl:value-of select="assertSummary/assertsFailed"/> <br/>
 		      </div>
-		      </xsl:for-each>
-		      AssertSummary:
-		      Assert count: <xsl:value-of select="assertSummary/assertCount"/> <br/>
-		      Asserts Passed <xsl:value-of select="assertSummary/assertsPassed"/> <br/>
-		      Asserts Failed <xsl:value-of select="assertSummary/assertsFailed"/> <br/>
-		    </div>
     		</div>
 		  </xsl:for-each>
 	    </div>