diff options
| author | Steve Monnier | 2017-10-10 10:01:27 +0000 |
|---|---|---|
| committer | Steve Monnier | 2017-10-10 16:21:09 +0000 |
| commit | 09c32f988e1ebb63f445c6b23beee1305fd63b73 (patch) | |
| tree | e1b6031cb591d9ba1be8fe9c12c87172eee70a29 | |
| parent | b0ccfb0011d7279f245ac7dbb1b80aa15147b4ab (diff) | |
| download | org.eclipse.sirius-09c32f988e1ebb63f445c6b23beee1305fd63b73.tar.gz org.eclipse.sirius-09c32f988e1ebb63f445c6b23beee1305fd63b73.tar.xz org.eclipse.sirius-09c32f988e1ebb63f445c6b23beee1305fd63b73.zip | |
[525814] Resizing state next start of a parent sync should not throw CCE
- Resizing a state next to the message of a parent sync call should not
throw CCE
- Addition of a SWTBot test for this scenario
- Addition of a new constructor in the condition CheckEditPartResized
Bug: 525814
Change-Id: I9b59898f70ffb184b0bb3290e9f4868a6aced85b
Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
3 files changed, 68 insertions, 9 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java index 1ef3ee829b..cc2a3ccd30 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java +++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java @@ -466,21 +466,23 @@ public class ExecutionSelectionEditPolicy extends SpecificBorderItemSelectionEdi } private boolean hasBothEndMoving(Message smep) { - Set<Execution> movingExecutionEditPart = getMovingExecutions(); + Set<AbstractNodeEvent> movingExecutionEditPart = getMovingExecutions(); return movingExecutionEditPart.contains(smep.getSourceElement()) && movingExecutionEditPart.contains(smep.getTargetElement()); } - private Set<Execution> getMovingExecutions() { + private Set<AbstractNodeEvent> getMovingExecutions() { EditPartViewer viewer = getHost().getViewer(); - Set<Execution> movingExecutions = Sets.newHashSet(); + Set<AbstractNodeEvent> movingExecutions = Sets.newHashSet(); for (ExecutionEditPart eep : Iterables.filter(viewer.getSelectedEditParts(), ExecutionEditPart.class)) { - Execution exec = (Execution) eep.getISequenceEvent(); + AbstractNodeEvent exec = (AbstractNodeEvent) eep.getISequenceEvent(); movingExecutions.add(exec); - movingExecutions.addAll(exec.findLinkedExecutions(true)); + if (exec instanceof Execution) { + movingExecutions.addAll(((Execution) exec).findLinkedExecutions(true)); + } } ArrayList<Execution> subExecutions = Lists.newArrayList(); - for (Execution eep : movingExecutions) { + for (Execution eep : Iterables.filter(movingExecutions, Execution.class)) { subExecutions.addAll(new ISequenceEventQuery(eep).getAllExecutions()); } movingExecutions.addAll(subExecutions); diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/CheckEditPartResized.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/CheckEditPartResized.java index 884eb1f782..c22347f825 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/CheckEditPartResized.java +++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/CheckEditPartResized.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 @@ -33,7 +33,17 @@ public class CheckEditPartResized extends DefaultCondition { * bot to check if resized */ public CheckEditPartResized(SWTBotGefEditPart editPartBot) { - this.graphicalEditPart = (GraphicalEditPart) editPartBot.part(); + this((GraphicalEditPart) editPartBot.part()); + } + + /** + * Default Constructor. + * + * @param editPart + * {@link GraphicalEditPart} to check if resized + */ + public CheckEditPartResized(GraphicalEditPart editPart) { + this.graphicalEditPart = editPart; this.initialSize = graphicalEditPart.getFigure().getBounds().getSize().getCopy(); } diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/StateBasicTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/StateBasicTests.java index a9b1143d2c..537c4cfb80 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/StateBasicTests.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/StateBasicTests.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 @@ -14,6 +14,7 @@ import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.sirius.diagram.sequence.business.internal.layout.LayoutConstants; +import org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.part.ExecutionEditPart; import org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.part.SequenceDiagramEditPart; import org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.part.StateEditPart; import org.eclipse.sirius.ext.base.Option; @@ -23,8 +24,10 @@ import org.eclipse.sirius.tests.swtbot.support.api.business.UIDiagramRepresentat import org.eclipse.sirius.tests.swtbot.support.api.condition.CheckEditPartMoved; import org.eclipse.sirius.tests.swtbot.support.api.condition.CheckEditPartResized; import org.eclipse.sirius.tests.unit.diagram.sequence.InteractionsConstants; +import org.eclipse.swt.SWTException; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; import org.eclipse.swtbot.swt.finder.waits.ICondition; +import org.eclipse.swtbot.swt.finder.widgets.TimeoutException; import com.google.common.collect.Iterables; @@ -456,6 +459,50 @@ public class StateBasicTests extends AbstractStatesSequenceTests { } /** + * Scenario that checks that resizing a state close to the message of the parent sync call is possible and does not + * throw class cast exceptions. + */ + public void test_Resize_State_On_Execution() { + editor.reveal(LIFELINE_A); + arrangeAll(); + editor.maximize(); + // Create a sync call from lifeLine B to A + createSyncCall(new Point(getLifelineScreenX(LIFELINE_B), 150), new Point(getLifelineScreenX(LIFELINE_A), 150)); + Rectangle firstSyncCall = getExecutionScreenBounds(LIFELINE_A, 0); + ExecutionEditPart executionEP = getExecutionEditPart(LIFELINE_A, 0); + Rectangle firstExecutionBoundsA = assertExecutionHasValidScreenBounds(LIFELINE_A, 0, new Rectangle(0, 150, 0, 50), false); + + // Resize the execution + editor.click(firstExecutionBoundsA.getBottom()); + Point expectedTranslation = new Point(0, 200); + CheckEditPartResized cR = new CheckEditPartResized(executionEP); + editor.drag(firstExecutionBoundsA.getBottom(), firstExecutionBoundsA.getBottom().getCopy().getTranslated(expectedTranslation)); + bot.waitUntil(cR); + + // Create a state on the execution + Option<SWTBotGefEditPart> state = createStateWithResult(new Point(getLifelineScreenX(LIFELINE_A), 250)); + Rectangle stateBoundsA = assertStateHasValidScreenBounds((StateEditPart) state.get().part(), new Rectangle(0, 250, 0, 30), false); + + // Resize state close to the execution upper bound or close to m1 + editor.select(state.get()); + expectedTranslation = new Point(0, -95); + cR = new CheckEditPartResized(state.get()); + editor.drag(stateBoundsA.getTop(), stateBoundsA.getTop().getCopy().getTranslated(expectedTranslation)); + try { + bot.waitUntil(cR); + } catch (TimeoutException e) { + boolean doesAnErrorOccurs = doesAnErrorOccurs(); + if (doesAnErrorOccurs) { + Throwable exception = errors.values().iterator().next().getException(); + if (exception instanceof ClassCastException || (exception instanceof SWTException && exception.getCause() instanceof ClassCastException)) { + fail("The resize of the state next to the message m1 causes a ClassCastException"); + } + } + fail(e.getMessage()); + } + } + + /** * Test resize state with 2 messages. * <p> * Step 1 : Resize state above the first message. This action is forbidden. |
