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 @@ -15,37 +15,34 @@

package org.eclipse.ui.tests;

import static org.junit.Assert.assertEquals;

import org.eclipse.jface.text.contentassist.BoldStylerProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.dialogs.StyledStringHighlighter;
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 StyledStringHighlighterTest extends UITestCase {

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

private StyledStringHighlighter cut;
private static Font font;
private static BoldStylerProvider boldStyler;

@Override
@Before
public void doSetUp() {
font = new Font(fWorkbench.getDisplay(), "Arial", 14, SWT.BOLD);
font = new Font(Display.getDefault(), "Arial", 14, SWT.BOLD);
boldStyler = new BoldStylerProvider(font);
cut = new StyledStringHighlighter();
}

@Override
protected void doTearDown() {
@After
public void doTearDown() {
if (boldStyler != null) {
boldStyler.dispose();
boldStyler = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
import org.eclipse.ui.activities.IActivityManager;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* @since 3.1
*/
@RunWith(JUnit4.class)
public class ActivityPreferenceTest {
/**
* Preference prefix - must match the one specified in ActivityPreferenceHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
*******************************************************************************/
package org.eclipse.ui.tests.activities;

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

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
Expand All @@ -22,7 +27,7 @@
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.tests.harness.util.ImageTests;
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;
Expand All @@ -31,16 +36,12 @@
* @since 3.1
*/
@RunWith(JUnit4.class)
public class ImagesTest extends UITestCase {
public class ImagesTest {

private Image defaultImage;
private Image image1;
private Image image2;

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

@Test
public void testActivityImages() {
IWorkbenchActivitySupport support = PlatformUI.getWorkbench().getActivitySupport();
Expand Down Expand Up @@ -95,9 +96,8 @@ public void testCategoryImages() {
}


@Override
protected void doTearDown() throws Exception {
super.doTearDown();
@After
public void doTearDown() throws Exception {
if (defaultImage != null) {
defaultImage.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,89 +14,77 @@

package org.eclipse.ui.tests.activities;

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.ui.PlatformUI;
import org.eclipse.ui.activities.IActivity;
import org.eclipse.ui.activities.IActivityManager;
import org.eclipse.ui.activities.ICategory;
import org.eclipse.ui.activities.NotDefinedException;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* Tests that the Persistance class is catching malformed registry entries.
*
* @since 3.1
*/
@RunWith(JUnit4.class)
public class PersistanceTest extends UITestCase {

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

@Test
public void testCategoryPermutations() {
try {
IActivityManager manager = fWorkbench.getActivitySupport().getActivityManager();
ICategory category = manager.getCategory("org.eclipse.ui.PT.C1"); // should not be defined - missing name
assertFalse(category.isDefined());
public void testCategoryPermutations() throws NotDefinedException {
IActivityManager manager = PlatformUI.getWorkbench().getActivitySupport().getActivityManager();
ICategory category = manager.getCategory("org.eclipse.ui.PT.C1"); // should not be defined - missing name
assertFalse(category.isDefined());

category = manager.getCategory("org.eclipse.ui.PT.C2"); // should be defined - missing desc
assertTrue(category.isDefined());
assertNotNull(category.getDescription());
category = manager.getCategory("org.eclipse.ui.PT.C2"); // should be defined - missing desc
assertTrue(category.isDefined());
assertNotNull(category.getDescription());

for (String string : manager.getDefinedCategoryIds()) {
if (manager.getCategory(string).getName().equals("org.eclipse.ui.PT.C3")) {
fail("Found category that should not be.");
}
for (String string : manager.getDefinedCategoryIds()) {
if (manager.getCategory(string).getName().equals("org.eclipse.ui.PT.C3")) {
fail("Found category that should not be.");
}
}
catch (NotDefinedException e) {
fail(e.getMessage());
}
}

@Test
public void testActivityRequirementBindings() {
IActivityManager manager = fWorkbench.getActivitySupport().getActivityManager();
IActivityManager manager = PlatformUI.getWorkbench().getActivitySupport().getActivityManager();
IActivity activity = manager.getActivity("org.eclipse.ui.PT.A2");
assertTrue(activity.getActivityRequirementBindings().isEmpty());
}

@Test
public void testActivityPatternBindings() {
IActivityManager manager = fWorkbench.getActivitySupport().getActivityManager();
IActivityManager manager = PlatformUI.getWorkbench().getActivitySupport().getActivityManager();
IActivity activity = manager.getActivity("org.eclipse.ui.PT.A2");
assertTrue(activity.getActivityPatternBindings().isEmpty());
}

@Test
public void testCategoryActivityBindings() {
IActivityManager manager = fWorkbench.getActivitySupport().getActivityManager();
IActivityManager manager = PlatformUI.getWorkbench().getActivitySupport().getActivityManager();
ICategory category = manager.getCategory("org.eclipse.ui.PT.C2");
assertTrue(category.getCategoryActivityBindings().isEmpty());
}

@Test
public void testActivityPermutations() {
try {
IActivityManager manager = fWorkbench.getActivitySupport().getActivityManager();
IActivity activity = manager.getActivity("org.eclipse.ui.PT.A1"); // should not be defined - missing name
assertFalse(activity.isDefined());
public void testActivityPermutations() throws NotDefinedException {
IActivityManager manager = PlatformUI.getWorkbench().getActivitySupport().getActivityManager();
IActivity activity = manager.getActivity("org.eclipse.ui.PT.A1"); // should not be defined - missing name
assertFalse(activity.isDefined());

activity = manager.getActivity("org.eclipse.ui.PT.A2"); // should be defined - missing desc
assertTrue(activity.isDefined());
assertNotNull(activity.getDescription());
activity = manager.getActivity("org.eclipse.ui.PT.A2"); // should be defined - missing desc
assertTrue(activity.isDefined());
assertNotNull(activity.getDescription());

for (String string : manager.getDefinedActivityIds()) {
if (manager.getActivity(string).getName().equals("org.eclipse.ui.PT.A3")) {
fail("Found activity that should not be.");
}
for (String string : manager.getDefinedActivityIds()) {
if (manager.getActivity(string).getName().equals("org.eclipse.ui.PT.A3")) {
fail("Found activity that should not be.");
}
}
catch (NotDefinedException e) {
fail(e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*******************************************************************************/
package org.eclipse.ui.tests.dialogs;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

Expand All @@ -31,33 +35,22 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
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 that resources are highlighted to match user search input. See Bug
* 519525, 520250, and 520251 for references.
*
* @since 3.14
*/
@RunWith(JUnit4.class)
public class ResourceItemLabelTest extends UITestCase {

/**
* Constructs a new instance of <code>ResourceItemlLabelTest</code>.
*/

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

private IProject project;

@Override
protected void doSetUp() throws Exception {
super.doSetUp();
@Before
public void doSetUp() throws Exception {
project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(getClass().getName() + "_" + System.currentTimeMillis());
project.create(new NullProgressMonitor());
Expand Down Expand Up @@ -357,14 +350,13 @@ private String printStyleRanges(StyleRange[] styleRanges) {
return builder.toString();
}

@Override
protected void doTearDown() throws Exception {
@After
public void doTearDown() throws Exception {
if (dialog != null) {
dialog.close();
}
if (project != null) {
project.delete(true, null);
}
super.doTearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
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 ResourceSelectionFilteringDialogTest extends UITestCase {

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

private static SeeThroughFilteredResourcesSelectionDialog createDialog() {
SeeThroughFilteredResourcesSelectionDialog dialog = new SeeThroughFilteredResourcesSelectionDialog(
Expand All @@ -47,9 +41,8 @@ private static SeeThroughFilteredResourcesSelectionDialog createDialog() {

private IProject project;

@Override
@Before
public void doSetUp() throws Exception {
super.doSetUp();
project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(getClass().getSimpleName() + System.currentTimeMillis());
project.create(null);
Expand All @@ -76,9 +69,8 @@ public void testMatch() throws CoreException {
}
}

@Override
@After
public void doTearDown() throws Exception {
super.doTearDown();
project.delete(true, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,21 @@
*******************************************************************************/
package org.eclipse.ui.tests.encoding;

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

import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.util.List;

import org.eclipse.core.runtime.Assert;
import org.eclipse.ui.WorkbenchEncoding;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* The EncodingTestCase is the suite that tests the 3.1
* encoding support.
*/
@RunWith(JUnit4.class)
public class EncodingTestCase extends UITestCase {

/**
* Create a new instance of the receiver.
*/
public EncodingTestCase() {
super(EncodingTestCase.class.getSimpleName());
}
public class EncodingTestCase {

/**
* Test that the workbench encodings are all valid. The
Expand All @@ -48,10 +39,10 @@ public void testWorkbenchEncodings() {

for (String encoding : encodings) {
try {
Assert.isTrue(Charset.isSupported(encoding), "Unsupported charset " + encoding);
assertTrue("Unsupported charset " + encoding, Charset.isSupported(encoding));

} catch (IllegalCharsetNameException e) {
Assert.isTrue(false, "Unsupported charset " + encoding);
fail("Unsupported charset " + encoding);
}
}
}
Expand Down
Loading
Loading