Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-04-16 14:11:28 +0000
committerBenoit Maggi2014-04-16 14:11:28 +0000
commit7244cb50f720ea95826bdab12b5dbb8398507d75 (patch)
tree27f4a01a965d5d68a2cb5f506715efadb50d6fbb
parentf12a871dde88d2ea09453b757daf02ec4847bc5a (diff)
downloadorg.eclipse.papyrus-7244cb50f720ea95826bdab12b5dbb8398507d75.tar.gz
org.eclipse.papyrus-7244cb50f720ea95826bdab12b5dbb8398507d75.tar.xz
org.eclipse.papyrus-7244cb50f720ea95826bdab12b5dbb8398507d75.zip
Bug - 432813 : Move the enabled test from setEnabled to computeEnabled
- it will patch the broken test for sysml.explorer.copy.paste - also add //$NON-NLS-1$ for all assert in modelexplorer.test Change-Id: I8cba06310e127ae115fc4f7a237f4fbb5b9d2c9f Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java9
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java11
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java52
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteBlockTest.java10
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteReferenceTest.java3
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java26
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java8
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java8
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java10
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java14
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java334
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java150
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java410
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java442
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java124
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteHandlerTest.java12
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java8
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/OpendiagramTest.java238
18 files changed, 940 insertions, 929 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
index 2e7a25fe7bc..4e223669af6 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
@@ -50,12 +50,13 @@ public class CopyHandler extends AbstractCommandHandler {
}
return defaultCopyCommand;
}
-
+
/* (non-Javadoc)
- * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#computeEnabled()
*/
@Override
- public void setEnabled(Object evaluationContext) { // copy is enable as long as there is an EObject to put in the Clipboard
- setBaseEnabled(!getSelectedElements().isEmpty());
+ protected boolean computeEnabled() { // copy is enable as long as there is an EObject to put in the Clipboard
+ return !getSelectedElements().isEmpty();
}
+
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java
index 0abbaddb6b6..60ec26aeb3d 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/PasteHandler.java
@@ -55,12 +55,15 @@ public class PasteHandler extends AbstractCommandHandler {
return UnexecutableCommand.INSTANCE;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.views.modelexplorer.handler.AbstractCommandHandler#computeEnabled()
+ */
@Override
- public void setEnabled(Object evaluationContext) { // past is only available on a simple selection and wit ha full Clipboard
+ protected boolean computeEnabled() { // paste is only available on a simple selection and wit ha full Clipboard
if (!PapyrusClipboard.getInstance().isEmpty() && getSelectedElements().size() == 1){
- super.setEnabled(evaluationContext);
+ return true;
} else {
- setBaseEnabled(false);
- }
+ return super.computeEnabled();
+ }
}
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java
index 1c386641ccf..dd9d9861e10 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java
@@ -75,7 +75,7 @@ public abstract class AbstractModelExplorerTest {
public static IEditorPart editor = null;
/** id of the papyrus editor */
- public static String editorID = "org.eclipse.papyrus.infra.core.papyrusEditor";
+ public static String editorID = "org.eclipse.papyrus.infra.core.papyrusEditor";
/** view part: the model explorer */
protected static IViewPart modelExplorerPart;
@@ -172,42 +172,42 @@ public abstract class AbstractModelExplorerTest {
DiagramEditPart diagramEditPart = EditorUtils.getDiagramEditPart();
EObject root = diagramEditPart.getDiagramView().getElement();
- Assert.assertTrue("Impossible to find main model", root instanceof Model);
+ Assert.assertTrue("Impossible to find main model", root instanceof Model); //$NON-NLS-1$
/** generated selectable objects */
model_EObject = (org.eclipse.uml2.uml.Model)root;
b1_EObject = (org.eclipse.uml2.uml.Class)model_EObject.getPackagedElement("B1");
- Assert.assertNotNull("Impossible to find Class B1", b1_EObject);
+ Assert.assertNotNull("Impossible to find Class B1", b1_EObject); //$NON-NLS-1$
pB1P1_B1_EObject = b1_EObject.getAttribute("pB1P1", null);
- Assert.assertNotNull("Impossible to find Property pB1P1", pB1P1_B1_EObject);
+ Assert.assertNotNull("Impossible to find Property pB1P1", pB1P1_B1_EObject); //$NON-NLS-1$
rB2_B1_EObject = b1_EObject.getAttribute("rB2", null);
- Assert.assertNotNull("Impossible to find Property rB2", rB2_B1_EObject);
+ Assert.assertNotNull("Impossible to find Property rB2", rB2_B1_EObject); //$NON-NLS-1$
pB2_B1_EObject = b1_EObject.getAttribute("pB2", null);
- Assert.assertNotNull("Impossible to find Property pB2", pB2_B1_EObject);
+ Assert.assertNotNull("Impossible to find Property pB2", pB2_B1_EObject); //$NON-NLS-1$
b2_EObject = (org.eclipse.uml2.uml.Class)model_EObject.getPackagedElement("B2");
- Assert.assertNotNull("Impossible to find Class B2", b2_EObject);
+ Assert.assertNotNull("Impossible to find Class B2", b2_EObject); //$NON-NLS-1$
p1_EObject = (org.eclipse.uml2.uml.Package)model_EObject.getPackagedElement("P1");
- Assert.assertNotNull("Impossible to find Package P1", p1_EObject);
+ Assert.assertNotNull("Impossible to find Package P1", p1_EObject); //$NON-NLS-1$
b2P1_P1_EObject = (org.eclipse.uml2.uml.Class)p1_EObject.getPackagedElement("B2P1");
- Assert.assertNotNull("Impossible to find Class B2P1", b2P1_P1_EObject);
+ Assert.assertNotNull("Impossible to find Class B2P1", b2P1_P1_EObject); //$NON-NLS-1$
b1P1_P1_EObject = (org.eclipse.uml2.uml.Class)p1_EObject.getPackagedElement("B1P1");
- Assert.assertNotNull("Impossible to find Class B1P1", b1P1_P1_EObject);
+ Assert.assertNotNull("Impossible to find Class B1P1", b1P1_P1_EObject); //$NON-NLS-1$
pB1_B1P1_P1_EObject = b1P1_P1_EObject.getAttribute("pB1", null);
- Assert.assertNotNull("Impossible to find Property pB1", pB1_B1P1_P1_EObject);
+ Assert.assertNotNull("Impossible to find Property pB1", pB1_B1P1_P1_EObject); //$NON-NLS-1$
pB2P1_B1P1_P1_EObject = b1P1_P1_EObject.getAttribute("pB2P1", null);
- Assert.assertNotNull("Impossible to find Property pB2P1", pB2P1_B1P1_P1_EObject);
+ Assert.assertNotNull("Impossible to find Property pB2P1", pB2P1_B1P1_P1_EObject); //$NON-NLS-1$
iBD_B1_Diagram = getDiagram("IBD_B1");
- Assert.assertNotNull("Impossible to find IBD_B1", iBD_B1_Diagram);
+ Assert.assertNotNull("Impossible to find IBD_B1", iBD_B1_Diagram); //$NON-NLS-1$
bDD_Main_Diagram = getDiagram("BDD_Main");
- Assert.assertNotNull("Impossible to find BDD_Main", bDD_Main_Diagram);
+ Assert.assertNotNull("Impossible to find BDD_Main", bDD_Main_Diagram); //$NON-NLS-1$
List<Customization> appliedCustomizations=org.eclipse.papyrus.views.modelexplorer.Activator.getDefault().getCustomizationManager().getManagedCustomizations();
Customization SimpleUML=null;
Iterator<?>iter=appliedCustomizations.iterator();
@@ -217,12 +217,12 @@ public abstract class AbstractModelExplorerTest {
SimpleUML=custo;
}
}
- org.junit.Assert.assertNotNull("Custom SimpleUML not found", SimpleUML);
+ Assert.assertNotNull("Custom SimpleUML not found", SimpleUML); //$NON-NLS-1$
org.eclipse.papyrus.views.modelexplorer.Activator.getDefault().getCustomizationManager().getManagedCustomizations().add(0, SimpleUML);
- org.junit.Assert.assertEquals("bad order of applied Custom", "SimpleUML", appliedCustomizations.get(0).getName());
+ Assert.assertEquals("bad order of applied Custom", "SimpleUML", appliedCustomizations.get(0).getName()); //$NON-NLS-1$
/** end of generated selectable objects */
}
@@ -293,7 +293,7 @@ public abstract class AbstractModelExplorerTest {
semanticElementList.addAll(newElements);
modelExplorerView.revealSemanticElement(semanticElementList);
} else {
- throw new Exception("Impossible to find the model explorer required to select: " + newElements);
+ throw new Exception("Impossible to find the model explorer required to select: " + newElements); //$NON-NLS-1$
}
}
@@ -372,7 +372,7 @@ public abstract class AbstractModelExplorerTest {
modelExplorerView.revealSemanticElement(semanticElementList);
//reveal(semanticElementList, modelExplorerView.getCommonViewer());
} else {
- throw new Exception("Impossible to find the model explorer required to select: " + newDiagrams);
+ throw new Exception("Impossible to find the model explorer required to select: " + newDiagrams); //$NON-NLS-1$
}
}
@@ -476,11 +476,11 @@ public abstract class AbstractModelExplorerTest {
protected EObjectTreeElement findSemanticModelElementItem(EObject objectToFind) throws Exception {
selectAndReveal(objectToFind);
IStructuredSelection selection = (IStructuredSelection)modelExplorerPart.getSite().getSelectionProvider().getSelection();
- Assert.assertEquals("one and only one object should be selected", 1, selection.size());
+ Assert.assertEquals("one and only one object should be selected", 1, selection.size()); //$NON-NLS-1$
Object selectedElement = selection.getFirstElement();
- Assert.assertTrue("selection should be a model item element", selectedElement instanceof EObjectTreeElement);
- Assert.assertTrue("selection should be linked to a EObject", ((EObjectTreeElement)selectedElement).getEObject() instanceof EObject);
- Assert.assertTrue("selection should be linked to the Object: " + objectToFind, ((EObjectTreeElement)selectedElement).getEObject().equals(objectToFind));
+ Assert.assertTrue("selection should be a model item element", selectedElement instanceof EObjectTreeElement); //$NON-NLS-1$
+ Assert.assertTrue("selection should be linked to a EObject", ((EObjectTreeElement)selectedElement).getEObject() instanceof EObject); //$NON-NLS-1$
+ Assert.assertTrue("selection should be linked to the Object: " + objectToFind, ((EObjectTreeElement)selectedElement).getEObject().equals(objectToFind)); //$NON-NLS-1$
return (EObjectTreeElement)selectedElement;
}
@@ -497,11 +497,11 @@ public abstract class AbstractModelExplorerTest {
selectAndRevealDiagram(diagramToFind);
IStructuredSelection selection = (IStructuredSelection)modelExplorerPart.getSite().getSelectionProvider().getSelection();
- Assert.assertEquals("one and only one diagram should be selected", 1, selection.size());
+ Assert.assertEquals("one and only one diagram should be selected", 1, selection.size()); //$NON-NLS-1$
Object selectedElement = selection.getFirstElement();
- Assert.assertTrue("selection should be a model item element", selectedElement instanceof EObjectTreeElement);
- Assert.assertTrue("selection should be linked to a Diagram", ((EObjectTreeElement)selectedElement).getEObject() instanceof Diagram);
- Assert.assertTrue("selection should be linked to the Object: " + diagramToFind, ((EObjectTreeElement)selectedElement).getEObject().equals(diagramToFind));
+ Assert.assertTrue("selection should be a model item element", selectedElement instanceof EObjectTreeElement); //$NON-NLS-1$
+ Assert.assertTrue("selection should be linked to a Diagram", ((EObjectTreeElement)selectedElement).getEObject() instanceof Diagram); //$NON-NLS-1$
+ Assert.assertTrue("selection should be linked to the Object: " + diagramToFind, ((EObjectTreeElement)selectedElement).getEObject().equals(diagramToFind)); //$NON-NLS-1$
return (EObjectTreeElement)selectedElement;
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteBlockTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteBlockTest.java
index 4b28cca05c6..e936af4ae53 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteBlockTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteBlockTest.java
@@ -40,7 +40,8 @@ public abstract class AbstractCopyPasteBlockTest extends AbstractCopyPasteTest {
super.initializeTest(additionalChecks, targetContainer, copiedEObject);
/* pre-copy initialization */
- List<Property> originalParts = new ArrayList<Property>(); for(Property p : ((org.eclipse.uml2.uml.Class)copiedEObject).getAllAttributes()) { if(new org.eclipse.papyrus.sysml.service.types.matcher.PartPropertyMatcher().matches(p)) {originalParts.add(p);}} additionalChecks.put("originalParts", originalParts);
+ List<Property> originalParts = new ArrayList<Property>();
+ for(Property p : ((org.eclipse.uml2.uml.Class)copiedEObject).getAllAttributes()) { if(new org.eclipse.papyrus.sysml.service.types.matcher.PartPropertyMatcher().matches(p)) {originalParts.add(p);}} additionalChecks.put("originalParts", originalParts);
/* END OF pre-copy initialization */
}
@@ -54,7 +55,12 @@ public abstract class AbstractCopyPasteBlockTest extends AbstractCopyPasteTest {
super.postCopyAdditionalChecks(originalModel, newValues, delta);
/* post copy checks */
- FilteredCollectionView<EObject> newClasses = new FilteredCollectionView<EObject>(delta, new IFilter() { /** * {@inheritDoc} */ public boolean isAllowed(Object object) { return object instanceof org.eclipse.uml2.uml.Class && !(object instanceof org.eclipse.uml2.uml.Association); } }); Assert.assertEquals("New values should contain a Class", 1, newClasses.size()); org.eclipse.uml2.uml.Class newBlock = newClasses.toArray(new org.eclipse.uml2.uml.Class[]{})[0]; Assert.assertNotNull("Block stereotype should be applied", ((org.eclipse.uml2.uml.Class) newBlock) .getAppliedStereotype("SysML::Blocks::Block")); List<Property> originalParts = (List<Property>) originalModel .get("originalParts"); List<Property> newParts = new ArrayList<Property>(); for (Property p : ((org.eclipse.uml2.uml.Class) newBlock) .getAllAttributes()) { if (new org.eclipse.papyrus.sysml.service.types.matcher.PartPropertyMatcher().matches(p)) { newParts.add(p); Assert.assertNotNull( "Part should have an associated association.", p.getAssociation()); } } Assert.assertEquals( "Both original and new list of attributes should be quivalent for the blocks", originalParts.size(), newParts.size());
+ FilteredCollectionView<EObject> newClasses = new FilteredCollectionView<EObject>(delta, new IFilter() { /** * {@inheritDoc} */ public boolean isAllowed(Object object) { return object instanceof org.eclipse.uml2.uml.Class && !(object instanceof org.eclipse.uml2.uml.Association); } });
+ Assert.assertEquals("New values should contain a Class", 1, newClasses.size()); //$NON-NLS-1$
+ org.eclipse.uml2.uml.Class newBlock = newClasses.toArray(new org.eclipse.uml2.uml.Class[]{})[0];
+ Assert.assertNotNull("Block stereotype should be applied", ((org.eclipse.uml2.uml.Class) newBlock).getAppliedStereotype("SysML::Blocks::Block")); //$NON-NLS-1$
+ List<Property> originalParts = (List<Property>) originalModel .get("originalParts"); List<Property> newParts = new ArrayList<Property>(); for (Property p : ((org.eclipse.uml2.uml.Class) newBlock) .getAllAttributes()) { if (new org.eclipse.papyrus.sysml.service.types.matcher.PartPropertyMatcher().matches(p)) { newParts.add(p); Assert.assertNotNull( "Part should have an associated association.", p.getAssociation()); } }
+ Assert.assertEquals( "Both original and new list of attributes should be quivalent for the blocks", originalParts.size(), newParts.size()); //$NON-NLS-1$
/* END OF post copy checks */
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteReferenceTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteReferenceTest.java
index 1ea66a8dec2..17b6ec3f5e1 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteReferenceTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteReferenceTest.java
@@ -51,7 +51,8 @@ public abstract class AbstractCopyPasteReferenceTest extends AbstractCopyPasteTe
super.postCopyAdditionalChecks(originalModel, newValues, delta);
/* post copy checks */
- Association newAssociation = ((Property)newValues.get(0)).getAssociation(); Assert.assertNotNull("New Reference should have an association", newAssociation);
+ Association newAssociation = ((Property)newValues.get(0)).getAssociation();
+ Assert.assertNotNull("New Reference should have an association", newAssociation); //$NON-NLS-1$
/* END OF post copy checks */
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java
index cef2d877c86..775705e82d9 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/AbstractCopyPasteTest.java
@@ -65,14 +65,14 @@ public abstract class AbstractCopyPasteTest extends AbstractModelExplorerTest {
ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
commandService.refreshElements(IWorkbenchCommandConstants.EDIT_PASTE, null);
org.eclipse.core.commands.Command pasteCommand = commandService.getCommand(IWorkbenchCommandConstants.EDIT_PASTE);
- Assert.assertNotNull("Impossible to find paste command", pasteCommand);
- Assert.assertTrue("command in not enabled", pasteCommand.isEnabled());
- Assert.assertTrue("command in not defined", pasteCommand.isDefined());
+ Assert.assertNotNull("Impossible to find paste command", pasteCommand); //$NON-NLS-1$
+ Assert.assertTrue("command in not enabled", pasteCommand.isEnabled()); //$NON-NLS-1$
+ Assert.assertTrue("command in not defined", pasteCommand.isDefined()); //$NON-NLS-1$
pasteCommand.executeWithChecks(new ExecutionEvent());
// check editor state (should be non dirty)
- Assert.assertTrue("Editor should be dirty after paste command execution", isEditorDirty());
+ Assert.assertTrue("Editor should be dirty after paste command execution", isEditorDirty()); //$NON-NLS-1$
// should retrieve a new Part AND a new association
@@ -86,7 +86,7 @@ public abstract class AbstractCopyPasteTest extends AbstractModelExplorerTest {
}
// size = original size +1
- Assert.assertEquals("Wrong number of attributes after paste", expectedNumberOfAddedElements, delta.size());
+ Assert.assertEquals("Wrong number of attributes after paste", expectedNumberOfAddedElements, delta.size()); //$NON-NLS-1$
// part should be linked to an association
postCopyAdditionalChecks(originalModel, newValues, delta);
@@ -95,22 +95,22 @@ public abstract class AbstractCopyPasteTest extends AbstractModelExplorerTest {
if(getEditingDomain().getCommandStack().canUndo()) {
getEditingDomain().getCommandStack().undo();
} else {
- throw new Exception("Impossible to undo the paste command: " + pasteCommand);
+ throw new Exception("Impossible to undo the paste command: " + pasteCommand); //$NON-NLS-1$
}
// check editor state (should be non dirty)
- Assert.assertFalse("Editor should not be dirty after undo", isEditorDirty());
+ Assert.assertFalse("Editor should not be dirty after undo", isEditorDirty()); //$NON-NLS-1$
// check old values equals the actual values
newValues = (List<EObject>)targetContainer.eGet(feature);
- Assert.assertEquals("Initial and current list feature list should be equivalent", newValues, originalValues);
+ Assert.assertEquals("Initial and current list feature list should be equivalent", newValues, originalValues); //$NON-NLS-1$
// redo
if(getEditingDomain().getCommandStack().canRedo()) {
getEditingDomain().getCommandStack().redo();
} else {
- throw new Exception("Impossible to redo the paste command: " + pasteCommand);
+ throw new Exception("Impossible to redo the paste command: " + pasteCommand); //$NON-NLS-1$
}
// check editor state (should be non dirty)
- Assert.assertTrue("Editor should not dirty after redo", isEditorDirty());
+ Assert.assertTrue("Editor should not dirty after redo", isEditorDirty()); //$NON-NLS-1$
// check as it was the result of the paste command
newValues = (List<EObject>)targetContainer.eGet(feature);
@@ -122,7 +122,7 @@ public abstract class AbstractCopyPasteTest extends AbstractModelExplorerTest {
}
// size = original size + delta
- Assert.assertEquals("Wrong number of attributes after paste", expectedNumberOfAddedElements, delta.size());
+ Assert.assertEquals("Wrong number of attributes after paste", expectedNumberOfAddedElements, delta.size()); //$NON-NLS-1$
// part should be linked to an association
postCopyAdditionalChecks(originalModel, newValues, delta);
@@ -131,10 +131,10 @@ public abstract class AbstractCopyPasteTest extends AbstractModelExplorerTest {
if(getEditingDomain().getCommandStack().canUndo()) {
getEditingDomain().getCommandStack().undo();
} else {
- throw new Exception("Impossible to re-undo the paste command: " + pasteCommand);
+ throw new Exception("Impossible to re-undo the paste command: " + pasteCommand); //$NON-NLS-1$
}
// check editor state (should be non dirty)
- Assert.assertFalse("Editor should not be dirty after undo", isEditorDirty());
+ Assert.assertFalse("Editor should not be dirty after undo", isEditorDirty()); //$NON-NLS-1$
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java
index ec838f4f9f9..a3cb4d822bd 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java
@@ -57,13 +57,13 @@ public class CopyPasteSimpleBlock2Test extends AbstractCopyPasteBlockTest {
ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
commandService.refreshElements(IWorkbenchCommandConstants.EDIT_COPY, null);
org.eclipse.core.commands.Command copyCommand = commandService.getCommand(IWorkbenchCommandConstants.EDIT_COPY);
- Assert.assertNotNull("Impossible to find copy command", copyCommand);
- Assert.assertTrue("command in not enabled", copyCommand.isEnabled());
- Assert.assertTrue("command in not defined", copyCommand.isDefined());
+ Assert.assertNotNull("Impossible to find copy command", copyCommand); //$NON-NLS-1$
+ Assert.assertTrue("command in not enabled", copyCommand.isEnabled()); //$NON-NLS-1$
+ Assert.assertTrue("command in not defined", copyCommand.isDefined()); //$NON-NLS-1$
copyCommand.executeWithChecks(new ExecutionEvent());
// check editor state (should be non dirty)
- Assert.assertFalse("Editor should not be dirty after copy", isEditorDirty());
+ Assert.assertFalse("Editor should not be dirty after copy", isEditorDirty()); //$NON-NLS-1$
}
@Override
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java
index e9d9582cd55..36e8f1414bf 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java
@@ -68,13 +68,13 @@ public class CopyPasteSimpleBlockTest extends AbstractCopyPasteBlockTest {
commandService.refreshElements(IWorkbenchCommandConstants.EDIT_COPY, null);
org.eclipse.core.commands.Command copyCommand = commandService.getCommand(IWorkbenchCommandConstants.EDIT_COPY);
- Assert.assertNotNull("Impossible to find copy command", copyCommand);
- Assert.assertTrue("command in not enabled", copyCommand.isEnabled());
- Assert.assertTrue("command in not defined", copyCommand.isDefined());
+ Assert.assertNotNull("Impossible to find copy command", copyCommand); //$NON-NLS-1$
+ Assert.assertTrue("command in not enabled", copyCommand.isEnabled()); //$NON-NLS-1$
+ Assert.assertTrue("command in not defined", copyCommand.isDefined()); //$NON-NLS-1$
copyCommand.executeWithChecks(new ExecutionEvent());
// check editor state (should be non dirty)
- Assert.assertFalse("Editor should not be dirty after copy", isEditorDirty());
+ Assert.assertFalse("Editor should not be dirty after copy", isEditorDirty()); //$NON-NLS-1$
}
@Override
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java
index d3c63e210e1..7a1dbc69a03 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java
@@ -57,13 +57,13 @@ public class CopyPasteSimplePartTest extends AbstractCopyPastePartTest {
ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
commandService.refreshElements(IWorkbenchCommandConstants.EDIT_COPY, null);
org.eclipse.core.commands.Command copyCommand = commandService.getCommand(IWorkbenchCommandConstants.EDIT_COPY);
- Assert.assertNotNull("Impossible to find copy command", copyCommand);
- Assert.assertTrue("command in not enabled", copyCommand.isEnabled());
- Assert.assertTrue("command in not defined", copyCommand.isDefined());
- copyCommand.executeWithChecks(new ExecutionEvent());
+ Assert.assertNotNull("Impossible to find copy command", copyCommand); //$NON-NLS-1$
+ Assert.assertTrue("command in not enabled", copyCommand.isEnabled()); //$NON-NLS-1$
+ Assert.assertTrue("command in not defined", copyCommand.isDefined()); //$NON-NLS-1$
+ copyCommand.executeWithChecks(new ExecutionEvent());
// check editor state (should be non dirty)
- Assert.assertFalse("Editor should not be dirty after copy", isEditorDirty());
+ Assert.assertFalse("Editor should not be dirty after copy", isEditorDirty()); //$NON-NLS-1$
}
@Override
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java
index ebf2450d313..7f2d76c61a3 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java
@@ -51,7 +51,7 @@ public class CopyPasteSimpleReferenceTest extends AbstractCopyPasteReferenceTest
}
});
- Assert.assertFalse("Editor should not be dirty at initialization", isEditorDirty());
+ Assert.assertFalse("Editor should not be dirty at initialization", isEditorDirty()); //$NON-NLS-1$
// retrieve elements in the model explorer
selectAndReveal(rB2_B1_EObject);
@@ -59,16 +59,16 @@ public class CopyPasteSimpleReferenceTest extends AbstractCopyPasteReferenceTest
ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
commandService.refreshElements(IWorkbenchCommandConstants.EDIT_COPY, null);
org.eclipse.core.commands.Command copyCommand = commandService.getCommand(IWorkbenchCommandConstants.EDIT_COPY);
- Assert.assertNotNull("Impossible to find copy command", copyCommand);
- Assert.assertTrue("command in not enabled", copyCommand.isEnabled());
- Assert.assertTrue("command in not defined", copyCommand.isDefined());
+ Assert.assertNotNull("Impossible to find copy command", copyCommand); //$NON-NLS-1$
+ Assert.assertTrue("command in not enabled", copyCommand.isEnabled()); //$NON-NLS-1$
+ Assert.assertTrue("command in not defined", copyCommand.isDefined()); //$NON-NLS-1$
copyCommand.executeWithChecks(new ExecutionEvent());
// check editor state (should be non dirty)
// Assert.assertFalse("Editor should not be dirty after copy", isEditorDirty());
// NOTE: save editor. The copy command should not dirty the model, the implementation of the copy command or the editor should be modified
- Assert.assertFalse("Copy command is dirtying the model, whereas it should not. This assert is here to remember that the test code should be modified: Isdirty = false after copy...", isEditorDirty());
+ Assert.assertFalse("Copy command is dirtying the model, whereas it should not. This assert is here to remember that the test code should be modified: Isdirty = false after copy...", isEditorDirty()); //$NON-NLS-1$
Display.getDefault().syncExec(new Runnable() {
public void run() {
@@ -76,7 +76,7 @@ public class CopyPasteSimpleReferenceTest extends AbstractCopyPasteReferenceTest
}
});
- Assert.assertFalse("Save command is non-dirtying the model, whereas it should. ", isEditorDirty());
+ Assert.assertFalse("Save command is non-dirtying the model, whereas it should. ", isEditorDirty()); //$NON-NLS-1$
// END NOTE
}
@@ -110,7 +110,7 @@ public class CopyPasteSimpleReferenceTest extends AbstractCopyPasteReferenceTest
*/
@Test
public void testCopyPasteInB1() throws Exception {
- testExecutableCopyPaste(b1_EObject, rB2_B1_EObject, "attribute", 1);
+ testExecutableCopyPaste(b1_EObject, rB2_B1_EObject, "attribute", 1);
}
/**
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java
index 82e15f263d6..8bf37088ae6 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java
@@ -1,167 +1,167 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * 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.sysml.modelexplorer.tests.dragdrop;
-
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
-import org.eclipse.papyrus.sysml.modelexplorer.tests.common.AbstractModelExplorerTest;
-import org.eclipse.papyrus.sysml.modelexplorer.tests.utils.EditorUtils;
-import org.eclipse.papyrus.views.modelexplorer.CustomCommonViewer;
-import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
-import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
-import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.navigator.dnd.NavigatorDnDService;
-import org.eclipse.ui.navigator.CommonDropAdapter;
-import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
-import org.junit.Assert;
-import org.junit.Before;
-
-/**
- * Abstract Class to implement diagram drag and drop tests.
- */
-public class AbstractDragDropTest extends AbstractModelExplorerTest {
-
- /**
- * prepare the copy
- *
- * @throws Exception
- * exception thrown in case of problems
- */
- @Before
- public void testPrepare() throws Exception {
- // check editor state (should be non dirty)
- //FIXME: In Papyrus, the editor may be dirty at initialization. This should not be tested here. We simply save the editor as soon as it is opened.
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
- }
- });
-
- Assert.assertFalse("Editor should not be dirty at initialization", isEditorDirty());
- }
-
- public List<CompoundCommand> getListOfDropCommands(EObject sourceElement, EObject targetElement) throws Exception {
- // init source object
- EObjectTreeElement sourceMEI = null;
- if(sourceElement instanceof Diagram) {
- sourceMEI = findSemanticModelElementItem((Diagram)sourceElement);
- } else {
- sourceMEI = findSemanticModelElementItem(sourceElement);
- }
- EObjectTreeElement targetMEI = null;
- if(targetElement instanceof Diagram) {
- targetMEI = findSemanticModelElementItem((Diagram)targetElement);
- } else {
- targetMEI = findSemanticModelElementItem(targetElement);
- }
- if(sourceElement instanceof Diagram) {
- selectAndRevealDiagram((Diagram)sourceElement);
- } else {
- selectAndReveal(sourceElement);
- }
- ModelExplorerView modelExplorerView = null;
- ModelExplorerPageBookView bookViewPart = (ModelExplorerPageBookView)NavigatorUtils.findViewPart(ModelExplorerPageBookView.VIEW_ID);
- if(bookViewPart != null) {
- modelExplorerView = (ModelExplorerView)bookViewPart.getActiveView();
- Assert.assertNotNull("Impossible to find model explorer view", modelExplorerView);
- }
- NavigatorDnDService dndService = (NavigatorDnDService)modelExplorerView.getNavigatorContentService().getDnDService();
- Assert.assertNotNull("Impossible to find dnd service", dndService);
- CommonDropAdapter commonDropAdapter = ((CustomCommonViewer)modelExplorerView.getCommonViewer()).getDropAdapter();
- CommonDropAdapterAssistant[] commonDropAdapterAssistants = dndService.findCommonDropAdapterAssistants(targetMEI, (IStructuredSelection)modelExplorerView.getCommonViewer().getSelection());
- List<CompoundCommand> results = new ArrayList<CompoundCommand>();
- for(CommonDropAdapterAssistant assistant : commonDropAdapterAssistants) {
- // try to adapt to a Papyrus drop assistant. If not, send a warning
- if(!(assistant instanceof org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant)) {
- fail("this test expects that only papyrus drop assistants are provided for papyrus model explorer");
- }
- org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant papyrusAssistant = ((org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant)assistant);
- Field currentOperationField = ViewerDropAdapter.class.getDeclaredField("currentOperation");
- Assert.assertNotNull(currentOperationField);
- currentOperationField.setAccessible(true);
- currentOperationField.set(commonDropAdapter, DND.DROP_MOVE);
- System.err.println(commonDropAdapter.getCurrentOperation()); // should be 2
- Field currentLocationField = ViewerDropAdapter.class.getDeclaredField("currentLocation");
- Assert.assertNotNull(currentLocationField);
- currentLocationField.setAccessible(true);
- currentLocationField.set(commonDropAdapter, ViewerDropAdapter.LOCATION_ON);
- System.err.println(commonDropAdapter.getCurrentLocation()); // should be 3
- LocalSelectionTransfer.getTransfer().setSelection(modelExplorerView.getCommonViewer().getSelection());
- CompoundCommand command = papyrusAssistant.getDrop(targetMEI);
- results.add(command);
- }
- return results;
- }
-
- public void testExecutableDropOfDiagram(Diagram sourceElement, EObject targetElement) throws Exception {
- Assert.assertFalse("Editor should not be dirty at the beginning of the test", EditorUtils.getEditor().isDirty());
- EObject initialDiagramContainer = sourceElement.getElement();
- // find command for the drag / drop (source, target)
- List<CompoundCommand> dropCommands = getListOfDropCommands(sourceElement, targetElement);
- // create only one compound command
- CompoundCommand executableCommand = new CompoundCommand();
- for(CompoundCommand cc : dropCommands) {
- executableCommand.append(cc);
- }
- getEditingDomain().getCommandStack().execute(executableCommand);
- // check results
- Assert.assertEquals("Context of the diagram should be the target: " + printElement(targetElement), targetElement, sourceElement.getElement());
- Assert.assertNotNull("diagram should still be contained in a resource", sourceElement.eResource());
- // try to undo
- getEditingDomain().getCommandStack().undo();
- Assert.assertEquals("Context of the diagram should be the initial value: " + printElement(initialDiagramContainer), initialDiagramContainer, sourceElement.getElement());
- // try to redo
- getEditingDomain().getCommandStack().redo();
- // check results
- Assert.assertEquals("Context of the diagram should be the target: " + printElement(targetElement), targetElement, sourceElement.getElement());
- Assert.assertNotNull("diagram should still be contained in a resource", sourceElement.eResource());
- // undo to go to previous state
- getEditingDomain().getCommandStack().undo();
- Assert.assertEquals("Context of the diagram should be the initial value: " + printElement(initialDiagramContainer), initialDiagramContainer, sourceElement.getElement());
-
- Assert.assertFalse("Editor should not be dirty at the end of the test", EditorUtils.getEditor().isDirty());
- }
-
- public void testUnexecutableDropOfDiagram(Diagram sourceElement, EObject targetElement) throws Exception {
- // find command for the drag / drop (source, target)
- List<CompoundCommand> dropCommands = getListOfDropCommands(sourceElement, targetElement);
- // create only one compound command
- // boolean that indicates that the command can really be not executable
- boolean notexecutable = true;
- for(CompoundCommand cc : dropCommands) {
- if(cc != null && !cc.isEmpty()) {
- if(cc.canExecute()) {
- notexecutable = false;
- }
- }
- }
- Assert.assertTrue("It should be impossible to move " + printElement(sourceElement) + " on " + printElement(targetElement), notexecutable);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * 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.sysml.modelexplorer.tests.dragdrop;
+
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ViewerDropAdapter;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
+import org.eclipse.papyrus.sysml.modelexplorer.tests.common.AbstractModelExplorerTest;
+import org.eclipse.papyrus.sysml.modelexplorer.tests.utils.EditorUtils;
+import org.eclipse.papyrus.views.modelexplorer.CustomCommonViewer;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.navigator.dnd.NavigatorDnDService;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.junit.Assert;
+import org.junit.Before;
+
+/**
+ * Abstract Class to implement diagram drag and drop tests.
+ */
+public class AbstractDragDropTest extends AbstractModelExplorerTest {
+
+ /**
+ * prepare the copy
+ *
+ * @throws Exception
+ * exception thrown in case of problems
+ */
+ @Before
+ public void testPrepare() throws Exception {
+ // check editor state (should be non dirty)
+ //FIXME: In Papyrus, the editor may be dirty at initialization. This should not be tested here. We simply save the editor as soon as it is opened.
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
+
+ Assert.assertFalse("Editor should not be dirty at initialization", isEditorDirty()); //$NON-NLS-1$
+ }
+
+ public List<CompoundCommand> getListOfDropCommands(EObject sourceElement, EObject targetElement) throws Exception {
+ // init source object
+ EObjectTreeElement sourceMEI = null;
+ if(sourceElement instanceof Diagram) {
+ sourceMEI = findSemanticModelElementItem((Diagram)sourceElement);
+ } else {
+ sourceMEI = findSemanticModelElementItem(sourceElement);
+ }
+ EObjectTreeElement targetMEI = null;
+ if(targetElement instanceof Diagram) {
+ targetMEI = findSemanticModelElementItem((Diagram)targetElement);
+ } else {
+ targetMEI = findSemanticModelElementItem(targetElement);
+ }
+ if(sourceElement instanceof Diagram) {
+ selectAndRevealDiagram((Diagram)sourceElement);
+ } else {
+ selectAndReveal(sourceElement);
+ }
+ ModelExplorerView modelExplorerView = null;
+ ModelExplorerPageBookView bookViewPart = (ModelExplorerPageBookView)NavigatorUtils.findViewPart(ModelExplorerPageBookView.VIEW_ID);
+ if(bookViewPart != null) {
+ modelExplorerView = (ModelExplorerView)bookViewPart.getActiveView();
+ Assert.assertNotNull("Impossible to find model explorer view", modelExplorerView); //$NON-NLS-1$
+ }
+ NavigatorDnDService dndService = (NavigatorDnDService)modelExplorerView.getNavigatorContentService().getDnDService();
+ Assert.assertNotNull("Impossible to find dnd service", dndService); //$NON-NLS-1$
+ CommonDropAdapter commonDropAdapter = ((CustomCommonViewer)modelExplorerView.getCommonViewer()).getDropAdapter();
+ CommonDropAdapterAssistant[] commonDropAdapterAssistants = dndService.findCommonDropAdapterAssistants(targetMEI, (IStructuredSelection)modelExplorerView.getCommonViewer().getSelection());
+ List<CompoundCommand> results = new ArrayList<CompoundCommand>();
+ for(CommonDropAdapterAssistant assistant : commonDropAdapterAssistants) {
+ // try to adapt to a Papyrus drop assistant. If not, send a warning
+ if(!(assistant instanceof org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant)) {
+ fail("this test expects that only papyrus drop assistants are provided for papyrus model explorer"); //$NON-NLS-1$
+ }
+ org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant papyrusAssistant = ((org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant)assistant);
+ Field currentOperationField = ViewerDropAdapter.class.getDeclaredField("currentOperation");
+ Assert.assertNotNull(currentOperationField);
+ currentOperationField.setAccessible(true);
+ currentOperationField.set(commonDropAdapter, DND.DROP_MOVE);
+ System.err.println(commonDropAdapter.getCurrentOperation()); // should be 2
+ Field currentLocationField = ViewerDropAdapter.class.getDeclaredField("currentLocation");
+ Assert.assertNotNull(currentLocationField);
+ currentLocationField.setAccessible(true);
+ currentLocationField.set(commonDropAdapter, ViewerDropAdapter.LOCATION_ON);
+ System.err.println(commonDropAdapter.getCurrentLocation()); // should be 3
+ LocalSelectionTransfer.getTransfer().setSelection(modelExplorerView.getCommonViewer().getSelection());
+ CompoundCommand command = papyrusAssistant.getDrop(targetMEI);
+ results.add(command);
+ }
+ return results;
+ }
+
+ public void testExecutableDropOfDiagram(Diagram sourceElement, EObject targetElement) throws Exception {
+ Assert.assertFalse("Editor should not be dirty at the beginning of the test", EditorUtils.getEditor().isDirty()); //$NON-NLS-1$
+ EObject initialDiagramContainer = sourceElement.getElement();
+ // find command for the drag / drop (source, target)
+ List<CompoundCommand> dropCommands = getListOfDropCommands(sourceElement, targetElement);
+ // create only one compound command
+ CompoundCommand executableCommand = new CompoundCommand();
+ for(CompoundCommand cc : dropCommands) {
+ executableCommand.append(cc);
+ }
+ getEditingDomain().getCommandStack().execute(executableCommand);
+ // check results
+ Assert.assertEquals("Context of the diagram should be the target: " + printElement(targetElement), targetElement, sourceElement.getElement()); //$NON-NLS-1$
+ Assert.assertNotNull("diagram should still be contained in a resource", sourceElement.eResource()); //$NON-NLS-1$
+ // try to undo
+ getEditingDomain().getCommandStack().undo();
+ Assert.assertEquals("Context of the diagram should be the initial value: " + printElement(initialDiagramContainer), initialDiagramContainer, sourceElement.getElement()); //$NON-NLS-1$
+ // try to redo
+ getEditingDomain().getCommandStack().redo();
+ // check results
+ Assert.assertEquals("Context of the diagram should be the target: " + printElement(targetElement), targetElement, sourceElement.getElement()); //$NON-NLS-1$
+ Assert.assertNotNull("diagram should still be contained in a resource", sourceElement.eResource()); //$NON-NLS-1$
+ // undo to go to previous state
+ getEditingDomain().getCommandStack().undo();
+ Assert.assertEquals("Context of the diagram should be the initial value: " + printElement(initialDiagramContainer), initialDiagramContainer, sourceElement.getElement()); //$NON-NLS-1$
+
+ Assert.assertFalse("Editor should not be dirty at the end of the test", EditorUtils.getEditor().isDirty()); //$NON-NLS-1$
+ }
+
+ public void testUnexecutableDropOfDiagram(Diagram sourceElement, EObject targetElement) throws Exception {
+ // find command for the drag / drop (source, target)
+ List<CompoundCommand> dropCommands = getListOfDropCommands(sourceElement, targetElement);
+ // create only one compound command
+ // boolean that indicates that the command can really be not executable
+ boolean notexecutable = true;
+ for(CompoundCommand cc : dropCommands) {
+ if(cc != null && !cc.isEmpty()) {
+ if(cc.canExecute()) {
+ notexecutable = false;
+ }
+ }
+ }
+ Assert.assertTrue("It should be impossible to move " + printElement(sourceElement) + " on " + printElement(targetElement), notexecutable); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java
index b6ff508f5c3..c026ac2656d 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java
@@ -1,75 +1,75 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.sysml.modelexplorer.tests.utils;
-
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-
-/**
- * Utility class for tests
- */
-public class EditorUtils {
-
- /**
- * Retrieves current active editor
- *
- * @return current active editor
- * @throws Exception
- * exception thrown in case of issue
- */
- public static IEditorPart getEditor() throws Exception {
- RunnableWithResult<IEditorPart> runnable;
-
- Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IEditorPart>() {
-
- public void run() {
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- setResult(editor);
- }
- });
-
- return runnable.getResult();
- }
-
- public static DiagramEditor getDiagramEditor() throws Exception {
-
- ServicesRegistry serviceRegistry = (ServicesRegistry)getEditor().getAdapter(ServicesRegistry.class);
- try {
- return (DiagramEditor)ServiceUtils.getInstance().getNestedActiveIEditorPart(serviceRegistry);
-
- } catch (ServiceException e) {
- throw new Exception("Unable to retrieve service.", e);
- } catch (ClassCastException e) {
- throw new Exception("Active diagram is not a DiagramEditor." + e.getMessage(), e);
- }
- }
-
- public static DiagramEditPart getDiagramEditPart() throws Exception {
-
- try {
- return getDiagramEditor().getDiagramEditPart();
-
- } catch (NullPointerException e) {
- throw new Exception("Could not find diagram edit part.", e);
- }
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.modelexplorer.tests.utils;
+
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Utility class for tests
+ */
+public class EditorUtils {
+
+ /**
+ * Retrieves current active editor
+ *
+ * @return current active editor
+ * @throws Exception
+ * exception thrown in case of issue
+ */
+ public static IEditorPart getEditor() throws Exception {
+ RunnableWithResult<IEditorPart> runnable;
+
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IEditorPart>() {
+
+ public void run() {
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ setResult(editor);
+ }
+ });
+
+ return runnable.getResult();
+ }
+
+ public static DiagramEditor getDiagramEditor() throws Exception {
+
+ ServicesRegistry serviceRegistry = (ServicesRegistry)getEditor().getAdapter(ServicesRegistry.class);
+ try {
+ return (DiagramEditor)ServiceUtils.getInstance().getNestedActiveIEditorPart(serviceRegistry);
+
+ } catch (ServiceException e) {
+ throw new Exception("Unable to retrieve service.", e); //$NON-NLS-1$
+ } catch (ClassCastException e) {
+ throw new Exception("Active diagram is not a DiagramEditor." + e.getMessage(), e); //$NON-NLS-1$
+ }
+ }
+
+ public static DiagramEditPart getDiagramEditPart() throws Exception {
+
+ try {
+ return getDiagramEditor().getDiagramEditPart();
+
+ } catch (NullPointerException e) {
+ throw new Exception("Could not find diagram edit part.", e); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java
index 09c95ab5eab..477b5a4c3aa 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java
@@ -1,205 +1,205 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.modelexplorer.tests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
-import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Model;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-
-/**
- *
- * @author VL222926
- *
- * This plugin tests the activation of the correct handler for differents selection in the ModelExplorer
- */
-public class DeleteHandlerTest extends AbstractHandlerTest {
-
- /**
- * the id of the delete command
- */
- private static final String DELETE_COMMAND_ID = "org.eclipse.ui.edit.delete";
-
- /**
- *
- * Constructor.
- *
- */
- public DeleteHandlerTest() {
- super(DELETE_COMMAND_ID, Activator.getDefault().getBundle());
- }
-
- /**
- * We test if we can delete the root of the Model or not
- */
- @Ignore("Currently fails on Hudson and freezes the Test Thread (EMF Facet dialog)")
- @Test
- public void deleteRootOfTheModel() {
- final List<EObject> selectedElement = new ArrayList<EObject>();
- selectedElement.add(getRootOfTheModel());
- getModelExplorerView().revealSemanticElement(selectedElement);
-
- RunnableWithResult<IWorkbenchPart> runnable;
-
- Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
-
- public void run() {
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- setResult(activePart);
- }
- });
-
- IWorkbenchPart activePart = runnable.getResult();
-
- assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
-
- final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
- Object obj = currentSelection.getFirstElement();
- if(obj instanceof IAdaptable) {
- obj = ((IAdaptable)obj).getAdapter(EObject.class);
- }
- assertEquals(getRootOfTheModel(), obj);
- final IHandler currentHandler = getActiveHandler();
- if(currentHandler == null) {
- // not a problem in this case
- } else {
- Assert.assertFalse("We can delete the root of the model. It is not the wanted behavior", currentHandler.isEnabled()); //$NON-NLS-1$
- }
- }
-
- /**
- * We test if we can delete other uml elements
- */
- @Ignore("Currently fails on Hudson and freezes the Test Thread (EMF Facet dialog)")
- @Test
- public void deleteUMLElementsTest() throws Exception {
- testIsModelExplorerActivePart();
-
- int size = ((Model)getRootOfTheModel()).getPackagedElements().size();
- EObject elementToDelete;
- while(((Model)getRootOfTheModel()).getPackagedElements().size() != 0) {
- //we need to clean the selection
-
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- getCommonViewer().setSelection(new StructuredSelection());
- }
- });
-
- IStructuredSelection currentSelection = getCurrentSelection();
- elementToDelete = ((Model)getRootOfTheModel()).getPackagedElements().get(0);
- List<EObject> selectedElement = new ArrayList<EObject>();
- selectedElement.add(elementToDelete);
- getModelExplorerView().revealSemanticElement(selectedElement);
- currentSelection = getCurrentSelection();
- assertEquals("Only one element should be selected", 1, currentSelection.size());
- Object obj = currentSelection.getFirstElement();
- if(obj instanceof IAdaptable) {
- obj = ((IAdaptable)obj).getAdapter(EObject.class);
- }
- Assert.assertEquals(elementToDelete, obj);
- IHandler currentHandler = getActiveHandler();
- Assert.assertTrue("We can't delete the following element" + elementToDelete, currentHandler.isEnabled());
-
- currentHandler.execute(new ExecutionEvent());
-
- int newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
- Assert.assertEquals(size - 1, newSize);
- //We test the undo
- Assert.assertTrue(getCommandStack().canUndo());
- getCommandStack().undo();
- newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
- Assert.assertEquals(size, newSize);
-
- //we test the redo
- Assert.assertTrue(getCommandStack().canRedo());
- getCommandStack().redo();
- newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
- Assert.assertEquals(size - 1, newSize);
- size = newSize;
- }
-
- int newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
- Assert.assertEquals(0, newSize);
- undoRedo(10);
- }
-
-
- @Test
- @Ignore("this tests doesn't work because the method revealSemanticElement is not able to reveal imported element")
- public void deleteReadOnlyElementsTest() {
- //TODO this tests doesn't work because the method revealSemanticElement is not able to reveal imported element
- // testIsModelExplorerActivePart();
- //
- // List<PackageImport> packageImports = ((Model)getRootOfTheModel()).getPackageImports();
- // EObject elementToDelete;
- // for(int i = 0; i < packageImports.size(); i++) {
- // //we clean the selection
- // getCommonViewer().setSelection(new StructuredSelection());
- // IStructuredSelection currentSelection = getCurrentSelection();
- // Assert.isTrue(currentSelection.isEmpty());
- //
- // List<EObject> selectedElement = new ArrayList<EObject>();
- // selectedElement.add(packageImports.get(i).getImportedPackage());
- // getModelExplorerView().revealSemanticElement(selectedElement);
- // currentSelection = getCurrentSelection();
- //// IContentProvider contentProvider = getModelExplorerView().getCommonViewer().getContentProvider();
- //// Object[] children = ((ITreeContentProvider)contentProvider).getChildren(currentSelection.getFirstElement());
- //// for(int iter = 0; iter < children.length; iter++) {
- //// Object tcurrent = children[0];
- //// int d = 0;
- //// d++;
- //// }
- //// selectedElement.clear();
- // elementToDelete = packageImports.get(i);
- //// selectedElement.add(elementToDelete);
- //
- // getModelExplorerView().revealSemanticElement(selectedElement);
- //
- //
- // currentSelection = getCurrentSelection();
- // Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected");
- // Object obj = currentSelection.getFirstElement();
- // if(obj instanceof IAdaptable) {
- // obj = ((IAdaptable)obj).getAdapter(EObject.class);
- // }
- // Assert.isTrue(obj == elementToDelete);
- // IHandler currentHandler = getActiveHandler();
- // Assert.isTrue(currentHandler.isEnabled(), "We can't delete the following element" + elementToDelete);
- // }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.modelexplorer.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Model;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author VL222926
+ *
+ * This plugin tests the activation of the correct handler for differents selection in the ModelExplorer
+ */
+public class DeleteHandlerTest extends AbstractHandlerTest {
+
+ /**
+ * the id of the delete command
+ */
+ private static final String DELETE_COMMAND_ID = "org.eclipse.ui.edit.delete";
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public DeleteHandlerTest() {
+ super(DELETE_COMMAND_ID, Activator.getDefault().getBundle());
+ }
+
+ /**
+ * We test if we can delete the root of the Model or not
+ */
+ @Ignore("Currently fails on Hudson and freezes the Test Thread (EMF Facet dialog)")
+ @Test
+ public void deleteRootOfTheModel() {
+ final List<EObject> selectedElement = new ArrayList<EObject>();
+ selectedElement.add(getRootOfTheModel());
+ getModelExplorerView().revealSemanticElement(selectedElement);
+
+ RunnableWithResult<IWorkbenchPart> runnable;
+
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ final IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ IWorkbenchPart activePart = runnable.getResult();
+
+ assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+
+ final IStructuredSelection currentSelection = getCurrentSelection();
+ Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
+ Object obj = currentSelection.getFirstElement();
+ if(obj instanceof IAdaptable) {
+ obj = ((IAdaptable)obj).getAdapter(EObject.class);
+ }
+ assertEquals(getRootOfTheModel(), obj);
+ final IHandler currentHandler = getActiveHandler();
+ if(currentHandler == null) {
+ // not a problem in this case
+ } else {
+ Assert.assertFalse("We can delete the root of the model. It is not the wanted behavior", currentHandler.isEnabled()); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * We test if we can delete other uml elements
+ */
+ @Ignore("Currently fails on Hudson and freezes the Test Thread (EMF Facet dialog)")
+ @Test
+ public void deleteUMLElementsTest() throws Exception {
+ testIsModelExplorerActivePart();
+
+ int size = ((Model)getRootOfTheModel()).getPackagedElements().size();
+ EObject elementToDelete;
+ while(((Model)getRootOfTheModel()).getPackagedElements().size() != 0) {
+ //we need to clean the selection
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ getCommonViewer().setSelection(new StructuredSelection());
+ }
+ });
+
+ IStructuredSelection currentSelection = getCurrentSelection();
+ elementToDelete = ((Model)getRootOfTheModel()).getPackagedElements().get(0);
+ List<EObject> selectedElement = new ArrayList<EObject>();
+ selectedElement.add(elementToDelete);
+ getModelExplorerView().revealSemanticElement(selectedElement);
+ currentSelection = getCurrentSelection();
+ assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
+ Object obj = currentSelection.getFirstElement();
+ if(obj instanceof IAdaptable) {
+ obj = ((IAdaptable)obj).getAdapter(EObject.class);
+ }
+ Assert.assertEquals(elementToDelete, obj);
+ IHandler currentHandler = getActiveHandler();
+ Assert.assertTrue("We can't delete the following element" + elementToDelete, currentHandler.isEnabled()); //$NON-NLS-1$
+
+ currentHandler.execute(new ExecutionEvent());
+
+ int newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
+ Assert.assertEquals(size - 1, newSize);
+ //We test the undo
+ Assert.assertTrue(getCommandStack().canUndo());
+ getCommandStack().undo();
+ newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
+ Assert.assertEquals(size, newSize);
+
+ //we test the redo
+ Assert.assertTrue(getCommandStack().canRedo());
+ getCommandStack().redo();
+ newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
+ Assert.assertEquals(size - 1, newSize);
+ size = newSize;
+ }
+
+ int newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
+ Assert.assertEquals(0, newSize);
+ undoRedo(10);
+ }
+
+
+ @Test
+ @Ignore("this tests doesn't work because the method revealSemanticElement is not able to reveal imported element")
+ public void deleteReadOnlyElementsTest() {
+ //TODO this tests doesn't work because the method revealSemanticElement is not able to reveal imported element
+ // testIsModelExplorerActivePart();
+ //
+ // List<PackageImport> packageImports = ((Model)getRootOfTheModel()).getPackageImports();
+ // EObject elementToDelete;
+ // for(int i = 0; i < packageImports.size(); i++) {
+ // //we clean the selection
+ // getCommonViewer().setSelection(new StructuredSelection());
+ // IStructuredSelection currentSelection = getCurrentSelection();
+ // Assert.isTrue(currentSelection.isEmpty());
+ //
+ // List<EObject> selectedElement = new ArrayList<EObject>();
+ // selectedElement.add(packageImports.get(i).getImportedPackage());
+ // getModelExplorerView().revealSemanticElement(selectedElement);
+ // currentSelection = getCurrentSelection();
+ //// IContentProvider contentProvider = getModelExplorerView().getCommonViewer().getContentProvider();
+ //// Object[] children = ((ITreeContentProvider)contentProvider).getChildren(currentSelection.getFirstElement());
+ //// for(int iter = 0; iter < children.length; iter++) {
+ //// Object tcurrent = children[0];
+ //// int d = 0;
+ //// d++;
+ //// }
+ //// selectedElement.clear();
+ // elementToDelete = packageImports.get(i);
+ //// selectedElement.add(elementToDelete);
+ //
+ // getModelExplorerView().revealSemanticElement(selectedElement);
+ //
+ //
+ // currentSelection = getCurrentSelection();
+ // Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected");
+ // Object obj = currentSelection.getFirstElement();
+ // if(obj instanceof IAdaptable) {
+ // obj = ((IAdaptable)obj).getAdapter(EObject.class);
+ // }
+ // Assert.isTrue(obj == elementToDelete);
+ // IHandler currentHandler = getActiveHandler();
+ // Assert.isTrue(currentHandler.isEnabled(), "We can't delete the following element" + elementToDelete);
+ // }
+ }
+}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
index 94aca47bd96..f2669008604 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
@@ -1,223 +1,223 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.modelexplorer.tests;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RunnableWithResult;
-import org.eclipse.jface.viewers.IStructuredSelection;
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.modelexplorer.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
-import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-import org.junit.Assert;
-import org.junit.Test;
-
-
-public class ModelExplorerViewTests extends AbstractHandlerTest {
-
- /**
- *
- * Constructor.
- * This plugin test the ModelExplorerView
- */
- public ModelExplorerViewTests() {
- super(Activator.getDefault().getBundle());
- }
-
- /**
- * tests the method reveal semantic element on the root element
- */
- @Test
- public void revealSemanticElement_selectRootTest() {
- final List<EObject> selectedElement = new ArrayList<EObject>();
- selectedElement.add(getRootOfTheModel());
- getModelExplorerView().revealSemanticElement(selectedElement);
- RunnableWithResult<IWorkbenchPart> activePartRunnable;
- Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
-
- public void run() {
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IWorkbenchPart activePart = activePage.getActivePart();
- setResult(activePart);
- }
- });
-
- Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
- final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
- Object obj = currentSelection.getFirstElement();
- obj =EMFHelper.getEObject(obj);
-
- Assert.assertEquals("The function revealSemanticElement seems doesn't work on the root of the model", getRootOfTheModel(), obj);
- }
-
-
- /**
- * tests the method reveal semantic element selects the correct element
- */
- @Test
- public void revealSemanticElement_selectChildrenTest() {
- final List<EObject> selectedElement = new ArrayList<EObject>();
- final Package pack = (Package)getRootOfTheModel();
- final List<NamedElement> members = pack.getOwnedMembers();
- final int size = members.size();
- Assert.assertTrue(size != 0);//to be sure that the tested model is correct
- for(NamedElement current : members) {
- selectedElement.clear();
- selectedElement.add(current);
-
- RunnableWithResult<IWorkbenchPart> runnable;
- Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
-
- public void run() {
- getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
-
- setResult(activePart);
- }
- });
-
- IWorkbenchPart activePart = runnable.getResult();
-
- Assert.assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
- final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.assertTrue("Only one element should be selected", currentSelection.size() == 1); //$NON-NLS-1$
- Object obj = currentSelection.getFirstElement();
- obj =org.eclipse.papyrus.infra.emf.utils.EMFHelper.getEObject(obj);
- Assert.assertTrue("The function revealSemanticElement seems doesn't work with children", obj == current);
- }
- }
-
- /**
- * tests the method reveal semantic element on the root element
- */
- @Test
- public void revealSemanticElement_selectChildrenTestList() {
- final List<EObject> selectedElement = new ArrayList<EObject>();
- final Package pack = (Package)getRootOfTheModel();
- final List<NamedElement> members = pack.getOwnedMembers();
- final int size = members.size();
- Assert.assertTrue(size != 0);//to be sure that the tested model is correct
- selectedElement.addAll(members);
-
- RunnableWithResult<IWorkbenchPart> runnable;
- Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
-
- public void run() {
- getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
-
- setResult(activePart);
- }
- });
-
- IWorkbenchPart activePart = runnable.getResult();
-
-
- Assert.assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
- final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.assertTrue("Multi selction doesn't work with the method revealSemanticElement", currentSelection.size() == size); //$NON-NLS-1$
- }
-
- /**
- * tests the method reveal semantic element on the root element
- */
- @Test
- public void revealSemanticElement_selectImportedPackage() {
- final List<EObject> selectedElement = new ArrayList<EObject>();
- final Package pack = (Package)getRootOfTheModel();
- final EList<Package> importedPackage = pack.getImportedPackages();
- final int size = importedPackage.size();
- Assert.assertTrue(size != 0);//to be sure that the tested model is correct
- for(NamedElement current : importedPackage) {
-
- waitForPendingMessages();
-
- selectedElement.clear();
- selectedElement.add(current);
- getModelExplorerView().revealSemanticElement(selectedElement);
- RunnableWithResult<IWorkbenchPart> activePartRunnable;
- Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
-
- public void run() {
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IWorkbenchPart activePart = activePage.getActivePart();
- setResult(activePart);
- }
- });
-
- Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
- final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.assertEquals("I don't get the correct selection", 1, currentSelection.size()); //$NON-NLS-1$
- Object obj = currentSelection.getFirstElement();
- obj =EMFHelper.getEObject(obj);
- Assert.assertEquals("The function revealSemanticElement seems doesn't work with importedPackage", current, obj);
- }
- }
-
- private void waitForPendingMessages() {
- //Run all pending tasks to refresh the ModelExplorer
- if(Display.getCurrent() != null) {
- while(true) {
- try {
- if(!Display.getCurrent().readAndDispatch()) {
- break;
- }
- } catch (Throwable t) {
- Activator.log.error(t);
- }
- }
- }
- }
-
- @Test
- public void revealSemanticElement_selectImportedPackageList() {
- final List<EObject> selectedElement = new ArrayList<EObject>();
- final Package pack = (Package)getRootOfTheModel();
- final EList<Package> importedPackage = pack.getImportedPackages();
- final int size = importedPackage.size();
- Assert.assertNotSame(0, size);//to be sure that the tested model is correct
-
- //Run all pending tasks to refresh the ModelExplorer
- waitForPendingMessages();
-
- selectedElement.addAll(importedPackage);
- getModelExplorerView().revealSemanticElement(selectedElement);
- RunnableWithResult<IWorkbenchPart> activePartRunnable;
- Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
-
- public void run() {
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IWorkbenchPart activePart = activePage.getActivePart();
- setResult(activePart);
- }
- });
-
- Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
- final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.assertEquals("I don't get the current selection for revealSemanticElement_importedPackageList", 1, currentSelection.size()); //$NON-NLS-1$
- }
-}
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class ModelExplorerViewTests extends AbstractHandlerTest {
+
+ /**
+ *
+ * Constructor.
+ * This plugin test the ModelExplorerView
+ */
+ public ModelExplorerViewTests() {
+ super(Activator.getDefault().getBundle());
+ }
+
+ /**
+ * tests the method reveal semantic element on the root element
+ */
+ @Test
+ public void revealSemanticElement_selectRootTest() {
+ final List<EObject> selectedElement = new ArrayList<EObject>();
+ selectedElement.add(getRootOfTheModel());
+ getModelExplorerView().revealSemanticElement(selectedElement);
+ RunnableWithResult<IWorkbenchPart> activePartRunnable;
+ Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+ final IStructuredSelection currentSelection = getCurrentSelection();
+ Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
+ Object obj = currentSelection.getFirstElement();
+ obj =EMFHelper.getEObject(obj);
+
+ Assert.assertEquals("The function revealSemanticElement seems doesn't work on the root of the model", getRootOfTheModel(), obj);
+ }
+
+
+ /**
+ * tests the method reveal semantic element selects the correct element
+ */
+ @Test
+ public void revealSemanticElement_selectChildrenTest() {
+ final List<EObject> selectedElement = new ArrayList<EObject>();
+ final Package pack = (Package)getRootOfTheModel();
+ final List<NamedElement> members = pack.getOwnedMembers();
+ final int size = members.size();
+ Assert.assertTrue(size != 0);//to be sure that the tested model is correct
+ for(NamedElement current : members) {
+ selectedElement.clear();
+ selectedElement.add(current);
+
+ RunnableWithResult<IWorkbenchPart> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ getModelExplorerView().revealSemanticElement(selectedElement);
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ final IWorkbenchPart activePart = activePage.getActivePart();
+
+ setResult(activePart);
+ }
+ });
+
+ IWorkbenchPart activePart = runnable.getResult();
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+ final IStructuredSelection currentSelection = getCurrentSelection();
+ Assert.assertTrue("Only one element should be selected", currentSelection.size() == 1); //$NON-NLS-1$
+ Object obj = currentSelection.getFirstElement();
+ obj =org.eclipse.papyrus.infra.emf.utils.EMFHelper.getEObject(obj);
+ Assert.assertTrue("The function revealSemanticElement seems doesn't work with children", obj == current); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * tests the method reveal semantic element on the root element
+ */
+ @Test
+ public void revealSemanticElement_selectChildrenTestList() {
+ final List<EObject> selectedElement = new ArrayList<EObject>();
+ final Package pack = (Package)getRootOfTheModel();
+ final List<NamedElement> members = pack.getOwnedMembers();
+ final int size = members.size();
+ Assert.assertTrue(size != 0);//to be sure that the tested model is correct
+ selectedElement.addAll(members);
+
+ RunnableWithResult<IWorkbenchPart> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ getModelExplorerView().revealSemanticElement(selectedElement);
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ final IWorkbenchPart activePart = activePage.getActivePart();
+
+ setResult(activePart);
+ }
+ });
+
+ IWorkbenchPart activePart = runnable.getResult();
+
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+ final IStructuredSelection currentSelection = getCurrentSelection();
+ Assert.assertTrue("Multi selction doesn't work with the method revealSemanticElement", currentSelection.size() == size); //$NON-NLS-1$
+ }
+
+ /**
+ * tests the method reveal semantic element on the root element
+ */
+ @Test
+ public void revealSemanticElement_selectImportedPackage() {
+ final List<EObject> selectedElement = new ArrayList<EObject>();
+ final Package pack = (Package)getRootOfTheModel();
+ final EList<Package> importedPackage = pack.getImportedPackages();
+ final int size = importedPackage.size();
+ Assert.assertTrue(size != 0);//to be sure that the tested model is correct
+ for(NamedElement current : importedPackage) {
+
+ waitForPendingMessages();
+
+ selectedElement.clear();
+ selectedElement.add(current);
+ getModelExplorerView().revealSemanticElement(selectedElement);
+ RunnableWithResult<IWorkbenchPart> activePartRunnable;
+ Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+ final IStructuredSelection currentSelection = getCurrentSelection();
+ Assert.assertEquals("I don't get the correct selection", 1, currentSelection.size()); //$NON-NLS-1$
+ Object obj = currentSelection.getFirstElement();
+ obj =EMFHelper.getEObject(obj);
+ Assert.assertEquals("The function revealSemanticElement seems doesn't work with importedPackage", current, obj); //$NON-NLS-1$
+ }
+ }
+
+ private void waitForPendingMessages() {
+ //Run all pending tasks to refresh the ModelExplorer
+ if(Display.getCurrent() != null) {
+ while(true) {
+ try {
+ if(!Display.getCurrent().readAndDispatch()) {
+ break;
+ }
+ } catch (Throwable t) {
+ Activator.log.error(t);
+ }
+ }
+ }
+ }
+
+ @Test
+ public void revealSemanticElement_selectImportedPackageList() {
+ final List<EObject> selectedElement = new ArrayList<EObject>();
+ final Package pack = (Package)getRootOfTheModel();
+ final EList<Package> importedPackage = pack.getImportedPackages();
+ final int size = importedPackage.size();
+ Assert.assertNotSame(0, size);//to be sure that the tested model is correct
+
+ //Run all pending tasks to refresh the ModelExplorer
+ waitForPendingMessages();
+
+ selectedElement.addAll(importedPackage);
+ getModelExplorerView().revealSemanticElement(selectedElement);
+ RunnableWithResult<IWorkbenchPart> activePartRunnable;
+ Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+ final IStructuredSelection currentSelection = getCurrentSelection();
+ Assert.assertEquals("I don't get the current selection for revealSemanticElement_importedPackageList", 1, currentSelection.size()); //$NON-NLS-1$
+ }
+}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java
index bec108c7d6a..478fecf6145 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java
@@ -1,62 +1,62 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.modelexplorer.tests;
-
-import java.util.List;
-
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Model;
-import org.junit.Assert;
-import org.junit.Test;
-
-
-
-public class RenameHandlerTest extends AbstractHandlerTest {
-
- /**
- * the id of the command to rename the element
- */
- private static final String commandId = "org.eclipse.ui.edit.rename";
-
- /**
- *
- * Constructor.
- *
- */
- public RenameHandlerTest() {
- super(commandId, Activator.getDefault().getBundle());
- }
-
- @Test
- public void renameUMLUnnamedElementTest() {
- List<Comment> comments = ((Model)getRootOfTheModel()).getOwnedComments();
- Assert.assertFalse(comments.isEmpty());
- for(int i = 0; i < ((Model)getRootOfTheModel()).getOwnedComments().size(); i++) {
- selectElementInTheModelexplorer(((Model)getRootOfTheModel()).getOwnedComments().get(i));
- IHandler handler = getActiveHandler();
- if(handler != null) {
- Assert.assertFalse("Rename handler is not disabled on UnnamedElement", handler.isEnabled());
- }
- }
- }
-
- @Test
- public void renameUMLNamedElementTest() {
- selectElementInTheModelexplorer(getRootOfTheModel());
- IHandler handler = getActiveHandler();
- Assert.assertTrue(handler.isEnabled());
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.modelexplorer.tests;
+
+import java.util.List;
+
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Model;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class RenameHandlerTest extends AbstractHandlerTest {
+
+ /**
+ * the id of the command to rename the element
+ */
+ private static final String commandId = "org.eclipse.ui.edit.rename";
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public RenameHandlerTest() {
+ super(commandId, Activator.getDefault().getBundle());
+ }
+
+ @Test
+ public void renameUMLUnnamedElementTest() {
+ List<Comment> comments = ((Model)getRootOfTheModel()).getOwnedComments();
+ Assert.assertFalse(comments.isEmpty());
+ for(int i = 0; i < ((Model)getRootOfTheModel()).getOwnedComments().size(); i++) {
+ selectElementInTheModelexplorer(((Model)getRootOfTheModel()).getOwnedComments().get(i));
+ IHandler handler = getActiveHandler();
+ if(handler != null) {
+ Assert.assertFalse("Rename handler is not disabled on UnnamedElement", handler.isEnabled()); //$NON-NLS-1$
+ }
+ }
+ }
+
+ @Test
+ public void renameUMLNamedElementTest() {
+ selectElementInTheModelexplorer(getRootOfTheModel());
+ IHandler handler = getActiveHandler();
+ Assert.assertTrue(handler.isEnabled());
+ }
+}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteHandlerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteHandlerTest.java
index 7d751062389..582063d820a 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteHandlerTest.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/paste/CopyPasteHandlerTest.java
@@ -51,7 +51,7 @@ public class CopyPasteHandlerTest extends AbstractDualHandlerTest {
try {
EObject rootOfTheModel = getRootOfTheModel();
// check that there is Class1
- Assert.assertEquals("Class1 is missing", getCountElementByName(CLASS1), 1);
+ Assert.assertEquals("Class1 is missing", getCountElementByName(CLASS1), 1); //$NON-NLS-1$
EObject class1 = getNameElementByName(CLASS1); // get Class1
// select class1
@@ -71,7 +71,7 @@ public class CopyPasteHandlerTest extends AbstractDualHandlerTest {
pasteHandler.execute(new ExecutionEvent());
// check that there is 2 Class1
- Assert.assertEquals("Class1 copy is missing", getCountElementByName(CLASS1), 2);
+ Assert.assertEquals("Class1 copy is missing", getCountElementByName(CLASS1), 2); //$NON-NLS-1$
} catch (ExecutionException e) {
Assert.fail(e.toString());
@@ -88,8 +88,8 @@ public class CopyPasteHandlerTest extends AbstractDualHandlerTest {
try {
EObject rootOfTheModel = getRootOfTheModel();
// check that there is Class1 and Class2
- Assert.assertEquals("Class1 is missing", getCountElementByName(CLASS1), 1);
- Assert.assertEquals("Class2 is missing", getCountElementByName(CLASS2), 1);
+ Assert.assertEquals("Class1 is missing", getCountElementByName(CLASS1), 1); //$NON-NLS-1$
+ Assert.assertEquals("Class2 is missing", getCountElementByName(CLASS2), 1); //$NON-NLS-1$
EObject class1 = getNameElementByName(CLASS1); // get Class1
EObject class2 = getNameElementByName(CLASS2); // get Class2
@@ -113,8 +113,8 @@ public class CopyPasteHandlerTest extends AbstractDualHandlerTest {
Assert.assertTrue(pasteHandler.isEnabled());
pasteHandler.execute(new ExecutionEvent());
// check that there is 2 Class1 and 2 Class2
- Assert.assertEquals("Class1 copy is missing", getCountElementByName(CLASS1), 2);
- Assert.assertEquals("Class2 copy is missing", getCountElementByName(CLASS2), 2);
+ Assert.assertEquals("Class1 copy is missing", getCountElementByName(CLASS1), 2); //$NON-NLS-1$
+ Assert.assertEquals("Class2 copy is missing", getCountElementByName(CLASS2), 2); //$NON-NLS-1$
} catch (ExecutionException e) {
Assert.fail(e.toString());
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
index de229a128f4..c29eaf3b2ba 100644
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
+++ b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
@@ -122,7 +122,7 @@ public abstract class AbstractHandlerTest {
* the id of the command to test
*/
public AbstractHandlerTest(String commandId, Bundle bundle) {
- Assert.assertNotNull("Bundle can't be null to do the test.", bundle);
+ Assert.assertNotNull("Bundle can't be null to do the test.", bundle); //$NON-NLS-1$
this.commandId = commandId;
this.bundle = bundle;
}
@@ -306,7 +306,7 @@ public abstract class AbstractHandlerTest {
SimpleUML=custo;
}
}
- org.junit.Assert.assertNotNull("Custom SimpleUML not found", SimpleUML);
+ Assert.assertNotNull("Custom SimpleUML not found", SimpleUML); //$NON-NLS-1$
org.eclipse.papyrus.views.modelexplorer.Activator.getDefault().getCustomizationManager().getManagedCustomizations().add(0, SimpleUML);
setStatus(Status.OK_STATUS);
}
@@ -352,9 +352,9 @@ public abstract class AbstractHandlerTest {
}
public void undoRedoTest() {
- Assert.assertTrue("I can't undo the command!", getCommandStack().canUndo());
+ Assert.assertTrue("I can't undo the command!", getCommandStack().canUndo()); //$NON-NLS-1$
getCommandStack().undo();
- Assert.assertTrue("I can't Redo the command!", getCommandStack().canRedo());
+ Assert.assertTrue("I can't Redo the command!", getCommandStack().canRedo()); //$NON-NLS-1$
getCommandStack().redo();
}
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/OpendiagramTest.java b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/OpendiagramTest.java
index bc0c520100b..70b5b326239 100644
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/OpendiagramTest.java
+++ b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/OpendiagramTest.java
@@ -1,119 +1,119 @@
-
-/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- *
- * 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:
- * Patrick Tessier (CEA LIST) Patrick.Tessier.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.views.modelexplorer.tests;
-
-import java.util.ArrayList;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
-import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest;
-import org.eclipse.papyrus.views.modelexplorer.DecoratingLabelProviderWTooltips;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Model;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class OpendiagramTest extends AbstractEditorTest {
- /**
- * here the purpose is to test the creation of constraint on variable elements.
- */
- @Test
- public void testOpendiagramTest() throws Exception {
-
- //get the rootModel
- Assert.assertNotNull("RootModel is null", getRootUMLModel());
- //get all semantic elment that will handled
- Model model=(Model) getRootUMLModel();
- org.eclipse.uml2.uml.Class class1=(org.eclipse.uml2.uml.Class) model.getPackagedElement("Class1");
- org.eclipse.uml2.uml.Class class2=(org.eclipse.uml2.uml.Class) model.getPackagedElement("Class2");
- Diagram diagram1=(Diagram)getPageManager().allPages().get(0);
- Diagram diagram2=(Diagram)getPageManager().allPages().get(1);
-
- IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- ISelectionService selectionService = activeWorkbenchWindow.getSelectionService();
- modelExplorerView=getModelExplorerView();
- modelExplorerView.setFocus();
- ArrayList<Object>elements= new ArrayList<Object>();
- elements.add(getRootUMLModel());
- modelExplorerView.revealSemanticElement( elements);
-
-
- //getItem for model
- EObject modelTreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
- Assert.assertNotNull("Model TreeElement is null", modelTreeObject);
-
- //get Item for class1
- elements.clear();
- elements.add(class1);
- modelExplorerView.revealSemanticElement( elements);
- EObject class1TreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
- Assert.assertNotNull("Class1 TreeElement is null", class1TreeObject);
-
- //get Item for class2
- elements.clear();
- elements.add(class2);
- modelExplorerView.revealSemanticElement( elements);
- EObject class2TreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
- Assert.assertNotNull("Class2 TreeElement is null", class2TreeObject);
-
- //get Item for diagram1
- elements.clear();
- elements.add(diagram1);
- modelExplorerView.revealSemanticElement( elements);
- EObject diagram1TreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
- Assert.assertNotNull("digram1 TreeElement is null", diagram1TreeObject);
- //get Item for diagram2
- elements.clear();
- elements.add(diagram2);
- modelExplorerView.revealSemanticElement( elements);
- EObject diagram2TreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
- Assert.assertNotNull("digram2 TreeElement is null", diagram2TreeObject);
-
- //test icons of closed diagram
- DecoratingLabelProviderWTooltips labeProvider=(DecoratingLabelProviderWTooltips)modelExplorerView.getCommonViewer().getLabelProvider();
- Assert.assertNotEquals("the label of diagram1 is not good", "Diagram1", labeProvider.getText(diagram1));
- Assert.assertNotEquals("the label of class1 is not good","class1",labeProvider.getText(class1));
-
- //now test image about diagram for open and closed diagram
- //select all Tree element in the common viewer.
- }
- @Before
- public void initOpendiagramTest(){
- try {
- initModel("openDiagramTest", "OpenDiagram", Activator.getDefault().getBundle());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Override
- protected String getSourcePath() {
- // TODO Auto-generated method stub
- return "resources/";
- }
-
-}
+
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.Tessier.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.views.modelexplorer.tests;
+
+import java.util.ArrayList;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest;
+import org.eclipse.papyrus.views.modelexplorer.DecoratingLabelProviderWTooltips;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Model;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class OpendiagramTest extends AbstractEditorTest {
+ /**
+ * here the purpose is to test the creation of constraint on variable elements.
+ */
+ @Test
+ public void testOpendiagramTest() throws Exception {
+
+ //get the rootModel
+ Assert.assertNotNull("RootModel is null", getRootUMLModel()); //$NON-NLS-1$
+ //get all semantic elment that will handled
+ Model model=(Model) getRootUMLModel();
+ org.eclipse.uml2.uml.Class class1=(org.eclipse.uml2.uml.Class) model.getPackagedElement("Class1");
+ org.eclipse.uml2.uml.Class class2=(org.eclipse.uml2.uml.Class) model.getPackagedElement("Class2");
+ Diagram diagram1=(Diagram)getPageManager().allPages().get(0);
+ Diagram diagram2=(Diagram)getPageManager().allPages().get(1);
+
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ ISelectionService selectionService = activeWorkbenchWindow.getSelectionService();
+ modelExplorerView=getModelExplorerView();
+ modelExplorerView.setFocus();
+ ArrayList<Object>elements= new ArrayList<Object>();
+ elements.add(getRootUMLModel());
+ modelExplorerView.revealSemanticElement( elements);
+
+
+ //getItem for model
+ EObject modelTreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
+ Assert.assertNotNull("Model TreeElement is null", modelTreeObject); //$NON-NLS-1$
+
+ //get Item for class1
+ elements.clear();
+ elements.add(class1);
+ modelExplorerView.revealSemanticElement( elements);
+ EObject class1TreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
+ Assert.assertNotNull("Class1 TreeElement is null", class1TreeObject); //$NON-NLS-1$
+
+ //get Item for class2
+ elements.clear();
+ elements.add(class2);
+ modelExplorerView.revealSemanticElement( elements);
+ EObject class2TreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
+ Assert.assertNotNull("Class2 TreeElement is null", class2TreeObject); //$NON-NLS-1$
+
+ //get Item for diagram1
+ elements.clear();
+ elements.add(diagram1);
+ modelExplorerView.revealSemanticElement( elements);
+ EObject diagram1TreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
+ Assert.assertNotNull("digram1 TreeElement is null", diagram1TreeObject); //$NON-NLS-1$
+ //get Item for diagram2
+ elements.clear();
+ elements.add(diagram2);
+ modelExplorerView.revealSemanticElement( elements);
+ EObject diagram2TreeObject=(EObject)((IStructuredSelection)selectionService.getSelection()).getFirstElement();
+ Assert.assertNotNull("digram2 TreeElement is null", diagram2TreeObject); //$NON-NLS-1$
+
+ //test icons of closed diagram
+ DecoratingLabelProviderWTooltips labeProvider=(DecoratingLabelProviderWTooltips)modelExplorerView.getCommonViewer().getLabelProvider();
+ Assert.assertNotEquals("the label of diagram1 is not good", "Diagram1", labeProvider.getText(diagram1)); //$NON-NLS-1$ //$NON-NLS-2$
+ Assert.assertNotEquals("the label of class1 is not good","class1",labeProvider.getText(class1)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ //now test image about diagram for open and closed diagram
+ //select all Tree element in the common viewer.
+ }
+ @Before
+ public void initOpendiagramTest(){
+ try {
+ initModel("openDiagramTest", "OpenDiagram", Activator.getDefault().getBundle());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected String getSourcePath() {
+ // TODO Auto-generated method stub
+ return "resources/";
+ }
+
+}

Back to the top