Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2017-09-07 07:27:03 +0000
committerFlorian Barbin2017-09-07 08:51:26 +0000
commitf7289093aeb0823dca566b174ab6753d90246474 (patch)
treeba1a3bb73111b409f018f50ec490fa78dd134ad2
parent63c28596f3822f08444a1c2019edf7f338481f89 (diff)
downloadorg.eclipse.sirius-f7289093aeb0823dca566b174ab6753d90246474.tar.gz
org.eclipse.sirius-f7289093aeb0823dca566b174ab6753d90246474.tar.xz
org.eclipse.sirius-f7289093aeb0823dca566b174ab6753d90246474.zip
[520632] Fix testCreateTwoBorderNodesAtSameLocationWithThinGridSpacing
The test org.eclipse.sirius.tests.swtbot.BorderedNodeCreationWithSnapToGridTest.testCreateTwoBorderNodesAtSameLocationWithThinGridSpacing() is wrongly written: * The container on which the 2 border nodes are created was not revealed before. * The check location used the wrong grid step. Bug: 520632 Change-Id: I79b852927cccf32a50c1c6d871825ecc8249fe28 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderedNodeCreationWithSnapToGridTest.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderedNodeCreationWithSnapToGridTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderedNodeCreationWithSnapToGridTest.java
index 78eda6e89a..d34e699e26 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderedNodeCreationWithSnapToGridTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderedNodeCreationWithSnapToGridTest.java
@@ -108,7 +108,10 @@ public class BorderedNodeCreationWithSnapToGridTest extends BorderedNodeCreation
SWTBotGefEditPart packageP4 = editor.getEditPart(PACKAGE_4_NAME, AbstractDiagramContainerEditPart.class);
Rectangle packageAbsoluteBounds = editor.getAbsoluteBounds(packageP4);
+ editor.reveal(packageP4.part());
+ // We convert to screen coordinates
+ ((GraphicalEditPart) packageP4.part()).getFigure().translateToAbsolute(packageAbsoluteBounds);
// We compute the location according the top left package location
Point creationLocation = packageAbsoluteBounds.getTopLeft().translate(20, 20);
@@ -116,10 +119,10 @@ public class BorderedNodeCreationWithSnapToGridTest extends BorderedNodeCreation
createBorderedNode(BORDERED_NODE_CREATION_ON_PACKAGE_TOOL_NAME_2, creationLocation.x, creationLocation.y);
IGraphicalEditPart firstNewNode = (IGraphicalEditPart) editor.getEditPart("new Enum2", AbstractDiagramBorderNodeEditPart.class).part();
- checkLocationAlignOnGrid(firstNewNode, "BorderNode 'new Enum2'");
+ checkLocationAlignOnGrid(firstNewNode, "BorderNode 'new Enum2'", gridStep);
IGraphicalEditPart secondNewNode = (IGraphicalEditPart) editor.getEditPart("new Enum3", AbstractDiagramBorderNodeEditPart.class).part();
- checkLocationAlignOnGrid(secondNewNode, "BorderNode 'new Enum3'");
+ checkLocationAlignOnGrid(secondNewNode, "BorderNode 'new Enum3'", gridStep);
}
/**
@@ -184,17 +187,20 @@ public class BorderedNodeCreationWithSnapToGridTest extends BorderedNodeCreation
* edit part of the diagram element to check
* @param elementNameToDisplay
* The name of the element displayed in case of error
+ * @param gridSpacing
+ * The current grid spacing
*/
- private void checkLocationAlignOnGrid(IGraphicalEditPart editPart, String elementNameToDisplay) {
+ private void checkLocationAlignOnGrid(IGraphicalEditPart editPart, String elementNameToDisplay, int gridSpacing) {
Point location = editPart.getFigure().getBounds().getTopLeft();
- boolean locationIsOK = (location.x % GRID_SPACING) == 0 || (location.y % GRID_SPACING) == 0;
+ boolean locationIsOK = (location.x % gridSpacing) == 0 || (location.y % gridSpacing) == 0;
if (!locationIsOK) {
IGraphicalEditPart parentPart = (IGraphicalEditPart) editPart.getParent();
Rectangle parentBounds = GraphicalHelper.getAbsoluteBoundsIn100Percent(parentPart);
- locationIsOK = (location.x == parentBounds.x || location.x == (parentBounds.x + parentBounds.width)) || (location.y == parentBounds.y || location.y == (parentBounds.y + parentBounds.height));
+ locationIsOK = (location.x == parentBounds.x || location.x == (parentBounds.x + parentBounds.width))
+ || (location.y == parentBounds.y || location.y == (parentBounds.y + parentBounds.height));
}
if (!locationIsOK) {
- fail("For " + elementNameToDisplay + ", the x or y coordinate of the top left corner should be on the grid (grid spacing = " + GRID_SPACING + "), but was: " + location + ".");
+ fail("For " + elementNameToDisplay + ", the x or y coordinate of the top left corner should be on the grid (grid spacing = " + gridSpacing + "), but was: " + location + ".");
}
}

Back to the top