Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2015-02-10 15:07:13 +0000
committerEsteban DUGUEPEROUX2015-02-10 15:27:32 +0000
commit2112bfbd0705ae7f4b957ce785bdc4241275e838 (patch)
tree8b125f0f1ea817fd9d44b4e482bda1f64915f977
parentf0b9dc110ca0369d2ea464aa31994ae6bda2fae4 (diff)
downloadorg.eclipse.sirius-2112bfbd0705ae7f4b957ce785bdc4241275e838.tar.gz
org.eclipse.sirius-2112bfbd0705ae7f4b957ce785bdc4241275e838.tar.xz
org.eclipse.sirius-2112bfbd0705ae7f4b957ce785bdc4241275e838.zip
[458977] Add SWTBot tests about F5 shortcut for refresh in tree/table
TreeRefreshWithF5ShortcutTests and TableRefreshWithF5ShortcutTests SWTBot tests addition. Bug: 458977 Change-Id: Ieba0ee9036bf0406ba8d663e14d4ab359a754af7 Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java11
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TableSwtbotTestSuite.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TreeSwtbotTestSuite.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableRefreshWithF5ShortcutTests.java123
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeRefreshWithF5ShortcutTests.java146
5 files changed, 280 insertions, 4 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java
index a91c88f26c..924949333d 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java
@@ -45,7 +45,9 @@ import org.hamcrest.Matchers;
*/
public final class SWTBotUtils {
- /** 60 seconds of timeout (long timeout but big session can be long to open). */
+ /**
+ * 60 seconds of timeout (long timeout but big session can be long to open).
+ */
public static final long CLOSE_PROGRESS_MONITOR_TIMEOUT = TimeUnit.SECONDS.toSeconds(60);
/**
@@ -85,12 +87,13 @@ public final class SWTBotUtils {
* @param key
* the key to press
*/
- public static void pressKeyboardKey(final Widget widget, final char key) {
+ public static void pressKeyboardKey(final Widget widget, final int key) {
UIThreadRunnable.asyncExec(new VoidResult() {
@Override
public void run() {
- widget.notifyListeners(SWT.KeyDown, SWTBotUtils.keyEvent(SWT.NONE, key, key, widget));
- widget.notifyListeners(SWT.KeyUp, SWTBotUtils.keyEvent(SWT.NONE, key, key, widget));
+ Event event = SWTBotUtils.keyEvent(SWT.NONE, (char) key, key, widget);
+ widget.notifyListeners(SWT.KeyDown, event);
+ widget.notifyListeners(SWT.KeyUp, event);
}
});
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TableSwtbotTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TableSwtbotTestSuite.java
index f42661cbc8..e3120de7ca 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TableSwtbotTestSuite.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TableSwtbotTestSuite.java
@@ -24,6 +24,7 @@ import org.eclipse.sirius.tests.swtbot.table.HideRevealTableLinesTest;
import org.eclipse.sirius.tests.swtbot.table.NavigationDescriptionFromTableAndTreeTest;
import org.eclipse.sirius.tests.swtbot.table.ReadOnlyColumnTest;
import org.eclipse.sirius.tests.swtbot.table.RenameTableRepresentationTest;
+import org.eclipse.sirius.tests.swtbot.table.TableRefreshWithF5ShortcutTests;
import org.eclipse.sirius.tests.swtbot.table.TableUIPermissionAuthorityTests;
import org.eclipse.sirius.tests.swtbot.table.TableUIRefreshTests;
@@ -58,6 +59,7 @@ public class TableSwtbotTestSuite extends TestCase {
suite.addTestSuite(TableUIPermissionAuthorityTests.class);
suite.addTestSuite(TableUIRefreshTests.class);
suite.addTestSuite(DeleteLineWithDELShortcutTest.class);
+ suite.addTestSuite(TableRefreshWithF5ShortcutTests.class);
suite.addTestSuite(NavigationDescriptionFromTableAndTreeTest.class);
suite.addTestSuite(CellEditionTest.class);
suite.addTestSuite(ReadOnlyColumnTest.class);
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TreeSwtbotTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TreeSwtbotTestSuite.java
index e398c077d6..48abfc6002 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TreeSwtbotTestSuite.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/TreeSwtbotTestSuite.java
@@ -28,6 +28,7 @@ import org.eclipse.sirius.tests.swtbot.tree.TreeItemMappingTest;
import org.eclipse.sirius.tests.swtbot.tree.TreeItemPopupMenusTest;
import org.eclipse.sirius.tests.swtbot.tree.TreeItemPopupMenusWithJavaActionTest;
import org.eclipse.sirius.tests.swtbot.tree.TreeItemStyleDescriptionTest;
+import org.eclipse.sirius.tests.swtbot.tree.TreeRefreshWithF5ShortcutTests;
import org.eclipse.sirius.tests.swtbot.tree.TreeUIPermissionAuthorityTests;
import org.eclipse.sirius.tests.swtbot.tree.TreeUIRefreshTests;
@@ -67,6 +68,7 @@ public class TreeSwtbotTestSuite extends TestCase {
suite.addTestSuite(ContextMenuTreeTest.class);
suite.addTestSuite(TreeUIPermissionAuthorityTests.class);
suite.addTestSuite(TreeUIRefreshTests.class);
+ suite.addTestSuite(TreeRefreshWithF5ShortcutTests.class);
suite.addTestSuite(DisplayLabelOnNodeTest.class);
return suite;
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableRefreshWithF5ShortcutTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableRefreshWithF5ShortcutTests.java
new file mode 100644
index 0000000000..1377f0d0ab
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/TableRefreshWithF5ShortcutTests.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.table;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
+import org.eclipse.sirius.table.metamodel.table.DLine;
+import org.eclipse.sirius.table.metamodel.table.DTable;
+import org.eclipse.sirius.table.ui.tools.api.editor.DTableEditor;
+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;
+import org.eclipse.sirius.tests.swtbot.support.api.condition.OperationDoneCondition;
+import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
+import org.eclipse.sirius.tests.swtbot.tree.AbstractTreeSiriusSWTBotGefTestCase;
+import org.eclipse.sirius.tests.unit.diagram.modeler.ecore.EcoreModeler;
+import org.eclipse.sirius.ui.business.api.preferences.SiriusUIPreferencesKeys;
+import org.eclipse.swt.SWT;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+/**
+ * Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=458977 .
+ *
+ * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
+ */
+public class TableRefreshWithF5ShortcutTests extends AbstractTreeSiriusSWTBotGefTestCase {
+
+ /** Path. */
+ private static final String PATH = "data/unit/tree/";
+
+ /** Modeler resource file. */
+ private static final String MODELER_RESOURCE_FILE = "ecore.odesign";
+
+ /** Session resource file. */
+ private static final String SESSION_RESOURCE_FILE = "tree.aird";
+
+ /** Semantic resource file. */
+ private static final String SEMANTIC_RESOURCE_FILE = "tree.ecore";
+
+ private SWTBotEditor tableEditorBot;
+
+ private UITreeRepresentation tableRepresentation;
+
+ private DTable dTable;
+
+ private DLine firstLine;
+
+ private DLine secondLine;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ copyFileToTestProject(Activator.PLUGIN_ID, PATH, MODELER_RESOURCE_FILE, SESSION_RESOURCE_FILE, SEMANTIC_RESOURCE_FILE);
+
+ changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false);
+ changeSiriusUIPreference(SiriusUIPreferencesKeys.PREF_REFRESH_ON_REPRESENTATION_OPENING.name(), false);
+ sessionAirdResource = new UIResource(designerProject, "/", SESSION_RESOURCE_FILE);
+ localSession = designerPerspective.openSessionFromFile(sessionAirdResource);
+ SWTBotUtils.waitAllUiEvents();
+
+ tableRepresentation = openEditor(localSession, EcoreModeler.DESIGN_VIEWPOINT_NAME, "Classes", "new Classes");
+ tableEditorBot = tableRepresentation.getEditor();
+ DTableEditor dTableEditor = (DTableEditor) tableEditorBot.getReference().getEditor(false);
+ dTable = (DTable) dTableEditor.getRepresentation();
+ firstLine = dTable.getLines().get(0);
+ secondLine = dTable.getLines().get(1);
+ }
+
+ /**
+ * Test table global refresh with F5 shortcut.
+ */
+ public void testTableGlobalRefreshWithF5Shortcut() {
+ int nbSubLinesOfFirstLine = firstLine.getLines().size();
+ int nbSubLinesOfSecondLine = secondLine.getLines().size();
+ TransactionalEditingDomain domain = localSession.getOpenedSession().getTransactionalEditingDomain();
+ Command cmd = AddCommand.create(domain, firstLine.getTarget(), EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES, EcoreFactory.eINSTANCE.createEAttribute());
+ domain.getCommandStack().execute(cmd);
+ cmd = AddCommand.create(domain, secondLine.getTarget(), EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES, EcoreFactory.eINSTANCE.createEAttribute());
+ domain.getCommandStack().execute(cmd);
+
+ assertEquals(nbSubLinesOfFirstLine, firstLine.getLines().size());
+ assertEquals(nbSubLinesOfSecondLine, secondLine.getLines().size());
+
+ tableEditorBot.setFocus();
+ launchRefreshWithF5Shortcut(tableRepresentation.getTree());
+
+ assertEquals(nbSubLinesOfFirstLine + 1, firstLine.getLines().size());
+ assertEquals(nbSubLinesOfSecondLine + 1, secondLine.getLines().size());
+ }
+
+ private void launchRefreshWithF5Shortcut(SWTBotTree swtBotTree) {
+ ICondition condition = new OperationDoneCondition();
+ SWTBotUtils.pressKeyboardKey(swtBotTree.widget, SWT.F5);
+ bot.waitUntil(condition);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ tableEditorBot.close();
+ tableEditorBot = null;
+ tableRepresentation = null;
+ dTable = null;
+ firstLine = null;
+ secondLine = null;
+
+ super.tearDown();
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeRefreshWithF5ShortcutTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeRefreshWithF5ShortcutTests.java
new file mode 100644
index 0000000000..8932358421
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeRefreshWithF5ShortcutTests.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.tree;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys;
+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;
+import org.eclipse.sirius.tests.swtbot.support.api.condition.OperationDoneCondition;
+import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
+import org.eclipse.sirius.tests.unit.diagram.modeler.ecore.EcoreModeler;
+import org.eclipse.sirius.tree.DTree;
+import org.eclipse.sirius.tree.DTreeItem;
+import org.eclipse.sirius.tree.ui.tools.api.editor.DTreeEditor;
+import org.eclipse.sirius.ui.business.api.preferences.SiriusUIPreferencesKeys;
+import org.eclipse.swt.SWT;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+/**
+ * Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=458977 .
+ *
+ * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
+ */
+public class TreeRefreshWithF5ShortcutTests extends AbstractTreeSiriusSWTBotGefTestCase {
+
+ /** Path. */
+ private static final String PATH = "data/unit/tree/";
+
+ /** Modeler resource file. */
+ private static final String MODELER_RESOURCE_FILE = "ecore.odesign";
+
+ /** Session resource file. */
+ private static final String SESSION_RESOURCE_FILE = "tree.aird";
+
+ /** Semantic resource file. */
+ private static final String SEMANTIC_RESOURCE_FILE = "tree.ecore";
+
+ private SWTBotEditor treeEditorBot;
+
+ private UITreeRepresentation treeRepresentation;
+
+ private DTree dTree;
+
+ private DTreeItem firstDTreeItem;
+
+ private DTreeItem secondDTreeItem;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ copyFileToTestProject(Activator.PLUGIN_ID, PATH, MODELER_RESOURCE_FILE, SESSION_RESOURCE_FILE, SEMANTIC_RESOURCE_FILE);
+
+ changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false);
+ changeSiriusUIPreference(SiriusUIPreferencesKeys.PREF_REFRESH_ON_REPRESENTATION_OPENING.name(), false);
+ sessionAirdResource = new UIResource(designerProject, "/", SESSION_RESOURCE_FILE);
+ localSession = designerPerspective.openSessionFromFile(sessionAirdResource);
+ SWTBotUtils.waitAllUiEvents();
+
+ treeRepresentation = openEditor(localSession, EcoreModeler.DESIGN_VIEWPOINT_NAME, "Tree", "new Tree");
+ treeEditorBot = treeRepresentation.getEditor();
+ DTreeEditor dTreeEditor = (DTreeEditor) treeEditorBot.getReference().getEditor(false);
+ dTree = (DTree) dTreeEditor.getRepresentation();
+ firstDTreeItem = dTree.getOwnedTreeItems().get(0);
+ secondDTreeItem = dTree.getOwnedTreeItems().get(1);
+ }
+
+ /**
+ * Test tree global refresh with F5 shortcut.
+ */
+ public void testTreeGlobalRefreshWithF5Shortcut() {
+ int nbSubTreeitemsOfFirstDTreeItem = firstDTreeItem.getOwnedTreeItems().size();
+ int nbSubTreeitemsOfSecondDTreeItem = secondDTreeItem.getOwnedTreeItems().size();
+
+ TransactionalEditingDomain domain = localSession.getOpenedSession().getTransactionalEditingDomain();
+ Command cmd = AddCommand.create(domain, firstDTreeItem.getTarget(), EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES, EcoreFactory.eINSTANCE.createEAttribute());
+ domain.getCommandStack().execute(cmd);
+ cmd = AddCommand.create(domain, secondDTreeItem.getTarget(), EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES, EcoreFactory.eINSTANCE.createEAttribute());
+ domain.getCommandStack().execute(cmd);
+
+ assertEquals(nbSubTreeitemsOfFirstDTreeItem, firstDTreeItem.getOwnedTreeItems().size());
+ assertEquals(nbSubTreeitemsOfSecondDTreeItem, secondDTreeItem.getOwnedTreeItems().size());
+
+ launchRefreshWithF5Shortcut(treeRepresentation.getTree());
+
+ assertEquals(nbSubTreeitemsOfFirstDTreeItem + 1, firstDTreeItem.getOwnedTreeItems().size());
+ assertEquals(nbSubTreeitemsOfSecondDTreeItem + 1, secondDTreeItem.getOwnedTreeItems().size());
+ }
+
+ /**
+ * Test tree local refresh with F5 shortcut.
+ */
+ public void testTreeLocalRefreshWithF5Shortcut() {
+ int nbSubTreeitemsOfFirstDTreeItem = firstDTreeItem.getOwnedTreeItems().size();
+ int nbSubTreeitemsOfSecondDTreeItem = secondDTreeItem.getOwnedTreeItems().size();
+
+ TransactionalEditingDomain domain = localSession.getOpenedSession().getTransactionalEditingDomain();
+ Command cmd = AddCommand.create(domain, firstDTreeItem.getTarget(), EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES, EcoreFactory.eINSTANCE.createEAttribute());
+ domain.getCommandStack().execute(cmd);
+ cmd = AddCommand.create(domain, secondDTreeItem.getTarget(), EcorePackage.Literals.ECLASS__ESTRUCTURAL_FEATURES, EcoreFactory.eINSTANCE.createEAttribute());
+ domain.getCommandStack().execute(cmd);
+
+ assertEquals(nbSubTreeitemsOfFirstDTreeItem, firstDTreeItem.getOwnedTreeItems().size());
+ assertEquals(nbSubTreeitemsOfSecondDTreeItem, secondDTreeItem.getOwnedTreeItems().size());
+
+ treeEditorBot.bot().tree().getAllItems()[0].select();
+ launchRefreshWithF5Shortcut(treeRepresentation.getTree());
+
+ assertEquals(nbSubTreeitemsOfFirstDTreeItem + 1, firstDTreeItem.getOwnedTreeItems().size());
+ assertEquals(nbSubTreeitemsOfSecondDTreeItem, secondDTreeItem.getOwnedTreeItems().size());
+ }
+
+ private void launchRefreshWithF5Shortcut(final SWTBotTree swtBotTree) {
+ ICondition condition = new OperationDoneCondition();
+ SWTBotUtils.pressKeyboardKey(swtBotTree.widget, SWT.F5);
+ bot.waitUntil(condition);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+
+ treeEditorBot.close();
+ treeEditorBot = null;
+ treeRepresentation = null;
+ dTree = null;
+ firstDTreeItem = null;
+ secondDTreeItem = null;
+
+ super.tearDown();
+ }
+
+}

Back to the top