Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2015-05-20 15:29:06 +0000
committerPierre-Charles David2015-05-22 11:26:29 +0000
commit58f7eb77baad2ab05b079c60bedad3a9d382aef6 (patch)
tree08c1cdc5b52d10a2da21ac66b13a045d11461114
parenta0503359ced66e4055e849572f0a83ce4b82a133 (diff)
downloadorg.eclipse.sirius-58f7eb77baad2ab05b079c60bedad3a9d382aef6.tar.gz
org.eclipse.sirius-58f7eb77baad2ab05b079c60bedad3a9d382aef6.tar.xz
org.eclipse.sirius-58f7eb77baad2ab05b079c60bedad3a9d382aef6.zip
[424422] Add tests for table and tree editors.
Diagram editor is already tested with org.eclipse.sirius.tests.swtbot.LabelFontModificationsTest Bug: 424422 Change-Id: I3969ed05c0b2ee20dc3e3ec3f4dcfe5cf1c66b20 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java18
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java32
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java33
3 files changed, 83 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java
index c416a48182..51f5bfddfc 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/TreeItemLabelFontFormatQuery.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
import org.eclipse.sirius.viewpoint.FontFormat;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.TreeItem;
@@ -68,6 +69,7 @@ public class TreeItemLabelFontFormatQuery extends RunnableWithResult.Impl<List<F
@Override
public void run() {
List<FontFormat> treeItemLabelFormat = new ArrayList<FontFormat>();
+ // Search italic and bold status in FontData
Font font = treeItem.getFont(index);
FontData[] fontData = font.getFontData();
if (fontData.length > 0) {
@@ -87,6 +89,22 @@ public class TreeItemLabelFontFormatQuery extends RunnableWithResult.Impl<List<F
break;
}
}
+ // Search underline and strike through status in StyleRange
+ // Use a constant originally computed with private method
+ // org.eclipse.jface.viewers.ViewerRow.getStyleRangesDataKey(int)
+ String dataKey = "org.eclipse.jfacestyled_label_key_" + index;
+ Object styledData = treeItem.getData(dataKey);
+ if (styledData != null) {
+ StyleRange[] styledDataArray = (StyleRange[]) styledData;
+ StyleRange styleRange = styledDataArray[0];
+ if (styleRange.strikeout) {
+ FontFormatHelper.setFontFormat(treeItemLabelFormat, FontFormat.STRIKE_THROUGH_LITERAL);
+ }
+ if (styleRange.underline) {
+ FontFormatHelper.setFontFormat(treeItemLabelFormat, FontFormat.UNDERLINE_LITERAL);
+ }
+ }
+
setResult(treeItemLabelFormat);
}
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java
index b8cb314475..c8aa711891 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableUIRefreshTests.java
@@ -283,6 +283,38 @@ public class TableUIRefreshTests extends AbstractTreeSiriusSWTBotGefTestCase {
redo("Set Label Format");
TreeUtils.checkTreeItemLabelFormat(tableEditorBot, firstDCellOfSecondDLine);
+
+ // Test a the underline font format
+ labelFormat = new ArrayList<FontFormat>();
+ FontFormatHelper.setFontFormat(labelFormat, FontFormat.UNDERLINE_LITERAL);
+ changeDTreeItemLabelStyleCmd = SetCommand.create(transactionalEditingDomain, dTableElementStyle, TablePackage.Literals.DTABLE_ELEMENT_STYLE__LABEL_FORMAT, labelFormat);
+ commandStack.execute(changeDTreeItemLabelStyleCmd);
+
+ TreeUtils.checkTreeItemLabelFormat(tableEditorBot, firstDCellOfSecondDLine);
+
+ undo("Set Label Format");
+
+ TreeUtils.checkTreeItemLabelFormat(tableEditorBot, firstDCellOfSecondDLine);
+
+ redo("Set Label Format");
+
+ TreeUtils.checkTreeItemLabelFormat(tableEditorBot, firstDCellOfSecondDLine);
+
+ // Test a the strike through font format
+ labelFormat = new ArrayList<FontFormat>();
+ FontFormatHelper.setFontFormat(labelFormat, FontFormat.STRIKE_THROUGH_LITERAL);
+ changeDTreeItemLabelStyleCmd = SetCommand.create(transactionalEditingDomain, dTableElementStyle, TablePackage.Literals.DTABLE_ELEMENT_STYLE__LABEL_FORMAT, labelFormat);
+ commandStack.execute(changeDTreeItemLabelStyleCmd);
+
+ TreeUtils.checkTreeItemLabelFormat(tableEditorBot, firstDCellOfSecondDLine);
+
+ undo("Set Label Format");
+
+ TreeUtils.checkTreeItemLabelFormat(tableEditorBot, firstDCellOfSecondDLine);
+
+ redo("Set Label Format");
+
+ TreeUtils.checkTreeItemLabelFormat(tableEditorBot, firstDCellOfSecondDLine);
}
/**
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java
index 6d02885718..904421be70 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeUIRefreshTests.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper;
+import org.eclipse.sirius.table.metamodel.table.TablePackage;
import org.eclipse.sirius.tests.swtbot.Activator;
import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource;
import org.eclipse.sirius.tests.swtbot.support.api.business.UITreeRepresentation;
@@ -269,6 +270,38 @@ public class TreeUIRefreshTests extends AbstractTreeSiriusSWTBotGefTestCase {
redo("Set Label Format");
TreeUtils.checkTreeItemLabelFormat(treeEditorBot, thirdDTreeItem);
+
+ // Test a the underline font format
+ labelFormat = new ArrayList<FontFormat>();
+ FontFormatHelper.setFontFormat(labelFormat, FontFormat.UNDERLINE_LITERAL);
+ changeDTreeItemLabelStyleCmd = SetCommand.create(transactionalEditingDomain, treeItemStyle, TablePackage.Literals.DTABLE_ELEMENT_STYLE__LABEL_FORMAT, labelFormat);
+ commandStack.execute(changeDTreeItemLabelStyleCmd);
+
+ TreeUtils.checkTreeItemLabelFormat(treeEditorBot, secondDTreeItem);
+
+ undo("Set Label Format");
+
+ TreeUtils.checkTreeItemLabelFormat(treeEditorBot, secondDTreeItem);
+
+ redo("Set Label Format");
+
+ TreeUtils.checkTreeItemLabelFormat(treeEditorBot, secondDTreeItem);
+
+ // Test a the strike through font format
+ labelFormat = new ArrayList<FontFormat>();
+ FontFormatHelper.setFontFormat(labelFormat, FontFormat.STRIKE_THROUGH_LITERAL);
+ changeDTreeItemLabelStyleCmd = SetCommand.create(transactionalEditingDomain, treeItemStyle, TablePackage.Literals.DTABLE_ELEMENT_STYLE__LABEL_FORMAT, labelFormat);
+ commandStack.execute(changeDTreeItemLabelStyleCmd);
+
+ TreeUtils.checkTreeItemLabelFormat(treeEditorBot, secondDTreeItem);
+
+ undo("Set Label Format");
+
+ TreeUtils.checkTreeItemLabelFormat(treeEditorBot, secondDTreeItem);
+
+ redo("Set Label Format");
+
+ TreeUtils.checkTreeItemLabelFormat(treeEditorBot, secondDTreeItem);
}
/**

Back to the top