/hg/MauveTestCoverage: * src/ReportGenerator.java:
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Fri Mar 16 03:22:23 PDT 2012
changeset 8c9c61f17fd1 in /hg/MauveTestCoverage
details: http://icedtea.classpath.org/hg/MauveTestCoverage?cmd=changeset;node=8c9c61f17fd1
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Mar 16 11:24:48 2012 +0100
* src/ReportGenerator.java:
* templates/all_classes_template.html:
* templates/all_packages_template.html:
* templates/class_report.js:
* templates/package_template.html:
* templates/style.css:
Added new functionality of report generator:
new filter can be applied to a class list
based on test coverage for each class.
diffstat:
ChangeLog | 12 +++++++++++
src/ReportGenerator.java | 10 +++++++-
templates/all_classes_template.html | 13 ++++++++++++
templates/all_packages_template.html | 2 +
templates/class_report.js | 39 ++++++++++++++++++++++++++++++++++-
templates/package_template.html | 13 ++++++++++++
templates/style.css | 18 ++++++++++++++++
7 files changed, 103 insertions(+), 4 deletions(-)
diffs (245 lines):
diff -r 5030a59cd546 -r 8c9c61f17fd1 ChangeLog
--- a/ChangeLog Fri Mar 02 16:51:17 2012 +0100
+++ b/ChangeLog Fri Mar 16 11:24:48 2012 +0100
@@ -1,3 +1,15 @@
+2012-03-16 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/ReportGenerator.java:
+ * templates/all_classes_template.html:
+ * templates/all_packages_template.html:
+ * templates/class_report.js:
+ * templates/package_template.html:
+ * templates/style.css:
+ Added new functionality of report generator:
+ new filter can be applied to a class list
+ based on test coverage for each class.
+
2012-03-02 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/ReportGenerator.java:
diff -r 5030a59cd546 -r 8c9c61f17fd1 src/ReportGenerator.java
--- a/src/ReportGenerator.java Fri Mar 02 16:51:17 2012 +0100
+++ b/src/ReportGenerator.java Fri Mar 16 11:24:48 2012 +0100
@@ -225,6 +225,7 @@
final int testedClassesCnt = numberOfClassesInPackage(packageName, testedClasses);
// -> in percent
final float percentage = 100.0f*testedClassesCnt / allClassesCnt;
+
// table row background color is based on percentual test coverage ration
String backgroundColor = generateTableRowBackground(percentage);
String doc = DOC_BASE + "/" + packageName.replace('.', '/') + "/package-summary.html";
@@ -353,12 +354,17 @@
final int testedMethodsCnt = testedMethods.size();
// -> in percent
final float percentage = 100.0f*testedMethodsCnt / allMethodsCnt;
+
+ // construct CSS class for given row based on a code coverage
+ final long coverage = Math.round(Math.ceil(percentage / 10.0f) * 10);
+ String cssClass = "coverage_" + coverage;
+
// table row background color is based on percentual test coverage ration
String backgroundColor = generateTableRowBackground(percentage);
String doc = DOC_BASE + "/" + className.replace('.', '/') + ".html";
// format output string
- String outStr = String.format("<tr style='background-color:%s'><td><a target='ResultsFrame' href='%s.html'>%s</a></td><td style='text-align:right'>%d</td><td style='text-align:right'>%d</td><td style='text-align:right'>%5.1f %%</td><td style='text-align:right'><a href='%s' target='_blank'>ext</a></td></tr>",
- backgroundColor, className, className,
+ String outStr = String.format("<tr class='%s' style='background-color:%s'><td><a target='ResultsFrame' href='%s.html'>%s</a></td><td style='text-align:right'>%d</td><td style='text-align:right'>%d</td><td style='text-align:right'>%5.1f %%</td><td style='text-align:right'><a href='%s' target='_blank'>ext</a></td></tr>",
+ cssClass, backgroundColor, className, className,
Integer.valueOf(allMethodsCnt), Integer.valueOf(testedMethodsCnt), Float.valueOf(percentage), doc);
return outStr;
}
diff -r 5030a59cd546 -r 8c9c61f17fd1 templates/all_classes_template.html
--- a/templates/all_classes_template.html Fri Mar 02 16:51:17 2012 +0100
+++ b/templates/all_classes_template.html Fri Mar 16 11:24:48 2012 +0100
@@ -6,9 +6,22 @@
<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" />
+ <script language="JavaScript" type="text/javascript" src="class_report.js">
+ </script>
</head>
<body>
<h1>Class list</h1>
+Filter:
+<a href="javascript:showPercent(10);">10</a>
+<a href="javascript:showPercent(20);">20</a>
+<a href="javascript:showPercent(30);">30</a>
+<a href="javascript:showPercent(40);">40</a>
+<a href="javascript:showPercent(50);">50</a>
+<a href="javascript:showPercent(60);">60</a>
+<a href="javascript:showPercent(70);">70</a>
+<a href="javascript:showPercent(80);">80</a>
+<a href="javascript:showPercent(90);">90</a>
+<a href="javascript:showPercent(100);">100%</a>
${PACKAGE_AND_CLASS_LIST}
</body>
</html>
diff -r 5030a59cd546 -r 8c9c61f17fd1 templates/all_packages_template.html
--- a/templates/all_packages_template.html Fri Mar 02 16:51:17 2012 +0100
+++ b/templates/all_packages_template.html Fri Mar 16 11:24:48 2012 +0100
@@ -6,6 +6,8 @@
<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" />
+ <script language="JavaScript" type="text/javascript" src="class_report.js">
+ </script>
</head>
<body>
<h1>Package list</h1>
diff -r 5030a59cd546 -r 8c9c61f17fd1 templates/class_report.js
--- a/templates/class_report.js Fri Mar 02 16:51:17 2012 +0100
+++ b/templates/class_report.js Fri Mar 16 11:24:48 2012 +0100
@@ -39,9 +39,10 @@
/*
- * Script used to filter methods in a report generated for each API class.
+ * Script used to filter methods in a report generated for each API class and
+ * also for given package or set of packages.
*
- * @author Pavel Tisnovsky
+ * @author Pavel Tisnovsky <ptisnovs at redhat.com>
*/
@@ -51,7 +52,9 @@
*/
function setDisplayStyle(selectorText, displayStyle)
{
+ // array containing all CSS rules
var setOfCssRules = new Array();
+ // acquire the array depending on browser capabilities
if (document.styleSheets[0].cssRules)
{
setOfCssRules = document.styleSheets[0].cssRules;
@@ -60,8 +63,10 @@
{
setOfCssRules = document.styleSheets[0].rules;
}
+ // iterate through all rules
for (i in setOfCssRules)
{
+ // and select display style for selected rules
if (setOfCssRules[i].selectorText == selectorText)
{
setOfCssRules[i].style.display = displayStyle;
@@ -86,3 +91,33 @@
setDisplayStyle(".coveraged", "none");
}
+/*
+ * Show only classes with the test coverage which is less or
+ * equal than given threshold (%).
+ */
+function showPercent(threshold)
+{
+ var percent;
+ for (percent = 0; percent <= 100; percent += 10)
+ {
+ // construct CSS class name
+ // it should look like as follows:
+ // ".coverage_0", ".coverage_10", ... ".coverage_100"
+ var cssClassName = ".coverage_" + percent;
+
+ //window.alert(cssClassName);
+
+ // when percent is lower than threshold
+ // then rows with such % should be displayed
+ if (percent <= threshold)
+ {
+ setDisplayStyle(cssClassName, "");
+ }
+ // otherwise the rows should be unvisible
+ else
+ {
+ setDisplayStyle(cssClassName, "none");
+ }
+ }
+}
+
diff -r 5030a59cd546 -r 8c9c61f17fd1 templates/package_template.html
--- a/templates/package_template.html Fri Mar 02 16:51:17 2012 +0100
+++ b/templates/package_template.html Fri Mar 16 11:24:48 2012 +0100
@@ -6,9 +6,22 @@
<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" />
+ <script language="JavaScript" type="text/javascript" src="class_report.js">
+ </script>
</head>
<body>
<h1>Class list</h1>
+Filter:
+<a href="javascript:showPercent(10);">10</a>
+<a href="javascript:showPercent(20);">20</a>
+<a href="javascript:showPercent(30);">30</a>
+<a href="javascript:showPercent(40);">40</a>
+<a href="javascript:showPercent(50);">50</a>
+<a href="javascript:showPercent(60);">60</a>
+<a href="javascript:showPercent(70);">70</a>
+<a href="javascript:showPercent(80);">80</a>
+<a href="javascript:showPercent(90);">90</a>
+<a href="javascript:showPercent(100);">100%</a>
<h2>
${PACKAGE_NAME}
</h2>
diff -r 5030a59cd546 -r 8c9c61f17fd1 templates/style.css
--- a/templates/style.css Fri Mar 02 16:51:17 2012 +0100
+++ b/templates/style.css Fri Mar 16 11:24:48 2012 +0100
@@ -18,10 +18,24 @@
.forms {background-color: #f0f0dd; vertical-align: top; width: 720px; border-collapse: collapse; border-color:#808080; margin-left:32px}
+/* CSS classes used in class list */
.present-method {background-color:#006000}
.absent-method {background-color:#600000}
.coveraged {}
+/* CSS classes used in package list */
+.coverage_0 {}
+.coverage_10 {}
+.coverage_20 {}
+.coverage_30 {}
+.coverage_40 {}
+.coverage_50 {}
+.coverage_60 {}
+.coverage_70 {}
+.coverage_80 {}
+.coverage_90 {}
+.coverage_100 {}
+
.method-return-type {}
.method-name {}
.method-params {}
@@ -35,6 +49,7 @@
background-color: white;
width: 100%;
}
+
table.package_list th {
border-width: 1px;
padding: 1px;
@@ -43,6 +58,7 @@
background-color: #c0c0ff;
/* -moz-border-radius: ; */
}
+
table.package_list td {
border-width: 1px;
padding: 1px;
@@ -60,6 +76,7 @@
background-color: white;
width: 100%;
}
+
table.classes_list th {
border-width: 1px;
padding: 1px;
@@ -68,6 +85,7 @@
background-color: #c0c0ff;
/* -moz-border-radius: ; */
}
+
table.classes_list td {
border-width: 1px;
padding: 1px;
More information about the distro-pkg-dev
mailing list