Skip to content

Commit 740b945

Browse files
committed
Replace property sheet tests hierarchy to UITestCase with test rule
1 parent 44bfc55 commit 740b945

File tree

6 files changed

+56
-79
lines changed

6 files changed

+56
-79
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/AbstractPropertySheetTest.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,28 @@
2525
import org.eclipse.ui.IViewReference;
2626
import org.eclipse.ui.IWorkbenchPage;
2727
import org.eclipse.ui.IWorkbenchWindow;
28-
import org.eclipse.ui.tests.harness.util.UITestCase;
28+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
2929
import org.eclipse.ui.views.properties.PropertySheet;
30+
import org.junit.Before;
31+
import org.junit.Rule;
3032

3133
/**
3234
* @since 3.4
3335
*/
34-
public abstract class AbstractPropertySheetTest extends UITestCase {
36+
public abstract class AbstractPropertySheetTest {
37+
38+
@Rule
39+
public final CloseTestWindowsRule closeTestWindowsRule = new CloseTestWindowsRule();
3540

3641
private static final String PIN_PROPERTY_SHEET_ACTION_ID_PREFIX = "org.eclipse.ui.views.properties.PinPropertySheetAction";
3742
protected IWorkbenchPage activePage;
38-
protected PropertySheet propertySheet;
39-
40-
public AbstractPropertySheetTest(String testName) {
41-
super(testName);
42-
}
4343

44-
@Override
45-
protected void doSetUp() throws Exception {
46-
super.doSetUp();
44+
@Before
45+
public final void initializeActivePage() throws Exception {
4746
IWorkbenchWindow workbenchWindow = openTestWindow();
4847
activePage = workbenchWindow.getActivePage();
4948
}
5049

51-
@Override
52-
protected void doTearDown() throws Exception {
53-
super.doTearDown();
54-
activePage = null;
55-
propertySheet = null;
56-
}
57-
5850
/**
5951
* @return the count of PropertySheets
6052
*/

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/DirtyStatePropertySheetTest.java

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

1717
import static org.eclipse.ui.internal.SaveableHelper.isDirtyStateSupported;
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertTrue;
1821

1922
import java.util.HashMap;
2023
import java.util.Map;
@@ -26,16 +29,15 @@
2629
import org.eclipse.ui.ISecondarySaveableSource;
2730
import org.eclipse.ui.views.properties.PropertySheet;
2831
import org.eclipse.ui.views.properties.PropertySheetPage;
32+
import org.junit.After;
33+
import org.junit.Before;
2934
import org.junit.Test;
30-
import org.junit.runner.RunWith;
31-
import org.junit.runners.JUnit4;
3235

3336
/**
3437
* @since 3.5
3538
*/
36-
@RunWith(JUnit4.class)
3739
public class DirtyStatePropertySheetTest extends AbstractPropertySheetTest {
38-
40+
private PropertySheet propertySheet;
3941
private AdaptingSaveableView saveableView;
4042
private ISecondarySaveableSource dirtyDisallowed;
4143
private ISecondarySaveableSource dirtyAllowed;
@@ -64,13 +66,8 @@ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
6466
}
6567
}
6668

67-
public DirtyStatePropertySheetTest() {
68-
super(DirtyStatePropertySheetTest.class.getName());
69-
}
70-
71-
@Override
72-
protected void doSetUp() throws Exception {
73-
super.doSetUp();
69+
@Before
70+
public void setUp() throws Exception {
7471
PropertySheetPerspectiveFactory.applyPerspective(activePage);
7572
dirtyDisallowed = new ISecondarySaveableSource() {
7673
};
@@ -92,11 +89,10 @@ public boolean isDirtyStateSupported() {
9289
assertFalse(propertySheet.isDirtyStateSupported());
9390
}
9491

95-
@Override
96-
protected void doTearDown() throws Exception {
92+
@After
93+
public final void tearDown() throws Exception {
9794
Platform.getAdapterManager().unregisterAdapters(adapterFactory);
9895
activePage.resetPerspective();
99-
super.doTearDown();
10096
}
10197

10298
@Test

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/MultiInstancePropertySheetTest.java

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

1717
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertNotNull;
21+
import static org.junit.Assert.assertNotSame;
22+
import static org.junit.Assert.assertNull;
23+
import static org.junit.Assert.assertTrue;
1824

1925
import java.lang.reflect.Field;
2026

@@ -48,17 +54,18 @@
4854
import org.eclipse.ui.views.properties.PropertySheetEntry;
4955
import org.eclipse.ui.views.properties.PropertySheetPage;
5056
import org.eclipse.ui.views.properties.PropertyShowInContext;
57+
import org.junit.After;
58+
import org.junit.Before;
5159
import org.junit.Test;
52-
import org.junit.runner.RunWith;
53-
import org.junit.runners.JUnit4;
5460
import org.osgi.framework.Bundle;
5561

5662
/**
5763
* @since 3.4
5864
*/
59-
@RunWith(JUnit4.class)
6065
public class MultiInstancePropertySheetTest extends AbstractPropertySheetTest {
6166

67+
private PropertySheet propertySheet;
68+
6269
/**
6370
* TestPropertySheetPage exposes certain members for testability
6471
*/
@@ -90,13 +97,8 @@ public class MultiInstancePropertySheetTest extends AbstractPropertySheetTest {
9097

9198
private IProject project;
9299

93-
public MultiInstancePropertySheetTest() {
94-
super(MultiInstancePropertySheetTest.class.getSimpleName());
95-
}
96-
97-
@Override
98-
protected void doSetUp() throws Exception {
99-
super.doSetUp();
100+
@Before
101+
public void setUp() throws Exception {
100102
testPropertySheetPage = new TestPropertySheetPage();
101103
// open the property sheet with the TestPropertySheetPage
102104
Platform.getAdapterManager().registerAdapters(testPropertySheetPage,
@@ -113,10 +115,9 @@ protected void doSetUp() throws Exception {
113115

114116

115117

116-
@Override
117-
protected void doTearDown() throws Exception {
118+
@After
119+
public final void tearDown() throws Exception {
118120
activePage.resetPerspective();
119-
super.doTearDown();
120121
// reset the exception to null
121122
e = null;
122123
// remove our log listener

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/NewPropertySheetHandlerTest.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616

1717
import static org.eclipse.ui.PlatformUI.getWorkbench;
1818
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertFalse;
21+
import static org.junit.Assert.assertNotNull;
22+
import static org.junit.Assert.assertNotSame;
23+
import static org.junit.Assert.assertNull;
1924
import static org.junit.Assert.assertThrows;
25+
import static org.junit.Assert.assertTrue;
2026

2127
import java.util.HashMap;
2228

@@ -41,25 +47,18 @@
4147
import org.eclipse.ui.tests.SelectionProviderView;
4248
import org.eclipse.ui.views.properties.PropertySheet;
4349
import org.eclipse.ui.views.properties.PropertyShowInContext;
50+
import org.junit.Before;
4451
import org.junit.Test;
45-
import org.junit.runner.RunWith;
46-
import org.junit.runners.JUnit4;
4752

4853
/**
4954
* @since 3.5
5055
*/
51-
@RunWith(JUnit4.class)
5256
public class NewPropertySheetHandlerTest extends AbstractPropertySheetTest {
5357

5458
private TestNewPropertySheetHandler testNewPropertySheetHandler;
5559

56-
public NewPropertySheetHandlerTest() {
57-
super(NewPropertySheetHandlerTest.class.getSimpleName());
58-
}
59-
60-
@Override
61-
protected void doSetUp() throws Exception {
62-
super.doSetUp();
60+
@Before
61+
public void setUp() throws Exception {
6362
testNewPropertySheetHandler = new TestNewPropertySheetHandler();
6463
}
6564

@@ -207,7 +206,7 @@ public final void testFindPropertySheetWithoutActivePart() {
207206
@Test
208207
public final void testFindPropertySheetWithOtherSheetActive()
209208
throws PartInitException, ExecutionException {
210-
propertySheet = (PropertySheet) activePage
209+
PropertySheet propertySheet = (PropertySheet) activePage
211210
.showView(IPageLayout.ID_PROP_SHEET);
212211
assertTrue(countPropertySheetViews() == 1);
213212

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertyShowInContextTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

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

17+
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.assertFalse;
19+
import static org.junit.Assert.assertTrue;
20+
1721
import org.eclipse.jface.viewers.ISelection;
1822
import org.eclipse.jface.viewers.StructuredSelection;
1923
import org.eclipse.ui.IPageLayout;
@@ -22,19 +26,12 @@
2226
import org.eclipse.ui.part.ShowInContext;
2327
import org.eclipse.ui.views.properties.PropertyShowInContext;
2428
import org.junit.Test;
25-
import org.junit.runner.RunWith;
26-
import org.junit.runners.JUnit4;
2729

2830
/**
2931
* @since 3.5
3032
*/
31-
@RunWith(JUnit4.class)
3233
public class PropertyShowInContextTest extends AbstractPropertySheetTest {
3334

34-
public PropertyShowInContextTest() {
35-
super(PropertyShowInContextTest.class.getSimpleName());
36-
}
37-
3835
/**
3936
* Test method for
4037
* {@link org.eclipse.ui.views.properties.PropertyShowInContext#hashCode()}.

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/ShowInPropertySheetTest.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,29 @@
1414

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

17+
import static org.junit.Assert.assertFalse;
18+
import static org.junit.Assert.assertNotNull;
19+
import static org.junit.Assert.assertTrue;
20+
1721
import org.eclipse.jface.viewers.StructuredSelection;
1822
import org.eclipse.ui.IPageLayout;
1923
import org.eclipse.ui.part.IShowInTarget;
2024
import org.eclipse.ui.part.ShowInContext;
2125
import org.eclipse.ui.views.properties.PropertySheet;
2226
import org.eclipse.ui.views.properties.PropertyShowInContext;
27+
import org.junit.Before;
2328
import org.junit.Test;
24-
import org.junit.runner.RunWith;
25-
import org.junit.runners.JUnit4;
2629

2730
/**
2831
* @since 3.4
2932
*/
30-
@RunWith(JUnit4.class)
3133
public class ShowInPropertySheetTest extends AbstractPropertySheetTest {
3234

33-
public ShowInPropertySheetTest() {
34-
super(ShowInPropertySheetTest.class.getSimpleName());
35-
}
36-
37-
@Override
38-
protected void doSetUp() throws Exception {
39-
super.doSetUp();
40-
41-
propertySheet = (PropertySheet) activePage
42-
.showView(IPageLayout.ID_PROP_SHEET);
43-
}
35+
private PropertySheet propertySheet;
4436

45-
@Override
46-
protected void doTearDown() throws Exception {
47-
super.doTearDown();
37+
@Before
38+
public final void setUp() throws Exception {
39+
propertySheet = (PropertySheet) activePage.showView(IPageLayout.ID_PROP_SHEET);
4840
}
4941

5042
/**

0 commit comments

Comments
 (0)