diff options
-rw-r--r-- | plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/multipageeditor/SiriusMultiPageEditorTest.java | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/multipageeditor/SiriusMultiPageEditorTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/multipageeditor/SiriusMultiPageEditorTest.java index 53d8e12d0a..12439261a7 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/multipageeditor/SiriusMultiPageEditorTest.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/multipageeditor/SiriusMultiPageEditorTest.java @@ -10,9 +10,11 @@ *******************************************************************************/ package org.eclipse.sirius.tests.unit.multipageeditor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.transaction.RunnableWithResult; import org.eclipse.sirius.business.api.session.CustomDataConstants; import org.eclipse.sirius.diagram.tools.api.command.DiagramCommandFactoryService; import org.eclipse.sirius.diagram.tools.api.command.IDiagramCommandFactory; @@ -25,6 +27,7 @@ import org.eclipse.sirius.ui.business.api.session.SessionEditorInput; import org.eclipse.sirius.viewpoint.DRepresentation; import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.MultiPageEditorPart; @@ -54,6 +57,8 @@ public class SiriusMultiPageEditorTest extends SiriusTestCase { private IDiagramCommandFactory commandFactory; + private IEditorPart openEditor; + @Override protected void setUp() throws Exception { super.setUp(); @@ -61,6 +66,15 @@ public class SiriusMultiPageEditorTest extends SiriusTestCase { } + @Override + protected void tearDown() throws Exception { + if (openEditor != null) { + openEditor.dispose(); + } + super.tearDown(); + + } + /** * Tests that {@link DDiagramEditorImpl} opens correctly inside a * {@link MultiPageEditorPart} without exceptions. This tests particularly @@ -79,17 +93,36 @@ public class SiriusMultiPageEditorTest extends SiriusTestCase { final IEditorInput editorInput = new SessionEditorInput(uri, editorName, session); final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); assertFalse(doesAnErrorOccurs()); - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + + RunnableWithResult<IEditorPart> result = new RunnableWithResult<IEditorPart>() { + private IEditorPart resultEditor; @Override public void run() { try { - activePage.openEditor(editorInput, SIRIUS_MULTI_PAGE_EDITOR_ID); + resultEditor = activePage.openEditor(editorInput, SIRIUS_MULTI_PAGE_EDITOR_ID); } catch (Exception e) { throw new RuntimeException(e); } } - }); + + @Override + public IEditorPart getResult() { + return resultEditor; + } + + @Override + public void setStatus(IStatus status) { + + } + + @Override + public IStatus getStatus() { + return null; + } + }; + PlatformUI.getWorkbench().getDisplay().syncExec(result); + openEditor = result.getResult(); assertFalse("No error should have occurs during opening of the Sirius Diagram editor inside a multi page editor.", doesAnErrorOccurs()); } |