Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2014-11-21 16:32:07 +0000
committerLaurent Redor2014-12-01 13:52:35 +0000
commit028332adc33a7c29a71fb00c9f9eb3620dd8137d (patch)
treef5425fb48c0ea4c48627d276317cbf6617105234
parent5ca028139011f2c30380af9c58158e8821bc26c5 (diff)
downloadorg.eclipse.sirius-028332adc33a7c29a71fb00c9f9eb3620dd8137d.tar.gz
org.eclipse.sirius-028332adc33a7c29a71fb00c9f9eb3620dd8137d.tar.xz
org.eclipse.sirius-028332adc33a7c29a71fb00c9f9eb3620dd8137d.zip
[452652] Wrong last GMF bendpoint in case of target move
Use second to last point instead of last point for intersection computation. The test UmlClassDragAndDropTest.testMoveClass() has been added to reveal the problem. Tests of UmlPortMoveTest and UmlPortDragAndDropTest have been also completed for checks on GMF bendpoints and reveal the problem of bug 452651. Bug: 452652 Bug: 452651 Change-Id: I03a59babdb51c1734c2d96f1324c613afac2b5df Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToExtremityMoveCommmand.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java66
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/uml2.aird2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/AbstractUmlDragAndDropTest.java108
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlClassDragAndDropTest.java37
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortDragAndDropTest.java12
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortMoveTest.java9
7 files changed, 220 insertions, 16 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 5a952dcb9c..4a28903d69 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
@@ -181,7 +181,7 @@ public class SetConnectionBendpointsAccordingToExtremityMoveCommmand extends Set
// (tempTargetRefPoint<-->second to last point) and the target
// node
// 2-Compute intersection
- Option<Point> intersectionPoint = GraphicalHelper.getIntersection(targetRefPoint, connectionPointList.getPoint(connectionPointList.size() - 1), bounds.getTranslated(moveDelta), false);
+ Option<Point> intersectionPoint = GraphicalHelper.getIntersection(targetRefPoint, connectionPointList.getPoint(connectionPointList.size() - 2), bounds.getTranslated(moveDelta), false);
if (intersectionPoint.some()) {
connectionPointList.setPoint(intersectionPoint.get(), connectionPointList.size() - 1);
} else {
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java
index bab871e6ee..bf9fcb2daf 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java
@@ -11,13 +11,16 @@
package org.eclipse.sirius.diagram.ui.internal.refresh;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
@@ -26,8 +29,10 @@ import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Location;
import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
import org.eclipse.gmf.runtime.notation.Size;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
import org.eclipse.sirius.common.ui.tools.api.util.EclipseUIUtil;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.ContainerStyle;
@@ -47,6 +52,7 @@ import org.eclipse.sirius.ext.base.Options;
import org.eclipse.ui.IEditorPart;
import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
/**
* GMF Helper.
@@ -553,4 +559,64 @@ public final class GMFHelper {
}
return result;
}
+
+ /**
+ * Get the points list computed from GMF bendpoints according to source side
+ * for the <code>edgeEditPart</code>.
+ *
+ * @param edgeEditPart
+ * The concerned edge edit part.
+ * @return Points list
+ * @throws IllegalArgumentException
+ * when the edgeEditPart is not as expected
+ */
+ public static List<Point> getPointsFromSource(ConnectionEditPart edgeEditPart) throws IllegalArgumentException {
+ if (edgeEditPart.getModel() instanceof Edge && edgeEditPart.getFigure() instanceof Connection) {
+ List<Point> result = Lists.newArrayList();
+ Edge gmfEdge = (Edge) edgeEditPart.getModel();
+ Connection connectionFigure = (Connection) edgeEditPart.getFigure();
+ Point srcAnchorLoc = connectionFigure.getSourceAnchor().getReferencePoint();
+ connectionFigure.translateToRelative(srcAnchorLoc);
+
+ RelativeBendpoints bp = (RelativeBendpoints) gmfEdge.getBendpoints();
+ for (int i = 0; i < bp.getPoints().size(); i++) {
+ RelativeBendpoint rbp = (RelativeBendpoint) bp.getPoints().get(i);
+ Point fromSrc = srcAnchorLoc.getTranslated(rbp.getSourceX(), rbp.getSourceY());
+ result.add(fromSrc);
+ }
+ return result;
+ }
+ throw new IllegalArgumentException(
+ "The model of the edgeEditPart should be a org.eclipse.gmf.runtime.notation.Edge and the figure of this edgeEditPart should be a org.eclipse.draw2d.Connection.");
+ }
+
+ /**
+ * Get the points list computed from GMF bendpoints according to target side
+ * for the <code>edgeEditPart</code>.
+ *
+ * @param edgeEditPart
+ * The concerned edge edit part.
+ * @return Points list
+ * @throws IllegalArgumentException
+ * when the edgeEditPart is not as expected
+ */
+ public static List<Point> getPointsFromTarget(ConnectionEditPart edgeEditPart) throws IllegalArgumentException {
+ if (edgeEditPart.getModel() instanceof Edge && edgeEditPart.getFigure() instanceof Connection) {
+ List<Point> result = Lists.newArrayList();
+ Edge gmfEdge = (Edge) edgeEditPart.getModel();
+ Connection connectionFigure = (Connection) edgeEditPart.getFigure();
+ Point tgtAnchorLoc = connectionFigure.getTargetAnchor().getReferencePoint();
+ connectionFigure.translateToRelative(tgtAnchorLoc);
+
+ RelativeBendpoints bp = (RelativeBendpoints) gmfEdge.getBendpoints();
+ for (int i = 0; i < bp.getPoints().size(); i++) {
+ RelativeBendpoint rbp = (RelativeBendpoint) bp.getPoints().get(i);
+ Point fromTgt = tgtAnchorLoc.getTranslated(rbp.getTargetX(), rbp.getTargetY());
+ result.add(fromTgt);
+ }
+ return result;
+ }
+ throw new IllegalArgumentException(
+ "The model of the edgeEditPart should be a org.eclipse.gmf.runtime.notation.Edge and the figure of this edgeEditPart should be a org.eclipse.draw2d.Connection.");
+ }
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/uml2.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/uml2.aird
index baf103d85c..ac351c3f90 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/uml2.aird
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/dragAndDrop/uml2.aird
@@ -176,7 +176,7 @@
</children>
<styles xmi:type="notation:ConnectorStyle" xmi:id="_FLHF0c31Ed6I_ZSkQ7u_fA"/>
<styles xmi:type="notation:FontStyle" xmi:id="_FLHF0s31Ed6I_ZSkQ7u_fA" fontName="Comic Sans MS" fontHeight="8"/>
- <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_FLHF0831Ed6I_ZSkQ7u_fA" points="[0, 0, 0, 0]$[0, 0, 0, 0]"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_FLHF0831Ed6I_ZSkQ7u_fA" points="[-52, -9, 187, -9]$[-134, -22, 105, -22]$[-206, -7, 33, -7]"/>
</edges>
<edges xmi:type="notation:Edge" xmi:id="_FLIT8M31Ed6I_ZSkQ7u_fA" type="4001" element="_4hMCoJjJEeCGbO5oLE72PQ" source="_FKzj0M31Ed6I_ZSkQ7u_fA" target="_FLBmQM31Ed6I_ZSkQ7u_fA">
<children xmi:type="notation:Node" xmi:id="_FLIT9M31Ed6I_ZSkQ7u_fA" type="6001">
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/AbstractUmlDragAndDropTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/AbstractUmlDragAndDropTest.java
index 444e344f6c..3ffa35eb85 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/AbstractUmlDragAndDropTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/AbstractUmlDragAndDropTest.java
@@ -23,6 +23,7 @@ import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.sirius.diagram.DDiagram;
@@ -31,6 +32,7 @@ import org.eclipse.sirius.diagram.EdgeRouting;
import org.eclipse.sirius.diagram.EdgeStyle;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramBorderNodeEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart.ViewEdgeFigure;
+import org.eclipse.sirius.diagram.ui.internal.refresh.GMFHelper;
import org.eclipse.sirius.tests.support.api.GraphicTestsSupportHelp;
import org.eclipse.sirius.tests.swtbot.Activator;
import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase;
@@ -334,11 +336,13 @@ public abstract class AbstractUmlDragAndDropTest extends AbstractSiriusSwtBotGef
*
* @param editPartName
* name of the edit part to search
+ * @param expectedEditPartType
+ * The type of the expected edit part
*
* @return copy of bendpoints position or null if there is no edge
*/
- protected PointList getBendpoints(String editPartName) {
- ConnectionEditPart connectionEditPart = getEdge(editPartName);
+ protected PointList getBendpoints(String editPartName, final Class<? extends EditPart> expectedEditPartType) {
+ ConnectionEditPart connectionEditPart = getEdge(editPartName, expectedEditPartType);
if (connectionEditPart == null)
return null; // no edge defined
assertTrue(connectionEditPart.getFigure() instanceof ViewEdgeFigure);
@@ -346,15 +350,36 @@ public abstract class AbstractUmlDragAndDropTest extends AbstractSiriusSwtBotGef
}
/**
+ * Get the points list computed from GMF bendpoints according to source side
+ * for the first edge found connected to the edit part with
+ * <code>editPartName</code> as name.
+ *
+ * @param editPartName
+ * name of the edit part to search
+ * @param expectedEditPartType
+ * The type of the expected edit part
+ *
+ * @return List of points or null if there is no edge
+ */
+ protected List<Point> getGMFBendpointsFromSource(String editPartName, final Class<? extends EditPart> expectedEditPartType) {
+ ConnectionEditPart connectionEditPart = getEdge(editPartName, expectedEditPartType);
+ if (connectionEditPart == null)
+ return null; // no edge defined
+ return GMFHelper.getPointsFromSource(connectionEditPart);
+ }
+
+ /**
* Get the first edge found connected to the edit part with
* <code>editPartName</code> as name.
*
* @param editPartName
* name of the edit part to search
+ * @param expectedEditPartType
+ * The type of the expected edit part
* @return the edge connected to the edit part or null if there is no edge.
*/
- protected ConnectionEditPart getEdge(String editPartName) {
- SWTBotGefEditPart editPart = editor.getEditPart(editPartName, AbstractDiagramBorderNodeEditPart.class);
+ protected ConnectionEditPart getEdge(String editPartName, final Class<? extends EditPart> expectedEditPartType) {
+ SWTBotGefEditPart editPart = editor.getEditPart(editPartName, expectedEditPartType);
List<SWTBotGefConnectionEditPart> sourceConnections = editPart.sourceConnections();
ConnectionEditPart connectionEditPart = null;
@@ -378,16 +403,20 @@ public abstract class AbstractUmlDragAndDropTest extends AbstractSiriusSwtBotGef
* @param editPartName
* name of the edit part to search
* @param originalPoints
- * original points
+ * original draw2d points
+ * @param originalGmfPointsFromSource
+ * original GMF points computed from source
*/
- protected void checkEdgeStability(String editPartName, PointList originalPoints) {
- ConnectionEditPart connectionEditPart = getEdge(editPartName);
+ protected void checkEdgeStability(String editPartName, final Class<? extends EditPart> expectedEditPartType, PointList originalPoints, List<Point> originalGmfPointsFromSource) {
+ ConnectionEditPart connectionEditPart = getEdge(editPartName, expectedEditPartType);
// get new bendpoints
assertTrue(connectionEditPart.getFigure() instanceof ViewEdgeFigure);
PointList newPoints = ((ViewEdgeFigure) connectionEditPart.getFigure()).getPoints().getCopy();
Assert.assertEquals("The number of bendpoints should be the same", originalPoints.size(), newPoints.size());
+ List<Point> newGMFBendpointsFromSource = GMFHelper.getPointsFromSource(connectionEditPart);
+
// get routing style
assertTrue(connectionEditPart.getModel() instanceof Edge);
EObject element = ((Edge) connectionEditPart.getModel()).getElement();
@@ -413,6 +442,7 @@ public abstract class AbstractUmlDragAndDropTest extends AbstractSiriusSwtBotGef
Point originalPoint = originalPoints.getPoint(i);
Point newPoint = newPoints.getPoint(i);
Assert.assertEquals("The two points at index " + i + " should be equal", originalPoint, newPoint);
+ Assert.assertEquals("The two GMF points at index " + i + " should be equal", originalGmfPointsFromSource.get(i), newGMFBendpointsFromSource.get(i));
}
// moved points
@@ -420,6 +450,7 @@ public abstract class AbstractUmlDragAndDropTest extends AbstractSiriusSwtBotGef
Point originalPoint = originalPoints.getPoint(i);
Point newPoint = newPoints.getPoint(i);
Assert.assertNotEquals("The two points at index " + i + " should be different", originalPoint, newPoint);
+ Assert.assertNotEquals("The two GMF points at index " + i + " should be different", originalGmfPointsFromSource.get(i), newGMFBendpointsFromSource.get(i));
}
} else {
// EdgeRouting.STRAIGHT: the first point has moved
@@ -431,6 +462,7 @@ public abstract class AbstractUmlDragAndDropTest extends AbstractSiriusSwtBotGef
Point originalPoint = originalPoints.getPoint(i);
Point newPoint = newPoints.getPoint(i);
Assert.assertNotEquals("The two points at index " + i + " should be different", originalPoint, newPoint);
+ Assert.assertNotEquals("The two GMF points at index " + i + " should be different", originalGmfPointsFromSource.get(i), newGMFBendpointsFromSource.get(i));
}
// unmoved points
@@ -438,7 +470,69 @@ public abstract class AbstractUmlDragAndDropTest extends AbstractSiriusSwtBotGef
Point originalPoint = originalPoints.getPoint(i);
Point newPoint = newPoints.getPoint(i);
Assert.assertEquals("The two points at index " + i + " should be equal", originalPoint, newPoint);
+ Assert.assertEquals("The two GMF points at index " + i + " should be equal", originalGmfPointsFromSource.get(i), newGMFBendpointsFromSource.get(i));
+ }
+ }
+ if (isEquals(originalPoints, originalGmfPointsFromSource) && !isEquals(newPoints, newGMFBendpointsFromSource)) {
+ fail("The draw2d and GMF lists of points should be the same: \n" + toString(newPoints) + "\n" + toString(newGMFBendpointsFromSource));
+ }
+ }
+
+ /**
+ * @param newGMFBendpointsFromSource
+ * @return
+ */
+ private String toString(List<Point> newGMFBendpointsFromSource) {
+ StringBuffer result = new StringBuffer("[");
+ for (int i = 0; i < newGMFBendpointsFromSource.size(); i++) {
+ Point point = newGMFBendpointsFromSource.get(i);
+ result.append("(").append(point.x).append(", ").append(point.y).append(")");
+ if (i < newGMFBendpointsFromSource.size() - 1) {
+ result.append(", ");
+ }
+ }
+ result.append("]");
+ return result.toString();
+ }
+
+ /**
+ * @param newPoints
+ * @return
+ */
+ private String toString(PointList newPoints) {
+ StringBuffer result = new StringBuffer("[");
+ for (int i = 0; i < newPoints.size(); i++) {
+ Point point = newPoints.getPoint(i);
+ result.append("(").append(point.x).append(", ").append(point.y).append(")");
+ if (i < newPoints.size() - 1) {
+ result.append(", ");
+ }
+ }
+ result.append("]");
+ return result.toString();
+ }
+
+ /**
+ * Compare a list of draw2d point and a list of GMF points.
+ *
+ * @param draw2dPoints
+ * List of draw2d points
+ * @param gmfPoints
+ * List of GMF points
+ * @return true if the lists are the same.
+ */
+ private boolean isEquals(PointList draw2dPoints, List<Point> gmfPoints) {
+ boolean isEquals = true;
+ if (draw2dPoints.size() != gmfPoints.size()) {
+ isEquals = false;
+ }
+ for (int i = 0; i < draw2dPoints.size() && isEquals; i++) {
+ Point d2dPoint = draw2dPoints.getPoint(i);
+ Point gmfPoint = gmfPoints.get(i);
+ if (!((d2dPoint.x == gmfPoint.x || d2dPoint.x == gmfPoint.x + 1) || (d2dPoint.y == gmfPoint.y || d2dPoint.y == gmfPoint.y + 1))) {
+ isEquals = false;
}
}
+ return isEquals;
}
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlClassDragAndDropTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlClassDragAndDropTest.java
index c5eea73157..4cd256d8b6 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlClassDragAndDropTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlClassDragAndDropTest.java
@@ -17,8 +17,11 @@ import java.util.List;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramListEditPart;
import org.eclipse.sirius.tests.support.api.GraphicTestsSupportHelp;
+import org.eclipse.sirius.tests.swtbot.support.api.matcher.geometry.PointAround;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotCommonHelper;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotCommonHelper.EdgeData;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
@@ -42,6 +45,8 @@ public class UmlClassDragAndDropTest extends AbstractUmlDragAndDropTest {
private static final String REPRESENTATION_NAME = "Class Diagram";
+ private static final String IN_CLASS2 = "InClass2";
+
private static final String IN_CLASS3 = "InClass3";
private static final String IN_AND_OUT_CLASS_4 = "InAndOutClass4";
@@ -241,6 +246,38 @@ public class UmlClassDragAndDropTest extends AbstractUmlDragAndDropTest {
}
}
+ /**
+ * Move a class to check the stability of the edge.
+ *
+ */
+ public void testMoveClass() {
+ // Get original bendpoints
+ PointList originalDraw2DPoints = getBendpoints(IN_CLASS2, AbstractDiagramListEditPart.class);
+ List<Point> originalGmfPointsFromSource = getGMFBendpointsFromSource(IN_CLASS2, AbstractDiagramListEditPart.class);
+
+ // Get the bottom center coordinates of the port
+ final Rectangle originalClassBounds = getEditPartBounds(IN_CLASS2);
+
+ // clicked point, drag start
+ final Point pointToDrag = originalClassBounds.getTop().getTranslated(0, 3);
+
+ // Select the Class
+ editor.select(editor.getEditPart(IN_CLASS2, AbstractDiagramListEditPart.class));
+ // Compute the drop destination
+ final Point endpoint = pointToDrag.getTranslated(0, 20);
+ // Drag'and'drop with the mouse
+ editor.drag(pointToDrag.x, pointToDrag.y, endpoint.x, endpoint.y);
+ // Get the new bounds and compare with the expected
+ final Rectangle newClassBounds = getEditPartBounds(IN_CLASS2);
+ assertThat("Class is not at expected position (probably not moved but resized)", newClassBounds.getTopRight(), PointAround.around(originalClassBounds.getTopRight().getTranslated(0, 20), 5));
+
+ if (originalDraw2DPoints != null && originalGmfPointsFromSource != null) {
+ // check the stability of the existing edge when moving the
+ // border node
+ checkEdgeStability(IN_CLASS2, AbstractDiagramListEditPart.class, originalDraw2DPoints, originalGmfPointsFromSource);
+ }
+ }
+
private void dragAndDropClassesWithEdge(final Point dropPoint) {
dragAndDropClassesWithEdge(RECT_DRAG_AROUND, PT_IN_CLASS_TO_DRAG, dropPoint);
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortDragAndDropTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortDragAndDropTest.java
index c4e57fdc95..6ba885646a 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortDragAndDropTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortDragAndDropTest.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot.uml;
+import java.util.List;
+
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
@@ -110,7 +112,8 @@ public class UmlPortDragAndDropTest extends AbstractUmlDragAndDropTest {
String portToDropName = "Port5";
final Rectangle originalPortBounds = getEditPartBounds(portToDropName);
- PointList originalEdgeBendpoints = getBendpoints(portToDropName);
+ PointList originalEdgeBendpoints = getBendpoints(portToDropName, AbstractDiagramBorderNodeEditPart.class);
+ List<Point> originalGmfPointsFromSource = getGMFBendpointsFromSource(portToDropName, AbstractDiagramBorderNodeEditPart.class);
final Point originalCenter = originalPortBounds.getCenter();
final Point endpoint = originalCenter.getTranslated(-HORIZONTAL_TRANSLATION, 0);
@@ -124,7 +127,7 @@ public class UmlPortDragAndDropTest extends AbstractUmlDragAndDropTest {
assertFalse("The port should have different coordinates.", newCenter.equals(originalCenter));
// Check edge stability
- checkEdgeStability(portToDropName, originalEdgeBendpoints);
+ checkEdgeStability(portToDropName, AbstractDiagramBorderNodeEditPart.class, originalEdgeBendpoints, originalGmfPointsFromSource);
}
/**
@@ -136,7 +139,8 @@ public class UmlPortDragAndDropTest extends AbstractUmlDragAndDropTest {
String portToDropName = "Port6";
final Rectangle originalPortBounds = getEditPartBounds(portToDropName);
- PointList originalEdgeBendpoints = getBendpoints(portToDropName);
+ PointList originalEdgeBendpoints = getBendpoints(portToDropName, AbstractDiagramBorderNodeEditPart.class);
+ List<Point> originalGmfPointsFromSource = getGMFBendpointsFromSource(portToDropName, AbstractDiagramBorderNodeEditPart.class);
final Point originalCenter = originalPortBounds.getCenter();
final Point endpoint = originalCenter.getTranslated(-HORIZONTAL_TRANSLATION, 0);
@@ -150,7 +154,7 @@ public class UmlPortDragAndDropTest extends AbstractUmlDragAndDropTest {
assertFalse("The port should have different coordinates.", newCenter.equals(originalCenter));
// Check edge stability
- checkEdgeStability(portToDropName, originalEdgeBendpoints);
+ checkEdgeStability(portToDropName, AbstractDiagramBorderNodeEditPart.class, originalEdgeBendpoints, originalGmfPointsFromSource);
}
/**
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortMoveTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortMoveTest.java
index 950de215ad..30a3b7c153 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortMoveTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/uml/UmlPortMoveTest.java
@@ -17,6 +17,8 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import java.util.List;
+
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
@@ -281,7 +283,8 @@ public class UmlPortMoveTest extends AbstractUmlDragAndDropTest {
editor = openAndGetEditor(representationName, representationName);
// Get original bendpoints
- PointList originalPoints = getBendpoints(DROP_PORT_NAME);
+ PointList originalDraw2DPoints = getBendpoints(DROP_PORT_NAME, AbstractDiagramBorderNodeEditPart.class);
+ List<Point> originalGmfPointsFromSource = getGMFBendpointsFromSource(DROP_PORT_NAME, AbstractDiagramBorderNodeEditPart.class);
// Get the bottom center coordinates of the port
final Rectangle originalPortBounds = getEditPartBounds(DROP_PORT_NAME);
@@ -305,10 +308,10 @@ public class UmlPortMoveTest extends AbstractUmlDragAndDropTest {
assertThat("Port is not at expected position (probably not moved but resized)", newPortBounds.getTopRight(),
PointAround.around(originalPortBounds.getTopRight().getTranslated(VERTICAL_TRANSLATION), 5));
- if (originalPoints != null) {
+ if (originalDraw2DPoints != null && originalGmfPointsFromSource != null) {
// check the stability of the existing edge when moving the
// border node
- checkEdgeStability(DROP_PORT_NAME, originalPoints);
+ checkEdgeStability(DROP_PORT_NAME, AbstractDiagramBorderNodeEditPart.class, originalDraw2DPoints, originalGmfPointsFromSource);
}
} else {
assertThat("Port is not at expected position (probably not moved but resized)", newPortBounds.getTopRight(), PointAround.around(originalPortBounds.getTopRight(), 0));

Back to the top