# HG changeset patch # User ptisnovs # Date 1328088285 -3600 # Node ID 5bc6733b29bdb0d93ca19132db41e2e9796c099a # Parent a929d697c161e6f10d42a4f74a89e7dca843447d 2012-02-01 Pavel Tisnovsky * 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. diff -r a929d697c161 -r 5bc6733b29bd ChangeLog --- 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 + + * 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 * src/ReportGenerator.java: diff -r a929d697c161 -r 5bc6733b29bd Makefile --- 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) diff -r a929d697c161 -r 5bc6733b29bd path_to_rt_jar.txt --- 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 diff -r a929d697c161 -r 5bc6733b29bd src/ReportGenerator.java --- 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("" + constructPrintedMethodName(methodName) + ""); + // 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("" + constructPrintedMethodName(methodName) + ""); out.add(printMethodCoverage(methodName, apiMethods)); out.add(printMethodCoverage(methodName, testedMethods)); out.add("\n"); diff -r a929d697c161 -r 5bc6733b29bd templates/class_report.js --- /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"); +} + diff -r a929d697c161 -r 5bc6733b29bd templates/class_template.html --- 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 @@ + +

Report for class: ${CLASS_NAME}   summary

- + diff -r a929d697c161 -r 5bc6733b29bd templates/style.css --- 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: ; */ } diff -r a929d697c161 -r 5bc6733b29bd test_directory.txt --- 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/
MethodMethod +  [all] +  [diff only] + API Tested