diff options
author | Oleg Besedin | 2011-12-12 19:09:36 +0000 |
---|---|---|
committer | Oleg Besedin | 2011-12-12 19:11:18 +0000 |
commit | 0d98115edaf95f17982215d3c9d54e435d26d1dd (patch) | |
tree | 9f448152e247e5cfaa4067081e576edef5caa68b | |
parent | c84cf95f51a9adbe911bf751805c3ef2ca2c8add (diff) | |
download | eclipse.platform.ui-0d98115edaf95f17982215d3c9d54e435d26d1dd.tar.gz eclipse.platform.ui-0d98115edaf95f17982215d3c9d54e435d26d1dd.tar.xz eclipse.platform.ui-0d98115edaf95f17982215d3c9d54e435d26d1dd.zip |
Bug 351851 - [Compatibility] we need to fix up 122 errors in our
org.eclipse.ui.tests bundle
2 files changed, 64 insertions, 53 deletions
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/Bug108033Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/Bug108033Test.java index 78d8555e1a1..4600858d86a 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/Bug108033Test.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/Bug108033Test.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2011 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 @@ -10,8 +10,15 @@ *******************************************************************************/ package org.eclipse.ui.tests.session; +import java.util.List; + import junit.framework.TestCase; +import org.eclipse.e4.ui.model.application.ui.MElementContainer; +import org.eclipse.e4.ui.model.application.ui.MUIElement; +import org.eclipse.e4.ui.model.application.ui.MUILabel; +import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.ui.IPerspectiveDescriptor; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbench; @@ -20,10 +27,6 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.ViewSite; -import org.eclipse.ui.internal.ViewStack; -import org.eclipse.ui.internal.presentations.PresentablePart; -import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation; -import org.eclipse.ui.presentations.IPresentablePart; /** * Bug 108033 Need a test to ensure that view tab order is the same on start up @@ -94,18 +97,34 @@ public class Bug108033Test extends TestCase { IViewPart problemView = instantiateViews(); ViewSite site = (ViewSite) problemView.getSite(); - ViewStack stack = (ViewStack) site.getPane().getContainer(); - - TabbedStackPresentation pres = (TabbedStackPresentation) stack - .getTestPresentation(); - - verifyOrder(pres, new String[] { "Tasks", "Progress", "Problems" }); - IPresentablePart part = getPresentablePart(site); - assertNotNull(part); - - pres.moveTab(part, 0); + MElementContainer<MUIElement> stack = getParent(site.getModel()); + + verifyOrder(stack, new String[] { "Tasks", "Progress", "Problems" }); + moveTab(stack, problemView, 0); - verifyOrder(pres, new String[] { "Problems", "Tasks", "Progress" }); + verifyOrder(stack, new String[] { "Problems", "Tasks", "Progress" }); + } + + // TBD should this be in the ModelService or PartService? + private MElementContainer<MUIElement> getParent(MUIElement element) { + MElementContainer<MUIElement> parent = element.getParent(); + if (parent != null) + return parent; + MPlaceholder placeholder = element.getCurSharedRef(); + if (placeholder != null) + return placeholder.getParent(); + return null; + } + + private void moveTab(MElementContainer<MUIElement> stack, IViewPart viewPart, int indexTo) { + ViewSite site = (ViewSite) viewPart.getSite(); + MPart part = site.getModel(); + List<MUIElement> children = stack.getChildren(); + int indexFrom = children.indexOf(part); + assertTrue(indexFrom >= 0); + children.remove(part); + children.add(indexTo, part); + stack.setSelectedElement(part); } /** @@ -119,12 +138,9 @@ public class Bug108033Test extends TestCase { IViewPart problemView = instantiateViews(); ViewSite site = (ViewSite) problemView.getSite(); - ViewStack stack = (ViewStack) site.getPane().getContainer(); + MElementContainer<MUIElement> stack = getParent(site.getModel()); - TabbedStackPresentation pres = (TabbedStackPresentation) stack - .getTestPresentation(); - - verifyOrder(pres, new String[] { "Problems", "Tasks", "Progress" }); + verifyOrder(stack, new String[] { "Problems", "Tasks", "Progress" }); } /** @@ -152,31 +168,15 @@ public class Bug108033Test extends TestCase { * @param order * the expected order */ - private void verifyOrder(TabbedStackPresentation pres, String[] order) { - IPresentablePart[] tabs = pres.getPartList(); - assertEquals("Different number of tabs", order.length, tabs.length); - for (int i = 0; i < tabs.length; ++i) { - assertEquals("Failed on tab " + i, order[i], tabs[i].getName()); + private void verifyOrder(MElementContainer<MUIElement> stack, String[] order) { + List<MUIElement> children = stack.getChildren(); + assertEquals("Different number of tabs", order.length, children.size()); + for (int i = 0; i < children.size(); ++i) { + MUIElement child = children.get(i); + if (child instanceof MPlaceholder) + child = ((MPlaceholder) child).getRef(); + assertEquals("Failed on tab " + i, order[i], ((MUILabel)child).getLabel()); } } - /** - * Get the presentable part for the view (view site). - * - * @param site - * the site of the view we want - * @return it's presentable part. - */ - private IPresentablePart getPresentablePart(ViewSite site) { - IPresentablePart[] partList = (IPresentablePart[]) ((ViewStack) site - .getPane().getContainer()).getPresentableParts().toArray( - new IPresentablePart[0]); - for (int i = 0; i < partList.length; i++) { - IPresentablePart part = partList[i]; - if (((PresentablePart) part).getPane() == site.getPane()) { - return part; - } - } - return null; - } } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/Bug95357Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/Bug95357Test.java index efcfd256b92..b16e060f63d 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/Bug95357Test.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/Bug95357Test.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2011 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 @@ -14,6 +14,9 @@ import junit.framework.TestCase; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; +import org.eclipse.e4.ui.model.application.ui.MElementContainer; +import org.eclipse.e4.ui.model.application.ui.MUIElement; +import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder; import org.eclipse.swt.SWT; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; @@ -24,7 +27,6 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.internal.EditorSite; -import org.eclipse.ui.internal.EditorStack; import org.eclipse.ui.tests.api.SessionEditorPart; import org.eclipse.ui.tests.dnd.DragOperations; import org.eclipse.ui.tests.dnd.EditorDropTarget; @@ -147,10 +149,8 @@ public class Bug95357Test extends TestCase { DragOperations.drag(current, new EditorDropTarget( new ExistingWindowProvider(fWin), 0, SWT.BOTTOM), false); - EditorStack firstStack = (EditorStack) ((EditorSite) last - .getEditorSite()).getPane().getContainer(); - EditorStack secondStack = (EditorStack) ((EditorSite) current - .getEditorSite()).getPane().getContainer(); + MElementContainer<MUIElement> firstStack = getParent(((EditorSite) last.getEditorSite()).getModel()); + MElementContainer<MUIElement> secondStack = getParent(((EditorSite) current.getEditorSite()).getModel()); for (int i = startAt; i < itsFilename.length; ++i) { fActivePage.activate(last); @@ -158,10 +158,21 @@ public class Bug95357Test extends TestCase { current = IDE.openEditor(fActivePage, FileUtil.createFile( itsFilename[i], fProject), true); } - assertEquals(Bug95357Test.FILE_MAX / 2, firstStack.getItemCount()); - assertEquals(Bug95357Test.FILE_MAX / 2, secondStack.getItemCount()); + assertEquals(Bug95357Test.FILE_MAX / 2, firstStack.getChildren().size()); + assertEquals(Bug95357Test.FILE_MAX / 2, secondStack.getChildren().size()); } + // TBD should this be in the ModelService or PartService? + private MElementContainer<MUIElement> getParent(MUIElement element) { + MElementContainer<MUIElement> parent = element.getParent(); + if (parent != null) + return parent; + MPlaceholder placeholder = element.getCurSharedRef(); + if (placeholder != null) + return placeholder.getParent(); + return null; + } + /** * Multiple editors in 2 stacks - part 2 of 2. 2 of the editors should have * been instantiated. The rest should still be inactive. |