diff options
| author | Thibault Le Ouay | 2015-01-28 22:22:48 +0000 |
|---|---|---|
| committer | Lars Vogel | 2015-02-10 06:40:35 +0000 |
| commit | 5de4b5badd0f4fc31e4e18ea1587844ca7c0a4e5 (patch) | |
| tree | 2a11414464c0a195bb27753e7467b25af51b004d | |
| parent | 70624dce934a0963c556607f43c75959dd8a59f2 (diff) | |
| download | eclipse.platform.ui-5de4b5badd0f4fc31e4e18ea1587844ca7c0a4e5.tar.gz eclipse.platform.ui-5de4b5badd0f4fc31e4e18ea1587844ca7c0a4e5.tar.xz eclipse.platform.ui-5de4b5badd0f4fc31e4e18ea1587844ca7c0a4e5.zip | |
Bug 457870 - [Tests] Update org.eclipse.ui.tests.navigator to JUnit 4I20150210-0800
Change-Id: Ibc2ac2877c28a935db1d61c259db6544c66d55f1
Signed-off-by: Thibault Le Ouay <thibaultleouay@gmail.com>
24 files changed, 436 insertions, 217 deletions
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 015a0e90079..5f8da0cbe82 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 a0035b1cd36..eee781af5fd 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 @@ public class ActionProviderTest extends NavigatorTestBase { _navigatorInstanceId = TEST_VIEWER; } + @Test public void testBasicModel() throws Exception { waitForModelObjects(); @@ -58,7 +66,8 @@ public class ActionProviderTest extends NavigatorTestBase { } - 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 @@ public class ActionProviderTest extends NavigatorTestBase { 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 class ActionProviderTest extends NavigatorTestBase { } - 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 7c41ae405aa..f8c89826781 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 @@ public class ActivityTest extends NavigatorTestBase { // 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 @@ public class ActivityTest extends NavigatorTestBase { // 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 83c91e4ed73..9b55a6d0a4d 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 @@ public class DnDTest extends NavigatorTestBase { } @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 @@ public class DnDTest extends NavigatorTestBase { // 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 @@ public class DnDTest extends NavigatorTestBase { // 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 @@ public class DnDTest extends NavigatorTestBase { } // 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 @@ public class DnDTest extends NavigatorTestBase { // 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 @@ public class DnDTest extends NavigatorTestBase { // 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 58005f44d13..d79561b5542 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 @@ public class ExtensionsTest extends NavigatorTestBase { } // 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 bd1ffc127b3..a14d1ce4919 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 @@ public class FilterTest extends NavigatorTestBase { } // 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 fc308a4c17a..aeb6f93e8c2 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 @@ public class FirstClassM1Tests extends NavigatorTestBase { * 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 5a1e2b261b1..a76199f5415 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.INavigatorContentService; 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 @@ public class INavigatorContentServiceTests extends NavigatorTestBase { } + @Test public void testFindValidExtensions() { _contentService @@ -87,6 +93,7 @@ public class INavigatorContentServiceTests extends NavigatorTestBase { } + @Test public void testDeactivateTestExtension() { _contentService.getActivationService().activateExtensions( @@ -111,6 +118,7 @@ public class INavigatorContentServiceTests extends NavigatorTestBase { } + @Test public void testBindTestExtension() { INavigatorContentService contentServiceWithProgrammaticBindings = NavigatorContentServiceFactory.INSTANCE @@ -148,18 +156,21 @@ public class INavigatorContentServiceTests extends NavigatorTestBase { } + @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 @@ public class INavigatorContentServiceTests extends NavigatorTestBase { } // 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 b86954032b7..82340a882fb 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 @@ public class InitialActivationTest extends NavigatorTestBase { _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 8fc60e2b50c..c81a0a6c93d 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.TestLabelProviderBlank; 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 @@ public class LabelProviderTest extends NavigatorTestBase { } } + @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 @@ public class LabelProviderTest extends NavigatorTestBase { * 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 @@ public class LabelProviderTest extends NavigatorTestBase { } // 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 @@ public class LabelProviderTest extends NavigatorTestBase { 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 @@ public class LabelProviderTest extends NavigatorTestBase { } // 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 @@ public class LabelProviderTest extends NavigatorTestBase { // 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 @@ public class LabelProviderTest extends NavigatorTestBase { } // 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 @@ public class LabelProviderTest extends NavigatorTestBase { } // 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 @@ public class LabelProviderTest extends NavigatorTestBase { } // 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 7d7adced7bc..aac9cfcac2c 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 @@ public class LinkHelperTest extends NavigatorTestBase { } + @Test public void testLinkHelperSelectionChange() throws Exception { System.out.println("SelectionChange start"); @@ -65,6 +69,7 @@ public class LinkHelperTest extends NavigatorTestBase { 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 e85a13d8f41..64e2ffac730 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 @@ public class M12Tests extends NavigatorTestBase { * 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 @@ public class M12Tests extends NavigatorTestBase { } /** 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 @@ public class M12Tests extends NavigatorTestBase { } /** Tests that file2.txt in p2 is provided by M2 content provider. */ + @Test public void testM2Override() throws Exception { _initContent(); @@ -126,6 +133,7 @@ public class M12Tests extends NavigatorTestBase { * * @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 4b8bf980704..ac556808823 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.EditorTestHelper; 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.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.TestContentProviderResource; +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 @@ public class NavigatorTestBase extends TestCase { 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 class NavigatorTestBase extends TestCase { } 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 @@ public class NavigatorTestBase extends TestCase { // 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 @@ public class NavigatorTestBase extends TestCase { _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 @@ public class NavigatorTestBase extends TestCase { 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 @@ public class NavigatorTestBase extends TestCase { _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 743e38ce906..b6ac6a51e54 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 b97231d3af7..715f3a0616c 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 @@ public class OpenTest extends NavigatorTestBase { _navigatorInstanceId = TEST_VIEWER; } + @Test public void testNavigatorRootContents() throws Exception { _contentService.getActivationService().activateExtensions( @@ -55,6 +61,7 @@ public class OpenTest extends NavigatorTestBase { } + @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 1ae30448b25..6ad434433b7 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 @@ public class PerformanceTest extends NavigatorTestBase { } @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 @@ public class PerformanceTest extends NavigatorTestBase { 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 @@ public class PerformanceTest extends NavigatorTestBase { assertEquals(_numProjects, numOfProjects); } - protected void deleteProjects() throws Exception { + protected void deleteProjects() { Job deleteJob = new Job("Delete Projects") { @Override @@ -116,7 +132,11 @@ public class PerformanceTest extends NavigatorTestBase { 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 @@ public class PerformanceTest extends NavigatorTestBase { } protected void createFiles(final IProject project, final int startNumber) - throws Exception { + { Job createJob = new Job("Create Files") { @Override @@ -146,7 +166,11 @@ public class PerformanceTest extends NavigatorTestBase { 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 @@ public class PerformanceTest extends NavigatorTestBase { } // 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 @@ public class PerformanceTest extends NavigatorTestBase { + (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 @@ public class PerformanceTest extends NavigatorTestBase { } // 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 @@ public class PerformanceTest extends NavigatorTestBase { 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 2c6ccd4e3ba..b1cb0e740ce 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 @@ public class PipelineChainTest extends NavigatorTestBase { _contentService.getActivationService().activateExtensions(EXTENSIONS, true); } + @Test public void testPipelinedChildren() throws Exception { _initContent(); _testPipelinedChildren(); } + @Test public void testPipelinedChildrenWithLabel() throws Exception { _initContentWithLabel(); @@ -101,6 +104,7 @@ public class PipelineChainTest extends NavigatorTestBase { } /** Verifies that interceptAdd is called in the right sequence */ + @Test public void testInterceptAdd() throws CoreException { _initContent(); @@ -108,6 +112,7 @@ public class PipelineChainTest extends NavigatorTestBase { } /** Verifies that interceptAdd is called in the right sequence */ + @Test public void testInterceptAddWithLabel() throws CoreException { _initContentWithLabel(); @@ -132,6 +137,7 @@ public class PipelineChainTest extends NavigatorTestBase { /** 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 @@ public class PipelineChainTest extends NavigatorTestBase { /** 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 @@ public class PipelineChainTest extends NavigatorTestBase { /** 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 @@ public class PipelineChainTest extends NavigatorTestBase { /** 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 @@ public class PipelineChainTest extends NavigatorTestBase { // Bug 285529 Incorrect pipeline logic for interceptXXX methods + @Test public void testInterceptUpdate() throws CoreException { _initContent(); @@ -211,6 +221,7 @@ public class PipelineChainTest extends NavigatorTestBase { } // 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 44d05b6e668..54612ae8e63 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.jface.viewers.StructuredSelection; 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 @@ public class PipelineTest extends NavigatorTestBase { _navigatorInstanceId = TEST_VIEWER_PIPELINE; } + @Test public void testNavigatorResourceJava() throws Exception { assertEquals( @@ -99,6 +106,7 @@ public class PipelineTest extends NavigatorTestBase { } // 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 @@ public class PipelineTest extends NavigatorTestBase { } // 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 @@ public class PipelineTest extends NavigatorTestBase { 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 00ac6f794a4..3ba80365ef7 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.TestLabelProviderCyan; 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 @@ public class ProgrammaticOpenTest extends NavigatorTestBase { _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 @@ public class ProgrammaticOpenTest extends NavigatorTestBase { } + @Test public void testNavigatorExtensionEnablement() throws Exception { assertEquals("There should be no visible extensions for the programmatic viewer.", 0, @@ -97,6 +103,7 @@ public class ProgrammaticOpenTest extends NavigatorTestBase { } + @Test public void testNavigatorSorterAccess() throws Exception { INavigatorSorterService sorterService = _contentService.getSorterService(); @@ -116,6 +123,7 @@ public class ProgrammaticOpenTest extends NavigatorTestBase { } // 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 @@ public class ProgrammaticOpenTest extends NavigatorTestBase { } // 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 @@ public class ProgrammaticOpenTest extends NavigatorTestBase { } // 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 @@ public class ProgrammaticOpenTest extends NavigatorTestBase { } // 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 ca58dc938b0..bc37947a814 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.internal.navigator.NavigatorPlugin; 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 @@ public class SorterTest extends NavigatorTestBase { private int _statusCount; // bug 262707 CommonViewerSorter gets NPE when misconfigured + @Test public void testSorterMissing() throws Exception { TestContentProviderResource._returnBadObject = true; @@ -71,6 +77,7 @@ public class SorterTest extends NavigatorTestBase { // bug 231855 [CommonNavigator] CommonViewerSorter does not support // isSorterProperty method of ViewerComparator + @Test public void testSorterProperty() throws Exception { _contentService.bindExtensions( @@ -232,6 +239,7 @@ public class SorterTest extends NavigatorTestBase { // 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 @@ public class SorterTest extends NavigatorTestBase { } + @Test public void testSorterContentAdd() throws Exception { waitForModelObjects(); @@ -285,6 +294,7 @@ public class SorterTest extends NavigatorTestBase { assertEquals("BlueAddedFile2.txt", addedParent.getItem(3).getText()); } + @Test public void testSorterContentAddOverride() throws Exception { waitForModelObjects(); @@ -314,6 +324,7 @@ public class SorterTest extends NavigatorTestBase { } + @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 5ede00a2dc2..1975066edc4 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 @@ public class ViewerTest extends NavigatorTestBase { } // Bug 218127 [CommonNavigator] Common Navigator inherited viewer bindings + @Test public void testInheritedViewer() throws Exception { IStructuredSelection sel; @@ -35,6 +41,7 @@ public class ViewerTest extends NavigatorTestBase { } // 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 @@ public class ViewerTest extends NavigatorTestBase { // 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 c79ed1ef4ce..354c66a992b 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.IExtensionStateModel; 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 @@ public class WorkingSetTest extends NavigatorTestBase { // 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 @@ public class WorkingSetTest extends NavigatorTestBase { // 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 @@ public class WorkingSetTest extends NavigatorTestBase { // 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 @@ public class WorkingSetTest extends NavigatorTestBase { // 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 @@ public class WorkingSetTest extends NavigatorTestBase { 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 de5904f0773..df693e73247 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 @@ public class CdtTest extends NavigatorTestBase { _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 544407fc46f..93c3c296bbe 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 @@ public class JstPipelineTest extends NavigatorTestBase { } @Override - public void setUp() throws Exception { + @Before + public void setUp() { super.setUp(); WebJavaContentProvider.staticInit(_contentService @@ -48,6 +51,7 @@ public class JstPipelineTest extends NavigatorTestBase { * 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[] { |
