diff options
| author | Laurent Redor | 2017-08-22 15:14:05 +0000 |
|---|---|---|
| committer | Laurent Redor | 2017-08-31 08:46:27 +0000 |
| commit | edc3d5238c18005aa1aa2af9c1a2e97b12bfb761 (patch) | |
| tree | 1a878d97759be9f5bbff3287364068c02de3ab2a | |
| parent | 1039dee85973458a623896374dc6d6d73d7f5815 (diff) | |
| download | org.eclipse.sirius-edc3d5238c18005aa1aa2af9c1a2e97b12bfb761.tar.gz org.eclipse.sirius-edc3d5238c18005aa1aa2af9c1a2e97b12bfb761.tar.xz org.eclipse.sirius-edc3d5238c18005aa1aa2af9c1a2e97b12bfb761.zip | |
[518246] Add tests that reveals cases not handled
Currently just the resizing in the bottom direction of an execution of
the last operand is handled.
Bug: 518246
Change-Id: Ia60559f8e7592a6113e4dba97a18cd7755073e9c
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
2 files changed, 111 insertions, 38 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/CombinedFragmentsOperandOverlapTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/CombinedFragmentsOperandOverlapTests.java index 0e57d4ab12..44b7284e91 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/CombinedFragmentsOperandOverlapTests.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/CombinedFragmentsOperandOverlapTests.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.sirius.tests.swtbot.sequence; +import static org.junit.Assert.assertNotEquals; + import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; @@ -484,6 +486,17 @@ public class CombinedFragmentsOperandOverlapTests extends AbstractCombinedFragme } /** + * Test that tries to resize an execution in the first operand lower than + * the operand bottom bound. Then, dimension of resized or moved elements + * are checked. + */ + public void testResizeExecutionOutOfFirstOperandLowerBound() { + e2Bot.select(); + + checkExecutionResize(LIFELINE_B, 1, 0, e2Bounds, 200); + } + + /** * Test that tries to resize an execution in the first operand lower than the operand bottom bound (not accepted). */ public void testResizeExecutionOutOfFirstOperandUpperBound() { @@ -501,6 +514,59 @@ public class CombinedFragmentsOperandOverlapTests extends AbstractCombinedFragme } /** + * Test that resizes an execution in the last operand upper than the operand + * top bound. Then, dimension of resized or moved elements are checked. + */ + public void testResizeExecutionOutOfLastOperandUpperBound() { + String toolName = "Execution"; + ICondition done = new CheckToolIsActivated(editor, toolName); + editor.activateTool(toolName); + bot.waitUntil(done); + editor.click(e2Bounds.getCenter().x, secondOperandOfFirstCombinedFragmentBounds.getCenter().y); + SWTBotGefEditPart e3Bot = instanceRoleEditPartBBot.parent().descendants(IsInstanceOf.instanceOf(ExecutionEditPart.class)).get(2); + e3Bot.select(); + + Rectangle executionBounds = editor.getBounds(e3Bot); + checkExecutionResize(LIFELINE_B, 2, 1, executionBounds, secondOperandOfFirstCombinedFragmentBounds.getTop().y - executionBounds.getTop().y - 10); + } + + private void checkExecutionResize(String labelOfLifelineEditPart, int indexOfExecution, int indexOfParentOperand, Rectangle executionBounds, int expectedResize) { + CheckResize cR = new CheckResize(labelOfLifelineEditPart, indexOfExecution, new Dimension(0, Math.abs(expectedResize)), editor); + if (expectedResize > 0) { + editor.drag(executionBounds.getBottom(), executionBounds.getBottom().translate(0, expectedResize)); + } else { + editor.drag(executionBounds.getTop(), executionBounds.getTop().translate(0, expectedResize)); + } + bot.waitUntil(cR); + SWTBotGefEditPart executionAfterRezize = instanceRoleEditPartBBot.parent().descendants(IsInstanceOf.instanceOf(ExecutionEditPart.class)).get(indexOfExecution); + Rectangle executionBoundsAfterRezize = editor.getBounds(executionAfterRezize); + + SWTBotGefEditPart parentOperand = firstCombinedFragmentBot.descendants(IsInstanceOf.instanceOf(OperandEditPart.class)).get(indexOfParentOperand); + Rectangle parentOperandBoundsAfterRezize = editor.getBounds(parentOperand); + + SWTBotGefEditPart firstCombinedFragmentBotAfterRezize = sequenceDiagramBot.descendants(IsInstanceOf.instanceOf(CombinedFragmentEditPart.class)).get(0); + Rectangle firstCombinedFragmentBoundsAfterRezize = editor.getBounds(firstCombinedFragmentBotAfterRezize); + + SWTBotGefEditPart secondCombinedFragmentBotAfterRezize = sequenceDiagramBot.descendants(IsInstanceOf.instanceOf(CombinedFragmentEditPart.class)).get(1); + Rectangle secondCombinedFragmentBoundsAfterRezize = editor.getBounds(secondCombinedFragmentBotAfterRezize); + + assertEquals("The execution should have resized.", executionBounds.height + Math.abs(expectedResize), executionBoundsAfterRezize.height); + assertNotEquals("The size of the containing operand should have changed.", firstCombinedFragmentBounds.height, parentOperandBoundsAfterRezize.height); + if (expectedResize > 0) { + // Resize in the bottom direction + assertEquals("Unexpected gap between the end of the resized execution and the containing operand.", parentOperandBoundsAfterRezize.getBottom().y, + executionBoundsAfterRezize.getBottom().y + LayoutConstants.EXECUTION_CHILDREN_MARGIN); + assertEquals("The gap between both Combined Fragment should be unchanged.", secondCombinedFragmentBounds.getTop().y - firstCombinedFragmentBounds.getBottom().y, + secondCombinedFragmentBoundsAfterRezize.getTop().y - firstCombinedFragmentBoundsAfterRezize.getBottom().y); + assertEquals("Second Combined Fragment dimension should be unchanged.", secondCombinedFragmentBounds.getSize(), secondCombinedFragmentBoundsAfterRezize.getSize()); + } else { + // Resize in the top direction + assertEquals("Unexpected gap between the start of the resized execution and the containing operand.", parentOperandBoundsAfterRezize.getTop().y, + executionBoundsAfterRezize.getTop().y - LayoutConstants.EXECUTION_CHILDREN_MARGIN); + } + } + + /** * Test that resizes an execution in the last operand lower than the operand bottom bound (accepted). Then, * dimension of resized or moved elements are checked. */ diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckResize.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckResize.java index d2242da588..0e07f1edcc 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckResize.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/condition/CheckResize.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2017 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 @@ -39,67 +39,72 @@ public class CheckResize extends DefaultCondition { private String labelOfEditPart; - private Point expectedTranslation; - private final SWTBotSiriusDiagramEditor editor; private int indexOfExecution = Integer.MIN_VALUE; - private Dimension expectedResize; + Dimension expectedEffect; /** * Constructor for resize from top : resize delta == - translation delta * - * @param bot - * Bot. + * @param labelOfEditPart + * The label of the edit part that must be resized + * @param expectedTranslation + * the resize delta + * @param editor + * The editor containing the edit part that must be resized */ public CheckResize(String labelOfEditPart, Point expectedTranslation, SWTBotSiriusDiagramEditor editor) { this.labelOfEditPart = labelOfEditPart; - this.expectedTranslation = expectedTranslation; + expectedEffect = new Dimension(-expectedTranslation.x, -expectedTranslation.y); this.editor = editor; - this.initialBounds = getBounds(labelOfEditPart).getCopy(); + this.initialBounds = getBounds(labelOfEditPart); } /** - * Constructor for resize from top : resize delta == - translation delta + * Constructor for resizing an execution from top : resize delta == - + * translation delta * - * @param bot - * Bot. + * @param labelOfLifelineEditPart + * The label of life line containing the edit part that must be + * resized + * @param indexOfExecution + * The index of the execution on the life line + * @param expectedTranslation + * the resize delta the resize delta + * @param editor + * The editor containing the edit part that must be resized */ public CheckResize(String labelOfLifelineEditPart, int indexOfExecution, Point expectedTranslation, SWTBotSiriusDiagramEditor editor) { - this.labelOfEditPart = labelOfLifelineEditPart; - this.expectedTranslation = expectedTranslation; - this.editor = editor; - this.indexOfExecution = indexOfExecution; - this.initialBounds = getBounds(labelOfLifelineEditPart).getCopy(); + this(labelOfLifelineEditPart, indexOfExecution, new Dimension(-expectedTranslation.x, -expectedTranslation.y), editor); } /** - * Constructor. + * Constructor for resizing an execution. * - * @param bot - * Bot. + * @param labelOfLifelineEditPart + * The label of life line containing the edit part that must be + * resized + * @param indexOfExecution + * The index of the execution on the life line + * @param expectedResize + * the resize delta + * @param editor + * The editor containing the edit part that must be resized */ public CheckResize(String labelOfLifelineEditPart, int indexOfExecution, Dimension expectedResize, SWTBotSiriusDiagramEditor editor) { this.labelOfEditPart = labelOfLifelineEditPart; - this.expectedResize = expectedResize; + expectedEffect = expectedResize; this.editor = editor; this.indexOfExecution = indexOfExecution; - this.initialBounds = getBounds(labelOfLifelineEditPart).getCopy(); + this.initialBounds = getBounds(labelOfLifelineEditPart); } - /** - * {@inheritDoc} - */ + @Override public boolean test() throws Exception { - Dimension expectedEffect = new Dimension(); - if (expectedTranslation != null) { - expectedEffect = new Dimension(-expectedTranslation.x, -expectedTranslation.y); - } else if (expectedResize != null) { - expectedEffect = expectedResize.getCopy(); - } - - return getBounds(labelOfEditPart).width == initialBounds.width + expectedEffect.width && getBounds(labelOfEditPart).height == initialBounds.height + expectedEffect.height; + Rectangle currentBounds = getBounds(labelOfEditPart); + return currentBounds.width == initialBounds.width + expectedEffect.width && currentBounds.height == initialBounds.height + expectedEffect.height; } private Rectangle getBounds(final String editPartName) { @@ -116,10 +121,11 @@ public class CheckResize extends DefaultCondition { /** * Get the execution edit part. + * * @param lifelineLabel - * name of the lifeline + * name of the life line * @param index - * position of the execution on the lifeline + * position of the execution on the life line * @return the execution edit part. */ public ExecutionEditPart getExecutionEditPart(String lifelineLabel, int index) { @@ -132,10 +138,11 @@ public class CheckResize extends DefaultCondition { return allExecutions.get(index); } - /** - * {@inheritDoc} - */ + @Override public String getFailureMessage() { - return null; + Rectangle currentBounds = getBounds(labelOfEditPart); + return "The edit part \"" + labelOfEditPart + "\" with initial size <" + initialBounds.width + ", " + initialBounds.height + "> has not been resized as expected. expected <" + + (initialBounds.width + expectedEffect.width) + ", " + + (initialBounds.height + expectedEffect.height) + "> but was <" + currentBounds.width + ", " + currentBounds.height + ">"; } } |
