Permalink
Browse files

add code coverage and test success gadget

  • Loading branch information...
jeremi committed Jan 20, 2010
1 parent d19d80e commit a29f0424bfdc229c17231182b0629f721bfe7c1b
Showing with 137 additions and 0 deletions.
  1. +137 −0 gadget-code-coverage-test-success.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<Module>
+ <ModulePrefs author="Jeremi Joslin - eXo Platform"
+ title="Sonar - Code coverage and Test success"
+ directory_title="Sonar - Code coverage and Test success"
+ title_url="http://www.exoplatform.com"
+ description="Sonar gadget.">
+
+ <Require feature="dynamic-height" />
+ <Require feature="setprefs"/>
+ <Require feature="settitle"/>
+ </ModulePrefs>
+ <UserPref name="sonar_url" datatype="string" default_value="http://sonar.exoplatform.org/"/>
+ <UserPref name="sonar_project" datatype="string"/>
+ <UserPref name="is_configured" datatype="hidden" default_value="0"/>
+ <Content type="html">
+ <![CDATA[
+ <link href="style.css" media="all" rel="stylesheet" type="text/css" />
+ <script type="text/javascript" src="jquery.js"></script>
+ <script type="text/javascript" src="sonar.js"></script>
+ <script type="text/javascript">
+ function update_metrics() {
+ var metrics = "coverage,line_coverage,branch_coverage,tests,test_execution_time";
+ metrics += "test_success_density,test_failures,test_errors";
+
+ sonar.GetMetrics(metrics, function(res) {
+ var resource = res.data[0];
+ var prefs = new gadgets.Prefs();
+ var sonar_url = prefs.getString("sonar_url");
+ $("#resource_name").text(resource.name);
+ $("#resource_description").text(resource.description);
+ for (var i = 0; i < resource.msr.length; i++) {
+ var metric = resource.msr[i];
+ $("#m_" + metric.key).text(metric.frmt_val);
+ $("#l_" + metric.key).attr("href", sonar_url + "drilldown/measures/" + resource.id + "?metric=" + metric.key);
+ if (metric.var != 0) {
+ $("#t_" + metric.key).attr("src", sonar_url + "images/tendency/" + metric.var + "-black-small.png");
+ $("#t_" + metric.key).show();
+ } else {
+ $("#t_" + metric.key).hide();
+ }
+ }
+ gadgets.window.adjustHeight($(document).height());
+ }, {includetrends: "true"});
+ }
+
+
+
+ $(function() {
+ $("#preferences").bind("finish_edit", function(){update_metrics();});
+
+ var prefs = new gadgets.Prefs();
+ $("#edit").click(sonar.EditPreferences);
+
+ if (prefs.getString("is_configured") === "0"){
+ sonar.EditPreferences();
+ } else {
+ update_metrics();
+ }
+ });
+ </script>
+ <div id="container">
+ <div id="body">
+ <h1 id="resource_name"></h1>
+ <span id="resource_description"></span> <a href="#" id="edit">Edit</a>
+
+
+ <table width="100%" style="margin-top:10px">
+ <tr>
+ <td valign="top" width="48%" nowrap>
+
+ <div class="dashbox">
+ <h3>Code coverage</h3>
+ <p><span class="big"><a href='' id='l_coverage'><span id='m_coverage'></span></a> <img src="" id='t_coverage' style="display:none;" /></span></p>
+ <p><a href='' id='l_line_coverage'><span id='m_line_coverage'></span> line coverage</a> <img src="" id="t_line_coverage" style="display:none;" /></p>
+ <p><a href='' id='l_branch_coverage'><span id='m_branch_coverage'></span> branch coverage</a> <img src="" id="t_branch_coverage" style="display:none;" /></p>
+ <p><a href='' id='l_tests'><span id='m_tests'></span> tests</a> <img src="" id="t_tests" style="display:none;" /></p>
+ <p><a href='' id='l_test_execution_time'><span id='m_test_execution_time'></span></a> <img src="" id="t_test_execution_time" style="display:none;"/></p>
+ </div>
+
+ </td>
+ <td width="10"> </td>
+ <td valign="top">
+
+ <div class="dashbox">
+ <h3>Test success</h3>
+ <p><span class="big"><a href='' id='l_test_success_density'><span id='m_test_success_density'></span></a></span></p>
+ <p><a href='' id='l_test_failures'><span id='m_test_failures' class=''></span> failures</a></p>
+ <p><a href='' id='l_test_errors'><span id='m_test_errors' class=''></span> errors</a></p>
+
+ </div>
+
+
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="preferences" style="display:none;">
+ <form>
+ <fieldset>
+ <label for="id_url">Sonar Server: </label>
+ <span class="help">e.g.: http://sonar.exoplatform.org/</span>
+ <input type="text" name="url" id="id_url" />
+
+ <label for="id_project" style="margin-top:10px">Project</label>
+ <div><select name="project" id="id_project"></select></div>
+ </fieldset>
+ <input type="submit" value="Save" />
+ </form>
+ </div>
+ <div id="footer" style="border-top:1px #C3C3C3 solid;">
+ <a href="http://www.exoplatform.com" style="float:left;"><img src="http://www.exoplatform.com/portal/favicon.ico" style="margin-right:5px;"/>eXo Platform</a>
+ </div>
+ </div>
+ ]]>
+ </Content>
+</Module>

0 comments on commit a29f042

Please sign in to comment.