Skip to content

Commit 2bc4843

Browse files
committed
Replace UITestCase hierarchy with test rule in internal UI tests
1 parent 740b945 commit 2bc4843

18 files changed

+146
-172
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/ActionExpressionTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@
2222
import org.eclipse.ui.IWorkbenchWindow;
2323
import org.eclipse.ui.tests.api.ListElement;
2424
import org.eclipse.ui.tests.api.ListView;
25-
import org.eclipse.ui.tests.harness.util.UITestCase;
25+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
26+
import org.junit.Before;
27+
import org.junit.Rule;
2628
import org.junit.Test;
2729

2830
/**
2931
* This class contains tests for popup menu enablement
3032
*/
31-
public abstract class ActionExpressionTest extends UITestCase {
33+
public abstract class ActionExpressionTest {
34+
35+
@Rule
36+
public final CloseTestWindowsRule closeTestWindowsRule = new CloseTestWindowsRule();
37+
3238
protected IWorkbenchWindow fWindow;
3339

3440
protected IWorkbenchPage fPage;
@@ -41,13 +47,8 @@ public abstract class ActionExpressionTest extends UITestCase {
4147

4248
ListElement redTrue = new ListElement("red", true);
4349

44-
public ActionExpressionTest(String testName) {
45-
super(testName);
46-
}
47-
48-
@Override
49-
protected void doSetUp() throws Exception {
50-
super.doSetUp();
50+
@Before
51+
public final void setUp() throws Exception {
5152
fWindow = openTestWindow();
5253
fPage = fWindow.getActivePage();
5354
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/ActionSetExpressionTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,21 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.tests.internal;
1515

16+
import static org.junit.Assert.assertEquals;
17+
import static org.junit.Assert.fail;
18+
1619
import org.eclipse.jface.action.IContributionItem;
1720
import org.eclipse.jface.action.MenuManager;
1821
import org.eclipse.jface.action.SubContributionItem;
1922
import org.eclipse.ui.internal.WorkbenchWindow;
2023
import org.eclipse.ui.tests.api.ListView;
2124
import org.eclipse.ui.tests.harness.util.ActionUtil;
22-
import org.junit.runner.RunWith;
23-
import org.junit.runners.JUnit4;
2425

2526
/**
2627
* This class contains tests for action set enablement
2728
*/
28-
@RunWith(JUnit4.class)
2929
public class ActionSetExpressionTest extends ActionExpressionTest {
3030

31-
public ActionSetExpressionTest() {
32-
super(ActionSetExpressionTest.class.getSimpleName());
33-
}
34-
3531
/**
3632
* Opens the action set. Returns the menu manager containing it.
3733
*/

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug549139Test.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ public String getLastValidatedResourceName() {
7171

7272
private IProject testProject;
7373

74-
public Bug549139Test() {
75-
super();
76-
}
77-
7874
@Before
7975
public void setUp2() throws Exception {
8076
testProject = createTestProject(getName());

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug99858Test.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
*/
3939
public class Bug99858Test extends ResourceActionTest {
4040

41-
public Bug99858Test() {
42-
super();
43-
}
44-
4541
/**
4642
* Create a project with some files, close it, and delete it. With the
4743
* changes in runtime to throw a CoreException from IContainer#members(),

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/EditorActionBarsTest.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
package org.eclipse.ui.tests.internal;
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
17+
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.assertTrue;
19+
import static org.junit.Assert.fail;
1720

1821
import org.eclipse.core.resources.IFile;
1922
import org.eclipse.core.resources.IProject;
@@ -37,37 +40,31 @@
3740
import org.eclipse.ui.tests.api.MockEditorActionBarContributor;
3841
import org.eclipse.ui.tests.api.MockEditorPart;
3942
import org.eclipse.ui.tests.api.MockViewPart;
43+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
4044
import org.eclipse.ui.tests.harness.util.FileUtil;
41-
import org.eclipse.ui.tests.harness.util.UITestCase;
45+
import org.junit.Before;
4246
import org.junit.Ignore;
47+
import org.junit.Rule;
4348
import org.junit.Test;
44-
import org.junit.runner.RunWith;
45-
import org.junit.runners.JUnit4;
4649

4750
/**
4851
* This class contains tests for the editor action bars
4952
* implementation.
5053
*/
51-
@RunWith(JUnit4.class)
5254
@Ignore
53-
public class EditorActionBarsTest extends UITestCase {
55+
public class EditorActionBarsTest {
56+
57+
@Rule
58+
public final CloseTestWindowsRule closeTestWindowsRule = new CloseTestWindowsRule();
5459

5560
protected IWorkbenchWindow fWindow;
5661

5762
protected IWorkbenchPage fPage;
5863

5964
private final String EDITOR_ID = "org.eclipse.ui.tests.internal.EditorActionBarsTest";
6065

61-
/**
62-
* Constructor for IEditorPartTest
63-
*/
64-
public EditorActionBarsTest() {
65-
super(EditorActionBarsTest.class.getSimpleName());
66-
}
67-
68-
@Override
69-
protected void doSetUp() throws Exception {
70-
super.doSetUp();
66+
@Before
67+
public final void setUp() throws Exception {
7168
fWindow = openTestWindow();
7269
fPage = fWindow.getActivePage();
7370
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/FileEditorMappingTest.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,33 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.tests.internal;
1515

16+
import static org.junit.Assert.assertEquals;
17+
import static org.junit.Assert.assertFalse;
18+
1619
import java.util.ArrayList;
1720
import java.util.List;
1821

1922
import org.eclipse.ui.IEditorDescriptor;
2023
import org.eclipse.ui.ide.IDE;
2124
import org.eclipse.ui.internal.registry.EditorDescriptor;
2225
import org.eclipse.ui.internal.registry.FileEditorMapping;
23-
import org.eclipse.ui.tests.harness.util.UITestCase;
26+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
27+
import org.junit.Before;
2428
import org.junit.Ignore;
29+
import org.junit.Rule;
2530
import org.junit.Test;
26-
import org.junit.runner.RunWith;
27-
import org.junit.runners.JUnit4;
2831

29-
@RunWith(JUnit4.class)
3032
@Ignore
31-
public class FileEditorMappingTest extends UITestCase {
33+
public class FileEditorMappingTest {
34+
35+
@Rule
36+
public final CloseTestWindowsRule closeTestWindowsRule = new CloseTestWindowsRule();
3237

3338
private EditorDescriptor textEditor;
3439
private EditorDescriptor pdeEditor;
3540

36-
public FileEditorMappingTest() {
37-
super(FileEditorMappingTest.class.getSimpleName());
38-
}
39-
40-
@Override
41-
protected void doSetUp() throws Exception {
42-
super.doSetUp();
43-
41+
@Before
42+
public final void setUp() throws Exception {
4443
textEditor = (EditorDescriptor) IDE.getEditorDescriptor("test.txt");
4544
pdeEditor = (EditorDescriptor) IDE.getEditorDescriptor("plugin.xml");
4645
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/PerspectiveSwitcherTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,25 @@
1515
package org.eclipse.ui.tests.internal;
1616

1717
import static org.eclipse.ui.PlatformUI.getWorkbench;
18+
import static org.junit.Assert.assertNotNull;
1819

1920
import org.eclipse.e4.ui.workbench.modeling.EModelService;
2021
import org.eclipse.jface.preference.IPreferenceStore;
2122
import org.eclipse.ui.IWorkbenchPreferenceConstants;
2223
import org.eclipse.ui.internal.WorkbenchWindow;
2324
import org.eclipse.ui.internal.util.PrefUtil;
25+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
2426
import org.eclipse.ui.tests.harness.util.PreferenceMementoRule;
25-
import org.eclipse.ui.tests.harness.util.UITestCase;
2627
import org.junit.Rule;
2728
import org.junit.Test;
28-
import org.junit.runner.RunWith;
29-
import org.junit.runners.JUnit4;
3029

31-
@RunWith(JUnit4.class)
32-
public class PerspectiveSwitcherTest extends UITestCase {
30+
public class PerspectiveSwitcherTest {
3331

3432
@Rule
35-
public final PreferenceMementoRule preferenceMemento = new PreferenceMementoRule();
33+
public final CloseTestWindowsRule closeTestWindowsRule = new CloseTestWindowsRule();
3634

37-
public PerspectiveSwitcherTest() {
38-
super(PerspectiveSwitcherTest.class.getSimpleName());
39-
}
35+
@Rule
36+
public final PreferenceMementoRule preferenceMemento = new PreferenceMementoRule();
4037

4138
/**
4239
* This test ensures that our workbench window's perspective bar can opened if

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/PopupMenuExpressionTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,19 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.tests.internal;
1515

16+
import static org.junit.Assert.assertNotNull;
17+
import static org.junit.Assert.assertNull;
18+
1619
import org.eclipse.jface.action.MenuManager;
1720
import org.eclipse.ui.tests.api.ListView;
1821
import org.eclipse.ui.tests.harness.util.ActionUtil;
1922
import org.junit.Test;
20-
import org.junit.runner.RunWith;
21-
import org.junit.runners.JUnit4;
2223

2324
/**
2425
* This class contains tests for popup menu visibility
2526
*/
26-
@RunWith(JUnit4.class)
2727
public class PopupMenuExpressionTest extends ActionExpressionTest {
2828

29-
public PopupMenuExpressionTest() {
30-
super(PopupMenuExpressionTest.class.getSimpleName());
31-
}
32-
3329
/**
3430
* Returns the menu manager containing the actions.
3531
*/

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/ResourceActionTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
*/
1515
public abstract class ResourceActionTest {
1616

17-
public ResourceActionTest() {
18-
super();
19-
}
20-
2117
@Before
2218
public void setUp() throws Exception {
2319
AdvancedValidationUserApprover.AUTOMATED_MODE = true;

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SWTBotWorkbenchResetTest.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
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.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertNotNull;
21+
import static org.junit.Assert.assertTrue;
1922

2023
import org.eclipse.core.runtime.CoreException;
2124
import org.eclipse.swt.widgets.Composite;
@@ -25,23 +28,17 @@
2528
import org.eclipse.ui.IWorkbenchWindow;
2629
import org.eclipse.ui.WorkbenchException;
2730
import org.eclipse.ui.ide.IDE;
28-
import org.eclipse.ui.tests.harness.util.UITestCase;
31+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
32+
import org.junit.Rule;
2933
import org.junit.Test;
30-
import org.junit.runner.RunWith;
31-
import org.junit.runners.JUnit4;
3234

3335
/**
3436
* Test for Bug 511729 — Improve robustness to SWTBot.resetWorkbench()
3537
*/
36-
@RunWith(JUnit4.class)
37-
public class SWTBotWorkbenchResetTest extends UITestCase {
38+
public class SWTBotWorkbenchResetTest {
3839

39-
/**
40-
* Constructs a new instance of this test case.
41-
*/
42-
public SWTBotWorkbenchResetTest() {
43-
super(SWTBotWorkbenchResetTest.class.getSimpleName());
44-
}
40+
@Rule
41+
public final CloseTestWindowsRule closeTestWindowsRule = new CloseTestWindowsRule();
4542

4643
/**
4744
* Open a new window, switch to a different perspective such that parts are

0 commit comments

Comments
 (0)