Bug 457870 - [Tests] Update org.eclipse.ui.tests.navigator to JUnit 4
Change-Id: Ibc2ac2877c28a935db1d61c259db6544c66d55f1
Signed-off-by: Thibault Le Ouay <thibaultleouay@gmail.com>
diff --git a/tests/org.eclipse.ui.tests.navigator/Navigator Test Suite.launch b/tests/org.eclipse.ui.tests.navigator/Navigator Test Suite.launch
index 015a0e9..5f8da0c 100644
--- a/tests/org.eclipse.ui.tests.navigator/Navigator Test Suite.launch
+++ b/tests/org.eclipse.ui.tests.navigator/Navigator Test Suite.launch
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="askclear" value="false"/>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="false"/>
@@ -29,7 +30,8 @@
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ui.tests.navigator.NavigatorTestSuite"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ui.tests.navigator"/>
@@ -333,4 +335,4 @@
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="true"/>
-</launchConfiguration>
\ No newline at end of file
+</launchConfiguration>
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ActionProviderTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ActionProviderTest.java
index a0035b1..eee781a 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ActionProviderTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ActionProviderTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 Oakland Software Incorporated and others.
+ * Copyright (c) 2009, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,25 +7,32 @@
*
* Contributors:
* Oakland Software Incorporated - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+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.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IContainer;
-
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.navigator.extension.TestContentProvider;
import org.eclipse.ui.tests.navigator.extension.TestExtensionTreeData;
+import org.junit.Test;
public class ActionProviderTest extends NavigatorTestBase {
@@ -36,6 +43,7 @@
_navigatorInstanceId = TEST_VIEWER;
}
+ @Test
public void testBasicModel() throws Exception {
waitForModelObjects();
@@ -58,7 +66,8 @@
}
- public void testOverride() throws Exception {
+ @Test
+ public void testOverride() {
_contentService.bindExtensions(
new String[] { TEST_CONTENT_ACTION_PROVIDER }, false);
_contentService.getActivationService().activateExtensions(
@@ -68,9 +77,12 @@
refreshViewer();
- IStructuredSelection sel;
- sel = new StructuredSelection(
- ((IContainer) _p2.members()[1]).members()[0]);
+ IStructuredSelection sel = null;
+ try {
+ sel = new StructuredSelection(((IContainer) _p2.members()[1]).members()[0]);
+ } catch (CoreException e) {
+ fail("Should not throw an exception");
+ }
_viewer.setSelection(sel);
if (SLEEP_LONG)
@@ -97,18 +109,22 @@
}
- public void testAppearsBefore() throws Exception {
+ @Test
+ public void testAppearsBefore() {
- IStructuredSelection sel;
- sel = new StructuredSelection(
- ((IContainer) _p2.members()[1]).members()[0]);
+ IStructuredSelection sel = null;
+ try {
+ sel = new StructuredSelection(((IContainer) _p2.members()[1]).members()[0]);
+ } catch (CoreException e) {
+ fail("Should not throw an exception");
+ }
_viewer.setSelection(sel);
MenuManager mm = new MenuManager();
_actionService.setContext(new ActionContext(sel));
_actionService.fillContextMenu(mm);
- List priorityItems = new ArrayList();
+ List<String> priorityItems = new ArrayList<String>();
IContributionItem[] items = mm.getItems();
for (int i = 0; i < items.length; i++) {
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ActivityTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ActivityTest.java
index 7c41ae4..f8c8982 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ActivityTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ActivityTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Oakland Software Incorporated and others.
+ * Copyright (c) 2008, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,18 +7,22 @@
*
* Contributors:
* Oakland Software Incorporated - initial API and implementation
- *.....IBM Corporation - fixed dead code warning
+ * IBM Corporation - fixed dead code warning
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashSet;
import java.util.Set;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.IWorkbenchActivitySupport;
+import org.junit.Test;
public class ActivityTest extends NavigatorTestBase {
@@ -32,7 +36,8 @@
// Bug 217801 make sure category filtering works with common wizards
// Bug 257598 missing capabilities support for actions
- public void testCategoryWizard() throws Exception {
+ @Test
+ public void testCategoryWizard() {
IStructuredSelection sel = new StructuredSelection(_project);
_viewer.setSelection(sel);
@@ -65,7 +70,8 @@
// Bug 257598 missing capabilities support for actions
- public void testProviderFilter() throws Exception {
+ @Test
+ public void testProviderFilter() {
IStructuredSelection sel = new StructuredSelection(_project);
_viewer.setSelection(sel);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/DnDTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/DnDTest.java
index 83c91e4..9b55a6d 100755
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/DnDTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/DnDTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oakland Software Incorporated and others.
+ * Copyright (c) 2009, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,21 +7,31 @@
*
* Contributors:
* Francis Upton IV, Oakland Software - Initial implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+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.resources.IFile;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.TreeItem;
-
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.harness.util.SWTEventHelper;
import org.eclipse.ui.tests.navigator.extension.TestDragAssistant;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class DnDTest extends NavigatorTestBase {
@@ -30,16 +40,19 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
super.setUp();
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
super.tearDown();
}
- public void testBasicDragDrop() throws Exception {
+ @Test
+ public void testBasicDragDrop() {
_viewer.expandToLevel(_p1, 3);
// Need to set the selection because the Dnd stuff is not doing it
@@ -73,7 +86,8 @@
// bug 185569 CommonDragAdapter should provide ways for
// CommonDragAdapterAssistant
// to perform clean up after drag has finished
- public void testResourceDrag() throws Exception {
+ @Test
+ public void testResourceDrag() {
_viewer.expandToLevel(_p1, 3);
IFile file = _p1.getFolder("f1").getFile("file1.txt");
@@ -85,7 +99,12 @@
// used
IWorkbenchPage activePage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
- TextEditor editorPart = (TextEditor) IDE.openEditor(activePage, file);
+ TextEditor editorPart = null;
+ try {
+ editorPart = (TextEditor) IDE.openEditor(activePage, file);
+ } catch (PartInitException e) {
+ fail("Should not throw an exception");
+ }
Control end = (Control) editorPart.getAdapter(Control.class);
@@ -104,7 +123,8 @@
}
// bug 264323 [CommonNavigator] CommonDragAdapterAssistant should be allowed to opt out of a drag
- public void testDragOptOut() throws Exception {
+ @Test
+ public void testDragOptOut() {
_viewer.expandToLevel(_p1, 3);
IFile file = _p1.getFolder("f1").getFile("file1.txt");
@@ -116,7 +136,12 @@
// used
IWorkbenchPage activePage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
- TextEditor editorPart = (TextEditor) IDE.openEditor(activePage, file);
+ TextEditor editorPart = null;
+ try {
+ editorPart = (TextEditor) IDE.openEditor(activePage, file);
+ } catch (PartInitException e) {
+ fail("Should not throw an exception");
+ }
Control end = (Control) editorPart.getAdapter(Control.class);
@@ -137,7 +162,8 @@
// Bug 261060 Add capability of setting drag operation
// Bug 242265 Allow event to be available for validateDrop
- public void testSetDragOperation() throws Exception {
+ @Test
+ public void testSetDragOperation() {
_contentService.bindExtensions(new String[] { TEST_CONTENT_DROP_COPY },
false);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ExtensionsTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ExtensionsTest.java
index 58005f4..d79561b 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ExtensionsTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ExtensionsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Oakland Software Incorporated and others.
+ * Copyright (c) 2008, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,14 +7,18 @@
*
* Contributors:
* Oakland Software Incorporated - initial API and implementation
- *.....IBM Corporation - fixed dead code warning
+ * IBM Corporation - fixed dead code warning
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.internal.navigator.filters.CommonFilterSelectionDialog;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
+import org.junit.Test;
public class ExtensionsTest extends NavigatorTestBase {
@@ -37,6 +41,7 @@
}
// Bug 185561 when hideAvailableExtensionsTab is true, everything gone
+ @Test
public void testHideAvailableExtensions() throws Exception {
assertEquals(3, _commonNavigator.getCommonViewer().getTree()
.getItemCount());
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/FilterTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/FilterTest.java
index bd1ffc1..a14d1ce 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/FilterTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/FilterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oakland Software Incorporated and others.
+ * Copyright (c) 2010, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,11 +7,15 @@
*
* Contributors:
* Oakland Software Incorporated - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.internal.navigator.NavigatorContentService;
+import org.junit.Test;
public class FilterTest extends NavigatorTestBase {
@@ -20,6 +24,7 @@
}
// bug 292813 Add API for high level activation of filters
+ @Test
public void testFilterActivation() throws Exception {
_contentService.bindExtensions(new String[] { COMMON_NAVIGATOR_RESOURCE_EXT }, false);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/FirstClassM1Tests.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/FirstClassM1Tests.java
index fc308a4..aeb6f93 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/FirstClassM1Tests.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/FirstClassM1Tests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Fair Isaac Corporation.
+ * Copyright (c) 2009, 2015 Fair Isaac Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,12 +7,16 @@
*
* Contributors:
* Fair Isaac Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.tests.navigator.m12.model.M1Project;
+import org.junit.Test;
/**
* M1/M2 tests with M1 as a first class provider (i.e. override policy set to
@@ -30,6 +34,7 @@
* both Ganymede and Galileo because the resourceContent provider triggers
* for M1Project, then fails to provide any children. See Bug #285353
*/
+ @Test
public void testM1ProjectHasChildren() throws Exception {
String[] EXTENSIONS = new String[] { COMMON_NAVIGATOR_RESOURCE_EXT,
// The issue only arises if the override policy is
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/INavigatorContentServiceTests.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/INavigatorContentServiceTests.java
index 5a1e2b2..a76199f 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/INavigatorContentServiceTests.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/INavigatorContentServiceTests.java
@@ -1,15 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Corporation - initial API and implementation
+ * IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Iterator;
import java.util.Set;
@@ -23,6 +27,7 @@
import org.eclipse.ui.navigator.NavigatorContentServiceFactory;
import org.eclipse.ui.tests.harness.util.EditorTestHelper;
import org.eclipse.ui.tests.navigator.extension.TestContentProvider;
+import org.junit.Test;
public class INavigatorContentServiceTests extends NavigatorTestBase {
@@ -32,6 +37,7 @@
}
+ @Test
public void testFindValidExtensions() {
_contentService
@@ -87,6 +93,7 @@
}
+ @Test
public void testDeactivateTestExtension() {
_contentService.getActivationService().activateExtensions(
@@ -111,6 +118,7 @@
}
+ @Test
public void testBindTestExtension() {
INavigatorContentService contentServiceWithProgrammaticBindings = NavigatorContentServiceFactory.INSTANCE
@@ -148,18 +156,21 @@
}
+ @Test
public void testTestExtensionVisibility() {
assertTrue("The test extension should be visible.", _contentService
.getViewerDescriptor().isVisibleContentExtension(
TEST_CONTENT));
}
+ @Test
public void testResourceExtensionVisibility() {
assertTrue("The test extension should be visible.", _contentService
.getViewerDescriptor().isVisibleContentExtension(
COMMON_NAVIGATOR_RESOURCE_EXT));
}
+ @Test
public void testVisibleExtensionIds() {
String[] visibleIds = _contentService.getVisibleExtensionIds();
@@ -191,6 +202,7 @@
}
// Bug 267722 [CommonNavigator] ClassCastException when synchronizing
+ @Test
public void testNonCommonViewer() throws Exception {
EditorTestHelper.showView(TEST_VIEW_NON_COMMONVIEWER, true);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/InitialActivationTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/InitialActivationTest.java
index b869540..82340a8 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/InitialActivationTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/InitialActivationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oakland Software Incorporated and others.
+ * Copyright (c) 2010,2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,9 +7,15 @@
*
* Contributors:
* Francis Upton IV, Oakland Software - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
public class InitialActivationTest extends NavigatorTestBase {
@@ -18,6 +24,7 @@
_navigatorInstanceId = TEST_VIEWER_INITIAL_ACTIVATION;
}
+ @Test
public void testInitialActivationExpression() throws Exception {
assertFalse(_contentService.isActive(TEST_CONTENT_INITIAL_ACTIVATION_FALSE));
assertTrue(_contentService.isActive(TEST_CONTENT_INITIAL_ACTIVATION_TRUE));
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LabelProviderTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LabelProviderTest.java
index 8fc60e2..c81a0a6 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LabelProviderTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LabelProviderTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Oakland Software Incorporated and others.
+ * Copyright (c) 2008, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,12 +9,17 @@
* Oakland Software Incorporated - initial API and implementation
*.....IBM Corporation - fixed dead code warning
* Fair Issac Corp - bug 287103 - NCSLabelProvider does not properly handle overrides
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
-import org.eclipse.swt.widgets.TreeItem;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.navigator.extension.TestEmptyContentProvider;
@@ -23,6 +28,7 @@
import org.eclipse.ui.tests.navigator.extension.TestLabelProviderCyan;
import org.eclipse.ui.tests.navigator.extension.TestLabelProviderStyledGreen;
import org.eclipse.ui.tests.navigator.extension.TrackingLabelProvider;
+import org.junit.Test;
public class LabelProviderTest extends NavigatorTestBase {
@@ -112,71 +118,88 @@
}
}
+ @Test
public void testBlankLabelProviderOverrideNone() throws Exception {
blankLabelProviderOverride(NONE, BLANK, "");
}
+ @Test
public void testNullLabelProviderOverrideNone() throws Exception {
blankLabelProviderOverride(NONE, NULL, "");
}
+ @Test
public void testPlainBlankLabelProviderOverrideNone() throws Exception {
blankLabelProviderOverride(NONE, BLANK, PLAIN);
}
+ @Test
public void testPlainNullLabelProviderOverrideNone() throws Exception {
blankLabelProviderOverride(NONE, NULL, PLAIN);
}
+ @Test
public void testBlankLabelProviderOverride1() throws Exception {
blankLabelProviderOverride(OVERRIDDEN, BLANK, "");
}
+ @Test
public void testNullLabelProviderOverride1() throws Exception {
blankLabelProviderOverride(OVERRIDDEN, NULL, "");
}
+ @Test
public void testPlainBlankLabelProviderOverride1() throws Exception {
blankLabelProviderOverride(OVERRIDDEN, BLANK, PLAIN);
}
+ @Test
public void testPlainNullLabelProviderOverride1() throws Exception {
blankLabelProviderOverride(OVERRIDDEN, NULL, PLAIN);
}
+ @Test
public void testBlankLabelProviderOverride2() throws Exception {
blankLabelProviderOverride(OVERRIDING, BLANK, "");
}
+ @Test
public void testNullLabelProviderOverride2() throws Exception {
blankLabelProviderOverride(OVERRIDING, NULL, "");
}
+ @Test
public void testPlainBlankLabelProviderOverride2() throws Exception {
blankLabelProviderOverride(OVERRIDING, BLANK, PLAIN);
}
+ @Test
public void testPlainNullLabelProviderOverride2() throws Exception {
blankLabelProviderOverride(OVERRIDING, NULL, PLAIN);
}
+ @Test
public void testBlankLabelProviderBoth() throws Exception {
blankLabelProviderOverride(BOTH, BLANK, "");
}
+ @Test
public void testNullLabelProviderBoth() throws Exception {
blankLabelProviderOverride(BOTH, NULL, "");
}
+ @Test
public void testPlainBlankLabelProviderBoth() throws Exception {
blankLabelProviderOverride(BOTH, BLANK, PLAIN);
}
+ @Test
public void testPlainNullLabelProviderBoth() throws Exception {
blankLabelProviderOverride(BOTH, NULL, PLAIN);
}
// bug 252293 [CommonNavigator] LabelProviders do not obey override rules
+ @Test
public void testSimpleResFirst() throws Exception {
_contentService.bindExtensions(new String[] { TEST_CONTENT_OVERRIDDEN1,
@@ -198,6 +221,7 @@
* B is next, but is overridden by E and D. So we have FEDB. Then A is processed
* which is overridden by B and C which is overridden by B, so we have FEDBGCA.
*/
+ @Test
public void testOverrideChain() throws Exception {
final String[] EXTENSIONS = new String[] { TEST_CONTENT_TRACKING_LABEL + ".A",
TEST_CONTENT_TRACKING_LABEL + ".B", TEST_CONTENT_TRACKING_LABEL + ".C",
@@ -258,6 +282,7 @@
}
// bug 252293 [CommonNavigator] LabelProviders do not obey override rules
+ @Test
public void testSimpleResLast() throws Exception {
_contentService.bindExtensions(new String[] { TEST_CONTENT_OVERRIDDEN2,
TEST_CONTENT_OVERRIDE2 }, false);
@@ -273,6 +298,7 @@
checkItems(rootItems, TestLabelProviderCyan.instance);
}
+ @Test
public void testOverrideAdd() throws Exception {
_contentService.bindExtensions(new String[] { TEST_CONTENT_OVERRIDDEN2,
TEST_CONTENT_OVERRIDE2 }, false);
@@ -294,6 +320,7 @@
}
// Bug 299438 activating extensions does not properly refresh
+ @Test
public void testChangeActivation() throws Exception {
TreeItem[] rootItems = _viewer.getTree().getItems();
checkItems(rootItems, TestLabelProviderStyledGreen.instance);
@@ -333,6 +360,7 @@
// extensions
// if none of the label providers from the desired content extensions return
// anything
+ @Test
public void testUsingOverriddenLabelProvider() throws Exception {
_contentService.bindExtensions(new String[] { TEST_CONTENT_OVERRIDDEN2,
@@ -356,6 +384,7 @@
}
// Bug 295803 Source of contribution set to lowest priority NCE
+ @Test
public void testMultiNceSameObject() throws Exception {
_contentService.bindExtensions(new String[] { TEST_CONTENT_OVERRIDDEN1, COMMON_NAVIGATOR_RESOURCE_EXT }, true);
@@ -377,6 +406,7 @@
}
// Bug 307132 label provider priority not respected
+ @Test
public void testLabelProviderPriority() throws Exception {
_contentService.bindExtensions(new String[] { TEST_CONTENT_EMPTY, COMMON_NAVIGATOR_RESOURCE_EXT }, true);
@@ -398,6 +428,7 @@
}
// Bug 189986 add SafeRunner for everything
+ @Test
public void testLabelProviderThrow() throws Exception {
_contentService.bindExtensions(new String[] { TEST_CONTENT_EMPTY, COMMON_NAVIGATOR_RESOURCE_EXT }, true);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LinkHelperTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LinkHelperTest.java
index 7d7adce..aac9cfc 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LinkHelperTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LinkHelperTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 Oakland Software Incorporated and others.
+ * Copyright (c) 2010, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,17 +7,20 @@
*
* Contributors:
* Oakland Software Incorporated - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
-import org.eclipse.jface.viewers.StructuredSelection;
+import static org.junit.Assert.assertEquals;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.navigator.extension.TestLinkHelper;
+import org.junit.Test;
public class LinkHelperTest extends NavigatorTestBase {
@@ -29,6 +32,7 @@
}
+ @Test
public void testLinkHelperSelectionChange() throws Exception {
System.out.println("SelectionChange start");
@@ -65,6 +69,7 @@
DisplayHelper.sleep(100000000);
}
+ @Test
public void testLinkHelperEditorActivation() throws Exception {
System.out.println("EditorActivation start");
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/M12Tests.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/M12Tests.java
index e85a13d..64e2ffa 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/M12Tests.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/M12Tests.java
@@ -1,29 +1,33 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 Fair Isaac Corporation.
+ * Copyright (c) 2009, 2015 Fair Isaac Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Contributors:
* Fair Isaac Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
******************************************************************************/
package org.eclipse.ui.tests.navigator;
-import org.eclipse.swt.widgets.TreeItem;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
-
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.navigator.m12.M1ContentProvider;
import org.eclipse.ui.tests.navigator.m12.M2ContentProvider;
import org.eclipse.ui.tests.navigator.m12.model.M1Project;
import org.eclipse.ui.tests.navigator.m12.model.M2File;
+import org.junit.Test;
/**
* M1/M2 tests. Those tests configure the M1 content provider override policy as
@@ -53,6 +57,7 @@
* This test passes in Ganymede, but fails in Galileo due to changes in
* pipelineChildren. See bug #285353
*/
+ @Test
public void testM1ChildrenAreThere() throws Exception {
_initContent();
@@ -75,6 +80,7 @@
}
/** Test that when M2 is not active F1 has two children. */
+ @Test
public void testM1ChildrenAreThereWithoutM2() throws Exception {
String[] EXTENSIONS = new String[] { COMMON_NAVIGATOR_RESOURCE_EXT,
// Note: should be using TEST_CONTENT_M12_M1_CONTENT_FIRST_CLASS
@@ -99,6 +105,7 @@
}
/** Tests that file2.txt in p2 is provided by M2 content provider. */
+ @Test
public void testM2Override() throws Exception {
_initContent();
@@ -126,6 +133,7 @@
*
* @throws CoreException
*/
+ @Test
public void testInterceptAdd() throws CoreException {
final String NEW_FOLDER_1 = "newFolder1";
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java
index 4b8bf98..ac55680 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,17 +7,22 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.HashSet;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
@@ -39,16 +44,18 @@
import org.eclipse.ui.tests.harness.util.FileUtil;
import org.eclipse.ui.tests.navigator.extension.TestContentProvider;
import org.eclipse.ui.tests.navigator.extension.TestContentProviderPipelined;
-import org.eclipse.ui.tests.navigator.extension.TestEmptyContentProvider;
-import org.eclipse.ui.tests.navigator.extension.TestSorterData;
-import org.eclipse.ui.tests.navigator.extension.TestDragAssistant;
-import org.eclipse.ui.tests.navigator.extension.TestLabelProvider;
import org.eclipse.ui.tests.navigator.extension.TestContentProviderResource;
+import org.eclipse.ui.tests.navigator.extension.TestDragAssistant;
+import org.eclipse.ui.tests.navigator.extension.TestEmptyContentProvider;
+import org.eclipse.ui.tests.navigator.extension.TestLabelProvider;
+import org.eclipse.ui.tests.navigator.extension.TestSorterData;
import org.eclipse.ui.tests.navigator.extension.TestSorterResource;
import org.eclipse.ui.tests.navigator.m12.model.ResourceWrapper;
import org.eclipse.ui.tests.navigator.util.TestWorkspace;
+import org.junit.After;
+import org.junit.Before;
-public class NavigatorTestBase extends TestCase {
+public class NavigatorTestBase {
public static final String COMMON_NAVIGATOR_RESOURCE_EXT = "org.eclipse.ui.navigator.resourceContent";
@@ -132,7 +139,7 @@
protected String _navigatorInstanceId;
- protected Set _expectedChildren = new HashSet();
+ protected Set<IResource> _expectedChildren = new HashSet<IResource>();
protected IProject _project;
protected IProject _p1;
@@ -160,11 +167,11 @@
}
public NavigatorTestBase(String name) {
- super(name);
+ // Nothing
}
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
if (_navigatorInstanceId == null) {
throw new RuntimeException("Set the _navigatorInstanceId in the constructor");
@@ -172,7 +179,11 @@
// Easier if this is not around when not needed
if (!_navigatorInstanceId.equals(ProjectExplorer.VIEW_ID))
- EditorTestHelper.showView(ProjectExplorer.VIEW_ID, false);
+ try {
+ EditorTestHelper.showView(ProjectExplorer.VIEW_ID, false);
+ } catch (PartInitException e) {
+ fail("Should not throw an exception");
+ }
TestContentProviderPipelined.resetTest();
TestContentProviderResource.resetTest();
@@ -195,10 +206,15 @@
_expectedChildren.add(_project.getFile(".classpath")); //$NON-NLS-1$
_expectedChildren.add(_project.getFile("model.properties")); //$NON-NLS-1$
- _p1 = ResourcesPlugin.getWorkspace().getRoot().getProject("p1");
- _p1.open(null);
- _p2 = ResourcesPlugin.getWorkspace().getRoot().getProject("p2");
- _p2.open(null);
+ try {
+ _p1 = ResourcesPlugin.getWorkspace().getRoot().getProject("p1");
+ _p1.open(null);
+ _p2 = ResourcesPlugin.getWorkspace().getRoot().getProject("p2");
+ _p2.open(null);
+ } catch (CoreException e) {
+ fail("Should not throw an exception");
+ }
+
_projectCount = 3;
}
@@ -224,8 +240,12 @@
DisplayHelper.sleep(50);
}
- protected void showNavigator() throws PartInitException {
- EditorTestHelper.showView(_navigatorInstanceId, true);
+ protected void showNavigator() {
+ try {
+ EditorTestHelper.showView(_navigatorInstanceId, true);
+ } catch (PartInitException e) {
+ fail("Should not throw an exception");
+ }
IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWindow.getActivePage();
@@ -235,17 +255,25 @@
_viewer = (CommonViewer) _commonNavigator.getAdapter(CommonViewer.class);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
clearAll();
// Hide it, we want a new one each time
- EditorTestHelper.showView(_navigatorInstanceId, false);
+ try {
+ EditorTestHelper.showView(_navigatorInstanceId, false);
+ } catch (PartInitException e) {
+ fail("Should not throw an exception");
+ }
}
- protected void clearAll() throws Exception {
+ protected void clearAll() {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
- FileUtil.delete(projects[i]);
+ try {
+ FileUtil.delete(projects[i]);
+ } catch (CoreException e) {
+ fail("Should not throw an exception");
+ }
}
}
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestSuite.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestSuite.java
index 743e38c..b6ac6a5 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestSuite.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,51 +8,24 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Fair Issac Corp - bug 287103 - NCSLabelProvider does not properly handle overrides
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
import org.eclipse.ui.tests.navigator.cdt.CdtTest;
import org.eclipse.ui.tests.navigator.jst.JstPipelineTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+@RunWith(Suite.class)
+@SuiteClasses({ InitialActivationTest.class, ActionProviderTest.class, ExtensionsTest.class, FilterTest.class,
+ WorkingSetTest.class, ActivityTest.class, OpenTest.class, INavigatorContentServiceTests.class,
+ ProgrammaticOpenTest.class, PipelineTest.class, PipelineChainTest.class, JstPipelineTest.class,
+ LabelProviderTest.class, SorterTest.class, ViewerTest.class, CdtTest.class, M12Tests.class,
+ FirstClassM1Tests.class, LinkHelperTest.class, DnDTest.class, PerformanceTest.class })
+public final class NavigatorTestSuite {
-public final class NavigatorTestSuite extends TestSuite {
-
- /**
- * Returns the suite. This is required to use the JUnit Launcher.
- */
- public static final Test suite() {
- return new NavigatorTestSuite();
- }
-
- /**
- * Construct the test suite.
- */
- public NavigatorTestSuite() {
- addTest(new TestSuite(InitialActivationTest.class));
- addTest(new TestSuite(ActionProviderTest.class));
- addTest(new TestSuite(ExtensionsTest.class));
- addTest(new TestSuite(FilterTest.class));
- addTest(WorkingSetTest.suite());
- addTest(new TestSuite(ActivityTest.class));
- addTest(new TestSuite(OpenTest.class));
- addTest(new TestSuite(INavigatorContentServiceTests.class));
- addTest(new TestSuite(ProgrammaticOpenTest.class));
- addTest(new TestSuite(PipelineTest.class));
- addTest(new TestSuite(PipelineChainTest.class));
- addTest(new TestSuite(JstPipelineTest.class));
- addTest(new TestSuite(LabelProviderTest.class));
- addTest(new TestSuite(SorterTest.class));
- addTest(new TestSuite(ViewerTest.class));
- addTest(new TestSuite(CdtTest.class));
- addTest(new TestSuite(M12Tests.class));
- addTest(new TestSuite(FirstClassM1Tests.class));
- addTest(new TestSuite(LinkHelperTest.class));
- //addTest(new TestSuite(DnDTest.class));
- // Does not pass on all platforms see bug 264449
- //addTest(new TestSuite(PerformanceTest.class));
- }
}
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/OpenTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/OpenTest.java
index b97231d..715f3a0 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/OpenTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/OpenTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,13 +7,18 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.internal.navigator.filters.UpdateActiveFiltersOperation;
+import org.junit.Test;
public class OpenTest extends NavigatorTestBase {
@@ -22,6 +27,7 @@
_navigatorInstanceId = TEST_VIEWER;
}
+ @Test
public void testNavigatorRootContents() throws Exception {
_contentService.getActivationService().activateExtensions(
@@ -55,6 +61,7 @@
}
+ @Test
public void testNavigatorExtensionEnablement() throws Exception {
_contentService.getActivationService().activateExtensions(new String[] {}, true);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PerformanceTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PerformanceTest.java
index 1ae3044..6ad4344 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PerformanceTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PerformanceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 webtekie@gmail.com, IBM Corporation and others.
+ * Copyright (c) 2008, 2015 webtekie@gmail.com, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,25 +7,35 @@
*
* Contributors:
* webtekie@gmail.com - initial API and implementation
- *.....IBM Corporation - fixed dead code warning
+ * IBM Corporation - fixed dead code warning
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.text.DecimalFormat;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.navigator.ICommonViewerMapper;
import org.eclipse.ui.navigator.resources.ProjectExplorer;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.harness.util.EditorTestHelper;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* A test to see if created projects are reflected in Project Explorer
@@ -44,16 +54,18 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
super.setUp();
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
super.tearDown();
}
- protected void createProjects() throws Exception {
+ protected void createProjects() {
Job createJob = new Job("Create projects") {
@Override
@@ -79,7 +91,11 @@
createJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
createJob.schedule();
- createJob.join();
+ try {
+ createJob.join();
+ } catch (InterruptedException e) {
+ fail("Should not throw an exception");
+ }
assertEquals(createJob.getResult(), Status.OK_STATUS);
@@ -94,7 +110,7 @@
assertEquals(_numProjects, numOfProjects);
}
- protected void deleteProjects() throws Exception {
+ protected void deleteProjects() {
Job deleteJob = new Job("Delete Projects") {
@Override
@@ -116,7 +132,11 @@
deleteJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
deleteJob.schedule();
- deleteJob.join();
+ try {
+ deleteJob.join();
+ } catch (InterruptedException e) {
+ fail("Should not throw an exception");
+ }
assertEquals(deleteJob.getResult(), Status.OK_STATUS);
@@ -124,7 +144,7 @@
}
protected void createFiles(final IProject project, final int startNumber)
- throws Exception {
+ {
Job createJob = new Job("Create Files") {
@Override
@@ -146,7 +166,11 @@
createJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
createJob.schedule();
- createJob.join();
+ try {
+ createJob.join();
+ } catch (InterruptedException e) {
+ fail("Should not throw an exception");
+ }
assertEquals(createJob.getResult(), Status.OK_STATUS);
}
@@ -176,14 +200,19 @@
}
// bug 159828 deleting large number of projects takes too long
- public void testCreateAndDeleteProjects() throws Exception {
+ @Test
+ public void testCreateAndDeleteProjects() {
_numProjects = 100;
createProjects();
// Hide it
- EditorTestHelper.showView(_navigatorInstanceId, false);
+ try {
+ EditorTestHelper.showView(_navigatorInstanceId, false);
+ } catch (PartInitException e) {
+ fail("Should not throw an exception");
+ }
long start = System.currentTimeMillis();
deleteProjects();
@@ -249,7 +278,7 @@
+ (System.currentTimeMillis() - start));
}
- protected void createFilesForProjects() throws Exception {
+ protected void createFilesForProjects() {
for (int i = 0; i < _numProjects; i++) {
String name = _df.format(i);
IProject p1 = ResourcesPlugin.getWorkspace().getRoot().getProject(
@@ -259,6 +288,7 @@
}
// bug 194209 updating lots of label providers does not scale well
+ @Test
public void testLabelProviderMapping() throws Exception {
ICommonViewerMapper mapper = _viewer.getMapper();
@@ -273,7 +303,12 @@
final IProject p1 = ResourcesPlugin.getWorkspace().getRoot()
.getProject("p000");
- p1.close(null);
+ try {
+ p1.close(null);
+ } catch (CoreException e) {
+ fail("Should not throw an exception");
+
+ }
long start = System.currentTimeMillis();
_viewer.setMapper(null);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PipelineChainTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PipelineChainTest.java
index 2c6ccd4..b1cb0e7 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PipelineChainTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PipelineChainTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 Fair Isaac Corporation.
+ * Copyright (c) 2009, 2015 Fair Isaac Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,23 +7,24 @@
*
* Contributors:
* Fair Isaac Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
******************************************************************************/
package org.eclipse.ui.tests.navigator;
-import org.eclipse.swt.widgets.TreeItem;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
-
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.navigator.extension.TestPipelineProvider;
+import org.junit.Test;
/**
* @since 3.3
@@ -69,12 +70,14 @@
_contentService.getActivationService().activateExtensions(EXTENSIONS, true);
}
+ @Test
public void testPipelinedChildren() throws Exception
{
_initContent();
_testPipelinedChildren();
}
+ @Test
public void testPipelinedChildrenWithLabel() throws Exception
{
_initContentWithLabel();
@@ -101,6 +104,7 @@
}
/** Verifies that interceptAdd is called in the right sequence */
+ @Test
public void testInterceptAdd() throws CoreException
{
_initContent();
@@ -108,6 +112,7 @@
}
/** Verifies that interceptAdd is called in the right sequence */
+ @Test
public void testInterceptAddWithLabel() throws CoreException
{
_initContentWithLabel();
@@ -132,6 +137,7 @@
/** Verifies that interceptRemove is called in the right sequence */
// Bug 285529 Incorrect pipeline logic for interceptXXX methods
+ @Test
public void testInterceptRemove() throws CoreException
{
_initContent();
@@ -140,6 +146,7 @@
/** Verifies that interceptRemove is called in the right sequence */
// Bug 285529 Incorrect pipeline logic for interceptXXX methods
+ @Test
public void testInterceptRemoveWithLabel() throws CoreException
{
_initContentWithLabel();
@@ -168,6 +175,7 @@
/** Verifies that interceptRefresh or interceptUpdate is called in the right sequence */
// Bug 285529 Incorrect pipeline logic for interceptXXX methods
+ @Test
public void testInterceptRefreshOnChildTypeChange() throws CoreException
{
_initContent();
@@ -176,6 +184,7 @@
/** Verifies that interceptRefresh or interceptUpdate is called in the right sequence */
// Bug 285529 Incorrect pipeline logic for interceptXXX methods
+ @Test
public void testInterceptRefreshOnChildTypeChangeWithLabel() throws CoreException
{
_initContentWithLabel();
@@ -204,6 +213,7 @@
// Bug 285529 Incorrect pipeline logic for interceptXXX methods
+ @Test
public void testInterceptUpdate() throws CoreException
{
_initContent();
@@ -211,6 +221,7 @@
}
// Bug 285529 Incorrect pipeline logic for interceptXXX methods
+ @Test
public void testInterceptUpdateWithLabel() throws CoreException
{
_initContentWithLabel();
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PipelineTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PipelineTest.java
index 44d05b6..54612ae 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PipelineTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/PipelineTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,9 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -20,6 +25,7 @@
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.tests.navigator.extension.TestContentProviderNoChildren;
import org.eclipse.ui.tests.navigator.extension.TestContentProviderPipelined;
+import org.junit.Test;
public class PipelineTest extends NavigatorTestBase {
@@ -27,6 +33,7 @@
_navigatorInstanceId = TEST_VIEWER_PIPELINE;
}
+ @Test
public void testNavigatorResourceJava() throws Exception {
assertEquals(
@@ -99,6 +106,7 @@
}
// Make sure problems in bad extension points are reported well
+ @Test
public void testInterceptAddThrow() throws Exception {
_contentService.bindExtensions(new String[] {
COMMON_NAVIGATOR_RESOURCE_EXT, TEST_CONTENT_RESOURCE_OVERRIDE},
@@ -122,7 +130,8 @@
}
// Bug 299661 hasChildren() does not handle overrides correctly
- public void testHasNoChildrenOverride(boolean hasChildren) throws Exception {
+
+ private void testHasNoChildrenOverride(boolean hasChildren) throws Exception {
TestContentProviderNoChildren._hasChildrenTrue = hasChildren;
_contentService.bindExtensions(new String[] {
COMMON_NAVIGATOR_RESOURCE_EXT, TEST_CONTENT_NO_CHILDREN},
@@ -143,10 +152,12 @@
assertEquals(0, rootItems[0].getItems().length);
}
+ @Test
public void testHasNoChildrenOverrideHasChildren() throws Exception {
testHasNoChildrenOverride(true);
}
+ @Test
public void testHasNoChildrenOverride() throws Exception {
testHasNoChildrenOverride(false);
}
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java
index 00ac6f7..3ba8036 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,15 +7,18 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Iterator;
import java.util.Map;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.TreeItem;
-
import org.eclipse.ui.navigator.INavigatorContentDescriptor;
import org.eclipse.ui.navigator.INavigatorSorterService;
import org.eclipse.ui.tests.navigator.extension.TestLabelProviderBlue;
@@ -23,6 +26,7 @@
import org.eclipse.ui.tests.navigator.extension.TestLabelProviderStyledGreen;
import org.eclipse.ui.tests.navigator.extension.TestSimpleChildrenContentProvider;
import org.eclipse.ui.tests.navigator.extension.TestSorterData;
+import org.junit.Test;
public class ProgrammaticOpenTest extends NavigatorTestBase {
@@ -31,6 +35,7 @@
_navigatorInstanceId = TEST_VIEWER_PROGRAMMATIC;
}
+ @Test
public void testNavigatorRootContents() throws Exception {
assertEquals("There should be no visible extensions for the programmatic viewer.", 0,
@@ -65,6 +70,7 @@
}
+ @Test
public void testNavigatorExtensionEnablement() throws Exception {
assertEquals("There should be no visible extensions for the programmatic viewer.", 0,
@@ -97,6 +103,7 @@
}
+ @Test
public void testNavigatorSorterAccess() throws Exception {
INavigatorSorterService sorterService = _contentService.getSorterService();
@@ -116,6 +123,7 @@
}
// bug 299438 things are not right after the active NCEs are changed
+ @Test
public void testChangeNceActivation() throws Exception {
_contentService.bindExtensions(new String[] { TEST_CONTENT_OVERRIDDEN1,
TEST_CONTENT_OVERRIDE1, TEST_CONTENT_OVERRIDDEN2, TEST_CONTENT_OVERRIDE2 }, false);
@@ -141,6 +149,7 @@
}
// bug 296728 expression evaluation does not support with
+ @Test
public void testEvaluateWith() throws Exception {
_contentService.bindExtensions(new String[] { COMMON_NAVIGATOR_RESOURCE_EXT,
TEST_CONTENT_WITH, }, false);
@@ -154,6 +163,7 @@
}
// bug 228022 add ordering of content
+ @Test
public void testNceOrdering() throws Exception {
_contentService.bindExtensions(new String[] {
COMMON_NAVIGATOR_RESOURCE_EXT, TEST_SIMPLE_CHILDREN1 }, false);
@@ -190,6 +200,7 @@
}
// bug 349224 Navigator content provider "appearsBefore" creates hard reference to named id
+ @Test
public void testNceNotFound() throws Exception {
_contentService.bindExtensions(new String[] {
COMMON_NAVIGATOR_RESOURCE_EXT, TEST_SIMPLE_CHILDREN_NOT_FOUND }, false);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/SorterTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/SorterTest.java
index ca58dc9..bc37947 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/SorterTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/SorterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oakland Software Incorporated and others.
+ * Copyright (c) 2008, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,9 +8,13 @@
* Contributors:
* Oakland Software Incorporated - initial API and implementation
* IBM Corporation - fixed dead code warning
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.util.Properties;
@@ -25,10 +29,11 @@
import org.eclipse.ui.navigator.INavigatorContentDescriptor;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.navigator.extension.TestContentProvider;
-import org.eclipse.ui.tests.navigator.extension.TestExtensionTreeData;
import org.eclipse.ui.tests.navigator.extension.TestContentProviderResource;
+import org.eclipse.ui.tests.navigator.extension.TestExtensionTreeData;
import org.eclipse.ui.tests.navigator.extension.TestSorterDataAndResource;
import org.eclipse.ui.tests.navigator.extension.TestSorterResource;
+import org.junit.Test;
public class SorterTest extends NavigatorTestBase {
@@ -39,6 +44,7 @@
private int _statusCount;
// bug 262707 CommonViewerSorter gets NPE when misconfigured
+ @Test
public void testSorterMissing() throws Exception {
TestContentProviderResource._returnBadObject = true;
@@ -71,6 +77,7 @@
// bug 231855 [CommonNavigator] CommonViewerSorter does not support
// isSorterProperty method of ViewerComparator
+ @Test
public void testSorterProperty() throws Exception {
_contentService.bindExtensions(
@@ -232,6 +239,7 @@
// Here we want to make sure the sorting is done by the
// highest (in the override hierarchy) content extension that
// has a sorter
+ @Test
public void testSorterContentOverrideNoSort() throws Exception {
waitForModelObjects();
@@ -262,6 +270,7 @@
}
+ @Test
public void testSorterContentAdd() throws Exception {
waitForModelObjects();
@@ -285,6 +294,7 @@
assertEquals("BlueAddedFile2.txt", addedParent.getItem(3).getText());
}
+ @Test
public void testSorterContentAddOverride() throws Exception {
waitForModelObjects();
@@ -314,6 +324,7 @@
}
+ @Test
public void testSorterResource() throws Exception {
_contentService.bindExtensions(
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ViewerTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ViewerTest.java
index 5ede00a..1975066 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ViewerTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oakland Software Incorporated and others.
+ * Copyright (c) 2009, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,15 +7,20 @@
*
* Contributors:
* Oakland Software Incorporated - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.internal.help.WorkbenchHelpSystem;
import org.eclipse.ui.tests.harness.util.EditorTestHelper;
import org.eclipse.ui.tests.navigator.extension.TestContentProvider;
+import org.junit.Test;
public class ViewerTest extends NavigatorTestBase {
@@ -24,6 +29,7 @@
}
// Bug 218127 [CommonNavigator] Common Navigator inherited viewer bindings
+ @Test
public void testInheritedViewer() throws Exception {
IStructuredSelection sel;
@@ -35,6 +41,7 @@
}
// Bug 198971[CommonNavigator] Provide extension schema for setting help ID
+ @Test
public void testHelpId() throws Exception {
String context = (String) _viewer.getControl().getData(WorkbenchHelpSystem.HELP_KEY);
assertEquals(TEST_VIEWER_HELP_CONTEXT, context);
@@ -42,6 +49,7 @@
// Bug 275932 [CommonNavigator] Window close throws exception in
// ObservableCollectionTreeContentProvider
+ @Test
public void testDispose() throws Exception {
refreshViewer();
_viewer.expandAll();
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/WorkingSetTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/WorkingSetTest.java
index c79ed1e..354c66a 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/WorkingSetTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/WorkingSetTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Oakland Software Incorporated and others.
+ * Copyright (c) 2008, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,22 +7,20 @@
*
* Contributors:
* Francis Upton IV, Oakland Software Incorporated - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator;
-import junit.framework.TestSuite;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.TreeItem;
-
-import org.eclipse.core.runtime.IAdaptable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.resources.IFile;
-
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ViewerFilter;
-
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkingSet;
@@ -39,35 +37,28 @@
import org.eclipse.ui.navigator.INavigatorContentExtension;
import org.eclipse.ui.navigator.resources.ProjectExplorer;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
+import org.junit.Test;
public class WorkingSetTest extends NavigatorTestBase {
private static final boolean SLEEP_LONG = false;
+ private static final IWorkingSet[] NO_WORKINGSET = {};
- public static TestSuite suite() {
- TestSuite suite = new TestSuite("org.eclipse.ui.tests.navigator.WorkingSetTest");
- suite.addTest(new WorkingSetTest("testEmptyWindowWorkingSet"));
- suite.addTest(new WorkingSetTest("testMissingProjectsInWorkingSet"));
- suite.addTest(new WorkingSetTest("testTopLevelWorkingSet"));
- suite.addTest(new WorkingSetTest("testTopLevelChange"));
- suite.addTest(new WorkingSetTest("testMultipleWorkingSets"));
- suite.addTest(new WorkingSetTest("testWorkingSetFilter"));
- suite.addTest(new WorkingSetTest("testDeletedAndRecreated"));
- return suite;
- }
public WorkingSetTest() {
_navigatorInstanceId = ProjectExplorer.VIEW_ID;
}
- public WorkingSetTest(String name) {
- super(name);
- _navigatorInstanceId = ProjectExplorer.VIEW_ID;
- }
// Bug 157877 when using empty window working set, it should show all
+ @Test
public void testEmptyWindowWorkingSet() throws Exception {
+ // This test should be run first with an no working set in the workbench
+ // Thus we enforce the fact that there's no Working Set, as we cant
+ // order test
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setWorkingSets(NO_WORKINGSET);
+
WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper
.getActionProvider(_contentService, _actionService, WorkingSetActionProvider.class);
@@ -86,14 +77,15 @@
assertEquals(null, _commonNavigator.getWorkingSetLabel());
}
- // Bug 212389 projects are not shown when they are not in the working set,
+ // Bug 212389 projects are not shown when they are not in the working
// but their children are
+ @Test
public void testMissingProjectsInWorkingSet() throws Exception {
IFile f1 = _p1.getFile("f1");
- WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper
- .getActionProvider(_contentService, _actionService, WorkingSetActionProvider.class);
+ WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider(
+ _contentService, _actionService, WorkingSetActionProvider.class);
IWorkingSet workingSet = new WorkingSet("ws1", "ws1", new IAdaptable[] { f1 });
@@ -101,8 +93,8 @@
new IWorkingSet[] { workingSet });
IPropertyChangeListener l = provider.getFilterChangeListener();
- PropertyChangeEvent event = new PropertyChangeEvent(this,
- WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, agWorkingSet);
+ PropertyChangeEvent event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
+ agWorkingSet);
l.propertyChange(event);
DisplayHelper.runEventLoop(Display.getCurrent(), 100);
@@ -118,22 +110,22 @@
// bug 220090 test that working sets are shown when selected locally (not
// using the window working set)
+ @Test
public void testTopLevelWorkingSet() throws Exception {
- WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper
- .getActionProvider(_contentService, _actionService, WorkingSetActionProvider.class);
+ WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider(
+ _contentService, _actionService, WorkingSetActionProvider.class);
IExtensionStateModel extensionStateModel = _contentService
.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);
- extensionStateModel.setBooleanProperty(
- WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
+ extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
IWorkingSet workingSet = new WorkingSet("ws1", "ws1", new IAdaptable[] { _p1 });
IPropertyChangeListener l = provider.getFilterChangeListener();
- PropertyChangeEvent event = new PropertyChangeEvent(this,
- WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, workingSet);
+ PropertyChangeEvent event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
+ workingSet);
l.propertyChange(event);
// DisplayHelper.sleep(Display.getCurrent(), 10000000);
@@ -155,6 +147,7 @@
// bug 244174 test property to switch back and forth between working sets
// as top level and not
+ @Test
public void testTopLevelChange() throws Exception {
IExtensionStateModel extensionStateModel = _contentService
@@ -168,11 +161,11 @@
IWorkingSet workingSet = new WorkingSet("ws1", "ws1", new IAdaptable[] { _p1 });
- WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper
- .getActionProvider(_contentService, _actionService, WorkingSetActionProvider.class);
+ WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider(
+ _contentService, _actionService, WorkingSetActionProvider.class);
IPropertyChangeListener l = provider.getFilterChangeListener();
- PropertyChangeEvent event = new PropertyChangeEvent(this,
- WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, workingSet);
+ PropertyChangeEvent event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
+ workingSet);
l.propertyChange(event);
IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
@@ -180,23 +173,20 @@
IWorkingSet[] activeWorkingSets = activePage.getWorkingSets();
activePage.setWorkingSets(new IWorkingSet[] { workingSet });
- extensionStateModel.setBooleanProperty(
- WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
+ extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
refreshViewer();
TreeItem[] items = _viewer.getTree().getItems();
assertTrue("First item needs to be working set", items[0].getData().equals(workingSet));
- extensionStateModel.setBooleanProperty(
- WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, false);
+ extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, false);
refreshViewer();
items = _viewer.getTree().getItems();
assertTrue("First item needs to be project", items[0].getData().equals(_p1));
- extensionStateModel.setBooleanProperty(
- WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
+ extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
refreshViewer();
items = _viewer.getTree().getItems();
@@ -206,6 +196,7 @@
activePage.setWorkingSets(activeWorkingSets);
}
+ @Test
public void testMultipleWorkingSets() throws Exception {
// Force the content provider to be loaded so that it responds to the
@@ -217,15 +208,15 @@
IWorkingSet workingSet1 = new WorkingSet("ws1", "ws1", new IAdaptable[] { _p1 });
IWorkingSet workingSet2 = new WorkingSet("ws2", "ws2", new IAdaptable[] { _p1 });
- AggregateWorkingSet agWorkingSet = new AggregateWorkingSet("AgWs", "Ag Working Set",
- new IWorkingSet[] { workingSet1, workingSet2 });
+ AggregateWorkingSet agWorkingSet = new AggregateWorkingSet("AgWs", "Ag Working Set", new IWorkingSet[] {
+ workingSet1, workingSet2 });
- WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper
- .getActionProvider(_contentService, _actionService, WorkingSetActionProvider.class);
+ WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider(
+ _contentService, _actionService, WorkingSetActionProvider.class);
IPropertyChangeListener l = provider.getFilterChangeListener();
- PropertyChangeEvent event = new PropertyChangeEvent(this,
- WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, agWorkingSet);
+ PropertyChangeEvent event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
+ agWorkingSet);
l.propertyChange(event);
assertEquals(WorkbenchNavigatorMessages.WorkingSetActionProvider_multipleWorkingSets,
@@ -234,19 +225,19 @@
// bug 262096 [CommonNavigator] Changing *any* filter breaks working sets
// filter
+ @Test
public void testWorkingSetFilter() throws Exception {
_contentService.bindExtensions(new String[] { COMMON_NAVIGATOR_RESOURCE_EXT }, false);
- _contentService.getActivationService().activateExtensions(
- new String[] { COMMON_NAVIGATOR_RESOURCE_EXT }, true);
+ _contentService.getActivationService().activateExtensions(new String[] { COMMON_NAVIGATOR_RESOURCE_EXT }, true);
IWorkingSet workingSet = new WorkingSet("ws1", "ws1", new IAdaptable[] { _p1 });
- WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper
- .getActionProvider(_contentService, _actionService, WorkingSetActionProvider.class);
+ WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider(
+ _contentService, _actionService, WorkingSetActionProvider.class);
IPropertyChangeListener l = provider.getFilterChangeListener();
- PropertyChangeEvent event = new PropertyChangeEvent(this,
- WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, workingSet);
+ PropertyChangeEvent event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
+ workingSet);
l.propertyChange(event);
ViewerFilter vf[];
@@ -273,6 +264,7 @@
// Bug 224703 - Project explorer doesn't show recreated working set
// (this test does not show the problem since it was in the
// WorkingSetSelectionDialog, but still it's nice to have)
+ @Test
public void testDeletedAndRecreated() throws Exception {
INavigatorContentExtension ce = _contentService
@@ -286,16 +278,16 @@
IWorkingSet ws2 = workingSetManager.createWorkingSet("ws2", new IAdaptable[] { _p2 });
workingSetManager.addWorkingSet(ws2);
- WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper
- .getActionProvider(_contentService, _actionService, WorkingSetActionProvider.class);
+ WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider(
+ _contentService, _actionService, WorkingSetActionProvider.class);
IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWindow.getActivePage();
activePage.setWorkingSets(new IWorkingSet[] { ws1, ws2 });
IPropertyChangeListener l = provider.getFilterChangeListener();
- PropertyChangeEvent event = new PropertyChangeEvent(this,
- WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, ws2);
+ PropertyChangeEvent event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
+ ws2);
l.propertyChange(event);
DisplayHelper.runEventLoop(Display.getCurrent(), 100);
@@ -304,8 +296,7 @@
assertTrue(items[0].getData().equals(_p2));
l = provider.getFilterChangeListener();
- event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
- ws1);
+ event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, ws1);
l.propertyChange(event);
DisplayHelper.runEventLoop(Display.getCurrent(), 100);
items = _viewer.getTree().getItems();
@@ -317,8 +308,7 @@
workingSetManager.addWorkingSet(ws2);
l = provider.getFilterChangeListener();
- event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
- ws2);
+ event = new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, ws2);
l.propertyChange(event);
DisplayHelper.runEventLoop(Display.getCurrent(), 100);
items = _viewer.getTree().getItems();
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/cdt/CdtTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/cdt/CdtTest.java
index de5904f..df693e7 100755
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/cdt/CdtTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/cdt/CdtTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Oakland Software Incorporated and others.
+ * Copyright (c) 2008, 2015 Oakland Software Incorporated and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,21 +8,22 @@
* Contributors:
* Oakland Software Incorporated - initial API and implementation
* IBM Corporation - fixed dead code warning
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator.cdt;
-import org.eclipse.swt.widgets.TreeItem;
-
-import org.eclipse.core.runtime.Path;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
-
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.navigator.resources.ProjectExplorer;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.navigator.NavigatorTestBase;
import org.eclipse.ui.tests.navigator.util.ProjectUnzipUtil;
import org.eclipse.ui.tests.navigator.util.TestWorkspace;
+import org.junit.Test;
/**
* This simulates the CDT usage of the CNF.
@@ -40,6 +41,7 @@
_navigatorInstanceId = ProjectExplorer.VIEW_ID;
}
+ @Test
public void testCdt1() throws Exception {
_contentService.bindExtensions(new String[] { TEST_C_CONTENT }, false);
diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/jst/JstPipelineTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/jst/JstPipelineTest.java
index 544407f..93c3c29 100644
--- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/jst/JstPipelineTest.java
+++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/jst/JstPipelineTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2013 IBM Corporation and others.
+ * Copyright (c) 2003, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,21 +8,23 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Oakland Software Incorporated - Added to CNF tests
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 457870
*******************************************************************************/
package org.eclipse.ui.tests.navigator.jst;
-import org.eclipse.swt.widgets.TreeItem;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Path;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.StructuredSelection;
-
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.eclipse.ui.tests.navigator.NavigatorTestBase;
+import org.junit.Before;
+import org.junit.Test;
public class JstPipelineTest extends NavigatorTestBase {
@@ -34,7 +36,8 @@
}
@Override
- public void setUp() throws Exception {
+ @Before
+ public void setUp() {
super.setUp();
WebJavaContentProvider.staticInit(_contentService
@@ -48,6 +51,7 @@
* objects as the content, and the JDT label provider does not get invoked
* for those objects.
*/
+ @Test
public void testJstPipeline() throws Exception {
_contentService.bindExtensions(new String[] {