Bug 500327 - Cleanups to o.e.ui.tests
* Remove useless casts.
* Remove non-existing dirs/files from bin and src.includes.
* Fix javadoc warning about @link usage.
* Format surrounding code.
Change-Id: I6b8e5176878fac94593c980ec87cdb2acae8f220
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MultipleWindowsTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MultipleWindowsTest.java
index 66d7577..0f78d85 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MultipleWindowsTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MultipleWindowsTest.java
@@ -40,8 +40,8 @@
}
/**
- * {@link http://eclip.se/493335 Bug 493335 - [WorkingSets] Setting window
- * working set affects all windows}
+ * @see <a href="http://eclip.se/493335"> Bug 493335 - [WorkingSets] Setting
+ * window working set affects all windows</a>
*/
@Test
public void testIndependentWorkingSets() {
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java
index 54d96c4..a26a389 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2016 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
@@ -85,29 +85,23 @@
private void findInPresentation(WorkbenchWindow window,
WWinPluginAction[] action, boolean[] found) {
- IRendererFactory factory = (IRendererFactory) window
- .getService(IRendererFactory.class);
+ IRendererFactory factory = window.getService(IRendererFactory.class);
MWindow mwindow = window.getModel();
- AbstractPartRenderer obj = factory.getRenderer(mwindow.getMainMenu(),
- null);
+ AbstractPartRenderer obj = factory.getRenderer(mwindow.getMainMenu(), null);
if (!(obj instanceof MenuManagerRenderer)) {
return;
}
- ContributionRecord[] records = ((MenuManagerRenderer) obj)
- .getContributionRecords();
+ ContributionRecord[] records = ((MenuManagerRenderer) obj).getContributionRecords();
for (ContributionRecord rec : records) {
String id = rec.getMenuContribution().getElementId();
- if (id != null
- && id.startsWith("org.eclipse.newActionSet1.newActionSet2")) {
+ if (id != null && id.startsWith("org.eclipse.newActionSet1.newActionSet2")) {
found[0] = true;
Collection<MMenuElement> elements = rec.getGeneratedElements();
for (MMenuElement element : elements) {
- if ("org.eclipse.ui.tests.action1".equals(element
- .getElementId())) {
+ if ("org.eclipse.ui.tests.action1".equals(element.getElementId())) {
// FIXME return the plugin action
- action[0] = new WWinPluginAction(null, window,
- element.getElementId(), IAction.AS_PUSH_BUTTON);
+ action[0] = new WWinPluginAction(null, window, element.getElementId(), IAction.AS_PUSH_BUTTON);
}
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/PerspectiveSwitcherTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/PerspectiveSwitcherTest.java
index 7302b44..242e774 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/PerspectiveSwitcherTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/PerspectiveSwitcherTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Remy Chi Jian Suen and others.
+ * Copyright (c) 2009, 2016 Remy Chi Jian Suen 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
@@ -45,12 +45,8 @@
protected void doTearDown() throws Exception {
// reset values so we don't screw any assumptions up for other tests
// down the line
- apiPreferenceStore.setValue(
- IWorkbenchPreferenceConstants.SHOW_OPEN_ON_PERSPECTIVE_BAR,
- originalShowOpenValue);
- apiPreferenceStore.setValue(
- IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
- originalPerspectiveBarPosition);
+ apiPreferenceStore.setValue(IWorkbenchPreferenceConstants.SHOW_OPEN_ON_PERSPECTIVE_BAR, originalShowOpenValue);
+ apiPreferenceStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, originalPerspectiveBarPosition);
super.doTearDown();
}
@@ -65,46 +61,36 @@
// be recreated, TOP_RIGHT and TOP_LEFT should switch to LEFT, LEFT
// should switch to TOP_RIGHT or TOP_LEFT
String targetDockPosition = null;
- if (IWorkbenchPreferenceConstants.TOP_RIGHT
- .equals(originalPerspectiveBarPosition)
- || IWorkbenchPreferenceConstants.TOP_LEFT
- .equals(originalPerspectiveBarPosition)) {
+ if (IWorkbenchPreferenceConstants.TOP_RIGHT.equals(originalPerspectiveBarPosition)
+ || IWorkbenchPreferenceConstants.TOP_LEFT.equals(originalPerspectiveBarPosition)) {
targetDockPosition = IWorkbenchPreferenceConstants.LEFT;
- } else if (IWorkbenchPreferenceConstants.LEFT
- .equals(originalPerspectiveBarPosition)) {
+ } else if (IWorkbenchPreferenceConstants.LEFT.equals(originalPerspectiveBarPosition)) {
targetDockPosition = IWorkbenchPreferenceConstants.TOP_RIGHT;
} else {
- throw new IllegalStateException(
- "The current perspective bar position is unknown: " //$NON-NLS-1$
- + originalPerspectiveBarPosition);
+ throw new IllegalStateException("The current perspective bar position is unknown: " //$NON-NLS-1$
+ + originalPerspectiveBarPosition);
}
- WorkbenchWindow window = (WorkbenchWindow) fWorkbench
- .getActiveWorkbenchWindow();
+ WorkbenchWindow window = (WorkbenchWindow) fWorkbench.getActiveWorkbenchWindow();
assertNotNull("We should have a perspective bar in the beginning", //$NON-NLS-1$
getPerspectiveSwitcher(window));
// turn off the 'Open Perspective' item
- apiPreferenceStore.setValue(
- IWorkbenchPreferenceConstants.SHOW_OPEN_ON_PERSPECTIVE_BAR,
- false);
+ apiPreferenceStore.setValue(IWorkbenchPreferenceConstants.SHOW_OPEN_ON_PERSPECTIVE_BAR, false);
// now we dock the perspective bar on the other end
- apiPreferenceStore.setValue(
- IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
- targetDockPosition);
+ apiPreferenceStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, targetDockPosition);
// check that we have a perspective bar, the setValue(String, String)
// method does not throw an exception because the perspective bar
// creation code is wrapped around a SafeRunner so the exception does
// not get propagated, hence, we need to check here
- assertNotNull(
- "The perspective bar should have been created successfully", //$NON-NLS-1$
+ assertNotNull("The perspective bar should have been created successfully", //$NON-NLS-1$
getPerspectiveSwitcher(window));
}
private static Object getPerspectiveSwitcher(WorkbenchWindow window) {
- EModelService modelService = (EModelService) window.getService(EModelService.class);
+ EModelService modelService = window.getService(EModelService.class);
return modelService.find("PerspectiveSwitcher", window.getModel());
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchWindowSubordinateSourcesTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchWindowSubordinateSourcesTests.java
index b94bb73..6ac4d57 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchWindowSubordinateSourcesTests.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchWindowSubordinateSourcesTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 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
@@ -50,8 +50,7 @@
}
public void testIsCoolbarVisible() {
- IEvaluationService service = (IEvaluationService) window
- .getService(IEvaluationService.class);
+ IEvaluationService service = window.getService(IEvaluationService.class);
IEvaluationContext context = service.getCurrentState();
WithExpression with = new WithExpression(
@@ -76,15 +75,13 @@
}
public void testIsStatusLineVisible() {
- IEvaluationService service = (IEvaluationService) window
- .getService(IEvaluationService.class);
+ IEvaluationService service = window.getService(IEvaluationService.class);
IEvaluationContext context = service.getCurrentState();
WithExpression with = new WithExpression(
ISources.ACTIVE_WORKBENCH_WINDOW_NAME + ".isStatusLineVisible");
boolean current = window.getStatusLineVisible();
- EqualsExpression test = new EqualsExpression(current ? Boolean.TRUE
- : Boolean.FALSE);
+ EqualsExpression test = new EqualsExpression(current ? Boolean.TRUE : Boolean.FALSE);
with.add(test);
try {
@@ -102,15 +99,13 @@
}
public void testIsPerspectiveBarVisible() {
- IEvaluationService service = (IEvaluationService) window
- .getService(IEvaluationService.class);
+ IEvaluationService service = window.getService(IEvaluationService.class);
IEvaluationContext context = service.getCurrentState();
WithExpression with = new WithExpression(
ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME);
boolean current = window.getPerspectiveBarVisible();
- EqualsExpression test = new EqualsExpression(current ? Boolean.TRUE
- : Boolean.FALSE);
+ EqualsExpression test = new EqualsExpression(current ? Boolean.TRUE : Boolean.FALSE);
with.add(test);
try {
@@ -137,22 +132,18 @@
}
public void testPerspectiveId() throws Exception {
- IEvaluationService service = (IEvaluationService) window
- .getService(IEvaluationService.class);
- WithExpression with = new WithExpression(
- ISources.ACTIVE_WORKBENCH_WINDOW_ACTIVE_PERSPECTIVE_NAME);
+ IEvaluationService service = window.getService(IEvaluationService.class);
+ WithExpression with = new WithExpression(ISources.ACTIVE_WORKBENCH_WINDOW_ACTIVE_PERSPECTIVE_NAME);
IPerspectiveDescriptor currentPerspective = window.getActivePage().getPerspective();
String id = currentPerspective.getId();
EqualsExpression test = new EqualsExpression(id);
with.add(test);
PerspectiveL listener = new PerspectiveL();
- service.addEvaluationListener(with, listener,
- ISources.ACTIVE_WORKBENCH_WINDOW_ACTIVE_PERSPECTIVE_NAME);
+ service.addEvaluationListener(with, listener, ISources.ACTIVE_WORKBENCH_WINDOW_ACTIVE_PERSPECTIVE_NAME);
assertEquals(Boolean.TRUE, listener.val);
listener.val = null;
- final IPerspectiveRegistry registry = WorkbenchPlugin.getDefault()
- .getPerspectiveRegistry();
+ final IPerspectiveRegistry registry = WorkbenchPlugin.getDefault().getPerspectiveRegistry();
final IPerspectiveDescriptor perspective1 = registry
.findPerspectiveWithId("org.eclipse.ui.tests.api.ViewPerspective");
window.getActivePage().setPerspective(perspective1);
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/stress/OpenCloseTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/stress/OpenCloseTest.java
index aea4671..75e3211 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/stress/OpenCloseTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/stress/OpenCloseTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -59,8 +59,7 @@
*/
public OpenCloseTest(String testName) {
super(testName);
- workbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
+ workbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
/**
@@ -70,19 +69,16 @@
public void testOpenCloseFile() {
IWorkbenchPage page = workbenchWindow.getActivePage();
try {
- FileUtil.createProject("TestProject");
- IProject testProject = ResourcesPlugin.getWorkspace().getRoot()
- .getProject("TestProject"); //$NON-NLS-1$
- FileUtil.createFile("tempFile.txt", testProject);
- testProject.open(null);
- IEditorInput editorInput = new FileEditorInput(testProject
- .getFile("tempFile.txt"));
- IEditorPart editorPart = null;
- for (index = 0; index < numIterations; index++) {
- editorPart = page.openEditor(editorInput,
- "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$
- page.closeEditor(editorPart, false);
- }
+ FileUtil.createProject("TestProject");
+ IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject"); //$NON-NLS-1$
+ FileUtil.createFile("tempFile.txt", testProject);
+ testProject.open(null);
+ IEditorInput editorInput = new FileEditorInput(testProject.getFile("tempFile.txt"));
+ IEditorPart editorPart = null;
+ for (index = 0; index < numIterations; index++) {
+ editorPart = page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$
+ page.closeEditor(editorPart, false);
+ }
FileUtil.deleteProject(testProject);
} catch (Exception e) {
e.printStackTrace(System.err);
@@ -96,11 +92,10 @@
public void testOpenCloseWorkbenchWindow() {
IWorkbenchWindow secondWorkbenchWindow = null;
try {
- for (index = 0; index < numIterations; index++) {
- secondWorkbenchWindow = PlatformUI.getWorkbench()
- .openWorkbenchWindow(getPageInput());
- secondWorkbenchWindow.close();
- }
+ for (index = 0; index < numIterations; index++) {
+ secondWorkbenchWindow = PlatformUI.getWorkbench().openWorkbenchWindow(getPageInput());
+ secondWorkbenchWindow.close();
+ }
} catch (WorkbenchException e) {
e.printStackTrace(System.err);
}
@@ -120,25 +115,23 @@
ParameterizedCommand pCommand = ParameterizedCommand.generateCommand(command, parameters);
- IHandlerService handlerService = (IHandlerService) workbenchWindow
- .getService(IHandlerService.class);
+ IHandlerService handlerService = workbenchWindow.getService(IHandlerService.class);
- for (index = 0; index < numIterations; index++) {
- try {
- PlatformUI.getWorkbench().showPerspective(
- ORG_ECLIPSE_JDT_UI_JAVA_PERSPECTIVE, workbenchWindow);
- try {
- handlerService.executeCommand(pCommand, null);
- } catch (ExecutionException e1) {
- } catch (NotDefinedException e1) {
- } catch (NotEnabledException e1) {
- } catch (NotHandledException e1) {
- }
- } catch (WorkbenchException e) {
- e.printStackTrace();
- }
- }
- }
+ for (index = 0; index < numIterations; index++) {
+ try {
+ PlatformUI.getWorkbench().showPerspective(ORG_ECLIPSE_JDT_UI_JAVA_PERSPECTIVE, workbenchWindow);
+ try {
+ handlerService.executeCommand(pCommand, null);
+ } catch (ExecutionException e1) {
+ } catch (NotDefinedException e1) {
+ } catch (NotEnabledException e1) {
+ } catch (NotHandledException e1) {
+ }
+ } catch (WorkbenchException e) {
+ e.printStackTrace();
+ }
+ }
+ }
/**
* Test open and close of view.
@@ -147,13 +140,12 @@
public void testOpenCloseView() {
IViewPart consoleView = null;
try {
- IWorkbenchPage page = PlatformUI.getWorkbench().showPerspective(
- ORG_ECLIPSE_JDT_UI_JAVA_PERSPECTIVE, workbenchWindow);
- for (index = 0; index < numIterations; index++) {
- consoleView = page
- .showView("org.eclipse.ui.views.ResourceNavigator");
- page.hideView(consoleView);
- }
+ IWorkbenchPage page = PlatformUI.getWorkbench().showPerspective(ORG_ECLIPSE_JDT_UI_JAVA_PERSPECTIVE,
+ workbenchWindow);
+ for (index = 0; index < numIterations; index++) {
+ consoleView = page.showView("org.eclipse.ui.views.ResourceNavigator");
+ page.hideView(consoleView);
+ }
} catch (WorkbenchException e) {
e.printStackTrace();
}
@@ -166,9 +158,8 @@
public void testOpenCloseIntro() {
IIntroPart introPart = null;
for (index = 0; index < numIterations; index++) {
- introPart = PlatformUI.getWorkbench().getIntroManager().showIntro(
- workbenchWindow, false);
- PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
+ introPart = PlatformUI.getWorkbench().getIntroManager().showIntro(workbenchWindow, false);
+ PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
}
}
}
diff --git a/tests/org.eclipse.ui.tests/build.properties b/tests/org.eclipse.ui.tests/build.properties
index ab20764..1bcacd2 100644
--- a/tests/org.eclipse.ui.tests/build.properties
+++ b/tests/org.eclipse.ui.tests/build.properties
@@ -10,9 +10,7 @@
# Lars Vogel <Lars.Vogel@vogella.com> - Bug 474544
###############################################################################
source.. = Eclipse JFace Tests/,\
- Eclipse UI Tests/,\
- Eclipse Part References Test/,\
- Benchmark Tests/
+ Eclipse UI Tests/
bin.includes = icons/,\
doc/,\
@@ -22,9 +20,5 @@
.,\
plugin.xml,\
test.xml,\
- uiSniff,\
- uiSniff.bat,\
META-INF/
-src.includes = about.html
-
-javacWarnings.uitests.jar=-deadCode,-raw,-unchecked
+src.includes = about.html
\ No newline at end of file