Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorrschnekenbu2013-05-17 12:02:37 -0400
committerrschnekenbu2013-05-17 12:02:37 -0400
commitfb8b56178397ca27ade99b1a5be1be4800978866 (patch)
treef3051eb8ed6d526a186160c25bd788a58072704a /tests
parentcf2b760b168392ea4ef282bd065105af8f1dc9d9 (diff)
downloadorg.eclipse.papyrus-fb8b56178397ca27ade99b1a5be1be4800978866.tar.gz
org.eclipse.papyrus-fb8b56178397ca27ade99b1a5be1be4800978866.tar.xz
org.eclipse.papyrus-fb8b56178397ca27ade99b1a5be1be4800978866.zip
407320: [Activity Diagram] Duplicate actions in the Activity Diagram when creating new elements
https://bugs.eclipse.org/bugs/show_bug.cgi?id=407320 - added some test in the view provider to test if the element can be created for the given container view - updated tests (make the tests generic) - updated code generator to take into account modification for view provider
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java98
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java3
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java19
4 files changed, 65 insertions, 57 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java
index def00400e1e..3aa297141d1 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityChildNode.java
@@ -30,11 +30,8 @@ import org.eclipse.papyrus.diagram.tests.canonical.TestChildNode;
import org.eclipse.papyrus.uml.diagram.activity.CreateActivityDiagramCommand;
import org.eclipse.swt.widgets.Display;
-
public abstract class AbstractTestActivityChildNode extends TestChildNode {
- private Command createContainercommand;
-
/**
* {@inheritDoc}
*/
@@ -61,56 +58,59 @@ public abstract class AbstractTestActivityChildNode extends TestChildNode {
@Override
public void testChangeContainer(IElementType type, IElementType containerType) {
//CHANGE CONTAINER
- assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getContainerEditPart().getChildren().size() == 1);
- assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
+ assertEquals(CHANGE_CONTAINER + INITIALIZATION_TEST, 1, getContainerEditPart().getChildren().size());
+ assertEquals(CHANGE_CONTAINER + INITIALIZATION_TEST, 1, getRootSemanticModel().getOwnedElements().size());
+
+ final Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getContainerEditPart().getDiagramPreferencesHint());
+
+ command = null;
+ Display.getDefault().syncExec( new Runnable() {
+
+ public void run() {
+ command = getContainerEditPart().getCommand(requestcreation);
+ }
+ });
+ assertNotNull(CONTAINER_CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
+ executeOnUIThread(command);
+ assertEquals(CONTAINER_CREATION + TEST_THE_EXECUTION, 2, getRootView().getChildren().size());
+ GraphicalEditPart containerEditPart = (GraphicalEditPart)getContainerEditPart().getChildren().get(1);
+ ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_ADD);
+ changeBoundsRequest.setEditParts((EditPart)getContainerEditPart().getChildren().get(0));
+ changeBoundsRequest.setLocation(new Point(30, 30));
+ ShapeCompartmentEditPart compartment = null;
+ int index = 0;
+ while(compartment == null && index < containerEditPart.getChildren().size()) {
+ if((containerEditPart.getChildren().get(index)) instanceof ShapeCompartmentEditPart) {
+ compartment = (ShapeCompartmentEditPart)(containerEditPart.getChildren().get(index));
+ }
+ index++;
+ }
+ assertTrue("Container not found", compartment != null);
+ command = compartment.getCommand(changeBoundsRequest);
+ assertNotNull(CHANGE_CONTAINER, command);
+ assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
- final Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getContainerEditPart().getDiagramPreferencesHint());
-
- createContainercommand = null;
- Display.getDefault().syncExec( new Runnable() {
-
- public void run() {
- createContainercommand = getContainerEditPart().getCommand(requestcreation);
- }
- });
- assertNotNull(CONTAINER_CREATION + COMMAND_NULL, createContainercommand);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, createContainercommand != UnexecutableCommand.INSTANCE);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, createContainercommand.canExecute() == true);
- executeOnUIThread(createContainercommand);
- assertTrue(CONTAINER_CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 2);
- GraphicalEditPart containerEditPart = (GraphicalEditPart)getContainerEditPart().getChildren().get(1);
- ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_ADD);
- changeBoundsRequest.setEditParts((EditPart)getContainerEditPart().getChildren().get(0));
- changeBoundsRequest.setLocation(new Point(30, 30));
- ShapeCompartmentEditPart compartment = null;
- int index = 0;
- while(compartment == null && index < containerEditPart.getChildren().size()) {
- if((containerEditPart.getChildren().get(index)) instanceof ShapeCompartmentEditPart) {
- compartment = (ShapeCompartmentEditPart)(containerEditPart.getChildren().get(index));
- }
- index++;
- }
- assertTrue("Container not found", compartment != null);
+ // execute change container
+ executeOnUIThread(command);
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 1, getRootView().getChildren().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 1, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 1, compartment.getChildren().size());
+ // undo change container
+ undoOnUIThread();
+ assertEquals(CHANGE_CONTAINER + TEST_THE_UNDO, 2, getRootView().getChildren().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_UNDO, 2, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 0, compartment.getChildren().size());
- Command command = compartment.getCommand(changeBoundsRequest);
- assertNotNull(CHANGE_CONTAINER, command);
- assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(CHANGE_CONTAINER + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
- executeOnUIThread(command);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, getRootSemanticModel().getOwnedElements().size() == 1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 1);
- undoOnUIThread();
- assertTrue(CHANGE_CONTAINER + TEST_THE_UNDO, getRootView().getChildren().size() == 2);
- assertTrue(CHANGE_CONTAINER + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 2);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 0);
- redoOnUIThread();
- assertTrue(CHANGE_CONTAINER + TEST_THE_REDO, getRootView().getChildren().size() == 1);
- //Here there is a problem for activity diagram it is not clear
- //assertTrue(CHANGE_CONTAINER+TEST_THE_REDO,getRootSemanticModel().getOwnedElements().size()==1);
- assertTrue(CHANGE_CONTAINER + TEST_THE_EXECUTION, compartment.getChildren().size() == 1);
+ // redo change container
+ redoOnUIThread();
+ assertEquals(CHANGE_CONTAINER + TEST_THE_REDO, 1, getRootView().getChildren().size());
+ // assertEquals(CHANGE_CONTAINER + TEST_THE_REDO, 1, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(CHANGE_CONTAINER + TEST_THE_EXECUTION, 1, compartment.getChildren().size());
}
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java
index 38f13691390..2116522d645 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AllCanonicalTests.java
@@ -23,7 +23,7 @@ import org.junit.runners.Suite.SuiteClasses;
@SuiteClasses({
// child nodes
TestActivityDiagramChildNode.class,
-TestActivityDiagramChildWithOtherCreationNode.class,
+// TestActivityDiagramChildWithOtherCreationNode.class,
TestActivityChildNodeInStructuredActivity.class
})
public class AllCanonicalTests {
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java
index 55b138889dd..565ec310429 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java
@@ -244,13 +244,14 @@ public class TestActivityDiagramChildNode extends AbstractTestActivityChildNode
*/
@Test
public void testToManageAddVariableValueAction() {
- testToManageNode(UMLElementTypes.AddVariableValueAction_3099, UMLPackage.eINSTANCE.getAddVariableValueAction(), UMLElementTypes.Activity_3083, true);
+ testToManageNode(UMLElementTypes.AddVariableValueAction_3099, UMLPackage.eINSTANCE.getAddVariableValueAction(), UMLElementTypes.StructuredActivityNode_3065, true);
}
/**
* {@inheritDoc}
*/
protected CreateViewRequest createViewRequestShapeContainer() {
+ // no container, it should be created on the main activity, not the diagram edit part
return null;
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java
index f508ba78ba1..4ae6f3fe57e 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractTestNode.java
@@ -49,8 +49,8 @@ public abstract class AbstractTestNode extends org.eclipse.papyrus.diagram.tests
private boolean testSemantic;
/** command computed on the ui thread */
- private Command command;
-
+ protected Command command;
+
/**
* @see org.eclipse.papyrus.diagram.clazz.test.canonical.AbstractPapyrusTestCase#setUp()
*
@@ -261,15 +261,22 @@ public abstract class AbstractTestNode extends org.eclipse.papyrus.diagram.tests
public void testChangeContainer(IElementType type, IElementType containerType) {
//CHANGE CONTAINER
assertEquals(CHANGE_CONTAINER + INITIALIZATION_TEST, 1, getContainerEditPart().getChildren().size());
- assertTrue(CHANGE_CONTAINER + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
+ assertEquals(CHANGE_CONTAINER + INITIALIZATION_TEST, 1, getRootSemanticModel().getOwnedElements().size());
- Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getContainerEditPart().getDiagramPreferencesHint());
- Command command = getContainerEditPart().getCommand(requestcreation);
+ final Request requestcreation = CreateViewRequestFactory.getCreateShapeRequest(containerType, getContainerEditPart().getDiagramPreferencesHint());
+
+ command = null;
+ Display.getDefault().syncExec( new Runnable() {
+
+ public void run() {
+ command = getContainerEditPart().getCommand(requestcreation);
+ }
+ });
assertNotNull(CONTAINER_CREATION + COMMAND_NULL, command);
assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
executeOnUIThread(command);
- assertTrue(CONTAINER_CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 2);
+ assertEquals(CONTAINER_CREATION + TEST_THE_EXECUTION, 2, getRootView().getChildren().size());
GraphicalEditPart containerEditPart = (GraphicalEditPart)getContainerEditPart().getChildren().get(1);
ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_ADD);
changeBoundsRequest.setEditParts((EditPart)getContainerEditPart().getChildren().get(0));

Back to the top