From: Julien Lancelot Date: Tue, 20 Nov 2012 17:26:31 +0000 (+0100) Subject: SONAR-3786 Rewrite the "Tests" tabulation in the source viewer to drop use of GWT X-Git-Tag: 3.4~315 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aaa127f45f9e6d499ee9b32b400fdfb046e0a0d7;p=sonarqube.git SONAR-3786 Rewrite the "Tests" tabulation in the source viewer to drop use of GWT --- 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 @@ - - - 4.0.0 - - org.codehaus.sonar - sonar - 3.4-SNAPSHOT - ../.. - - sonar-core-gwt - jar - Sonar :: Plugins :: Core GWT - - - - org.codehaus.sonar - sonar-plugin-api - provided - - - org.codehaus.sonar - sonar-gwt-api - ${sonarGwt.version} - provided - - - org.codehaus.sonar - sonar-ws-client - 3.3.1 - provided - - - com.google.gwt - gwt-user - provided - - - com.google.gwt - gwt-incubator - provided - - - - - org.codehaus.sonar - sonar-testing-harness - test - - - - - - - ${basedir}/src/main/resources - - - ${basedir}/src/test/resources - - - - - - org.codehaus.mojo - gwt-maven-plugin - - - - - org.sonar.plugins.core.testdetailsviewer.TestsViewer${gwt.permutationSuffix} - - ${skipGwt} - ${project.build.directory}/classes - ${gwt.extraJvmArgs} - - - compile - - - - - - - \ No newline at end of file diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java deleted file mode 100644 index e9d32713cfc..00000000000 --- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java +++ /dev/null @@ -1,41 +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; - -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 String getTitle() { - return "Tests"; - } - - public String getGwtId() { - return TestsViewer.GWT_ID; - } - -} 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 { - - 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) + "
" + 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("
"); - } - 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 @@ - - - - - - - - - - - - - \ 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 @@ - - - - - - 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 deleted file mode 100644 index 6e195cf3919..00000000000 Binary files a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png and /dev/null differ 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 deleted file mode 100644 index f00e4264181..00000000000 Binary files a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png and /dev/null differ 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 deleted file mode 100644 index 1faba7e79cc..00000000000 Binary files a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png and /dev/null differ 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 deleted file mode 100644 index 34c0de006c3..00000000000 Binary files a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png and /dev/null differ 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 @@ - - - - - - TestDetails - - - - - - - - - - - - - -
-
-
- - -load - - \ 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-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java new file mode 100644 index 00000000000..b3470ecf13f --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java @@ -0,0 +1,44 @@ +/* + * 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.web; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.web.*; + +@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 TestsViewer extends AbstractRubyTemplate implements RubyRailsPage { + + public String getId() { + return "tests_viewer"; + } + + public String getTitle() { + return "Tests"; + } + + @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 @@ -1023,6 +1023,21 @@ dependencies.ca=Afferent (incoming) couplings 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 @@ +
+ + + <% test_success_density = measure('test_success_density') %> + + + + <% + 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 + %> + + + + <% + test_failures = measure('test_failures') ? format_measure(measure('test_failures')) : "0" + test_errors = measure('test_errors') ? format_measure(measure('test_errors')) : "0" + %> + + + + <% test_execution_time = measure('test_execution_time') %> + + +
<%= test_success_density ? number_with_precision(test_success_density.value(), :precision => 1) : "100.0" -%>% <%= message('test_viewer.tests') -%>:<%= tests_display -%> <%= message('test_viewer.failures') -%>/<%= message('test_viewer.errors') -%>:<%= test_failures -%>/<%= test_errors -%> <%= message('test_viewer.duration') -%>:<%= test_execution_time ? format_measure(test_execution_time) : "-" -%>
+
+ +<% test_data = measure('test_data') %> +<% if test_data %> + + + + + + + + + + + + <% + index = 0 + blocks = REXML::Document.new test_data.data + blocks.elements.each("tests-details/testcase") do |block| + %> + <% index = index+1 %> + " 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 + %> + + + + + + + <% + end + %> + +
  <%= message('test_viewer.duration') -%><%= message('test_viewer.unit_test_name') -%>
+ <% if !block_message.nil? %> + <%= message('test_viewer.expand') -%> + + <% else %> +   + <% end %> + + + <%= block.attributes['time'] -%> ms + <%= block.attributes['name'] -%> + <% if !block_message.nil? %> + + <% end %> +
+ +<% + else +%> +

<%= message('no_data') -%>

+<% + end +%> \ No newline at end of file diff --git a/pom.xml b/pom.xml index be2d5e3375b..ce90818969e 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,6 @@ sonar-squid sonar-testing-harness sonar-ws-client - plugins/sonar-core-gwt plugins/sonar-core-plugin plugins/sonar-dbcleaner-plugin plugins/sonar-findbugs-plugin diff --git a/sonar-server/src/main/webapp/javascripts/resource.js b/sonar-server/src/main/webapp/javascripts/resource.js index bd2e7404257..7b4327dfd47 100644 --- a/sonar-server/src/main/webapp/javascripts/resource.js +++ b/sonar-server/src/main/webapp/javascripts/resource.js @@ -181,4 +181,19 @@ function hVF(line) { row.remove(); } return false; +} + +/* + Functions used in tests viewer + */ +function expandTests(index){ + $j(".tests_viewer #collapseLink_"+ index).show(); + $j(".tests_viewer #expandLink_"+ index).hide(); + $j(".tests_viewer #message_"+ index).show(); +} + +function collapseTests(index){ + $j(".tests_viewer #collapseLink_"+ index).hide(); + $j(".tests_viewer #expandLink_"+ index).show(); + $j(".tests_viewer #message_"+ index).hide(); } \ No newline at end of file