Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2015-08-07 08:05:59 +0000
committerLaurent Redor2015-08-07 12:35:21 +0000
commit08d4a2628b1b9e7f01d4f18635168f07e0b7e4e9 (patch)
tree17ebd44122f6165a89c41cfb079e46fc8de62b59
parent18a3d109ccd0938113cbaf4baa775e0f46331257 (diff)
downloadorg.eclipse.sirius-08d4a2628b1b9e7f01d4f18635168f07e0b7e4e9.tar.gz
org.eclipse.sirius-08d4a2628b1b9e7f01d4f18635168f07e0b7e4e9.tar.xz
org.eclipse.sirius-08d4a2628b1b9e7f01d4f18635168f07e0b7e4e9.zip
[471139] Add tests to reveal the problem
2 tests have been added in the class EdgeWithBorderNodeCreationPositionWithSnapToGridTest to reveal the problem. These 2 tests are similar but the locations are not exactly the same, the behavior of the feedback is not exactly the same for these 2 cases. A modification of the SWTBot framework have been done to show the feedback of edge during the edge creation. Bug: 471139 Change-Id: I4d30cc5c375067f1aa42a7279ad3e5f2eef1cc7d Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java17
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java18
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java38
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/tc-2185_edge_creation_position/models/tc-2185.aird58
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeCreationPositionTest.java13
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeWithBorderNodeCreationPositionWithSnapToGridTest.java45
6 files changed, 178 insertions, 11 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
index 0f15e54c8b..65e1c3a6fd 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
@@ -225,6 +225,21 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
}
/**
+ * Helper to click with a Point as parameter.
+ *
+ * @param point
+ * the coordinate to click on described as a Point. This
+ * coordinates is relative to screen.
+ * @param displayFeedback
+ * true to display feedback, false otherwise.
+ * @see org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor#click(int,
+ * int)
+ */
+ public void click(final Point point, boolean displayFeedback) {
+ ((SWTBotSiriusGefViewer) getSWTBotGefViewer()).click(point.x, point.y, displayFeedback);
+ }
+
+ /**
* Clicks on the center of the targeted GraphicalEditPart known by its
* label.
*
@@ -1475,7 +1490,7 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
}
});
}
-
+
/**
* Return the "Snap to grid" option value for this editor.
*
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
index 3290369f7e..746b330b23 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
@@ -324,4 +324,22 @@ public class SWTBotSiriusGefViewer extends SWTBotGefViewer {
canvas.mouseDrag(fromXPosition, fromYPosition, toXPosition, toYPosition);
}
}
+
+ /**
+ * Click on the editor at the specified location.
+ *
+ * @param xPosition
+ * the x relative position
+ * @param yPosition
+ * the y relative position
+ * @param displayFeedback
+ * true to display feedback, false otherwise.
+ */
+ public void click(final int xPosition, final int yPosition, boolean displayFeedback) {
+ if (canvas instanceof SWTBotSiriusFigureCanvas) {
+ ((SWTBotSiriusFigureCanvas) canvas).mouseMoveLeftClick(xPosition, yPosition, displayFeedback);
+ } else {
+ canvas.mouseMoveLeftClick(xPosition, yPosition);
+ }
+ }
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
index dc4d11a563..a7975328c3 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
@@ -96,6 +96,44 @@ public class SWTBotSiriusFigureCanvas extends SWTBotGefFigureCanvas {
});
}
+ /**
+ * Contrary to {@link #mouseMoveLeftClick(int, int)}, this method allows to
+ * display the feedback during the creation: Useful for edge creation.
+ *
+ * @param xPosition
+ * the relative x position
+ * @param yPosition
+ * the relative y position
+ * @param displayFeedback
+ * true to display feedback, false otherwise.
+ *
+ * @see org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefFigureCanvas#mouseMoveLeftClick(int,
+ * int)
+ */
+ public void mouseMoveLeftClick(final int xPosition, final int yPosition, boolean displayFeedback) {
+ if (!displayFeedback) {
+ mouseMoveLeftClick(xPosition, yPosition);
+ } else {
+ UIThreadRunnable.asyncExec(new VoidResult() {
+ @Override
+ public void run() {
+ org.eclipse.swt.events.MouseEvent meMove = wrapMouseEvent(xPosition, yPosition, 0, 0, 0);
+ eventDispatcher.dispatchMouseMoved(meMove);
+ // Force an update of viewport (necessary to have a correct
+ // feedback of edge in case of edge creation for example)
+ if (widget instanceof FigureCanvas) {
+ ((FigureCanvas) widget).getViewport().getUpdateManager().performUpdate();
+ }
+ org.eclipse.swt.events.MouseEvent meDown = wrapMouseEvent(xPosition, yPosition, 1, SWT.None, 1);
+ eventDispatcher.dispatchMousePressed(meDown);
+ org.eclipse.swt.events.MouseEvent meUp = wrapMouseEvent(xPosition, yPosition, 1, SWT.BUTTON1, 1);
+ eventDispatcher.dispatchMouseReleased(meUp);
+ }
+ });
+ }
+
+ }
+
private org.eclipse.swt.events.MouseEvent wrapMouseEvent(int x, int y, int button, int stateMask, int count) {
return new org.eclipse.swt.events.MouseEvent(createMouseEvent(x, y, button, stateMask, count));
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/tc-2185_edge_creation_position/models/tc-2185.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/tc-2185_edge_creation_position/models/tc-2185.aird
index 8de82949c3..d609758f1b 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/tc-2185_edge_creation_position/models/tc-2185.aird
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/tc-2185_edge_creation_position/models/tc-2185.aird
@@ -554,6 +554,64 @@
<activatedLayers xmi:type="description_1:Layer" href="../description/tc-2185.odesign#//@ownedViewpoints[name='TC2185']/@ownedRepresentations[name='TC2185%20Bordered%20Node%20on%20Node']/@defaultLayer"/>
<target xmi:type="ecore:EPackage" href="tc-2185.ecore#/"/>
</ownedRepresentations>
+ <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_bNxoQDzWEeWflaMpVJ1jYw" name="NodeForStraightCase">
+ <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_bNxoQTzWEeWflaMpVJ1jYw" source="GMF_DIAGRAMS">
+ <data xmi:type="notation:Diagram" xmi:id="_bNxoQjzWEeWflaMpVJ1jYw" type="Sirius" element="_bNxoQDzWEeWflaMpVJ1jYw" measurementUnit="Pixel">
+ <children xmi:type="notation:Node" xmi:id="_bNxoQzzWEeWflaMpVJ1jYw" type="2001" element="_bNxoVjzWEeWflaMpVJ1jYw">
+ <children xmi:type="notation:Node" xmi:id="_bNxoRDzWEeWflaMpVJ1jYw" type="5002">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_bNxoRTzWEeWflaMpVJ1jYw" y="5"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_bNxoRjzWEeWflaMpVJ1jYw" type="3003" element="_bNxoVzzWEeWflaMpVJ1jYw">
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_bNxoRzzWEeWflaMpVJ1jYw" fontName="Sans"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_bNxoSDzWEeWflaMpVJ1jYw"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_bNxoSTzWEeWflaMpVJ1jYw" fontName="Sans" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_bNxoSjzWEeWflaMpVJ1jYw" x="99" y="40" width="307" height="101"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_bNxoSzzWEeWflaMpVJ1jYw" type="2001" element="_bNxoWDzWEeWflaMpVJ1jYw">
+ <children xmi:type="notation:Node" xmi:id="_bNxoTDzWEeWflaMpVJ1jYw" type="5002">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_bNxoTTzWEeWflaMpVJ1jYw" y="5"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_bNxoTjzWEeWflaMpVJ1jYw" type="3003" element="_bNxoWTzWEeWflaMpVJ1jYw">
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_bNxoTzzWEeWflaMpVJ1jYw" fontName="Sans"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_bNxoUDzWEeWflaMpVJ1jYw"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_bNxoUTzWEeWflaMpVJ1jYw" fontName="Sans" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_bNxoUjzWEeWflaMpVJ1jYw" x="99" y="200" width="302" height="101"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_bNxoUzzWEeWflaMpVJ1jYw"/>
+ </data>
+ </ownedAnnotationEntries>
+ <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_bNxoVDzWEeWflaMpVJ1jYw" source="DANNOTATION_CUSTOMIZATION_KEY">
+ <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_bNxoVTzWEeWflaMpVJ1jYw"/>
+ </ownedAnnotationEntries>
+ <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_bNxoVjzWEeWflaMpVJ1jYw" name="A" width="3" height="3" resizeKind="NSEW">
+ <target xmi:type="ecore:EClass" href="tc-2185.ecore#//A"/>
+ <semanticElements xmi:type="ecore:EClass" href="tc-2185.ecore#//A"/>
+ <arrangeConstraints>KEEP_LOCATION</arrangeConstraints>
+ <arrangeConstraints>KEEP_SIZE</arrangeConstraints>
+ <arrangeConstraints>KEEP_RATIO</arrangeConstraints>
+ <ownedStyle xmi:type="diagram:Square" xmi:id="_bNxoVzzWEeWflaMpVJ1jYw" labelPosition="node">
+ <description xmi:type="style:SquareDescription" href="../description/tc-2185.odesign#//@ownedViewpoints[name='TC2185']/@ownedRepresentations[name='TC2185%20Node']/@defaultLayer/@nodeMappings[name='NM_EClass']/@style"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:NodeMapping" href="../description/tc-2185.odesign#//@ownedViewpoints[name='TC2185']/@ownedRepresentations[name='TC2185%20Node']/@defaultLayer/@nodeMappings[name='NM_EClass']"/>
+ </ownedDiagramElements>
+ <ownedDiagramElements xmi:type="diagram:DNode" xmi:id="_bNxoWDzWEeWflaMpVJ1jYw" name="B" width="3" height="3" resizeKind="NSEW">
+ <target xmi:type="ecore:EClass" href="tc-2185.ecore#//B"/>
+ <semanticElements xmi:type="ecore:EClass" href="tc-2185.ecore#//B"/>
+ <arrangeConstraints>KEEP_LOCATION</arrangeConstraints>
+ <arrangeConstraints>KEEP_SIZE</arrangeConstraints>
+ <arrangeConstraints>KEEP_RATIO</arrangeConstraints>
+ <ownedStyle xmi:type="diagram:Square" xmi:id="_bNxoWTzWEeWflaMpVJ1jYw" labelPosition="node">
+ <description xmi:type="style:SquareDescription" href="../description/tc-2185.odesign#//@ownedViewpoints[name='TC2185']/@ownedRepresentations[name='TC2185%20Node']/@defaultLayer/@nodeMappings[name='NM_EClass']/@style"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:NodeMapping" href="../description/tc-2185.odesign#//@ownedViewpoints[name='TC2185']/@ownedRepresentations[name='TC2185%20Node']/@defaultLayer/@nodeMappings[name='NM_EClass']"/>
+ </ownedDiagramElements>
+ <description xmi:type="description_1:DiagramDescription" href="../description/tc-2185.odesign#//@ownedViewpoints[name='TC2185']/@ownedRepresentations[name='TC2185%20Node']"/>
+ <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_bNxoWjzWEeWflaMpVJ1jYw"/>
+ <activatedLayers xmi:type="description_1:Layer" href="../description/tc-2185.odesign#//@ownedViewpoints[name='TC2185']/@ownedRepresentations[name='TC2185%20Node']/@defaultLayer"/>
+ <target xmi:type="ecore:EPackage" href="tc-2185.ecore#/"/>
+ </ownedRepresentations>
<viewpoint xmi:type="description:Viewpoint" href="../description/tc-2185.odesign#//@ownedViewpoints[name='TC2185']"/>
</ownedViews>
</viewpoint:DAnalysis>
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeCreationPositionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeCreationPositionTest.java
index a042b050e1..2dda1213ef 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeCreationPositionTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeCreationPositionTest.java
@@ -32,7 +32,6 @@ import org.eclipse.sirius.diagram.ui.internal.edit.parts.DEdgeEditPart;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.ext.gmf.runtime.editparts.GraphicalHelper;
import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase;
-import org.eclipse.sirius.tests.swtbot.support.api.business.UILocalSession;
import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource;
import org.eclipse.sirius.tests.swtbot.support.api.condition.OperationDoneCondition;
import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor;
@@ -49,12 +48,13 @@ import org.eclipse.swtbot.swt.finder.waits.ICondition;
* @author pcdavid
*/
public class EdgeCreationPositionTest extends AbstractSiriusSwtBotGefTestCase {
+ /** The viewpoint name. */
+ protected static final String VIEWPOINT_NAME = "TC2185";
+
private static final PrecisionPoint TOP_LEFT_CORNER = new PrecisionPoint(0.1, 0.1);
private static final PrecisionPoint BOTTOM_RIGHT_CORNER = new PrecisionPoint(0.9, 0.9);
- private static final String VIEWPOINT_NAME = "TC2185";
-
private static final String MODEL = "tc-2185.ecore";
private static final String SESSION_FILE = "tc-2185.aird";
@@ -63,13 +63,6 @@ public class EdgeCreationPositionTest extends AbstractSiriusSwtBotGefTestCase {
private static final String FILE_DIR = "models/";
- /** The current editor */
- protected SWTBotSiriusDiagramEditor editor;
-
- private UIResource sessionAirdResource;
-
- private UILocalSession localSession;
-
@Override
protected void onSetUpBeforeClosingWelcomePage() throws Exception {
copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, "models/" + MODEL, "models/" + SESSION_FILE, "description/tc-2185.odesign");
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeWithBorderNodeCreationPositionWithSnapToGridTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeWithBorderNodeCreationPositionWithSnapToGridTest.java
index 4853b99e50..f57f608ee4 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeWithBorderNodeCreationPositionWithSnapToGridTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeWithBorderNodeCreationPositionWithSnapToGridTest.java
@@ -18,9 +18,15 @@ import org.eclipse.gef.EditPart;
import org.eclipse.gef.NodeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramBorderNodeEditPart;
+import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramNodeEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.DEdgeEditPart;
import org.eclipse.sirius.ext.gmf.runtime.editparts.GraphicalHelper;
+import org.eclipse.sirius.tests.swtbot.support.api.condition.OperationDoneCondition;
+import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor;
+import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
import com.google.common.collect.Iterables;
@@ -94,4 +100,43 @@ public class EdgeWithBorderNodeCreationPositionWithSnapToGridTest extends EdgeCr
}
return result;
}
+
+ /**
+ * For closed source and target points on an axis, the feedback shows a
+ * straighten edge, the result must be also 2 aligned border nodes.
+ */
+ public void testBorderNodesAreAligned() {
+ testBorderNodesAreAligned(new Point(200, 135), new Point(209, 203));
+ }
+
+ /**
+ * For closed source and target points on an axis, the feedback shows a
+ * straighten edge, the result must be also 2 aligned border nodes.<BR>
+ * For this test, the feedback behavior is slightly different as
+ * {@link #testBorderNodesAreAligned()}.
+ */
+ public void testBorderNodesAreAlignedAnotherCase() {
+ testBorderNodesAreAligned(new Point(200, 135), new Point(210, 203));
+ }
+
+ private void testBorderNodesAreAligned(Point source, Point target) {
+ editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), VIEWPOINT_NAME + " " + "Node", "NodeForStraightCase", DDiagram.class);
+ editor.setSnapToGrid(true, 2, 2);
+
+ ICondition done = new OperationDoneCondition();
+ editor.activateTool(getCreateEdgeToolName());
+ editor.click(source);
+ editor.click(target, true);
+ SWTBotUtils.waitAllUiEvents();
+ bot.waitUntil(done);
+
+ // Get the new source border node
+ IGraphicalEditPart sourcePart = (IGraphicalEditPart) editor.getEditPart("A", AbstractDiagramNodeEditPart.class).part();
+ IGraphicalEditPart sourceBorderNode = getBorderNode(sourcePart);
+ // Get the new target border node
+ IGraphicalEditPart targetPart = (IGraphicalEditPart) editor.getEditPart("B", AbstractDiagramNodeEditPart.class).part();
+ IGraphicalEditPart targetBorderNode = getBorderNode(targetPart);
+ assertEquals("The source and the target border nodes should be aligned.", GraphicalHelper.getAbsoluteBoundsIn100Percent(sourceBorderNode).getLocation().x,
+ GraphicalHelper.getAbsoluteBoundsIn100Percent(targetBorderNode).getLocation().x);
+ }
}

Back to the top