From aaa127f45f9e6d499ee9b32b400fdfb046e0a0d7 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 20 Nov 2012 18:26:31 +0100 Subject: [PATCH] SONAR-3786 Rewrite the "Tests" tabulation in the source viewer to drop use of GWT --- plugins/sonar-core-gwt/infinitest.args | 1 - plugins/sonar-core-gwt/pom.xml | 83 --------- .../testdetailsviewer/client/TestsPanel.java | 169 ------------------ .../testdetailsviewer/client/TestsViewer.java | 89 --------- .../testdetailsviewer/TestsViewer.gwt.xml | 13 -- .../testdetailsviewer/TestsViewerDev.gwt.xml | 6 - .../testdetailsviewer/public/TestsViewer.css | 88 --------- .../testdetailsviewer/public/images/error.png | Bin 647 -> 0 bytes .../public/images/failure.png | Bin 613 -> 0 bytes .../testdetailsviewer/public/images/ok.png | Bin 727 -> 0 bytes .../public/images/skipped.png | Bin 731 -> 0 bytes .../core/testdetailsviewer/public/test.html | 41 ----- .../org/sonar/plugins/core/CorePlugin.java | 3 +- .../sonar/plugins/core/web/TestsViewer.java} | 15 +- .../resources/org/sonar/l10n/core.properties | 15 ++ .../plugins/core/web/tests_viewer.html.erb | 106 +++++++++++ pom.xml | 1 - .../src/main/webapp/javascripts/resource.js | 15 ++ 18 files changed, 147 insertions(+), 498 deletions(-) delete mode 100644 plugins/sonar-core-gwt/infinitest.args delete mode 100644 plugins/sonar-core-gwt/pom.xml delete mode 100644 plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsPanel.java delete mode 100644 plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/client/TestsViewer.java delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewer.gwt.xml delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/TestsViewerDev.gwt.xml delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/TestsViewer.css delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/error.png delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/failure.png delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/ok.png delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/images/skipped.png delete mode 100644 plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/testdetailsviewer/public/test.html rename plugins/{sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java => sonar-core-plugin/src/main/java/org/sonar/plugins/core/web/TestsViewer.java} (82%) create mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/web/tests_viewer.html.erb 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/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 6e195cf3919a8b243df22293d681ad88574bdf7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 647 zcmV;20(kw2P)fJ6HXN>`j$b6&5r$K%xs^bO8Whd8%M}tFbv1MsoV&HbuHB9}f>XfYj|P zK9aA~1{yV~8PWma*YacmYSlrZ%t`+5-T9 z;H49OAp-|Xyq?nLqj1^9Fa}7**YRy)9Py>u6_P!tUVh$x%DWoBaIB7G8-<;u?0qJ3 h@bs&hzdzHz=ogjIuS{1%f(rlu002ovPDHLkV1fd!8{q%| 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 f00e4264181b956aee36c2d0193594bec7ae12ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 613 zcmV-r0-F7aP)j%0tMA4H~Y)p#q^#*5x%00LC_ zsX-X#B1#(D1HR*30|4XulZG~{u&!@YODFvKm+%tzep^z4GynpoMHqBJ3QTJwawbj6&Jw!c!+Pe;HApnUIHq(+9W+7um1ygGlHqEJ!% z*~JrxNklr0bS9LN1T_H27>f&?<65J5tyy$TYEJ(>;0yev!8-M!K_W7tfKGICzVNGUC|)M|6i zZ0gkJ)|4`F*`tJ*d((w#!{}n)&a)RYNqkWUzHm64&*yipaRB1}Cw~nT`VJ-JO&`?f zcv9KSC;P+F$KtTmmBdP&N%{=?-h^ER`Q9`}=1B?ZJTlx2TF}4T9ZlC_3rbzbAnBt+ zl3tqGQ9!CPS>wr(t8+#;R|jBwbq%Jus%W^rW3?YmGu1d?6GT#M0%n^a*OMyBawo5I zFgLL_P>xD}DKs-@pd+ausqvkK{mngGoT`M_!e19(=Zj(jnLF8_8q1DW=3ov~c~3zx zT?EBcA=FbvaIX!);8nswBze6@ka&e}hzT+ui`lMV3#`FrRQgJwd@3hk0hE&@o&t=& zb%AT4$Qs&TG{H94g!l$N8xtJ0CvH4gxsAGj23l`1S;-(4Kh8rnQG~Iz;VArb^9S0W zUxHzx1pUD-2#wT6Odz>WZwxH=!01<@&acJiZ=a&jhp+Equw}LZYF7^Q?$a0uc0ySD zr=XW+Z_GENW8pG%lX94SHHduw5`{N^ZNl>G0?M7)&=5gupdKAwGw5n+YYS<&ga-Lw zI_xWVQ8OWj+IOx|002ov JPDHLkV1k&bQ;Glp 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 34c0de006c3fe00bad9b73994d946351b3279657..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 731 zcmV<10wn#3P)JtZ**pMP2-E-o4Lnd)_^74uG8h;jaTNd6=tl9q`qTeNwr> z&|hpxT5hGuS#z8}ZQRQ}Q=oD%>^XZX;0_*QbC-dOqBFR6Qn33|7+nenh8KhEQw79& zk}b0&l3SsDn7&0JnfF0B?m)xn2D*t&=nNd4n#DXmZ&3Xv+5{n=!=${Xe&UDuvVhc6BMpXB#!WT|qdc_Zwbq7pZ zpt4fnbZF5wZHL7Z#giTbnH6-(J&cP=Kp-}w>Z1YNE`9p44l@QXqVxfFqYV1yoG5G8 zpz4DTcJCgzA{~6H(9al*A z5y%aG=b?URhNPHimJqG#0*$hQODTp;M#OXS>YA25$ktbSYRlHfCmK`A|R(;^K zt5MjjK>LI-!>@2b<0MAZE~w3Z+^iX=u0I@OofuNSaE^Vikw|K7J5X6Dyc92^v_*#E zrWri%(?MbIKxy*fYUStTT1KAZ6cvHWlb6Ht^LIgxM3xu;kc9x73O}t|V}= zLVWs^|8V2cSnjpzQT~<65%Lmmh|c3k=nLh8_n@Dtas1)^0gDhU7p N002ovPDHLkV1gvUP-_4H 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-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 similarity index 82% rename from plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/testdetailsviewer/TestsViewerDefinition.java rename to 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 @@ -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 -- 2.39.5