diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/SequenceHorizontalLayout.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/SequenceHorizontalLayout.java index 4b0f40a955..4f19500fd4 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/SequenceHorizontalLayout.java +++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/SequenceHorizontalLayout.java @@ -73,7 +73,7 @@ public class SequenceHorizontalLayout extends AbstractSequenceOrderingLayout RECT_TO_X = new Function() { @Override @@ -560,7 +560,7 @@ private int getLifelineLeftGap(Lifeline lifeline, Range zone, int irWidth, Map bounds, Map lostEndsDelta) { // Reset width of the interaction container Rectangle rectangle = new Rectangle(-1, 0, InteractionContainer.DEFAULT_WIDTH, InteractionContainer.DEFAULT_HEIGHT); - if (INTERACTION_CONTAINER_DYNAMIC_LEFT) { + if (Boolean.getBoolean(INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME)) { rectangle.setX(-1); } @@ -583,7 +583,7 @@ private Rectangle computeInteractionContainerLayout(InteractionContainer interac rectangle.setRight(right); } - if (INTERACTION_CONTAINER_DYNAMIC_LEFT) { + if (Boolean.getBoolean(INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME)) { int left = sequenceElementRectangle.x() - InteractionContainer.MARGIN; if (left < rectangle.x() || rectangle.x() == -1) { if (rectangle.x() == -1) { diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/InteractionContainerAdditionalLayerTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/InteractionContainerAdditionalLayerTests.java index 20be82aab0..39f74c30a3 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/InteractionContainerAdditionalLayerTests.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/InteractionContainerAdditionalLayerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) CEA. + * Copyright 2024 (c) CEA. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -19,14 +19,19 @@ import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gef.EditPart; import org.eclipse.gef.editparts.AbstractGraphicalEditPart; +import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.sequence.business.internal.elements.InteractionContainer; import org.eclipse.sirius.diagram.sequence.business.internal.layout.LayoutConstants; +import org.eclipse.sirius.diagram.sequence.business.internal.layout.horizontal.SequenceHorizontalLayout; import org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.part.EndOfLifeEditPart; import org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.part.InteractionContainerEditPart; import org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.part.LifelineEditPart; +import org.eclipse.sirius.diagram.tools.api.preferences.SiriusDiagramPreferencesKeys; +import org.eclipse.sirius.diagram.ui.tools.api.preferences.SiriusDiagramUiPreferencesKeys; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.ext.base.Options; import org.eclipse.sirius.tests.swtbot.support.api.business.UIDiagramRepresentation; +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; import org.eclipse.sirius.tests.unit.diagram.sequence.InteractionsConstants; @@ -67,13 +72,29 @@ public class InteractionContainerAdditionalLayerTests extends AbstractSequenceDi private UIDiagramRepresentation diagram; + /** * {@inheritDoc} */ @Override protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { - super.onSetUpAfterOpeningDesignerPerspective(); + changeDiagramUIPreference(SiriusDiagramUiPreferencesKeys.PREF_OLD_UI.name(), true); + changeDiagramPreference(SiriusDiagramPreferencesKeys.PREF_DISPLAY_HEADER_SECTION.name(), false); + } + + public void initDiagram() { + if (getSessionModel() == null) { + + } else { + sessionAirdResource = new UIResource(designerProject, FILE_DIR, getSessionModel()); + localSession = designerPerspective.openSessionFromFile(sessionAirdResource, true); + Option dRepresentationName = getDRepresentationName(); + if (dRepresentationName.some()) { + editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), getRepresentationId(), dRepresentationName.get(), DDiagram.class, true, true); + } + } + initEditor(); diagram = localSession.getLocalSessionBrowser().perCategory().selectViewpoint(VIEWPOINT_NAME).selectRepresentation(getRepresentationId()) .selectRepresentationInstance(getDRepresentationName().get(), UIDiagramRepresentation.class); @@ -87,43 +108,94 @@ protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { } /** - * Check that on lifeline move and change position, the interaction container bounds also move accordingly. + * Check that on lifeline move and change position, the interaction container bounds also move accordingly.In this + * version of the test, the property to have a left margin dynamic is true. */ - public void testInteractionResizeOnInstanceRolePositionChange() { - // Activate the extension layer. - ICondition done = new OperationDoneCondition(); - diagram.changeLayerActivation(INTERACTION_CONTAINER_LAYER); - bot.waitUntil(done); - - // Check that the Interaction Container east bound correspond to the Instance Role C east bound + margin - SWTBotGefEditPart interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); - Rectangle interactionContainerBounds = editor.getBounds(interactionContainereditPart); - assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); - - /* - * Move lifelines to graphically change their order. - */ - // drag LIFELINE_C to (250,0) delta - editor.drag(instanceRoleEditPartCBot, instanceRoleEditPartCBounds.x + 250, origin.y); - // Drag LIFELINE_A to (300,0) delta, Lifeline A forth between Lifeline B - // and Lifeline C - editor.drag(instanceRoleEditPartABot, instanceRoleEditPartABounds.x + 300, origin.y); + public void testInteractionResizeOnInstanceRolePositionChangeWithLeftMargin() { + String oldPreferenceValue = System.getProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME); + try { + System.setProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME, String.valueOf(true)); + initDiagram(); + // Activate the extension layer. + ICondition done = new OperationDoneCondition(); + diagram.changeLayerActivation(INTERACTION_CONTAINER_LAYER); + bot.waitUntil(done); + + // Check that the Interaction Container east bound correspond to the Instance Role C east bound + margin + SWTBotGefEditPart interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); + Rectangle interactionContainerBounds = editor.getBounds(interactionContainereditPart); + assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); + + /* + * Move lifelines to graphically change their order. + */ + // drag LIFELINE_C to (250,0) delta + editor.drag(instanceRoleEditPartCBot, instanceRoleEditPartCBounds.x + 250, origin.y); + // Drag LIFELINE_A to (300,0) delta, Lifeline A forth between Lifeline B + // and Lifeline C + editor.drag(instanceRoleEditPartABot, instanceRoleEditPartABounds.x + 300, origin.y); + + // Check that the Interaction Container east bound still correspond to the Instance Role C east bound + margin + instanceRoleEditPartCBot = editor.getEditPart(LIFELINE_C); + instanceRoleEditPartCBounds = editor.getBounds(instanceRoleEditPartCBot); + instanceRoleEditPartBBot = editor.getEditPart(LIFELINE_B); + instanceRoleEditPartBBounds = editor.getBounds(instanceRoleEditPartBBot); + interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); + interactionContainerBounds = editor.getBounds(interactionContainereditPart); + assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); + assertEquals("Interaction Container west bound is not where expected", instanceRoleEditPartBBounds.getLeft().x - InteractionContainer.MARGIN, interactionContainerBounds.getLeft().x, 1); + } finally { + System.setProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME, oldPreferenceValue != null ? oldPreferenceValue : String.valueOf(false)); + } + } - // Check that the Interaction Container east bound still correspond to the Instance Role C east bound + margin - instanceRoleEditPartCBot = editor.getEditPart(LIFELINE_C); - instanceRoleEditPartCBounds = editor.getBounds(instanceRoleEditPartCBot); - instanceRoleEditPartBBot = editor.getEditPart(LIFELINE_B); - instanceRoleEditPartBBounds = editor.getBounds(instanceRoleEditPartBBot); - interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); - interactionContainerBounds = editor.getBounds(interactionContainereditPart); - assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); - assertEquals("Interaction Container west bound is not where expected", instanceRoleEditPartBBounds.getLeft().x - InteractionContainer.MARGIN, interactionContainerBounds.getLeft().x, 1); + /** + * Check that on lifeline move and change position, the interaction container bounds also move accordingly.In this + * version of the test, the property to have a left margin dynamic is true. + */ + public void testInteractionResizeOnInstanceRolePositionChangeWithoutLeftMargin() { + String oldPreferenceValue = System.getProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME); + try { + System.setProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME, String.valueOf(false)); + initDiagram(); + // Activate the extension layer. + ICondition done = new OperationDoneCondition(); + diagram.changeLayerActivation(INTERACTION_CONTAINER_LAYER); + bot.waitUntil(done); + + // Check that the Interaction Container east bound correspond to the Instance Role C east bound + margin + SWTBotGefEditPart interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); + Rectangle interactionContainerBounds = editor.getBounds(interactionContainereditPart); + assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); + + /* + * Move lifelines to graphically change their order. + */ + // drag LIFELINE_C to (250,0) delta + editor.drag(instanceRoleEditPartCBot, instanceRoleEditPartCBounds.x + 250, origin.y); + // Drag LIFELINE_A to (300,0) delta, Lifeline A forth between Lifeline B + // and Lifeline C + editor.drag(instanceRoleEditPartABot, instanceRoleEditPartABounds.x + 300, origin.y); + + // Check that the Interaction Container east bound still correspond to the Instance Role C east bound + margin + instanceRoleEditPartCBot = editor.getEditPart(LIFELINE_C); + instanceRoleEditPartCBounds = editor.getBounds(instanceRoleEditPartCBot); + instanceRoleEditPartBBot = editor.getEditPart(LIFELINE_B); + instanceRoleEditPartBBounds = editor.getBounds(instanceRoleEditPartBBot); + interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); + interactionContainerBounds = editor.getBounds(interactionContainereditPart); + assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); + assertEquals("Interaction Container west bound is not where expected", -1, interactionContainerBounds.getLeft().x, 1); + } finally { + System.setProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME, oldPreferenceValue != null ? oldPreferenceValue : String.valueOf(false)); + } } /** * Check that when the last lifeline move back and forth, the interaction container bounds also move accordingly. */ public void testInteractionResizeOnInstanceRoleMoveBackAndForth() { + initDiagram(); // Activate the extension layer. ICondition done = new OperationDoneCondition(); diagram.changeLayerActivation(INTERACTION_CONTAINER_LAYER); @@ -164,6 +236,7 @@ public void testInteractionResizeOnInstanceRoleMoveBackAndForth() { * accordingly. */ public void testInteractionResizeOnExecutionMove() { + initDiagram(); // Activate the extension layer. ICondition done = new OperationDoneCondition(); diagram.changeLayerActivation(INTERACTION_CONTAINER_LAYER); diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/InteractionContainerDefaultLayerTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/InteractionContainerDefaultLayerTests.java index e4c57a4b6d..dff1ab73df 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/InteractionContainerDefaultLayerTests.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/InteractionContainerDefaultLayerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) CEA. + * Copyright (c) 2024 CEA. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -13,14 +13,17 @@ package org.eclipse.sirius.tests.swtbot.sequence; import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; +import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.sequence.business.internal.elements.InteractionContainer; +import org.eclipse.sirius.diagram.sequence.business.internal.layout.horizontal.SequenceHorizontalLayout; import org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.part.InteractionContainerEditPart; +import org.eclipse.sirius.diagram.tools.api.preferences.SiriusDiagramPreferencesKeys; +import org.eclipse.sirius.diagram.ui.tools.api.preferences.SiriusDiagramUiPreferencesKeys; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.ext.base.Options; import org.eclipse.sirius.tests.swtbot.Activator; import org.eclipse.sirius.tests.swtbot.support.api.business.UIDiagramRepresentation; +import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource; import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; @@ -62,13 +65,29 @@ public class InteractionContainerDefaultLayerTests extends AbstractSequenceDiagr private UIDiagramRepresentation diagram; + /** * {@inheritDoc} */ @Override protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { - super.onSetUpAfterOpeningDesignerPerspective(); + changeDiagramUIPreference(SiriusDiagramUiPreferencesKeys.PREF_OLD_UI.name(), true); + changeDiagramPreference(SiriusDiagramPreferencesKeys.PREF_DISPLAY_HEADER_SECTION.name(), false); + } + public void initDiagram() { + if (getSessionModel() == null) { + + } else { + sessionAirdResource = new UIResource(designerProject, FILE_DIR, getSessionModel()); + localSession = designerPerspective.openSessionFromFile(sessionAirdResource, true); + Option dRepresentationName = getDRepresentationName(); + if (dRepresentationName.some()) { + editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), getRepresentationId(), dRepresentationName.get(), DDiagram.class, true, true); + } + } + + initEditor(); diagram = localSession.getLocalSessionBrowser().perCategory().selectViewpoint(VIEWPOINT_NAME).selectRepresentation(getRepresentationId()) .selectRepresentationInstance(getDRepresentationName().get(), UIDiagramRepresentation.class); @@ -90,38 +109,86 @@ protected void onSetUpBeforeClosingWelcomePage() throws Exception { } /** - * Check that on lifeline move and change position, the interaction container bounds also move accordingly. + * Check that on lifeline move and change position, the interaction container bounds also move accordingly. In this + * version of the test, the property to have a left margin dynamic is true. */ - public void testInteractionResizeOnInstanceRolePositionChange() { - // Check that the Interaction Container east bound correspond to the Instance Role C east bound + margin - SWTBotGefEditPart interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); - Rectangle interactionContainerBounds = editor.getBounds(interactionContainereditPart); - assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); - - /* - * Move lifelines to graphically change their order. - */ - // drag LIFELINE_C to (250,0) delta - editor.drag(instanceRoleEditPartCBot, instanceRoleEditPartCBounds.x + 250, origin.y); - // Drag LIFELINE_A to (300,0) delta, Lifeline A forth between Lifeline B - // and Lifeline C - editor.drag(instanceRoleEditPartABot, instanceRoleEditPartABounds.x + 300, origin.y); + public void testInteractionResizeOnInstanceRolePositionChangeWithLeftMargin() { + String oldPreferenceValue = System.getProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME); + try { + System.setProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME, String.valueOf(true)); + initDiagram(); + + // Check that the Interaction Container east bound correspond to the Instance Role C east bound + margin + SWTBotGefEditPart interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); + Rectangle interactionContainerBounds = editor.getBounds(interactionContainereditPart); + assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); + + /* + * Move lifelines to graphically change their order. + */ + // drag LIFELINE_C to (250,0) delta + editor.drag(instanceRoleEditPartCBot, instanceRoleEditPartCBounds.x + 250, origin.y); + // Drag LIFELINE_A to (300,0) delta, Lifeline A forth between Lifeline B + // and Lifeline C + editor.drag(instanceRoleEditPartABot, instanceRoleEditPartABounds.x + 300, origin.y); + + // Check that the Interaction Container east bound still correspond to the Instance Role C east bound + margin + instanceRoleEditPartCBot = editor.getEditPart(LIFELINE_C); + instanceRoleEditPartCBounds = editor.getBounds(instanceRoleEditPartCBot); + instanceRoleEditPartBBot = editor.getEditPart(LIFELINE_B); + instanceRoleEditPartBBounds = editor.getBounds(instanceRoleEditPartBBot); + interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); + interactionContainerBounds = editor.getBounds(interactionContainereditPart); + assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); + assertEquals("Interaction Container west bound is not where expected", instanceRoleEditPartBBounds.getLeft().x - InteractionContainer.MARGIN, interactionContainerBounds.getLeft().x, 1); + } finally { + System.setProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME, oldPreferenceValue != null ? oldPreferenceValue : String.valueOf(false)); + } + } - // Check that the Interaction Container east bound still correspond to the Instance Role C east bound + margin - instanceRoleEditPartCBot = editor.getEditPart(LIFELINE_C); - instanceRoleEditPartCBounds = editor.getBounds(instanceRoleEditPartCBot); - instanceRoleEditPartBBot = editor.getEditPart(LIFELINE_B); - instanceRoleEditPartBBounds = editor.getBounds(instanceRoleEditPartBBot); - interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); - interactionContainerBounds = editor.getBounds(interactionContainereditPart); - assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); - assertEquals("Interaction Container west bound is not where expected", instanceRoleEditPartBBounds.getLeft().x - InteractionContainer.MARGIN, interactionContainerBounds.getLeft().x, 1); + /** + * Check that on lifeline move and change position, the interaction container bounds also move accordingly. In this + * version of the test, the property to have a left margin dynamic is false. + */ + public void testInteractionResizeOnInstanceRolePositionChangeWithoutLeftMargin() { + String oldPreferenceValue = System.getProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME); + try { + System.setProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME, String.valueOf(false)); + initDiagram(); + + // Check that the Interaction Container east bound correspond to the Instance Role C east bound + margin + SWTBotGefEditPart interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); + Rectangle interactionContainerBounds = editor.getBounds(interactionContainereditPart); + assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); + + /* + * Move lifelines to graphically change their order. + */ + // drag LIFELINE_C to (250,0) delta + editor.drag(instanceRoleEditPartCBot, instanceRoleEditPartCBounds.x + 250, origin.y); + // Drag LIFELINE_A to (300,0) delta, Lifeline A forth between Lifeline B + // and Lifeline C + editor.drag(instanceRoleEditPartABot, instanceRoleEditPartABounds.x + 300, origin.y); + + // Check that the Interaction Container east bound still correspond to the Instance Role C east bound + margin + instanceRoleEditPartCBot = editor.getEditPart(LIFELINE_C); + instanceRoleEditPartCBounds = editor.getBounds(instanceRoleEditPartCBot); + instanceRoleEditPartBBot = editor.getEditPart(LIFELINE_B); + instanceRoleEditPartBBounds = editor.getBounds(instanceRoleEditPartBBot); + interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); + interactionContainerBounds = editor.getBounds(interactionContainereditPart); + assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); + assertEquals("Interaction Container west bound is not where expected", -1, interactionContainerBounds.getLeft().x, 1); + } finally { + System.setProperty(SequenceHorizontalLayout.INTERACTION_CONTAINER_DYNAMIC_LEFT_PROPERTY_NAME, oldPreferenceValue != null ? oldPreferenceValue : String.valueOf(false)); + } } /** * Check that when the last lifeline move back and forth, the interaction container bounds also move accordingly. */ public void testInteractionResizeOnInstanceRoleMoveBackAndForth() { + initDiagram(); // Check that the Interaction Container east bound correspond to the Instance Role C east bound + margin SWTBotGefEditPart interactionContainereditPart = editor.getEditPart("Lifelines", InteractionContainerEditPart.class); Rectangle interactionContainerBounds = editor.getBounds(interactionContainereditPart); @@ -152,10 +219,6 @@ public void testInteractionResizeOnInstanceRoleMoveBackAndForth() { assertEquals("Interaction Container east bound is not where expected", instanceRoleEditPartCBounds.getRight().x + InteractionContainer.MARGIN, interactionContainerBounds.getRight().x, 1); } - private SWTBotGefEditPart getBotEditPart(AbstractGraphicalEditPart parentExec, final Class expectedEditPartType) { - return editor.getEditPart(parentExec.getFigure().getBounds().getCopy().getCenter(), expectedEditPartType); - } - private void initBotsAndBounds(SWTBotSiriusDiagramEditor swtBotEditor) { instanceRoleEditPartABot = swtBotEditor.getEditPart(LIFELINE_A); instanceRoleEditPartBBot = swtBotEditor.getEditPart(LIFELINE_B);