diff options
| author | Belqassim Djafer | 2015-04-30 08:17:47 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2015-05-04 10:04:12 +0000 |
| commit | 289b9dbddd7d93165205b9688c8d77115821674b (patch) | |
| tree | b5c06b740b14a27ca215077edeab4566401bb5d5 | |
| parent | 9b1150aee5c2a80392c706d74cba580a63cb0308 (diff) | |
| download | org.eclipse.sirius-289b9dbddd7d93165205b9688c8d77115821674b.tar.gz org.eclipse.sirius-289b9dbddd7d93165205b9688c8d77115821674b.tar.xz org.eclipse.sirius-289b9dbddd7d93165205b9688c8d77115821674b.zip | |
[462927] Fix ContainerChildrenPresentationTest
Bug: 462927
Change-Id: I11741721ce7e5d2da5d58df02d5da94cc0b1b48b
Signed-off-by: Belqassim Djafer <belqassim.djafer@obeo.fr>
| -rw-r--r-- | plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/ContainerChildrenPresentationChangeTest.java | 94 |
1 files changed, 32 insertions, 62 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/ContainerChildrenPresentationChangeTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/ContainerChildrenPresentationChangeTest.java index f6f468c57b..c72cd155b8 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/ContainerChildrenPresentationChangeTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/ContainerChildrenPresentationChangeTest.java @@ -10,22 +10,20 @@ *******************************************************************************/ package org.eclipse.sirius.tests.swtbot; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys; import org.eclipse.sirius.diagram.ContainerLayout; import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.diagram.DDiagramElement; import org.eclipse.sirius.diagram.business.api.query.DiagramElementMappingQuery; import org.eclipse.sirius.diagram.description.ContainerMapping; +import org.eclipse.sirius.diagram.description.DiagramElementMapping; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeContainerEditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeListEditPart; import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase; import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource; import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; -import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusHelper; -import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; -import org.eclipse.swtbot.swt.finder.SWTBot; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio; /** * In a diagram representation, ensure that when we change container children @@ -55,14 +53,6 @@ public class ContainerChildrenPresentationChangeTest extends AbstractSiriusSwtBo private static final String CONTAINER_NAME = "c"; - private static final String DEFAULT = "Default"; - - private static final String CONTAINER = "462927"; - - private static final String PROPERTIES = "Properties"; - - private static final String GENERAL = "General"; - private DDiagram dDiagram; /** @@ -129,26 +119,25 @@ public class ContainerChildrenPresentationChangeTest extends AbstractSiriusSwtBo * Test container children presentation change with opened/closed diagram. */ private void testContainerChildrenPresentation(boolean openedDiagram, boolean isSynchronized) { + // get the container mapping + ContainerMapping containerMapping = getContainerMapping(dDiagram); + // Change children presentation change from list to freeform - changeChildrenPresentation(ContainerLayout.FREE_FORM); + changeChildrenPresentation(containerMapping, ContainerLayout.FREE_FORM); String representationName; if (isSynchronized) { representationName = SYNCHRONIZED_REPRESENTATION_INSTANCE_NAME; } else { representationName = UNSYNCHRONIZED_REPRESENTATION_INSTANCE_NAME; } - if (openedDiagram) { - bot.editorByTitle(representationName).show(); - } else { + if (!openedDiagram) { openDiagramRepresentation(representationName); } checkContainerPresentationInDiagram(ContainerLayout.FREE_FORM); // Change children presentation change from freeform to list - changeChildrenPresentation(ContainerLayout.LIST); - if (openedDiagram) { - bot.editorByTitle(representationName).show(); - } else { + changeChildrenPresentation(containerMapping, ContainerLayout.LIST); + if (!openedDiagram) { openDiagramRepresentation(representationName); } checkContainerPresentationInDiagram(ContainerLayout.LIST); @@ -179,41 +168,16 @@ public class ContainerChildrenPresentationChangeTest extends AbstractSiriusSwtBo } /** - * Change container children presentation from FreeForm to List or from List - * to FreeForm. - */ - private void changeChildrenPresentation(ContainerLayout childrenPresentation) { - openVSM(); - SWTBotEditor vsmEditor = selectContainerNodeMapping(); - modifyVSM(childrenPresentation); - // save the VSM - vsmEditor.setFocus(); - vsmEditor.save(); - } - - /** - * Select the container node mapping. - * - * @return the VSM editor + * Change container children presentation mapping. */ - private SWTBotEditor selectContainerNodeMapping() { - SWTBotEditor activeEditor = bot.activeEditor(); - activeEditor.setFocus(); - activeEditor.bot().tree().expandNode("platform:/resource/" + getProjectName() + "/" + VSM_FILE).expandNode(REPRESENTATION_NAME).expandNode(REPRESENTATION_NAME).expandNode(REPRESENTATION_NAME) - .expandNode(DEFAULT).select(CONTAINER); - return activeEditor; - } - - /** - * Modify children presentation in the VSM. - */ - private void modifyVSM(ContainerLayout childrenPresentation) { - SWTBotView propertiesBot = bot.viewByTitle(PROPERTIES); - propertiesBot.setFocus(); - SWTBotSiriusHelper.selectPropertyTabItem(GENERAL); - SWTBotUtils.waitAllUiEvents(); - SWTBotRadio radioBox = propertiesBot.bot().radio(childrenPresentation.getName()); - radioBox.click().setFocus(); + private void changeChildrenPresentation(final ContainerMapping containerMapping, final ContainerLayout containerLayout) { + TransactionalEditingDomain domain = localSession.getOpenedSession().getTransactionalEditingDomain(); + domain.getCommandStack().execute(new RecordingCommand(domain) { + @Override + protected void doExecute() { + containerMapping.setChildrenPresentation(containerLayout); + } + }); } /** @@ -229,13 +193,19 @@ public class ContainerChildrenPresentationChangeTest extends AbstractSiriusSwtBo } /** - * Open the VSM. + * Get the container mapping. + * + * @param representation + * the given diagram representation + * @return a container mapping */ - private void openVSM() { - SWTBotView projectExplorer = bot.viewByTitle("Model Explorer"); - projectExplorer.setFocus(); - SWTBot projectExplorerBot = projectExplorer.bot(); - projectExplorerBot.tree().expandNode(getProjectName()).expandNode(VSM_FILE).doubleClick(); + private ContainerMapping getContainerMapping(DDiagram representation) { + DDiagramElement dDiagramElement = representation.getContainers().get(0); + DiagramElementMapping diagramElementMapping = dDiagramElement.getDiagramElementMapping(); + + assertTrue("The '" + diagramElementMapping.getLabel() + "' mapping should be a ContainerMapping", diagramElementMapping instanceof ContainerMapping); + ContainerMapping containerMapping = (ContainerMapping) diagramElementMapping; + return containerMapping; } /** |
