Author: psrna
Date: 2012-08-14 11:31:51 -0400 (Tue, 14 Aug 2012)
New Revision: 43029
Added:
trunk/forge/tests/org.jboss.tools.forge.ui.bot.test/src/org/jboss/tools/forge/ui/bot/test/util/ViewUtils.java
Modified:
trunk/forge/tests/org.jboss.tools.forge.ui.bot.test/src/org/jboss/tools/forge/ui/bot/test/suite/ForgeTest.java
Log:
* getToolbar workaround for juno
Modified:
trunk/forge/tests/org.jboss.tools.forge.ui.bot.test/src/org/jboss/tools/forge/ui/bot/test/suite/ForgeTest.java
===================================================================
---
trunk/forge/tests/org.jboss.tools.forge.ui.bot.test/src/org/jboss/tools/forge/ui/bot/test/suite/ForgeTest.java 2012-08-14
15:27:13 UTC (rev 43028)
+++
trunk/forge/tests/org.jboss.tools.forge.ui.bot.test/src/org/jboss/tools/forge/ui/bot/test/suite/ForgeTest.java 2012-08-14
15:31:51 UTC (rev 43029)
@@ -2,16 +2,15 @@
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
import org.eclipse.ui.part.PageBook;
import org.jboss.tools.forge.ui.bot.test.util.ConsoleUtils;
+import org.jboss.tools.forge.ui.bot.test.util.ViewUtils;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.ext.view.PackageExplorer;
import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -172,7 +171,10 @@
return;
SWTBotView view = getForgeView();
- view.toolbarButton("Start the default Forge runtime").click();
+ /* view.toolbarButton("Start the default Forge runtime").click(); */
+ //not working with juno ^^^
+ //workaround:
+ ViewUtils.getToolbarButton("Start the default Forge runtime").click();
util.waitForNonIgnoredJobs();
}
@@ -183,7 +185,11 @@
openForgeView();
SWTBotView view = getForgeView();
- view.toolbarButton("Stop the running Forge runtime").click();
+ /* view.toolbarButton("Stop the running Forge runtime").click(); */
+ //not working with juno ^^^
+ //workaround:
+ ViewUtils.getToolbarButton("Stop the running Forge runtime").click();
+
bot.sleep(TIME_5S);
}
Added:
trunk/forge/tests/org.jboss.tools.forge.ui.bot.test/src/org/jboss/tools/forge/ui/bot/test/util/ViewUtils.java
===================================================================
---
trunk/forge/tests/org.jboss.tools.forge.ui.bot.test/src/org/jboss/tools/forge/ui/bot/test/util/ViewUtils.java
(rev 0)
+++
trunk/forge/tests/org.jboss.tools.forge.ui.bot.test/src/org/jboss/tools/forge/ui/bot/test/util/ViewUtils.java 2012-08-14
15:31:51 UTC (rev 43029)
@@ -0,0 +1,80 @@
+package org.jboss.tools.forge.ui.bot.test.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.ListResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarPushButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarRadioButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarSeparatorButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.internal.WorkbenchPartReference;
+import org.jboss.tools.forge.ui.bot.test.suite.ForgeTest;
+
+
+public class ViewUtils {
+
+ public static List<SWTBotToolbarButton> getToolbarButtons() {
+ return UIThreadRunnable.syncExec(new ListResult<SWTBotToolbarButton>() {
+
+ public List<SWTBotToolbarButton> run() {
+ SWTBotView view = ForgeTest.openForgeView();
+ IWorkbenchPart obj = ((WorkbenchPartReference) view.getReference()).getPart(false);
+ ToolBar toolbar = null;
+ IToolBarManager t = ((IViewSite)obj.getSite()).getActionBars().getToolBarManager();
+ if (t instanceof ToolBarManager) {
+ toolbar = ((ToolBarManager)t).getControl();
+ }
+
+ final List<SWTBotToolbarButton> l = new
ArrayList<SWTBotToolbarButton>();
+
+ if (toolbar == null)
+ return l;
+
+ ToolItem[] items = toolbar.getItems();
+ for (int i = 0; i < items.length; i++) {
+ try {
+ if (SWTUtils.hasStyle(items[i], SWT.PUSH))
+ l.add(new SWTBotToolbarPushButton(items[i]));
+ else if(SWTUtils.hasStyle(items[i], SWT.CHECK))
+ l.add(new SWTBotToolbarToggleButton(items[i]));
+ else if(SWTUtils.hasStyle(items[i], SWT.RADIO))
+ l.add(new SWTBotToolbarRadioButton(items[i]));
+ else if(SWTUtils.hasStyle(items[i], SWT.DROP_DOWN))
+ l.add(new SWTBotToolbarDropDownButton(items[i]));
+ else if(SWTUtils.hasStyle(items[i], SWT.SEPARATOR))
+ l.add(new SWTBotToolbarSeparatorButton(items[i]));
+ } catch (WidgetNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ return l;
+ }
+ });
+ }
+
+ public static SWTBotToolbarButton getToolbarButton(String tooltip){
+
+ List<SWTBotToolbarButton> btns = ViewUtils.getToolbarButtons();
+ for (SWTBotToolbarButton btn : btns){
+ if(btn.getToolTipText().equals(tooltip)){
+ return btn;
+ }
+ }
+ return null;
+ }
+
+}
Show replies by date