Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-03-27 16:24:29 +0000
committerCamille Letavernier2014-03-27 16:24:29 +0000
commit8219c110e97ae2b3be22738cf470a3e4281c4a73 (patch)
treef0d24ce0d267427333b38d0bc608ed3851a2fdd8 /tests/junit/plugins/infra
parent1eb28d11e147be4960464706bf4977277889c6aa (diff)
downloadorg.eclipse.papyrus-8219c110e97ae2b3be22738cf470a3e4281c4a73.tar.gz
org.eclipse.papyrus-8219c110e97ae2b3be22738cf470a3e4281c4a73.tar.xz
org.eclipse.papyrus-8219c110e97ae2b3be22738cf470a3e4281c4a73.zip
431366: [CSS] The CSS Theme is not taken into account when the model is
deployed in a plug-in https://bugs.eclipse.org/bugs/show_bug.cgi?id=431366 - Fix the ProjectCSSEngine - Fix the showCompartmentTitle test (Don't use Commands as there is no EditingDomain)
Diffstat (limited to 'tests/junit/plugins/infra')
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.notation14
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.uml2
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/compartments.css4
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java22
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java31
5 files changed, 47 insertions, 26 deletions
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.notation b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.notation
index 6fa635f903c..d76d49cb8c9 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.notation
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.notation
@@ -1,5 +1,5 @@
<?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:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML">
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML">
<notation:Diagram xmi:id="_4EGG0ImVEeOGN4dVepS-Uw" type="PapyrusUMLClassDiagram" name="compartments" measurementUnit="Pixel">
<children xmi:type="notation:Shape" xmi:id="_Cz4qUImWEeOGN4dVepS-Uw" type="2008">
<children xmi:type="notation:DecorationNode" xmi:id="_Cz4qUomWEeOGN4dVepS-Uw" type="5029"/>
@@ -166,7 +166,7 @@
<styles xmi:type="notation:FilteringStyle" xmi:id="_61R_nImWEeOGN4dVepS-Uw"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_61R_nYmWEeOGN4dVepS-Uw"/>
</children>
- <children xmi:type="notation:BasicCompartment" xmi:id="_61R_nomWEeOGN4dVepS-Uw" type="7019">
+ <children xmi:type="notation:BasicCompartment" xmi:id="_61R_nomWEeOGN4dVepS-Uw" visible="false" type="7019">
<styles xmi:type="notation:TitleStyle" xmi:id="_61R_n4mWEeOGN4dVepS-Uw"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_61R_oImWEeOGN4dVepS-Uw"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_61R_oYmWEeOGN4dVepS-Uw"/>
@@ -202,12 +202,12 @@
<children xmi:type="notation:Shape" xmi:id="_Tfr8cYmaEeOGN4dVepS-Uw" type="2012">
<children xmi:type="notation:DecorationNode" xmi:id="_Tfr8c4maEeOGN4dVepS-Uw" type="5038"/>
<element xmi:type="uml:Comment" href="model.uml#_Tfr8cImaEeOGN4dVepS-Uw"/>
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Tfr8comaEeOGN4dVepS-Uw" x="852" y="85" width="167"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Tfr8comaEeOGN4dVepS-Uw" x="997" y="72" width="167"/>
</children>
<children xmi:type="notation:Shape" xmi:id="_TlMukYmaEeOGN4dVepS-Uw" type="2012">
<children xmi:type="notation:DecorationNode" xmi:id="_TlV4gImaEeOGN4dVepS-Uw" type="5038"/>
<element xmi:type="uml:Comment" href="model.uml#_TlMukImaEeOGN4dVepS-Uw"/>
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_TlMukomaEeOGN4dVepS-Uw" x="859" y="248" width="149"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_TlMukomaEeOGN4dVepS-Uw" x="881" y="248" width="149"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_4EGG0YmVEeOGN4dVepS-Uw"/>
<styles xmi:type="notation:EObjectListValueStyle" xmi:id="_OgIPAImWEeOGN4dVepS-Uw" name="css_stylesheets" eObjectListValue="_OgIPAYmWEeOGN4dVepS-Uw"/>
@@ -239,16 +239,20 @@
<styles xmi:type="notation:FontStyle" xmi:id="_YgJloYmaEeOGN4dVepS-Uw"/>
<element xsi:nil="true"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_YgJloomaEeOGN4dVepS-Uw" points="[-74, -6, 126, 1]$[-192, 45, 8, 52]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_yWTbwLXCEeOtu7CRWiD6kg" id="(0.0,0.4)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_yWTbwbXCEeOtu7CRWiD6kg" id="(1.0,0.56)"/>
</edges>
<edges xmi:type="notation:Connector" xmi:id="_Y5mAYImaEeOGN4dVepS-Uw" type="4013" source="_Tfr8cYmaEeOGN4dVepS-Uw" target="_DZrfAYmWEeOGN4dVepS-Uw">
<styles xmi:type="notation:FontStyle" xmi:id="_Y5mAYYmaEeOGN4dVepS-Uw"/>
<element xsi:nil="true"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Y5mAYomaEeOGN4dVepS-Uw" points="[-83, -1, 122, -8]$[-198, -48, 7, -55]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_yOHJELXCEeOtu7CRWiD6kg" id="(0.0,0.47)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_yOHJEbXCEeOtu7CRWiD6kg" id="(1.0,0.5)"/>
</edges>
</notation:Diagram>
<notation:Diagram xmi:id="_8JDKAImVEeOGN4dVepS-Uw" type="PapyrusUMLClassDiagram" name="labels" measurementUnit="Pixel">
<styles xmi:type="notation:DiagramStyle" xmi:id="_8JDKAYmVEeOGN4dVepS-Uw"/>
<element xmi:type="uml:Model" href="model.uml#_4DWgNImVEeOGN4dVepS-Uw"/>
</notation:Diagram>
- <css:StyleSheetReference xmi:id="_OgIPAYmWEeOGN4dVepS-Uw" path="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/compartments.css"/>
+ <css:StyleSheetReference xmi:id="_OgIPAYmWEeOGN4dVepS-Uw" path="../../stylesheets/compartments.css"/>
</xmi:XMI>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.uml b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.uml
index b356eaf5ce0..d1eaf6c61a4 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.uml
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/compartmentsTest/model.uml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<uml:Model xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_4DWgNImVEeOGN4dVepS-Uw" name="CSSTests">
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_4DWgNImVEeOGN4dVepS-Uw" name="CSSTests">
<ownedComment xmi:type="uml:Comment" xmi:id="__TiJAImVEeOGN4dVepS-Uw">
<body>Test model for CSS in Luna >= M5 (Compartments, Labels)</body>
</ownedComment>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/compartments.css b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/compartments.css
index fe0cb1f18a7..d38b353f6f8 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/compartments.css
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/compartments.css
@@ -33,7 +33,3 @@ Enumeration > Compartment {
Enumeration > Compartment[kind=LiteRalS]{ /* Case insensitive */
collapsed: false;
}
-
-Compartment {
- showTitle: true;
-}
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java
index ee6096aa813..553f738b70e 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSCompartmentsTests.java
@@ -17,6 +17,7 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
@@ -26,12 +27,13 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
import org.eclipse.gmf.runtime.notation.BasicCompartment;
import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.gmf.runtime.notation.StringListValueStyle;
import org.eclipse.gmf.runtime.notation.TitleStyle;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableList;
import org.eclipse.papyrus.infra.gmfdiag.css.helper.CSSHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.helper.ResetStyleHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
@@ -155,8 +157,7 @@ public class CSSCompartmentsTests extends AbstractPapyrusTest {
}
//We need an editingDomain for the ResetStyle operation
- TransactionalEditingDomain domain = new TransactionalEditingDomainImpl(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE), diagram.eResource().getResourceSet());
- diagram.eResource().getResourceSet().eAdapters().add(new AdapterFactoryEditingDomain.EditingDomainProvider(domain));
+ createAndAttachEditingDomain(diagram);
//Test resetStyle
ResetStyleHelper.resetStyle(Collections.singleton(class3));
@@ -180,14 +181,17 @@ public class CSSCompartmentsTests extends AbstractPapyrusTest {
for(View compartment : (List<View>)childNode.getChildren()) {
if(compartment instanceof BasicCompartment) {
TitleStyle titleStyle = (TitleStyle)compartment.getStyle(NotationPackage.eINSTANCE.getTitleStyle());
- Assert.assertFalse("Title should be hidden", titleStyle.isShowTitle());
+ Assert.assertFalse("Title should be hidden for " + childNode + ", " + compartment, titleStyle.isShowTitle());
}
}
}
//Apply style
- CustomStringStyleObservableList stylesList = new CustomStringStyleObservableList(diagram, null, "cssClass");
- stylesList.add("showTitleForAllCompartments");
+ StringListValueStyle stylesList = (StringListValueStyle)diagram.getNamedStyle(NotationPackage.eINSTANCE.getStringListValueStyle(), "cssClass");
+ if(stylesList == null) {
+ stylesList = NotationFactory.eINSTANCE.createStringListValueStyle();
+ }
+ stylesList.getStringListValue().add("showTitleForAllCompartments");
//Check that all titles are visible
for(View childNode : (List<View>)diagram.getChildren()) {
@@ -198,8 +202,14 @@ public class CSSCompartmentsTests extends AbstractPapyrusTest {
}
}
}
+
}
+ protected static TransactionalEditingDomain createAndAttachEditingDomain(EObject element) {
+ TransactionalEditingDomain domain = new TransactionalEditingDomainImpl(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE), element.eResource().getResourceSet());
+ element.eResource().getResourceSet().eAdapters().add(new AdapterFactoryEditingDomain.EditingDomainProvider(domain));
+ return domain;
+ }
@After
public void dispose() {
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java
index 0c1efe15355..758a702b244 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -22,15 +22,19 @@ import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.GradientStyle;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.css.engine.WorkspaceCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.helper.CSSHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
+import org.eclipse.papyrus.infra.gmfdiag.css.preferences.ThemePreferences;
import org.eclipse.papyrus.infra.gmfdiag.css.tests.Activator;
import org.eclipse.uml2.uml.NamedElement;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
@@ -38,6 +42,13 @@ public class CSSStylesheetTest {
private CSSDiagram diagram;
+ @BeforeClass
+ public static void initCSSTheme() {
+ IPreferenceStore cssThemePreferences = org.eclipse.papyrus.infra.gmfdiag.css.Activator.getDefault().getPreferenceStore();
+ cssThemePreferences.setValue(ThemePreferences.CURRENT_THEME, "org.eclipse.papyrus.css.papyrus_theme");
+ WorkspaceCSSEngine.instance.reset();
+ }
+
@Before
public void init() {
ResourceSet resourceSet = new ResourceSetImpl();
@@ -63,25 +74,25 @@ public class CSSStylesheetTest {
Assert.assertEquals("Invalid color", rgb(255, 0, 0), classView.getFillColor()); //Red = #FF0000
Assert.assertNull("Invalid gradient", classView.getGradient());
- Assert.assertTrue(AppearanceHelper.showElementIcon(classView));
+ Assert.assertTrue("The element icon should be displayed", AppearanceHelper.showElementIcon(classView));
}
@Test
public void testInterfaceStyle() {
Shape interfaceView = findShape("Interface1");
- Assert.assertNotNull(interfaceView.getGradient());
- Assert.assertEquals(rgb(255, 255, 0), interfaceView.getFillColor()); //Yellow = #FFFF00
- Assert.assertEquals(rgb(255, 0, 0), interfaceView.getGradient().getGradientColor1()); //Red = #FF0000
- Assert.assertEquals(GradientStyle.VERTICAL, interfaceView.getGradient().getGradientStyle());
- Assert.assertTrue(AppearanceHelper.showElementIcon(interfaceView));
+ Assert.assertNotNull("The interface should have a gradient", interfaceView.getGradient());
+ Assert.assertEquals("The fill color should be yellow", rgb(255, 255, 0), interfaceView.getFillColor()); //Yellow = #FFFF00
+ Assert.assertEquals("The gradient should be red", rgb(255, 0, 0), interfaceView.getGradient().getGradientColor1()); //Red = #FF0000
+ Assert.assertEquals("The gradient should be vertical", GradientStyle.VERTICAL, interfaceView.getGradient().getGradientStyle());
+ Assert.assertTrue("The element icon should be displayed", AppearanceHelper.showElementIcon(interfaceView));
}
@Test
public void testCSSClassStyle() {
Shape interfaceView = findShape("Interface2");
- Assert.assertNotNull(interfaceView.getGradient());
- Assert.assertEquals(rgb(144, 238, 144), interfaceView.getFillColor()); //Lightgreen = #90EE90
+ Assert.assertNotNull("The interface should have a gradient", interfaceView.getGradient());
+ Assert.assertEquals("The fill color should be light green (#90EE90)", rgb(144, 238, 144), interfaceView.getFillColor()); //Lightgreen = #90EE90
//Case insensitive color name
Assert.assertEquals(rgb(0, 191, 255), interfaceView.getGradient().getGradientColor1()); //DeepSkyBlue = #00BFFF
@@ -108,7 +119,7 @@ public class CSSStylesheetTest {
//.myClass : Low priority
//.myClass.myOtherClass : Highest priority
//[isAbstract=true] : Medium priority
- //Styles should also be merged when they aren't conflicting (ie. [isAbstract] + .myClass -> fontName = Tunga)
+ //Styles should also be merged when they aren't conflicting (ie. [isAbstract] + .myClass -> fontName = Tunga)
Shape class3 = findShape("Class3");
Shape class5 = findShape("Class5");

Back to the top