diff options
| author | Laurent Fasani | 2015-07-27 07:48:19 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-08-11 09:18:08 +0000 |
| commit | 992463d0ccdda3424faa53fa927527508d2122a2 (patch) | |
| tree | b13fbd4e178b059339a479c39b84d2049ba4650a | |
| parent | 12d9fb965a2c8f7b6f49610e936ed8151d7a542d (diff) | |
| download | org.eclipse.sirius-992463d0ccdda3424faa53fa927527508d2122a2.tar.gz org.eclipse.sirius-992463d0ccdda3424faa53fa927527508d2122a2.tar.xz org.eclipse.sirius-992463d0ccdda3424faa53fa927527508d2122a2.zip | |
[474672] Fix bendpoints source and target update at node move
Before this commit, the result is OK visually (draw2d) but not in GMF.
Bug: 474672
Change-Id: I0be5367d6130f3df1360fd66b5872f000fefc86f
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
5 files changed, 299 insertions, 4 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToExtremityMoveCommmand.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToExtremityMoveCommmand.java index b7ac280b9f..0300df9f0a 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToExtremityMoveCommmand.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToExtremityMoveCommmand.java @@ -150,10 +150,10 @@ public class SetConnectionBendpointsAccordingToExtremityMoveCommmand extends Set if (isEdgeWithRectilinearRoutingStyle) { LineSeg firstSegment = new LineSeg(connectionPointList.getPoint(0), connectionPointList.getPoint(1)); if (firstSegment.isHorizontal()) { - connectionPointList.setPoint(connectionPointList.getPoint(0).translate(0, moveDelta.y), 0); + connectionPointList.setPoint(connectionPointList.getPoint(0).translate(moveDelta.x, moveDelta.y), 0); connectionPointList.setPoint(connectionPointList.getPoint(1).translate(0, moveDelta.y), 1); } else { - connectionPointList.setPoint(connectionPointList.getPoint(0).translate(moveDelta.x, 0), 0); + connectionPointList.setPoint(connectionPointList.getPoint(0).translate(moveDelta.x, moveDelta.y), 0); connectionPointList.setPoint(connectionPointList.getPoint(1).translate(moveDelta.x, 0), 1); } } else { @@ -175,10 +175,10 @@ public class SetConnectionBendpointsAccordingToExtremityMoveCommmand extends Set LineSeg lastSegment = new LineSeg(connectionPointList.getPoint(connectionPointList.size() - 2), connectionPointList.getPoint(connectionPointList.size() - 1)); if (lastSegment.isHorizontal()) { connectionPointList.setPoint(connectionPointList.getPoint(connectionPointList.size() - 2).translate(0, moveDelta.y), connectionPointList.size() - 2); - connectionPointList.setPoint(connectionPointList.getPoint(connectionPointList.size() - 1).translate(0, moveDelta.y), connectionPointList.size() - 1); + connectionPointList.setPoint(connectionPointList.getPoint(connectionPointList.size() - 1).translate(moveDelta.x, moveDelta.y), connectionPointList.size() - 1); } else { connectionPointList.setPoint(connectionPointList.getPoint(connectionPointList.size() - 2).translate(moveDelta.x, 0), connectionPointList.size() - 2); - connectionPointList.setPoint(connectionPointList.getPoint(connectionPointList.size() - 1).translate(moveDelta.x, 0), connectionPointList.size() - 1); + connectionPointList.setPoint(connectionPointList.getPoint(connectionPointList.size() - 1).translate(moveDelta.x, moveDelta.y), connectionPointList.size() - 1); } } else { // Compute intersection between the line diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/bendpointsStability/otherSpecificCases/My.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/bendpointsStability/otherSpecificCases/My.aird new file mode 100644 index 0000000000..21f35773bc --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/bendpointsStability/otherSpecificCases/My.aird @@ -0,0 +1,88 @@ +<?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="__OXRoD_3EeWEGe6pBhmYQg" selectedViews="_AEoyUD_4EeWEGe6pBhmYQg" version="10.1.0.201507101000"> + <semanticResources>My.ecore</semanticResources> + <ownedViews xmi:type="viewpoint:DRepresentationContainer" xmi:id="_AEoyUD_4EeWEGe6pBhmYQg"> + <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_AIKAYD_4EeWEGe6pBhmYQg" name="rectilinearCase1"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_AIKAYT_4EeWEGe6pBhmYQg" source="DANNOTATION_CUSTOMIZATION_KEY"> + <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_AIKAYj_4EeWEGe6pBhmYQg"/> + </ownedAnnotationEntries> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_AIQHAD_4EeWEGe6pBhmYQg" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_AIQHAT_4EeWEGe6pBhmYQg" type="Sirius" element="_AIKAYD_4EeWEGe6pBhmYQg" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_AITxYD_4EeWEGe6pBhmYQg" type="2003" element="_AIKAYz_4EeWEGe6pBhmYQg"> + <children xmi:type="notation:Node" xmi:id="_AIZQ8D_4EeWEGe6pBhmYQg" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_AIZ4AD_4EeWEGe6pBhmYQg" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_AIZ4AT_4EeWEGe6pBhmYQg"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_AIZ4Aj_4EeWEGe6pBhmYQg"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_AITxYT_4EeWEGe6pBhmYQg" fontName="Ubuntu" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_AITxYj_4EeWEGe6pBhmYQg" x="20" y="20" width="115" height="96"/> + </children> + <children xmi:type="notation:Node" xmi:id="_AIafED_4EeWEGe6pBhmYQg" type="2003" element="_AIKAZT_4EeWEGe6pBhmYQg"> + <children xmi:type="notation:Node" xmi:id="_AIbGID_4EeWEGe6pBhmYQg" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_AIbGIT_4EeWEGe6pBhmYQg" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_AIbGIj_4EeWEGe6pBhmYQg"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_AIbGIz_4EeWEGe6pBhmYQg"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_AIafET_4EeWEGe6pBhmYQg" fontName="Ubuntu" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_AIafEj_4EeWEGe6pBhmYQg" x="360" y="220" width="115" height="96"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_AIQHAj_4EeWEGe6pBhmYQg"/> + <edges xmi:type="notation:Edge" xmi:id="_l6zGMD_4EeWEGe6pBhmYQg" type="4001" element="_l6kcsD_4EeWEGe6pBhmYQg" source="_AITxYD_4EeWEGe6pBhmYQg" target="_AIafED_4EeWEGe6pBhmYQg"> + <children xmi:type="notation:Node" xmi:id="_l6ztQD_4EeWEGe6pBhmYQg" type="6001"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_l6ztQT_4EeWEGe6pBhmYQg" x="-14" y="49"/> + </children> + <children xmi:type="notation:Node" xmi:id="_l6ztQj_4EeWEGe6pBhmYQg" type="6002"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_l6ztQz_4EeWEGe6pBhmYQg" x="-16" y="21"/> + </children> + <children xmi:type="notation:Node" xmi:id="_l6ztRD_4EeWEGe6pBhmYQg" type="6003"> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_l6ztRT_4EeWEGe6pBhmYQg" x="-37" y="-120"/> + </children> + <styles xmi:type="notation:ConnectorStyle" xmi:id="_l6zGMT_4EeWEGe6pBhmYQg" routing="Rectilinear"/> + <styles xmi:type="notation:FontStyle" xmi:id="_l6zGMj_4EeWEGe6pBhmYQg" fontName="Ubuntu" fontHeight="8"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_l6zGMz_4EeWEGe6pBhmYQg" points="[0, 0, -227, -240]$[47, 0, -180, -240]$[47, 100, -180, -140]$[127, 100, -100, -140]$[127, 240, -100, 0]$[227, 240, 0, 0]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_l6ztRj_4EeWEGe6pBhmYQg" id="(1.0,0.425531914893617)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_l6ztRz_4EeWEGe6pBhmYQg" id="(0.0,0.851063829787234)"/> + </edges> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_AIKAYz_4EeWEGe6pBhmYQg" name="C1" tooltipText="root.C1" outgoingEdges="_l6kcsD_4EeWEGe6pBhmYQg"> + <target xmi:type="ecore:EClass" href="My.ecore#//C1"/> + <semanticElements xmi:type="ecore:EClass" href="My.ecore#//C1"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_AIKAZD_4EeWEGe6pBhmYQg" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="GradientTopToBottom"> + <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"/> + </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 xmi:type="diagram:DNodeList" xmi:id="_AIKAZT_4EeWEGe6pBhmYQg" name="C2" tooltipText="root.C2" incomingEdges="_l6kcsD_4EeWEGe6pBhmYQg"> + <target xmi:type="ecore:EClass" href="My.ecore#//C2"/> + <semanticElements xmi:type="ecore:EClass" href="My.ecore#//C2"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_AIKAZj_4EeWEGe6pBhmYQg" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="GradientTopToBottom"> + <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"/> + </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 xmi:type="diagram:DEdge" xmi:id="_l6kcsD_4EeWEGe6pBhmYQg" name="[0..1] toC2" sourceNode="_AIKAYz_4EeWEGe6pBhmYQg" targetNode="_AIKAZT_4EeWEGe6pBhmYQg"> + <target xmi:type="ecore:EReference" href="My.ecore#//C1/toC2"/> + <semanticElements xmi:type="ecore:EReference" href="My.ecore#//C1/toC2"/> + <ownedStyle xmi:type="diagram:EdgeStyle" xmi:id="_l6lq0D_4EeWEGe6pBhmYQg" routingStyle="manhattan"> + <customFeatures>routingStyle</customFeatures> + <description xmi:type="style:EdgeStyleDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']/@style"/> + <centerLabelStyle xmi:type="diagram:CenterLabelStyle" xmi:id="_l6lq0T_4EeWEGe6pBhmYQg" showIcon="false"/> + </ownedStyle> + <actualMapping xmi:type="description_1:EdgeMapping" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@edgeMappings[name='EC_EReference']"/> + </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="_AIKAZz_4EeWEGe6pBhmYQg"/> + <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/data/unit/bendpointsStability/otherSpecificCases/My.ecore b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/bendpointsStability/otherSpecificCases/My.ecore new file mode 100644 index 0000000000..d817108d20 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/bendpointsStability/otherSpecificCases/My.ecore @@ -0,0 +1,8 @@ +<?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="root"> + <eClassifiers xsi:type="ecore:EClass" name="C1"> + <eStructuralFeatures xsi:type="ecore:EReference" name="toC2" eType="#//C2"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="C2"/> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BendpointsStabilityOnMovesSpecificCasesTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BendpointsStabilityOnMovesSpecificCasesTest.java new file mode 100644 index 0000000000..b89bcc3a0c --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BendpointsStabilityOnMovesSpecificCasesTest.java @@ -0,0 +1,198 @@ +/******************************************************************************* + * Copyright (c) 2014, 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; + +import static org.junit.Assert.assertNotEquals; + +import java.util.List; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; +import org.eclipse.sirius.diagram.DSemanticDiagram; +import org.eclipse.sirius.diagram.ui.edit.api.part.IAbstractDiagramNodeEditPart; +import org.eclipse.sirius.diagram.ui.internal.refresh.GMFHelper; +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.api.condition.CheckEditPartMoved; +import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; +import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefConnectionEditPart; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; +import org.eclipse.swtbot.swt.finder.waits.ICondition; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +/** + * This class is complementary to {@link BendpointsStabilityOnMovesTest} but + * with specific cases detected after. + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + */ +public class BendpointsStabilityOnMovesSpecificCasesTest extends AbstractSiriusSwtBotGefTestCase { + + private static final String PROPERTIES_VIEW_ID = "org.eclipse.ui.views.PropertySheet"; + + private static final String DATA_UNIT_DIR = "data/unit/bendpointsStability/otherSpecificCases/"; + + private static final String MODEL = "My.ecore"; + + private static final String SESSION_FILE = "My.aird"; + + private static final String DIAGRAM_DESCRIPTION_NAME = "Entities"; + + boolean isOutlineViewOpened; + + boolean isPropertiesViewOpened; + + @Override + protected void onSetUpBeforeClosingWelcomePage() throws Exception { + copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE); + } + + @Override + protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { + sessionAirdResource = new UIResource(designerProject, "/", SESSION_FILE); + + localSession = designerPerspective.openSessionFromFile(sessionAirdResource); + // Close outline & property view (to improve test performances) + final IWorkbenchPage currentPage = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getPages()[0]; + final IViewReference[] viewReferences = currentPage.getViewReferences(); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + for (int i = 0; i < viewReferences.length; i++) { + if ("org.eclipse.ui.views.ContentOutline".equals(viewReferences[i].getId())) { + isOutlineViewOpened = true; + currentPage.hideView(viewReferences[i]); + } else if (PROPERTIES_VIEW_ID.equals(viewReferences[i].getId())) { + isPropertiesViewOpened = true; + currentPage.hideView(viewReferences[i]); + } + } + } + }); + } + + @Override + protected void tearDown() throws Exception { + if (isOutlineViewOpened) { + designerViews.openOutlineView(); + } + if (isPropertiesViewOpened) { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + try { + PlatformUI.getWorkbench().getWorkbenchWindows()[0].getPages()[0].showView(PROPERTIES_VIEW_ID); + } catch (PartInitException e) { + fail("Could not reopen property view during teardown : " + e.getMessage()); + } + } + }); + } + SWTBotUtils.waitAllUiEvents(); + super.tearDown(); + } + + /** + * Test that last point is moved has expected and that draw2d and GMF last + * points are consistency. + */ + public void testLastPointConsistency() { + // Step 1: open the testing diagram editor + SWTBotSiriusDiagramEditor diagramEditor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), DIAGRAM_DESCRIPTION_NAME, "rectilinearCase1", DSemanticDiagram.class); + try { + String nodeToMoveName = "C2"; + diagramEditor.reveal(nodeToMoveName); + // Step 2: store the previous bendpoints + SWTBotGefEditPart editPartToMove = diagramEditor.getEditPart(nodeToMoveName, IAbstractDiagramNodeEditPart.class); + SWTBotGefConnectionEditPart connectionEditPart = editPartToMove.targetConnections().get(0); + PointList previousPoints = ((PolylineConnectionEx) connectionEditPart.part().getFigure()).getPoints(); + + // Step 3: Drag node + Point moveDelta = new Point(-20, 50); + Point initialLocation = diagramEditor.getBounds(editPartToMove).getCenter(); + Point targetLocation = new Point(initialLocation.x + moveDelta.x, initialLocation.y + moveDelta.y); + ICondition editPartMovedCondition = new CheckEditPartMoved(editPartToMove); + diagramEditor.drag(initialLocation, targetLocation); + bot.waitUntil(editPartMovedCondition); + assertEquals("Drag as failed: selection should be the same before and after drag.", editPartToMove, diagramEditor.selectedEditParts().get(0)); + // Step 4: Check bendpoints + compareActualBendpointsWithExpected(diagramEditor, connectionEditPart, previousPoints, moveDelta, false); + } finally { + diagramEditor.close(); + SWTBotUtils.waitAllUiEvents(); + } + } + + /** + * Test that first point is moved has expected and that draw2d and GMF last + * points are consistency. + */ + public void testFirstPointConsistency() { + // Step 1: open the testing diagram editor + SWTBotSiriusDiagramEditor diagramEditor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), DIAGRAM_DESCRIPTION_NAME, "rectilinearCase1", DSemanticDiagram.class); + try { + String nodeToMoveName = "C1"; + diagramEditor.reveal(nodeToMoveName); + // Step 2: store the previous bendpoints + SWTBotGefEditPart editPartToMove = diagramEditor.getEditPart(nodeToMoveName, IAbstractDiagramNodeEditPart.class); + SWTBotGefConnectionEditPart connectionEditPart = editPartToMove.sourceConnections().get(0); + PointList previousPoints = ((PolylineConnectionEx) connectionEditPart.part().getFigure()).getPoints(); + + // Step 3: Drag node + Point moveDelta = new Point(20, 20); + Point initialLocation = diagramEditor.getBounds(editPartToMove).getCenter(); + Point targetLocation = new Point(initialLocation.x + moveDelta.x, initialLocation.y + moveDelta.y); + ICondition editPartMovedCondition = new CheckEditPartMoved(editPartToMove); + diagramEditor.drag(initialLocation, targetLocation); + bot.waitUntil(editPartMovedCondition); + assertEquals("Drag as failed: selection should be the same before and after drag.", editPartToMove, diagramEditor.selectedEditParts().get(0)); + // Step 4: Check bendpoints + compareActualBendpointsWithExpected(diagramEditor, connectionEditPart, previousPoints, moveDelta, true); + } finally { + diagramEditor.close(); + SWTBotUtils.waitAllUiEvents(); + } + } + + // Check the first or last benpoint of the connection. + private void compareActualBendpointsWithExpected(SWTBotSiriusDiagramEditor diagramEditor, SWTBotGefConnectionEditPart connectionEditPart, PointList expectedBendPoints, Point moveDelta, + boolean firstPoint) { + PointList actualBendPoints = ((PolylineConnectionEx) connectionEditPart.part().getFigure()).getPoints(); + List<Point> newGMFBendpointsFromSource = GMFHelper.getPointsFromSource(connectionEditPart.part()); + Point expectedDraw2dPoint; + Point actualDraw2dPoint; + Point actualGmfPoint; + if (firstPoint) { + expectedDraw2dPoint = expectedBendPoints.getFirstPoint(); + actualDraw2dPoint = actualBendPoints.getFirstPoint(); + actualGmfPoint = newGMFBendpointsFromSource.get(0); + } else { + expectedDraw2dPoint = expectedBendPoints.getLastPoint(); + actualDraw2dPoint = actualBendPoints.getLastPoint(); + actualGmfPoint = newGMFBendpointsFromSource.get(newGMFBendpointsFromSource.size() - 1); + } + // The first (or last) bendpoint should have moved. + String messagePrefix = "First"; + if (!firstPoint) { + messagePrefix = "Last"; + } + assertNotEquals(messagePrefix + " point should have moved", expectedDraw2dPoint, actualDraw2dPoint); + assertEquals(messagePrefix + " point should have moved at the expected location", expectedDraw2dPoint.getTranslated(moveDelta), actualDraw2dPoint); + // The draw2d and GMF point should be the same. + assertEquals(messagePrefix + " draw2d and GMF points should be the same", actualDraw2dPoint, actualGmfPoint); + } +} 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 fb2d343fc2..19088411e9 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 @@ -344,6 +344,7 @@ public class AllTestSuite extends TestCase { suite.addTestSuite(BracketEdgeTests.class); suite.addTestSuite(EdgeCopyPasteLayoutTest.class); suite.addTestSuite(BendpointsStabilityOnMovesTest.class); + suite.addTestSuite(BendpointsStabilityOnMovesSpecificCasesTest.class); suite.addTestSuite(BorderedNodeCopyPastLayoutTest.class); suite.addTestSuite(ContainerDefaultSizeLayoutTest.class); suite.addTestSuite(ModifyEdgeLayoutAfterRefreshTest.class); |
