Author: ljelinko
Date: 2012-02-07 10:59:28 -0500 (Tue, 07 Feb 2012)
New Revision: 38476
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/ProgressInformationShellIsActiveCondition.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/wizards/SWTBotWizard.java
Log:
Created new waiting condition for wizard
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/ProgressInformationShellIsActiveCondition.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/ProgressInformationShellIsActiveCondition.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/ProgressInformationShellIsActiveCondition.java 2012-02-07
15:59:28 UTC (rev 38476)
@@ -0,0 +1,39 @@
+package org.jboss.tools.ui.bot.ext.condition;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+
+/**
+ * Checks if the progress information dialog is visible.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ProgressInformationShellIsActiveCondition implements ICondition {
+
+ private static final String DIALOG_TITLE = "Progress Information";
+
+ private SWTBotShell shell;
+
+ @Override
+ public void init(SWTBot bot) {
+ try {
+ shell = SWTBotFactory.getBot().shell("Progress Information");
+ } catch (WidgetNotFoundException e){
+ // nothing, dialog is not there
+ }
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ return shell != null && shell.isActive();
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "Expected the " + DIALOG_TITLE + " shell to become non
active";
+ }
+}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/wizards/SWTBotWizard.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/wizards/SWTBotWizard.java 2012-02-07
15:59:06 UTC (rev 38475)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/wizards/SWTBotWizard.java 2012-02-07
15:59:28 UTC (rev 38476)
@@ -15,16 +15,17 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.condition.NonSystemJobRunsCondition;
+import org.jboss.tools.ui.bot.ext.condition.ProgressInformationShellIsActiveCondition;
import org.jboss.tools.ui.bot.ext.condition.ShellIsActiveCondition;
import org.jboss.tools.ui.bot.ext.condition.TaskDuration;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
public class SWTBotWizard extends SWTBotShell {
-
+
public SWTBotWizard() {
this(SWTTestExt.bot.activeShell().widget);
}
-
+
public SWTBotWizard(Shell shell) {
super(shell);
assert getText().contains("New ");
@@ -45,6 +46,13 @@
return this;
}
+ public SWTBotWizard nextWithWait() {
+ SWTBotShell activeShell = getActiveShell();
+ next();
+ bot().waitUntil(new ShellIsActiveCondition(activeShell));
+ return this;
+ }
+
public void cancel() {
clickButton(IDELabel.Button.CANCEL);
}
@@ -52,14 +60,15 @@
public void finish() {
clickButton(IDELabel.Button.FINISH);
}
-
+
public void finishWithWait() {
SWTBotShell activeShell = getActiveShell();
finish();
bot().waitWhile(new ShellIsActiveCondition(activeShell),
TaskDuration.LONG.getTimeout());
+ bot().waitWhile(new ProgressInformationShellIsActiveCondition(),
TaskDuration.LONG.getTimeout());
bot().waitWhile(new NonSystemJobRunsCondition(), TaskDuration.LONG.getTimeout());
}
-
+
protected void clickButton(String text) {
bot().button(text).click();
bot().sleep(500);
@@ -70,7 +79,7 @@
t.setFocus();
t.setText(text);
}
-
+
private SWTBotShell getActiveShell(){
for (SWTBotShell shell : bot().shells()){
if (shell.isActive()){
Show replies by date