Author: lzoubek(a)redhat.com
Date: 2010-04-30 12:09:11 -0400 (Fri, 30 Apr 2010)
New Revision: 21834
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTOpenExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java
Log:
SWTBot Extensions : small fixes, + auto-closing unexpected dialogs when closing shell
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTOpenExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTOpenExt.java 2010-04-30
15:49:48 UTC (rev 21833)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTOpenExt.java 2010-04-30
16:09:11 UTC (rev 21834)
@@ -237,6 +237,12 @@
log.info("OK, shell '"+activeShellStr+"' closed.");
return;
} catch (TimeoutException ex) {
+ String currentShellStr = bot.activeShell().getText();
+ if (!activeShellStr.equals(currentShellStr)) {
+ log.error("Unexpected shell '"+currentShellStr+"':
["+SWTUtilExt.getAllBotWidgetsAsText(bot)+"] appeared, when waiting for shell to
close");
+ bot.activeShell().close();
+ log.info("Shell '"+currentShellStr+"' closed.");
+ }
if (System.currentTimeMillis()-time>timeout) {
log.error("Shell '"+activeShellStr+"' probably hanged up
(480s timeout), returning, forcing to close it, expect errors");
try {
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-04-30
15:49:48 UTC (rev 21833)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-04-30
16:09:11 UTC (rev 21834)
@@ -33,6 +33,8 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
@@ -606,6 +608,27 @@
}
}
/**
+ * gets all active widgets as string
+ * @param bot
+ * @return
+ */
+ public static String getAllBotWidgetsAsText(final SWTBot bot) {
+ return UIThreadRunnable.syncExec(new Result<String>(){
+ public String run() {
+ StringBuilder sb = new StringBuilder();
+ List<?> widgets = bot.widgets(new
SWTUtilExt.AlwaysMatchMatcher<Widget>());
+ for (Object object : widgets){
+ String objectName = object.getClass().getSimpleName();
+ String text = SWTUtilExt.invokeMethod(object, "getText").trim();
+ if (!"".equals(text)) {
+ sb.append("{"+ objectName + "->"+text+"} ");
+ }
+ }
+ return sb.toString();
+ }});
+
+ }
+ /**
* Display all active widgets
* @param bot
*/
@@ -652,7 +675,7 @@
String result = "<null>";
try {
- Object oResult = SWTUtils.invokeMethod(object, "getText");
+ Object oResult = SWTUtils.invokeMethod(object, method);
if (oResult != null){
result = oResult.toString();
}
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java 2010-04-30
15:49:48 UTC (rev 21833)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java 2010-04-30
16:09:11 UTC (rev 21834)
@@ -53,7 +53,7 @@
*/
public void deleteProject(String projectName, boolean fileSystem) {
log.info("Deleting project '"+projectName+"'");
- SWTBot viewBot = viewByTitle(viewObject.getName()).bot();
+ SWTBot viewBot = show().bot();
SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
ContextMenuHelper.prepareTreeItemForContextMenu(viewBot.tree(), item);
new SWTBotMenu(ContextMenuHelper.getContextMenu(viewBot.tree(), IDELabel.Menu.DELETE,
false)).click();
@@ -69,7 +69,7 @@
* deletes all projects from workspace
*/
public void deleteAllProjects() {
- SWTBot viewBot = viewByTitle(viewObject.getName()).bot();
+ SWTBot viewBot = show().bot();
List<String> items = new Vector<String>();
for (SWTBotTreeItem ti : viewBot.tree().getAllItems()) {
items.add(ti.getText());
@@ -95,7 +95,7 @@
* @return editor with opened file
*/
public SWTBotEditor openFile(String projectName, String... path) {
- SWTBot viewBot = open.viewOpen(viewObject).bot();
+ SWTBot viewBot = show().bot();
SWTBotTree tree = viewBot.tree();
SWTBotTreeItem item = tree.expandNode(projectName);
StringBuilder builder = new StringBuilder(projectName);
@@ -114,7 +114,7 @@
* @param projectName
*/
public void runOnServer(String projectName) {
- SWTBot viewBot = open.viewOpen(viewObject).bot();
+ SWTBot viewBot = show().bot();
SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
ContextMenuHelper.prepareTreeItemForContextMenu(viewBot.tree(), item);
final SWTBotMenu menuRunAs =
viewBot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.RUN_AS);
@@ -155,7 +155,7 @@
public boolean existsResource(String... resource) {
try {
- SWTBot viewBot = viewByTitle(viewObject.getName()).bot();
+ SWTBot viewBot = show().bot();
SWTBotTreeItem ancestor = viewBot.tree().getTreeItem(resource[0]);
viewBot.tree().expandNode(resource[0]);
for (int i=1;i<resource.length;i++) {
@@ -167,7 +167,6 @@
return true;
}
catch (WidgetNotFoundException ex) {
- ex.printStackTrace();
return false;
}
}
Show replies by date