diff options
| author | Mickael ADAM | 2017-08-02 08:00:37 +0000 |
|---|---|---|
| committer | vincent lorenzo | 2017-09-01 09:00:08 +0000 |
| commit | 89e2ce2171030b79eb62e61a45ad25d6a655554b (patch) | |
| tree | 5f4d1a9927891ad61b32887ec95b0bf0e8aaf1b1 | |
| parent | f139df60e5418da0ae90662f1d6ed8bd4b8e4454 (diff) | |
| download | org.eclipse.papyrus-89e2ce2171030b79eb62e61a45ad25d6a655554b.tar.gz org.eclipse.papyrus-89e2ce2171030b79eb62e61a45ad25d6a655554b.tar.xz org.eclipse.papyrus-89e2ce2171030b79eb62e61a45ad25d6a655554b.zip | |
Bug 520439 - [Test] Graphical direction customization on connectors must
be tested
Change-Id: I511bcaf9be298b76646fe4ebe8818ea04bcbb003
Signed-off-by: Mickael ADAM <mickael.adam@all4tec.net>
5 files changed, 380 insertions, 2 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.di b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.di new file mode 100644 index 00000000000..08128862c28 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<architecture:ArchitectureDescription xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:architecture="http://www.eclipse.org/papyrus/infra/core/architecture" contextId="org.eclipse.papyrus.infra.services.edit.TypeContext"/>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.notation b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.notation new file mode 100644 index 00000000000..16c24c9f7dd --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.notation @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/gmfdiag/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML">
+ <notation:Diagram xmi:id="_L3wvYHaSEeeEHdA8pJmIgQ" type="CompositeStructure" name="Composite Structure Diagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_BPhI4HaTEeeEHdA8pJmIgQ" type="Class_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_BPkzQHaTEeeEHdA8pJmIgQ" type="Class_NameLabel"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="_BPkzQXaTEeeEHdA8pJmIgQ" type="Class_FloatingNameLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BPkzQnaTEeeEHdA8pJmIgQ" y="15"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_BPlaUHaTEeeEHdA8pJmIgQ" type="Class_StructureCompartment">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_BPlaUXaTEeeEHdA8pJmIgQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_BPlaUnaTEeeEHdA8pJmIgQ"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_BP8msHaTEeeEHdA8pJmIgQ" type="compartment_shape_display">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_BP8msXaTEeeEHdA8pJmIgQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_BP8msnaTEeeEHdA8pJmIgQ"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_Bq-84HaTEeeEHdA8pJmIgQ" type="Port_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_Bq_j8HaTEeeEHdA8pJmIgQ" type="Port_NameLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Bq_j8XaTEeeEHdA8pJmIgQ" x="25" y="3"/>
+ </children>
+ <children xmi:type="notation:DecorationNode" xmi:id="_Bq_j8naTEeeEHdA8pJmIgQ" type="Port_StereotypeLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Bq_j83aTEeeEHdA8pJmIgQ" x="25" y="-10"/>
+ </children>
+ <element xmi:type="uml:Port" href="edgeCustomisation.uml#_BqZHAHaTEeeEHdA8pJmIgQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Bq-84XaTEeeEHdA8pJmIgQ" x="531" y="50" width="20" height="20"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_COAxcHaTEeeEHdA8pJmIgQ" type="Port_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_COBYgHaTEeeEHdA8pJmIgQ" type="Port_NameLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_COBYgXaTEeeEHdA8pJmIgQ" x="25" y="3"/>
+ </children>
+ <children xmi:type="notation:DecorationNode" xmi:id="_COBYgnaTEeeEHdA8pJmIgQ" type="Port_StereotypeLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_COBYg3aTEeeEHdA8pJmIgQ" x="25" y="-10"/>
+ </children>
+ <element xmi:type="uml:Port" href="edgeCustomisation.uml#_CN3ngHaTEeeEHdA8pJmIgQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_COAxcXaTEeeEHdA8pJmIgQ" x="531" y="210" width="20" height="20"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_IlDyEHaeEeeEHdA8pJmIgQ" type="Port_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_IlEZIHaeEeeEHdA8pJmIgQ" type="Port_NameLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_IlEZIXaeEeeEHdA8pJmIgQ" x="25" y="3"/>
+ </children>
+ <children xmi:type="notation:DecorationNode" xmi:id="_IlEZInaeEeeEHdA8pJmIgQ" type="Port_StereotypeLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_IlEZI3aeEeeEHdA8pJmIgQ" x="25" y="-10"/>
+ </children>
+ <element xmi:type="uml:Port" href="edgeCustomisation.uml#_Ik4y8HaeEeeEHdA8pJmIgQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_IlDyEXaeEeeEHdA8pJmIgQ" x="110" y="311" width="20" height="20"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_JEccwHaeEeeEHdA8pJmIgQ" type="Port_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_JEccwnaeEeeEHdA8pJmIgQ" type="Port_NameLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_JEccw3aeEeeEHdA8pJmIgQ" x="25" y="3"/>
+ </children>
+ <children xmi:type="notation:DecorationNode" xmi:id="_JEdD0HaeEeeEHdA8pJmIgQ" type="Port_StereotypeLabel">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_JEdD0XaeEeeEHdA8pJmIgQ" x="25" y="-10"/>
+ </children>
+ <element xmi:type="uml:Port" href="edgeCustomisation.uml#_JEVIAHaeEeeEHdA8pJmIgQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_JEccwXaeEeeEHdA8pJmIgQ" x="310" y="311" width="20" height="20"/>
+ </children>
+ <element xmi:type="uml:Class" href="edgeCustomisation.uml#_BPZNEHaTEeeEHdA8pJmIgQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_BPhI4XaTEeeEHdA8pJmIgQ" x="60" y="60" width="541" height="321"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_L3wvYXaSEeeEHdA8pJmIgQ" name="diagram_compatibility_version" stringValue="1.3.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_L3wvYnaSEeeEHdA8pJmIgQ"/>
+ <styles xmi:type="style:PapyrusDiagramStyle" xmi:id="_L3wvY3aSEeeEHdA8pJmIgQ" diagramKindId="org.eclipse.papyrus.uml.diagram.compositeStructure.root.package">
+ <owner xmi:type="uml:Model" href="edgeCustomisation.uml#_L12q4HaSEeeEHdA8pJmIgQ"/>
+ </styles>
+ <styles xmi:type="notation:EObjectListValueStyle" xmi:id="_rnyVAHaeEeeEHdA8pJmIgQ" name="css_stylesheets" eObjectListValue="_rnzjIHaeEeeEHdA8pJmIgQ"/>
+ <element xmi:type="uml:Model" href="edgeCustomisation.uml#_L12q4HaSEeeEHdA8pJmIgQ"/>
+ <edges xmi:type="notation:Connector" xmi:id="_DWT2QHaTEeeEHdA8pJmIgQ" type="Connector_Edge" source="_Bq-84HaTEeeEHdA8pJmIgQ" target="_COAxcHaTEeeEHdA8pJmIgQ">
+ <children xmi:type="notation:DecorationNode" xmi:id="_DWVEYHaTEeeEHdA8pJmIgQ" type="Connector_StereotypeLabel">
+ <styles xmi:type="notation:BooleanValueStyle" xmi:id="_QgXbwHaeEeeEHdA8pJmIgQ" name="IS_UPDATED_POSITION" booleanValue="true"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_DWVEYXaTEeeEHdA8pJmIgQ" x="-1" y="58"/>
+ </children>
+ <children xmi:type="notation:DecorationNode" xmi:id="_DWVEYnaTEeeEHdA8pJmIgQ" type="Connector_NameLabel">
+ <styles xmi:type="notation:BooleanValueStyle" xmi:id="_Qgia4HaeEeeEHdA8pJmIgQ" name="IS_UPDATED_POSITION" booleanValue="true"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_DWVEY3aTEeeEHdA8pJmIgQ" x="1" y="-16"/>
+ </children>
+ <styles xmi:type="notation:FontStyle" xmi:id="_DWT2QXaTEeeEHdA8pJmIgQ"/>
+ <element xmi:type="uml:Connector" href="edgeCustomisation.uml#_DV2jQHaTEeeEHdA8pJmIgQ"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_DWT2QnaTEeeEHdA8pJmIgQ" points="[611, 126, -643984, -643984]$[680, 200, -643984, -643984]$[611, 273, -643984, -643984]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Dy9WAHaTEeeEHdA8pJmIgQ" id="(1.0,0.8)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_DWy-cHaTEeeEHdA8pJmIgQ" id="(1.0,0.15)"/>
+ </edges>
+ <edges xmi:type="notation:Connector" xmi:id="_KTKSoHaeEeeEHdA8pJmIgQ" type="Connector_Edge" source="_IlDyEHaeEeeEHdA8pJmIgQ" target="_JEccwHaeEeeEHdA8pJmIgQ">
+ <children xmi:type="notation:DecorationNode" xmi:id="_KTKSo3aeEeeEHdA8pJmIgQ" type="Connector_StereotypeLabel">
+ <styles xmi:type="notation:BooleanValueStyle" xmi:id="_K-2T8HaeEeeEHdA8pJmIgQ" name="IS_UPDATED_POSITION" booleanValue="true"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_KTKSpHaeEeeEHdA8pJmIgQ" x="-1" y="57"/>
+ </children>
+ <children xmi:type="notation:DecorationNode" xmi:id="_KTKSpXaeEeeEHdA8pJmIgQ" type="Connector_NameLabel">
+ <styles xmi:type="notation:BooleanValueStyle" xmi:id="_K_B6IHaeEeeEHdA8pJmIgQ" name="IS_UPDATED_POSITION" booleanValue="true"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_KTK5sHaeEeeEHdA8pJmIgQ" x="1" y="-19"/>
+ </children>
+ <styles xmi:type="notation:FontStyle" xmi:id="_KTKSoXaeEeeEHdA8pJmIgQ"/>
+ <styles xmi:type="notation:StringListValueStyle" xmi:id="_6Eh18HafEeeEHdA8pJmIgQ" name="cssClass">
+ <stringListValue>edgeCusto</stringListValue>
+ </styles>
+ <element xmi:type="uml:Connector" href="edgeCustomisation.uml#_KTBvwHaeEeeEHdA8pJmIgQ"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_KTKSonaeEeeEHdA8pJmIgQ" points="[190, 391, -643984, -643984]$[280, 460, -643984, -643984]$[370, 391, -643984, -643984]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_K-rU0HaeEeeEHdA8pJmIgQ" id="(1.0,1.0)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_KTkiUHaeEeeEHdA8pJmIgQ" id="(0.0,1.0)"/>
+ </edges>
+ <edges xmi:type="notation:Connector" xmi:id="_M8AkMHaeEeeEHdA8pJmIgQ" type="Connector_Edge" source="_JEccwHaeEeeEHdA8pJmIgQ" target="_COAxcHaTEeeEHdA8pJmIgQ">
+ <children xmi:type="notation:DecorationNode" xmi:id="_M8AkM3aeEeeEHdA8pJmIgQ" type="Connector_StereotypeLabel">
+ <styles xmi:type="notation:BooleanValueStyle" xmi:id="_NoyxsHaeEeeEHdA8pJmIgQ" name="IS_UPDATED_POSITION" booleanValue="true"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_M8AkNHaeEeeEHdA8pJmIgQ" x="1" y="59"/>
+ </children>
+ <children xmi:type="notation:DecorationNode" xmi:id="_M8AkNXaeEeeEHdA8pJmIgQ" type="Connector_NameLabel">
+ <styles xmi:type="notation:BooleanValueStyle" xmi:id="_NpXZcHaeEeeEHdA8pJmIgQ" name="IS_UPDATED_POSITION" booleanValue="true"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_M8AkNnaeEeeEHdA8pJmIgQ" x="1" y="-18"/>
+ </children>
+ <styles xmi:type="notation:FontStyle" xmi:id="_M8AkMXaeEeeEHdA8pJmIgQ"/>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_XzqDMHaeEeeEHdA8pJmIgQ" name="sourceDecoration" stringValue="solid_diamond_filled"/>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_ZAseEHaeEeeEHdA8pJmIgQ" name="targetDecoration" stringValue="open_arrow"/>
+ <element xmi:type="uml:Connector" href="edgeCustomisation.uml#_M7zv4HaeEeeEHdA8pJmIgQ"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_M8AkMnaeEeeEHdA8pJmIgQ" points="[390, 381, -643984, -643984]$[600, 460, -643984, -643984]$[680, 380, -643984, -643984]$[607, 290, -643984, -643984]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_NooZoHaeEeeEHdA8pJmIgQ" id="(1.0,0.5)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_NooZoXaeEeeEHdA8pJmIgQ" id="(0.8,1.0)"/>
+ </edges>
+ </notation:Diagram>
+ <css:EmbeddedStyleSheet xmi:id="_rnzjIHaeEeeEHdA8pJmIgQ" label="" content=".edgeCusto{
sourceDecoration: "open_arrow";
targetDecoration: "open_arrow";
}"/>
+</xmi:XMI>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.uml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.uml new file mode 100644 index 00000000000..5cd95853a7b --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/resources/edgeCustomisation/edgeCustomisation.uml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_L12q4HaSEeeEHdA8pJmIgQ" name="edgeCustomisation">
+ <packagedElement xmi:type="uml:Class" xmi:id="_BPZNEHaTEeeEHdA8pJmIgQ" name="Class1">
+ <ownedAttribute xmi:type="uml:Port" xmi:id="_BqZHAHaTEeeEHdA8pJmIgQ" name="Port1" aggregation="composite"/>
+ <ownedAttribute xmi:type="uml:Port" xmi:id="_CN3ngHaTEeeEHdA8pJmIgQ" name="Port2" aggregation="composite"/>
+ <ownedAttribute xmi:type="uml:Port" xmi:id="_Ik4y8HaeEeeEHdA8pJmIgQ" name="Port3" aggregation="composite"/>
+ <ownedAttribute xmi:type="uml:Port" xmi:id="_JEVIAHaeEeeEHdA8pJmIgQ" name="Port4" aggregation="composite"/>
+ <ownedConnector xmi:type="uml:Connector" xmi:id="_DV2jQHaTEeeEHdA8pJmIgQ" name="DefaultConnector">
+ <end xmi:type="uml:ConnectorEnd" xmi:id="_DV6NoHaTEeeEHdA8pJmIgQ" role="_BqZHAHaTEeeEHdA8pJmIgQ"/>
+ <end xmi:type="uml:ConnectorEnd" xmi:id="_DV60sHaTEeeEHdA8pJmIgQ" role="_CN3ngHaTEeeEHdA8pJmIgQ"/>
+ </ownedConnector>
+ <ownedConnector xmi:type="uml:Connector" xmi:id="_KTBvwHaeEeeEHdA8pJmIgQ" name="CSSConnector">
+ <end xmi:type="uml:ConnectorEnd" xmi:id="_KTCW0HaeEeeEHdA8pJmIgQ" role="_Ik4y8HaeEeeEHdA8pJmIgQ"/>
+ <end xmi:type="uml:ConnectorEnd" xmi:id="_KTCW0XaeEeeEHdA8pJmIgQ" role="_JEVIAHaeEeeEHdA8pJmIgQ"/>
+ </ownedConnector>
+ <ownedConnector xmi:type="uml:Connector" xmi:id="_M7zv4HaeEeeEHdA8pJmIgQ" name="PropertiesSetConnector">
+ <end xmi:type="uml:ConnectorEnd" xmi:id="_M70W8HaeEeeEHdA8pJmIgQ" role="_JEVIAHaeEeeEHdA8pJmIgQ"/>
+ <end xmi:type="uml:ConnectorEnd" xmi:id="_M70W8XaeEeeEHdA8pJmIgQ" role="_CN3ngHaTEeeEHdA8pJmIgQ"/>
+ </ownedConnector>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java index 8c951ffcd8d..0be076fcff0 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java @@ -10,7 +10,7 @@ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation * Christian W. Damus - bug 471954 * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 507488 - * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 518645 + * Micka�l ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 518645 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.tests.tests; @@ -42,7 +42,8 @@ import org.junit.runners.Suite.SuiteClasses; Bug495430_DuplicatedTransitionsTest.class, Bug488744_PortPositionTest.class, Bug507488_BinaryRelationshipLabelPositionTest.class, - StereotypePropertyReferenceEdgeTest.class + StereotypePropertyReferenceEdgeTest.class, + EdgeCustomizationTest.class }) public class AllTests { diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/EdgeCustomizationTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/EdgeCustomizationTest.java new file mode 100644 index 00000000000..d1f04b8a6e9 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/EdgeCustomizationTest.java @@ -0,0 +1,235 @@ +/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST, ALL4TEC 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.tests.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Iterator;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.RotatableDecoration;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStyleValueCommand;
+import org.eclipse.papyrus.infra.gmfdiag.common.decoration.ConnectionDecorationRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.decoration.OpenArrowConnectionDecoration;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.edge.PapyrusEdgeFigure;
+import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.DiagramUtils;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * <pre>
+ * Tests for the edge source and target decoration customization.
+ * </pre>
+ *
+ * @author Mickaël ADAM
+ */
+@SuppressWarnings("nls")
+@PluginResource("/resources/edgeCustomisation/edgeCustomisation.di")
+public class EdgeCustomizationTest extends AbstractPapyrusTest {
+
+ /** The model set fixture. */
+ @Rule
+ public final PapyrusEditorFixture modelSetFixture = new PapyrusEditorFixture();
+
+ /** The diagram. */
+ private Diagram diagram = null;
+
+ /** The connector edit part with default style. */
+ private EditPart defaultConnectorEditPart = null;
+
+ /** The connector edit part with CSS style. */
+ private EditPart cssConnectorEditPart = null;
+
+ /** The connector edit part with style set with properties view. */
+ private EditPart propertiesConnectorEditPart = null;
+
+ /**
+ * Initialize tests.
+ */
+ @Before
+ public void init() {
+ diagram = DiagramUtils.getNotationDiagram((ModelSet) modelSetFixture.getResourceSet(), "Composite Structure Diagram");
+ assertNotNull(diagram);
+
+ defaultConnectorEditPart = getEditPart("DefaultConnector");
+ Assert.assertTrue("The Edit Part must be a ConnectionEditPart", defaultConnectorEditPart instanceof ConnectionEditPart);
+
+ cssConnectorEditPart = getEditPart("CSSConnector");
+ Assert.assertTrue("The Edit Part must be a ConnectionEditPart", cssConnectorEditPart instanceof ConnectionEditPart);
+
+ propertiesConnectorEditPart = getEditPart("PropertiesSetConnector");
+ Assert.assertTrue("The Edit Part must be a ConnectionEditPart", propertiesConnectorEditPart instanceof ConnectionEditPart);
+ }
+
+
+ /**
+ * Test the edge decoration customization.
+ */
+ @Test
+ public void testEdgeDecoration() {
+ testDefaultEdgeDecoration();
+ testPropertiesEdgeDecoration();
+ testCSSEdgeDecoration();
+ }
+
+ /**
+ * Test the {@link ConnectionDecorationRegistry}.
+ */
+ @Test
+ public void testConnectionDecorationRegistry() {
+ Class<? extends RotatableDecoration> decorationClass = ConnectionDecorationRegistry.getInstance().getDecorationClass("open_arrow");
+ assertNotNull("open_arrow decoration must exist", decorationClass);
+ if (null != decorationClass) {
+ // load the class
+ RotatableDecoration decoration = ClassLoaderHelper.newInstance(decorationClass);
+ assertTrue("Instanciate decoration must be instance of OpenArrowConnectionDecoration", decoration instanceof OpenArrowConnectionDecoration);
+ }
+ }
+
+ /**
+ * Test the connector with default edge decoration.
+ */
+ private void testDefaultEdgeDecoration() {
+ IFigure primaryShape = ((IPapyrusEditPart) defaultConnectorEditPart).getPrimaryShape();
+ Assert.assertTrue("The Figure must implement PapyrusEdgeFigure", primaryShape instanceof PapyrusEdgeFigure);
+
+ // Default value test:
+ String sourceDecoration = extract((StringValueStyle) ((View) defaultConnectorEditPart.getModel()).getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), ConnectionEditPart.SOURCE_DECORATION));
+ assertNull("Default source decoration must be null", sourceDecoration);
+
+ // Set Value Style
+ getCommandStack().execute(
+ new CustomStyleValueCommand((View) defaultConnectorEditPart.getModel(), "open_arrow", NotationPackage.eINSTANCE.getStringValueStyle(), NotationPackage.eINSTANCE.getStringValueStyle_StringValue(), ConnectionEditPart.SOURCE_DECORATION));
+
+ // test of set command
+ sourceDecoration = extract((StringValueStyle) ((View) defaultConnectorEditPart.getModel()).getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), ConnectionEditPart.SOURCE_DECORATION));
+ assertEquals("SourceDecoration value style must be open_arrow", "open_arrow", sourceDecoration);
+ }
+
+ /**
+ * Test the connector with edge decoration set with properties view.
+ */
+ private void testPropertiesEdgeDecoration() {
+ IFigure primaryShape = ((IPapyrusEditPart) propertiesConnectorEditPart).getPrimaryShape();
+ Assert.assertTrue("The Figure must implement PapyrusEdgeFigure", primaryShape instanceof PapyrusEdgeFigure);
+
+ // Default value test:
+ String sourceDecoration = extract((StringValueStyle) ((View) propertiesConnectorEditPart.getModel()).getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), ConnectionEditPart.SOURCE_DECORATION));
+ assertEquals("SourceDecoration value style must be solid_diamond_filled", "solid_diamond_filled", sourceDecoration);
+
+ // Set Value Style
+ getCommandStack().execute(
+ new CustomStyleValueCommand((View) propertiesConnectorEditPart.getModel(), "open_arrow", NotationPackage.eINSTANCE.getStringValueStyle(), NotationPackage.eINSTANCE.getStringValueStyle_StringValue(), ConnectionEditPart.SOURCE_DECORATION));
+
+ // test of set command
+ sourceDecoration = extract((StringValueStyle) ((View) propertiesConnectorEditPart.getModel()).getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), ConnectionEditPart.SOURCE_DECORATION));
+ assertEquals("SourceDecoration value style must be open_arrow", "open_arrow", sourceDecoration);
+ }
+
+ /**
+ * Test the connector with edge decoration set with CSS.
+ */
+ private void testCSSEdgeDecoration() {
+ IFigure primaryShape = ((IPapyrusEditPart) cssConnectorEditPart).getPrimaryShape();
+ Assert.assertTrue("The Figure must implement PapyrusEdgeFigure", primaryShape instanceof PapyrusEdgeFigure);
+
+ // Default value test:
+ String sourceDecoration = extract((StringValueStyle) ((View) cssConnectorEditPart.getModel()).getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), ConnectionEditPart.SOURCE_DECORATION));
+ assertEquals("SourceDecoration value style must be open_arrow", "open_arrow", sourceDecoration);
+
+ // Set Value Style
+ getCommandStack().execute(
+ new CustomStyleValueCommand((View) cssConnectorEditPart.getModel(), "solid_diamond_filled", NotationPackage.eINSTANCE.getStringValueStyle(), NotationPackage.eINSTANCE.getStringValueStyle_StringValue(), ConnectionEditPart.SOURCE_DECORATION));
+
+ // test of set command
+ sourceDecoration = extract((StringValueStyle) ((View) cssConnectorEditPart.getModel()).getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), ConnectionEditPart.SOURCE_DECORATION));
+ assertEquals("SourceDecoration value style must be solid_diamond_filled", "solid_diamond_filled", sourceDecoration);
+ }
+
+
+ /**
+ * Gets the command stack.
+ *
+ * @return the command stack
+ */
+ private CommandStack getCommandStack() {
+ return modelSetFixture.getEditingDomain().getCommandStack();
+ }
+
+ /**
+ * Gets the edit part.
+ *
+ * @param semanticElement
+ * the semantic element name
+ * @return the edit part
+ */
+ private EditPart getEditPart(final String semanticElement) {
+ modelSetFixture.getPageManager().openPage(diagram);
+
+ View diagramView = DiagramUtils.findShape(diagram, semanticElement);
+ if (null == diagramView) {
+ diagramView = DiagramUtils.findEdge(diagram, semanticElement);
+ }
+ if (null == diagramView) {
+ Iterator<?> iterator = diagram.eAllContents();
+ while (null == diagramView && iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof View) {
+ diagramView = DiagramUtils.findShape((View) object, semanticElement);
+ if (null == diagramView) {
+ diagramView = DiagramUtils.findEdge((View) object, semanticElement);
+ }
+ }
+ }
+ }
+ assertNotNull(diagramView);
+ IGraphicalEditPart semanticEP = DiagramUtils.findEditPartforView(modelSetFixture.getEditor(), diagramView, IGraphicalEditPart.class);
+ assertNotNull(semanticEP);
+
+ return semanticEP;
+ }
+
+ /**
+ * Extracts the string value from the given style
+ *
+ * @param style
+ * The style
+ * @return The primitive value
+ */
+ private String extract(final StringValueStyle style) {
+ if (null == style || null == style.getStringValue() || style.getStringValue().isEmpty()) {
+ return null;
+ }
+ return style.getStringValue();
+ }
+
+}
|
