Bug 560625 - ui.tests.performance tests run with errors
Reorganize tests to make it more straightforward to understand
what/where/how runs.
Change-Id: Ica33593447a73b8504360fd148d2dfedd0c611c1
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ActivitiesPerformanceSuite.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ActivitiesPerformanceSuite.java
deleted file mode 100644
index 2157ca9..0000000
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ActivitiesPerformanceSuite.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.tests.performance;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @since 3.1
- *
- */
-public class ActivitiesPerformanceSuite extends TestSuite {
-
- /**
- * Returns the suite. This is required to use the JUnit Launcher.
- */
- public static Test suite() {
- return new ActivitiesPerformanceSuite();
- }
-
- public ActivitiesPerformanceSuite() {
- super();
- addTest(new GenerateIdentifiersTest(10000));
- }
-
-}
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/EditorPerformanceSuite.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/EditorPerformanceSuite.java
deleted file mode 100644
index 5c64614..0000000
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/EditorPerformanceSuite.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.tests.performance;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @since 3.1
- */
-public class EditorPerformanceSuite extends TestSuite {
-
- public static final String [] EDITOR_FILE_EXTENSIONS = {"perf_basic", "perf_outline", "java"};
- public static final String [][] EDITOR_SWITCH_PAIRS = {
- {"perf_outline", "java"},
- {"perf_basic", "perf_outline"}};
-
- /**
- * Returns the suite. This is required to use the JUnit Launcher.
- */
- public static Test suite() {
- return new EditorPerformanceSuite();
- }
-
- public EditorPerformanceSuite() {
- addOpenCloseScenarios();
- addSwitchScenarios();
- addOpenMultipleScenarios(true);
- addOpenMultipleScenarios(false);
- }
-
- private void addSwitchScenarios() {
- for (String[] EDITOR_SWITCH_PAIR : EDITOR_SWITCH_PAIRS) {
- addTest(new EditorSwitchTest(EDITOR_SWITCH_PAIR));
- }
- }
-
- private void addOpenMultipleScenarios(boolean closeAll) {
- for (String EDITOR_FILE_EXTENSION : EDITOR_FILE_EXTENSIONS) {
- addTest(new OpenMultipleEditorTest(EDITOR_FILE_EXTENSION, closeAll, BasicPerformanceTest.NONE));
- }
- }
-
- private void addOpenCloseScenarios() {
- for (int i = 0; i < EDITOR_FILE_EXTENSIONS.length; i++) {
- addTest(new OpenCloseEditorTest(EDITOR_FILE_EXTENSIONS[i], i == 3 ? BasicPerformanceTest.LOCAL : BasicPerformanceTest.NONE));
- }
- }
-}
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/EditorSwitchTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/EditorSwitchTest.java
index 80dcb1d..0f62133 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/EditorSwitchTest.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/EditorSwitchTest.java
@@ -13,38 +13,51 @@
*******************************************************************************/
package org.eclipse.ui.tests.performance;
+import java.util.Arrays;
+import java.util.Collection;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.ide.IDE;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
/**
* Test editor switching.
*/
+@RunWith(Parameterized.class)
public class EditorSwitchTest extends BasicPerformanceTest {
private String extension1;
private String extension2;
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] { { "perf_outline", "java" }, { "perf_basic", "perf_outline" } });
+ }
+
/**
* Constructor.
*
* @param testName
* Test's name.
*/
- public EditorSwitchTest(String[] pair) {
- super("testEditorSwitch:" + pair[0] + "," + pair[1]);
- extension1 = pair[0];
- extension2 = pair[1];
+ public EditorSwitchTest(String extension1, String extension2) {
+ super("testEditorSwitch:" + extension1 + "," + extension2);
+ this.extension1 = extension1;
+ this.extension2 = extension2;
}
/**
* Test editor opening performance. This test always fails.
*/
- @Override
- protected void runTest() throws CoreException {
+ @Test
+ public void test() throws CoreException {
// Open both files outside the loop so as not to include
// the initial time to open, just switching.
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/GenerateIdentifiersTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/GenerateIdentifiersTest.java
index 98de433..bff02c1 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/GenerateIdentifiersTest.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/GenerateIdentifiersTest.java
@@ -15,6 +15,7 @@
package org.eclipse.ui.tests.performance;
import org.eclipse.ui.activities.IActivityManager;
+import org.junit.Test;
/**
* @since 3.1
@@ -22,15 +23,14 @@
*/
public class GenerateIdentifiersTest extends BasicPerformanceTest {
- private int count;
+ private static final int count = 10000;
- public GenerateIdentifiersTest(int numberOfIdentifiers) {
- super("Generate " + numberOfIdentifiers + " identifiers");
- this.count = numberOfIdentifiers;
+ public GenerateIdentifiersTest() {
+ super("Generate " + count + " identifiers");
}
- @Override
- protected void runTest() throws Throwable {
+ @Test
+ public void test() throws Throwable {
final IActivityManager activityManager = fWorkbench.getActivitySupport().getActivityManager();
exercise(() -> {
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/LabelProviderTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/LabelProviderTest.java
index 6bb0809..edfbb3a 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/LabelProviderTest.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/LabelProviderTest.java
@@ -14,6 +14,9 @@
package org.eclipse.ui.tests.performance;
+import java.util.Arrays;
+import java.util.Collection;
+
import org.eclipse.jface.tests.performance.JFacePerformanceSuite;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
@@ -41,11 +44,17 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
/**
* Test scrolling performance with various label styles
+ *
* @since 3.5
*/
+@RunWith(Parameterized.class)
public class LabelProviderTest extends BasicPerformanceTest {
private class CountryEntry {
@@ -64,21 +73,21 @@
baseName = Integer.toString(i + 100);
switch (i % 3) {
- case 0:
- image = display.getSystemImage(SWT.ICON_WARNING);
- bkColor = display.getSystemColor(SWT.COLOR_BLUE);
- fgColor = display.getSystemColor(SWT.COLOR_RED);
- break;
- case 1:
- image = display.getSystemImage(SWT.ICON_ERROR);
- bkColor = display.getSystemColor(SWT.COLOR_GREEN);
- fgColor = display.getSystemColor(SWT.COLOR_BLUE);
- break;
- case 2:
- image = display.getSystemImage(SWT.ICON_QUESTION);
- bkColor = display.getSystemColor(SWT.COLOR_RED);
- fgColor = display.getSystemColor(SWT.COLOR_GREEN);
- break;
+ case 0:
+ image = display.getSystemImage(SWT.ICON_WARNING);
+ bkColor = display.getSystemColor(SWT.COLOR_BLUE);
+ fgColor = display.getSystemColor(SWT.COLOR_RED);
+ break;
+ case 1:
+ image = display.getSystemImage(SWT.ICON_ERROR);
+ bkColor = display.getSystemColor(SWT.COLOR_GREEN);
+ fgColor = display.getSystemColor(SWT.COLOR_BLUE);
+ break;
+ case 2:
+ image = display.getSystemImage(SWT.ICON_QUESTION);
+ bkColor = display.getSystemColor(SWT.COLOR_RED);
+ fgColor = display.getSystemColor(SWT.COLOR_GREEN);
+ break;
}
}
@@ -114,19 +123,19 @@
// test so its contents has no effect on the performance results.
Object element = cell.getElement();
if (!(element instanceof CountryEntry))
- return;
+ return;
cell.setText(element.toString());
cell.setImage(getImage(element));
if (useColor) {
- cell.setForeground(((CountryEntry)element).getForegroundColor());
- cell.setBackground(((CountryEntry)element).getBackgroundColor());
+ cell.setForeground(((CountryEntry) element).getForegroundColor());
+ cell.setBackground(((CountryEntry) element).getBackgroundColor());
}
}
@Override
public Image getImage(Object element) {
if (element instanceof CountryEntry)
- return ((CountryEntry)element).getImage();
+ return ((CountryEntry) element).getImage();
return null;
}
@@ -152,18 +161,23 @@
private boolean styled;
private boolean colors;
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] { { true, true }, { true, false }, { false, true }, { false, false } });
+ }
+
/**
* @param styled <code>true</code> to use DecoratingStyledCellLabelProvider
* @param colors Run test with color on or off
*/
- public LabelProviderTest(String testName, boolean styled, boolean colors) {
- super(testName);
+ public LabelProviderTest(boolean styled, boolean colors) {
+ super("DecoratingLabelProviderStyled[" + styled + "]Colors[" + colors + "]");
this.styled = styled;
this.colors = colors;
}
- @Override
- protected void runTest() throws Throwable {
+ @Test
+ public void test() throws Throwable {
if (styled)
fViewer.setLabelProvider(getDecoratingStyledCellLabelProvider(colors));
else
@@ -259,17 +273,18 @@
private DecoratingStyledCellLabelProvider getDecoratingStyledCellLabelProvider(boolean useColor) {
// create our own context to avoid using default context
IDecorationContext context = new IDecorationContext() {
- @Override
- public String[] getProperties() {
- return null;
- }
- @Override
- public Object getProperty(String property) {
- return null;
- }
- };
- return new DecoratingStyledCellLabelProvider(
- new TestCellLabelProvider(useColor), useColor ? getDecorator() : null, context);
+ @Override
+ public String[] getProperties() {
+ return null;
+ }
+
+ @Override
+ public Object getProperty(String property) {
+ return null;
+ }
+ };
+ return new DecoratingStyledCellLabelProvider(new TestCellLabelProvider(useColor),
+ useColor ? getDecorator() : null, context);
}
private ILabelDecorator getDecorator() {
@@ -308,14 +323,14 @@
@Override
public Color decorateBackground(Object element) {
if (element instanceof CountryEntry)
- return ((CountryEntry)element).getBackgroundColor();
+ return ((CountryEntry) element).getBackgroundColor();
return null;
}
@Override
public Color decorateForeground(Object element) {
if (element instanceof CountryEntry)
- return ((CountryEntry)element).getForegroundColor();
+ return ((CountryEntry) element).getForegroundColor();
return null;
}
}
@@ -326,7 +341,7 @@
@Override
public Image getImage(Object element) {
if (element instanceof CountryEntry)
- return ((CountryEntry)element).getImage();
+ return ((CountryEntry) element).getImage();
return null;
}
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/LabelProviderTestSuite.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/LabelProviderTestSuite.java
deleted file mode 100644
index 7f416f8..0000000
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/LabelProviderTestSuite.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.tests.performance;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @since 3.5
- */
-public class LabelProviderTestSuite extends TestSuite {
-
- public static Test suite() {
- return new LabelProviderTestSuite();
- }
-
- public LabelProviderTestSuite() {
- addTest(new LabelProviderTest("DecoratingStyledCellLabelProvider with Colors", true, true));
- addTest(new LabelProviderTest("DecoratingStyledCellLabelProvider", true, false));
- addTest(new LabelProviderTest("DecoratingLabelProvider with Colors", false, true));
- addTest(new LabelProviderTest("DecoratingLabelProvider", false, false));
- }
-}
\ No newline at end of file
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionClasses.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionClasses.java
deleted file mode 100644
index fb4f638..0000000
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionClasses.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.tests.performance;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.mapping.ModelProvider;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.resources.mapping.ResourceMappingContext;
-import org.eclipse.core.resources.mapping.ResourceTraversal;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.ui.IContributorResourceAdapter;
-import org.eclipse.ui.ide.IContributorResourceAdapter2;
-
-public class ObjectContributionClasses implements IAdapterFactory {
-
- public static final String PROJECT_NAME = "testContributorResourceAdapter";
-
- public static interface ICommon {
- }
-
- public static class Common implements ICommon {
- }
-
- public static interface IA {
- }
-
- public static class A implements IA {
- }
-
- public static class A1 extends A {
- }
-
- public static class A11 extends A1 {
- }
-
- public static interface IB {
- }
-
- public static class B implements IB {
- }
-
- public static class B2 implements IB {
- }
-
- public static class D extends Common implements IA {
- }
-
- public static class C implements ICommon {
- }
-
- public static class CResource implements IAdaptable {
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getAdapter(Class<T> adapter) {
- if(adapter == IContributorResourceAdapter.class) {
- return (T) new ResourceAdapter();
- }
- return null;
- }
- }
-
- public static class CFile implements IAdaptable {
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getAdapter(Class<T> adapter) {
- if(adapter == IContributorResourceAdapter.class) {
- return (T) new ResourceAdapter();
- }
- return null;
- }
- }
-
- // Returns a contribution adapter that doesn't handle ResourceMappings
- public static class CResourceOnly implements IAdaptable {
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getAdapter(Class<T> adapter) {
- if(adapter == IContributorResourceAdapter.class) {
- return (T) new ResourceOnlyAdapter();
- }
- return null;
- }
- }
-
- public interface IModelElement {
- }
-
- public static class ModelElement extends PlatformObject implements IModelElement {
- }
-
- // Default contributor adapter
-
- public static class ResourceAdapter implements IContributorResourceAdapter2 {
- @Override
- public IResource getAdaptedResource(IAdaptable adaptable) {
- if(adaptable instanceof CResource) {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
- if(adaptable instanceof CFile) {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME).getFile("dummy");
- }
- return null;
- }
- @Override
- public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) {
- return getAdaptedResource(adaptable).getAdapter(ResourceMapping.class);
- }
- }
-
- // Contributor adapter that doesn't handle resource mappings
-
- public static class ResourceOnlyAdapter implements IContributorResourceAdapter {
- @Override
- public IResource getAdaptedResource(IAdaptable adaptable) {
- if(adaptable instanceof CResourceOnly) {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
- return null;
- }
- }
-
- // Adapter methods
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getAdapter(final Object adaptableObject, Class<T> adapterType) {
- if(adapterType == IContributorResourceAdapter.class) {
- return (T) new ResourceAdapter();
- }
- if(adaptableObject instanceof IA && adapterType == IA.class) {
- return (T) new A();
- }
- if(adapterType == IResource.class) {
- return (T) ResourcesPlugin.getWorkspace().getRoot();
- }
- if(adapterType == ICommon.class) {
- return (T) new Common();
- }
- if(adapterType == ResourceMapping.class) {
- return (T) new ResourceMapping() {
- @Override
- public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) {
- return new ResourceTraversal[] {
- new ResourceTraversal(new IResource[] {ResourcesPlugin.getWorkspace().getRoot()}, IResource.DEPTH_INFINITE, IResource.NONE)
- };
- }
- @Override
- public IProject[] getProjects() {
- return ResourcesPlugin.getWorkspace().getRoot().getProjects();
- }
- @Override
- public Object getModelObject() {
- return adaptableObject;
- }
- @Override
- public String getModelProviderId() {
- return ModelProvider.RESOURCE_MODEL_PROVIDER_ID;
- }
- };
- }
-
- return null;
- }
-
- @Override
- public Class<?>[] getAdapterList() {
- return new Class[] { ICommon.class, IResource.class, IFile.class, IContributorResourceAdapter.class, ResourceMapping.class};
- }
-}
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionTest.java
deleted file mode 100644
index 781528d..0000000
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionTest.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.tests.performance;
-
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.SubContributionItem;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.PartSite;
-import org.eclipse.ui.internal.PopupMenuExtender;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-import org.eclipse.ui.tests.performance.ObjectContributionClasses.ICommon;
-/**
- * Tests that object contributions are enabled and shown correctly in pop-up
- * menus depending on the state of the workbench. This test relies on the
- * <code>plugin.xml</code> file containing certain values. Please see the
- * appropriate section in that file for more information about the initial
- * set-up.
- *
- * @since 3.0
- */
-public final class ObjectContributionTest extends UITestCase {
-
- /**
- * Constructs a new instance of <code>ObjectContributionTest</code> with
- * the name of the test.
- *
- * @param name
- * The name of the test; may be <code>null</code>.
- */
- public ObjectContributionTest(final String name) {
- super(name);
- }
-
- /**
- * Tests whether the content-type object contribution works. This is testing
- * a use care familiar to Ant UI. The content-type scans an XML file to see
- * if its root element is <code><project></code>.
- *
- * @throws CoreException
- * If a problem occurs when creating the project or file, or if
- * the project can't be opened.
- */
- public final void testObjectStateContentType() throws CoreException {
- // Create an XML file with <project> as its root element.
- final IWorkspace workspace = ResourcesPlugin.getWorkspace();
- final IProject testProject = workspace.getRoot().getProject(
- "ObjectContributionTestProject");
- testProject.create(null);
- testProject.open(null);
- final IFile xmlFile = testProject.getFile("ObjectContributionTest.xml");
- final String contents = "<testObjectStateContentTypeElement></testObjectStateContentTypeElement>";
- final ByteArrayInputStream inputStream = new ByteArrayInputStream(
- contents.getBytes());
- xmlFile.create(inputStream, true, null);
- final ISelection selection = new StructuredSelection(xmlFile);
- assertPopupMenus("1", new String[] {"org.eclipse.ui.tests.testObjectStateContentType"}, selection, null, true);
- }
-
- /**
- * This tests backwards compatibility support for adaptable IResource objectContributions. This
- * allows IResource adaptable contributions without an adapter factory and using
- * the IContributorResourceAdapter factory. In addition, test the ResourceMapping adaptations.
- *
- * @since 3.1
- */
- public final void testContributorResourceAdapter() throws CoreException {
-
- final IWorkspace workspace = ResourcesPlugin.getWorkspace();
- final IProject testProject = workspace.getRoot().getProject(ObjectContributionClasses.PROJECT_NAME);
- if(! testProject.exists()) {
- testProject.create(null);
- }
- if(! testProject.isOpen()) {
- testProject.open(null);
- }
-
- assertPopupMenus("1",
- new String[] {"IResource.1"},
- new StructuredSelection(new Object[] {new ObjectContributionClasses.CResource()}),
- IResource.class,
- true
- );
- assertPopupMenus("2",
- new String[] {"IProject.1"},
- new StructuredSelection(new Object[] {new ObjectContributionClasses.CFile()}),
- null,
- false
- );
- assertPopupMenus("3",
- new String[] {"IFile.1"},
- new StructuredSelection(new Object[] {new ObjectContributionClasses.CFile()}),
- IFile.class,
- true
- );
- assertPopupMenus("4",
- new String[] {"IResource.1"},
- new StructuredSelection(new Object[] {new ObjectContributionClasses.CFile(), new ObjectContributionClasses.CResource()}),
- IResource.class,
- true
- );
- assertPopupMenus("5",
- new String[] {"IFile.1", "IProject.1"},
- new StructuredSelection(new Object[] {new ObjectContributionClasses.CFile(), new ObjectContributionClasses.CResource()}),
- IResource.class,
- false
- );
- assertPopupMenus("6",
- new String[] {"ResourceMapping.1"},
- new StructuredSelection(new Object[] {new ObjectContributionClasses.CFile(), new ObjectContributionClasses.CResource()}),
- ResourceMapping.class,
- true
- );
- assertPopupMenus("7",
- new String[] {"ResourceMapping.1", "IResource.1"},
- new StructuredSelection(new Object[] {new ObjectContributionClasses.ModelElement()}),
- ResourceMapping.class,
- true
- );
- // Ensure that the case where an object uses a contribution adapter that doesn't handle mappings
- // will still show the menus for resource mappings
- assertPopupMenus("8",
- new String[] {"ResourceMapping.1", "IResource.1"},
- new StructuredSelection(new Object[] {new ObjectContributionClasses.CResourceOnly()}),
- ResourceMapping.class,
- true
- );
- }
-
- /**
- * This tests adaptable contributions that are not IResource.
- *
- * @since 3.1
- */
- public final void testAdaptables() {
- assertPopupMenus("1",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.A()}),
- ICommon.class,
- true
- );
- assertPopupMenus("2",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.A(),
- new ObjectContributionClasses.B()}),
- ICommon.class,
- true
- );
- assertPopupMenus("3",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.A(),
- new ObjectContributionClasses.B(),
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.Common()
- }),
- ICommon.class,
- true
- );
- assertPopupMenus("4",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.Common(),
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.B(),
- new ObjectContributionClasses.A()
- }),
- ICommon.class,
- true
- );
- assertPopupMenus("5",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.Common(),
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.B(),
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.A(),
- new ObjectContributionClasses.Common()
- }),
- ICommon.class,
- true
- );
- assertPopupMenus("6",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.Common()
- }),
- ICommon.class,
- true
- );
- assertPopupMenus("7",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new Object()
- }),
- ICommon.class,
- false
- );
- assertPopupMenus("8",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.C(),
- new Object()
- }),
- ICommon.class,
- false
- );
- assertPopupMenus("9",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.A(),
- new Object()
- }),
- ICommon.class,
- false
- );
- }
-
- /**
- * Ensure that there are no duplicate contributions.
- *
- * @since 3.1
- */
- public final void testDuplicateAdaptables() {
- assertPopupMenus("1",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.D()}),
- ICommon.class,
- true
- );
- // repeat test on purpose to ensure no double call duplicates.
- assertPopupMenus("1",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.D()}),
- ICommon.class,
- true
- );
- assertPopupMenus("2",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.D(),
- new ObjectContributionClasses.A()
- }),
- ICommon.class,
- true
- );
- assertPopupMenus("3",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.A(),
- new ObjectContributionClasses.D()
- }),
- ICommon.class,
- true
- );
- assertPopupMenus("4",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.Common(),
- new ObjectContributionClasses.D()
- }),
- ICommon.class,
- true
- );
- assertPopupMenus("5",
- new String[] {"ICommon.1"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.D(),
- new ObjectContributionClasses.Common()
- }),
- ICommon.class,
- true
- );
- }
-
- /**
- * Test non-adaptable contributions
- *
- * @since 3.1
- */
- public final void testNonAdaptableContributions() {
- assertPopupMenus("1",
- new String[] {"ICommon.2"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.A(),
- new ObjectContributionClasses.B()}),
- ICommon.class,
- false
- );
- assertPopupMenus("2",
- new String[] {"ICommon.2"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.D(),
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.Common()}),
- ICommon.class,
- true
- );
- assertPopupMenus("3",
- new String[] {"Common.2"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.D(),
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.A()}),
- ICommon.class,
- false
- );
- assertPopupMenus("4",
- new String[] {"Common.2"},
- new StructuredSelection(new Object[] {
- new ObjectContributionClasses.B(),
- new ObjectContributionClasses.C(),
- new ObjectContributionClasses.A()}),
- ICommon.class,
- false
- );
- }
-
- /**
- * Helper class that will create a popup menu based on the given selection and
- * then ensure that the provided commandIds are added to the menu.
- *
- * @param commandIds the command ids that should appear in the menu
- * @param selection the selection on which to contribute object contributions
- */
- public void assertPopupMenus(String name, String[] commandIds, final ISelection selection, Class<?> selectionType,
- boolean existance) {
- ISelectionProvider selectionProvider = new ISelectionProvider() {
- @Override
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- }
- @Override
- public ISelection getSelection() {
- return selection;
- }
- @Override
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- }
- @Override
- public void setSelection(ISelection selection) {
- }
- };
-
- // The popup extender needs a part to notify actions of the active part
- final WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- final IWorkbenchPage page = window.getActivePage();
- IWorkbenchPart part = page.getActivePartReference().getPart(true);
-
- // Create a fake PopupMenuExtender so we can get some data back.
- final MenuManager fakeMenuManager = new MenuManager();
- fakeMenuManager.add(new GroupMarker(
- org.eclipse.ui.IWorkbenchActionConstants.MB_ADDITIONS));
- final PopupMenuExtender extender = new PopupMenuExtender(null,
- fakeMenuManager, selectionProvider, part,
- ((PartSite) part.getSite()).getContext());
-
-
-
- /*
- * Pretend to show the pop-up menu -- looking to motivate the extender
- * to fill the menu based on the selection provider.
- *
- * TODO This causes a big delay (in the order of a minute or more) while
- * trying to fill this menu. It seems to be loading a bunch of plug-ins,
- * and doing class loading.
- */
- extender.menuAboutToShow(fakeMenuManager);
-
- extender.dispose();
-
- // Check to see if the appropriate object contributions are present.
- final IContributionItem[] items = fakeMenuManager.getItems();
- Set<String> seenCommands = new HashSet<>(Arrays.asList(commandIds));
- List<String> commands = new ArrayList<>(Arrays.asList(commandIds));
- for (IContributionItem contributionItem : items) {
- // Step 1: test the selection
- if (selectionType != null) {
- IContributionItem item = contributionItem;
- if (item instanceof SubContributionItem) {
- item = ((SubContributionItem) contributionItem).getInnerItem();
- }
- }
- // Step 2: remember that we saw this element
- String id = contributionItem.getId();
- if(existance) {
- boolean removed = commands.remove(id);
- if(seenCommands.contains(id) && ! removed) {
- fail(name + " item duplicated in the context menu: " + id);
- }
- } else {
- assertTrue(name + " item should not be in the context menu", ! commands.contains(id));
- }
- }
-
- if(existance && ! commands.isEmpty()) {
- fail(name + " Missing " + commands + " from context menu.");
- }
- }
-}
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionsPerformance.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionsPerformance.java
deleted file mode 100644
index 764c8f9..0000000
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ObjectContributionsPerformance.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.tests.performance;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.test.performance.Dimension;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class ObjectContributionsPerformance extends BasicPerformanceTest {
-
- public static final int SEED = 1001001;
- private IStructuredSelection selection;
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Object contribution performance");
- suite.addTest(new ObjectContributionsPerformance(
- "large selection, limited contributors",
- generateAdaptableSelection(SEED, 5000),
- BasicPerformanceTest.NONE));
- suite
- .addTest(new ObjectContributionsPerformance(
- "limited selection, limited contributors",
- generateAdaptableSelection(SEED, 50),
- BasicPerformanceTest.NONE));
- return suite;
- }
-
- public ObjectContributionsPerformance(String label, IStructuredSelection selection, int tagging) {
- super("testObjectContributions:" + label, tagging);
- this.selection = selection;
- }
-
- @Override
- protected void runTest() {
- ObjectContributionTest tests = new ObjectContributionTest(
- "testObjectContributions");
- tagIfNecessary("UI - " + selection.size() + " contribution(s)",
- Dimension.ELAPSED_PROCESS);
- startMeasuring();
- for (int i = 0; i < 5000; i++) {
- tests.assertPopupMenus("1", new String[] { "bogus" }, selection,
- null, false);
- }
- stopMeasuring();
- commitMeasurements();
- assertPerformance();
- }
-
- protected static IStructuredSelection generateAdaptableSelection(int seed, int size) {
- Random rand = new Random(seed);
- List<Object> selection = new ArrayList<>();
- for (int i = 0; i < size; i++) {
- switch ((int) Math.round(rand.nextDouble() * 5)) {
- case 0 :
- selection.add(new ObjectContributionClasses.A());
- break;
- case 1 :
- selection.add(new ObjectContributionClasses.B());
- break;
- case 2 :
- selection.add(new ObjectContributionClasses.C());
- break;
- case 3 :
- selection.add(new ObjectContributionClasses.Common());
- break;
- case 4 :
- selection.add(new ObjectContributionClasses.D());
- break;
- case 5 :
- selection.add(new ObjectContributionClasses.A1());
- break;
- default :
- selection.add(new Object());
- }
- }
- return new StructuredSelection(selection);
- }
-}
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseEditorTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseEditorTest.java
index 5d66fd2..6040f7f 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseEditorTest.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseEditorTest.java
@@ -14,6 +14,9 @@
package org.eclipse.ui.tests.performance;
+import java.util.Arrays;
+import java.util.Collection;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.test.performance.Dimension;
import org.eclipse.ui.IEditorPart;
@@ -21,21 +24,30 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
-/**
- * @since 3.1
- */
+@RunWith(Parameterized.class)
public class OpenCloseEditorTest extends BasicPerformanceTest {
private String extension;
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] { { "perf_basic", BasicPerformanceTest.NONE },
+ { "perf_outline", BasicPerformanceTest.NONE }, { "java", BasicPerformanceTest.LOCAL } });
+ }
+
+
public OpenCloseEditorTest(String extension, int tagging) {
super("testOpenAndCloseEditors:" + extension, tagging);
this.extension = extension;
}
- @Override
- protected void runTest() throws Throwable {
+ @Test
+ public void test() throws Throwable {
final IFile file = getProject().getFile("1." + extension);
assertTrue(file.exists());
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenClosePerspectiveTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenClosePerspectiveTest.java
index 24619b3..6ec04b0 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenClosePerspectiveTest.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenClosePerspectiveTest.java
@@ -15,6 +15,8 @@
package org.eclipse.ui.tests.performance;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import org.eclipse.core.commands.Command;
@@ -33,25 +35,34 @@
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.WorkbenchPlugin;
+import org.eclipse.ui.tests.harness.util.EmptyPerspective;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
-/**
- * @since 3.1
- */
+@RunWith(Parameterized.class)
public class OpenClosePerspectiveTest extends BasicPerformanceTest {
private String id;
- /**
- * @param tagging
- * @param testName
- */
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] { { EmptyPerspective.PERSP_ID2, BasicPerformanceTest.NONE }, {
+ UIPerformanceTestSetup.PERSPECTIVE1,
+ BasicPerformanceTest.LOCAL },
+ { "org.eclipse.ui.resourcePerspective", BasicPerformanceTest.NONE },
+ { "org.eclipse.jdt.ui.JavaPerspective", BasicPerformanceTest.NONE },
+ { "org.eclipse.debug.ui.DebugPerspective", BasicPerformanceTest.NONE } });
+ }
+
public OpenClosePerspectiveTest(String id, int tagging) {
super("testOpenClosePerspectives:" + id, tagging);
this.id = id;
}
- @Override
- protected void runTest() throws Throwable {
+ @Test
+ public void test() throws Throwable {
// Get the two perspectives to switch between.
final IPerspectiveRegistry registry = WorkbenchPlugin.getDefault()
.getPerspectiveRegistry();
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseWindowTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseWindowTest.java
index cdd9df0..4978f14 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseWindowTest.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseWindowTest.java
@@ -14,27 +14,36 @@
package org.eclipse.ui.tests.performance;
+import java.util.Arrays;
+import java.util.Collection;
+
import org.eclipse.test.performance.Dimension;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.tests.harness.util.EmptyPerspective;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
-/**
- * @since 3.1
- */
+@RunWith(Parameterized.class)
public class OpenCloseWindowTest extends BasicPerformanceTest {
private String id;
- /**
- * @param tagging
- * @param testName
- */
- public OpenCloseWindowTest(String id, int tagging) {
- super("testOpenCloseWindows:" + id, tagging);
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] { { EmptyPerspective.PERSP_ID2 }, { UIPerformanceTestSetup.PERSPECTIVE1 },
+ { "org.eclipse.ui.resourcePerspective" }, { "org.eclipse.jdt.ui.JavaPerspective" },
+ { "org.eclipse.debug.ui.DebugPerspective" } });
+ }
+
+ public OpenCloseWindowTest(String id) {
+ super("testOpenCloseWindows:" + id, BasicPerformanceTest.NONE);
this.id = id;
}
- @Override
- protected void runTest() throws Throwable {
+ @Test
+ public void test() throws Throwable {
tagIfNecessary("UI - Open/Close Window", Dimension.ELAPSED_PROCESS);
exercise(() -> {
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenMultipleEditorTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenMultipleEditorTest.java
index 8fbadc3..8d5ad2a 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenMultipleEditorTest.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenMultipleEditorTest.java
@@ -14,32 +14,44 @@
package org.eclipse.ui.tests.performance;
+import java.util.Arrays;
+import java.util.Collection;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.test.performance.Dimension;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.ide.IDE;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
/**
* @since 3.1
*/
+@RunWith(Parameterized.class)
public class OpenMultipleEditorTest extends BasicPerformanceTest {
private String extension;
private boolean closeAll;
- /**
- * @param testName
- */
- public OpenMultipleEditorTest(String extension, boolean closeAll, int tagging) {
- super ("testOpenMultipleEditors:" + extension + (closeAll ? "[closeAll]" : "[closeEach]"), tagging);
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] { { "perf_basic", true }, { "perf_outline", true }, { "java", true },
+ { "perf_basic", false }, { "perf_outline", false }, { "java", false } });
+ }
+
+ public OpenMultipleEditorTest(String extension, boolean closeAll) {
+ super("testOpenMultipleEditors:" + extension + (closeAll ? "[closeAll]" : "[closeEach]"),
+ BasicPerformanceTest.NONE);
this.extension = extension;
this.closeAll = closeAll;
}
- @Override
- protected void runTest() throws Throwable {
+ @Test
+ public void test() throws Throwable {
IWorkbenchWindow window = openTestWindow(UIPerformanceTestSetup.PERSPECTIVE1);
IWorkbenchPage activePage = window.getActivePage();
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/PerspectiveSwitchTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/PerspectiveSwitchTest.java
index 3ddcd93..c1d9adb 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/PerspectiveSwitchTest.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/PerspectiveSwitchTest.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ui.tests.performance;
+import java.util.Arrays;
+import java.util.Collection;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.test.performance.Dimension;
@@ -23,40 +26,54 @@
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.WorkbenchPlugin;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
/**
* Test perspective switching.
*/
+@RunWith(Parameterized.class)
public class PerspectiveSwitchTest extends BasicPerformanceTest {
private String id1;
private String id2;
private String activeEditor;
- /**
- * Constructor.
- *
- * @param id
- */
- public PerspectiveSwitchTest(String [] ids, int tagging) {
- super("testPerspectiveSwitch:" + ids[0] + "," + ids[1] + ",editor " + ids[2], tagging);
- this.id1 = ids[0];
- this.id2 = ids[1];
- this.activeEditor = ids[2];
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] { // Test switching between the two most commonly used perspectives in the
+ // SDK
+ // (this is the most important
+ // perspective switch test, but it is easily affected by changes in JDT, etc.)
+ { "org.eclipse.jdt.ui.JavaPerspective", "org.eclipse.debug.ui.DebugPerspective", "1.java" },
+
+ { UIPerformanceTestSetup.PERSPECTIVE1, UIPerformanceTestSetup.PERSPECTIVE2, "1.perf_basic" },
+
+ // Test switching between a perspective with lots of actions and a perspective
+ // with none
+ { "org.eclipse.jdt.ui.JavaPerspective", "org.eclipse.ui.tests.util.EmptyPerspective", "1.perf_basic" },
+
+ { "org.eclipse.ui.resourcePerspective", "org.eclipse.jdt.ui.JavaPerspective", "1.java" } });
+ }
+
+ public PerspectiveSwitchTest(String id1, String id2, String activeEditor) {
+ super("testPerspectiveSwitch:" + id1 + "," + id2 + ",editor " + activeEditor, BasicPerformanceTest.NONE);
+ this.id1 = id1;
+ this.id2 = id2;
+ this.activeEditor = activeEditor;
}
/**
* Test perspective switching performance.
*/
- @Override
- protected void runTest() throws CoreException, WorkbenchException {
+ @Test
+ public void test() throws CoreException, WorkbenchException {
// Get the two perspectives to switch between.
- final IPerspectiveRegistry registry = WorkbenchPlugin.getDefault()
- .getPerspectiveRegistry();
- final IPerspectiveDescriptor perspective1 = registry
- .findPerspectiveWithId(id1);
- final IPerspectiveDescriptor perspective2 = registry
- .findPerspectiveWithId(id2);
+ final IPerspectiveRegistry registry = WorkbenchPlugin.getDefault().getPerspectiveRegistry();
+ final IPerspectiveDescriptor perspective1 = registry.findPerspectiveWithId(id1);
+ final IPerspectiveDescriptor perspective2 = registry.findPerspectiveWithId(id2);
// Don't fail if we reference an unknown perspective ID. This can be
// a normal occurrance since the test suites reference JDT perspectives, which
@@ -79,7 +96,8 @@
assertNotNull(page);
page.setPerspective(perspective2);
- //IFile aFile = getProject().getFile("1." + EditorPerformanceSuite.EDITOR_FILE_EXTENSIONS[0]);
+ // IFile aFile = getProject().getFile("1." +
+ // EditorPerformanceSuite.EDITOR_FILE_EXTENSIONS[0]);
IFile aFile = getProject().getFile(activeEditor);
assertTrue(aFile.exists());
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestSetup.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestSetup.java
index d19b144..e48517f 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestSetup.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestSetup.java
@@ -37,6 +37,7 @@
public static final String PROJECT_NAME = "Performance Project";
private static final String INTRO_VIEW= "org.eclipse.ui.internal.introview";
+ public static final String[] EDITOR_FILE_EXTENSIONS = { "perf_basic", "perf_outline", "java" };
private IProject testProject;
@@ -63,23 +64,6 @@
}
}
- @Override
- protected void tearDown() throws Exception {
- // do nothing, the set up workspace will be used by the open editor tests
-
- /*
- * ensure the workbench state gets saved when running with the Automated Testing Framework
- * TODO: remove when https://bugs.eclipse.org/bugs/show_bug.cgi?id=71362 is fixed
- */
- StackTraceElement[] elements= new Throwable().getStackTrace();
- for (StackTraceElement element : elements) {
- if (element.getClassName().equals("org.eclipse.test.EclipseTestRunner")) {
- PlatformUI.getWorkbench().close();
- break;
- }
- }
- }
-
private void setUpProject() throws CoreException {
// Create a java project.
@@ -87,15 +71,8 @@
testProject = workspace.getRoot().getProject(PROJECT_NAME);
testProject.create(null);
testProject.open(null);
- /*IProjectDescription projectDescription = testProject.getDescription();
- String[] natureIds = { "org.eclipse.jdt.core.javanature" };
- projectDescription.setNatureIds(natureIds);*/
- /*ICommand buildCommand = new BuildCommand();
- buildCommand.setBuilderName("org.eclipse.jdt.core.javabuilder");
- projectDescription.setBuildSpec(new ICommand[] { buildCommand });
- testProject.setDescription(projectDescription, null);*/
- for (String EDITOR_FILE_EXTENSION : EditorPerformanceSuite.EDITOR_FILE_EXTENSIONS) {
+ for (String EDITOR_FILE_EXTENSION : EDITOR_FILE_EXTENSIONS) {
createFiles(EDITOR_FILE_EXTENSION);
}
}
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestSuite.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestSuite.java
index 037010e..1b3eb3d 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestSuite.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestSuite.java
@@ -13,17 +13,12 @@
*******************************************************************************/
package org.eclipse.ui.tests.performance;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
+import junit.framework.JUnit4TestAdapter;
import junit.framework.Test;
-import junit.framework.TestSuite;
/**
* Test all areas of the UI API.
*/
-@RunWith(Suite.class)
-@Suite.SuiteClasses({})
public class UIPerformanceTestSuite extends FilteredTestSuite {
/**
@@ -38,12 +33,18 @@
*/
public UIPerformanceTestSuite() {
super();
- addTest(new ActivitiesPerformanceSuite());
+ addTestSuite(GenerateIdentifiersTest.class);
addTest(new WorkbenchPerformanceSuite());
+ addTest(new JUnit4TestAdapter(OpenClosePerspectiveTest.class));
+ addTest(new JUnit4TestAdapter(PerspectiveSwitchTest.class));
+ addTest(new JUnit4TestAdapter(OpenCloseWindowTest.class));
addTest(new ViewPerformanceSuite());
- addTest(new EditorPerformanceSuite());
- addTest(new TestSuite(CommandsPerformanceTest.class));
- addTest(new LabelProviderTestSuite());
- addTest(new TestSuite(ProgressReportingTest.class));
+ addTest(new JUnit4TestAdapter(OpenCloseEditorTest.class));
+ addTest(new JUnit4TestAdapter(OpenMultipleEditorTest.class));
+ addTest(new JUnit4TestAdapter(EditorSwitchTest.class));
+ addTestSuite(CommandsPerformanceTest.class);
+ addTest(new JUnit4TestAdapter(LabelProviderTest.class));
+ addTestSuite(ProgressReportingTest.class);
+ addTestSuite(OpenNavigatorFolderTest.class);
}
}
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ViewPerformanceSuite.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ViewPerformanceSuite.java
index b3c5a18..83f8e28 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ViewPerformanceSuite.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ViewPerformanceSuite.java
@@ -45,7 +45,6 @@
public ViewPerformanceSuite() {
addOpenCloseTests();
addResizeTests();
- addTestSuite(OpenNavigatorFolderTest.class);
}
private void addOpenCloseTests() {
@@ -69,8 +68,7 @@
public static String[] getAllTestableViewIds() {
HashSet<String> result = new HashSet<>();
- IViewDescriptor[] descriptors = PlatformUI.getWorkbench()
- .getViewRegistry().getViews();
+ IViewDescriptor[] descriptors = PlatformUI.getWorkbench().getViewRegistry().getViews();
for (IViewDescriptor descriptor : descriptors) {
String[] categoryPath = descriptor.getCategoryPath();
if (categoryPath == null)
diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/WorkbenchPerformanceSuite.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/WorkbenchPerformanceSuite.java
index 7e22f6f..1f654df 100644
--- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/WorkbenchPerformanceSuite.java
+++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/WorkbenchPerformanceSuite.java
@@ -14,10 +14,6 @@
package org.eclipse.ui.tests.performance;
-import java.util.ArrayList;
-
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.tests.harness.util.EmptyPerspective;
import org.eclipse.ui.tests.performance.layout.PerspectiveWidgetFactory;
import org.eclipse.ui.tests.performance.layout.ResizeTest;
@@ -25,47 +21,21 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-/**
- * @since 3.1
- */
class WorkbenchPerformanceSuite extends TestSuite {
private static String RESOURCE_PERSPID = "org.eclipse.ui.resourcePerspective";
- // Note: to test perspective switching properly, we need perspectives with lots of
+ // Note: to test perspective switching properly, we need perspectives with lots
+ // of
// associated actions.
- // NOTE - do not change the order of the IDs below. the PerspectiveSwitchTest has a
+ // NOTE - do not change the order of the IDs below. the PerspectiveSwitchTest
+ // has a
// fingerprint test for performance that releys on this not changing.
- public static final String [] PERSPECTIVE_IDS = {
- EmptyPerspective.PERSP_ID2,
- UIPerformanceTestSetup.PERSPECTIVE1,
- RESOURCE_PERSPID,
- "org.eclipse.jdt.ui.JavaPerspective",
- "org.eclipse.debug.ui.DebugPerspective"};
+ public static final String[] PERSPECTIVE_IDS = { EmptyPerspective.PERSP_ID2, UIPerformanceTestSetup.PERSPECTIVE1,
+ RESOURCE_PERSPID, "org.eclipse.jdt.ui.JavaPerspective", "org.eclipse.debug.ui.DebugPerspective" };
// Perspective ID to use for the resize window fingerprint test
public static String resizeFingerprintTest = RESOURCE_PERSPID;
- public static final String [][] PERSPECTIVE_SWITCH_PAIRS = {
- // Test switching between the two most commonly used perspectives in the SDK (this is the most important
- // perspective switch test, but it is easily affected by changes in JDT, etc.)
- {"org.eclipse.jdt.ui.JavaPerspective", "org.eclipse.debug.ui.DebugPerspective", "1.java"},
-
- {UIPerformanceTestSetup.PERSPECTIVE1, UIPerformanceTestSetup.PERSPECTIVE2, "1.perf_basic"},
-
- {"org.eclipse.ui.tests.dnd.dragdrop", "org.eclipse.ui.tests.fastview_perspective", "1.perf_basic"},
-
- // Test switching between a perspective with lots of actions and a perspective with none
- {"org.eclipse.jdt.ui.JavaPerspective", "org.eclipse.ui.tests.util.EmptyPerspective", "1.perf_basic"},
-
- {RESOURCE_PERSPID, "org.eclipse.jdt.ui.JavaPerspective", "1.java"}
- };
-
- public static final String[] VIEW_IDS = {
- "org.eclipse.ui.views.ProblemView",
- "org.eclipse.ui.views.ResourceNavigator"
- };
- public static final int ITERATIONS = 25;
-
/**
* Returns the suite. This is required to use the JUnit Launcher.
*/
@@ -75,58 +45,11 @@
public WorkbenchPerformanceSuite() {
addResizeScenarios();
- addPerspectiveSwitchScenarios();
- addPerspectiveOpenCloseScenarios();
- addWindowOpenCloseScenarios();
- addContributionScenarios();
}
- private void addContributionScenarios() {
- addTest(new ObjectContributionsPerformance(
- "large selection, limited contributors",
- ObjectContributionsPerformance.generateAdaptableSelection(
- ObjectContributionsPerformance.SEED, 5000),
- BasicPerformanceTest.NONE));
- addTest(new ObjectContributionsPerformance(
- "limited selection, limited contributors",
- ObjectContributionsPerformance.generateAdaptableSelection(
- ObjectContributionsPerformance.SEED, 50),
- BasicPerformanceTest.NONE));
- }
-
- private void addWindowOpenCloseScenarios() {
- for (String PERSPECTIVE_ID : PERSPECTIVE_IDS) {
- addTest(new OpenCloseWindowTest(PERSPECTIVE_ID, BasicPerformanceTest.NONE));
- }
- }
-
- private void addPerspectiveOpenCloseScenarios() {
- for (int i = 0; i < PERSPECTIVE_IDS.length; i++) {
- addTest(new OpenClosePerspectiveTest(PERSPECTIVE_IDS[i], i == 1 ? BasicPerformanceTest.LOCAL : BasicPerformanceTest.NONE));
- }
- }
-
- private void addPerspectiveSwitchScenarios() {
- for (String[] PERSPECTIVE_SWITCH_PAIR : PERSPECTIVE_SWITCH_PAIRS) {
- addTest(new PerspectiveSwitchTest(PERSPECTIVE_SWITCH_PAIR, BasicPerformanceTest.NONE));
- }
- }
-
- public static String[] getAllPerspectiveIds() {
- ArrayList<String> result = new ArrayList<>();
- IPerspectiveDescriptor[] perspectives = PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
-
- for (IPerspectiveDescriptor descriptor : perspectives) {
- String id = descriptor.getId();
- result.add(id);
- }
-
- return result.toArray(new String[result.size()]);
- }
private void addResizeScenarios() {
- String[] perspectiveIds = getAllPerspectiveIds();
- for (String id : perspectiveIds) {
+ for (String id : PERSPECTIVE_IDS) {
addTest(new ResizeTest(new PerspectiveWidgetFactory(id),
id.equals(resizeFingerprintTest) ? BasicPerformanceTest.LOCAL : BasicPerformanceTest.NONE,
"UI - Workbench Window Resize"));
diff --git a/tests/org.eclipse.ui.tests/plugin.xml b/tests/org.eclipse.ui.tests/plugin.xml
index 8b450c0..815d98a 100644
--- a/tests/org.eclipse.ui.tests/plugin.xml
+++ b/tests/org.eclipse.ui.tests/plugin.xml
@@ -48,11 +48,6 @@
id="org.eclipse.ui.tests.api.SessionPerspective">
</perspective>
<perspective
- class="org.eclipse.ui.tests.api.PerspectiveWithFastView"
- name="UI Test Perspective with Fast View"
- id="org.eclipse.ui.tests.fastview_perspective">
- </perspective>
- <perspective
class="org.eclipse.ui.tests.api.PerspectiveWithMultiViewPlaceholdersAtTopLevel"
name="UI Test Perspective with Multi View Placeholders At Top Level"
id="org.eclipse.ui.tests.PerspectiveWithMultiViewPlaceholdersAtTopLevel">