Skip to content

Commit d0e2112

Browse files
committed
Centralize test project access for UI performance tests in test rule
Currently, the test project access in projects is scattered across multiple places. This centralizes the access at the UIPerformanceTestRule, which is responsible with creating and deleting the project anyway.
1 parent 0073270 commit d0e2112

File tree

6 files changed

+15
-23
lines changed

6 files changed

+15
-23
lines changed

tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/BasicPerformanceTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
package org.eclipse.ui.tests.performance;
1616

17-
import org.eclipse.core.resources.IProject;
18-
import org.eclipse.core.resources.IWorkspace;
19-
import org.eclipse.core.resources.ResourcesPlugin;
2017
import org.eclipse.core.runtime.CoreException;
2118
import org.eclipse.core.runtime.IProgressMonitor;
2219
import org.eclipse.core.runtime.IStatus;
@@ -49,8 +46,6 @@ public abstract class BasicPerformanceTest extends PerformanceTestCaseJunit4 {
4946
@Rule
5047
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
5148

52-
private IProject testProject;
53-
5449
final private boolean tagAsGlobalSummary;
5550

5651
final private boolean tagAsSummary;
@@ -88,15 +83,6 @@ private boolean shouldLocallyTag() {
8883
return tagAsSummary;
8984
}
9085

91-
protected IProject getProject() {
92-
if (testProject == null) {
93-
IWorkspace workspace = ResourcesPlugin.getWorkspace();
94-
testProject = workspace.getRoot().getProject(
95-
UIPerformanceTestRule.PROJECT_NAME);
96-
}
97-
return testProject;
98-
}
99-
10086
public void tagIfNecessary(String shortName, Dimension dimension) {
10187
if (shouldGloballyTag()) {
10288
tagAsGlobalSummary(shortName, dimension);

tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/EditorSwitchTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
1717
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
18+
import static org.eclipse.ui.tests.performance.UIPerformanceTestRule.getTestProject;
1819
import static org.junit.Assert.assertTrue;
1920

2021
import java.util.Arrays;
@@ -67,9 +68,9 @@ public void test() throws CoreException {
6768
// the initial time to open, just switching.
6869
IWorkbenchWindow window = openTestWindow(UIPerformanceTestRule.PERSPECTIVE1);
6970
final IWorkbenchPage activePage = window.getActivePage();
70-
final IFile file1 = getProject().getFile("1." + extension1);
71+
final IFile file1 = getTestProject().getFile("1." + extension1);
7172
assertTrue(file1.exists());
72-
final IFile file2 = getProject().getFile("1." + extension2);
73+
final IFile file2 = getTestProject().getFile("1." + extension2);
7374
assertTrue(file2.exists());
7475
IDE.openEditor(activePage, file1, true);
7576
IDE.openEditor(activePage, file2, true);

tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenCloseEditorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
1818
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
19+
import static org.eclipse.ui.tests.performance.UIPerformanceTestRule.getTestProject;
1920
import static org.junit.Assert.assertTrue;
2021

2122
import java.util.Arrays;
@@ -56,7 +57,7 @@ public OpenCloseEditorTest(String extension, int tagging) {
5657

5758
@Test
5859
public void test() throws Throwable {
59-
final IFile file = getProject().getFile("1." + extension);
60+
final IFile file = getTestProject().getFile("1." + extension);
6061
assertTrue(file.exists());
6162

6263
IWorkbenchWindow window = openTestWindow(UIPerformanceTestRule.PERSPECTIVE1);

tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/OpenMultipleEditorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
1818
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
19+
import static org.eclipse.ui.tests.performance.UIPerformanceTestRule.getTestProject;
1920

2021
import java.util.Arrays;
2122
import java.util.Collection;
@@ -65,7 +66,7 @@ public void test() throws Throwable {
6566
startMeasuring();
6667

6768
for (int i = 0; i < 100; i++) {
68-
IFile file = getProject().getFile(i + "." + extension);
69+
IFile file = getTestProject().getFile(i + "." + extension);
6970
IDE.openEditor(activePage, file, true);
7071
processEvents();
7172
}

tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/PerspectiveSwitchTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
1717
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
18+
import static org.eclipse.ui.tests.performance.UIPerformanceTestRule.getTestProject;
1819
import static org.junit.Assert.assertNotNull;
1920
import static org.junit.Assert.assertTrue;
2021

@@ -106,7 +107,7 @@ public void test() throws CoreException, WorkbenchException {
106107

107108
// IFile aFile = getProject().getFile("1." +
108109
// EditorPerformanceSuite.EDITOR_FILE_EXTENSIONS[0]);
109-
IFile aFile = getProject().getFile(activeEditor);
110+
IFile aFile = getTestProject().getFile(activeEditor);
110111
assertTrue(aFile.exists());
111112

112113
IDE.openEditor(page, aFile, true);

tests/org.eclipse.ui.tests.performance/src/org/eclipse/ui/tests/performance/UIPerformanceTestRule.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import org.eclipse.core.resources.IFile;
1919
import org.eclipse.core.resources.IProject;
20-
import org.eclipse.core.resources.IWorkspace;
2120
import org.eclipse.core.resources.ResourcesPlugin;
2221
import org.eclipse.core.runtime.CoreException;
2322
import org.eclipse.ui.IWorkbench;
@@ -57,16 +56,19 @@ protected void before() throws Throwable {
5756
@Override
5857
protected void after() {
5958
try {
60-
ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME).delete(true, null);
59+
getTestProject().delete(true, null);
6160
} catch (CoreException e) {
6261
e.printStackTrace();
6362
}
6463
}
6564

65+
public static IProject getTestProject() {
66+
return ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
67+
}
68+
6669
private static void setUpProject() throws CoreException {
6770
// Create a java project.
68-
IWorkspace workspace = ResourcesPlugin.getWorkspace();
69-
IProject testProject = workspace.getRoot().getProject(PROJECT_NAME);
71+
IProject testProject = getTestProject();
7072
testProject.create(null);
7173
testProject.open(null);
7274

0 commit comments

Comments
 (0)