diff options
| author | Laurent Redor | 2015-10-01 15:26:09 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-11-12 16:33:49 +0000 |
| commit | 4280a8f7e4bcd9898ce74b5f532e4b8f0f9dc31c (patch) | |
| tree | c7d3925058a967dc93c8d73e1979cdec732264e3 | |
| parent | 72ec5371a20c52a06b678ab497eeecdb310f40cf (diff) | |
| download | org.eclipse.sirius-4280a8f7e4bcd9898ce74b5f532e4b8f0f9dc31c.tar.gz org.eclipse.sirius-4280a8f7e4bcd9898ce74b5f532e4b8f0f9dc31c.tar.xz org.eclipse.sirius-4280a8f7e4bcd9898ce74b5f532e4b8f0f9dc31c.zip | |
[478802] Fix tests of RefreshWithCustomizedStyleTests
The tests of RefreshWithCustomizedStyleTests were KO but they were not
really launched because of a wrong condition on "fixed tabbar".
This commit:
* "Activates" all tests
* Fixes pb concerning Color customization
* Fixes pb concerning Font label format (Bold, Italic, ...)
* Allows to check the fix of bug 478802.
* Fixes a problem about StylePropertySection: the label color is not
correctly propagated to GMF font color attribute.
Bug: 478802
Change-Id: Ibfe9dd765fa68d0208d311a85b398e00dbb3a947
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
3 files changed, 89 insertions, 49 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java index b65e036205..02e0871642 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/StylePropertySection.java @@ -21,6 +21,7 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.provider.IItemPropertySource; import org.eclipse.emf.edit.ui.provider.PropertySource; import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; import org.eclipse.gmf.runtime.notation.ConnectorStyle; import org.eclipse.gmf.runtime.notation.FontStyle; import org.eclipse.gmf.runtime.notation.Routing; @@ -38,6 +39,7 @@ import org.eclipse.sirius.viewpoint.RGBValues; import org.eclipse.sirius.viewpoint.SiriusPlugin; import org.eclipse.sirius.viewpoint.Style; import org.eclipse.sirius.viewpoint.ViewpointPackage; +import org.eclipse.swt.graphics.RGB; import org.eclipse.ui.views.properties.IPropertySource; /** @@ -245,8 +247,11 @@ public class StylePropertySection extends SemanticPropertySection { fontStyle.setUnderline(false); fontStyle.setStrikeThrough(false); } - } else if (value instanceof Integer && propertyId.equals(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE.getName())) { + } else if (value instanceof Integer && ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE.getName().equals(propertyId)) { fontStyle.setFontHeight(Math.max((Integer) value, 1)); + } else if (value instanceof RGBValues && ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_COLOR.getName().equals(propertyId)) { + RGBValues rgbValues = (RGBValues) value; + fontStyle.setFontColor(FigureUtilities.RGBToInteger(new RGB(rgbValues.getRed(), rgbValues.getGreen(), rgbValues.getBlue()))); } } else if (notationStyle instanceof ConnectorStyle) { ConnectorStyle connectorStyle = (ConnectorStyle) notationStyle; diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java index 3a59d0149d..390527515e 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleOnCompleteExampleTest.java @@ -71,17 +71,16 @@ import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.TextAlignment; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.gmf.runtime.notation.datatype.GradientData; +import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper; import org.eclipse.sirius.common.tools.api.resource.FileProvider; import org.eclipse.sirius.common.tools.api.util.ReflectionHelper; import org.eclipse.sirius.diagram.AlignmentKind; -import org.eclipse.sirius.diagram.BracketEdgeStyle; import org.eclipse.sirius.diagram.BundledImageShape; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.DDiagramElement; import org.eclipse.sirius.diagram.DiagramPackage; import org.eclipse.sirius.diagram.EdgeArrows; import org.eclipse.sirius.diagram.EdgeRouting; -import org.eclipse.sirius.diagram.EdgeStyle; import org.eclipse.sirius.diagram.GaugeCompositeStyle; import org.eclipse.sirius.diagram.LabelPosition; import org.eclipse.sirius.diagram.LineStyle; @@ -219,6 +218,7 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs /** * {@inheritDoc} */ + @Override protected void onSetUpAfterOpeningDesignerPerspective() throws Exception { super.onSetUpAfterOpeningDesignerPerspective(); @@ -254,9 +254,9 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs return feature instanceof EReference && ((EReference) feature).isContainment(); } - protected void resetStylePropertiesToDefault(SWTBotGefEditPart swtBotGefEditPart) { + protected void resetStylePropertiesToDefault(SWTBotGefEditPart swtBotGefEditPart, boolean launchResetFromTabbar) { swtBotGefEditPart.select(); - AbstractSWTBot<? extends Widget> resetStylePropertiesToDefaultButton = getResetStylePropertiesToDefaultValuesButton(true, true); + AbstractSWTBot<? extends Widget> resetStylePropertiesToDefaultButton = getResetStylePropertiesToDefaultValuesButton(launchResetFromTabbar, true); click(resetStylePropertiesToDefaultButton); editor.setFocus(); editor.scrollTo(0, 0); @@ -264,6 +264,7 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs SWTBotUtils.waitAllUiEvents(); } + @Override protected void click(AbstractSWTBot<? extends Widget> button) { button.setFocus(); if (button instanceof SWTBotToolbarButton) { @@ -300,12 +301,6 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs if (category == null) { category = "Misc"; } - if (style instanceof EdgeStyle) { - category = "Edge Style solid"; - if (style instanceof BracketEdgeStyle) { - category = "Bracket Edge Style solid"; - } - } String displayName = propertyDescriptor.getDisplayName(style); Object propertyValue = propertyDescriptor.getPropertyValue(style); Object value = null; @@ -319,7 +314,13 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs SWTBotTreeItem treeItem = tree.expandNode(category).select().getNode(displayName); treeItem.doubleClick(); if (feature instanceof EAttribute) { - if (feature.getEType() instanceof EEnum && value instanceof Enumerator) { + if (feature.getEType() instanceof EEnum && value instanceof List && ((List) value).isEmpty()) { + // For label format, we make the change from tabbar (more + // simple)... + editor.setFocus(); + editor.bot().toolbarToggleButtonWithTooltip("Bold Font Style").click(); + SWTBotUtils.waitAllUiEvents(); + } else if (feature.getEType() instanceof EEnum && value instanceof Enumerator) { SWTBotCCombo ccomboBox = propertiesBot.bot().ccomboBox(); Enumerator newValueLiteral = getNewValueLiteral(value, choiceOfValues); String text = propertyDescriptor.getLabelProvider(style).getText(newValueLiteral); @@ -333,6 +334,12 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs ccomboBox.setSelection(newSelection); } else if (feature == ViewpointPackage.Literals.BASIC_LABEL_STYLE__ICON_PATH) { propertiesBot.bot().text().setText("/" + getProjectName() + "/" + NEW_IMAGE_NAME); + } else if (feature == ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_COLOR || feature == DiagramPackage.Literals.BORDERED_STYLE__BORDER_COLOR + || feature == DiagramPackage.Literals.SHAPE_CONTAINER_STYLE__BACKGROUND_COLOR || feature == DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR + || feature == DiagramPackage.Literals.FLAT_CONTAINER_STYLE__FOREGROUND_COLOR || feature == DiagramPackage.Literals.ELLIPSE__COLOR + || feature == DiagramPackage.Literals.SQUARE__COLOR || feature == DiagramPackage.Literals.DOT__BACKGROUND_COLOR || feature == DiagramPackage.Literals.EDGE_STYLE__STROKE_COLOR + || feature == DiagramPackage.Literals.NOTE__COLOR || feature == DiagramPackage.Literals.BUNDLED_IMAGE__COLOR || feature == DiagramPackage.Literals.LOZENGE__COLOR) { + propertiesBot.bot().text().setText("100,100,100"); } else if (feature == DiagramPackage.Literals.BORDERED_STYLE__BORDER_SIZE_COMPUTATION_EXPRESSION) { // FIXME VP-3559 : the customization of borderSize // doesn't works because the @@ -391,7 +398,7 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs customized = true; } } else if (gmfStyleEAttribute == NotationPackage.Literals.FILL_STYLE__TRANSPARENCY) { - // FIXME : the transparancy doesn't works for TextEditPart + // FIXME : the transparency doesn't works for TextEditPart if (!(swtBotGefEditPart.part() instanceof TextEditPart)) { int transparancy = (Integer) gmfStyle.eGet(gmfStyleEAttribute); TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(gmfStyle); @@ -655,8 +662,9 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs } else if (feature == DiagramPackage.Literals.EDGE_STYLE__ROUTING_STYLE) { EdgeRouting edgeRouting = (EdgeRouting) viewpointStyle.eGet(feature); EdgeRouting figureEdgeRouting = getFigureEdgeRouting(swtBotGefEditPart); - // assertEquals("The edge routing of the figure should corresponds to the edgeRouting feature value of the customized style", - // edgeRouting, figureEdgeRouting); + // assertEquals("The edge routing of the figure should + // corresponds to the edgeRouting feature value of the + // customized style", edgeRouting, figureEdgeRouting); // FIXME : changing the routingStyle:EdgeRouting doesn't update // the GMF routing the neither the figure connection router } else if (feature == DiagramPackage.Literals.NOTE__COLOR) { @@ -736,8 +744,9 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs TextAlignment textAlignment = (TextAlignment) gmfStyle.eGet(feature); TextAlignment figureTextAlignment = getFigureTextAlignment(swtBotGefEditPart); // FIXME : TextAlignment change doesn't works - // assertEquals("The textAlignment of the figure font should corresponds to the textAlignment feature value of the customized GMF style", - // textAlignment, figureTextAlignment); + // assertEquals("The textAlignment of the figure font should + // corresponds to the textAlignment feature value of the customized + // GMF style", textAlignment, figureTextAlignment); } else if (feature == NotationPackage.Literals.DESCRIPTION_STYLE__DESCRIPTION) { String description = (String) gmfStyle.eGet(feature); String figureDescription = getFigureNoteDescription(swtBotGefEditPart); @@ -1313,19 +1322,21 @@ public class AbstractRefreshWithCustomizedStyleOnCompleteExampleTest extends Abs List<FontFormat> getFigureFontFormat(Font font) { List<FontFormat> fontFormat = new ArrayList<FontFormat>(); - FontData[] fontData = font.getFontData(); - int swtFontStyle = fontData[0].getStyle(); - if ((SWT.NORMAL & swtFontStyle) != 0) { - fontFormat = null; - } else if ((SWT.BOLD & swtFontStyle) != 0 && (SWT.ITALIC & swtFontStyle) != 0) { - fontFormat.add(FontFormat.BOLD_LITERAL); - fontFormat.add(FontFormat.ITALIC_LITERAL); - } else if ((SWT.ITALIC & swtFontStyle) != 0) { - fontFormat.add(FontFormat.ITALIC_LITERAL); - } else if ((SWT.BOLD & swtFontStyle) != 0) { - fontFormat.add(FontFormat.BOLD_LITERAL); - } else { - fontFormat = null; + if (font.getFontData().length > 0) { + switch (font.getFontData()[0].getStyle()) { + case SWT.BOLD: + FontFormatHelper.setFontFormat(fontFormat, FontFormat.BOLD_LITERAL); + break; + case SWT.ITALIC: + FontFormatHelper.setFontFormat(fontFormat, FontFormat.ITALIC_LITERAL); + break; + case SWT.BOLD | SWT.ITALIC: + FontFormatHelper.setFontFormat(fontFormat, FontFormat.BOLD_LITERAL); + FontFormatHelper.setFontFormat(fontFormat, FontFormat.ITALIC_LITERAL); + break; + default: + break; + } } return fontFormat; } diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java index 36edea8369..bb147dd8ef 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RefreshWithCustomizedStyleTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2015 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 @@ -15,6 +15,7 @@ import java.util.Collection; import java.util.List; import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; @@ -23,6 +24,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; +import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; import org.eclipse.gmf.runtime.notation.FontStyle; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; @@ -37,8 +39,10 @@ import org.eclipse.sirius.diagram.ui.internal.refresh.diagram.ViewPropertiesSync import org.eclipse.sirius.tests.support.api.TestsUtil; import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusHelper; import org.eclipse.sirius.viewpoint.FontFormat; +import org.eclipse.sirius.viewpoint.RGBValues; import org.eclipse.sirius.viewpoint.Style; import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Widget; import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; import org.eclipse.swtbot.swt.finder.SWTBot; @@ -454,18 +458,22 @@ public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomiz } private void testStyleCustomization(SWTBotGefEditPart swtBotGefEditPart) throws Exception { - // Not available in 4.x specific Tabbar - if (TestsUtil.isDynamicTabbar()) { + // Not available in fixed tabbar + if (!TestsUtil.isDynamicTabbar()) { return; } + // Launch tests from properties view (style tab) and cancel + // customization from Appearance tab if (isSiriusElt(swtBotGefEditPart)) { - testSiriusStyleCustomizationFromStyleTab(swtBotGefEditPart); + testSiriusStyleCustomizationFromStyleTab(swtBotGefEditPart, false); } - testGMFStyleCustomization(swtBotGefEditPart); + // Launch tests from properties view (Appearance tab) and cancel + // customization from Tabbar + testGMFStyleCustomization(swtBotGefEditPart, true); } - private void testSiriusStyleCustomizationFromStyleTab(SWTBotGefEditPart swtBotGefEditPart) throws Exception { + private void testSiriusStyleCustomizationFromStyleTab(SWTBotGefEditPart swtBotGefEditPart, boolean launchResetFromTabbar) throws Exception { DDiagramElement dDiagramElement = getDDiagramElement(swtBotGefEditPart); View notationView = ((IGraphicalEditPart) swtBotGefEditPart.part()).getNotationView(); Style viewpointStyle = dDiagramElement.getStyle(); @@ -479,6 +487,10 @@ public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomiz for (String customizableFeatureName : customizableFeatureNames) { EStructuralFeature feature = viewpointStyle.eClass().getEStructuralFeature(customizableFeatureName); Object initialValue = viewpointStyle.eGet(feature); + if (initialValue instanceof BasicEList<?>) { + // Clone the list to avoid a change of it during customization. + initialValue = ((BasicEList<?>) initialValue).clone(); + } if (customizeSiriusStylePropertyFromStyleTab(swtBotGefEditPart, viewpointStyle, feature)) { Object newValue = viewpointStyle.eGet(feature); @@ -499,7 +511,7 @@ public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomiz assertEquals(assertMessage, customizableFeatureName, viewpointStyle.getCustomFeatures().get(0)); // Reset style properties to default values - resetStylePropertiesToDefault(swtBotGefEditPart); + resetStylePropertiesToDefault(swtBotGefEditPart, launchResetFromTabbar); viewpointStyle = dDiagramElement.getStyle(); assertSiriusAndGMFStyleSynchronized(viewpointStyle, notationView); @@ -523,7 +535,7 @@ public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomiz } } - private void testGMFStyleCustomization(SWTBotGefEditPart swtBotGefEditPart) throws Exception { + private void testGMFStyleCustomization(SWTBotGefEditPart swtBotGefEditPart, boolean launchResetFromTabbar) throws Exception { // Test the GMF style properties customization from the Appearance tab // of the property view for (EAttribute gmfStyleEAttribute : ViewQuery.CUSTOMIZABLE_GMF_STYLE_ATTRIBUTES) { @@ -546,7 +558,7 @@ public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomiz checkFigure(swtBotGefEditPart, gmfStyleEAttribute); // Reset style properties to default values - resetStylePropertiesToDefault(swtBotGefEditPart); + resetStylePropertiesToDefault(swtBotGefEditPart, launchResetFromTabbar); correspondingView = (View) swtBotGefEditPart.part().getModel(); gmfStyle = correspondingView.getStyle(gmfStyleEAttribute.getEContainingClass()); @@ -585,20 +597,32 @@ public class RefreshWithCustomizedStyleTests extends AbstractRefreshWithCustomiz } private Object convertToSiriusPropertyValue(org.eclipse.gmf.runtime.notation.Style gmfStyle, EAttribute gmfStyleAttribute) { - List<FontFormat> gmfStylePropertyValue = new ArrayList<FontFormat>(); - if (gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__BOLD || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__ITALIC) { + Object result = null; + if (gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__BOLD || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__ITALIC + || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__UNDERLINE || gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__STRIKE_THROUGH) { + List<FontFormat> gmfStylePropertyValue = new ArrayList<FontFormat>(); FontStyle gmfFontStyle = (FontStyle) gmfStyle; - if (gmfFontStyle.isBold() && gmfFontStyle.isItalic()) { - gmfStylePropertyValue.add(FontFormat.BOLD_LITERAL); - gmfStylePropertyValue.add(FontFormat.ITALIC_LITERAL); - } else if (gmfFontStyle.isBold()) { + if (gmfFontStyle.isBold()) { gmfStylePropertyValue.add(FontFormat.BOLD_LITERAL); - } else if (gmfFontStyle.isItalic()) { + } + if (gmfFontStyle.isItalic()) { gmfStylePropertyValue.add(FontFormat.ITALIC_LITERAL); - } else { - gmfStylePropertyValue = null; } + if (gmfFontStyle.isUnderline()) { + gmfStylePropertyValue.add(FontFormat.UNDERLINE_LITERAL); + } + if (gmfFontStyle.isStrikeThrough()) { + gmfStylePropertyValue.add(FontFormat.STRIKE_THROUGH_LITERAL); + } + result = gmfStylePropertyValue; + } else if (gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__FONT_COLOR) { + RGB rgb = FigureUtilities.integerToRGB((Integer) gmfStyle.eGet(gmfStyleAttribute)); + result = RGBValues.create(rgb.red, rgb.green, rgb.blue); + } else if (gmfStyleAttribute == NotationPackage.Literals.FONT_STYLE__FONT_HEIGHT) { + result = gmfStyle.eGet(gmfStyleAttribute); + } else { + result = gmfStyle.eGet(gmfStyleAttribute); } - return gmfStylePropertyValue; + return result; } } |
