diff options
| author | Florian Barbin | 2016-03-30 07:36:17 +0000 |
|---|---|---|
| committer | Laurent Redor | 2016-04-25 16:15:04 +0000 |
| commit | c6c91e00ce7a10530c11300475d5aa60ce284008 (patch) | |
| tree | a81cdc9d7453b74107c34f11d946075bc32e6541 | |
| parent | 9f050e77882080dab460821481b549c1117c9d10 (diff) | |
| download | org.eclipse.sirius-c6c91e00ce7a10530c11300475d5aa60ce284008.tar.gz org.eclipse.sirius-c6c91e00ce7a10530c11300475d5aa60ce284008.tar.xz org.eclipse.sirius-c6c91e00ce7a10530c11300475d5aa60ce284008.zip | |
[490444] Adds SWTBot test
This test makes sure that the copy appearance properties action takes
the last selected element as reference.
Bug: 490444
Change-Id: I73a2b45421979f4b6319080390acca9b180ace28
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
3 files changed, 317 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.aird new file mode 100644 index 0000000000..da8e2c5898 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.aird @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="UTF-8"?> +<viewpoint:DAnalysis 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" xmi:id="_3iyGIPWKEeW_qZJJi9_oUw" selectedViews="_4t7qoPWKEeW_qZJJi9_oUw" version="11.0.0.201601261200"> + <semanticResources>490444.ecore</semanticResources> + <ownedViews xmi:type="viewpoint:DRepresentationContainer" xmi:id="_4t7qoPWKEeW_qZJJi9_oUw"> + <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_43sDkPWKEeW_qZJJi9_oUw" name=" package entities"> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_43sDkfWKEeW_qZJJi9_oUw" source="DANNOTATION_CUSTOMIZATION_KEY"> + <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_43sDkvWKEeW_qZJJi9_oUw"/> + </ownedAnnotationEntries> + <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_4310kPWKEeW_qZJJi9_oUw" source="GMF_DIAGRAMS"> + <data xmi:type="notation:Diagram" xmi:id="_4310kfWKEeW_qZJJi9_oUw" type="Sirius" element="_43sDkPWKEeW_qZJJi9_oUw" measurementUnit="Pixel"> + <children xmi:type="notation:Node" xmi:id="_8MqbUPWKEeW_qZJJi9_oUw" type="2003" element="_8J7QYPWKEeW_qZJJi9_oUw"> + <children xmi:type="notation:Node" xmi:id="_8MuswPWKEeW_qZJJi9_oUw" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_8MvT0PWKEeW_qZJJi9_oUw" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_8Mv64PWKEeW_qZJJi9_oUw"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_8Mv64fWKEeW_qZJJi9_oUw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_8MqbUfWKEeW_qZJJi9_oUw" fontColor="12560536" fontName="Cantarell" fontHeight="16" bold="true" fillColor="10011046" lineColor="8047085"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8MqbUvWKEeW_qZJJi9_oUw" x="180" y="72"/> + </children> + <children xmi:type="notation:Node" xmi:id="_8YdboPWKEeW_qZJJi9_oUw" type="2003" element="_8YJSkPWKEeW_qZJJi9_oUw"> + <children xmi:type="notation:Node" xmi:id="_8YeCsPWKEeW_qZJJi9_oUw" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_8YeCsfWKEeW_qZJJi9_oUw" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_8YeCsvWKEeW_qZJJi9_oUw"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_8YeCs_WKEeW_qZJJi9_oUw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_8YdbofWKEeW_qZJJi9_oUw" fontName="Cantarell" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8YdbovWKEeW_qZJJi9_oUw" x="444" y="96"/> + </children> + <children xmi:type="notation:Node" xmi:id="_8ghygPWKEeW_qZJJi9_oUw" type="2003" element="_8gL0QPWKEeW_qZJJi9_oUw"> + <children xmi:type="notation:Node" xmi:id="_8giZkPWKEeW_qZJJi9_oUw" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_8giZkfWKEeW_qZJJi9_oUw" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_8giZkvWKEeW_qZJJi9_oUw"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_8giZk_WKEeW_qZJJi9_oUw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_8ghygfWKEeW_qZJJi9_oUw" fontName="Cantarell" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8ghygvWKEeW_qZJJi9_oUw" x="744" y="92"/> + </children> + <children xmi:type="notation:Node" xmi:id="_8lytAPWKEeW_qZJJi9_oUw" type="2003" element="_8lX2QPWKEeW_qZJJi9_oUw"> + <children xmi:type="notation:Node" xmi:id="_8lzUEPWKEeW_qZJJi9_oUw" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_8lz7IPWKEeW_qZJJi9_oUw" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_8lz7IfWKEeW_qZJJi9_oUw"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_8lz7IvWKEeW_qZJJi9_oUw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_8lytAfWKEeW_qZJJi9_oUw" fontName="Cantarell" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8lytAvWKEeW_qZJJi9_oUw" x="444" y="216"/> + </children> + <children xmi:type="notation:Node" xmi:id="_8qOhEPWKEeW_qZJJi9_oUw" type="2003" element="_8pxOEPWKEeW_qZJJi9_oUw"> + <children xmi:type="notation:Node" xmi:id="_8qPIIPWKEeW_qZJJi9_oUw" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_8qPvMPWKEeW_qZJJi9_oUw" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_8qPvMfWKEeW_qZJJi9_oUw"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_8qPvMvWKEeW_qZJJi9_oUw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_8qOhEfWKEeW_qZJJi9_oUw" fontName="Cantarell" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8qOhEvWKEeW_qZJJi9_oUw" x="288" y="240"/> + </children> + <children xmi:type="notation:Node" xmi:id="_8w6-8PWKEeW_qZJJi9_oUw" type="2003" element="_8wgvQPWKEeW_qZJJi9_oUw"> + <children xmi:type="notation:Node" xmi:id="_8w7mAPWKEeW_qZJJi9_oUw" type="5007"/> + <children xmi:type="notation:Node" xmi:id="_8w8NEPWKEeW_qZJJi9_oUw" type="7004"> + <styles xmi:type="notation:SortingStyle" xmi:id="_8w8NEfWKEeW_qZJJi9_oUw"/> + <styles xmi:type="notation:FilteringStyle" xmi:id="_8w8NEvWKEeW_qZJJi9_oUw"/> + </children> + <styles xmi:type="notation:ShapeStyle" xmi:id="_8w6-8fWKEeW_qZJJi9_oUw" fontName="Cantarell" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_8w6-8vWKEeW_qZJJi9_oUw" x="744" y="228"/> + </children> + <styles xmi:type="notation:DiagramStyle" xmi:id="_4310kvWKEeW_qZJJi9_oUw"/> + </data> + </ownedAnnotationEntries> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_8J7QYPWKEeW_qZJJi9_oUw" name="NewEClass1" tooltipText="root.NewEClass1"> + <target xmi:type="ecore:EClass" href="490444.ecore#//NewEClass1"/> + <semanticElements xmi:type="ecore:EClass" href="490444.ecore#//NewEClass1"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_8KTq4PWKEeW_qZJJi9_oUw" labelSize="16" labelColor="152,168,191" borderSize="1" borderSizeComputationExpression="1" borderColor="237,201,122" backgroundStyle="GradientTopToBottom" backgroundColor="166,193,152" foregroundColor="166,193,152"> + <customFeatures>labelSize</customFeatures> + <customFeatures>labelFormat</customFeatures> + <customFeatures>borderColor</customFeatures> + <customFeatures>labelColor</customFeatures> + <customFeatures>backgroundColor</customFeatures> + <customFeatures>foregroundColor</customFeatures> + <labelFormat>bold</labelFormat> + <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> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_8YJSkPWKEeW_qZJJi9_oUw" name="NewEClass2" tooltipText="root.NewEClass2"> + <target xmi:type="ecore:EClass" href="490444.ecore#//NewEClass2"/> + <semanticElements xmi:type="ecore:EClass" href="490444.ecore#//NewEClass2"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_8YKgsPWKEeW_qZJJi9_oUw" 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> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_8gL0QPWKEeW_qZJJi9_oUw" name="NewEClass3" tooltipText="root.NewEClass3"> + <target xmi:type="ecore:EClass" href="490444.ecore#//NewEClass3"/> + <semanticElements xmi:type="ecore:EClass" href="490444.ecore#//NewEClass3"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_8gNCYPWKEeW_qZJJi9_oUw" 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> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_8lX2QPWKEeW_qZJJi9_oUw" name="NewEClass4" tooltipText="root.NewEClass4"> + <target xmi:type="ecore:EClass" href="490444.ecore#//NewEClass4"/> + <semanticElements xmi:type="ecore:EClass" href="490444.ecore#//NewEClass4"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_8lYdUPWKEeW_qZJJi9_oUw" 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> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_8pxOEPWKEeW_qZJJi9_oUw" name="NewEClass5" tooltipText="root.NewEClass5"> + <target xmi:type="ecore:EClass" href="490444.ecore#//NewEClass5"/> + <semanticElements xmi:type="ecore:EClass" href="490444.ecore#//NewEClass5"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_8pzDQPWKEeW_qZJJi9_oUw" 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> + <ownedDiagramElements xmi:type="diagram:DNodeList" xmi:id="_8wgvQPWKEeW_qZJJi9_oUw" name="NewEClass6" tooltipText="root.NewEClass6"> + <target xmi:type="ecore:EClass" href="490444.ecore#//NewEClass6"/> + <semanticElements xmi:type="ecore:EClass" href="490444.ecore#//NewEClass6"/> + <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_8whWUPWKEeW_qZJJi9_oUw" 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="_43sDk_WKEeW_qZJJi9_oUw"/> + <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="490444.ecore#/"/> + </ownedRepresentations> + <viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.eclipse.sirius.sample.ecore.design/description/ecore.odesign#//@ownedViewpoints[name='Design']"/> + </ownedViews> +</viewpoint:DAnalysis> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.ecore b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.ecore new file mode 100644 index 0000000000..52d3dde7f2 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/copyAppearance/490444.ecore @@ -0,0 +1,10 @@ +<?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="root" nsPrefix=""> + <eClassifiers xsi:type="ecore:EClass" name="NewEClass1"/> + <eClassifiers xsi:type="ecore:EClass" name="NewEClass2"/> + <eClassifiers xsi:type="ecore:EClass" name="NewEClass3"/> + <eClassifiers xsi:type="ecore:EClass" name="NewEClass4"/> + <eClassifiers xsi:type="ecore:EClass" name="NewEClass5"/> + <eClassifiers xsi:type="ecore:EClass" name="NewEClass6"/> +</ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/CopyAppearanceActionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/CopyAppearanceActionTest.java new file mode 100644 index 0000000000..4ce4581ffc --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/CopyAppearanceActionTest.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (c) 2016 THALES GLOBAL SERVICES. + * 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.tabbar; + +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.diagram.ui.actions.internal.l10n.DiagramUIActionsMessages; +import org.eclipse.gmf.runtime.notation.Node; +import org.eclipse.gmf.runtime.notation.ShapeStyle; +import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramElementContainerEditPart; +import org.eclipse.sirius.diagram.ui.provider.Messages; +import org.eclipse.sirius.tests.swtbot.Activator; +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.utils.SWTBotUtils; +import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; + +/** + * This test makes sure that the copy appearance properties action takes the + * last selected element as reference. + * + * @author Florian Barbin + * + */ +@SuppressWarnings("restriction") +public class CopyAppearanceActionTest extends AbstractSiriusSwtBotGefTestCase { + + private static final String MODEL = "490444.ecore"; + + private static final String SESSION_FILE = "490444.aird"; + + private static final String DATA_UNIT_DIR = "data/unit/copyAppearance/"; + + private static final int EXPECTED_CUSTOM_FONT_COLOR = 12560536; + + private static final int EXPECTED_CUSTOM_LINE_COLOR = 8047085; + + private static final int EXPECTED_CUSTOM_FILL_COLOR = 10011046; + + private static final int EXPECTED_CUSTOM_FONT_HEIGHT = 16; + + private static final int EXPECTED_FONT_COLOR = 0; + + private static final int EXPECTED_LINE_COLOR = 11579568; + + private static final int EXPECTED_FILL_COLOR = 16777215; + + private static final int EXPECTED_FONT_HEIGHT = 8; + + @Override + protected void onSetUpBeforeClosingWelcomePage() throws Exception { + copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE); + } + + @Override + protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { + + sessionAirdResource = new UIResource(designerProject, "/", SESSION_FILE); + localSession = designerPerspective.openSessionFromFile(sessionAirdResource); + + // Open the editor + editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), "Entities", " package entities", DDiagram.class); + } + + /** + * Tests that the Copy Appearance Action works as expected with several + * element selected. In this case, the custom style element is the first + * selected one and it should have the same style than the last selection + * after the action execution. + */ + public void testSeveralSelectedElementWithFirstSelectionWithTabbar() { + testSeveralSelectedElementWithFirstSelection(true); + } + + /** + * Tests that the Copy Appearance Action works as expected with several + * element selected. In this case, the custom style element is the first + * selected one and it should have the same style than the last selection + * after the action execution. + */ + public void testSeveralSelectedElementWithFirstSelectionWithContextMenu() { + testSeveralSelectedElementWithFirstSelection(false); + } + + /** + * Tests that the Copy Appearance Action works as expected with several + * element selected. In this case, the custom style element is the last + * selected one and other elements should have the same style than the + * custom one. + */ + public void testSeveralSelectedElementWithLastSelectionWithTabbar() { + testSeveralSelectedElementWithLastSelection(true); + + } + + /** + * Tests that the Copy Appearance Action works as expected with several + * element selected. In this case, the custom style element is the last + * selected one and other elements should have the same style than the + * custom one. + */ + public void testSeveralSelectedElementWithLastSelectionWithContextMenu() { + testSeveralSelectedElementWithLastSelection(false); + + } + + private void testSeveralSelectedElementWithFirstSelection(boolean useTabbar) { + SWTBotGefEditPart eClass1BotGefEditPart = editor.getEditPart("NewEClass1", AbstractDiagramElementContainerEditPart.class); + checkCustomStyle(eClass1BotGefEditPart); + + SWTBotGefEditPart eClass2BotGefEditPart = editor.getEditPart("NewEClass2", AbstractDiagramElementContainerEditPart.class); + checkStyleBeforeCustom(eClass2BotGefEditPart); + SWTBotGefEditPart eClass3BotGefEditPart = editor.getEditPart("NewEClass3", AbstractDiagramElementContainerEditPart.class); + checkStyleBeforeCustom(eClass3BotGefEditPart); + editor.select(eClass1BotGefEditPart, eClass2BotGefEditPart, eClass3BotGefEditPart); + performAction(useTabbar); + SWTBotUtils.waitAllUiEvents(); + checkStyleBeforeCustom(eClass1BotGefEditPart); + checkStyleBeforeCustom(eClass2BotGefEditPart); + checkStyleBeforeCustom(eClass3BotGefEditPart); + } + + private void performAction(boolean useTabbar) { + if (useTabbar) { + editor.bot().toolbarButtonWithTooltip(Messages.SiriusCopyAppearancePropertiesAction_tooltipMessage).click(); + } else { + editor.clickContextMenu(DiagramUIActionsMessages.CopyAppearancePropertiesAction_text); + } + } + + private void testSeveralSelectedElementWithLastSelection(boolean useTabbar) { + SWTBotGefEditPart eClass1BotGefEditPart = editor.getEditPart("NewEClass1", AbstractDiagramElementContainerEditPart.class); + checkCustomStyle(eClass1BotGefEditPart); + + SWTBotGefEditPart eClass2BotGefEditPart = editor.getEditPart("NewEClass2", AbstractDiagramElementContainerEditPart.class); + checkStyleBeforeCustom(eClass2BotGefEditPart); + SWTBotGefEditPart eClass3BotGefEditPart = editor.getEditPart("NewEClass3", AbstractDiagramElementContainerEditPart.class); + checkStyleBeforeCustom(eClass3BotGefEditPart); + editor.select(eClass2BotGefEditPart, eClass3BotGefEditPart, eClass1BotGefEditPart); + + performAction(useTabbar); + SWTBotUtils.waitAllUiEvents(); + checkCustomStyle(eClass1BotGefEditPart); + checkCustomStyle(eClass2BotGefEditPart); + checkCustomStyle(eClass3BotGefEditPart); + } + + private void checkCustomStyle(SWTBotGefEditPart botGefEditPart) { + EditPart editPart = botGefEditPart.part(); + Node model = (Node) editPart.getModel(); + ShapeStyle shapeStyle = (ShapeStyle) model.getStyles().get(0); + assertEquals("Wrong expected fill color.", EXPECTED_CUSTOM_FILL_COLOR, shapeStyle.getFillColor()); + assertEquals("Wrong expected font height", EXPECTED_CUSTOM_FONT_HEIGHT, shapeStyle.getFontHeight()); + assertEquals("Wrong expected font color", EXPECTED_CUSTOM_FONT_COLOR, shapeStyle.getFontColor()); + assertEquals("Wrong expected line color", EXPECTED_CUSTOM_LINE_COLOR, shapeStyle.getLineColor()); + } + + private void checkStyleBeforeCustom(SWTBotGefEditPart botGefEditPart) { + EditPart editPart = botGefEditPart.part(); + Node model = (Node) editPart.getModel(); + ShapeStyle shapeStyle = (ShapeStyle) model.getStyles().get(0); + assertEquals("Wrong expected fill color.", EXPECTED_FILL_COLOR, shapeStyle.getFillColor()); + assertEquals("Wrong expected font height", EXPECTED_FONT_HEIGHT, shapeStyle.getFontHeight()); + assertEquals("Wrong expected font color", EXPECTED_FONT_COLOR, shapeStyle.getFontColor()); + assertEquals("Wrong expected line color", EXPECTED_LINE_COLOR, shapeStyle.getLineColor()); + } +} |
