Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2015-09-15 08:19:27 +0000
committerFlorian Barbin2015-09-16 08:12:01 +0000
commitb95959ea4433fd6c5c99025476840bbb6f74d44d (patch)
treea89604f8aeb37ed351b032acdfce637aac361d5c
parent6ea7e9f3e5f1e911cad8b320510d372a71fa8fd9 (diff)
downloadorg.eclipse.sirius-b95959ea4433fd6c5c99025476840bbb6f74d44d.tar.gz
org.eclipse.sirius-b95959ea4433fd6c5c99025476840bbb6f74d44d.tar.xz
org.eclipse.sirius-b95959ea4433fd6c5c99025476840bbb6f74d44d.zip
[477191] Adds a new test in the RepairOnStyleCustomizationsTest.
* The 477191 issue occurred with unsynchronized diagrams. This commit adds a new test to check the unsynchronized case. Bug: 477191 Change-Id: Id22736510de495b5c89a20b7c46b13b39deaeb1a Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.aird6
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.ecore7
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java67
3 files changed, 45 insertions, 35 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.aird
index 8796c24f45..a7c195587a 100644
--- a/plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.aird
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.aird
@@ -84,9 +84,9 @@
<foregroundColor xmi:type="viewpoint:RGBValues" xmi:id="_2peOUC2nEeKG1qVh92N5RA" red="227" green="164" blue="156"/>
</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="_1x4fAC2nEeKG1qVh92N5RA" name="NewEClass1" tooltipText="newPackage1.NewEClass1" incomingEdges="_3-Po4C2nEeKG1qVh92N5RA">
- <target xmi:type="ecore:EClass" href="VP-3643.ecore#//newPackage1/NewEClass1"/>
- <semanticElements xmi:type="ecore:EClass" href="VP-3643.ecore#//newPackage1/NewEClass1"/>
+ <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_1x4fAC2nEeKG1qVh92N5RA" name="NewEClass2" tooltipText="newPackage1.NewEClass2" incomingEdges="_3-Po4C2nEeKG1qVh92N5RA">
+ <target xmi:type="ecore:EClass" href="VP-3643.ecore#//newPackage1/NewEClass2"/>
+ <semanticElements xmi:type="ecore:EClass" href="VP-3643.ecore#//newPackage1/NewEClass2"/>
<ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_1ymQsC2nEeKG1qVh92N5RA" backgroundStyle="GradientTopToBottom">
<labelColor xmi:type="viewpoint:RGBValues" xmi:id="_1ymQsS2nEeKG1qVh92N5RA"/>
<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"/>
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.ecore
index 0f2ec00155..ab11d821bb 100644
--- a/plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.ecore
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/repair/customizations/VP-3643.ecore
@@ -1,12 +1,11 @@
<?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"
+<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="">
<eClassifiers xsi:type="ecore:EClass" name="NewEClass1">
- <eStructuralFeatures xsi:type="ecore:EReference" name="newEReference1" eType="#//newPackage1/NewEClass1"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="newEReference1" eType="#//newPackage1/NewEClass2"/>
</eClassifiers>
<eSubpackages name="newPackage1">
- <eClassifiers xsi:type="ecore:EClass" name="NewEClass1"/>
+ <eClassifiers xsi:type="ecore:EClass" name="NewEClass2"/>
</eSubpackages>
<eSubpackages name="newPackage2"/>
</ecore:EPackage>
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java
index 8b702aef03..aac1472f60 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/migration/RepairOnStyleCustomizationsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 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
@@ -11,16 +11,13 @@
package org.eclipse.sirius.tests.unit.diagram.migration;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.sirius.business.api.color.RGBValuesProvider;
+import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.business.api.session.SessionStatus;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
@@ -44,8 +41,6 @@ import org.eclipse.sirius.viewpoint.ViewpointPackage;
import org.eclipse.sirius.viewpoint.description.SystemColor;
import org.eclipse.ui.IEditorPart;
-import com.google.common.collect.Iterators;
-
/**
* Test that the repair process restore only customizations and leave the
* refresh update the non customized features.
@@ -67,38 +62,54 @@ public class RepairOnStyleCustomizationsTest extends AbstractRepairMigrateTest {
@Override
protected void setUp() throws Exception {
super.setUp();
-
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SEMANTIC_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_RESOURCE_NAME);
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + REPRESENTATIONS_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + REPRESENTATIONS_RESOURCE_NAME);
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + IMAGE, "/" + TEMPORARY_PROJECT_NAME + "/" + IMAGE);
}
/**
+ * same test than testRepairOnStyleCustomizations but with an unsynchronized
+ * diagram.
+ *
+ * @throws Exception
+ */
+ public void testRepairOnStyleCustomizationsUnsynchronized() throws Exception {
+ testRepairOnStyleCustomizations(true);
+
+ }
+
+ /**
* Test that the repair process restore only customizations and leave the
* refresh update the non customized features. Test also that the repair
* process doesn't reset a WorkspaceImage set to display a background image.
*
* @throws Exception
*/
- @SuppressWarnings({ "unchecked" })
public void testRepairOnStyleCustomizations() throws Exception {
- // Launch a repair
- runRepairProcess(REPRESENTATIONS_RESOURCE_NAME);
+ testRepairOnStyleCustomizations(false);
+ }
- // Check the fontFormat and the foregroundColor
- URI representationsResourceURI = URI.createPlatformResourceURI("/" + TEMPORARY_PROJECT_NAME + "/" + REPRESENTATIONS_RESOURCE_NAME, true);
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource representationsResource = resourceSet.getResource(representationsResourceURI, true);
+ @SuppressWarnings("unchecked")
+ private void testRepairOnStyleCustomizations(boolean unsynchronized) throws Exception {
- Iterator<DDiagram> filter = Iterators.filter(representationsResource.getAllContents(), DDiagram.class);
- assertTrue("It miss a DDiagram in the aird resource", filter.hasNext());
- DDiagram dDiagram = filter.next();
+ URI representationsResourceURI = URI.createPlatformResourceURI("/" + TEMPORARY_PROJECT_NAME + "/" + REPRESENTATIONS_RESOURCE_NAME, true);
+ if (unsynchronized) {
+ session = SessionManager.INSTANCE.getSession(representationsResourceURI, defaultProgress);
+ DDiagram dDiagram = (DDiagram) getRepresentations("Entities").iterator().next();
+ unsynchronizeDiagram(dDiagram);
+ session.save(defaultProgress);
+ }
+ // Launch a repair
+ runRepairProcess(REPRESENTATIONS_RESOURCE_NAME);
+ session = SessionManager.INSTANCE.getSession(representationsResourceURI, defaultProgress);
+ session.open(defaultProgress);
+ DDiagram dDiagram = (DDiagram) getRepresentations("Entities").iterator().next();
assertEquals("The DDiagram after repair should always contains 4 direct child DDiagramElements", 4, dDiagram.getOwnedDiagramElements().size());
- DDiagramElement dDiagramElementOfEPackage = dDiagram.getOwnedDiagramElements().get(0);
- DDiagramElement dDiagramElementOfEPackageWithWorkspaceImage = dDiagram.getOwnedDiagramElements().get(1);
- DDiagramElement dDiagramElementOfEClass = dDiagram.getOwnedDiagramElements().get(2);
- DDiagramElement dDiagramElementOfEReference = dDiagram.getOwnedDiagramElements().get(3);
+ DDiagramElement dDiagramElementOfEPackage = getDiagramElementsFromLabel(dDiagram, "newPackage1").get(0);
+ DDiagramElement dDiagramElementOfEPackageWithWorkspaceImage = getDiagramElementsFromLabel(dDiagram, "newPackage2").get(0);
+ DDiagramElement dDiagramElementOfEClass = getDiagramElementsFromLabel(dDiagram, "NewEClass1").get(0);
+ DDiagramElement dDiagramElementOfEReference = getDiagramElementsFromLabel(dDiagram, "[0..1] newEReference1").get(0);
assertTrue(dDiagramElementOfEPackage instanceof DNodeContainer);
assertTrue(dDiagramElementOfEPackageWithWorkspaceImage instanceof DNodeContainer);
@@ -111,12 +122,12 @@ public class RepairOnStyleCustomizationsTest extends AbstractRepairMigrateTest {
DEdge dEdgeOfEReference = (DEdge) dDiagramElementOfEReference;
RGBValuesProvider rgbValuesProvider = new RGBValuesProvider();
- RGBValues foregroundColorRGBValuesFromDescriptionForEClass = rgbValuesProvider.getRGBValues((SystemColor) ((FlatContainerStyleDescription) dNodeListOfEClass.getStyle().getDescription())
- .getForegroundColor());
- RGBValues foregroundColorRGBValuesFromDescriptionForEPackage = rgbValuesProvider.getRGBValues((SystemColor) ((FlatContainerStyleDescription) dNodeContainerOfEPackage.getStyle()
- .getDescription()).getForegroundColor());
- RGBValues strokeColorRGBValuesFromDescriptionForEReference = rgbValuesProvider.getRGBValues((SystemColor) ((EdgeStyleDescription) dEdgeOfEReference.getStyle().getDescription())
- .getStrokeColor());
+ RGBValues foregroundColorRGBValuesFromDescriptionForEClass = rgbValuesProvider
+ .getRGBValues((SystemColor) ((FlatContainerStyleDescription) dNodeListOfEClass.getStyle().getDescription()).getForegroundColor());
+ RGBValues foregroundColorRGBValuesFromDescriptionForEPackage = rgbValuesProvider
+ .getRGBValues((SystemColor) ((FlatContainerStyleDescription) dNodeContainerOfEPackage.getStyle().getDescription()).getForegroundColor());
+ RGBValues strokeColorRGBValuesFromDescriptionForEReference = rgbValuesProvider
+ .getRGBValues((SystemColor) ((EdgeStyleDescription) dEdgeOfEReference.getStyle().getDescription()).getStrokeColor());
String assertMessage = "The new color should be the new one computed by the refresh from the VSM";
assertEquals(assertMessage, strokeColorRGBValuesFromDescriptionForEReference.getRed(), dEdgeOfEReference.getOwnedStyle().getStrokeColor().getRed());

Back to the top