Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2018-07-24 12:50:46 +0000
committerNicolas FAUVERGUE2018-07-24 13:57:50 +0000
commit892cb3c424d47082d850b38a6c793692817c7a8a (patch)
treea12120fccb1a4808a8b9b55cb9aae28a3d1912fb /tests/junit
parentaa9490b90434811a4f38075ff24d0869106c8a03 (diff)
downloadorg.eclipse.papyrus-892cb3c424d47082d850b38a6c793692817c7a8a.tar.gz
org.eclipse.papyrus-892cb3c424d47082d850b38a6c793692817c7a8a.tar.xz
org.eclipse.papyrus-892cb3c424d47082d850b38a6c793692817c7a8a.zip
Bug 479981 - [Component Diagram] Components-in-component misplaced
Change-Id: Ie7b8879202ff0cd43cd86afab28e185542ac7c4b Signed-off-by: atischenko <tischenko@montages.com> Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'tests/junit')
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/AllTests.java6
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/dnd/AllDropTests.java25
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/dnd/TestDropComponent.java163
3 files changed, 192 insertions, 2 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/AllTests.java
index dc503863b1c..c4d430a7cbc 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/AllTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/AllTests.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2013, 2015 CEA LIST, Christian W. Damus, and others.
*
- *
+ *
* 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
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.uml.diagram.component.test;
import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite.DynamicClasses;
import org.eclipse.papyrus.uml.diagram.component.test.canonical.AllCanonicalTests;
+import org.eclipse.papyrus.uml.diagram.component.test.dnd.AllDropTests;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -26,7 +27,8 @@ import org.junit.runners.Suite.SuiteClasses;
@SuiteClasses({
// canonical
AllCanonicalTests.class,
- RoundedCompartmentTest.class
+ RoundedCompartmentTest.class,
+ AllDropTests.class
// load
// LoadTests.class,
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/dnd/AllDropTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/dnd/AllDropTests.java
new file mode 100644
index 00000000000..f2e51b772c9
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/dnd/AllDropTests.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.component.test.dnd;
+
+import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(ClassificationSuite.class)
+@SuiteClasses({
+ TestDropComponent.class
+})
+public class AllDropTests {
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/dnd/TestDropComponent.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/dnd/TestDropComponent.java
new file mode 100644
index 00000000000..15183ace59d
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component.tests/src/org/eclipse/papyrus/uml/diagram/component/test/dnd/TestDropComponent.java
@@ -0,0 +1,163 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.component.test.dnd;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Arrays;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.gmfdiag.menu.utils.DeleteActionUtil;
+import org.eclipse.papyrus.uml.diagram.component.CreateComponentDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.ComponentCompositeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.ComponentEditPart;
+import org.eclipse.papyrus.uml.diagram.component.edit.parts.ComponentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.component.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.component.test.IComponentDiagramTestsConstants;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusSemanticTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestDropComponent extends AbstractPapyrusSemanticTestCase {
+
+ protected IGraphicalEditPart topComponent;
+
+ protected IGraphicalEditPart topCompartment;
+
+ protected IGraphicalEditPart childComponent;
+
+ @Before
+ public void init() {
+ topComponent = createChild(ComponentEditPart.VISUAL_ID, getDiagramEditPart());
+ topCompartment = findChildBySemanticHint(topComponent, ComponentCompositeCompartmentEditPart.VISUAL_ID);
+ childComponent = createChild(ComponentEditPartCN.VISUAL_ID, topCompartment);
+ }
+
+ @Test
+ public void testDropChildComponentFromComponentToDiagram() {
+ IGraphicalEditPart diagram = getDiagramEditPart();
+ Request req = createDragDropRequest(childComponent);
+ Command command = diagram.getCommand(req);
+ assertNotNull("Drop component from component to diagram command must not be null", command);
+
+ int diagramChildrenBefore = diagram.getChildren().size();
+ executeOnUIThread(command);
+ assertEquals(diagramChildrenBefore + 1, diagram.getChildren().size());
+ }
+
+ @Test
+ public void testHideAndDropChildComponentToComponent() {
+ EObject childComponentSemantic = childComponent.resolveSemanticElement();
+
+ Command command = DeleteActionUtil.getDeleteFromDiagramCommand(childComponent);
+ assertNotNull("ComponentEditPartCN should have posible to be deleted from diagram", command);
+ int childrenBefore = topCompartment.getChildren().size();
+ executeOnUIThread(command);
+ assertEquals(childrenBefore - 1, topCompartment.getChildren().size());
+
+ Request req = createDropObjectRequest(childComponentSemantic);
+ command = topCompartment.getCommand(req);
+ assertNotNull("ComponentEditPartCN must be dropable to top component editpart", command);
+ execute(command);
+ assertEquals(childrenBefore, topCompartment.getChildren().size());
+ }
+
+ @Test
+ public void testHideChild_DropToDiagram_DropToParentComponent() {
+ EObject childComponentSemantic = childComponent.resolveSemanticElement();
+ IGraphicalEditPart diagram = getDiagramEditPart();
+
+ Command command = DeleteActionUtil.getDeleteFromDiagramCommand(childComponent);
+ assertNotNull("ComponentEditPartCN should have posible to be deleted from diagram", command);
+ int childrenBefore = topCompartment.getChildren().size();
+ executeOnUIThread(command);
+ assertEquals(childrenBefore - 1, topCompartment.getChildren().size());
+
+ Request req = createDropObjectRequest(childComponentSemantic);
+ command = diagram.getCommand(req);
+ int diagramCgildrenBefore = diagram.getChildren().size();
+ assertNotNull("Component must be dropable to diagram", command);
+ execute(command);
+ assertEquals(diagramCgildrenBefore + 1, diagram.getChildren().size());
+
+ IGraphicalEditPart componentToDrop = null;
+ // find component to drop
+ for (Object child : diagram.getChildren()) {
+ IGraphicalEditPart childEP = (IGraphicalEditPart) child;
+ if (childEP.resolveSemanticElement() == childComponentSemantic) {
+ componentToDrop = childEP;
+ break;
+ }
+ }
+ assertNotNull("Cannot find dropped component to diagram", componentToDrop);
+ req = createDragDropRequest(componentToDrop);
+ command = topCompartment.getCommand(req);
+ assertNotNull("ComponentEditPart must be dropable from diagram to self semantically parent", command);
+ execute(command);
+ assertEquals(diagramCgildrenBefore, diagram.getChildren().size());
+ assertEquals(childrenBefore, topCompartment.getChildren().size());
+ }
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateComponentDiagramCommand();
+ }
+
+ @Override
+ protected String getProjectName() {
+ return IComponentDiagramTestsConstants.PROJECT_NAME;
+ }
+
+ @Override
+ protected String getFileName() {
+ return IComponentDiagramTestsConstants.FILE_NAME;
+ }
+
+ protected Request createDropObjectRequest(EObject objectToDrop) {
+ DropObjectsRequest result = new DropObjectsRequest();
+ result.setObjects(Arrays.asList(objectToDrop));
+ result.setType(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DROP_OBJECTS);
+ result.setLocation(new Point(1, 1));
+ return result;
+ }
+
+ protected Request createDragDropRequest(IGraphicalEditPart editPart) {
+ ChangeBoundsRequest result = new ChangeBoundsRequest();
+ result.setEditParts(editPart);
+ result.setLocation(new Point(1, 1));
+ result.setType(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DROP);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.diagram.tests.canonical.AbstractPapyrusSemanticTestCase#getTypeByID(java.lang.String)
+ */
+ @Override
+ protected IElementType getTypeByID(final String vid) {
+ return UMLElementTypes.getElementType(vid);
+ }
+
+
+}

Back to the top