Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCamille Letavernier2013-07-26 12:41:40 +0000
committerCamille Letavernier2013-07-26 12:41:40 +0000
commit2b66cb06b6d9706e14b13314a2dfd3bf27013561 (patch)
tree7afeb8881312cac4be70f5748cc71833f04e016d /tests
parent81b1155aa31a69de9aeee6f694f60dd184c5048b (diff)
downloadorg.eclipse.papyrus-2b66cb06b6d9706e14b13314a2dfd3bf27013561.tar.gz
org.eclipse.papyrus-2b66cb06b6d9706e14b13314a2dfd3bf27013561.tar.xz
org.eclipse.papyrus-2b66cb06b6d9706e14b13314a2dfd3bf27013561.zip
389531: [Sequence Diagram] Graphical Presentation of Gate with In/Out
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389531
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/AbstractNodeTest.java11
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java112
2 files changed, 123 insertions, 0 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/AbstractNodeTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/AbstractNodeTest.java
index d3f089a1879..739c6f71605 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/AbstractNodeTest.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/AbstractNodeTest.java
@@ -50,6 +50,7 @@ import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.ISequenceDiagramTestsConstants;
import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
@@ -70,6 +71,16 @@ public abstract class AbstractNodeTest extends TestTopNode {
private static final String RESIZE = "Resize: ";
+ @Override
+ protected String getProjectName() {
+ return ISequenceDiagramTestsConstants.PROJECT_NAME;
+ }
+
+ @Override
+ protected String getFileName() {
+ return ISequenceDiagramTestsConstants.FILE_NAME;
+ }
+
/**
* @see org.eclipse.papyrus.diagram.tests.canonical.AbstractPapyrusTestCase#getDiagramCommandCreation()
*
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java
new file mode 100644
index 00000000000..7edb464079d
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA
+ *
+ *
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Soyatec - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.tests.bug.m7;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.Gate;
+import org.eclipse.uml2.uml.Lifeline;
+import org.eclipse.uml2.uml.Message;
+import org.junit.Test;
+
+
+/**
+ * Test the name of a Gate which created automatically on CombinedFragment when adding a Message.
+ *
+ * @author Jin Liu (jin.liu@soyatec.com)
+ */
+public class TestGateNameOnCombinedFragment extends AbstractNodeTest {
+
+ @Test
+ public void testUncoveredLifeline2CombinedFragment() {
+ testGateName("in_", false, true);
+ }
+
+
+ @Test
+ public void testCoveredLifeline2CombinedFragment() {
+ testGateName("out_", true, true);
+ }
+
+ @Test
+ public void testCombinedFragment2CoveredLifeline() {
+ testGateName("in_", true, false);
+ }
+
+ @Test
+ public void testCombinedFragment2UncoveredLifeline() {
+ testGateName("out_", false, false);
+ }
+
+ private void testGateName(String gateNamePrefix, boolean lifelineCovered, boolean messageFromLifeline2CombinedFragment) {
+ //1. Create CombinedFragment
+ CombinedFragmentEditPart cfEditPart = (CombinedFragmentEditPart)createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(100, 200), null);
+ assertNotNull("CombinedFragment creation", cfEditPart);
+
+ //2. Create Lifeline
+ //Create a Lifeline which is covered by the CombinedFragment
+ Rectangle cfBounds = SequenceUtil.getAbsoluteBounds(cfEditPart);
+ Point lifelineLocation = new Point(0, 100);
+ if(lifelineCovered) {
+ lifelineLocation.x = cfBounds.getCenter().x;
+ } else {
+ lifelineLocation.x = cfBounds.getRight().x + 100;
+ }
+ LifelineEditPart lifelineEp = (LifelineEditPart)createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), lifelineLocation, null);
+ assertNotNull("Lifeline Creation", lifelineEp);
+
+ //3. Check covered.
+ CombinedFragment combinedFragment = (CombinedFragment)cfEditPart.resolveSemanticElement();
+ Lifeline lifeline = (Lifeline)lifelineEp.resolveSemanticElement();
+ if(lifelineCovered) {
+ assertTrue("lifeline is covered by combinedFragment", lifeline.getCoveredBys().contains(combinedFragment));
+ } else {
+ assertTrue("lifeline is not covered by combinedFragment", !lifeline.getCoveredBys().contains(combinedFragment));
+ }
+
+ //4. Create Message between Lifeline and CombinedFragment.
+ EditPart source = null, target = null;
+ Point startLocation = null, targetLocation = null;
+ if(messageFromLifeline2CombinedFragment) {
+ source = lifelineEp;
+ target = cfEditPart;
+ targetLocation = SequenceUtil.getAbsoluteBounds(cfEditPart).getRight().getCopy();
+ startLocation = SequenceUtil.getAbsoluteBounds(lifelineEp).getCenter().setY(targetLocation.y);
+ } else {
+ source = cfEditPart;
+ startLocation = SequenceUtil.getAbsoluteBounds(cfEditPart).getRight().getCopy();
+ target = lifelineEp;
+ targetLocation = SequenceUtil.getAbsoluteBounds(lifelineEp).getCenter().setY(startLocation.y);
+ }
+ AbstractMessageEditPart messageEditPart = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, cfEditPart.getViewer(), startLocation, source, targetLocation, target);
+ assertNotNull("Message creation between Lifeline and CombinedFragment", messageEditPart);
+
+ //5. Check Gate name
+ IGraphicalEditPart gateEditPart = cfEditPart.getChildBySemanticHint(GateEditPart.GATE_TYPE);
+ assertNotNull("Gate created", gateEditPart);
+ assertTrue("Gate created successfully", gateEditPart instanceof GateEditPart);
+ Gate gate = (Gate)((GateEditPart)gateEditPart).resolveSemanticElement();
+ Message message = (Message)messageEditPart.resolveSemanticElement();
+ assertEquals("Gate name", gateNamePrefix + message.getLabel(), gate.getLabel());
+ }
+}

Back to the top