diff options
| author | pguilet | 2016-10-11 14:09:21 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2016-10-24 12:05:08 +0000 |
| commit | 461554e278040d7acafed986b8712c859868ef7e (patch) | |
| tree | 2c8d72049275356ed28a3e83f83ef40e82e97a53 | |
| parent | 6244b543d75102602fef55b36c3dc301caf04528 (diff) | |
| download | org.eclipse.sirius-461554e278040d7acafed986b8712c859868ef7e.tar.gz org.eclipse.sirius-461554e278040d7acafed986b8712c859868ef7e.tar.xz org.eclipse.sirius-461554e278040d7acafed986b8712c859868ef7e.zip | |
[501883] Add tests corresponding to the fix
- Adds tests verifying the "Authorized side" checkbox properties are
present with bordered node with conditional and no conditional styles.
- Adds tests verifying the "Authorized side" checkbox properties are not
present with node and container with WorkspaceImage style as default
style or conditional style.
- Adds tests verifying the "Authorized side" checkbox properties are
taken in consideration when bordered node are mapped to node with
conditional styles.
Bug: 501883
Change-Id: Ic78d341717e9c8728466fce46deda6c3e00bc161
Signed-off-by: pguilet <pierre.guilet@obeo.fr>
4 files changed, 477 insertions, 11 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/borderNodeSide/borderNodeSide.odesign b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/borderNodeSide/borderNodeSide.odesign index b0a97becbc..2f8082497d 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/borderNodeSide/borderNodeSide.odesign +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/borderNodeSide/borderNodeSide.odesign @@ -1,8 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> -<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="My" version="11.0.0.201601261200"> +<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="borderNodeSide" version="11.0.0.201609021200"> <ownedViewpoints name="borderNodeSide"> <ownedRepresentations xsi:type="description_1:DiagramDescription" name="borderNodeSide" initialisation="true" domainClass="EPackage" enablePopupBars="true"> <defaultLayer name="Default"> + <nodeMappings name="ePackageNode" semanticCandidatesExpression="feature:eSubpackages" domainClass="EPackage"> + <style xsi:type="style:BundledImageDescription" labelPosition="node" resizeKind="NSEW"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + </style> + <conditionnalStyles predicateExpression="false"> + <style xsi:type="style:WorkspaceImageDescription" sizeComputationExpression="-1" labelPosition="node" resizeKind="NSEW" workspacePath="/org.eclipse.sirius.tests.swtbot/images/es.png"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + </style> + </conditionnalStyles> + </nodeMappings> <containerMappings name="container" semanticCandidatesExpression="feature:eSubpackages" domainClass="EPackage"> <borderedNodeMappings name="eClassWest" preconditionExpression="aql:self.name.contains('West')" semanticCandidatesExpression="feature:eClassifiers" domainClass="EClass"> <style xsi:type="style:SquareDescription" resizeKind="NSEW"> @@ -13,6 +26,16 @@ <forbiddenSides>NORTH</forbiddenSides> <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='orange']"/> </style> + <conditionnalStyles predicateExpression="aql:self.abstract"> + <style xsi:type="style:SquareDescription" resizeKind="NSEW"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <forbiddenSides>SOUTH</forbiddenSides> + <forbiddenSides>EAST</forbiddenSides> + <forbiddenSides>NORTH</forbiddenSides> + <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_orange']"/> + </style> + </conditionnalStyles> </borderedNodeMappings> <borderedNodeMappings name="eClassEast" preconditionExpression="aql:self.name.contains('East')" semanticCandidatesExpression="feature:eClassifiers" domainClass="EClass"> <style xsi:type="style:SquareDescription" resizeKind="NSEW"> @@ -23,6 +46,16 @@ <forbiddenSides>NORTH</forbiddenSides> <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='green']"/> </style> + <conditionnalStyles predicateExpression="aql:self.abstract"> + <style xsi:type="style:SquareDescription" resizeKind="NSEW"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <forbiddenSides>WEST</forbiddenSides> + <forbiddenSides>SOUTH</forbiddenSides> + <forbiddenSides>NORTH</forbiddenSides> + <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_green']"/> + </style> + </conditionnalStyles> </borderedNodeMappings> <borderedNodeMappings name="eClassNorth" preconditionExpression="aql:self.name.contains('North')" semanticCandidatesExpression="feature:eClassifiers" domainClass="EClass"> <style xsi:type="style:SquareDescription" resizeKind="NSEW"> @@ -33,6 +66,16 @@ <forbiddenSides>EAST</forbiddenSides> <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='blue']"/> </style> + <conditionnalStyles predicateExpression="aql:self.abstract"> + <style xsi:type="style:SquareDescription" resizeKind="NSEW"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <forbiddenSides>WEST</forbiddenSides> + <forbiddenSides>SOUTH</forbiddenSides> + <forbiddenSides>EAST</forbiddenSides> + <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_gray']"/> + </style> + </conditionnalStyles> </borderedNodeMappings> <borderedNodeMappings name="eClassSouth" preconditionExpression="aql:self.name.contains('South')" semanticCandidatesExpression="feature:eClassifiers" domainClass="EClass"> <style xsi:type="style:SquareDescription" resizeKind="NSEW"> @@ -43,6 +86,16 @@ <forbiddenSides>NORTH</forbiddenSides> <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='purple']"/> </style> + <conditionnalStyles predicateExpression="aql:self.abstract"> + <style xsi:type="style:SquareDescription" resizeKind="NSEW"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <forbiddenSides>WEST</forbiddenSides> + <forbiddenSides>EAST</forbiddenSides> + <forbiddenSides>NORTH</forbiddenSides> + <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_chocolate']"/> + </style> + </conditionnalStyles> </borderedNodeMappings> <borderedNodeMappings name="eClassSN" preconditionExpression="aql:self.name.contains('SN')" semanticCandidatesExpression="feature:eClassifiers" domainClass="EClass"> <style xsi:type="style:SquareDescription" resizeKind="NSEW"> @@ -52,6 +105,15 @@ <forbiddenSides>EAST</forbiddenSides> <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='yellow']"/> </style> + <conditionnalStyles predicateExpression="aql:self.abstract"> + <style xsi:type="style:SquareDescription" resizeKind="NSEW"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <forbiddenSides>WEST</forbiddenSides> + <forbiddenSides>EAST</forbiddenSides> + <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_blue']"/> + </style> + </conditionnalStyles> </borderedNodeMappings> <style xsi:type="style:FlatContainerStyleDescription" borderSizeComputationExpression="1"> <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> @@ -59,6 +121,12 @@ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/> <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_blue']"/> </style> + <conditionnalStyles predicateExpression="false"> + <style xsi:type="style:WorkspaceImageDescription" sizeComputationExpression="-1" labelPosition="node" resizeKind="NSEW" workspacePath="/org.eclipse.sirius.tests.swtbot/images/es.png"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/> + </style> + </conditionnalStyles> </containerMappings> <toolSections name="nodeCreation"> <ownedTools xsi:type="tool:NodeCreationDescription" name="createWestBorderNode" nodeMappings="//@ownedViewpoints[name='borderNodeSide']/@ownedRepresentations[name='borderNodeSide']/@defaultLayer/@containerMappings[name='container']/@borderedNodeMappings[name='eClassWest']"> @@ -106,6 +174,56 @@ </firstModelOperations> </initialOperation> </ownedTools> + <ownedTools xsi:type="tool:NodeCreationDescription" name="createWestBorderNodeWithConditionalStyle" nodeMappings="//@ownedViewpoints[name='borderNodeSide']/@ownedRepresentations[name='borderNodeSide']/@defaultLayer/@containerMappings[name='container']/@borderedNodeMappings[name='eClassWest']"> + <variable name="container"/> + <viewVariable name="containerView"/> + <initialOperation> + <firstModelOperations xsi:type="tool_1:CreateInstance" typeName="EClass" referenceName="eClassifiers"> + <subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="aql:'WestClass'+container.eClassifiers->select(myEClassifier | myEClassifier.name.contains('West'))->size()"/> + <subModelOperations xsi:type="tool_1:SetValue" featureName="abstract" valueExpression="aql:true"/> + </firstModelOperations> + </initialOperation> + </ownedTools> + <ownedTools xsi:type="tool:NodeCreationDescription" name="createEastBorderNodeWithConditionalStyle" nodeMappings="//@ownedViewpoints[name='borderNodeSide']/@ownedRepresentations[name='borderNodeSide']/@defaultLayer/@containerMappings[name='container']/@borderedNodeMappings[name='eClassEast']"> + <variable name="container"/> + <viewVariable name="containerView"/> + <initialOperation> + <firstModelOperations xsi:type="tool_1:CreateInstance" typeName="EClass" referenceName="eClassifiers"> + <subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="aql:'EastClass'+container.eClassifiers->select(myEClassifier | myEClassifier.name.contains('East'))->size()"/> + <subModelOperations xsi:type="tool_1:SetValue" featureName="abstract" valueExpression="aql:true"/> + </firstModelOperations> + </initialOperation> + </ownedTools> + <ownedTools xsi:type="tool:NodeCreationDescription" name="createNorthBorderNodeWithConditionalStyle" nodeMappings="//@ownedViewpoints[name='borderNodeSide']/@ownedRepresentations[name='borderNodeSide']/@defaultLayer/@containerMappings[name='container']/@borderedNodeMappings[name='eClassNorth']"> + <variable name="container"/> + <viewVariable name="containerView"/> + <initialOperation> + <firstModelOperations xsi:type="tool_1:CreateInstance" typeName="EClass" referenceName="eClassifiers"> + <subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="aql:'NorthClass'+container.eClassifiers->select(myEClassifier | myEClassifier.name.contains('North'))->size()"/> + <subModelOperations xsi:type="tool_1:SetValue" featureName="abstract" valueExpression="aql:true"/> + </firstModelOperations> + </initialOperation> + </ownedTools> + <ownedTools xsi:type="tool:NodeCreationDescription" name="createSouthBorderNodeWithConditionalStyle" nodeMappings="//@ownedViewpoints[name='borderNodeSide']/@ownedRepresentations[name='borderNodeSide']/@defaultLayer/@containerMappings[name='container']/@borderedNodeMappings[name='eClassSouth']"> + <variable name="container"/> + <viewVariable name="containerView"/> + <initialOperation> + <firstModelOperations xsi:type="tool_1:CreateInstance" typeName="EClass" referenceName="eClassifiers"> + <subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="aql:'SouthClass'+container.eClassifiers->select(myEClassifier | myEClassifier.name.contains('South'))->size()"/> + <subModelOperations xsi:type="tool_1:SetValue" featureName="abstract" valueExpression="aql:true"/> + </firstModelOperations> + </initialOperation> + </ownedTools> + <ownedTools xsi:type="tool:NodeCreationDescription" name="createSouthNorthBorderNodeWithConditionalStyle" nodeMappings="//@ownedViewpoints[name='borderNodeSide']/@ownedRepresentations[name='borderNodeSide']/@defaultLayer/@containerMappings[name='container']/@borderedNodeMappings[name='eClassSN']"> + <variable name="container"/> + <viewVariable name="containerView"/> + <initialOperation> + <firstModelOperations xsi:type="tool_1:CreateInstance" typeName="EClass" referenceName="eClassifiers"> + <subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="aql:'SNClass'+container.eClassifiers->select(myEClassifier | myEClassifier.name.contains('SN'))->size()"/> + <subModelOperations xsi:type="tool_1:SetValue" featureName="abstract" valueExpression="aql:true"/> + </firstModelOperations> + </initialOperation> + </ownedTools> </toolSections> </defaultLayer> </ownedRepresentations> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderNodeSideTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderNodeSideTest.java index 40098c5e7c..0ff68edca8 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderNodeSideTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/BorderNodeSideTest.java @@ -16,12 +16,19 @@ import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.transaction.RecordingCommand; import org.eclipse.gef.EditPart; import org.eclipse.gef.editparts.AbstractGraphicalEditPart; import org.eclipse.sirius.business.api.session.Session; +import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.DNode; +import org.eclipse.sirius.diagram.description.ConditionalNodeStyleDescription; import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramBorderNodeEditPart; import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramContainerEditPart; import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase; @@ -33,6 +40,7 @@ import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; import org.eclipse.swtbot.swt.finder.SWTBot; import org.eclipse.swtbot.swt.finder.waits.ICondition; +import org.eclipse.uml2.common.edit.command.ChangeCommand; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; @@ -66,6 +74,8 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { private DDiagram dDiagram; + private Resource semanticResource; + @Override protected void onSetUpBeforeClosingWelcomePage() throws Exception { copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE, ODESIGN_FILE); @@ -80,6 +90,7 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { session = localSession.getOpenedSession(); editor = (SWTBotSiriusDiagramEditor) openRepresentation(session, REPRESENTATION_NAME, REPRESENTATION_NAME, DDiagram.class, true); dDiagram = (DDiagram) editor.getDRepresentation(); + semanticResource = ((DAnalysisSession) localSession.getOpenedSession()).getSemanticResources().iterator().next(); } /** @@ -88,7 +99,7 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { */ public void testBorderNodeSideOnRefresh() { synchronizeDiagram(); - checkBorderNodesSides(); + checkBorderNodesSides(false); } @@ -98,7 +109,7 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { */ public void testBorderNodeSideOnCreation() { createBorderNodesUsingTools(1); - checkBorderNodesSides(); + checkBorderNodesSides(false); } /** @@ -107,7 +118,7 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { */ public void testBorderNodeSideOnCreationWithFullSide() { createBorderNodesUsingTools(10); - checkBorderNodesSides(); + checkBorderNodesSides(false); } /** @@ -116,9 +127,9 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { */ public void testBorderNodeSideAfterArrangeAll() { createBorderNodesUsingTools(3); - checkBorderNodesSides(); + checkBorderNodesSides(false); arrangeAll(); - checkBorderNodesSides(); + checkBorderNodesSides(false); } /** @@ -126,12 +137,12 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { */ public void testMoveBorderNodeSide() { createBorderNodesUsingTools(3); - checkBorderNodesSides(); + checkBorderNodesSides(false); moveBorderNode("WestClass1", BOTTOM_RIGHT); moveBorderNode("EastClass1", TOP_LEFT); moveBorderNode("NorthClass1", BOTTOM_LEFT); moveBorderNode("SouthClass1", TOP_RIGHT); - checkBorderNodesSides(); + checkBorderNodesSides(false); } @@ -140,7 +151,113 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { */ public void testResizeContainer() { createBorderNodesUsingTools(3); - checkBorderNodesSides(); + checkBorderNodesSides(false); + SWTBotGefEditPart containerGefEditPart = editor.getEditPart("subPackage1", AbstractDiagramContainerEditPart.class); + containerGefEditPart.select(); + final Rectangle currentBounds = getContainerBounds().getCopy(); + editor.drag(currentBounds.getBottomRight(), currentBounds.getBottomRight().translate(-currentBounds.width / 2, -currentBounds.height / 2)); + bot.waitUntil(new ICondition() { + + @Override + public boolean test() throws Exception { + return !currentBounds.equals(getContainerBounds()); + } + + @Override + public void init(SWTBot bot) { + + } + + @Override + public String getFailureMessage() { + return "The container resizing failed"; + } + }); + checkBorderNodesSides(false); + } + + /** + * Tests that border nodes with an active conditional style are properly + * placed after having perform a refresh. + */ + public void testBorderNodeSideOnRefreshWithConditionalStyle() { + setEClassToAbstract(); + synchronizeDiagram(); + checkBorderNodesSides(true); + + } + + /** + * Set the abstract attribute of all model EClass to true to match all + * conditional style of the design. + */ + private void setEClassToAbstract() { + EPackage ePackage = (EPackage) semanticResource.getContents().get(0); + EList<EClassifier> eClassifiers = ePackage.getESubpackages().get(0).getEClassifiers(); + for (EClassifier eClassifier : eClassifiers) { + final EClass eClass = (EClass) eClassifier; + session.getTransactionalEditingDomain().getCommandStack().execute(new ChangeCommand(session.getTransactionalEditingDomain(), new Runnable() { + + @Override + public void run() { + eClass.setAbstract(true); + } + })); + + } + } + + /** + * Tests that border nodes with an active conditional style are properly + * placed after having created them using a tool. + */ + public void testBorderNodeSideOnCreationWithConditionalStyle() { + createBorderNodesUsingToolsReferencingConditionalStyle(1); + checkBorderNodesSides(true); + } + + /** + * Tests that border nodes with an active conditional style are properly + * placed after having created them using a tool until the side is full. + */ + public void testBorderNodeSideOnCreationWithFullSideWithConditionalStyle() { + createBorderNodesUsingToolsReferencingConditionalStyle(10); + checkBorderNodesSides(true); + } + + /** + * Tests that border nodes with an active conditional style are properly + * placed after having performed an arrangeAll. + */ + public void testBorderNodeSideAfterArrangeAllWithConditionalStyle() { + createBorderNodesUsingToolsReferencingConditionalStyle(3); + checkBorderNodesSides(true); + arrangeAll(); + checkBorderNodesSides(true); + } + + /** + * Tests that we can't move a border node with an active conditional style + * on an unauthorized side. + */ + public void testMoveBorderNodeSideWithConditionalStyle() { + createBorderNodesUsingToolsReferencingConditionalStyle(3); + checkBorderNodesSides(true); + moveBorderNode("WestClass1", BOTTOM_RIGHT); + moveBorderNode("EastClass1", TOP_LEFT); + moveBorderNode("NorthClass1", BOTTOM_LEFT); + moveBorderNode("SouthClass1", TOP_RIGHT); + checkBorderNodesSides(true); + + } + + /** + * Tests that border nodes with an active conditional style keep their side + * after a container resizing. + */ + public void testResizeContainerWithConditionalStyle() { + createBorderNodesUsingToolsReferencingConditionalStyle(3); + checkBorderNodesSides(true); SWTBotGefEditPart containerGefEditPart = editor.getEditPart("subPackage1", AbstractDiagramContainerEditPart.class); containerGefEditPart.select(); final Rectangle currentBounds = getContainerBounds().getCopy(); @@ -162,7 +279,7 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { return "The container resizing failed"; } }); - checkBorderNodesSides(); + checkBorderNodesSides(true); } private void moveBorderNode(String borderNodeName, int position) { @@ -213,6 +330,25 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { // test south and north activateAndUseTool("createSouthNorthBorderNode", "subPackage1", copies); + + } + + private void createBorderNodesUsingToolsReferencingConditionalStyle(int copies) { + // test west + activateAndUseTool("createWestBorderNodeWithConditionalStyle", "subPackage1", copies); + + // test east + activateAndUseTool("createEastBorderNodeWithConditionalStyle", "subPackage1", copies); + + // test south + activateAndUseTool("createSouthBorderNodeWithConditionalStyle", "subPackage1", copies); + + // test north + activateAndUseTool("createNorthBorderNodeWithConditionalStyle", "subPackage1", copies); + + // test south and north + activateAndUseTool("createSouthNorthBorderNodeWithConditionalStyle", "subPackage1", copies); + } private void activateAndUseTool(String toolName, String targetEditPartName, int iterations) { @@ -222,7 +358,7 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { } } - private void checkBorderNodesSides() { + private void checkBorderNodesSides(boolean expectConditionalStyle) { // We retrieve the border nodes edit parts... List<SWTBotGefEditPart> botGefEditParts = editor.editParts(new BaseMatcher<EditPart>() { @@ -242,6 +378,14 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { for (SWTBotGefEditPart botGefEditPart : botGefEditParts) { AbstractDiagramBorderNodeEditPart editPart = (AbstractDiagramBorderNodeEditPart) botGefEditPart.part(); DNode node = (DNode) editPart.resolveSemanticElement(); + + if (expectConditionalStyle) { + assertTrue("The tested node should be under a conditional style node. But it is not.", node.getOwnedStyle().getDescription().eContainer() instanceof ConditionalNodeStyleDescription); + } else { + assertFalse("The tested node should be not under a conditional style node. But it is.", node.getOwnedStyle().getDescription().eContainer() instanceof ConditionalNodeStyleDescription); + } + assertEquals("The tested node should be under a conditional style node. But is is not.", expectConditionalStyle, + node.getOwnedStyle().getDescription().eContainer() instanceof ConditionalNodeStyleDescription); String name = node.getName(); int side = computeSide(editPart); String message = "The border node " + name + " is not at the expected side"; @@ -317,4 +461,5 @@ public class BorderNodeSideTest extends AbstractSiriusSwtBotGefTestCase { SWTBotUtils.waitAllUiEvents(); super.tearDown(); } + } diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/BorderNodeSidePropertySectionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/BorderNodeSidePropertySectionTest.java new file mode 100644 index 0000000000..4e2e46cc2f --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/BorderNodeSidePropertySectionTest.java @@ -0,0 +1,201 @@ +/******************************************************************************* + * Copyright (c) 2016 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.tests.swtbot.editor.vsm; + +import org.eclipse.sirius.diagram.business.internal.metamodel.description.spec.ConditionalContainerStyleDescriptionSpec; +import org.eclipse.sirius.diagram.description.ConditionalNodeStyleDescription; +import org.eclipse.sirius.tests.swtbot.Activator; +import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase; +import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusHelper; +import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.IModelExplorerView; +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.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.eclipse.ui.PlatformUI; + +/** + * Test Class to check the border nodes authorized sides feature. + * + * @author <a href="mailto:pierre.guilet@obeo.fr">Pierre Guilet</a> + * + */ +public class BorderNodeSidePropertySectionTest extends AbstractSiriusSwtBotGefTestCase { + + private static final String DATA_UNIT_DIR = "data/unit/borderNodeSide/"; + + private static final String MODEL = "borderNodeSide.ecore"; + + private static final String SESSION_FILE = "borderNodeSide.aird"; + + private static final String ODESIGN_FILE = "borderNodeSide.odesign"; + + private static final String DEFAULT_LAYER_NAME = "Default"; + + private SWTBotView propertiesBot; + + private SWTBotEditor odesignEditorBot; + + private SWTBotTreeItem viewpointItemBot; + + @Override + protected void onSetUpBeforeClosingWelcomePage() throws Exception { + copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE, ODESIGN_FILE); + } + + @Override + protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { + super.onSetUpAfterOpeningDesignerPerspective(); + + SWTBotView projectExplorer = bot.viewById(IModelExplorerView.ID); + projectExplorer.setFocus(); + SWTBot projectExplorerBot = projectExplorer.bot(); + projectExplorerBot.tree().expandNode(getProjectName()).expandNode(ODESIGN_FILE).doubleClick(); + + odesignEditorBot = bot.activeEditor(); + odesignEditorBot.setFocus(); + viewpointItemBot = odesignEditorBot.bot().tree().expandNode("platform:/resource/" + getProjectName() + "/" + ODESIGN_FILE, true); + viewpointItemBot.setFocus(); + } + + /** + * Checks that the side property is visible or not for node with conditional + * style or not. + * + * @param parentNodeOfTestedNode + * the parent node of the node we test the property visibility + * on. + * @param testedNode + * the node we want to check the side property visibility on. + * @param shouldBeVisible + * true if the side property must be visible on the given tested + * node. + * @param conditionalStylePresent + * true if the given node should be under a conditional style. + * @param failMessage + * the message in case the test fails. + */ + private void checkSidePropertyVisibility(final SWTBotTreeItem parentNodeOfTestedNode, final SWTBotTreeItem testedNode, boolean shouldBeVisible, final boolean conditionalStylePresent, + String failMessage) { + testedNode.select(); + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + @Override + public void run() { + Object data = parentNodeOfTestedNode.widget.getData(); + if (conditionalStylePresent) { + assertTrue(data instanceof ConditionalNodeStyleDescription || data instanceof ConditionalContainerStyleDescriptionSpec); + } else { + assertFalse(data instanceof ConditionalNodeStyleDescription || data instanceof ConditionalContainerStyleDescriptionSpec); + } + } + }); + propertiesBot = bot.viewByTitle("Properties"); + propertiesBot.setFocus(); + SWTBotSiriusHelper.selectPropertyTabItem("Advanced"); + if (shouldBeVisible) { + try { + propertiesBot.bot().checkBoxWithLabel("Authorized Sides:"); + } catch (WidgetNotFoundException e) { + fail(failMessage); + } + } else { + try { + propertiesBot.bot().checkBoxWithLabel("Authorized Sides:"); + fail(failMessage); + } catch (WidgetNotFoundException e) { + // valid case + } + } + + } + + /** + * Tests that the checkbox used to specify the authorized sides of a border + * node in its parent are visible for a conditional style + */ + public void testSidePropertyVisibilityOnBorderedNodeWithConditionalStyle() { + final SWTBotTreeItem westBorderedNodeContditionalStyleParent = viewpointItemBot.getNode(0).getNode(0).getNode(0).getNode(DEFAULT_LAYER_NAME).getNode(1).getNode(0).getNode(1); + SWTBotTreeItem westBorderedNodeContditionalStyle = westBorderedNodeContditionalStyleParent.getNode(0); + checkSidePropertyVisibility(westBorderedNodeContditionalStyleParent, westBorderedNodeContditionalStyle, true, true, + "the checkbox to choose the authorized sides for bordered node style should be available."); + } + + /** + * Tests that the checkbox used to specify the authorized sides of a border + * node in its parent are visible for a no conditional style + */ + public void testSidePropertyVisibilityOnBorderedNode() { + final SWTBotTreeItem westBorderedNodeDefaultStyleParent = viewpointItemBot.getNode(0).getNode(0).getNode(0).getNode(DEFAULT_LAYER_NAME).getNode(1).getNode(0); + SWTBotTreeItem westBorderedNodeDefaultStyle = westBorderedNodeDefaultStyleParent.getNode(0); + checkSidePropertyVisibility(westBorderedNodeDefaultStyleParent, westBorderedNodeDefaultStyle, true, false, + "the checkbox to choose the authorized sides for bordered node style should be available."); + } + + /** + * Tests that the checkbox used to specify the authorized sides of a + * bordered node are not visible for a WorkspaceImageImage no conditional + * style of a container. + */ + public void testSidePropertyNoVisibilityOnContainerWithConditionalStyle() { + final SWTBotTreeItem containerWithConditionalStyleParent = viewpointItemBot.getNode(0).getNode(0).getNode(0).getNode(DEFAULT_LAYER_NAME).getNode(1).getNode(6); + SWTBotTreeItem containerWithConditionalStyle = containerWithConditionalStyleParent.getNode(0); + checkSidePropertyVisibility(containerWithConditionalStyleParent, containerWithConditionalStyle, false, true, + "the checkbox to choose the authorized sides for bordered node style should not be available for a container conditional style."); + + } + + /** + * Tests that the checkbox used to specify the authorized sides of a + * bordered node are not visible for a WorkspaceImage conditional style of a + * container. + */ + public void testSidePropertyNoVisibilityOnContainerWithNoConditionalStyle() { + final SWTBotTreeItem containerWithNoConditionalStyleParent = viewpointItemBot.getNode(0).getNode(0).getNode(0).getNode(DEFAULT_LAYER_NAME).getNode(1); + SWTBotTreeItem containerWithNoConditionalStyle = containerWithNoConditionalStyleParent.getNode(5); + checkSidePropertyVisibility(containerWithNoConditionalStyleParent, containerWithNoConditionalStyle, false, false, + "the checkbox to choose the authorized sides for bordered node style should not be available for a container style."); + } + + /** + * Tests that the checkbox used to specify the authorized sides of a + * bordered node are not visible for a WorkspaceImage no conditional style + * of a container. + */ + public void testSidePropertyNoVisibilityOnSimpleNodeWithConditionalStyle() { + final SWTBotTreeItem simpleNodeWithConditionalStyleParent = viewpointItemBot.getNode(0).getNode(0).getNode(0).getNode(DEFAULT_LAYER_NAME).getNode(0).getNode(1); + SWTBotTreeItem simpleNodeWithConditionalStyle = simpleNodeWithConditionalStyleParent.getNode(0); + checkSidePropertyVisibility(simpleNodeWithConditionalStyleParent, simpleNodeWithConditionalStyle, false, true, + "the checkbox to choose the authorized sides for bordered node style should not be available for a simple node conditional style."); + } + + /** + * Tests that the checkbox used to specify the authorized sides of a + * bordered node are not visible for a WorkspaceImage conditional style of a + * container. + */ + public void testSidePropertyNoVisibilityOnSimpleNodeWithNoConditionalStyle() { + final SWTBotTreeItem simpleNodeWithNoConditionalStyleParent = viewpointItemBot.getNode(0).getNode(0).getNode(0).getNode(DEFAULT_LAYER_NAME).getNode(0); + SWTBotTreeItem simpleNodeWithNoConditionalStyle = simpleNodeWithNoConditionalStyleParent.getNode(0); + checkSidePropertyVisibility(simpleNodeWithNoConditionalStyleParent, simpleNodeWithNoConditionalStyle, false, false, + "the checkbox to choose the authorized sides for bordered node style should not be available for a simple node style."); + } + + @Override + protected void tearDown() throws Exception { + odesignEditorBot.close(); + odesignEditorBot = null; + propertiesBot = null; + viewpointItemBot = null; + super.tearDown(); + } + +} diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java index 8cf7d34f82..712cc571c1 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java @@ -24,6 +24,7 @@ import org.eclipse.sirius.tests.swtbot.compartment.CompartmentsCreationTest; import org.eclipse.sirius.tests.swtbot.compartment.CompartmentsDragAndDropTest; import org.eclipse.sirius.tests.swtbot.crossTable.CrossTableIntersectionExpressionTest; import org.eclipse.sirius.tests.swtbot.crossTable.CrossTableIntersectionTest; +import org.eclipse.sirius.tests.swtbot.editor.vsm.BorderNodeSidePropertySectionTest; import org.eclipse.sirius.tests.swtbot.editor.vsm.BorderSizeComputationExpressionTest; import org.eclipse.sirius.tests.swtbot.editor.vsm.CompletionProposalInVSMTest; import org.eclipse.sirius.tests.swtbot.editor.vsm.ContainerDropPropertySectionsTests; @@ -286,6 +287,7 @@ public class AllTestSuite extends TestCase { suite.addTestSuite(InvalidMetamodelRessourceTest.class); suite.addTestSuite(ExtensionActivationOrderTest.class); suite.addTestSuite(ContainerDropPropertySectionsTests.class); + suite.addTestSuite(BorderNodeSidePropertySectionTest.class); } /** |
