diff options
| author | Pierre-Charles David | 2017-12-26 09:33:33 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2017-12-26 09:33:34 +0000 |
| commit | 73eef225134c9ece0a18d71eb2c0095f9b47f057 (patch) | |
| tree | f425dbf2225182a712cae42a55829aead0185356 | |
| parent | 4e90d720ec6b4d9610536f4d460b176d19762106 (diff) | |
| download | org.eclipse.sirius-73eef225134c9ece0a18d71eb2c0095f9b47f057.tar.gz org.eclipse.sirius-73eef225134c9ece0a18d71eb2c0095f9b47f057.tar.xz org.eclipse.sirius-73eef225134c9ece0a18d71eb2c0095f9b47f057.zip | |
[527391] Add test for NoteAttachments selection
Bug: 527391
Change-Id: Ia0e3bff93ff3f3e664cdd10061166039c64fba5f
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
5 files changed, 191 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/.project b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/.project new file mode 100644 index 0000000000..cf33a7e767 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/.project @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>Bugzilla-527391</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + </buildSpec> + <natures> + <nature>org.eclipse.sirius.nature.modelingproject</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/MyEcore.ecore b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/MyEcore.ecore new file mode 100644 index 0000000000..80f5e17def --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/MyEcore.ecore @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="p"> + <eClassifiers xsi:type="ecore:EClass" name="A"/> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/representations.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/representations.aird new file mode 100644 index 0000000000..21c735cc3b --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/noteAttachments/Bugzilla-527391/representations.aird @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI 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:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style"> + <viewpoint:DAnalysis xmi:id="_gOz7wMt7Eee3es3RN_SjfA" selectedViews="_kCr2AMt7Eee3es3RN_SjfA" version="12.1.0.201708031200"> + <semanticResources>MyEcore.ecore</semanticResources> + <ownedViews xmi:type="viewpoint:DView" xmi:id="_kCr2AMt7Eee3es3RN_SjfA"> + <viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']"/> + <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" xmi:id="_kL6DcMt7Eee3es3RN_SjfA" name=" package entities" repPath="#_kIpUEMt7Eee3es3RN_SjfA"> + <description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/> + <target xmi:type="ecore:EPackage" href="MyEcore.ecore#/"/> + </ownedRepresentationDescriptors> + </ownedViews> + </viewpoint:DAnalysis> + <diagram:DSemanticDiagram xmi:id="_kL1yAMt7Eee3es3RN_SjfA" name=" package entities" uid="_kIpUEMt7Eee3es3RN_SjfA"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_kL1yAct7Eee3es3RN_SjfA" source="DANNOTATION_CUSTOMIZATION_KEY"> + <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_kL1yAst7Eee3es3RN_SjfA"/> + </ownedAnnotationEntries> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_kNzg4Mt7Eee3es3RN_SjfA" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_kNzg4ct7Eee3es3RN_SjfA" type="Sirius" element="_kL1yAMt7Eee3es3RN_SjfA" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_vo1H0Mt9Eee9_uUFA0gDPg" type="2003" element="_vnttgMt9Eee9_uUFA0gDPg"> + <children xmi:type="notation:Node" xmi:id="_vo8ckMt9Eee9_uUFA0gDPg" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_vo9DoMt9Eee9_uUFA0gDPg" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_vo9Doct9Eee9_uUFA0gDPg"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_vo9Dost9Eee9_uUFA0gDPg"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_vo1H0ct9Eee9_uUFA0gDPg" fontName="Cantarell" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_vo1H0st9Eee9_uUFA0gDPg" x="75" y="55" width="213" height="213"/> + </children> + <children xmi:type="notation:Shape" xmi:id="_z6H94Mt9Eee9_uUFA0gDPg" type="Text" fontName="Cantarell" description="A text"> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_z6Ik8Mt9Eee9_uUFA0gDPg" type="DiagramName"> + <element xsi:nil="true"/> + </children> + <children xmi:type="notation:BasicDecorationNode" xmi:id="_z6Ik8ct9Eee9_uUFA0gDPg" type="Description"> + <element xsi:nil="true"/> + </children> + <element xsi:nil="true"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_z6H94ct9Eee9_uUFA0gDPg" x="550" y="170" height="96"/> + </children> + <children xmi:type="notation:Shape" xmi:id="__BgFgMt-EeeQtf-Um9dnbQ" type="Note" fontName="Cantarell" description="A note" fillColor="13369343" transparency="0" lineColor="6737151" lineWidth="1"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="__BgFgct-EeeQtf-Um9dnbQ" source="specificStyles"> + <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="__BgFgst-EeeQtf-Um9dnbQ" key="verticalAlignment" value="8"/> + </eAnnotations> + <children xmi:type="notation:BasicDecorationNode" xmi:id="__BkW8Mt-EeeQtf-Um9dnbQ" type="DiagramName"> + <element xsi:nil="true"/> + </children> + <children xmi:type="notation:BasicDecorationNode" xmi:id="__BkW8ct-EeeQtf-Um9dnbQ" type="Description"> + <element xsi:nil="true"/> + </children> + <styles xmi:type="notation:TextStyle" xmi:id="__BgFg8t-EeeQtf-Um9dnbQ" textAlignment="Center"/> + <styles xmi:type="notation:LineTypeStyle" xmi:id="__BgFhMt-EeeQtf-Um9dnbQ"/> + <element xsi:nil="true"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="__BgFhct-EeeQtf-Um9dnbQ" x="550" y="55" height="96"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_kNzg4st7Eee3es3RN_SjfA"/> + <edges xmi:type="notation:Connector" xmi:id="_iSK90Mt_EeeQtf-Um9dnbQ" type="NoteAttachment" source="_vo1H0Mt9Eee9_uUFA0gDPg" target="__BgFgMt-EeeQtf-Um9dnbQ" lineWidth="1"> + <styles xmi:type="notation:ArrowStyle" xmi:id="_iSK90ct_EeeQtf-Um9dnbQ"/> + <styles xmi:type="notation:LineTypeStyle" xmi:id="_iSK90st_EeeQtf-Um9dnbQ"/> + <element xsi:nil="true"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_iSK908t_EeeQtf-Um9dnbQ" points="[43, 8, -314, 3]$[349, 52, -8, 47]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_iSPPQMt_EeeQtf-Um9dnbQ" id="(0.7962085308056872,0.2037914691943128)"/> + </edges> + <edges xmi:type="notation:Connector" xmi:id="_j3n4sMt_EeeQtf-Um9dnbQ" type="NoteAttachment" source="_z6H94Mt9Eee9_uUFA0gDPg" target="_vo1H0Mt9Eee9_uUFA0gDPg" lineWidth="1"> + <styles xmi:type="notation:ArrowStyle" xmi:id="_j3n4sct_EeeQtf-Um9dnbQ"/> + <styles xmi:type="notation:LineTypeStyle" xmi:id="_j3n4sst_EeeQtf-Um9dnbQ"/> + <element xsi:nil="true"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_j3n4s8t_EeeQtf-Um9dnbQ" points="[-50, -8, 308, 0]$[-314, 27, 44, 35]"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_j3qU8Mt_EeeQtf-Um9dnbQ" id="(0.7914691943127962,0.7345971563981043)"/> + </edges> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_vnttgMt9Eee9_uUFA0gDPg" name="A" tooltipText="p.A"> + <target xmi:type="ecore:EClass" href="MyEcore.ecore#//A"/> + <semanticElements xmi:type="ecore:EClass" href="MyEcore.ecore#//A"/> + <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> + <arrangeConstraints>KEEP_SIZE</arrangeConstraints> + <arrangeConstraints>KEEP_RATIO</arrangeConstraints> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_voABYMt9Eee9_uUFA0gDPg" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="GradientTopToBottom"> + <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> + </ownedDiagramElements> + <description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/> + <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_kL1yBMt7Eee3es3RN_SjfA"/> + <activatedLayers xmi:type="description_1:Layer" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer"/> + <activatedLayers xmi:type="description_1:AdditionalLayer" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@additionalLayers[name='Package']"/> + <target xmi:type="ecore:EPackage" href="MyEcore.ecore#/"/> + </diagram:DSemanticDiagram> +</xmi:XMI> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/NoteAttachmentTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/NoteAttachmentTest.java new file mode 100644 index 0000000000..cbf1cdc81f --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/NoteAttachmentTest.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2017 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; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart; +import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.NoteAttachmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.TextEditPart; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.sirius.diagram.DDiagram; +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.condition.CheckSelectedCondition; +import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefConnectionEditPart; +import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; + +/** + * Verifies that Note (and Text) attachments, which are not handled + * directly/only by Sirius but inherited from GMF, work correctly. + */ +@SuppressWarnings("restriction") +public class NoteAttachmentTest extends AbstractSiriusSwtBotGefTestCase { + private static final String MODEL_FILE = "MyEcore.ecore"; + + private static final String SESSION_FILE = "representations.aird"; + + private static final String DATA_UNIT_DIR = "data/unit/noteAttachments/Bugzilla-527391/"; + + @Override + protected void onSetUpBeforeClosingWelcomePage() throws Exception { + copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL_FILE, SESSION_FILE); + sessionAirdResource = new UIResource(designerProject, SESSION_FILE); + localSession = designerPerspective.openSessionFromFile(sessionAirdResource, true); + editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), "Entities", " package entities", DDiagram.class); + } + + /** + * Checks that Note attachments can be selected. + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=527391" + */ + public void test_NoteAttachments_can_be_selected() { + List<NoteAttachmentEditPart> notes = editor.getConnectionsEditPart().stream().map(SWTBotGefConnectionEditPart::part).filter(NoteAttachmentEditPart.class::isInstance) + .map(NoteAttachmentEditPart.class::cast).collect(Collectors.toList()); + assertEquals("The test diagram should contain 2 note attachments", 2, notes.size()); + Optional<NoteAttachmentEditPart> attachmentToNote = notes.stream().filter(n -> n.getTarget() instanceof NoteEditPart).findFirst(); + assertTrue("Could not find the note attachment edit part", attachmentToNote.isPresent()); + Optional<NoteAttachmentEditPart> attachmentToText = notes.stream().filter(n -> n.getSource() instanceof TextEditPart).findFirst(); + assertTrue("Could not find the text attachment edit part", attachmentToText.isPresent()); + // Make sure the diagram's background is selected first. + editor.click(new Point(10, 10)); + bot.waitUntil(new DefaultCondition() { + @Override + public boolean test() throws Exception { + ISelection sel = editor.getSelection(); + return (sel instanceof StructuredSelection) && ((StructuredSelection) sel).getFirstElement() == editor.getDiagramEditPart(); + } + + @Override + public String getFailureMessage() { + return "The diagram was not selected"; + } + }); + // Select the note attachment + editor.click(new Point(417, 103)); + bot.waitUntil(new CheckSelectedCondition(editor, attachmentToNote.get())); + // Select the text attachment + editor.click(new Point(433, 211)); + bot.waitUntil(new CheckSelectedCondition(editor, attachmentToText.get())); + + } +} 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 705e7ccbb1..ddf211fb91 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 @@ -417,6 +417,7 @@ public class AllTestSuite extends TestCase { suite.addTestSuite(ChildrenPositionStabilityAfterParentResizeTest.class); suite.addTestSuite(VSMEditorPropertiesTest.class); suite.addTestSuite(SessionEditorOpeningTests.class); + suite.addTestSuite(NoteAttachmentTest.class); // Scenario test cases suite.addTestSuite(ESEDemoTest.class); |
