[jbosstools-commits] JBoss Tools SVN: r42614 - trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Jul 17 04:53:27 EDT 2012
Author: rhopp
Date: 2012-07-17 04:53:26 -0400 (Tue, 17 Jul 2012)
New Revision: 42614
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotHyperlinkExt.java
Log:
Fix for clicking on ImageHyperlink.
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotHyperlinkExt.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotHyperlinkExt.java 2012-07-17 07:46:22 UTC (rev 42613)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotHyperlinkExt.java 2012-07-17 08:53:26 UTC (rev 42614)
@@ -1,6 +1,7 @@
package org.jboss.tools.ui.bot.ext.parts;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.results.BoolResult;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
import org.eclipse.ui.forms.widgets.Hyperlink;
@@ -21,11 +22,38 @@
* @return
*/
public AbstractSWTBot<Hyperlink> activate() {
- setFocus();
+ int timeout = 0;
+ while (!hasFocus() && timeout!=5){
+ //try to set focus
+ setFocus();
+ log.info("Trying to set focus");
+ sleep(1000);
+ timeout++;
+ }
+ if (!hasFocus()){
+ throw new IllegalStateException("Unable to focus widget of type Hyperlink");
+ }
keyboard().typeCharacter('\r');
return this;
}
+
+
/**
+ * Tests whether widget has focus or not. Needed for workaround of issue, where method setFocus() isn't working properly when ececuting test via maven.
+ * @return true if widget has focus. False otherwise.
+ */
+
+ public boolean hasFocus(){
+ return syncExec(new BoolResult() {
+
+ @Override
+ public Boolean run() {
+ return widget.isFocusControl();
+ }
+ });
+ }
+
+ /**
* clicks on hyper-link (not real click, but {@link SWTBotHyperlinkExt#activate()}
*/
public AbstractSWTBot<Hyperlink> click() {
More information about the jbosstools-commits
mailing list