diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2012-11-20 18:26:31 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2012-11-21 11:41:24 +0100 |
commit | aaa127f45f9e6d499ee9b32b400fdfb046e0a0d7 (patch) | |
tree | 66fc6c3e255fa2e63cdd5619794d234a20418ee8 /plugins | |
parent | e6ec7cfad7ed7393451d6f0e239c347f5bff8dc8 (diff) | |
download | sonarqube-aaa127f45f9e6d499ee9b32b400fdfb046e0a0d7.tar.gz sonarqube-aaa127f45f9e6d499ee9b32b400fdfb046e0a0d7.zip |
SONAR-3786 Rewrite the "Tests" tabulation in the source viewer to drop use of GWT
Diffstat (limited to 'plugins')
16 files changed, 132 insertions, 497 deletions
diff --git a/plugins/sonar-core-gwt/infinitest.args b/plugins/sonar-core-gwt/infinitest.args deleted file mode 100644 index ed9f41dadc7..00000000000 --- a/plugins/sonar-core-gwt/infinitest.args +++ /dev/null @@ -1 +0,0 @@ --Djava.awt.headless=true
\ No newline at end of file diff --git a/plugins/sonar-core-gwt/pom.xml b/plugins/sonar-core-gwt/pom.xml deleted file mode 100644 index 83634548a2a..00000000000 --- a/plugins/sonar-core-gwt/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar</artifactId> - <version>3.4-SNAPSHOT</version> - <relativePath>../..</relativePath> - </parent> - <artifactId>sonar-core-gwt</artifactId> - <packaging>jar</packaging> - <name>Sonar :: Plugins :: Core GWT</name> - - <dependencies> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-plugin-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-gwt-api</artifactId> - <version>${sonarGwt.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-ws-client</artifactId> - <version>3.3.1</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.gwt</groupId> - <artifactId>gwt-user</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.gwt</groupId> - <artifactId>gwt-incubator</artifactId> - <scope>provided</scope> - </dependency> - - <!-- unit tests --> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-testing-harness</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <testResources> - <testResource> - <directory>${basedir}/src/main/resources</directory> - </testResource> - <testResource> - <directory>${basedir}/src/test/resources</directory> - </testResource> - </testResources> - - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>gwt-maven-plugin</artifactId> - <executions> - <execution> - <configuration> - <modules> - <module>org.sonar.plugins.core.testdetailsviewer.TestsViewer${gwt.permutationSuffix}</module> - </modules> - <skip>${skipGwt}</skip> - <webappDirectory>${project.build.directory}/classes</webappDirectory> - <extraJvmArgs>${gwt.extraJvmArgs}</extraJvmArgs> - </configuration> - <goals> - <goal>compile</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project>
\ No newline at end of file diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java deleted file mode 100644 index df22980fa17..00000000000 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.testdetailsviewer.client; - -import com.google.gwt.gen2.table.override.client.FlexTable; -import com.google.gwt.gen2.table.override.client.FlexTable.FlexCellFormatter; -import com.google.gwt.i18n.client.Dictionary; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.xml.client.Document; -import com.google.gwt.xml.client.Element; -import com.google.gwt.xml.client.NodeList; -import com.google.gwt.xml.client.XMLParser; -import org.sonar.gwt.Metrics; -import org.sonar.gwt.ui.ExpandCollapseLink; -import org.sonar.gwt.ui.Loading; -import org.sonar.wsclient.gwt.AbstractCallback; -import org.sonar.wsclient.gwt.Sonar; -import org.sonar.wsclient.services.Measure; -import org.sonar.wsclient.services.Resource; -import org.sonar.wsclient.services.ResourceQuery; - -public class TestsPanel extends Composite { - - private final Panel panel; - private Loading loading; - - public TestsPanel(Resource resource) { - panel = new VerticalPanel(); - loading = new Loading(); - panel.add(loading); - initWidget(panel); - setStyleName("gwt-TestDetailsPanel"); - getElement().setId("gwt-TestDetailsPanel"); - loadData(resource); - } - - private void loadData(Resource resource) { - ResourceQuery query = ResourceQuery.createForResource(resource, Metrics.TEST_DATA); - Sonar.getInstance().find(query, new TestDetailsMeasureHandler()); - } - - private class TestDetailsMeasureHandler extends AbstractCallback<Resource> { - - public TestDetailsMeasureHandler() { - super(loading); - } - - @Override - protected void doOnResponse(Resource resource) { - loading.removeFromParent(); - if (resource != null) { - Measure measure = resource.getMeasure(Metrics.TEST_DATA); - processTestDetails(measure.getData()); - } - } - - private void processTestDetails(String testXMLData) { - Document parsed = XMLParser.parse(testXMLData); - NodeList testcasesXML = parsed.getElementsByTagName("testcase"); - - Dictionary l10n = Dictionary.getDictionary("l10n"); - FlexTable table = new FlexTable(); - table.setStylePrimaryName("detailsTable"); - table.setText(0, 0, ""); - table.setText(0, 1, ""); - table.setText(0, 2, l10n.get("unittest.duration")); - table.setText(0, 3, l10n.get("unittest.name")); - table.getCellFormatter().getElement(0, 1).setId("iCol"); - table.getCellFormatter().getElement(0, 2).setId("dCol"); - setRowStyle(0, table, "header", false); - - int rowCounter = 1; - for (int i = 0; i < testcasesXML.getLength(); i++) { - Element testcaseXML = (Element) testcasesXML.item(i); - String time = testcaseXML.getAttribute("time"); - String name = testcaseXML.getAttribute("name"); - String status = testcaseXML.getAttribute("status"); - Element error = getFirstElement("error", testcaseXML); - Element failure = getFirstElement("failure", testcaseXML); - Element stackTrace = status.equals("error") ? error : failure; - renderTestDetails(rowCounter, i, status, stackTrace, name, time, table); - rowCounter += 2; - } - panel.add(table); - } - - private Element getFirstElement(String elementName, Element node) { - NodeList elements = node.getElementsByTagName(elementName); - return elements.getLength() > 0 ? (Element) elements.item(0) : null; - } - - private void renderTestDetails(int row, int testCounter, String testCaseStatus, Element stackTrace, String name, String timeMS, FlexTable table) { - HTML icon = new HTML(" "); - icon.setStyleName(testCaseStatus); - table.setWidget(row, 1, icon); - table.setText(row, 2, timeMS + " ms"); - - table.setText(row, 3, name); - String style = (testCounter % 2 == 0) ? "odd" : "even"; - setRowStyle(row, table, style, false); - - if (stackTrace != null) { - Panel stackPanel = new SimplePanel(); - stackPanel.setStyleName("stackPanel"); - stackPanel.getElement().setId("stack-panel" + name); - stackPanel.setVisible(false); - fillStackPanel(stackPanel, stackTrace); - - FlexCellFormatter frmt = (FlexCellFormatter) table.getCellFormatter(); - frmt.setColSpan(row + 1, 1, 3); - table.setWidget(row + 1, 1, stackPanel); - table.setWidget(row, 0, new ExpandCollapseLink(stackPanel)); - table.getCellFormatter().getElement(row, 0).setId("expandCollapseCol"); - setRowStyle(row + 1, table, style, true); - } - } - - private void setRowStyle(int row, FlexTable table, String style, boolean isPanelRow) { - table.getCellFormatter().setStyleName(row, 0, style); - table.getCellFormatter().setStyleName(row, 1, style); - if (!isPanelRow) { - table.getCellFormatter().setStyleName(row, 2, style); - table.getCellFormatter().setStyleName(row, 3, style); - } - table.getCellFormatter().getElement(row, 0).setId("noLinkExpandCollapseCol"); - } - } - - private void fillStackPanel(Panel p, Element stackElement) { - String message = stackElement.getAttribute("message"); - if (message.length() > 0) { - p.getElement().setInnerHTML(escapeHtml(message) + "<br/>" + stackLineBreaks(stackElement.getFirstChild().getNodeValue())); - } else { - p.getElement().setInnerHTML(stackLineBreaks(stackElement.getFirstChild().getNodeValue())); - } - } - - private String escapeHtml(String maybeHtml) { - com.google.gwt.dom.client.Element div = DOM.createDiv(); - div.setInnerText(maybeHtml); - return div.getInnerHTML(); - } - - private String stackLineBreaks(String s) { - StringBuilder stack = new StringBuilder(256); - for (String el : s.split("\n")) { - stack.append(el.trim()).append("<br/>"); - } - return stack.toString(); - } -}
\ No newline at end of file diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java deleted file mode 100644 index 0ac58dce8fa..00000000000 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.testdetailsviewer.client; - -import com.google.gwt.i18n.client.Dictionary; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Widget; -import org.sonar.gwt.Metrics; -import org.sonar.gwt.ui.Page; -import org.sonar.gwt.ui.ViewerHeader; -import org.sonar.wsclient.services.Measure; -import org.sonar.wsclient.services.Resource; - -public class TestsViewer extends Page { - - public static final String GWT_ID = "org.sonar.plugins.core.testdetailsviewer.TestsViewer"; - - @Override - protected Widget doOnResourceLoad(Resource resource) { - FlowPanel flowPanel = new FlowPanel(); - flowPanel.add(new UnitTestsHeader(resource)); - flowPanel.add(new TestsPanel(resource)); - return flowPanel; - } - - private static class UnitTestsHeader extends ViewerHeader { - public UnitTestsHeader(Resource resource) { - - super(resource, new String[]{ - Metrics.TEST_ERRORS, - Metrics.TEST_FAILURES, - Metrics.TEST_SUCCESS_DENSITY, - Metrics.TESTS, - Metrics.SKIPPED_TESTS, - Metrics.TEST_EXECUTION_TIME} - ); - } - - @Override - protected void display(FlowPanel header, Resource resource) { - Dictionary l10n = Dictionary.getDictionary("l10n"); - HorizontalPanel panel = new HorizontalPanel(); - header.add(panel); - - Measure measure = resource.getMeasure(Metrics.TEST_SUCCESS_DENSITY); - if (measure == null) { - addBigCell(panel, "100%"); // best value - } else { - addBigCell(panel, measure.getFormattedValue()); - } - - String skippedHtml = ""; - Measure skipped = resource.getMeasure(Metrics.SKIPPED_TESTS); - if (skipped != null && skipped.getValue() > 0.0) { - skippedHtml += " (+" + skipped.getFormattedValue() + " " + l10n.get("unittest.skipped") + ")"; - } - addCell(panel, - l10n.get("unittest.tests") + ": ", - resource.getMeasureFormattedValue(Metrics.TESTS, "-") + skippedHtml); - - addCell(panel, - l10n.get("unittest.failures") + ": ", - resource.getMeasureFormattedValue(Metrics.TEST_FAILURES, "0") + "/" + resource.getMeasureFormattedValue(Metrics.TEST_ERRORS, "0")); - - addCell(panel, - l10n.get("unittest.duration") + ": ", - resource.getMeasureFormattedValue(Metrics.TEST_EXECUTION_TIME, "-")); - } - } - -} diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewer.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewer.gwt.xml deleted file mode 100644 index c5e1c33bf6d..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewer.gwt.xml +++ /dev/null @@ -1,13 +0,0 @@ -<module> - <inherits name="com.google.gwt.xml.XML"/> - <inherits name="com.google.gwt.user.User"/> - <inherits name="com.google.gwt.json.JSON"/> - <inherits name="com.google.gwt.http.HTTP"/> - <inherits name="org.sonar.Sonar"/> - <inherits name="com.google.gwt.gen2.table.Table"/> - - <stylesheet src="TestsViewer.css"/> - - <entry-point class="org.sonar.plugins.core.testdetailsviewer.client.TestsViewer"/> - -</module>
\ No newline at end of file diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewerDev.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewerDev.gwt.xml deleted file mode 100644 index 8f8f3d80b0c..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewerDev.gwt.xml +++ /dev/null @@ -1,6 +0,0 @@ -<module rename-to="org.sonar.plugins.core.testdetailsviewer.TestsViewer"> - <inherits name="org.sonar.plugins.core.testdetailsviewer.TestsViewer"/> - <inherits name="org.sonar.SonarDev"/> - - <entry-point class="org.sonar.plugins.core.testdetailsviewer.client.TestsViewer"/> -</module> diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/TestsViewer.css b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/TestsViewer.css deleted file mode 100644 index 0ce428402b6..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/TestsViewer.css +++ /dev/null @@ -1,88 +0,0 @@ -.gwt-TestDetailsPanel { - width: 100%; -} - -.gwt-TestDetailsPanel .error { - background-image: url("images/error.png"); - background-position: 4px 2px; - background-repeat: no-repeat; - background-color: transparent; - border: none; - margin: 0 0 2px; - padding: 2px; - vertical-align: top; -} - -.gwt-TestDetailsPanel .failure { - background-image: url("images/failure.png"); - background-position: 4px 2px; - background-repeat: no-repeat; - margin: 0 0 2px; - padding: 2px; - vertical-align: top; -} - -.gwt-TestDetailsPanel .skipped { - background-image: url("images/skipped.png"); - background-position: 4px 2px; - background-repeat: no-repeat; - margin: 0 0 2px; - padding: 2px; - vertical-align: top; -} - -.gwt-TestDetailsPanel .ok { - background-image: url("images/ok.png"); - background-position: 4px 2px; - background-repeat: no-repeat; - margin: 0 0 2px; - padding: 2px; - vertical-align: top; -} - -.detailsTable { - border: 1px solid #C0C0C0; - width: 100%; - vertical-align: top; -} - -.detailsTable td { - vertical-align: top; - text-align: left; - padding: 3px; -} - -.detailsTable .header { - background-color: #EFEFEF; - font-weight: bold; - color: #333; - vertical-align: top; -} - -.detailsTable #iCol { - width: 25px; -} - -.detailsTable #dCol { - width: 70px; -} - -.detailsTable #expandCollapseCol { - width: 60px; - text-align: right; -} - -.detailsTable #noLinkExpandCollapseCol { - width: 0px; - padding: 0px; -} - -.stackPanel { - padding: 5px; - border: 1px solid #C0C0C0; -} - -.expandCollapseLink { - text-align: right; - margin-right: 5px; -}
\ No newline at end of file diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png Binary files differdeleted file mode 100644 index 6e195cf3919..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png +++ /dev/null diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png Binary files differdeleted file mode 100644 index f00e4264181..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png +++ /dev/null diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png Binary files differdeleted file mode 100644 index 1faba7e79cc..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png +++ /dev/null diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png Binary files differdeleted file mode 100644 index 34c0de006c3..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png +++ /dev/null diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/test.html b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/test.html deleted file mode 100644 index 6ec71b51686..00000000000 --- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/test.html +++ /dev/null @@ -1,41 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" - "http://www.w3.org/TR/html4/loose.dtd"> - -<html> -<head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - <title>TestDetails</title> - <link href="http://localhost:9000/dev/stylesheets/yui-2.6.0.css" media="all" rel="Stylesheet" type="text/css"/> - <link href="http://localhost:9000/dev/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css"/> - <script src="http://localhost:9000/dev/javascripts/application.js" type="text/javascript"></script> - <script src="http://localhost:9000/dev/javascripts/prototype.js" type="text/javascript"></script> - <script src="http://localhost:9000/dev/javascripts/scriptaculous.js" type="text/javascript"></script> -</head> - -<body> -<script type="text/javascript"> - var registeredTabs = []; - var config = { - "sonar_url": "http://localhost:9000/dev", - "viewer_resource_key" : "org.sonar.tests.test-failures:moduleA:ch.hortis.sonar.samples.testFailures.moduleA.FailTest" - }; -</script> -<div class="error" id="error" style="display:none"><span id="errormsg"></span> [<a href="#" - onclick="javascript:$('error').hide();return false;">hide</a>] -</div> -<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="#" - onclick="javascript:$('warning').hide();return false;">hide</a>] -</div> -<div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="#" - onclick="javascript:$('info').hide();return false;">hide</a>] -</div> - -<div id="resource_viewers"> - <div id='loading'></div> -</div> -<script type="text/javascript" language="javascript" - src="org.sonar.plugins.core.testdetailsviewer.TestsViewer.nocache.js"></script> - -<a href="#" onclick="load_org_sonar_plugins_core_testdetailsviewer_TestsViewer();">load</a> -</body> -</html>
\ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index b7a2f0f003d..5a8303e9dba 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -87,6 +87,7 @@ import org.sonar.plugins.core.timemachine.VariationDecorator; import org.sonar.plugins.core.timemachine.ViolationPersisterDecorator; import org.sonar.plugins.core.timemachine.ViolationTrackingDecorator; import org.sonar.plugins.core.web.Lcom4Viewer; +import org.sonar.plugins.core.web.TestsViewer; import org.sonar.plugins.core.widgets.AlertsWidget; import org.sonar.plugins.core.widgets.CommentsDuplicationsWidget; import org.sonar.plugins.core.widgets.ComplexityWidget; @@ -402,8 +403,8 @@ public final class CorePlugin extends SonarPlugin { Java.class, // pages - TestsViewerDefinition.class, Lcom4Viewer.class, + TestsViewer.class, // filters ProjectFilter.class, diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java index e9d32713cfc..b3470ecf13f 100644 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java @@ -17,25 +17,28 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.plugins.core.testdetailsviewer; +package org.sonar.plugins.core.web; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.resources.Qualifiers; import org.sonar.api.web.*; -import org.sonar.plugins.core.testdetailsviewer.client.TestsViewer; @ResourceQualifier(Qualifiers.UNIT_TEST_FILE) @NavigationSection(NavigationSection.RESOURCE_TAB) @DefaultTab(metrics = {CoreMetrics.TESTS_KEY, CoreMetrics.TEST_EXECUTION_TIME_KEY, CoreMetrics.TEST_SUCCESS_DENSITY_KEY, CoreMetrics.TEST_FAILURES_KEY, CoreMetrics.TEST_ERRORS_KEY, CoreMetrics.SKIPPED_TESTS_KEY}) @UserRole(UserRole.CODEVIEWER) -public class TestsViewerDefinition extends GwtPage { +public class TestsViewer extends AbstractRubyTemplate implements RubyRailsPage { + + public String getId() { + return "tests_viewer"; + } public String getTitle() { return "Tests"; } - public String getGwtId() { - return TestsViewer.GWT_ID; + @Override + protected String getTemplatePath() { + return "/org/sonar/plugins/core/web/tests_viewer.html.erb"; } - } diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index e050a5305f7..e3e8e475c6b 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -1025,6 +1025,21 @@ dependencies.ce=Efferent (outgoing) couplings #------------------------------------------------------------------------------ # +# TESTS VIEWER +# +#------------------------------------------------------------------------------ +test_viewer.tests=Tests +test_viewer.failures=Failures +test_viewer.errors=Errors +test_viewer.duration=Duration +test_viewer.unit_test_name=Unit test name +test_viewer.skipped=skipped +test_viewer.expand=expand +test_viewer.collapse=collapse + + +#------------------------------------------------------------------------------ +# # MANUAL MEASURES # #------------------------------------------------------------------------------ diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/tests_viewer.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/tests_viewer.html.erb new file mode 100644 index 00000000000..f9a28a20b86 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/tests_viewer.html.erb @@ -0,0 +1,106 @@ +<div class="tab_header tests_viewer" id="tests_header"> + <table> + <tr> + <% test_success_density = measure('test_success_density') %> + <td id= "test_success_density" class="big"><%= test_success_density ? number_with_precision(test_success_density.value(), :precision => 1) : "100.0" -%>%</td> + <td class="sep"> </td> + <td class="name"><%= message('test_viewer.tests') -%>:</td> + <% + tests = measure('tests') + tests_display = tests ? format_measure(tests) : "-" + skipped_tests = measure('skipped_tests') + if !skipped_tests.nil? + tests_display = tests_display + " (+" + format_measure(skipped_tests) + " " + message('test_viewer.skipped') + ")" + end + %> + <td id="tests" class="value"><%= tests_display -%></td> + <td class="sep"> </td> + <td class="name"><%= message('test_viewer.failures') -%>/<%= message('test_viewer.errors') -%>:</td> + <% + test_failures = measure('test_failures') ? format_measure(measure('test_failures')) : "0" + test_errors = measure('test_errors') ? format_measure(measure('test_errors')) : "0" + %> + <td id="test_failures_errors" class="value"><%= test_failures -%>/<%= test_errors -%></td> + <td class="sep"> </td> + <td class="name"><%= message('test_viewer.duration') -%>:</td> + <% test_execution_time = measure('test_execution_time') %> + <td id="test_execution_time" class="value"><%= test_execution_time ? format_measure(test_execution_time) : "-" -%></td> + </tr> + </table> +</div> + +<% test_data = measure('test_data') %> +<% if test_data %> +<table class="data width100 tests_viewer" id="test_data"> + <thead> + <tr> + <th class="thin"> </th> + <th class="thin"> </th> + <th class="thin"><%= message('test_viewer.duration') -%></th> + <th><%= message('test_viewer.unit_test_name') -%></th> + </tr> + </thead> + <tbody> + + <% + index = 0 + blocks = REXML::Document.new test_data.data + blocks.elements.each("tests-details/testcase") do |block| + %> + <% index = index+1 %> + <tr class="<%= cycle("even","odd") -%>" id="testdata_<%= index -%>" display="table-row"> + <% + status = block.attributes['status'] + case status + when 'failure' + icon_url = ApplicationController.root_context + "/images/warning.png" + when 'skipped' + icon_url = ApplicationController.root_context + "/images/levels/none.png" + else + icon_url = ApplicationController.root_context + "/images/levels/" + status + ".png" + end + + error = block.elements['error'] + block_message = !error.nil? ? error : nil + failure = block.elements['failure'] + block_message = !failure.nil? ? failure : block_message + %> + <td class="thin" nowrap> + <% if !block_message.nil? %> + <a id="expandLink_<%= index -%>" href="#" onclick="expandTests(<%= index -%>);"><%= message('test_viewer.expand') -%></a> + <a id="collapseLink_<%= index -%>" class="collapse" href="#" onclick="collapseTests(<%= index -%>);" style="display: none;"><%= message('test_viewer.collapse') -%></a> + <% else %> + + <% end %> + </td> + <td class="thin" nowrap> + <img id="test_status_<%= index -%>_<%= status -%>" src="<%= icon_url -%>" /> + </td> + <td id="test_time_<%= index -%>" class="thin" nowrap><%= block.attributes['time'] -%> ms</td> + <td> + <span><%= block.attributes['name'] -%></span> + <% if !block_message.nil? %> + <div id="message_<%= index -%>" class="message" style="display: none;"> + <% message = block_message.attributes['message'] %> + <% if !message.nil? %> + <span><%= h message -%></span> + <% end %> + <pre style="border: 1px solid #ddd; padding: 5px; margin: 5px 0"><%= block_message.first.to_s-%></pre> + </div> + <% end %> + </td> + </tr> + + <% + end + %> + </tbody> +</table> + +<% + else +%> + <p><%= message('no_data') -%></p> +<% + end +%>
\ No newline at end of file |