Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2018-05-04 16:02:28 +0000
committerPierre-Charles David2019-01-29 16:16:45 +0000
commit152e9bf6165d6971a987fb9a5dbdfb63af5ba97f (patch)
treed64ea7aad8f418aed64412bdb44f386a6912a9db
parentb675e2f3e09bc75d2aa3df45f16ef8a2b649ae66 (diff)
downloadorg.eclipse.sirius-152e9bf6165d6971a987fb9a5dbdfb63af5ba97f.tar.gz
org.eclipse.sirius-152e9bf6165d6971a987fb9a5dbdfb63af5ba97f.tar.xz
org.eclipse.sirius-152e9bf6165d6971a987fb9a5dbdfb63af5ba97f.zip
[497054] Adds the corresponding SWTBot tests
Those tests make sure that the make same size and auto-size actions work as expected on compartment. Bug: 497054 Change-Id: Iebfc1341fd6c31ac011521c311ec2cd4a701c75a Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/compartments/My.aird2
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/compartment/ICompartmentTests.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/compartment/CompartmentsSizeTest.java244
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java2
4 files changed, 249 insertions, 1 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/compartments/My.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/compartments/My.aird
index 44aa46d87a..616c6ac2e6 100644
--- a/plugins/org.eclipse.sirius.tests.junit/data/unit/compartments/My.aird
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/compartments/My.aird
@@ -205,7 +205,7 @@
<styles xmi:type="notation:FilteringStyle" xmi:id="_x1r9E0gKEeWO8ekbzmZQXg"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_x1rWCEgKEeWO8ekbzmZQXg" fontName="Comic Sans MS" fontHeight="8"/>
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_x1rWCUgKEeWO8ekbzmZQXg" x="338" y="66" width="166"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_x1rWCUgKEeWO8ekbzmZQXg" x="338" y="66"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_xGlbYkgKEeWO8ekbzmZQXg"/>
</data>
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/compartment/ICompartmentTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/compartment/ICompartmentTests.java
index 654faa0252..cdddc7b23a 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/compartment/ICompartmentTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/compartment/ICompartmentTests.java
@@ -64,6 +64,8 @@ public interface ICompartmentTests {
String SECOND_REGION_CONTAINER_NAME = "az";
+ String SECOND_REGION_CONTAINER_FIRST_PKG_NAME = "aaa";
+
String FIRST_REGION_NAME = "cccc";
String NEW_REGION_CONTAINER_NAME = "p3";
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/compartment/CompartmentsSizeTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/compartment/CompartmentsSizeTest.java
new file mode 100644
index 0000000000..a5e840c924
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/compartment/CompartmentsSizeTest.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2018-2019 Obeo.
+ * 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
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.swtbot.compartment;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.sirius.business.api.session.SessionStatus;
+import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramContainerEditPart;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeContainerEditPart;
+import org.eclipse.sirius.tests.swtbot.support.api.condition.CheckBoundsCondition;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
+
+/**
+ * Test the Make Same Size and Auto-size actions on compartments.
+ *
+ * @author fbarbin
+ *
+ */
+public class CompartmentsSizeTest extends AbstractCompartmentTest {
+
+ private static final String ERROR_MSG = "with the auto-size, the new region width should be smaller than the previous one.";
+
+ private static final Rectangle REGION_P1_BOUNDS_GMF = new Rectangle(64, 16, -1, -1);
+
+ private static final Rectangle REGION_P1_BOUNDS_DRAW2D_VSTACK = new Rectangle(64, 16, 141, 414);
+
+ private static final Rectangle REGION_AZ_BOUNDS_GMF = new Rectangle(338, 66, -1, -1);
+
+ private static final Rectangle REGION_AZ_BOUNDS_DRAW2D_VSTACK = new Rectangle(338, 66, 166, 198);
+
+ private static final Rectangle REGION_AZ_BOUNDS_DRAW2D_VSTACK_AUTO = new Rectangle(338, 66, 59, 198);
+
+ private static final Rectangle REGION_H_P1_BOUNDS_GMF = new Rectangle(0, 0, -1, -1);
+
+ private static final Rectangle REGION_P1_BOUNDS_DRAW2D_HSTACK = new Rectangle(0, 0, 831, 247);
+
+ private static final Rectangle REGION_P1_BOUNDS_DRAW2D_HSTACK_AUTO = new Rectangle(0, 0, 517, 182);
+
+ private static final Rectangle REGION_H_AZ_BOUNDS_GMF = new Rectangle(940, 125, -1, -1);
+
+ private static final Rectangle REGION_AZ_BOUNDS_DRAW2D_HSTACK = new Rectangle(940, 125, 233, 258);
+
+ private String oldFont;
+
+ @Override
+ protected void onSetUpAfterOpeningDesignerPerspective() throws Exception {
+ super.onSetUpAfterOpeningDesignerPerspective();
+ oldFont = changeDefaultFontName("Comic Sans MS");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (oldFont != null) {
+ changeDefaultFontName(oldFont);
+ }
+ super.tearDown();
+ }
+
+ /**
+ * This test makes sure the make same size on compartments works properly on vertical stack even with a different
+ * number of regions between them.
+ */
+ public void testMakeSameSizeVStack() {
+ openRepresentation(VERTICAL_STACK_REPRESENTATION_NAME, VERTICAL_STACK_REPRESENTATION_INSTANCE_NAME);
+
+ assertEquals("Session should not be dirty.", SessionStatus.SYNC, localSession.getOpenedSession().getStatus());
+
+ // Check the regions initial bounds
+ checkBounds(FIRST_REGION_CONTAINER_NAME, REGION_P1_BOUNDS_GMF, REGION_P1_BOUNDS_DRAW2D_VSTACK, false, 0, 0);
+ checkBounds(SECOND_REGION_CONTAINER_NAME, REGION_AZ_BOUNDS_GMF, REGION_AZ_BOUNDS_DRAW2D_VSTACK, false, 0, 0);
+
+ SWTBotGefEditPart part = editor.getEditPart(SECOND_REGION_CONTAINER_NAME, AbstractDiagramContainerEditPart.class);
+ SWTBotGefEditPart part2 = editor.getEditPart(FIRST_REGION_CONTAINER_NAME, AbstractDiagramContainerEditPart.class);
+
+ Collection<SWTBotGefEditPart> parts = new ArrayList<>();
+ parts.add(part);
+ parts.add(part2);
+ editor.select(parts);
+
+ // We perform the make same size. The last selected part (FIRST_REGION_CONTAINER_NAME) is the reference to apply
+ // the size.
+ SWTBotToolbarButton button = bot.toolbarButtonWithTooltip("Make height and width same size");
+ button.click();
+
+ bot.waitUntil(new CheckBoundsCondition((IGraphicalEditPart) part.part(), REGION_P1_BOUNDS_DRAW2D_VSTACK.getCopy().setLocation(REGION_AZ_BOUNDS_DRAW2D_VSTACK.getLocation())));
+
+ }
+
+ /**
+ * This test makes sure the "make same size" on compartments works properly on horizontal stack even with a
+ * different number of regions between them.
+ */
+ public void testMakeSameSizeHStack() {
+ openRepresentation(HORIZONTAL_STACK_REPRESENTATION_NAME, HORIZONTAL_STACK_REPRESENTATION_INSTANCE_NAME);
+
+ assertEquals("Session should not be dirty.", SessionStatus.SYNC, localSession.getOpenedSession().getStatus());
+
+ // Check the regions initial bounds
+ checkBounds(FIRST_REGION_CONTAINER_NAME, REGION_H_P1_BOUNDS_GMF, REGION_P1_BOUNDS_DRAW2D_HSTACK, false, 0, 0);
+ checkBounds(SECOND_REGION_CONTAINER_NAME, REGION_H_AZ_BOUNDS_GMF, REGION_AZ_BOUNDS_DRAW2D_HSTACK, false, 0, 0);
+
+ SWTBotGefEditPart part = editor.getEditPart(SECOND_REGION_CONTAINER_NAME, AbstractDiagramContainerEditPart.class);
+ SWTBotGefEditPart part2 = editor.getEditPart(FIRST_REGION_CONTAINER_NAME, AbstractDiagramContainerEditPart.class);
+
+ Collection<SWTBotGefEditPart> parts = new ArrayList<>();
+ parts.add(part);
+ parts.add(part2);
+ editor.select(parts);
+
+ // We perform the make same size. The last selected part (FIRST_REGION_CONTAINER_NAME) is the reference to apply
+ // the size.
+ SWTBotToolbarButton button = bot.toolbarButtonWithTooltip("Make height and width same size");
+ button.click();
+
+ bot.waitUntil(new CheckBoundsCondition((IGraphicalEditPart) part.part(), REGION_P1_BOUNDS_DRAW2D_HSTACK.getCopy().setLocation(REGION_AZ_BOUNDS_DRAW2D_HSTACK.getLocation())));
+
+ }
+
+ /**
+ * Tests that auto-size works as expected on horizontal region container.
+ */
+ public void testAutoSizeHStack() {
+ openRepresentation(HORIZONTAL_STACK_REPRESENTATION_NAME, HORIZONTAL_STACK_REPRESENTATION_INSTANCE_NAME);
+
+ assertEquals("Session should not be dirty.", SessionStatus.SYNC, localSession.getOpenedSession().getStatus());
+
+ // Check the regions initial bounds
+ checkBounds(FIRST_REGION_CONTAINER_NAME, REGION_H_P1_BOUNDS_GMF, REGION_P1_BOUNDS_DRAW2D_HSTACK, false, 0, 0);
+
+ final SWTBotGefEditPart part = editor.getEditPart(FIRST_REGION_CONTAINER_NAME, AbstractDiagramContainerEditPart.class);
+ editor.select(part);
+ SWTBotToolbarButton button = bot.toolbarButtonWithTooltip("Auto Size");
+ button.click();
+
+ // Check the regions after auto-size
+ bot.waitUntil(new DefaultCondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ Rectangle newBounds = ((DNodeContainerEditPart) part.part()).getFigure().getBounds();
+ return newBounds.preciseWidth() < REGION_P1_BOUNDS_DRAW2D_HSTACK.width;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return ERROR_MSG;
+ }
+ });
+
+ undo();
+
+ // Test applying auto-size on a region
+ final SWTBotGefEditPart part2 = editor.getEditPart(CENTER_CLASS_NAME, AbstractDiagramContainerEditPart.class);
+ editor.select(part2);
+ button = bot.toolbarButtonWithTooltip("Auto Size");
+ button.click();
+
+ // Check the regions after auto-size
+ bot.waitUntil(new DefaultCondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ Rectangle newBounds = ((DNodeContainerEditPart) part.part()).getFigure().getBounds();
+ return newBounds.preciseWidth() < REGION_P1_BOUNDS_DRAW2D_HSTACK.width;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return ERROR_MSG;
+ }
+ });
+ }
+
+ /**
+ * Tests that auto-size works as expected on vertical region container.
+ */
+ public void testAutoSizeVStack() {
+ openRepresentation(VERTICAL_STACK_REPRESENTATION_NAME, VERTICAL_STACK_REPRESENTATION_INSTANCE_NAME);
+
+ assertEquals("Session should not be dirty.", SessionStatus.SYNC, localSession.getOpenedSession().getStatus());
+
+ // Check the regions initial bounds
+ checkBounds(SECOND_REGION_CONTAINER_NAME, REGION_AZ_BOUNDS_GMF, REGION_AZ_BOUNDS_DRAW2D_VSTACK, false, 0, 0);
+
+ final SWTBotGefEditPart part = editor.getEditPart(SECOND_REGION_CONTAINER_NAME, AbstractDiagramContainerEditPart.class);
+ editor.select(part);
+ SWTBotToolbarButton button = bot.toolbarButtonWithTooltip("Auto Size");
+ button.click();
+
+ // Check the regions after auto-size
+ bot.waitUntil(new DefaultCondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ Rectangle newBounds = ((DNodeContainerEditPart) part.part()).getFigure().getBounds();
+ return newBounds.preciseWidth() < REGION_AZ_BOUNDS_DRAW2D_VSTACK.width;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return ERROR_MSG;
+ }
+ });
+
+ undo();
+
+ // Test applying auto-size on a region
+ final SWTBotGefEditPart part2 = editor.getEditPart(SECOND_REGION_CONTAINER_FIRST_PKG_NAME, AbstractDiagramContainerEditPart.class);
+ editor.select(part2);
+ button = bot.toolbarButtonWithTooltip("Auto Size");
+ button.click();
+
+ // Check the regions after auto-size
+ bot.waitUntil(new DefaultCondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ Rectangle newBounds = ((DNodeContainerEditPart) part.part()).getFigure().getBounds();
+ return newBounds.preciseWidth() < REGION_AZ_BOUNDS_DRAW2D_VSTACK.width;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return ERROR_MSG;
+ }
+ });
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
index 0a4232a0ed..4db651e495 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
@@ -24,6 +24,7 @@ import org.eclipse.sirius.tests.swtbot.clipboard.GenericClipboardSupportTest;
import org.eclipse.sirius.tests.swtbot.clipboard.MultiSessionCopyPasteTest;
import org.eclipse.sirius.tests.swtbot.compartment.CompartmentsCreationTest;
import org.eclipse.sirius.tests.swtbot.compartment.CompartmentsDragAndDropTest;
+import org.eclipse.sirius.tests.swtbot.compartment.CompartmentsSizeTest;
import org.eclipse.sirius.tests.swtbot.crossTable.CrossTableIntersectionExpressionTest;
import org.eclipse.sirius.tests.swtbot.crossTable.CrossTableIntersectionTest;
import org.eclipse.sirius.tests.swtbot.editor.vsm.BorderNodeSidePropertySectionTest;
@@ -173,6 +174,7 @@ public class AllTestSuite extends TestCase {
suite.addTestSuite(MigrationTest.class);
suite.addTest(new JUnit4TestAdapter(DragNDropTest.class));
suite.addTestSuite(OpenDiagramWithClassCastExceptionTest.class);
+ suite.addTestSuite(CompartmentsSizeTest.class);
}
/**

Back to the top