Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornlepine2010-02-11 17:23:12 +0000
committernlepine2010-02-11 17:23:12 +0000
commit493607f6c2397e6a9ac1c90771e7f47b721721ad (patch)
tree418d899a5b245f0c0b718ae2466e8f32e838ee34 /plugins/org.eclipse.emf.eef.runtime.tests
parente59046ee62539256c843bd5e69343fc7429dc4ff (diff)
downloadorg.eclipse.eef-493607f6c2397e6a9ac1c90771e7f47b721721ad.tar.gz
org.eclipse.eef-493607f6c2397e6a9ac1c90771e7f47b721721ad.tar.xz
org.eclipse.eef-493607f6c2397e6a9ac1c90771e7f47b721721ad.zip
added : tab generation
Diffstat (limited to 'plugins/org.eclipse.emf.eef.runtime.tests')
-rw-r--r--plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/finder/SWTEEFBot.java8
-rw-r--r--plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/utils/SWTBotUtils.java91
2 files changed, 97 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/finder/SWTEEFBot.java b/plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/finder/SWTEEFBot.java
index 2099807f2..c44412110 100644
--- a/plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/finder/SWTEEFBot.java
+++ b/plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/finder/SWTEEFBot.java
@@ -132,6 +132,7 @@ public class SWTEEFBot extends SWTWorkbenchBot {
}
/**
+ * Must open the file with EEF Reflexive editor -> SWTBot pb with context menu
* @param file
* the file to open
* @return the editor editing the file
@@ -177,9 +178,11 @@ public class SWTEEFBot extends SWTWorkbenchBot {
* the element to edit
* @return the shell of the opened wizard
*/
- public SWTBotShell prepareBatchEditing(SWTBotEditor editor, EClass elementType, EObject element) {
+ public SWTBotShell prepareBatchEditing(SWTBotEditor editor, EClass elementType, EObject element, String tabName) {
SWTBotTreeItem node2 = selectNode(editor, element);
node2.doubleClick();
+ cTabItem(tabName).activate();
+ cTabItem(tabName).setFocus();
sleep(1000);
return shell(elementType.getName());
}
@@ -193,9 +196,10 @@ public class SWTEEFBot extends SWTWorkbenchBot {
* the element to edit
* @return the shell of the opened wizard
*/
- public SWTBotView prepareLiveEditing(SWTBotEditor editor, EObject element) {
+ public SWTBotView prepareLiveEditing(SWTBotEditor editor, EObject element, String tabName) {
SWTBotTreeItem node2 = selectNode(editor, element);
node2.select();
+ SWTBotUtils.selectPropertyTabItem(tabName);
sleep(1000);
return viewByTitle(UIConstants.PROPERTIES_VIEW_NAME);
}
diff --git a/plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/utils/SWTBotUtils.java b/plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/utils/SWTBotUtils.java
index a34f7ac84..4736bea6a 100644
--- a/plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/utils/SWTBotUtils.java
+++ b/plugins/org.eclipse.emf.eef.runtime.tests/src/org/eclipse/emf/eef/runtime/tests/swtbot/utils/SWTBotUtils.java
@@ -11,12 +11,21 @@
package org.eclipse.emf.eef.runtime.tests.swtbot.utils;
+import java.util.List;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.waits.WaitForObjectCondition;
+import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList;
+import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.ListElement;
+import org.hamcrest.Matcher;
/**
* @author <a href="mailto:nathalie.lepine@obeo.fr">Nathalie Lepine</a>
@@ -76,6 +85,88 @@ public class SWTBotUtils {
}
+ /**
+ * Select the tab with the name label in the property views.
+ *
+ * @param label
+ * Label to find.
+ */
+ // CHECKSTYLE:OFF
+ @SuppressWarnings( { "restriction", "unchecked" })
+ // CHECKSTYLE:ON
+ public static void selectPropertyTabItem(final String label) {
+ final Matcher<TabbedPropertyList> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(TabbedPropertyList.class));
+ final List<TabbedPropertyList> widgets = widget(matcher);
+
+ UIThreadRunnable.syncExec(SWTUtils.display(), new VoidResult() {
+ public void run() {
+ for (final TabbedPropertyList tabbedProperty : widgets) {
+ final ListElement tabItem = getTabItem(label, tabbedProperty);
+ if (tabItem != null) {
+ final Event mouseEvent = createEvent(tabItem, tabItem.getBounds().x, tabItem.getBounds().y, 1, SWT.BUTTON1, 1);
+ tabItem.notifyListeners(SWT.MouseUp, mouseEvent);
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * Find widget.
+ *
+ * @param matcher
+ * the matcher used to match widgets.
+ * @return all the widgets matching the matcher.
+ */
+ @SuppressWarnings("restriction")
+ public static List<TabbedPropertyList> widget(final Matcher<TabbedPropertyList> matcher) {
+ final WaitForObjectCondition<TabbedPropertyList> waitForWidget = Conditions.waitForWidget(matcher);
+ bot.waitUntilWidgetAppears(waitForWidget);
+ return waitForWidget.getAllMatches();
+ }
+
+ /**
+ * Create a event <br>
+ *
+ * @param x
+ * the x coordinate of the mouse event.
+ * @param y
+ * the y coordinate of the mouse event.
+ * @param button
+ * the mouse button that was clicked.
+ * @param stateMask
+ * the state of the keyboard modifier keys.
+ * @param count
+ * the number of times the mouse was clicked.
+ * @return an event that encapsulates {@link #widget} and {@link #display}
+ */
+ private static Event createEvent(final Widget widget, final int x, final int y, final int button, final int stateMask, final int count) {
+ final Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = widget;
+ event.display = bot.getDisplay();
+ event.x = x;
+ event.y = y;
+ event.button = button;
+ event.stateMask = stateMask;
+ event.count = count;
+ return event;
+ }
+
+ /**
+ * Select the tab with the name label in the property views
+ *
+ * @param label
+ */
+ @SuppressWarnings("restriction")
+ private static ListElement getTabItem(final String label, final TabbedPropertyList tabbedProperty) {
+ for (final Object listElement : tabbedProperty.getTabList()) {
+ if (listElement instanceof ListElement && ((ListElement) listElement).getTabItem().getText().equals(label)) {
+ return (ListElement) listElement;
+ }
+ }
+ return null;
+ }
}

Back to the top