diff options
| author | Belqassim Djafer | 2015-01-19 10:03:31 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-01-21 07:56:52 +0000 |
| commit | 7d5d88dcf2b3eb0ccea1a1bcdffa34033cdedbe2 (patch) | |
| tree | 3c3529ab149d5e6e15e04e565c285fd56fd2cf1c | |
| parent | fb6277008e1b9f83dd4330568fe54dc3bce4e959 (diff) | |
| download | org.eclipse.sirius-7d5d88dcf2b3eb0ccea1a1bcdffa34033cdedbe2.tar.gz org.eclipse.sirius-7d5d88dcf2b3eb0ccea1a1bcdffa34033cdedbe2.tar.xz org.eclipse.sirius-7d5d88dcf2b3eb0ccea1a1bcdffa34033cdedbe2.zip | |
[452681] Test Representation visibility after Session reload
Ensure that the representation still appears under its semantic
resource in the Model Explorer view after session reload.
Bug: 452681
Change-Id: Ibab866c8378a23fcea7629f2895f31311127e37a
Signed-off-by: Belqassim Djafer <belqassim.djafer@obeo.fr>
4 files changed, 205 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/modelExplorer/My.ecore b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/modelExplorer/My.ecore new file mode 100644 index 0000000000..d8606b884e --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/modelExplorer/My.ecore @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="P0"> + <eSubpackages name="P1"> + <eClassifiers xsi:type="ecore:EClass" name="C1"/> + </eSubpackages> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/modelExplorer/representations.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/modelExplorer/representations.aird new file mode 100644 index 0000000000..5d507f6c0b --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/modelExplorer/representations.aird @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<viewpoint:DAnalysis xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style" xmi:id="_eBRlQKCDEeSWT5AoN_4btw" selectedViews="_kbkIIKCDEeSWT5AoN_4btw" version="10.0.0.201412231738"> + <models xmi:type="ecore:EPackage" href="My.ecore#/"/> + <ownedViews xmi:type="viewpoint:DRepresentationContainer" xmi:id="_kbkIIKCDEeSWT5AoN_4btw" initialized="true"> + <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_kdxHkKCDEeSWT5AoN_4btw" name="P0 package entities"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_kdxuoKCDEeSWT5AoN_4btw" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_kdxuoaCDEeSWT5AoN_4btw" type="Sirius" element="_kdxHkKCDEeSWT5AoN_4btw" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_kdxuo6CDEeSWT5AoN_4btw" type="2002" element="_kdxHkaCDEeSWT5AoN_4btw"> + <children xmi:type="notation:Node" xmi:id="_kdyVsKCDEeSWT5AoN_4btw" type="5006"/> + <children xmi:type="notation:Node" xmi:id="_kdyVsaCDEeSWT5AoN_4btw" type="7001"> + <children xmi:type="notation:Node" xmi:id="_kdyVtKCDEeSWT5AoN_4btw" type="3009" element="_kdxHl6CDEeSWT5AoN_4btw"> + <children xmi:type="notation:Node" xmi:id="_kdy8wKCDEeSWT5AoN_4btw" type="5004"/> + <children xmi:type="notation:Node" xmi:id="_kdy8waCDEeSWT5AoN_4btw" type="7003"> + <styles xmi:type="notation:SortingStyle" xmi:id="_kdy8wqCDEeSWT5AoN_4btw"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_kdy8w6CDEeSWT5AoN_4btw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_kdyVtaCDEeSWT5AoN_4btw" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kdyVtqCDEeSWT5AoN_4btw"/> + </children> + <styles xmi:type="notation:SortingStyle" xmi:id="_kdyVsqCDEeSWT5AoN_4btw"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_kdyVs6CDEeSWT5AoN_4btw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_kdxupKCDEeSWT5AoN_4btw" fontName="Segoe UI" fontHeight="10"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kdxupaCDEeSWT5AoN_4btw"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_kdxuoqCDEeSWT5AoN_4btw"/> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_kdxHkaCDEeSWT5AoN_4btw" name="P1"> + <target xmi:type="ecore:EPackage" href="My.ecore#//P1"/> + <semanticElements xmi:type="ecore:EPackage" href="My.ecore#//P1"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_kdxHkqCDEeSWT5AoN_4btw" labelSize="10" backgroundStyle="GradientTopToBottom"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_kdxHk6CDEeSWT5AoN_4btw"/> + <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']/@containerMappings[name='Design%20Package']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_kdxHlKCDEeSWT5AoN_4btw"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_kdxHlaCDEeSWT5AoN_4btw" red="255" green="245" blue="181"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_kdxHlqCDEeSWT5AoN_4btw" red="255" green="255" blue="255"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']/@containerMappings[name='Design%20Package']"/> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_kdxHl6CDEeSWT5AoN_4btw" name="C1" tooltipText="P1.C1"> + <target xmi:type="ecore:EClass" href="My.ecore#//P1/C1"/> + <semanticElements xmi:type="ecore:EClass" href="My.ecore#//P1/C1"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_kdxHmKCDEeSWT5AoN_4btw" backgroundStyle="GradientTopToBottom"> + <labelColor xmi:type="viewpoint:RGBValues" xmi:id="_kdxHmaCDEeSWT5AoN_4btw"/> + <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> + <borderColor xmi:type="viewpoint:RGBValues" xmi:id="_kdxHmqCDEeSWT5AoN_4btw"/> + <backgroundColor xmi:type="viewpoint:RGBValues" xmi:id="_kdxHm6CDEeSWT5AoN_4btw" red="255" green="255" blue="255"/> + <foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_kdxHnKCDEeSWT5AoN_4btw" red="209" green="209" blue="209"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> + </ownedDiagramElements> + </ownedDiagramElements> + <description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_kdxHnaCDEeSWT5AoN_4btw"/> + <activatedLayers xmi:type="description_1:Layer" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer"/> + <activatedLayers xmi:type="description_1:AdditionalLayer" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']"/> + <target xmi:type="ecore:EPackage" href="My.ecore#/"/> + </ownedRepresentations> + <viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']"/> + </ownedViews> +</viewpoint:DAnalysis> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/modelexplorer/RepresentationVisibilityAfterSessionReloadTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/modelexplorer/RepresentationVisibilityAfterSessionReloadTest.java new file mode 100644 index 0000000000..2d440d54d4 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/modelexplorer/RepresentationVisibilityAfterSessionReloadTest.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * Copyright (c) 2015 THALES GLOBAL SERVICES. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.tests.swtbot.modelexplorer; + +import java.io.IOException; +import java.util.Collections; +import java.util.Iterator; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.sirius.ecore.extender.tool.api.ModelUtils; +import org.eclipse.sirius.tests.swtbot.Activator; +import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase; +import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource; +import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils; +import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.IModelExplorerView; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; + +/** + * Test representation visibility in Model Explorer view after session reload. + * + * @author <a href="mailto:belqassim.djafer@obeo.fr">Belqassim Djafer</a> + */ +public class RepresentationVisibilityAfterSessionReloadTest extends AbstractSiriusSwtBotGefTestCase { + + private static final String SEMANTIC_RESOURCE_NAME = "My.ecore"; + + private static final String SESSION_RESOURCE_NAME = "representations.aird"; + + private static final String PATH = "data/unit/modelExplorer/"; + + private static final String REPRESENTATION_DESCRIPTION_NAME = "P0 package entities"; + + private UIResource sessionAirdResource; + + private SWTBot modelExplorerViewBot; + + @Override + protected void onSetUpBeforeClosingWelcomePage() throws Exception { + copyFileToTestProject(Activator.PLUGIN_ID, PATH, SEMANTIC_RESOURCE_NAME, SESSION_RESOURCE_NAME); + } + + @Override + protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { + sessionAirdResource = new UIResource(designerProject, SESSION_RESOURCE_NAME); + localSession = designerPerspective.openSessionFromFile(sessionAirdResource, true); + SWTBotView modelExplorerView = bot.viewById(IModelExplorerView.ID); + SWTBotUtils.waitAllUiEvents(); + modelExplorerView.setFocus(); + modelExplorerViewBot = modelExplorerView.bot(); + } + + /** + * Ensure that the representation still appears under its semantic resource + * in the Model Explorer view after session reload. + */ + public void testRepresentationVisibilityAfterSessionReload() { + // Check that the representation appears in Model Explorer before + // session reload + checkRepresentationVisibility(true); + // Edit the semantic model + editTheSemanticModel(); + // Check that the representation still appears in Model Explorer after + // session reload + checkRepresentationVisibility(false); + } + + /** + * Check that the representation appears in Model Explorer before or after + * session reload. + * + * @param sessionReload + * true before session reload, otherwise false. + */ + private void checkRepresentationVisibility(boolean sessionReload) { + SWTBotTreeItem projectTreeItemBot = modelExplorerViewBot.tree().expandNode(getProjectName(), false); + SWTBotTreeItem representationTreeItemBot = projectTreeItemBot.getNode(SESSION_RESOURCE_NAME).expand(); + SWTBotTreeItem semanticResourceTreeItemBot = representationTreeItemBot.getNode(1).expand(); + SWTBotTreeItem rootPackageTreeItemBot = semanticResourceTreeItemBot.getNode(0).expand(); + // Ensure that the representation exists in the root package + if (sessionReload) { + assertTrue("The representation '" + REPRESENTATION_DESCRIPTION_NAME + "' should exist in " + rootPackageTreeItemBot.getText() + " before session reload", rootPackageTreeItemBot.getNodes() + .contains(REPRESENTATION_DESCRIPTION_NAME)); + } else { + assertTrue("The representation '" + REPRESENTATION_DESCRIPTION_NAME + "' should exist in " + rootPackageTreeItemBot.getText() + " after session reload", rootPackageTreeItemBot.getNodes() + .contains(REPRESENTATION_DESCRIPTION_NAME)); + } + } + + /** + * Edit the semantic model and save resource. + */ + private void editTheSemanticModel() { + TransactionalEditingDomain domain = new TransactionalEditingDomainImpl(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)); + ResourceSet set = domain.getResourceSet(); + + Iterator<Resource> resourcesIterator = localSession.getOpenedSession().getSemanticResources().iterator(); + EPackage ePackage = null; + if (resourcesIterator.hasNext()) { + Resource semanticResource = resourcesIterator.next(); + if (!semanticResource.getContents().isEmpty()) { + ePackage = ((EPackage) semanticResource.getContents().get(0)).getESubpackages().get(0); + } + } + try { + final EPackage ePackageInAnotherResourceSet = (EPackage) ModelUtils.load(ePackage.eResource().getURI(), set); + assertFalse("The editing domain of each root semantic must be different.", domain.equals(TransactionUtil.getEditingDomain(ePackage))); + domain.getCommandStack().execute(new RecordingCommand(domain, "Remove all classes") { + @Override + protected void doExecute() { + ePackageInAnotherResourceSet.getEClassifiers().clear(); + } + }); + ePackageInAnotherResourceSet.eResource().save(Collections.EMPTY_MAP); + } catch (IOException e) { + fail("Promblem when saving the resource in another resourceSet : " + e.getMessage()); + } + } +} diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java index 2b4f3de5b4..7c4a4fc1b2 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java @@ -49,6 +49,7 @@ import org.eclipse.sirius.tests.swtbot.modelexplorer.LinkWithEditorFeatureWithMo import org.eclipse.sirius.tests.swtbot.modelexplorer.ModelExplorerFilterTests; import org.eclipse.sirius.tests.swtbot.modelexplorer.ProjectDependenciesTest; import org.eclipse.sirius.tests.swtbot.modelexplorer.ProjectsConcurrentCloseTest; +import org.eclipse.sirius.tests.swtbot.modelexplorer.RepresentationVisibilityAfterSessionReloadTest; import org.eclipse.sirius.tests.swtbot.tabbar.LockedTabBarTest; import org.eclipse.sirius.tests.swtbot.tabbar.NotInvisibleTabBarTest; import org.eclipse.sirius.tests.swtbot.tabbar.TabBarTest; @@ -208,6 +209,7 @@ public class AllTestSuite extends TestCase { suite.addTestSuite(EditorSavingTest.class); suite.addTestSuite(EmptyPropertyViewAfterDeletionTest.class); suite.addTestSuite(LinkWithEditorFeatureWithModelExplorerViewTest.class); + suite.addTestSuite(RepresentationVisibilityAfterSessionReloadTest.class); suite.addTestSuite(HideRevealDiagramElementsLabelsTest.class); suite.addTestSuite(HideRevealDiagramElementsLabelsTestWithOldUI.class); suite.addTestSuite(HideLabelIconsWithPreferencesTest.class); |
