Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@
import org.eclipse.ui.tests.harness.util.ImageTests;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* @since 3.1
*/
@RunWith(JUnit4.class)
public class ImagesTest {

private Image defaultImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

package org.eclipse.ui.tests.activities;

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 java.util.Collections;
import java.util.Set;

Expand All @@ -25,16 +30,12 @@
import org.eclipse.ui.menus.IMenuService;
import org.eclipse.ui.services.IServiceLocator;
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;

/**
* @since 3.3
*/
@RunWith(JUnit4.class)
public class MenusTest extends UITestCase {
public class MenusTest {

private TestFactory factory;
private IWorkbenchWindow window;
Expand Down Expand Up @@ -81,22 +82,17 @@ public CommandContributionItem getBarItemWithNoVisibilityClause() {
}
}

public MenusTest() {
super(MenusTest.class.getSimpleName());
}

@Override
protected void doSetUp() throws Exception {
super.doSetUp();
window = openTestWindow();
@Before
public void doSetUp() throws Exception {
window = UITestCase.openTestWindow();
enabledActivities = window.getWorkbench().getActivitySupport()
.getActivityManager().getEnabledActivityIds();
service = window.getService(IMenuService.class);
assertNotNull(service);
}

@Override
protected void doTearDown() throws Exception {
@After
public void doTearDown() throws Exception {
window.getWorkbench().getActivitySupport().setEnabledActivityIds(
enabledActivities);
assertEquals(enabledActivities, window.getWorkbench()
Expand All @@ -105,7 +101,6 @@ protected void doTearDown() throws Exception {
if (factory != null) {
service.removeContributionFactory(factory);
}
super.doTearDown();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.ui.tests.activities;

import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand All @@ -26,18 +28,14 @@
import org.eclipse.ui.activities.NotDefinedException;
import org.eclipse.ui.internal.activities.ActivityRequirementBinding;
import org.eclipse.ui.internal.activities.CategoryActivityBinding;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
*
* The static test reads activity definitions from the plugin.xml (in
* org.eclipse.ui.tests) file and valides its content.
*/
@RunWith(JUnit4.class)
public class StaticTest extends UITestCase {
public class StaticTest {
private final IActivityManager activityManager;

private List<String> categoryIds;
Expand All @@ -47,7 +45,6 @@ public class StaticTest extends UITestCase {
private List<Object> patternActivityIds;

public StaticTest() {
super(StaticTest.class.getSimpleName());
activityManager = PlatformUI.getWorkbench().getActivitySupport()
.getActivityManager();
populateIds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,49 @@
*******************************************************************************/
package org.eclipse.ui.tests.adaptable;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* Tests the markerImageProviders extension point.
*/
@RunWith(JUnit4.class)
public class MarkerImageProviderTest extends UITestCase {

public MarkerImageProviderTest() {
super(MarkerImageProviderTest.class.getSimpleName());
}
public class MarkerImageProviderTest {

/**
* Tests the static form of the extension, where just a file path is given.
*
* @throws CoreException
*/
@Test
public void testStatic() {
public void testStatic() throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IMarker marker = null;
try {
marker = workspace.getRoot().createMarker(
IMarker marker = workspace.getRoot().createMarker(
"org.eclipse.ui.tests.testmarker"); //$NON-NLS-1$
} catch (CoreException e) {
fail(e.getMessage());
}
IWorkbenchAdapter adapter = marker.getAdapter(IWorkbenchAdapter.class);
ImageDescriptor imageDesc = adapter.getImageDescriptor(marker);
assertNotNull(imageDesc);
assertTrue(imageDesc.toString().contains("anything")); //$NON-NLS-1$
}

/**
* Tests the dynamic form of the extension, where an IMarkerImageProvider class is given.
* Tests the dynamic form of the extension, where an IMarkerImageProvider class
* is given.
*
* @throws CoreException
*/
@Test
public void testDynamic() {
public void testDynamic() throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IMarker marker = null;
try {
marker = workspace.getRoot().createMarker(
IMarker marker = workspace.getRoot().createMarker(
"org.eclipse.ui.tests.testmarker2"); //$NON-NLS-1$
} catch (CoreException e) {
fail(e.getMessage());
}
IWorkbenchAdapter adapter = marker.getAdapter(IWorkbenchAdapter.class);
ImageDescriptor imageDesc = adapter.getImageDescriptor(marker);
assertNotNull(imageDesc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@

package org.eclipse.ui.tests.api;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ResourceLocator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.tests.harness.util.ImageTests;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* Tests to ensure that various icon scenarios work. These are tested on editors
Expand All @@ -33,20 +34,15 @@
*
* @since 3.0
*/
@RunWith(JUnit4.class)
public class EditorIconTest extends UITestCase {

public EditorIconTest() {
super(EditorIconTest.class.getSimpleName());
}
public class EditorIconTest {

@Test
public void testDependantBundleIcon() {
Image i1 = null;
Image i2 = null;

try {
i1 = fWorkbench.getEditorRegistry().getDefaultEditor(
i1 = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
"foo.icontest1").getImageDescriptor().createImage();
i2 = ResourceLocator.imageDescriptorFromBundle("org.eclipse.ui", "icons/full/obj16/font.png")
.orElseThrow(AssertionError::new).createImage();
Expand All @@ -67,7 +63,8 @@ public void testNonDependantBundleIcon() {
Image i1 = null;
Image i2 = null;
try {
i1 = fWorkbench.getEditorRegistry().getDefaultEditor(
i1 = PlatformUI.getWorkbench().getEditorRegistry()
.getDefaultEditor(
"foo.icontest2").getImageDescriptor().createImage();
i2 = ResourceLocator.imageDescriptorFromBundle(
"org.eclipse.jdt.ui", "icons/full/obj16/class_obj.png") // layer breaker!
Expand All @@ -90,7 +87,7 @@ public void testBadIcon() {
Image i2 = null;

try {
i1 = fWorkbench.getEditorRegistry().getDefaultEditor(
i1 = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
"foo.icontest3").getImageDescriptor().createImage();
i2 = ResourceLocator.imageDescriptorFromBundle("org.eclipse.ui", "icons/full/obj16/file_obj.png")
.orElseThrow(AssertionError::new).createImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@
*******************************************************************************/
package org.eclipse.ui.tests.api;

import static org.junit.Assert.assertTrue;

import org.eclipse.ui.PlatformUI;
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 StartupTest extends UITestCase {

/**
* Construct an instance.
*/
public StartupTest() {
super(StartupTest.class.getSimpleName());
}
public class StartupTest {

@Test
public void testStartup() {
Expand All @@ -36,9 +30,13 @@ public void testStartup() {
assertTrue("Startup - completed before tests", StartupClass.getEarlyStartupCompleted());
}

@Override
protected void doTearDown() throws Exception {
super.doTearDown();
@Before
public void doSetUp() {
PlatformUI.getWorkbench();
}

@After
public void doTearDown() throws Exception {
// NOTE: tearDown will run after each test. Therefore, we
// only want one test in this suite (or the values set when
// this plugin started up will be lost).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* @since 3.3
*/
@RunWith(JUnit4.class)
@Ignore("broke during e4 transition and still need adjustments")
public class ActionDelegateProxyTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,10 @@
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* @since 3.3
*/
@RunWith(JUnit4.class)
@Ignore("broke during e4 transition and still need adjustments")
public class CommandEnablementTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package org.eclipse.ui.tests.commands;

import static org.junit.Assert.assertEquals;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
Expand All @@ -23,20 +25,17 @@
import org.eclipse.core.expressions.ExpressionInfo;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.ui.ISources;
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;

/**
* Tests the new help context identifier support on commands and handlers.
*
* @since 3.2
*/
@RunWith(JUnit4.class)
public final class HelpContextIdTest extends UITestCase {
public final class HelpContextIdTest {

private static final String COMMAND_HELP_ID = "org.eclipse.ui.tests.commandHelp";

Expand All @@ -46,13 +45,6 @@ public final class HelpContextIdTest extends UITestCase {

private static final String NEW_HELP_ID = "new_help_id";

/**
* Constructs a new instance of <code>HelpContextIdTest</code>
*/
public HelpContextIdTest() {
super(HelpContextIdTest.class.getSimpleName());
}

/**
* Tests the reading of the help context identifier of the registry, as well
* as programmatic changes. It does not test whether there is notification.
Expand All @@ -63,9 +55,9 @@ public HelpContextIdTest() {
*/
@Test
public final void testHelpContextId() throws NotDefinedException {
final ICommandService commandService = fWorkbench
final ICommandService commandService = PlatformUI.getWorkbench()
.getService(ICommandService.class);
final IHandlerService handlerService = fWorkbench
final IHandlerService handlerService = PlatformUI.getWorkbench()
.getService(IHandlerService.class);
String helpContextId = null;

Expand Down
Loading
Loading