Commit ae6a8fb9 authored by Romain Bioteau's avatar Romain Bioteau

fix IT

parent 11bba82c
......@@ -8,17 +8,18 @@
*******************************************************************************/
package org.bonitasoft.studio.swtbot.framework;
import java.util.List;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.waits.WaitForObjectCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
/**
......@@ -52,32 +53,11 @@ public class BotDialog extends BotBase {
public void cancel() {
if (dialogTitle != null && !dialogTitle.isEmpty()) {
final SWTBotShell shell = bot.shell(dialogTitle);
shell.activate();
shell.setFocus();
final WaitForObjectCondition<Widget> waitForWidgetCondition = Conditions.waitForWidget(
WidgetMatcherFactory.withMnemonic(IDialogConstants.CANCEL_LABEL), shell.widget);
bot.waitUntil(waitForWidgetCondition, 10000, 100);
final List<Widget> allMatches = waitForWidgetCondition.getAllMatches();
if (!allMatches.isEmpty()) {
final StringBuilder sb = new StringBuilder("Cancel button matches :\n");
for (final Widget widget : allMatches) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
sb.append(widget.toString());
sb.append("\n");
}
});
}
BonitaStudioLog.debug(sb.toString(), "org.bonitasoft.studio.swtbot.framework");
} else {
BonitaStudioLog.debug("No Cancel button match :(", "org.bonitasoft.studio.swtbot.framework");
}
} else {
BonitaStudioLog.debug("No Dialog title set", "org.bonitasoft.studio.swtbot.framework");
}
bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.CANCEL_LABEL)));
bot.waitUntil(Conditions.waitForWidget(allOf(widgetOfType(Button.class), withMnemonic(IDialogConstants.CANCEL_LABEL),
withStyle(SWT.PUSH, "SWT.PUSH"))), 20000);
bot.button(IDialogConstants.CANCEL_LABEL).click();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment