changeset 9:5bc6733b29bd

2012-02-01 Pavel Tisnovsky <ptisnovs@redhat.com> * src/ReportGenerator.java: * templates/class_report.js: * templates/class_template.html: * templates/style.css: Added new functionality - methods coveraged by tests could be filtered in a generated class list (HTML page + JavaScript). * path_to_rt_jar.txt: Updated path * test_directory.txt: Updated path * Makefile: Updated according to previous changes.
author ptisnovs
date Wed, 01 Feb 2012 10:24:45 +0100
parents a929d697c161
children 4a18f35c8dff
files ChangeLog Makefile path_to_rt_jar.txt src/ReportGenerator.java templates/class_report.js templates/class_template.html templates/style.css test_directory.txt
diffstat 8 files changed, 125 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jan 27 17:28:22 2012 +0100
+++ b/ChangeLog	Wed Feb 01 10:24:45 2012 +0100
@@ -1,3 +1,18 @@
+2012-02-01  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/ReportGenerator.java:
+	* templates/class_report.js:
+	* templates/class_template.html:
+	* templates/style.css:
+	Added new functionality - methods coveraged by tests could
+	be filtered in a generated class list (HTML page + JavaScript).
+	* path_to_rt_jar.txt:
+	Updated path
+	* test_directory.txt:
+	Updated path
+	* Makefile:
+	Updated according to previous changes.
+
 2012-01-27  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/ReportGenerator.java:
--- a/Makefile	Fri Jan 27 17:28:22 2012 +0100
+++ b/Makefile	Wed Feb 01 10:24:45 2012 +0100
@@ -143,5 +143,6 @@
 gen_report: $(REPORTDIR)
 	cp -u $(TEMPLATEDIR)/index.html $(REPORTDIR)
 	cp -u $(TEMPLATEDIR)/style.css $(REPORTDIR)
+	cp -u $(TEMPLATEDIR)/class_report.js $(REPORTDIR)
 	java -cp $(CLASSDIR) ReportGenerator $(REPORTDIR)/$(ALL_CLASS_LIST) $(CLASS_LIST) $(REPORTDIR)
 
--- a/path_to_rt_jar.txt	Fri Jan 27 17:28:22 2012 +0100
+++ b/path_to_rt_jar.txt	Wed Feb 01 10:24:45 2012 +0100
@@ -1,2 +1,2 @@
-/usr/lib/jvm/java/jre/lib/rt.jar
+/usr/lib/jvm/java-1.6.0/jre/lib/rt.jar
 
--- a/src/ReportGenerator.java	Fri Jan 27 17:28:22 2012 +0100
+++ b/src/ReportGenerator.java	Wed Feb 01 10:24:45 2012 +0100
@@ -369,7 +369,13 @@
         // iterate through all methods
         for (String methodName : allMethods)
         {
-            out.add("<tr><td>" + constructPrintedMethodName(methodName) + "</td>");
+            // check if method is coveraged by the test
+            boolean coveragedMethod = testedMethods.contains(methodName);
+            // when the method is coveraged by the test
+            // 'ok' class should be used in generated HTML
+            // to allow as to hide such method
+            String okClass = coveragedMethod ? " class='coveraged'" : "";
+            out.add("<tr" + okClass + "><td>" + constructPrintedMethodName(methodName) + "</td>");
             out.add(printMethodCoverage(methodName, apiMethods));
             out.add(printMethodCoverage(methodName, testedMethods));
             out.add("</tr>\n");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/class_report.js	Wed Feb 01 10:24:45 2012 +0100
@@ -0,0 +1,88 @@
+/*
+  Test coverage tool.
+
+   Copyright (C) 2012 Red Hat
+
+This tool is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This tool is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this tool; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+*/
+
+
+
+/*
+ * Script used to filter methods in a report generated for each API class.
+ *
+ * @author Pavel Tisnovsky
+ */
+
+
+
+/*
+ * Set display style for selected CSS class.
+ */
+function setDisplayStyle(selectorText, displayStyle)
+{
+    var setOfCssRules = new Array();
+    if (document.styleSheets[0].cssRules)
+    {
+        setOfCssRules = document.styleSheets[0].cssRules;
+    }
+    else if (document.styleSheets[0].rules)
+    {
+        setOfCssRules = document.styleSheets[0].rules;
+    }
+    for (i in setOfCssRules)
+    {
+        if (setOfCssRules[i].selectorText == selectorText)
+        {
+            setOfCssRules[i].style.display = displayStyle;
+        }
+    }
+}
+
+/*
+ * Show all methods - table containing methods coveraged by test
+ * and also methods which are not coveraged.
+ */
+function showAll()
+{
+    setDisplayStyle(".coveraged", "");
+}
+
+/*
+ * Show only methods not coveraged by test.
+ */
+function showDiff(selectorText)
+{
+    setDisplayStyle(".coveraged", "none");
+}
+
--- a/templates/class_template.html	Fri Jan 27 17:28:22 2012 +0100
+++ b/templates/class_template.html	Wed Feb 01 10:24:45 2012 +0100
@@ -6,13 +6,21 @@
         <meta name="Generator" content="MauveTestCoverage" />
         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
         <link type="text/css" rel="StyleSheet" href="style.css" />
+        <style type="text/css">
+        .ok {}
+        </style>
+        <script language="JavaScript" type="text/javascript" src="class_report.js">
+        </script>
     </head>
     <body>
         <h1>Report for class: ${CLASS_NAME}&nbsp;&nbsp;&nbsp;<a href='all_results.html'>summary</a></h1>
 
         <table>
             <tr>
-                <th>Method</th>
+                <th>Method
+                    &nbsp;[<a href="javascript:showAll();">all</a>]
+                    &nbsp;[<a href="javascript:showDiff();">diff only</a>]
+                </th>
                 <th><a href="${CLASS_NAME}_api.txt">API</a></th>
                 <th><a href="${CLASS_NAME}_test.txt">Tested</a></th>
             </tr>
--- a/templates/style.css	Fri Jan 27 17:28:22 2012 +0100
+++ b/templates/style.css	Wed Feb 01 10:24:45 2012 +0100
@@ -20,6 +20,7 @@
 
 .present-method     {background-color:#006000}
 .absent-method      {background-color:#600000}
+.coveraged          {}
 
 .method-return-type {}
 .method-name        {}
@@ -40,13 +41,13 @@
         border-style: inset;
         border-color: gray;
         background-color: #c0c0ff;
-        -moz-border-radius: ;
+        /* -moz-border-radius: ; */
 }
 table.package_list td {
         border-width: 1px;
         padding: 1px;
         border-style: inset;
         border-color: gray;
-        -moz-border-radius: ;
+        /* -moz-border-radius: ; */
 }
 
--- a/test_directory.txt	Fri Jan 27 17:28:22 2012 +0100
+++ b/test_directory.txt	Wed Feb 01 10:24:45 2012 +0100
@@ -1,1 +1,1 @@
-/home/ptisnovs/temp/testlet/
+/mauve/mauve/gnu/testlet/