Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2020-03-24 13:40:57 +0000
committerAlexander Kurtakov2020-03-25 18:42:55 +0000
commit151264c783819749bf5583ca85a09eb8988eb367 (patch)
treeb707325b9059cfe88163b7130e9fae9cbd4c3bb8
parent100d6c323931045fbd7eeb362fb0e75b6fa1dbe8 (diff)
downloadeclipse.platform.ui-151264c783819749bf5583ca85a09eb8988eb367.tar.gz
eclipse.platform.ui-151264c783819749bf5583ca85a09eb8988eb367.tar.xz
eclipse.platform.ui-151264c783819749bf5583ca85a09eb8988eb367.zip
Bug 553836 - [Tests] Remove UITestCase dependency on TestCaseI20200325-1800
As a preliminary step make tests direct POJOs. Change-Id: I9e4db38d9c1ee3b6e5dbebca363173dd57f6fa37 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivityPreferenceTest.java15
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java18
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/adaptable/AdaptableDecoratorTestCase.java31
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java21
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug42616Test.java13
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DeprecatedSessionRestoreTest.java17
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java25
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/Bug543609Test.java20
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/DependencyInjectionViewTest.java14
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java21
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug125792Test.java15
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java19
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug66182Test.java22
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug70503Test.java16
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug73756Test.java34
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74982Test.java24
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74990Test.java56
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug87856Test.java38
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandActionTest.java36
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java56
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandExecutionTest.java129
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandManagerTest.java56
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java26
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandSerializationTest.java23
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java54
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug84763Test.java26
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorAdaptableTests.java24
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/AnimationEngineTest.java29
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug41931Test.java16
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug540297WorkbenchPageFindViewTest.java41
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug78470Test.java17
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingInteractionsTest.java27
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingManagerTest.java40
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java42
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36420Test.java18
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36537Test.java16
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug40023Test.java16
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42024Test.java32
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java15
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42627Test.java18
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43168Test.java13
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43321Test.java16
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43538Test.java15
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43597Test.java21
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43610Test.java15
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java21
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug44460Test.java22
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug53489Test.java54
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/DispatcherTest.java25
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug231304Test.java22
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java19
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug410426Test.java17
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multieditor/AbstractMultiEditorTest.java22
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DeprecatedFontPreferenceTestCase.java85
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DialogSettingsCustomizationTest.java33
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/AccumulatingProgressMonitorTest.java13
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/quickaccess/ContentMatchesTest.java27
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/ContributedServiceTest.java101
58 files changed, 630 insertions, 1087 deletions
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivityPreferenceTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivityPreferenceTest.java
index fb3b727a146..8402ef6e109 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivityPreferenceTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivityPreferenceTest.java
@@ -14,12 +14,14 @@
package org.eclipse.ui.tests.activities;
+import static org.junit.Assert.assertEquals;
+
import java.util.Collections;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.IActivityManager;
import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -28,7 +30,7 @@ import org.junit.runners.JUnit4;
* @since 3.1
*/
@RunWith(JUnit4.class)
-public class ActivityPreferenceTest extends UITestCase {
+public class ActivityPreferenceTest {
/**
* Preference prefix - must match the one specified in ActivityPreferenceHelper
*/
@@ -38,22 +40,19 @@ public class ActivityPreferenceTest extends UITestCase {
*/
private static String ID = "org.eclipse.ui.PT.A2"; //$NON-NLS-1$
- public ActivityPreferenceTest() {
- super(ActivityPreferenceTest.class.getSimpleName());
- }
-
/**
* Tests whether activity preferences are persisted as soon as the activity set changes.
*/
@Test
public void testActivityPreference() {
- IActivityManager manager = fWorkbench.getActivitySupport().getActivityManager();
+ IActivityManager manager = PlatformUI.getWorkbench().getActivitySupport().getActivityManager();
boolean initialState = manager.getEnabledActivityIds().contains(ID);
IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
assertEquals(initialState, store.getBoolean(PREFIX + ID));
- fWorkbench.getActivitySupport().setEnabledActivityIds(initialState ? Collections.EMPTY_SET : Collections.singleton(ID));
+ PlatformUI.getWorkbench().getActivitySupport()
+ .setEnabledActivityIds(initialState ? Collections.emptySet() : Collections.singleton(ID));
assertEquals(!initialState, store.getBoolean(PREFIX + ID));
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java
index a2bc3b9955f..5243f12f653 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java
@@ -13,6 +13,11 @@
*******************************************************************************/
package org.eclipse.ui.tests.activities;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
@@ -36,18 +41,15 @@ import org.eclipse.ui.activities.NotDefinedException;
import org.eclipse.ui.activities.WorkbenchTriggerPointAdvisor;
import org.eclipse.ui.internal.activities.MutableActivityManager;
import org.eclipse.ui.tests.TestPlugin;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
*
* The dynamic test manipualtes the categories, activities and their definitions
* and ensures that their content and their listeners are behaving properly.
*/
-@RunWith(JUnit4.class)
-public class DynamicTest extends UITestCase {
+public class DynamicTest {
private MutableActivityManager activityManager;
private DynamicModelActivityRegistry fixedModelRegistry;
@@ -78,8 +80,8 @@ public class DynamicTest extends UITestCase {
static final int DEFAULT_ENABLED_CHANGED = 11;
- public DynamicTest() {
- super(DynamicTest.class.getSimpleName());
+ @Before
+ public void init() {
fixedModelRegistry = new DynamicModelActivityRegistry();
activityManager = new MutableActivityManager(new WorkbenchTriggerPointAdvisor(), fixedModelRegistry);
listenerType = -1;
@@ -496,7 +498,7 @@ public class DynamicTest extends UITestCase {
try {
assertTrue(activity.isDefaultEnabled());
} catch (NotDefinedException e) {
- fail(e.getMessage(), e);
+ fail(e.getMessage());
}
Set<IActivityRequirementBinding> requirementBindings = activity.getActivityRequirementBindings();
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/adaptable/AdaptableDecoratorTestCase.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/adaptable/AdaptableDecoratorTestCase.java
index db12fb8c56b..0e1a01f1e77 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/adaptable/AdaptableDecoratorTestCase.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/adaptable/AdaptableDecoratorTestCase.java
@@ -14,6 +14,9 @@
*******************************************************************************/
package org.eclipse.ui.tests.adaptable;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import org.eclipse.core.resources.IFile;
@@ -30,16 +33,14 @@ import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.decorators.DecoratorDefinition;
import org.eclipse.ui.internal.decorators.DecoratorManager;
import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @version 1.0
*/
-@RunWith(JUnit4.class)
-public class AdaptableDecoratorTestCase extends UITestCase implements
- ILabelProviderListener {
+public class AdaptableDecoratorTestCase implements ILabelProviderListener {
private DecoratorDefinition fullDefinition;
@@ -55,13 +56,8 @@ public class AdaptableDecoratorTestCase extends UITestCase implements
protected IFile testFile;
- public AdaptableDecoratorTestCase() {
- super(AdaptableDecoratorTestCase.class.getSimpleName());
- }
-
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
+ @Before
+ public void doSetUp() throws Exception {
createTestFile();
showAdaptedNav();
@@ -85,9 +81,8 @@ public class AdaptableDecoratorTestCase extends UITestCase implements
return WorkbenchPlugin.getDefault().getDecoratorManager();
}
- @Override
- protected void doTearDown() throws Exception {
-
+ @After
+ public void doTearDown() throws Exception {
if (testProject != null) {
try {
testProject.delete(true, null);
@@ -98,7 +93,6 @@ public class AdaptableDecoratorTestCase extends UITestCase implements
testFolder = null;
testFile = null;
}
- super.doTearDown();
getDecoratorManager().removeListener(this);
}
@@ -131,7 +125,6 @@ public class AdaptableDecoratorTestCase extends UITestCase implements
*/
@Test
public void testRefreshFullContributor() {
-
updated = false;
getDecoratorManager().updateForEnablementChange();
fullDefinition.setEnabled(true);
@@ -139,7 +132,6 @@ public class AdaptableDecoratorTestCase extends UITestCase implements
getDecoratorManager().updateForEnablementChange();
assertTrue("Got an update", updated);
updated = false;
-
}
/**
@@ -147,7 +139,6 @@ public class AdaptableDecoratorTestCase extends UITestCase implements
*/
@Test
public void testRefreshLightContributor() {
-
updated = false;
getDecoratorManager().updateForEnablementChange();
lightDefinition.setEnabled(true);
@@ -167,7 +158,7 @@ public class AdaptableDecoratorTestCase extends UITestCase implements
* Shows the Adapted Resource Navigator in a new test window.
*/
protected void showAdaptedNav() throws PartInitException {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
window.getActivePage().showView(ADAPTED_NAVIGATOR_ID);
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java
index 26c39cef37c..bd8df38b24c 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.api;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.List;
@@ -31,23 +33,15 @@ import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.tests.harness.util.FileUtil;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @since 3.5
- *
*/
-@RunWith(JUnit4.class)
-public class Bug407422Test extends UITestCase {
-
- public Bug407422Test() {
- super(Bug407422Test.class.getName());
- }
+public class Bug407422Test {
@Test
public void test() throws CoreException {
- final IWorkbenchWindow window = openTestWindow();
+ final IWorkbenchWindow window = UITestCase.openTestWindow();
final IWorkbenchPage page = window.getActivePage();
final String EDITOR_ID = "org.eclipse.ui.DefaultTextEditor";
@@ -119,12 +113,5 @@ public class Bug407422Test extends UITestCase {
// In bug 407422, the actual returned array has length 2,
// one editor part for each of the lazily loaded editors.
assertEquals(0, editorParts.length);
-
-
-
-
-
-
}
-
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug42616Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug42616Test.java
index 8fd463bb0f6..2b47df878e4 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug42616Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug42616Test.java
@@ -13,12 +13,12 @@
*******************************************************************************/
package org.eclipse.ui.tests.api;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test to ensure that <code>WorkbenchPlugin.createExtension()</code> will only
@@ -27,12 +27,7 @@ import org.junit.runners.JUnit4;
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug42616Test extends UITestCase {
-
- public Bug42616Test() {
- super(Bug42616Test.class.getSimpleName());
- }
+public class Bug42616Test {
@Test
public void testErrorCondition() {
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DeprecatedSessionRestoreTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DeprecatedSessionRestoreTest.java
index 6e44df2d45c..7409a1155b1 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DeprecatedSessionRestoreTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DeprecatedSessionRestoreTest.java
@@ -13,6 +13,10 @@
*******************************************************************************/
package org.eclipse.ui.tests.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -21,23 +25,16 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.tests.harness.util.EmptyPerspective;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* SessionRestoreTest runs the second half of our session
* presistance tests.
*
*/
-@RunWith(JUnit4.class)
-public class DeprecatedSessionRestoreTest extends UITestCase {
-
- public DeprecatedSessionRestoreTest() {
- super(DeprecatedSessionRestoreTest.class.getSimpleName());
- }
+public class DeprecatedSessionRestoreTest {
/**
* Generates a session state in the workbench.
@@ -48,7 +45,7 @@ public class DeprecatedSessionRestoreTest extends UITestCase {
IWorkbenchPage[] pages;
// Get windows.
- windows = fWorkbench.getWorkbenchWindows();
+ windows = PlatformUI.getWorkbench().getWorkbenchWindows();
assertEquals(windows.length, 3);
// First window contains empty perspective.
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java
index 46a53dfa7f0..f04de9c48c9 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ui.tests.api.workbenchpart;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
@@ -26,15 +29,13 @@ import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class ArbitraryPropertyTest extends UITestCase {
+public class ArbitraryPropertyTest {
/**
*
*/
@@ -47,26 +48,16 @@ public class ArbitraryPropertyTest extends UITestCase {
static final String VIEW_ID = "org.eclipse.ui.tests.workbenchpart.OverriddenTitleView";
- public ArbitraryPropertyTest() {
- super(ArbitraryPropertyTest.class.getSimpleName());
- }
-
IWorkbenchWindow window;
IWorkbenchPage page;
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
- window = openTestWindow();
+ @Before
+ public void doSetUp() throws Exception {
+ window = UITestCase.openTestWindow();
page = window.getActivePage();
}
- @Override
- protected void doTearDown() throws Exception {
- super.doTearDown();
- }
-
static class PropListener implements IPropertyChangeListener {
String firedProp = null;
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/Bug543609Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/Bug543609Test.java
index 1e6272ad94e..3bc8952cc66 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/Bug543609Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/Bug543609Test.java
@@ -13,29 +13,25 @@
*******************************************************************************/
package org.eclipse.ui.tests.api.workbenchpart;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.eclipse.ui.tests.session.ViewWithState;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-@RunWith(JUnit4.class)
-public class Bug543609Test extends UITestCase {
+public class Bug543609Test {
private static final String VIEW_WITH_STATE_ID = "org.eclipse.ui.tests.session.ViewWithState";
private IWorkbenchPage fPage;
- public Bug543609Test() {
- super(Bug543609Test.class.getSimpleName());
- }
-
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
- IWorkbenchWindow window = openTestWindow();
+ @Before
+ public void doSetUp() throws Exception {
+ IWorkbenchWindow window = UITestCase.openTestWindow();
fPage = window.getActivePage();
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/DependencyInjectionViewTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/DependencyInjectionViewTest.java
index a218e430d4f..f0c623e725d 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/DependencyInjectionViewTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/DependencyInjectionViewTest.java
@@ -15,6 +15,9 @@
package org.eclipse.ui.tests.api.workbenchpart;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.List;
@@ -31,18 +34,13 @@ import org.junit.runners.JUnit4;
/**
* @since 3.4
- *
*/
@RunWith(JUnit4.class)
-public class DependencyInjectionViewTest extends UITestCase {
-
- public DependencyInjectionViewTest() {
- super(DependencyInjectionViewTest.class.getSimpleName());
- }
+public class DependencyInjectionViewTest {
@Test
public void testDependencyInjectionLifecycle() throws Exception {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
IWorkbenchPage page = window.getActivePage();
IViewPart v = page.showView(DependencyInjectionView.ID);
assertTrue(v instanceof DependencyInjectionView);
@@ -69,7 +67,7 @@ public class DependencyInjectionViewTest extends UITestCase {
assertEquals(expectedDisposeCallOrder, view.disposeCallOrder);
- processEvents();
+ UITestCase.processEvents();
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java
index c6460399be8..7d67844fae8 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java
@@ -14,6 +14,13 @@
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -41,7 +48,7 @@ import org.junit.runners.JUnit4;
*/
@RunWith(JUnit4.class)
@Ignore("broke during e4 transition and still need adjustments")
-public class ActionDelegateProxyTest extends UITestCase {
+public class ActionDelegateProxyTest {
/**
*
*/
@@ -52,13 +59,9 @@ public class ActionDelegateProxyTest extends UITestCase {
private static final String GO_COMMAND = "org.eclipse.ui.tests.simplyGo";
private static final String STAY_COMMAND = "org.eclipse.ui.tests.simplyStay";
- public ActionDelegateProxyTest() {
- super(ActionDelegateProxyTest.class.getSimpleName());
- }
-
@Test
public void testViewDelegate() throws Exception {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
IWorkbenchPage page = window.getActivePage();
assertNull(page.findView(VIEW_ID));
IViewPart view = page.showView(VIEW_ID);
@@ -88,7 +91,7 @@ public class ActionDelegateProxyTest extends UITestCase {
@Test
public void testWWActionDelegate() throws Exception {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
window.getActivePage().showActionSet(DELEGATE_ACTION_SET_ID);
IHandlerService service = window.getService(IHandlerService.class);
assertFalse(SimplyGoActionDelegate.executed);
@@ -100,7 +103,7 @@ public class ActionDelegateProxyTest extends UITestCase {
@Test
public void testEditorActionDelegate() throws Exception {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
window.getActivePage().closeAllEditors(false);
IHandlerService service = window.getService(IHandlerService.class);
assertFalse(EditorActionDelegate.executed);
@@ -134,7 +137,7 @@ public class ActionDelegateProxyTest extends UITestCase {
assertEquals(editor2, EditorActionDelegate.part);
window.getActivePage().activate(editor1);
- processEvents();
+ UITestCase.processEvents();
service.executeCommand(STAY_COMMAND, null);
assertTrue(EditorActionDelegate.executed);
assertEquals(editor1, EditorActionDelegate.part);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug125792Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug125792Test.java
index 66de923376e..c09f9c8eb52 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug125792Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug125792Test.java
@@ -17,11 +17,9 @@ package org.eclipse.ui.tests.commands;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.CommandException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests a bug found in
@@ -33,12 +31,7 @@ import org.junit.runners.JUnit4;
*
* @since 3.2
*/
-@RunWith(JUnit4.class)
-public class Bug125792Test extends UITestCase {
-
- public Bug125792Test() {
- super(Bug125792Test.class.getSimpleName());
- }
+public class Bug125792Test {
private static final String COMMAND_ID = "org.eclipse.ui.tests.commands.bug125792";
@@ -50,9 +43,9 @@ public class Bug125792Test extends UITestCase {
}
private ICommandService getCommandService() {
- Object serviceObject = getWorkbench().getAdapter(ICommandService.class);
+ ICommandService serviceObject = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
if (serviceObject != null) {
- return (ICommandService) serviceObject;
+ return serviceObject;
}
return null;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java
index 4f523fb357e..1075c567e52 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java
@@ -28,28 +28,21 @@ import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @since 3.5
*
*/
-@RunWith(JUnit4.class)
-public class Bug417762Test extends UITestCase {
-
- public Bug417762Test() {
- super(Bug417762Test.class.getSimpleName());
- }
+public class Bug417762Test {
@Test
public void testAsReported() throws ExecutionException,
NotDefinedException, NotEnabledException, NotHandledException {
- IWorkbench workbench = getWorkbench();
+ IWorkbench workbench = PlatformUI.getWorkbench();
ICommandService commandService = workbench
.getService(ICommandService.class);
IHandlerService handlerService = workbench
@@ -69,7 +62,7 @@ public class Bug417762Test extends UITestCase {
@Test
public void testSuggestionUseExecuteCommand() throws ExecutionException,
NotDefinedException, NotEnabledException, NotHandledException {
- IWorkbench workbench = getWorkbench();
+ IWorkbench workbench = PlatformUI.getWorkbench();
ICommandService commandService = workbench
.getService(ICommandService.class);
IHandlerService handlerService = workbench
@@ -98,7 +91,7 @@ public class Bug417762Test extends UITestCase {
@Test
public void testSuggestionUseExecuteCommandInContext() throws ExecutionException,
NotDefinedException, NotEnabledException, NotHandledException {
- IWorkbench workbench = getWorkbench();
+ IWorkbench workbench = PlatformUI.getWorkbench();
ICommandService commandService = workbench
.getService(ICommandService.class);
IHandlerService handlerService = workbench
@@ -127,7 +120,7 @@ public class Bug417762Test extends UITestCase {
@Test
public void testSuggestionUseParameterizedCommandExecuteWithChecks() throws ExecutionException,
NotDefinedException, NotEnabledException, NotHandledException {
- IWorkbench workbench = getWorkbench();
+ IWorkbench workbench = PlatformUI.getWorkbench();
ICommandService commandService = workbench
.getService(ICommandService.class);
IHandlerService handlerService = workbench
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug66182Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug66182Test.java
index 3c15cd91fe6..9426b19a824 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug66182Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug66182Test.java
@@ -15,11 +15,15 @@
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.util.Map;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.AbstractHandler;
import org.eclipse.ui.commands.ExecutionException;
import org.eclipse.ui.commands.HandlerSubmission;
@@ -31,8 +35,6 @@ import org.eclipse.ui.commands.Priority;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests that dialogs will inherit the handlers from the workbench window, if
@@ -41,16 +43,8 @@ import org.junit.runners.JUnit4;
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
@Ignore("broke during e4 transition and still need adjustments")
-public final class Bug66182Test extends UITestCase {
-
- /**
- * Constructor for Bug66182Test.
- */
- public Bug66182Test() {
- super(Bug66182Test.class.getSimpleName());
- }
+public final class Bug66182Test {
/**
* Tests that the dialog handlers will take priority. The set-up is a
@@ -227,7 +221,7 @@ public final class Bug66182Test extends UITestCase {
public final void testFallbackToWindowBlockedByDialog()
throws ExecutionException, NotHandledException {
// Open a test window.
- final IWorkbenchWindow window = openTestWindow();
+ final IWorkbenchWindow window = UITestCase.openTestWindow();
// Define a handler for some random command identifier.
final Object windowResult = new Object();
@@ -239,7 +233,7 @@ public final class Bug66182Test extends UITestCase {
return windowResult;
}
};
- final IWorkbenchCommandSupport commandSupport = fWorkbench
+ final IWorkbenchCommandSupport commandSupport = PlatformUI.getWorkbench()
.getCommandSupport();
final String commandId = "org.eclipse.ui.tests.Bug66182";
final Shell windowShell = window.getShell();
@@ -263,7 +257,7 @@ public final class Bug66182Test extends UITestCase {
dialogShell, display.getActiveShell());
assertSame(
"The active workbench window must be the window created in this test. If you are activating other workbench windows, then this test will fail",
- windowShell, fWorkbench.getActiveWorkbenchWindow().getShell());
+ windowShell, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
assertTrue(
"When a dialog is open, it should not fall back to the active workbench window.",
!command.isHandled());
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug70503Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug70503Test.java
index 77cb4868ba1..5d794214c32 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug70503Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug70503Test.java
@@ -13,13 +13,13 @@
*******************************************************************************/
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.commands.ActionHandler;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* This test whether an ActionHandler will update its internal cache of
@@ -27,8 +27,7 @@ import org.junit.runners.JUnit4;
*
* @since 3.0.1
*/
-@RunWith(JUnit4.class)
-public class Bug70503Test extends UITestCase {
+public class Bug70503Test {
private class PubliclyRetargettableAction extends RetargetAction {
/**
@@ -59,13 +58,6 @@ public class Bug70503Test extends UITestCase {
}
/**
- * Constructor for Bug70503Test.
- */
- public Bug70503Test() {
- super(Bug70503Test.class.getSimpleName());
- }
-
- /**
* Tests whether changing only the handler will update an action handler.
* The set up is a <code>RetargetAction</code> wrapped in an
* <code>ActionHandler</code>. The test verifies a switch back and forth
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug73756Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug73756Test.java
index 08e7f6de0bd..b6b83a072b6 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug73756Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug73756Test.java
@@ -14,6 +14,9 @@
*******************************************************************************/
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.text.MessageFormat;
import java.util.ResourceBundle;
@@ -22,11 +25,9 @@ import org.eclipse.jface.action.ExternalActionManager;
import org.eclipse.jface.util.Util;
import org.eclipse.ui.statushandlers.StatusAdapter;
import org.eclipse.ui.statushandlers.StatusManager;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.eclipse.ui.tests.statushandlers.TestStatusHandler;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* A tests whether is active will log an exception if the command is not
@@ -34,8 +35,7 @@ import org.junit.runners.JUnit4;
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class Bug73756Test extends UITestCase {
+public final class Bug73756Test {
private static String CMD_ID = "a command that is not defined";
@@ -44,30 +44,22 @@ public final class Bug73756Test extends UITestCase {
private static int SEVERITY = IStatus.ERROR;
- private static String MESSAGE = MessageFormat.format(Util.translateString(
- RESOURCE_BUNDLE, "undefinedCommand.WarningMessage", null), //$NON-NLS-1$
+ private static String MESSAGE = MessageFormat.format(
+ Util.translateString(RESOURCE_BUNDLE, "undefinedCommand.WarningMessage", null), //$NON-NLS-1$
CMD_ID);
private static String PLUGIN_ID = "org.eclipse.jface";
- /**
- * Constructs a new instance of <code>Bug73756Test</code>.
- */
- public Bug73756Test() {
- super(Bug73756Test.class.getSimpleName());
- }
-
- @Override
- protected void doTearDown() throws Exception {
- super.doTearDown();
+ @Before
+ public void doTearDown() throws Exception {
TestStatusHandler.uninstall();
}
/**
- * Tests that calling <code>isActive()</code> on an undefined command
- * causes a log message to be written. This simple calls
- * <code>isActive()</code> for a bogus command identifier. A log listener
- * flips a boolean flag if a log message is written.
+ * Tests that calling <code>isActive()</code> on an undefined command causes a
+ * log message to be written. This simple calls <code>isActive()</code> for a
+ * bogus command identifier. A log listener flips a boolean flag if a log
+ * message is written.
*/
@Test
public final void testUndefinedCommandIsActiveLogged() throws Exception {
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74982Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74982Test.java
index 32e93193ebe..3c5895769f6 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74982Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74982Test.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -21,23 +23,22 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ExecutionException;
import org.eclipse.ui.commands.ICommand;
import org.eclipse.ui.commands.IWorkbenchCommandSupport;
import org.eclipse.ui.commands.NotHandledException;
import org.eclipse.ui.internal.Workbench;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* A test for whether the select all handler will send a selection event.
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class Bug74982Test extends UITestCase {
+public final class Bug74982Test {
/**
* Whether the selection event has been fired.
@@ -46,16 +47,8 @@ public final class Bug74982Test extends UITestCase {
private Shell dialog;
- /**
- * Constructs a new instance of <code>Bug74982Test</code>.
- */
- public Bug74982Test() {
- super(Bug74982Test.class.getSimpleName());
- }
-
- @Override
- protected void doTearDown() throws Exception {
- super.doTearDown();
+ @Before
+ public void doTearDown() throws Exception {
if (dialog != null) {
dialog.dispose();
}
@@ -78,6 +71,7 @@ public final class Bug74982Test extends UITestCase {
public final void testSelectAllHandlerSendsSelectionEvent()
throws ExecutionException, NotHandledException {
// Create a dialog with a text widget.
+ IWorkbench fWorkbench = PlatformUI.getWorkbench();
dialog = new Shell(fWorkbench.getActiveWorkbenchWindow().getShell());
dialog.setLayout(new GridLayout());
final Text text = new Text(dialog, SWT.SINGLE);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74990Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74990Test.java
index ac63eecd23f..8436a00416a 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74990Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug74990Test.java
@@ -14,11 +14,15 @@
*******************************************************************************/
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertTrue;
+
import java.util.Map;
import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.AbstractHandler;
import org.eclipse.ui.commands.HandlerSubmission;
import org.eclipse.ui.commands.ICommand;
@@ -28,43 +32,31 @@ import org.eclipse.ui.commands.Priority;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* A test for whether part identifiers work properly for HandlerSubmissions.
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class Bug74990Test extends UITestCase {
-
- /**
- * Constructs a new instance of <code>Bug74990Test</code>.
- */
- public Bug74990Test() {
- super(Bug74990Test.class.getSimpleName());
- }
+public final class Bug74990Test {
/**
* Tests whether a part-specific handler -- submitted via Java code -- is
- * matched properly. This is only using the part id. The test verifies that
- * it is active when the part is active, and not active when the part is not
+ * matched properly. This is only using the part id. The test verifies that it
+ * is active when the part is active, and not active when the part is not
* active.
*
- * @throws PartInitException
- * If something goes wrong creating the part to which this
- * handler is tied.
+ * @throws PartInitException If something goes wrong creating the part to which
+ * this handler is tied.
*
*/
@Test
public final void testPartIdSubmission() throws PartInitException {
// Define a command.
final String testCommandId = "org.eclipse.ui.tests.commands.Bug74990";
- final IWorkbenchCommandSupport commandSupport = fWorkbench
- .getCommandSupport();
- final ICommand testCommand = commandSupport.getCommandManager()
- .getCommand(testCommandId);
+ IWorkbench fWorkbench = PlatformUI.getWorkbench();
+ final IWorkbenchCommandSupport commandSupport = fWorkbench.getCommandSupport();
+ final ICommand testCommand = commandSupport.getCommandManager().getCommand(testCommandId);
// Create a handler submission.
final IHandler handler = new AbstractHandler() {
@@ -74,38 +66,32 @@ public final class Bug74990Test extends UITestCase {
return null;
}
};
- final HandlerSubmission testSubmission = new HandlerSubmission(
- "org.eclipse.ui.tests.api.MockViewPart", null, null,
- testCommandId, handler, Priority.MEDIUM);
+ final HandlerSubmission testSubmission = new HandlerSubmission("org.eclipse.ui.tests.api.MockViewPart", null,
+ null, testCommandId, handler, Priority.MEDIUM);
commandSupport.addHandlerSubmission(testSubmission);
try {
// Test to make sure the command is not currently handled.
- assertTrue("The MockViewPart command should not be handled",
- !testCommand.isHandled());
+ assertTrue("The MockViewPart command should not be handled", !testCommand.isHandled());
/*
- * Open a window with the MockViewPart, and make sure it is now
- * handled.
+ * Open a window with the MockViewPart, and make sure it is now handled.
*/
- final IWorkbenchPage page = openTestWindow().getActivePage();
- final IViewPart openedView = page
- .showView("org.eclipse.ui.tests.api.MockViewPart");
+ final IWorkbenchPage page = UITestCase.openTestWindow().getActivePage();
+ final IViewPart openedView = page.showView("org.eclipse.ui.tests.api.MockViewPart");
page.activate(openedView);
while (fWorkbench.getDisplay().readAndDispatch()) {
- ((Workbench)fWorkbench).getContext().processWaiting();
+ ((Workbench) fWorkbench).getContext().processWaiting();
}
- assertTrue("The MockViewPart command should be handled",
- testCommand.isHandled());
+ assertTrue("The MockViewPart command should be handled", testCommand.isHandled());
// Hide the view, and test that is becomes unhandled again.
page.hideView(openedView);
while (fWorkbench.getDisplay().readAndDispatch()) {
// Read the event queue
}
- assertTrue("The MockViewPart command should not be handled",
- !testCommand.isHandled());
+ assertTrue("The MockViewPart command should not be handled", !testCommand.isHandled());
} finally {
commandSupport.removeHandlerSubmission(testSubmission);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug87856Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug87856Test.java
index 8cdfdc675d1..d4ff358820f 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug87856Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug87856Test.java
@@ -15,20 +15,21 @@
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertTrue;
+
import java.lang.ref.WeakReference;
import java.util.Map;
import org.eclipse.core.commands.Command;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.AbstractHandler;
import org.eclipse.ui.commands.HandlerSubmission;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.commands.IHandler;
import org.eclipse.ui.commands.IWorkbenchCommandSupport;
import org.eclipse.ui.commands.Priority;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* This tests whether we are leaking handlers after their submission has been
@@ -36,25 +37,17 @@ import org.junit.runners.JUnit4;
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public class Bug87856Test extends UITestCase {
-
- /**
- * Constructs a new instance of <code>Bug87856Test</code>.
- */
- public Bug87856Test() {
- super(Bug87856Test.class.getSimpleName());
- }
+public class Bug87856Test {
/**
- * Tests whether the workbench command support (or its dependencies) will
- * leak handlers when the process loop is run. Basically, we're checking to
- * see that removing a handler submission really works.
+ * Tests whether the workbench command support (or its dependencies) will leak
+ * handlers when the process loop is run. Basically, we're checking to see that
+ * removing a handler submission really works.
*/
@Test
public final void testHandlerLeak() {
- final IWorkbenchCommandSupport commandSupport = fWorkbench
- .getCommandSupport();
+ IWorkbench fWorkbench = PlatformUI.getWorkbench();
+ final IWorkbenchCommandSupport commandSupport = fWorkbench.getCommandSupport();
final ICommandService commandService = fWorkbench.getAdapter(ICommandService.class);
final String commandId = Bug87856Test.class.getName();
final Command command = commandService.getCommand(commandId);
@@ -69,13 +62,13 @@ public class Bug87856Test extends UITestCase {
}
};
- HandlerSubmission submission = new HandlerSubmission(null, null, null,
- command.getId(), handler, Priority.MEDIUM);
+ HandlerSubmission submission = new HandlerSubmission(null, null, null, command.getId(), handler,
+ Priority.MEDIUM);
commandSupport.addHandlerSubmission(submission);
/*
- * Remove the handler with no replacement, and hold on to the handler
- * via a weak reference.
+ * Remove the handler with no replacement, and hold on to the handler via a weak
+ * reference.
*/
commandSupport.removeHandlerSubmission(submission);
submission = null;
@@ -94,8 +87,7 @@ public class Bug87856Test extends UITestCase {
Thread.yield();
// Check to see if the reference has been cleared.
- assertTrue(
- "We should not hold on to a handler after the submission has been removed.",
+ assertTrue("We should not hold on to a handler after the submission has been removed.",
reference.isEnqueued() || (reference.get() == null));
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandActionTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandActionTest.java
index 6b345fd8fa3..7fdf4ea0421 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandActionTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandActionTest.java
@@ -15,6 +15,10 @@
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.HashMap;
import java.util.Map;
@@ -24,17 +28,15 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerActivation;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.actions.CommandAction;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @since 3.3
*
*/
-@RunWith(JUnit4.class)
-public class CommandActionTest extends UITestCase {
+public class CommandActionTest {
// you can find these commands in org.eclipse.ui.tests/plugin.xml
private static final String PREFIX = "tests.commands.CCT.";
private static final String CMD1_ID = PREFIX + "cmd1";
@@ -46,11 +48,9 @@ public class CommandActionTest extends UITestCase {
private VerifyHandler2 cmd2Handler;
private IHandlerActivation cmd2Activation;
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
- handlerService = fWorkbench
- .getService(IHandlerService.class);
+ @Before
+ public void doSetUp() throws Exception {
+ handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
cmd1Handler = new VerifyHandler();
cmd1Activation = handlerService.activateHandler(CMD1_ID, cmd1Handler);
@@ -58,8 +58,8 @@ public class CommandActionTest extends UITestCase {
cmd2Activation = handlerService.activateHandler(CMD2_ID, cmd2Handler);
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
if (cmd1Activation != null) {
handlerService.deactivateHandler(cmd1Activation);
cmd1Activation = null;
@@ -68,7 +68,6 @@ public class CommandActionTest extends UITestCase {
handlerService.deactivateHandler(cmd2Activation);
cmd2Activation = null;
}
- super.doTearDown();
}
private static class VerifyHandler2 extends AbstractHandler {
@@ -96,17 +95,11 @@ public class CommandActionTest extends UITestCase {
}
}
-
- public CommandActionTest() {
- super(CommandActionTest.class.getSimpleName());
- }
-
@Test
public void testCommandId() throws Exception {
// create a command action for CMD1_ID, which takes no parameters.
- CommandAction action1 = new CommandAction(PlatformUI.getWorkbench(),
- CMD1_ID);
+ CommandAction action1 = new CommandAction(PlatformUI.getWorkbench(), CMD1_ID);
assertEquals(0, cmd1Handler.count);
action1.run();
assertEquals(1, cmd1Handler.count);
@@ -125,8 +118,7 @@ public class CommandActionTest extends UITestCase {
map.put("protocol", "true"); //$NON-NLS-1$ //$NON-NLS-2$
map.put("host", "true");
- CommandAction action2 = new CommandAction(PlatformUI.getWorkbench(),
- CMD2_ID, map);
+ CommandAction action2 = new CommandAction(PlatformUI.getWorkbench(), CMD2_ID, map);
action2.run();
assertEquals(1, cmd2Handler.count);
assertNotNull(cmd2Handler.paramValue1);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java
index 77044707124..84c55664e08 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java
@@ -14,6 +14,12 @@
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.lang.reflect.Field;
import java.util.Map;
@@ -41,7 +47,9 @@ import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.contexts.IContextActivation;
@@ -60,6 +68,8 @@ import org.eclipse.ui.menus.UIElement;
import org.eclipse.ui.services.IEvaluationService;
import org.eclipse.ui.services.ISourceProviderService;
import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -71,7 +81,7 @@ import org.junit.runners.JUnit4;
*/
@RunWith(JUnit4.class)
@Ignore("broke during e4 transition and still need adjustments")
-public class CommandEnablementTest extends UITestCase {
+public class CommandEnablementTest {
private static final String CONTEXT_TEST2 = "org.eclipse.ui.command.contexts.enablement_test2";
private static final String CONTEXT_TEST1 = "org.eclipse.ui.command.contexts.enablement_test1";
@@ -97,22 +107,15 @@ public class CommandEnablementTest extends UITestCase {
private CheckContextHandler contextHandler;
private IContextActivation contextActivation1;
private IContextActivation contextActivation2;
-
- public CommandEnablementTest() {
- super(CommandEnablementTest.class.getSimpleName());
- }
-
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
- commandService = fWorkbench
- .getService(ICommandService.class);
- handlerService = fWorkbench
- .getService(IHandlerService.class);
- contextService = fWorkbench
- .getService(IContextService.class);
- evalService = fWorkbench
- .getService(IEvaluationService.class);
+ private IWorkbench fWorkbench;
+
+ @Before
+ public void doSetUp() throws Exception {
+ fWorkbench = PlatformUI.getWorkbench();
+ commandService = fWorkbench.getService(ICommandService.class);
+ handlerService = fWorkbench.getService(IHandlerService.class);
+ contextService = fWorkbench.getService(IContextService.class);
+ evalService = fWorkbench.getService(IEvaluationService.class);
cmd1 = commandService.getCommand(CMD1_ID);
cmd3 = commandService.getCommand(CMD3_ID);
normalHandler1 = new DefaultHandler();
@@ -124,8 +127,8 @@ public class CommandEnablementTest extends UITestCase {
contextHandler = new CheckContextHandler();
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
if (activation1 != null) {
handlerService.deactivateHandler(activation1);
activation1 = null;
@@ -142,7 +145,6 @@ public class CommandEnablementTest extends UITestCase {
contextService.deactivateContext(contextActivation2);
contextActivation2 = null;
}
- super.doTearDown();
}
private static class DefaultHandler extends AbstractHandler {
@@ -334,11 +336,11 @@ public class CommandEnablementTest extends UITestCase {
}
private IHandler getHandler(Command command) {
- EHandlerService service = getWorkbench().getService(EHandlerService.class);
+ EHandlerService service = fWorkbench.getService(EHandlerService.class);
if (service == null) {
return null;
}
- IEclipseContext ctx = getWorkbench().getService(IEclipseContext.class);
+ IEclipseContext ctx = fWorkbench.getService(IEclipseContext.class);
Object handler = HandlerServiceImpl.lookUpHandler(ctx, command.getId());
if (handler instanceof E4HandlerProxy) {
return ((E4HandlerProxy) handler).getHandler();
@@ -352,12 +354,10 @@ public class CommandEnablementTest extends UITestCase {
int enabledChangedCount = 0;
activation1 = handlerService.activateHandler(CMD1_ID, normalHandler1,
- new ActiveContextExpression(CONTEXT_TEST1,
- new String[] { ISources.ACTIVE_CONTEXT_NAME }));
+ new ActiveContextExpression(CONTEXT_TEST1, new String[] { ISources.ACTIVE_CONTEXT_NAME }));
activation2 = handlerService.activateHandler(CMD1_ID, normalHandler2,
- new ActiveContextExpression(CONTEXT_TEST2,
- new String[] { ISources.ACTIVE_CONTEXT_NAME }));
- IEclipseContext ctx = getWorkbench().getService(IEclipseContext.class);
+ new ActiveContextExpression(CONTEXT_TEST2, new String[] { ISources.ACTIVE_CONTEXT_NAME }));
+ IEclipseContext ctx = fWorkbench.getService(IEclipseContext.class);
ctx.processWaiting();
assertFalse(cmd1.isHandled());
@@ -610,7 +610,7 @@ public class CommandEnablementTest extends UITestCase {
@Test
public void testEnablementForLocalContext() throws Exception {
- openTestWindow("org.eclipse.ui.resourcePerspective");
+ UITestCase.openTestWindow("org.eclipse.ui.resourcePerspective");
activation1 = handlerService.activateHandler(CMD1_ID, contextHandler,
new ActiveContextExpression(CONTEXT_TEST1,
new String[] { ISources.ACTIVE_CONTEXT_NAME }));
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandExecutionTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandExecutionTest.java
index a3b581d276d..0f3e17fe950 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandExecutionTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandExecutionTest.java
@@ -14,6 +14,9 @@
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.util.ArrayList;
import org.eclipse.core.commands.Command;
@@ -27,20 +30,17 @@ import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @since 3.103
*
*/
-@RunWith(JUnit4.class)
-public class CommandExecutionTest extends UITestCase {
+public class CommandExecutionTest {
static class Pair {
public Pair(String a, Object b) {
key = a;
@@ -73,8 +73,7 @@ public class CommandExecutionTest extends UITestCase {
}
@Override
- public void postExecuteFailure(String commandId,
- ExecutionException exception) {
+ public void postExecuteFailure(String commandId, ExecutionException exception) {
methods.add(new Pair("postExecuteFailure", exception));
}
@@ -94,10 +93,6 @@ public class CommandExecutionTest extends UITestCase {
}
}
- public CommandExecutionTest() {
- super(CommandExecutionTest.class.getSimpleName());
- }
-
private void compare(String[] calls, ArrayList<Pair> methods) {
for (int i = 0; i < calls.length && i < methods.size(); i++) {
assertEquals("call " + i, calls[i], methods.get(i).key);
@@ -108,14 +103,11 @@ public class CommandExecutionTest extends UITestCase {
@Test
public void testCommandServiceExecute() throws Exception {
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
cmdService.addExecutionListener(listener);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
try {
- handlerService.executeCommand(
- IWorkbenchCommandConstants.FILE_CLOSE_OTHERS, null);
+ handlerService.executeCommand(IWorkbenchCommandConstants.FILE_CLOSE_OTHERS, null);
} catch (Exception e) {
// do nothing
}
@@ -128,15 +120,11 @@ public class CommandExecutionTest extends UITestCase {
@Test
public void testCommandExecute() throws Exception {
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
cmdService.addExecutionListener(listener);
- final Command cmd = cmdService
- .getCommand(IWorkbenchCommandConstants.FILE_CLOSE_OTHERS);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
- final ExecutionEvent event = handlerService.createExecutionEvent(cmd,
- null);
+ final Command cmd = cmdService.getCommand(IWorkbenchCommandConstants.FILE_CLOSE_OTHERS);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
+ final ExecutionEvent event = handlerService.createExecutionEvent(cmd, null);
try {
cmd.executeWithChecks(event);
} catch (Exception e) {
@@ -151,26 +139,22 @@ public class CommandExecutionTest extends UITestCase {
/**
* Verify that {@link IExecutionListener#preExecute(String, ExecutionEvent)} has
* received an event compatible with {@link HandlerUtil} methods.
+ *
* @param listener
*/
private void verifyHandlerUtilAccessDuringPreExecute(EL listener) {
- assertNotNull(
- "HandlerUtil.getActiveWorkbenchWindow() returned null during ICommandListener.preExecute().",
+ assertNotNull("HandlerUtil.getActiveWorkbenchWindow() returned null during ICommandListener.preExecute().",
listener.wbw);
}
@Test
public void testCommandListenerExecute() throws Exception {
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
- final Command cmd = cmdService
- .getCommand(IWorkbenchCommandConstants.FILE_CLOSE_OTHERS);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
+ final Command cmd = cmdService.getCommand(IWorkbenchCommandConstants.FILE_CLOSE_OTHERS);
cmd.addExecutionListener(listener);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
- final ExecutionEvent event = handlerService.createExecutionEvent(cmd,
- null);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
+ final ExecutionEvent event = handlerService.createExecutionEvent(cmd, null);
try {
cmd.executeWithChecks(event);
} catch (Exception e) {
@@ -185,14 +169,11 @@ public class CommandExecutionTest extends UITestCase {
@Test
public void testCommandServiceExecuteRefresh() throws Exception {
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
cmdService.addExecutionListener(listener);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
try {
- handlerService.executeCommand(
- IWorkbenchCommandConstants.FILE_REFRESH, null);
+ handlerService.executeCommand(IWorkbenchCommandConstants.FILE_REFRESH, null);
} catch (Exception e) {
// do nothing
}
@@ -205,15 +186,11 @@ public class CommandExecutionTest extends UITestCase {
@Test
public void testCommandExecuteRefresh() throws Exception {
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
cmdService.addExecutionListener(listener);
- final Command cmd = cmdService
- .getCommand(IWorkbenchCommandConstants.FILE_REFRESH);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
- final ExecutionEvent event = handlerService.createExecutionEvent(cmd,
- null);
+ final Command cmd = cmdService.getCommand(IWorkbenchCommandConstants.FILE_REFRESH);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
+ final ExecutionEvent event = handlerService.createExecutionEvent(cmd, null);
try {
cmd.executeWithChecks(event);
} catch (Exception e) {
@@ -228,15 +205,11 @@ public class CommandExecutionTest extends UITestCase {
@Test
public void testCommandListenerExecuteRefresh() throws Exception {
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
- final Command cmd = cmdService
- .getCommand(IWorkbenchCommandConstants.FILE_REFRESH);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
+ final Command cmd = cmdService.getCommand(IWorkbenchCommandConstants.FILE_REFRESH);
cmd.addExecutionListener(listener);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
- final ExecutionEvent event = handlerService.createExecutionEvent(cmd,
- null);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
+ final ExecutionEvent event = handlerService.createExecutionEvent(cmd, null);
try {
cmd.executeWithChecks(event);
} catch (Exception e) {
@@ -250,17 +223,13 @@ public class CommandExecutionTest extends UITestCase {
@Test
public void testCommandServiceExecuteClosePart() throws Exception {
- getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .showView(IPageLayout.ID_PROGRESS_VIEW);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(IPageLayout.ID_PROGRESS_VIEW);
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
cmdService.addExecutionListener(listener);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
try {
- handlerService.executeCommand(
- IWorkbenchCommandConstants.WINDOW_CLOSE_PART, null);
+ handlerService.executeCommand(IWorkbenchCommandConstants.WINDOW_CLOSE_PART, null);
} catch (Exception e) {
// do nothing
}
@@ -272,18 +241,13 @@ public class CommandExecutionTest extends UITestCase {
@Test
public void testCommandExecuteClosePart() throws Exception {
- getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .showView(IPageLayout.ID_PROGRESS_VIEW);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(IPageLayout.ID_PROGRESS_VIEW);
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
cmdService.addExecutionListener(listener);
- final Command cmd = cmdService
- .getCommand(IWorkbenchCommandConstants.WINDOW_CLOSE_PART);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
- final ExecutionEvent event = handlerService.createExecutionEvent(cmd,
- null);
+ final Command cmd = cmdService.getCommand(IWorkbenchCommandConstants.WINDOW_CLOSE_PART);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
+ final ExecutionEvent event = handlerService.createExecutionEvent(cmd, null);
try {
cmd.executeWithChecks(event);
} catch (Exception e) {
@@ -297,18 +261,13 @@ public class CommandExecutionTest extends UITestCase {
@Test
public void testCommandListenerExecuteClosePart() throws Exception {
- getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .showView(IPageLayout.ID_PROGRESS_VIEW);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(IPageLayout.ID_PROGRESS_VIEW);
EL listener = new EL();
- ICommandService cmdService = getWorkbench()
- .getService(ICommandService.class);
- final Command cmd = cmdService
- .getCommand(IWorkbenchCommandConstants.WINDOW_CLOSE_PART);
+ ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
+ final Command cmd = cmdService.getCommand(IWorkbenchCommandConstants.WINDOW_CLOSE_PART);
cmd.addExecutionListener(listener);
- IHandlerService handlerService = getWorkbench()
- .getService(IHandlerService.class);
- final ExecutionEvent event = handlerService.createExecutionEvent(cmd,
- null);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
+ final ExecutionEvent event = handlerService.createExecutionEvent(cmd, null);
try {
cmd.executeWithChecks(event);
} catch (Exception e) {
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandManagerTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandManagerTest.java
index bebc17e613e..bd1df484f77 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandManagerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandManagerTest.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertSame;
+
import org.eclipse.core.commands.Category;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.CommandManager;
@@ -21,36 +23,30 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IExecutionListener;
import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests some of the API on command manager.
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class CommandManagerTest extends UITestCase {
+public final class CommandManagerTest {
/**
- * An execution listener that can be attached to the command manager. It
- * will track which events it last heard.
+ * An execution listener that can be attached to the command manager. It will
+ * track which events it last heard.
*
* @since 3.1
*/
private final class ExecutionListener implements IExecutionListener {
/**
- * The last command identifier to be not handled, or <code>null</code>
- * if none.
+ * The last command identifier to be not handled, or <code>null</code> if none.
*/
private String notHandledId = null;
/**
- * The last command identifier to be executed, or <code>null</code> if
- * none.
+ * The last command identifier to be executed, or <code>null</code> if none.
*/
private String preExecuteId = null;
@@ -65,40 +61,29 @@ public final class CommandManagerTest extends UITestCase {
private ExecutionEvent preExecuteEvent = null;
@Override
- public final void notHandled(final String commandId,
- final NotHandledException exception) {
+ public final void notHandled(final String commandId, final NotHandledException exception) {
notHandledId = commandId;
notHandledException = exception;
}
@Override
- public final void postExecuteFailure(final String commandId,
- final ExecutionException exception) {
+ public final void postExecuteFailure(final String commandId, final ExecutionException exception) {
// Do nothing.
}
@Override
- public final void postExecuteSuccess(final String commandId,
- final Object returnValue) {
+ public final void postExecuteSuccess(final String commandId, final Object returnValue) {
// Do nothing
}
@Override
- public final void preExecute(final String commandId,
- final ExecutionEvent event) {
+ public final void preExecute(final String commandId, final ExecutionEvent event) {
preExecuteId = commandId;
preExecuteEvent = event;
}
}
- /**
- * Constructs a new instance of <code>CommandManagerTest</code>.
- */
- public CommandManagerTest() {
- super(CommandManagerTest.class.getSimpleName());
- }
-
@Test
public final void testExecutionListener() {
final String commandId = "myCommand";
@@ -117,18 +102,13 @@ public final class CommandManagerTest extends UITestCase {
exception = e;
}
- assertSame(
- "Should have received a pre-execute event for the correct command",
- commandId, listener.preExecuteId);
- assertSame(
- "Should have received a pre-execute event with the correct event",
- event, listener.preExecuteEvent);
- assertSame(
- "Should have received a not-handled event for the correct command",
- commandId, listener.notHandledId);
- assertSame(
- "Should have received a not-handled event with the correct exception",
- exception, listener.notHandledException);
+ assertSame("Should have received a pre-execute event for the correct command", commandId,
+ listener.preExecuteId);
+ assertSame("Should have received a pre-execute event with the correct event", event, listener.preExecuteEvent);
+ assertSame("Should have received a not-handled event for the correct command", commandId,
+ listener.notHandledId);
+ assertSame("Should have received a not-handled event with the correct exception", exception,
+ listener.notHandledException);
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java
index ce88106d1a6..43942cffd21 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java
@@ -14,6 +14,12 @@
*******************************************************************************/
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.ITypedParameter;
@@ -23,15 +29,12 @@ import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.CommandException;
import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-@RunWith(JUnit4.class)
-public class CommandParameterTypeTest extends UITestCase {
+public class CommandParameterTypeTest {
static final String SUBTRACT = "org.eclipse.ui.tests.commands.subtractInteger";
static final String MINUEND = "minuend";
@@ -40,13 +43,6 @@ public class CommandParameterTypeTest extends UITestCase {
static final String TYPE = "org.eclipse.ui.tests.commands.Integer";
/**
- * Constructs a new instance of <code>CommandParameterTypeTest</code>.
- */
- public CommandParameterTypeTest() {
- super(CommandParameterTypeTest.class.getSimpleName());
- }
-
- /**
* Tests invoking a command that subtracts one number from another. The
* handler for the subtract command will convert the string parameters to
* integers to perform the operation. This test drives much of the command
@@ -109,7 +105,7 @@ public class CommandParameterTypeTest extends UITestCase {
// execute the command and check the result
ParameterizedCommand pCommand = new ParameterizedCommand(command,
parameterizations);
- IHandlerService hs = getWorkbench().getService(IHandlerService.class);
+ IHandlerService hs = PlatformUI.getWorkbench().getService(IHandlerService.class);
Integer result = (Integer) pCommand.executeWithChecks(null, hs.getCurrentState());
assertEquals(difference, result.intValue());
}
@@ -278,9 +274,9 @@ public class CommandParameterTypeTest extends UITestCase {
}
private ICommandService getCommandService() {
- Object serviceObject = getWorkbench().getAdapter(ICommandService.class);
+ ICommandService serviceObject = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
if (serviceObject != null) {
- return (ICommandService) serviceObject;
+ return serviceObject;
}
return null;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandSerializationTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandSerializationTest.java
index 48cc22871db..c421a3f8d6b 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandSerializationTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandSerializationTest.java
@@ -13,17 +13,20 @@
*******************************************************************************/
package org.eclipse.ui.tests.commands;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Map;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.SerializationException;
import org.eclipse.core.commands.common.CommandException;
import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test serialization and deserialization of ParameterizedCommands. See <a
@@ -31,15 +34,7 @@ import org.junit.runners.JUnit4;
*
* @since 3.2
*/
-@RunWith(JUnit4.class)
-public class CommandSerializationTest extends UITestCase {
-
- /**
- * Constructs a new instance of <code>CommandSerializationTest</code>.
- */
- public CommandSerializationTest() {
- super(CommandSerializationTest.class.getSimpleName());
- }
+public class CommandSerializationTest {
private final String showPerspectiveCommandId = "org.eclipse.ui.perspectives.showPerspective";
@@ -337,9 +332,9 @@ public class CommandSerializationTest extends UITestCase {
}
private ICommandService getCommandService() {
- Object serviceObject = getWorkbench().getAdapter(ICommandService.class);
+ ICommandService serviceObject = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
if (serviceObject != null) {
- return (ICommandService) serviceObject;
+ return serviceObject;
}
return null;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java
index 348abb4294f..4c7fd611177 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java
@@ -13,82 +13,68 @@
*******************************************************************************/
package org.eclipse.ui.tests.contexts;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.EnabledSubmission;
import org.eclipse.ui.contexts.IContext;
import org.eclipse.ui.contexts.IWorkbenchContextSupport;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* A test for whether part identifiers work properly for EnabledSubmissions.
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class Bug74990Test extends UITestCase {
-
- /**
- * Constructs a new instance of <code>Bug74990Test</code>.
- */
- public Bug74990Test() {
- super(Bug74990Test.class.getSimpleName());
- }
+public final class Bug74990Test {
/**
* Tests whether a part-specific context -- submitted via Java code -- is
- * matched properly. This is only using the part id. The test verifies that
- * it is active when the part is active, and not active when the part is not
+ * matched properly. This is only using the part id. The test verifies that it
+ * is active when the part is active, and not active when the part is not
* active.
*
- * @throws PartInitException
- * If something goes wrong creating the part to which this
- * handler is tied.
+ * @throws PartInitException If something goes wrong creating the part to which
+ * this handler is tied.
*
*/
@Test
public final void testPartIdSubmission() throws PartInitException {
// Define a command.
final String testContextId = "org.eclipse.ui.tests.contexts.Bug74990";
- final IWorkbenchContextSupport contextSupport = fWorkbench
- .getContextSupport();
- final IContext testContext = contextSupport.getContextManager()
- .getContext(testContextId);
+ IWorkbench fWorkbench = PlatformUI.getWorkbench();
+ final IWorkbenchContextSupport contextSupport = fWorkbench.getContextSupport();
+ final IContext testContext = contextSupport.getContextManager().getContext(testContextId);
// Create an enabled submission.
- final EnabledSubmission testSubmission = new EnabledSubmission(
- "org.eclipse.ui.tests.api.MockViewPart", null, null,
- testContextId);
+ final EnabledSubmission testSubmission = new EnabledSubmission("org.eclipse.ui.tests.api.MockViewPart", null,
+ null, testContextId);
contextSupport.addEnabledSubmission(testSubmission);
try {
// Test to make sure the context is not currently enabled.
- assertTrue("The MockViewPart context should not be enabled",
- !testContext.isEnabled());
+ assertTrue("The MockViewPart context should not be enabled", !testContext.isEnabled());
/*
- * Open a window with the MockViewPart, and make sure it now
- * enabled.
+ * Open a window with the MockViewPart, and make sure it now enabled.
*/
- final IWorkbenchPage page = openTestWindow().getActivePage();
- final IViewPart openedView = page
- .showView("org.eclipse.ui.tests.api.MockViewPart");
+ final IWorkbenchPage page = UITestCase.openTestWindow().getActivePage();
+ final IViewPart openedView = page.showView("org.eclipse.ui.tests.api.MockViewPart");
page.activate(openedView);
while (fWorkbench.getDisplay().readAndDispatch()) {
}
- assertTrue("The MockViewPart context should be enabled",
- testContext.isEnabled());
+ assertTrue("The MockViewPart context should be enabled", testContext.isEnabled());
// Hide the view, and test that is becomes disabled again.
page.hideView(openedView);
while (fWorkbench.getDisplay().readAndDispatch()) {
}
- assertTrue("The MockViewPart context should not be enabled",
- !testContext.isEnabled());
+ assertTrue("The MockViewPart context should not be enabled", !testContext.isEnabled());
} finally {
contextSupport.removeEnabledSubmission(testSubmission);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug84763Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug84763Test.java
index fb8c1b431eb..689d8c4f6a5 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug84763Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug84763Test.java
@@ -14,6 +14,9 @@
package org.eclipse.ui.tests.contexts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashSet;
import java.util.Set;
@@ -31,10 +34,9 @@ import org.eclipse.jface.bindings.keys.KeyBinding;
import org.eclipse.jface.bindings.keys.KeySequence;
import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.jface.contexts.IContextIds;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* A test case covering the scenario described in Bug 84763. The problem was
@@ -44,8 +46,7 @@ import org.junit.runners.JUnit4;
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class Bug84763Test extends UITestCase {
+public final class Bug84763Test {
/**
* The binding manager to use in each test case. A new binding manager is
@@ -74,18 +75,11 @@ public final class Bug84763Test extends UITestCase {
private Set<String> previousContextIds = null;
/**
- * Constructor for <code>Bug84763Test</code>.
- */
- public Bug84763Test() {
- super(Bug84763Test.class.getSimpleName());
- }
-
- /**
* Creates a new context manager and a binding manager for use in the test
* cases.
*/
- @Override
- protected void doSetUp() {
+ @Before
+ public void doSetUp() {
contextManager = new ContextManager();
contextManagerListener = contextManagerEvent -> {
previousContextIds = contextManagerEvent.getPreviouslyActiveContextIds();
@@ -100,8 +94,8 @@ public final class Bug84763Test extends UITestCase {
/**
* Releases the context manager and binding manager for garbage collection.
*/
- @Override
- protected void doTearDown() {
+ @After
+ public void doTearDown() {
contextManager = null;
contextManagerListener = null;
previousContextIds = null;
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorAdaptableTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorAdaptableTests.java
index b269214ebfb..f9fb406308b 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorAdaptableTests.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorAdaptableTests.java
@@ -14,6 +14,8 @@
*******************************************************************************/
package org.eclipse.ui.tests.decorators;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -23,18 +25,12 @@ import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.decorators.DecorationResult;
import org.eclipse.ui.internal.decorators.DecoratorManager;
import org.eclipse.ui.internal.decorators.LightweightDecoratorManager;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.eclipse.ui.tests.menus.ObjectContributionClasses;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class DecoratorAdaptableTests extends UITestCase {
- public DecoratorAdaptableTests() {
- super(DecoratorAdaptableTests.class.getSimpleName());
- }
+public class DecoratorAdaptableTests {
private DecoratorManager getDecoratorManager() {
return WorkbenchPlugin.getDefault().getDecoratorManager();
@@ -61,22 +57,20 @@ public class DecoratorAdaptableTests extends UITestCase {
}
}
- @Override
- protected void doSetUp() throws Exception {
+ @Before
+ public void doSetUp() throws Exception {
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestAdaptableDecoratorContributor.ID, true);
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestUnadaptableDecoratorContributor.ID, true);
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceDecoratorContributor.ID, true);
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceMappingDecoratorContributor.ID, true);
- super.doSetUp();
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestAdaptableDecoratorContributor.ID, false);
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestUnadaptableDecoratorContributor.ID, false);
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceDecoratorContributor.ID, false);
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceMappingDecoratorContributor.ID, false);
- super.doTearDown();
}
/**
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/AnimationEngineTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/AnimationEngineTest.java
index 7512d4fd69d..b1ee891a2a3 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/AnimationEngineTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/AnimationEngineTest.java
@@ -14,28 +14,25 @@
package org.eclipse.ui.tests.internal;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.preference.PreferenceMemento;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.internal.AnimationEngine;
import org.eclipse.ui.internal.AnimationFeedbackBase;
import org.eclipse.ui.internal.util.PrefUtil;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @since 3.5
*
*/
-@RunWith(JUnit4.class)
-public class AnimationEngineTest extends UITestCase {
-
- public AnimationEngineTest() {
- super(AnimationEngineTest.class.getSimpleName());
- }
+public class AnimationEngineTest {
private class TestFeedback extends AnimationFeedbackBase {
/**
@@ -72,14 +69,17 @@ public class AnimationEngineTest extends UITestCase {
Shell shell;
TestFeedback feedback;
AnimationEngine engine;
+ private PreferenceMemento memento;
- @Override
- protected void doSetUp() {
+ @Before
+ public void doSetUp() {
shell = new Shell(Display.getCurrent());
+ memento = new PreferenceMemento();
}
- @Override
- protected void doTearDown() {
+ @After
+ public void doTearDown() {
+ memento.resetPreferences();
shell.dispose();
shell = null;
}
@@ -97,7 +97,8 @@ public class AnimationEngineTest extends UITestCase {
@Test
public void testAnimationEngine() throws InterruptedException {
// Ensure that animations are turned on
- setPreference(PrefUtil.getAPIPreferenceStore(), IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, true);
+ memento.setValue(PrefUtil.getAPIPreferenceStore(), IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS,
+ true);
feedback = new TestFeedback(shell);
engine = new AnimationEngine(feedback, 250, 0);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug41931Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug41931Test.java
index d15c2fdc5ac..3cee198bd73 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug41931Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug41931Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.internal;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -30,24 +32,14 @@ import org.eclipse.ui.internal.WorkbenchPage;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test for Bug 41931.
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
@Ignore
-public class Bug41931Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- */
- public Bug41931Test() {
- super(Bug41931Test.class.getSimpleName());
- }
+public class Bug41931Test {
/**
* Tests that the <code>bringToTop(IWorkbenchPart)</code> correctly
@@ -59,7 +51,7 @@ public class Bug41931Test extends UITestCase {
@Test
public void testBringToTop() throws CoreException {
// Open a window.
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
// Create a test project.
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug540297WorkbenchPageFindViewTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug540297WorkbenchPageFindViewTest.java
index 549fb59d3e1..f8f2fb4fd27 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug540297WorkbenchPageFindViewTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug540297WorkbenchPageFindViewTest.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.ui.tests.internal;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -23,19 +25,19 @@ import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests for bug 540297. Call {@link IWorkbenchPage#findView(String)} while the
* view is open in some perspective and window, and see if the find view method
* behaves properly.
*/
-@RunWith(JUnit4.class)
-public class Bug540297WorkbenchPageFindViewTest extends UITestCase {
+public class Bug540297WorkbenchPageFindViewTest {
public static class MyPerspective implements IPerspectiveFactory {
public static String ID1 = "org.eclipse.ui.tests.internal.Bug540297WorkbenchPageFindViewTest.MyPerspective1";
@@ -70,16 +72,10 @@ public class Bug540297WorkbenchPageFindViewTest extends UITestCase {
private IPerspectiveDescriptor activePerspective;
private IPerspectiveDescriptor inactivePerspective;
- public Bug540297WorkbenchPageFindViewTest() {
- super(Bug540297WorkbenchPageFindViewTest.class.getSimpleName());
- }
-
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
-
- firstWindow = fWorkbench.getActiveWorkbenchWindow();
- secondWindow = openTestWindow();
+ @Before
+ public void doSetUp() throws Exception {
+ firstWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ secondWindow = UITestCase.openTestWindow();
firstWindowActivePage = firstWindow.getActivePage();
secondWindowActivePage = secondWindow.getActivePage();
@@ -93,7 +89,7 @@ public class Bug540297WorkbenchPageFindViewTest extends UITestCase {
prepareWorkbenchPageForTest(firstWindowActivePage);
prepareWorkbenchPageForTest(secondWindowActivePage);
- processEvents();
+ UITestCase.processEvents();
}
private void prepareWorkbenchPageForTest(IWorkbenchPage page) {
@@ -109,15 +105,14 @@ public class Bug540297WorkbenchPageFindViewTest extends UITestCase {
}
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
secondWindow.close();
firstWindowActivePage.setPerspective(originalPerspective);
firstWindowActivePage.resetPerspective();
firstWindowActivePage.closePerspective(inactivePerspective, false, false);
firstWindowActivePage.closePerspective(activePerspective, false, false);
- processEvents();
- super.doTearDown();
+ UITestCase.processEvents();
}
/**
@@ -218,7 +213,7 @@ public class Bug540297WorkbenchPageFindViewTest extends UITestCase {
private static void setPerspective(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
page.setPerspective(perspective);
page.resetPerspective();
- processEvents();
+ UITestCase.processEvents();
}
private static void showAndHideView(IWorkbenchPage page) throws Exception {
@@ -228,17 +223,17 @@ public class Bug540297WorkbenchPageFindViewTest extends UITestCase {
private static void showView(IWorkbenchPage page) throws Exception {
page.showView(MyViewPart.ID);
- processEvents();
+ UITestCase.processEvents();
}
private static void hideView(IWorkbenchPage page) throws Exception {
IViewPart view = page.findView(MyViewPart.ID);
page.hideView(view);
- processEvents();
+ UITestCase.processEvents();
}
private IPerspectiveDescriptor getPerspetiveDescriptor(String perspectiveId) {
- return fWorkbench.getPerspectiveRegistry().findPerspectiveWithId(perspectiveId);
+ return PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(perspectiveId);
}
private static void assertCanFindView(IWorkbenchPage page) throws Exception {
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug78470Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug78470Test.java
index 1a1392beefc..763b4a5964c 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug78470Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/Bug78470Test.java
@@ -14,6 +14,9 @@
package org.eclipse.ui.tests.internal;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -25,14 +28,12 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-@RunWith(JUnit4.class)
-public class Bug78470Test extends UITestCase {
+public class Bug78470Test {
public static class MyPerspective implements IPerspectiveFactory {
public static String ID = "org.eclipse.ui.tests.internal.Bug78470Test.MyPerspective";
@@ -67,15 +68,11 @@ public class Bug78470Test extends UITestCase {
}
}
- public Bug78470Test() {
- super(Bug78470Test.class.getSimpleName());
- }
-
boolean partVisibleExecuted = false;
@Test
public void test78470() throws Exception {
- IWorkbench workbench = getWorkbench();
+ IWorkbench workbench = PlatformUI.getWorkbench();
final IWorkbenchWindow activeWorkbenchWindow = workbench
.getActiveWorkbenchWindow();
final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
@@ -116,7 +113,7 @@ public class Bug78470Test extends UITestCase {
}
});
workbench.showPerspective(MyPerspective.ID, activeWorkbenchWindow);
- processEvents();
+ UITestCase.processEvents();
Thread.sleep(2000);
assertTrue("view was not made visible", partVisibleExecuted);
assertNotNull(activePage.findView(MyViewPart.ID2));
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingInteractionsTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingInteractionsTest.java
index cb649eedbbe..4841ffdba70 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingInteractionsTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingInteractionsTest.java
@@ -13,6 +13,10 @@
*******************************************************************************/
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
@@ -26,10 +30,9 @@ import org.eclipse.jface.bindings.BindingManager;
import org.eclipse.jface.bindings.Scheme;
import org.eclipse.jface.bindings.TriggerSequence;
import org.eclipse.jface.util.Util;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test cases covering the various interaction between bindings. Bindings that
@@ -38,8 +41,7 @@ import org.junit.runners.JUnit4;
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class BindingInteractionsTest extends UITestCase {
+public final class BindingInteractionsTest {
/**
* The binding manager to use in each test case. A new binding manager is
@@ -54,18 +56,11 @@ public final class BindingInteractionsTest extends UITestCase {
private ContextManager contextManager = null;
/**
- * Constructor for <code>BindingInteractionsTest</code>.
- */
- public BindingInteractionsTest() {
- super(BindingInteractionsTest.class.getSimpleName());
- }
-
- /**
* Creates a new context manager and a binding manager for use in the test
* cases.
*/
- @Override
- protected void doSetUp() {
+ @Before
+ public void doSetUp() {
contextManager = new ContextManager();
bindingManager = new BindingManager(contextManager,
new CommandManager());
@@ -74,8 +69,8 @@ public final class BindingInteractionsTest extends UITestCase {
/**
* Releases the context manager and binding manager for garbage collection.
*/
- @Override
- protected void doTearDown() {
+ @After
+ public void doTearDown() {
contextManager = null;
bindingManager = null;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingManagerTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingManagerTest.java
index b166fd97070..34ed69e5e62 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingManagerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingManagerTest.java
@@ -14,6 +14,14 @@
*******************************************************************************/
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -36,10 +44,9 @@ import org.eclipse.jface.bindings.TriggerSequence;
import org.eclipse.jface.bindings.keys.KeyBinding;
import org.eclipse.jface.bindings.keys.KeySequence;
import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* <p>
@@ -56,8 +63,7 @@ import org.junit.runners.JUnit4;
* @see org.eclipse.ui.tests.keys.BindingInteractionsTest
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class BindingManagerTest extends UITestCase {
+public final class BindingManagerTest {
/**
* The binding manager to use in each test case. A new binding manager is
@@ -78,18 +84,11 @@ public final class BindingManagerTest extends UITestCase {
private ContextManager contextManager = null;
/**
- * Constructor for <code>BindingInteractionsTest</code>.
- */
- public BindingManagerTest() {
- super(BindingManagerTest.class.getSimpleName());
- }
-
- /**
* Creates a new context manager and a binding manager for use in the test
* cases.
*/
- @Override
- protected void doSetUp() {
+ @Before
+ public void doSetUp() {
commandManager = new CommandManager();
contextManager = new ContextManager();
bindingManager = new BindingManager(contextManager, commandManager);
@@ -98,8 +97,8 @@ public final class BindingManagerTest extends UITestCase {
/**
* Releases the context manager and binding manager for garbage collection.
*/
- @Override
- protected void doTearDown() {
+ @After
+ public void doTearDown() {
bindingManager = null;
contextManager = null;
commandManager = null;
@@ -108,14 +107,9 @@ public final class BindingManagerTest extends UITestCase {
/**
* Tests that the constructor disallows a null context manager.
*/
- @Test
+ @Test(expected = NullPointerException.class)
public void testConstructor() {
- try {
- new BindingManager(null, null);
- fail("A binding manager cannot be constructed with a null context manager");
- } catch (final NullPointerException e) {
- // Success
- }
+ new BindingManager(null, null);
}
/**
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java
index 0341c33c4fa..7e3a80c31d5 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java
@@ -14,6 +14,12 @@
*******************************************************************************/
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashMap;
import org.eclipse.core.commands.ParameterizedCommand;
@@ -29,15 +35,15 @@ import org.eclipse.jface.util.Util;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test cases covering the various interaction between bindings. Bindings that
@@ -46,28 +52,19 @@ import org.junit.runners.JUnit4;
*
* @since 3.1
*/
-@RunWith(JUnit4.class)
-public final class BindingPersistenceTest extends UITestCase {
+public final class BindingPersistenceTest {
private final String EMACS_SCHEME_ID = "org.eclipse.ui.emacsAcceleratorConfiguration";
private ICommandService commandService;
private IBindingService bindingService;
/**
- * Constructor for <code>BindingPersistenceTest</code>.
- */
- public BindingPersistenceTest() {
- super(BindingPersistenceTest.class.getSimpleName());
- }
-
- /**
* Creates a new workbench and retrieves its context manager and a binding
* manager for use in the test cases.
*/
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
- IWorkbench workbench = openTestWindow().getWorkbench();
+ @Before
+ public void doSetUp() throws Exception {
+ IWorkbench workbench = PlatformUI.getWorkbench();
commandService = workbench.getAdapter(ICommandService.class);
bindingService = workbench.getAdapter(IBindingService.class);
}
@@ -224,7 +221,7 @@ public final class BindingPersistenceTest extends UITestCase {
assertTrue("Unable to find delete marker", foundDeleteMarker);
// make sure that the proper contexts are currently active
- IContextService contextService = fWorkbench
+ IContextService contextService = PlatformUI.getWorkbench()
.getService(IContextService.class);
contextService
.activateContext(IContextService.CONTEXT_ID_DIALOG_AND_WINDOW);
@@ -322,7 +319,7 @@ public final class BindingPersistenceTest extends UITestCase {
assertNotNull(editorBinding);
assertEquals(activateEditorCmd, editorBinding.getParameterizedCommand());
- EBindingService ebs = fWorkbench
+ EBindingService ebs = PlatformUI.getWorkbench()
.getService(EBindingService.class);
HashMap<String, String> attrs = new HashMap<>();
attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
@@ -394,7 +391,7 @@ public final class BindingPersistenceTest extends UITestCase {
assertNotNull(editorBinding);
assertEquals(activateEditorCmd, editorBinding.getParameterizedCommand());
- EBindingService ebs = fWorkbench.getService(EBindingService.class);
+ EBindingService ebs = PlatformUI.getWorkbench().getService(EBindingService.class);
HashMap<String, String> attrs = new HashMap<>();
attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
final Binding localAboutBinding = ebs.createBinding(keyF12, aboutCmd,
@@ -445,7 +442,7 @@ public final class BindingPersistenceTest extends UITestCase {
findAndReplaceBinding.getParameterizedCommand());
assertEquals(EMACS_SCHEME_ID, findAndReplaceBinding.getSchemeId());
- EBindingService ebs = fWorkbench.getService(EBindingService.class);
+ EBindingService ebs = PlatformUI.getWorkbench().getService(EBindingService.class);
HashMap<String, String> attrs = new HashMap<>();
attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
attrs.put(EBindingService.SCHEME_ID_ATTR_TAG, EMACS_SCHEME_ID);
@@ -571,8 +568,8 @@ public final class BindingPersistenceTest extends UITestCase {
assertEquals(EMACS_SCHEME_ID, pasteBinding.getSchemeId());
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
WorkbenchPlugin.getDefault().getPreferenceStore().setValue(
"org.eclipse.ui.commands",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><org.eclipse.ui.commands><activeKeyConfiguration keyConfigurationId=\""
@@ -585,6 +582,5 @@ public final class BindingPersistenceTest extends UITestCase {
final Binding[] originalBindings = bindingService.getBindings();
bindingService.savePreferences(activeScheme, originalBindings);
bindingService = null;
- super.doTearDown();
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36420Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36420Test.java
index bc460c33bbd..07ecdfb85db 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36420Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36420Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertTrue;
+
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
@@ -28,31 +30,21 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.eclipse.core.runtime.Preferences;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandManager;
import org.eclipse.ui.internal.IWorkbenchConstants;
import org.eclipse.ui.keys.KeySequence;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests Bug 36420
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
@Ignore("This no longer works due to focus issues related to key bindings")
// See commit f4f9a6680173270f913891b1d2a8b5f05854b6f4
-public class Bug36420Test extends UITestCase {
-
- /**
- * Constructor for Bug36420Test.
- */
- public Bug36420Test() {
- super(Bug36420Test.class.getSimpleName());
- }
+public class Bug36420Test {
/**
* Tests that importing key preferences actually has an effect.
@@ -105,7 +97,7 @@ public class Bug36420Test extends UITestCase {
*/
// Check to see that the key binding for the given command matches.
- ICommandManager manager = fWorkbench.getCommandSupport()
+ ICommandManager manager = PlatformUI.getWorkbench().getCommandSupport()
.getCommandManager();
List<KeySequence> keyBindings = manager.getCommand(commandId)
.getKeySequenceBindings();
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36537Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36537Test.java
index ad4134d6a1a..4c87321ff7d 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36537Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug36537Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertFalse;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -28,23 +30,13 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests Bug 36537
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug36537Test extends UITestCase {
-
- /**
- * Constructor for Bug36537Test.
- */
- public Bug36537Test() {
- super(Bug36537Test.class.getSimpleName());
- }
+public class Bug36537Test {
/**
* Tests that there are no redundant key bindings defined in the
@@ -52,7 +44,7 @@ public class Bug36537Test extends UITestCase {
*/
@Test
public void testForRedundantKeySequenceBindings() {
- final IWorkbenchWindow window = openTestWindow();
+ final IWorkbenchWindow window = UITestCase.openTestWindow();
final IWorkbench workbench = window.getWorkbench();
final IBindingService bindingService = workbench.getAdapter(IBindingService.class);
final Binding[] bindings = bindingService.getBindings();
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug40023Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug40023Test.java
index 6c9b51b092d..eae7b29179a 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug40023Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug40023Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertTrue;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
@@ -33,17 +35,14 @@ import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests Bug 40023
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
@Ignore("Intermittent failure. SWT Bug 44344. XGrabPointer?")
-public class Bug40023Test extends UITestCase {
+public class Bug40023Test {
/**
* Retrieves a menu item matching or starting with the given name from an
@@ -66,13 +65,6 @@ public class Bug40023Test extends UITestCase {
}
/**
- * Constructor for Bug40023Test.
- */
- public Bug40023Test() {
- super(Bug40023Test.class.getSimpleName());
- }
-
- /**
* Tests that check box items on the menu are checked when activated from
* the keyboard.
*
@@ -93,7 +85,7 @@ public class Bug40023Test extends UITestCase {
public void testCheckOnCheckbox() throws CoreException, CommandException,
FileNotFoundException, IOException, ParseException {
// Open a window to run the test.
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
Workbench workbench = (Workbench) window.getWorkbench();
// Set up a key binding for "Lock Toolbars".
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42024Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42024Test.java
index 30e941423f6..e5ef06d45fc 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42024Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42024Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.jface.bindings.keys.KeySequence;
import org.eclipse.jface.bindings.keys.KeySequenceText;
import org.eclipse.jface.bindings.keys.ParseException;
@@ -22,18 +24,16 @@ import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests Bug 42024
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug42024Test extends UITestCase {
+public class Bug42024Test {
/** The shell on which the <code>KeySequenceText</code> is placed. */
private Shell shell = null;
@@ -41,20 +41,8 @@ public class Bug42024Test extends UITestCase {
/** The instance of <code>KeySequenceText</code> we should tinker with. */
private KeySequenceText text = null;
- /**
- * Constructor for Bug42024Test.
- */
- public Bug42024Test() {
- super(Bug42024Test.class.getSimpleName());
- }
-
- /*
- * @see TestCase#setUp()
- */
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
-
+ @Before
+ public void doSetUp() throws Exception {
// Create a window with a KeySequenceText
Display display = Display.getCurrent();
shell = new Shell(display);
@@ -66,10 +54,8 @@ public class Bug42024Test extends UITestCase {
shell.open();
}
- @Override
- protected void doTearDown() throws Exception {
- super.doTearDown();
-
+ @After
+ public void doTearDown() throws Exception {
// Close and destroy the window
shell.close();
shell.dispose();
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java
index 434bc79ba10..325b268b7f3 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42035Test.java
@@ -14,23 +14,21 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.keys.KeyStroke;
import org.eclipse.ui.keys.ParseException;
import org.eclipse.ui.keys.SWTKeySupport;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test for Bug 42035.
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug42035Test extends UITestCase {
+public class Bug42035Test {
/**
* Tests the given key event to see if generates the three key strokes
@@ -79,13 +77,6 @@ public class Bug42035Test extends UITestCase {
}
/**
- * Constructs a new instance of this test case.
- */
- public Bug42035Test() {
- super(Bug42035Test.class.getSimpleName());
- }
-
- /**
* Tests that "Ctrl+" generates "Ctrl+", "Ctrl+" and "Ctrl+".
*
* @throws ParseException
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42627Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42627Test.java
index bdfe5306cc8..0a3e61f9d80 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42627Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug42627Test.java
@@ -15,20 +15,16 @@
package org.eclipse.ui.tests.keys;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests Bug 42627
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
@Ignore("Logging piece of fix did not go in M4.") // See commit 74a677140dd3fc6a09fa1c769c0af2cac3c1c08b
-public class Bug42627Test extends UITestCase {
+public class Bug42627Test {
// TODO See if this is needed for anything.
// private class DummyView extends ViewPart {
@@ -50,18 +46,6 @@ public class Bug42627Test extends UITestCase {
// // Nothing to implement
// }
// private boolean logged;
- /**
- * Constructor for Bug42627Test.
- */
- public Bug42627Test(String name) {
- super(Bug42627Test.class.getSimpleName());
- }
-
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
- // logged = false;
- }
/**
* Tests that actions with no defined command ID are logged.
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43168Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43168Test.java
index cbeedcb39e6..79f7ba98ec0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43168Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43168Test.java
@@ -22,25 +22,14 @@ import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests Bug 43168
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug43168Test extends UITestCase {
-
- /**
- * Constructor for Bug43168Test.
- */
- public Bug43168Test() {
- super(Bug43168Test.class.getSimpleName());
- }
+public class Bug43168Test {
/**
* Tests that a <code>StackOverflowError</code> does not occur when
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43321Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43321Test.java
index 19b41817198..999b272d557 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43321Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43321Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.List;
@@ -37,23 +39,13 @@ import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests Bug 43321
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug43321Test extends UITestCase {
-
- /**
- * Constructor for Bug43321Test.
- */
- public Bug43321Test() {
- super(Bug43321Test.class.getSimpleName());
- }
+public class Bug43321Test {
/**
* Tests that non-check box items on the menu are not checked when activated
@@ -69,7 +61,7 @@ public class Bug43321Test extends UITestCase {
@Test
public void testNoCheckOnNonCheckbox() throws CommandException,
CoreException, ParseException {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject testProject = workspace.getRoot().getProject("TestProject"); //$NON-NLS-1$
testProject.create(null);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43538Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43538Test.java
index 426f8af5bd3..6aee202c5d9 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43538Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43538Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
@@ -22,25 +24,14 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.tests.harness.util.AutomationUtil;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test for Bug 43538.
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug43538Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- */
- public Bug43538Test() {
- super(Bug43538Test.class.getSimpleName());
- }
+public class Bug43538Test {
/**
* Tests that if "Ctrl+Space" is pressed only one key down event with the
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43597Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43597Test.java
index 904d610fe44..f0f88d01a20 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43597Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43597Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
@@ -21,29 +23,19 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests Bug 43597
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug43597Test extends UITestCase {
+public class Bug43597Test {
private Font textFont;
/**
- * Constructor for Bug43597Test.
- */
- public Bug43597Test() {
- super(Bug43597Test.class.getSimpleName());
- }
-
- /**
* Tests that setting the text on a text widget to an empty string does not
* reset the font. This was a problem only on carbon.
*/
@@ -81,11 +73,10 @@ public class Bug43597Test extends UITestCase {
shell.dispose();
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
if (textFont != null) {
textFont.dispose();
}
- super.doTearDown();
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43610Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43610Test.java
index 3cf450cd405..304dab34e54 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43610Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43610Test.java
@@ -14,31 +14,22 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.tests.harness.util.AutomationUtil;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test for Bug 43610.
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug43610Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- */
- public Bug43610Test() {
- super(Bug43610Test.class.getSimpleName());
- }
+public class Bug43610Test {
/**
* Tests that if "Shift+Alt+" is pressed, then the key code should
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java
index 0f766cab3e8..904ea5e28ef 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43800Test.java
@@ -14,28 +14,19 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.keys.SWTKeySupport;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test for Bug 43800.
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
-public class Bug43800Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- */
- public Bug43800Test() {
- super(Bug43800Test.class.getSimpleName());
- }
+public class Bug43800Test {
/**
* Tests that key pressed with key codes greater than 16 bits are correctly
@@ -44,8 +35,7 @@ public class Bug43800Test extends UITestCase {
@Test
public void testTruncatingCast() {
/*
- * Make an event representing a key stroke with a key code greater than
- * 16 bits.
+ * Make an event representing a key stroke with a key code greater than 16 bits.
*/
Event event = new Event();
event.keyCode = SWT.ARROW_LEFT;
@@ -53,8 +43,7 @@ public class Bug43800Test extends UITestCase {
event.stateMask = 0x00;
// Convert the event, and test the resulting accelerator value.
- int accelerator = SWTKeySupport
- .convertEventToUnmodifiedAccelerator(event);
+ int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event);
assertEquals("Arrow_Left key truncated.", SWT.ARROW_LEFT, accelerator); //$NON-NLS-1$
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug44460Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug44460Test.java
index 74910e8fa5b..e22e7a5c96f 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug44460Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug44460Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.util.List;
@@ -26,6 +28,7 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
@@ -42,27 +45,14 @@ import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Test for Bug 44460.
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
@Ignore("disabled since it refers to the Java builder and nature, which are not available in an RCP build")
-public class Bug44460Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- *
- * @param testName
- * The name of the test
- */
- public Bug44460Test(String testName) {
- super(Bug44460Test.class.getSimpleName());
- }
+public class Bug44460Test {
/**
* Test that pressing "Ctrl+Shift+T" in the Team Synchronizing perspective
@@ -76,7 +66,7 @@ public class Bug44460Test extends UITestCase {
@Test
public void testCtrlShiftT() throws CommandException, CoreException {
// Open a new test window.
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
// Open a new Java project, with a new class.
IWorkspace workspace = ResourcesPlugin.getWorkspace();
@@ -111,7 +101,7 @@ public class Bug44460Test extends UITestCase {
ctrlShiftT.stateMask = SWT.SHIFT | SWT.CTRL;
ctrlShiftT.character = 'T';
ctrlShiftT.keyCode = 't';
- List keyStrokes = WorkbenchKeyboard
+ List<KeyStroke> keyStrokes = WorkbenchKeyboard
.generatePossibleKeyStrokes(ctrlShiftT);
Workbench workbench = (Workbench) window.getWorkbench();
BindingService support = (BindingService) workbench
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug53489Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug53489Test.java
index 93c5c0016c4..28cdd11e35f 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug53489Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug53489Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.keys;
+import static org.junit.Assert.assertTrue;
+
import java.awt.AWTException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -34,8 +36,6 @@ import org.eclipse.ui.tests.harness.util.AutomationUtil;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests that pressing delete in a styled text widget does not cause a double
@@ -43,50 +43,31 @@ import org.junit.runners.JUnit4;
*
* @since 3.0
*/
-@RunWith(JUnit4.class)
@Ignore("disabled as it fails on the Mac.")
// Ctrl+S doesn't save the editor, and posting MOD1+S also doesn't seem to work.
-public class Bug53489Test extends UITestCase {
-
- /**
- * Constructor for Bug53489Test.
- *
- * @param name
- * The name of the test
- */
- public Bug53489Test(String name) {
- super(Bug53489Test.class.getSimpleName());
- }
+public class Bug53489Test {
/**
- * Tests that pressing delete in a styled text widget (in a running
- * Eclipse) does not cause a double delete.
+ * Tests that pressing delete in a styled text widget (in a running Eclipse)
+ * does not cause a double delete.
*
- * @throws AWTException
- * If the creation of robot
- * @throws CommandException
- * If execution of the handler fails.
- * @throws CoreException
- * If the test project cannot be created and opened.
- * @throws IOException
- * If the file cannot be read.
+ * @throws AWTException If the creation of robot
+ * @throws CommandException If execution of the handler fails.
+ * @throws CoreException If the test project cannot be created and opened.
+ * @throws IOException If the file cannot be read.
*/
@Test
- public void testDoubleDelete() throws CommandException,
- CoreException, IOException {
- IWorkbenchWindow window = openTestWindow();
+ public void testDoubleDelete() throws CommandException, CoreException, IOException {
+ IWorkbenchWindow window = UITestCase.openTestWindow();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IProject testProject = workspace.getRoot().getProject(
- "DoubleDeleteestProject"); //$NON-NLS-1$
+ IProject testProject = workspace.getRoot().getProject("DoubleDeleteestProject"); //$NON-NLS-1$
testProject.create(null);
testProject.open(null);
IFile textFile = testProject.getFile("A.txt"); //$NON-NLS-1$
String originalContents = "A blurb"; //$NON-NLS-1$
- ByteArrayInputStream inputStream = new ByteArrayInputStream(
- originalContents.getBytes());
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(originalContents.getBytes());
textFile.create(inputStream, true, null);
- IDE.openEditor(window.getActivePage(), textFile,
- true);
+ IDE.openEditor(window.getActivePage(), textFile, true);
// Allow the editor to finish opening.
Display display = Display.getCurrent();
@@ -96,8 +77,8 @@ public class Bug53489Test extends UITestCase {
AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, SWT.DEL);
AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, SWT.DEL);
AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, SWT.CTRL);
- AutomationUtil.performCharacterEvent(display, SWT.KeyDown,'S');
- AutomationUtil.performCharacterEvent(display, SWT.KeyUp,'S');
+ AutomationUtil.performCharacterEvent(display, SWT.KeyDown, 'S');
+ AutomationUtil.performCharacterEvent(display, SWT.KeyUp, 'S');
AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, SWT.CTRL);
// Spin the event loop.
@@ -105,8 +86,7 @@ public class Bug53489Test extends UITestCase {
}
// Test the text is only one character different.
- LineNumberReader reader = new LineNumberReader(new InputStreamReader(
- textFile.getContents()));
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(textFile.getContents()));
String currentContents = reader.readLine();
assertTrue("'DEL' deleted more than one key.", (originalContents //$NON-NLS-1$
.length() == (currentContents.length() + 1)));
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/DispatcherTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/DispatcherTest.java
index c38aee382bc..34753972e59 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/DispatcherTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/DispatcherTest.java
@@ -26,45 +26,40 @@ import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.tests.commands.CheckInvokedHandler;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-@RunWith(JUnit4.class)
-public class DispatcherTest extends UITestCase {
+public class DispatcherTest {
private KeyBindingDispatcher dispatcher;
private IProject p;
- @Override
+ @Before
public void doSetUp() throws CoreException {
- this.dispatcher = getWorkbench().getService(KeyBindingDispatcher.class);
+ this.dispatcher = PlatformUI.getWorkbench().getService(KeyBindingDispatcher.class);
CheckInvokedHandler.invoked = false;
p = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.currentTimeMillis());
p.create(new NullProgressMonitor());
p.open(new NullProgressMonitor());
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
p.delete(true, new NullProgressMonitor());
}
- public DispatcherTest() {
- super(DispatcherTest.class.getSimpleName());
- }
-
@Test
public void testDispatcherMultipleDisabledCommands() throws Exception {
IFile file = p.getFile("test.whatever");
try (ByteArrayInputStream stream = new ByteArrayInputStream("hello".getBytes())) {
file.create(stream, true, new NullProgressMonitor());
}
- IEditorPart part = IDE.openEditor(getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
+ IEditorPart part = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
try {
int shellCount = Display.getCurrent().getShells().length;
dispatcher.press(Arrays.asList(KeyStroke.getInstance(SWT.CTRL, 'O')), null);
@@ -83,7 +78,7 @@ public class DispatcherTest extends UITestCase {
try (ByteArrayInputStream stream = new ByteArrayInputStream("hello".getBytes())) {
file.create(stream, true, new NullProgressMonitor());
}
- IEditorPart part = IDE.openEditor(getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
+ IEditorPart part = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
try {
int shellCount = Display.getCurrent().getShells().length;
dispatcher.press(Arrays.asList(KeyStroke.getInstance(SWT.CTRL, 'O')), null);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug231304Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug231304Test.java
index 4b746b697ae..d85efe576ef 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug231304Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug231304Test.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.menus;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.bindings.keys.KeySequence;
@@ -23,8 +25,6 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.menus.IMenuService;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
*
@@ -32,23 +32,16 @@ import org.junit.runners.JUnit4;
* @author Prakash G.R.
*
*/
-@RunWith(JUnit4.class)
-public class Bug231304Test extends UITestCase {
-
- public Bug231304Test() {
- super(Bug231304Test.class.getSimpleName());
- }
+public class Bug231304Test {
@Test
public void testToolTip() throws Exception {
- IWorkbenchWindow window = openTestWindow();
- IMenuService menus = window
- .getService(IMenuService.class);
+ IWorkbenchWindow window = UITestCase.openTestWindow();
+ IMenuService menus = window.getService(IMenuService.class);
ToolBarManager manager = new ToolBarManager();
try {
// populate contribution
- menus.populateContributionManager(manager,
- "toolbar:org.eclipse.ui.tests.tooltipTest");
+ menus.populateContributionManager(manager, "toolbar:org.eclipse.ui.tests.tooltipTest");
IContributionItem[] items = manager.getItems();
assertEquals(1, items.length);
ToolBar toolBar = manager.createControl(window.getShell());
@@ -58,8 +51,7 @@ public class Bug231304Test extends UITestCase {
ToolItem[] toolItems = toolBar.getItems();
assertEquals(1, toolItems.length);
String keys = KeySequence.getInstance("M2+M3+1").format();
- assertEquals("My Test Tooltip Command (" + keys + ")", toolItems[0]
- .getToolTipText());
+ assertEquals("My Test Tooltip Command (" + keys + ")", toolItems[0].getToolTipText());
} finally {
menus.releaseContributions(manager);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java
index b8ebe47ecf4..8a6903afee9 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java
@@ -14,6 +14,10 @@
package org.eclipse.ui.tests.menus;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -28,24 +32,17 @@ import org.eclipse.ui.tests.api.ListElement;
import org.eclipse.ui.tests.api.ListView;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @since 3.5
* @author Prakash G.R.
*
*/
-@RunWith(JUnit4.class)
-public class Bug264804Test extends UITestCase {
-
- public Bug264804Test() {
- super(Bug264804Test.class.getSimpleName());
- }
+public class Bug264804Test {
@Test
public void testPopup() throws Exception {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
ListView part = (ListView) window.getActivePage().showView(
"org.eclipse.ui.tests.api.IActionFilterTest1");
@@ -71,7 +68,7 @@ public class Bug264804Test extends UITestCase {
// contextMenu.setVisible(true);
Event e = new Event();
e.widget = contextMenu;
- processEvents();
+ UITestCase.processEvents();
contextMenu.notifyListeners(SWT.Show, e);
find("org.eclipse.ui.file.close", manager.getItems());
@@ -81,7 +78,7 @@ public class Bug264804Test extends UITestCase {
// to run
contextMenu.notifyListeners(SWT.Hide, e);
contextMenu.notifyListeners(SWT.Show, e);
- processEvents();
+ UITestCase.processEvents();
find("org.eclipse.ui.file.close", manager.getItems());
} finally {
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug410426Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug410426Test.java
index 9c3a9aa5346..082844cf11d 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug410426Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug410426Test.java
@@ -13,6 +13,10 @@
*******************************************************************************/
package org.eclipse.ui.tests.menus;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
@@ -26,24 +30,17 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.menus.IMenuService;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
import org.osgi.service.log.LogListener;
import org.osgi.service.log.LogService;
/**
* @author Maxime Porhel
*/
-@RunWith(JUnit4.class)
-public class Bug410426Test extends UITestCase {
-
- public Bug410426Test() {
- super(Bug410426Test.class.getSimpleName());
- }
+public class Bug410426Test {
@Test
public void testToolbarContributionFromFactoryVisibility() throws Exception {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
IMenuService menus = window.getService(IMenuService.class);
ToolBarManager manager = new ToolBarManager();
@@ -94,7 +91,7 @@ public class Bug410426Test extends UITestCase {
@Test
public void testNoClassCastExceptionForMenuManagerToolbarContribution() throws Exception {
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
IMenuService menus = window.getService(IMenuService.class);
ToolBarManager manager = new ToolBarManager();
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multieditor/AbstractMultiEditorTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multieditor/AbstractMultiEditorTest.java
index 820990ec158..4136ebb4fc0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multieditor/AbstractMultiEditorTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multieditor/AbstractMultiEditorTest.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ui.tests.multieditor;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
@@ -37,6 +40,7 @@ import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.WorkbenchPage;
import org.eclipse.ui.internal.WorkbenchPlugin;
@@ -44,12 +48,13 @@ import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.MultiEditorInput;
import org.eclipse.ui.tests.TestPlugin;
import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
-public class AbstractMultiEditorTest extends UITestCase {
+public class AbstractMultiEditorTest {
private static final String PROJECT_NAME = "TiledEditorProject";
@@ -64,15 +69,11 @@ public class AbstractMultiEditorTest extends UITestCase {
private EditorErrorListener fErrorListener;
- public AbstractMultiEditorTest() {
- super(AbstractMultiEditorTest.class.getSimpleName());
- }
-
@Test
public void testBug317102() throws Throwable {
final String[] simpleFiles = { TEST01_TXT, TEST03_ETEST };
- IWorkbenchWindow window = openTestWindow();
+ IWorkbenchWindow window = UITestCase.openTestWindow();
WorkbenchPage page = (WorkbenchPage) window.getActivePage();
IProject testProject = findOrCreateProject(PROJECT_NAME);
@@ -151,7 +152,7 @@ public class AbstractMultiEditorTest extends UITestCase {
IProject testProject) throws CoreException, IOException {
String[] ids = new String[simpleFiles.length];
IEditorInput[] inputs = new IEditorInput[simpleFiles.length];
- IEditorRegistry registry = fWorkbench.getEditorRegistry();
+ IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
for (int f = 0; f < simpleFiles.length; ++f) {
IFile f1 = createFile(testProject, simpleFiles[f]);
@@ -195,10 +196,9 @@ public class AbstractMultiEditorTest extends UITestCase {
/**
* Close any editors at the beginner of a test, so the test can be clean.
*/
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
- IWorkbenchPage page = fWorkbench.getActiveWorkbenchWindow()
+ @Before
+ public void doSetUp() throws Exception {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage();
page.closeAllEditors(false);
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DeprecatedFontPreferenceTestCase.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DeprecatedFontPreferenceTestCase.java
index db30aeec337..9b84a6f0244 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DeprecatedFontPreferenceTestCase.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DeprecatedFontPreferenceTestCase.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.ui.tests.preferences;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.FontRegistry;
@@ -21,19 +23,14 @@ import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
- * The FontPreferenceTestCase tests adding fonts to
- * the preference store and what occurs if the values
- * are bogus
+ * The FontPreferenceTestCase tests adding fonts to the preference store and
+ * what occurs if the values are bogus
*/
-
-@RunWith(JUnit4.class)
-public class DeprecatedFontPreferenceTestCase extends UITestCase {
+public class DeprecatedFontPreferenceTestCase {
public String BAD_FONT_DEFINITION = "BadFont-regular-10";
@@ -43,93 +40,71 @@ public class DeprecatedFontPreferenceTestCase extends UITestCase {
private IPreferenceStore preferenceStore;
- /**
- * Constructor for FontPreferenceTestCase.
- */
- public DeprecatedFontPreferenceTestCase() {
- super(DeprecatedFontPreferenceTestCase.class.getSimpleName());
- }
-
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
+ @Before
+ public void doSetUp() throws Exception {
AbstractUIPlugin plugin = WorkbenchPlugin.getDefault();
preferenceStore = plugin.getPreferenceStore();
- //Set up the bogus entry for the bad first test
+ // Set up the bogus entry for the bad first test
FontData bogusData = new FontData();
bogusData.setName("BadData");
bogusData.setHeight(11);
FontData[] storedValue = new FontData[2];
- //We assume here that the text font is OK
+ // We assume here that the text font is OK
storedValue[0] = bogusData;
- storedValue[1] = (PreferenceConverter.getDefaultFontDataArray(
- preferenceStore, JFaceResources.TEXT_FONT))[0];
- PreferenceConverter
- .setValue(preferenceStore, TEST_FONT_ID, storedValue);
- PreferenceConverter.setDefault(preferenceStore, TEST_FONT_ID,
- storedValue);
+ storedValue[1] = (PreferenceConverter.getDefaultFontDataArray(preferenceStore, JFaceResources.TEXT_FONT))[0];
+ PreferenceConverter.setValue(preferenceStore, TEST_FONT_ID, storedValue);
+ PreferenceConverter.setDefault(preferenceStore, TEST_FONT_ID, storedValue);
}
/**
- * Test for a valid font like the test font. The first good one
- * we should find should be the first one in the list.
+ * Test for a valid font like the test font. The first good one we should find
+ * should be the first one in the list.
*/
-
@Test
public void testGoodFontDefinition() {
FontRegistry fontRegistry = JFaceResources.getFontRegistry();
- FontData[] currentTextFonts = PreferenceConverter.getFontDataArray(
- preferenceStore, JFaceResources.TEXT_FONT);
- FontData bestFont = fontRegistry.filterData(currentTextFonts, Display
- .getCurrent())[0];
+ FontData[] currentTextFonts = PreferenceConverter.getFontDataArray(preferenceStore, JFaceResources.TEXT_FONT);
+ FontData bestFont = fontRegistry.filterData(currentTextFonts, Display.getCurrent())[0];
- //Assert that it is the first font that we get as the
- //valid one
+ // Assert that it is the first font that we get as the
+ // valid one
assertEquals(bestFont.getName(), currentTextFonts[0].getName());
assertEquals(bestFont.getHeight(), currentTextFonts[0].getHeight());
}
/**
- * Test that if the first font in the list is bad that the
- * second one comes back as valid.
+ * Test that if the first font in the list is bad that the second one comes back
+ * as valid.
*/
-
@Test
public void testBadFirstFontDefinition() {
FontRegistry fontRegistry = JFaceResources.getFontRegistry();
- FontData[] currentTestFonts = PreferenceConverter.getFontDataArray(
- preferenceStore, TEST_FONT_ID);
- FontData bestFont = fontRegistry.filterData(currentTestFonts, Display
- .getCurrent())[0];
+ FontData[] currentTestFonts = PreferenceConverter.getFontDataArray(preferenceStore, TEST_FONT_ID);
+ FontData bestFont = fontRegistry.filterData(currentTestFonts, Display.getCurrent())[0];
- //Assert that it is the second font that we get as the
- //valid one
+ // Assert that it is the second font that we get as the
+ // valid one
assertEquals(bestFont.getName(), currentTestFonts[1].getName());
assertEquals(bestFont.getHeight(), currentTestFonts[1].getHeight());
}
/**
- * Test that the no valid font is returned when the entry
- * is missing.
+ * Test that the no valid font is returned when the entry is missing.
*/
-
@Test
public void testNoFontDefinition() {
FontRegistry fontRegistry = JFaceResources.getFontRegistry();
- FontData[] currentTestFonts = PreferenceConverter.getFontDataArray(
- preferenceStore, MISSING_FONT_ID);
- FontData bestFont = fontRegistry.filterData(currentTestFonts, Display
- .getCurrent())[0];
+ FontData[] currentTestFonts = PreferenceConverter.getFontDataArray(preferenceStore, MISSING_FONT_ID);
+ FontData bestFont = fontRegistry.filterData(currentTestFonts, Display.getCurrent())[0];
- FontData[] systemFontData = Display.getCurrent().getSystemFont()
- .getFontData();
+ FontData[] systemFontData = Display.getCurrent().getSystemFont().getFontData();
- //Assert that the first font is the system font
+ // Assert that the first font is the system font
assertEquals(bestFont.getName(), systemFontData[0].getName());
assertEquals(bestFont.getHeight(), systemFontData[0].getHeight());
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DialogSettingsCustomizationTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DialogSettingsCustomizationTest.java
index f73c753e13e..c750dc4b6d0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DialogSettingsCustomizationTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/DialogSettingsCustomizationTest.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ui.tests.preferences;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.lang.reflect.Field;
import java.net.URL;
import java.nio.file.Files;
@@ -20,16 +23,15 @@ import java.nio.file.Path;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.preference.PreferenceMemento;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.tests.TestPlugin;
-import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-@RunWith(JUnit4.class)
-public class DialogSettingsCustomizationTest extends UITestCase {
+public class DialogSettingsCustomizationTest {
// See AbstractUIPlugin
private static final String KEY_DEFAULT_DIALOG_SETTINGS_ROOTURL = "default_dialog_settings_rootUrl"; //$NON-NLS-1$
@@ -40,14 +42,10 @@ public class DialogSettingsCustomizationTest extends UITestCase {
private TestPlugin testPlugin;
private Path dialogSettingsPathBackup;
private String rootUrlValue;
+ private PreferenceMemento memento;
- public DialogSettingsCustomizationTest() {
- super(DialogSettingsCustomizationTest.class.getSimpleName());
- }
-
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
+ @Before
+ public void doSetUp() throws Exception {
testPlugin = TestPlugin.getDefault();
rootUrlValue = "platform:/plugin/" + testPlugin.getBundle().getSymbolicName() + "/data/dialog_settings_root";
dialogSettingsPath = testPlugin.getStateLocation().append(FN_DIALOG_SETTINGS).toFile().toPath();
@@ -59,22 +57,23 @@ public class DialogSettingsCustomizationTest extends UITestCase {
settingsField = AbstractUIPlugin.class.getDeclaredField("dialogSettings");
settingsField.setAccessible(true);
settingsField.set(testPlugin, null);
+ memento = new PreferenceMemento();
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
Files.deleteIfExists(dialogSettingsPath);
if (Files.exists(dialogSettingsPathBackup)) {
Files.move(dialogSettingsPathBackup, dialogSettingsPath);
}
settingsField.set(testPlugin, null);
- super.doTearDown();
+ memento.resetPreferences();
}
@Test
public void testDialogSettingsContributedByBundle() throws Exception {
assertDefaultBundleValueIsSet();
- setPreference(PlatformUI.getPreferenceStore(), KEY_DEFAULT_DIALOG_SETTINGS_ROOTURL, rootUrlValue);
+ memento.setValue(PlatformUI.getPreferenceStore(), KEY_DEFAULT_DIALOG_SETTINGS_ROOTURL, rootUrlValue);
assertCustomValueIsSet();
}
@@ -82,7 +81,7 @@ public class DialogSettingsCustomizationTest extends UITestCase {
public void testDialogSettingsContributedByFileUrl() throws Exception {
String rootUrl = FileLocator.toFileURL(new URL(rootUrlValue)).toString();
assertDefaultBundleValueIsSet();
- setPreference(PlatformUI.getPreferenceStore(), KEY_DEFAULT_DIALOG_SETTINGS_ROOTURL, rootUrl);
+ memento.setValue(PlatformUI.getPreferenceStore(), KEY_DEFAULT_DIALOG_SETTINGS_ROOTURL, rootUrl);
assertCustomValueIsSet();
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/AccumulatingProgressMonitorTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/AccumulatingProgressMonitorTest.java
index 03b6f2cf056..ef93d67704c 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/AccumulatingProgressMonitorTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/AccumulatingProgressMonitorTest.java
@@ -13,6 +13,12 @@
*******************************************************************************/
package org.eclipse.ui.tests.progress;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.concurrent.Semaphore;
@@ -21,7 +27,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.operation.ProgressMonitorUtil;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -36,11 +41,7 @@ import org.junit.runners.JUnit4;
*
*/
@RunWith(JUnit4.class)
-public class AccumulatingProgressMonitorTest extends UITestCase {
-
- public AccumulatingProgressMonitorTest() {
- super(AccumulatingProgressMonitorTest.class.getName());
- }
+public class AccumulatingProgressMonitorTest {
/*
* A monitor to be wrapped. This monitor's methods assert that each method
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/quickaccess/ContentMatchesTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/quickaccess/ContentMatchesTest.java
index 1273790e925..b6d46ff97e6 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/quickaccess/ContentMatchesTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/quickaccess/ContentMatchesTest.java
@@ -14,6 +14,8 @@
package org.eclipse.ui.tests.quickaccess;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@@ -26,40 +28,31 @@ import org.eclipse.ui.internal.quickaccess.QuickAccessDialog;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.hamcrest.Matchers;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Tests the content of quick access for given requests
*
* @since 3.14
*/
-@RunWith(JUnit4.class)
-public class ContentMatchesTest extends UITestCase {
+public class ContentMatchesTest {
private static final int TIMEOUT = 3000;
private QuickAccessDialog dialog;
private QuickAccessContents quickAccessContents;
- /**
- * @param testName
- */
- public ContentMatchesTest() {
- super(ContentMatchesTest.class.getSimpleName());
- }
-
- @Override
- protected void doSetUp() throws Exception {
- super.doSetUp();
- IWorkbenchWindow window = openTestWindow();
+ @Before
+ public void doSetUp() throws Exception {
+ IWorkbenchWindow window = UITestCase.openTestWindow();
dialog = new QuickAccessDialog(window, null);
quickAccessContents = dialog.getQuickAccessContents();
dialog.open();
}
- @Override
- protected void doTearDown() throws Exception {
+ @After
+ public void doTearDown() throws Exception {
dialog.close();
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/ContributedServiceTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/ContributedServiceTest.java
index 7d84b06c84c..1ed7e847cf9 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/ContributedServiceTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/ContributedServiceTest.java
@@ -15,9 +15,16 @@
package org.eclipse.ui.tests.services;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.services.IServiceLocatorCreator;
import org.eclipse.ui.internal.services.IWorkbenchLocationService;
import org.eclipse.ui.internal.services.WorkbenchLocationService;
@@ -30,29 +37,20 @@ import org.eclipse.ui.services.IServiceScopes;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @since 3.4
*
*/
-@RunWith(JUnit4.class)
-public class ContributedServiceTest extends UITestCase {
-
- public ContributedServiceTest() {
- super(ContributedServiceTest.class.getName());
- }
+public class ContributedServiceTest {
@Test
public void testGlobalService() throws Exception {
- IWorkbenchLocationService wls = getWorkbench()
- .getService(IWorkbenchLocationService.class);
+ IWorkbenchLocationService wls = getWorkbench().getService(IWorkbenchLocationService.class);
assertNotNull(wls.getWorkbench());
assertNull(wls.getWorkbenchWindow());
- ILevelService l = getWorkbench().getService(
- ILevelService.class);
+ ILevelService l = getWorkbench().getService(ILevelService.class);
assertNotNull(l);
assertEquals(1, l.getLevel());
@@ -63,16 +61,18 @@ public class ContributedServiceTest extends UITestCase {
assertEquals(1, LevelServiceFactory.instancesCreated);
}
+ private IWorkbench getWorkbench() {
+ return PlatformUI.getWorkbench();
+ }
+
@Test
@Ignore // TODO
public void testWindowService() throws Exception {
IServiceLocator locator = getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchLocationService wls = locator
- .getService(IWorkbenchLocationService.class);
+ IWorkbenchLocationService wls = locator.getService(IWorkbenchLocationService.class);
assertNotNull(wls.getWorkbenchWindow());
- ILevelService l = locator
- .getService(ILevelService.class);
+ ILevelService l = locator.getService(ILevelService.class);
assertNotNull(l);
assertEquals(2, l.getLevel());
@@ -97,8 +97,7 @@ public class ContributedServiceTest extends UITestCase {
}
@Override
- public Object create(Class serviceInterface,
- IServiceLocator parentLocator, IServiceLocator locator) {
+ public Object create(Class serviceInterface, IServiceLocator parentLocator, IServiceLocator locator) {
return (ILevelService) () -> level;
}
}
@@ -107,18 +106,14 @@ public class ContributedServiceTest extends UITestCase {
@Ignore // TODO
public void testLocalServiceCreated() throws Exception {
IServiceLocator parent = getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchLocationService wls = parent
- .getService(IWorkbenchLocationService.class);
+ IWorkbenchLocationService wls = parent.getService(IWorkbenchLocationService.class);
assertNotNull(wls.getWorkbenchWindow());
- IServiceLocatorCreator lc = parent
- .getService(IServiceLocatorCreator.class);
- IServiceLocator locator = lc.createServiceLocator(parent, null,
- () -> {
- });
+ IServiceLocatorCreator lc = parent.getService(IServiceLocatorCreator.class);
+ IServiceLocator locator = lc.createServiceLocator(parent, null, () -> {
+ });
- ILevelService l = locator
- .getService(ILevelService.class);
+ ILevelService l = locator.getService(ILevelService.class);
assertNotNull(l);
assertEquals(3, l.getLevel());
@@ -155,29 +150,20 @@ public class ContributedServiceTest extends UITestCase {
@Ignore // TODO
public void testLocalDialogService() throws Exception {
IServiceLocator parent = getWorkbench();
- IServiceLocatorCreator lc = parent
- .getService(IServiceLocatorCreator.class);
- IServiceLocator locator = lc.createServiceLocator(parent,
- new AbstractServiceFactory() {
- @Override
- public Object create(Class serviceInterface,
- IServiceLocator parentLocator,
- IServiceLocator locator) {
- if (IWorkbenchLocationService.class
- .equals(serviceInterface)) {
- IWorkbenchLocationService wls = parentLocator
- .getService(IWorkbenchLocationService.class);
- return new WorkbenchLocationService(
- IServiceScopes.DIALOG_SCOPE, wls
- .getWorkbench(), null, null, null,
- null, wls.getServiceLevel()+1);
- }
- return null;
- }
- }, () -> {
- });
- IWorkbenchLocationService wls = locator
- .getService(IWorkbenchLocationService.class);
+ IServiceLocatorCreator lc = parent.getService(IServiceLocatorCreator.class);
+ IServiceLocator locator = lc.createServiceLocator(parent, new AbstractServiceFactory() {
+ @Override
+ public Object create(Class serviceInterface, IServiceLocator parentLocator, IServiceLocator locator) {
+ if (IWorkbenchLocationService.class.equals(serviceInterface)) {
+ IWorkbenchLocationService wls = parentLocator.getService(IWorkbenchLocationService.class);
+ return new WorkbenchLocationService(IServiceScopes.DIALOG_SCOPE, wls.getWorkbench(), null, null,
+ null, null, wls.getServiceLevel() + 1);
+ }
+ return null;
+ }
+ }, () -> {
+ });
+ IWorkbenchLocationService wls = locator.getService(IWorkbenchLocationService.class);
assertNotNull(wls.getWorkbench());
assertNull(wls.getWorkbenchWindow());
assertEquals(1, wls.getServiceLevel());
@@ -186,14 +172,14 @@ public class ContributedServiceTest extends UITestCase {
@Test
public void testWorkbenchServiceFactory() throws Exception {
- IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
- IProgressService progress = window
- .getService(IProgressService.class);
+ IWorkbenchWindow window = UITestCase.openTestWindow("org.eclipse.ui.resourcePerspective");
+ IProgressService progress = window.getService(IProgressService.class);
assertNotNull(progress);
assertEquals(getWorkbench().getProgressService(), progress);
IViewPart part = null;
IViewReference[] refs = window.getActivePage().getViewReferences();
+ System.out.println("testWorkbenchServiceFactory refs number:" + refs.length);
for (IViewReference ref : refs) {
if ((part = ref.getView(false)) != null) {
break;
@@ -201,12 +187,9 @@ public class ContributedServiceTest extends UITestCase {
}
assertNotNull(part);
- progress = part.getSite().getService(
- IProgressService.class);
+ progress = part.getSite().getService(IProgressService.class);
assertFalse(progress == getWorkbench().getProgressService());
- assertEquals(part.getSite().getService(
- IWorkbenchSiteProgressService.class), progress);
- assertEquals(part.getSite().getAdapter(
- IWorkbenchSiteProgressService.class), progress);
+ assertEquals(part.getSite().getService(IWorkbenchSiteProgressService.class), progress);
+ assertEquals(part.getSite().getAdapter(IWorkbenchSiteProgressService.class), progress);
}
}

Back to the top