diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseViewTest.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseViewTest.java index a66faaf0498..9f1d20e002c 100644 --- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseViewTest.java +++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseViewTest.java @@ -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 @@ -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 data() { - return ViewPerformanceUtil.getAllTestableViewIds().stream().map(id -> new Object[] { id }).toList(); + static Stream 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(); diff --git a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ViewPerformanceUtil.java b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ViewPerformanceUtil.java index ebf55335f27..5da8878eb2d 100644 --- a/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ViewPerformanceUtil.java +++ b/tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/ViewPerformanceUtil.java @@ -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 @@ -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; /** @@ -27,7 +29,7 @@ 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"; @@ -35,23 +37,20 @@ private ViewPerformanceUtil() { } public static Collection getAllTestableViewIds() { - HashSet result = new HashSet<>(); - - IViewDescriptor[] descriptors = PlatformUI.getWorkbench().getViewRegistry().getViews(); - for (IViewDescriptor descriptor : descriptors) { - String[] categoryPath = descriptor.getCategoryPath(); - if (categoryPath == null) + Set 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; } }