Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-09-02 12:16:52 +0000
committerEike Stepper2013-09-02 12:16:52 +0000
commitf2b28a2742a13e0a12090d03d2c422cd3da8be59 (patch)
treee4755e1a6323adfbcdf7cf6bd6dfe9af82f58165 /plugins/org.eclipse.emf.cdo.releng.launches
parent74ceb220da0444f0e5bfcbb5c163d83f110b1502 (diff)
downloadcdo-f2b28a2742a13e0a12090d03d2c422cd3da8be59.tar.gz
cdo-f2b28a2742a13e0a12090d03d2c422cd3da8be59.tar.xz
cdo-f2b28a2742a13e0a12090d03d2c422cd3da8be59.zip
[Releng] Add TestElementLabelDecorator
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.releng.launches')
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.launches/META-INF/MANIFEST.MF7
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.launches/plugin.xml13
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.launches/src/org/eclipse/emf/cdo/releng/launches/TestElementLabelDecorator.java80
3 files changed, 97 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.launches/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.releng.launches/META-INF/MANIFEST.MF
index c5cdc18ac9..873ee9cd46 100644
--- a/plugins/org.eclipse.emf.cdo.releng.launches/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.releng.launches/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.releng.launches;singleton:=true
-Bundle-Version: 1.0.100.qualifier
+Bundle-Version: 1.0.200.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -9,7 +9,8 @@ Bundle-Activator: org.eclipse.emf.cdo.releng.launches.Activator
Require-Bundle: org.eclipse.ui;bundle-version="[3.7.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)"
+ org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.jdt.junit.core;bundle-version="[3.5.0,4.0.0)";resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.emf.cdo.releng.launches;version="1.0.100";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.releng.launches;version="1.0.200";x-internal:=true
diff --git a/plugins/org.eclipse.emf.cdo.releng.launches/plugin.xml b/plugins/org.eclipse.emf.cdo.releng.launches/plugin.xml
index 0f805e0c66..8c22b3faaf 100644
--- a/plugins/org.eclipse.emf.cdo.releng.launches/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.releng.launches/plugin.xml
@@ -30,6 +30,19 @@
</objectClass>
</enablement>
</decorator>
+ <decorator
+ adaptable="true"
+ class="org.eclipse.emf.cdo.releng.launches.TestElementLabelDecorator"
+ id="org.eclipse.emf.cdo.releng.TestElementLabelDecorator"
+ label="JUnit Average Times"
+ lightweight="false"
+ state="true">
+ <enablement>
+ <objectClass
+ name="org.eclipse.jdt.junit.model.ITestElementContainer">
+ </objectClass>
+ </enablement>
+ </decorator>
</extension>
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.releng.launches/src/org/eclipse/emf/cdo/releng/launches/TestElementLabelDecorator.java b/plugins/org.eclipse.emf.cdo.releng.launches/src/org/eclipse/emf/cdo/releng/launches/TestElementLabelDecorator.java
new file mode 100644
index 0000000000..05a2f535b3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.launches/src/org/eclipse/emf/cdo/releng/launches/TestElementLabelDecorator.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.launches;
+
+import org.eclipse.jdt.junit.model.ITestElement;
+import org.eclipse.jdt.junit.model.ITestElementContainer;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.swt.graphics.Image;
+
+import java.text.NumberFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class TestElementLabelDecorator extends BaseLabelProvider implements ILabelDecorator
+{
+ private final NumberFormat timeFormat;
+
+ public TestElementLabelDecorator()
+ {
+ timeFormat = NumberFormat.getNumberInstance();
+ timeFormat.setGroupingUsed(true);
+ timeFormat.setMinimumFractionDigits(3);
+ timeFormat.setMaximumFractionDigits(3);
+ timeFormat.setMinimumIntegerDigits(1);
+ }
+
+ public Image decorateImage(Image image, Object element)
+ {
+ return null;
+ }
+
+ public String decorateText(String text, Object element)
+ {
+ if (element instanceof ITestElementContainer)
+ {
+ ITestElementContainer container = (ITestElementContainer)element;
+
+ double time = container.getElapsedTimeInSeconds();
+ if (!Double.isNaN(time))
+ {
+ int count = countAllChildren(container);
+ if (count > 1)
+ {
+ double average = time / count;
+ return text + " = " + count + " x " + timeFormat.format(average) + " s";
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private int countAllChildren(ITestElementContainer container)
+ {
+ int count = 0;
+ for (ITestElement child : container.getChildren())
+ {
+ if (child instanceof ITestElementContainer)
+ {
+ count += countAllChildren((ITestElementContainer)child);
+ }
+ else
+ {
+ ++count;
+ }
+ }
+
+ return count;
+ }
+}

Back to the top