Author: lzoubek(a)redhat.com
Date: 2011-02-24 10:50:54 -0500 (Thu, 24 Feb 2011)
New Revision: 29311
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ConsoleView.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ViewBase.java
Log:
swtbotext: refactored views (ViewBase does not extend STWBotExt anymore)
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ConsoleView.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ConsoleView.java 2011-02-24
15:11:49 UTC (rev 29310)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ConsoleView.java 2011-02-24
15:50:54 UTC (rev 29311)
@@ -43,7 +43,7 @@
public String getConsoleText(){
show();
- SWTBot viewBot = viewByTitle(viewObject.getName()).bot();
+ SWTBot viewBot = bot.viewByTitle(viewObject.getName()).bot();
String consoleText = null;
try{
consoleText = viewBot.styledText().getText();
@@ -60,7 +60,7 @@
public void clearConsole(){
show();
- SWTBot viewBot = viewByTitle(viewObject.getName()).bot();
+ SWTBot viewBot = bot.viewByTitle(viewObject.getName()).bot();
try{
SWTBotButton clearConsole =
viewBot.buttonWithTooltip(IDELabel.ConsoleView.BUTTON_CLEAR_CONSOLE_TOOLTIP).click();
clearConsole.click();
@@ -93,7 +93,7 @@
public String getConsoleText (long sleepTime , long timeOut , boolean
quitWhenNoChange){
long estimatedTime = 0;
- SWTBot viewBot = viewByTitle(viewObject.getName()).bot();
+ SWTBot viewBot = bot.viewByTitle(viewObject.getName()).bot();
String prevConsoleText = getConsoleText();
String consoleText = prevConsoleText;
log.info("Waiting for console text with TimeOut: " + timeOut);
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java 2011-02-24
15:11:49 UTC (rev 29310)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java 2011-02-24
15:50:54 UTC (rev 29311)
@@ -10,6 +10,7 @@
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.WidgetResult;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
@@ -31,8 +32,7 @@
* Selects given project in Package Explorer
*/
public void selectProject(String projectName) {
- SWTBot viewBot = viewByTitle(viewObject.getName()).bot();
- viewBot.tree().expandNode(projectName).select();
+ bot().tree().expandNode(projectName).select();
}
/**
@@ -45,7 +45,7 @@
*/
public SWTBotTreeItem selectTreeItem(int timeOut, String treeItemText,
String[] path) {
- SWTBot viewBot = show().bot();
+ SWTBot viewBot = bot();
return SWTEclipseExt.getTreeItemOnPath(viewBot, viewBot.tree(), timeOut,
treeItemText, path).select();
}
@@ -71,13 +71,13 @@
SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
ContextMenuHelper.prepareTreeItemForContextMenu(viewBot.tree(), item);
new SWTBotMenu(ContextMenuHelper.getContextMenu(viewBot.tree(), IDELabel.Menu.DELETE,
false)).click();
- shell("Delete Resources").activate();
+ SWTBotShell shell = bot.shell("Delete Resources").activate();
if (fileSystem) {
- checkBox().click();
+ shell.bot().checkBox().click();
}
- open.finish(this,IDELabel.Button.OK);
- new SWTUtilExt(this).waitForNonIgnoredJobs();
- new SWTUtilExt(this).waitForAll(Timing.time3S());
+ open.finish(shell.bot(),IDELabel.Button.OK);
+ util.waitForNonIgnoredJobs();
+ util.waitForAll(Timing.time3S());
}
/**
* deletes all projects from workspace
@@ -123,7 +123,7 @@
}
item.select().doubleClick();
log.info("File Opened:" + builder.toString());
- SWTBotEditor editor = activeEditor();
+ SWTBotEditor editor = bot.activeEditor();
return editor;
}
/**
@@ -165,9 +165,9 @@
});
if (menuItem != null){
new SWTBotMenu(menuItem).click();
- shell(IDELabel.Shell.RUN_ON_SERVER).activate();
- open.finish(this);
- new SWTUtilExt(this).waitForAll(Timing.time3S());
+ SWTBotShell shell = bot.shell(IDELabel.Shell.RUN_ON_SERVER).activate();
+ open.finish(shell.bot());
+ util.waitForAll(Timing.time3S());
}
else{
throw new WidgetNotFoundException("Unable to find Menu Item with Label
'Run on Server'");
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java 2011-02-24
15:11:49 UTC (rev 29310)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java 2011-02-24
15:50:54 UTC (rev 29311)
@@ -33,7 +33,7 @@
ContextMenuHelper.prepareTreeItemForContextMenu(tree, server);
new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
IDELabel.Menu.ADD_AND_REMOVE, false)).click();
try {
- SWTBotShell shell = shell(IDELabel.Menu.ADD_AND_REMOVE);
+ SWTBotShell shell = bot.shell(IDELabel.Menu.ADD_AND_REMOVE);
shell.activate();
SWTBotButton btRemoveAll=shell.bot().button("<< Remove All");
if (btRemoveAll.isEnabled()) {
@@ -41,12 +41,12 @@
log.info("Removing all projects from server
'"+serverName+"'");
}
open.finish(shell.bot(), IDELabel.Button.FINISH);
- new SWTUtilExt(this).waitForNonIgnoredJobs();
- new SWTUtilExt(this).waitForAll(Timing.time3S());
+ util.waitForNonIgnoredJobs();
+ util.waitForAll(Timing.time3S());
} catch (WidgetNotFoundException ex) {
ex.printStackTrace();
- shell("Server").activate();
- button(IDELabel.Button.OK).click();
+ bot.shell("Server").activate();
+ bot.button(IDELabel.Button.OK).click();
}
}
@@ -62,8 +62,8 @@
if (server!=null) {
ContextMenuHelper.prepareTreeItemForContextMenu(tree, server);
new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.STOP,
false)).click();
- new SWTUtilExt(this).waitForNonIgnoredJobs();
- new SWTUtilExt(this).waitForAll(Timing.time10S());
+ util.waitForNonIgnoredJobs();
+ util.waitForAll(Timing.time10S());
}
}
@@ -78,7 +78,7 @@
if (server!=null) {
ContextMenuHelper.prepareTreeItemForContextMenu(tree, server);
new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.DELETE,
false)).click();
- SWTBotShell shell = shell("Delete Server");
+ SWTBotShell shell = bot.shell("Delete Server");
shell.activate();
open.finish(shell.bot(), IDELabel.Button.OK);
log.info("Removed server: " + serverName);
@@ -97,8 +97,8 @@
if (server!=null) {
ContextMenuHelper.prepareTreeItemForContextMenu(tree, server);
new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.START,
false)).click();
- new SWTUtilExt(this).waitForNonIgnoredJobs(Timing.time100S());
- new SWTUtilExt(this).waitForAll(Timing.time3S());
+ util.waitForNonIgnoredJobs(Timing.time100S());
+ util.waitForAll(Timing.time3S());
}
else{
throw new RuntimeException("Unable to start server witn name: " +
serverName +
@@ -139,11 +139,11 @@
log.info("Found project to be removed from server: " +
serverTreeItemChildren[itemIndex].getText());
ContextMenuHelper.prepareTreeItemForContextMenu(serverTree,serverTreeItemChildren[itemIndex]);
new SWTBotMenu(ContextMenuHelper.getContextMenu(serverTree,
IDELabel.Menu.REMOVE, false)).click();
- SWTBotShell shell = shell("Server");
+ SWTBotShell shell = bot.shell("Server");
shell.activate();
open.finish(shell.bot(), IDELabel.Button.OK);
log.info("Removed project from server: " +
serverTreeItemChildren[itemIndex].getText());
- new SWTUtilExt(this).waitForNonIgnoredJobs();
+ util.waitForNonIgnoredJobs();
} else {
log.info("Project '"+projectName+"' not found on any
server");
}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ViewBase.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ViewBase.java 2011-02-24
15:11:49 UTC (rev 29310)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ViewBase.java 2011-02-24
15:50:54 UTC (rev 29311)
@@ -2,28 +2,44 @@
import org.apache.log4j.Logger;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTOpenExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.gen.IView;
/**
* base class for all view extensions
* @author lzoubek(a)redhat.com
*
*/
-public class ViewBase extends SWTBotExt {
+public class ViewBase {
/**
* view object representing current view, MUST be defined in derived
* constructor (for use, see {@link SWTOpenExt#viewOpen(IView)}
*/
protected IView viewObject;
protected final SWTOpenExt open;
+ protected final SWTUtilExt util;
+ protected final SWTBotExt bot;
+
Logger log = Logger.getLogger(ViewBase.class);
public ViewBase() {
- open = new SWTOpenExt(this);
+ open = SWTTestExt.open;
+ util = SWTTestExt.util;
+ bot = SWTTestExt.bot;
+
}
-
/**
+ * gets view bot, view is guaranteed to be shown and focused
+ * @return
+ */
+ public SWTBot bot() {
+ return show().bot();
+ }
+ /**
* shows view
*/
public SWTBotView show() {