Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others.
* Copyright (c) 2004, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -17,49 +17,37 @@
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
import static org.eclipse.ui.tests.performance.UIPerformanceTestUtil.waitForBackgroundJobs;

import java.util.Collection;
import java.util.stream.Stream;

import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCaseJunit4;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

/**
* Performance tests for showing views.
* There are separate tests for showing a simple view (MockViewPart)
* and a more complex view (Resource Navigator).
* The views are shown in an empty perspective.
* Performance tests for opening and closing the basic workbench views. The
* views are shown in an empty perspective.
*/
@RunWith(Parameterized.class)
public class OpenCloseViewTest extends PerformanceTestCaseJunit4 {
class OpenCloseViewTest extends PerformanceTestCaseJunit5 {

@ClassRule
public static final UIPerformanceTestRule uiPerformanceTestRule = new UIPerformanceTestRule();
@RegisterExtension
static UIPerformanceTestRule uiPerformanceTestRule = new UIPerformanceTestRule();

@Rule
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
@RegisterExtension
CloseTestWindowsExtension closeTestWindows = new CloseTestWindowsExtension();

@Parameters(name = "{index}: {0}")
public static Collection<Object[]> data() {
return ViewPerformanceUtil.getAllTestableViewIds().stream().map(id -> new Object[] { id }).toList();
static Stream<String> data() {
return ViewPerformanceUtil.getAllTestableViewIds().stream();
}

private final String viewId;

public OpenCloseViewTest(String viewId) {
this.viewId = viewId;
}

@Test
public void test() throws Throwable {
@ParameterizedTest(name = "{0}")
@MethodSource("data")
void test(String viewId) throws Throwable {
IWorkbenchWindow window = openTestWindow();
final IWorkbenchPage page = window.getActivePage();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2017 IBM Corporation and others.
* Copyright (c) 2004, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -15,9 +15,11 @@
package org.eclipse.ui.tests.performance;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.IViewCategory;
import org.eclipse.ui.views.IViewDescriptor;

/**
Expand All @@ -27,31 +29,28 @@ public final class ViewPerformanceUtil {

public static final String PROJECT_EXPLORER = "org.eclipse.ui.navigator.ProjectExplorer";

private static final String BASIC_PATH = "org.eclipse.ui";
private static final String BASIC_CATEGORY = "org.eclipse.ui";

private static final String VIEWS_PATTERN = "org.eclipse.ui.views";

private ViewPerformanceUtil() {
}

public static Collection<String> getAllTestableViewIds() {
HashSet<String> result = new HashSet<>();

IViewDescriptor[] descriptors = PlatformUI.getWorkbench().getViewRegistry().getViews();
for (IViewDescriptor descriptor : descriptors) {
String[] categoryPath = descriptor.getCategoryPath();
if (categoryPath == null)
Set<String> result = new TreeSet<>();
// match by category id; in e4, getCategoryPath() contains the category label
for (IViewCategory category : PlatformUI.getWorkbench().getViewRegistry().getCategories()) {
// only test basic views
if (!BASIC_CATEGORY.equals(category.getId())) {
continue;
for (String categoryPath1 : categoryPath) {
// Only test basic views
if (categoryPath1.equals(BASIC_PATH)) {
if (descriptor.getId().contains(VIEWS_PATTERN) || descriptor.getId().equals(PROJECT_EXPLORER)) {
result.add(descriptor.getId());
}
}
for (IViewDescriptor descriptor : category.getViews()) {
String id = descriptor.getId();
if (id.contains(VIEWS_PATTERN) || id.equals(PROJECT_EXPLORER)) {
result.add(id);
}
}
}

return result;
}
}
Loading