[jbosstools-commits] JBoss Tools SVN: r42861 - 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
Mon Aug 6 09:13:23 EDT 2012
Author: rhopp
Date: 2012-08-06 09:13:23 -0400 (Mon, 06 Aug 2012)
New Revision: 42861
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotFormTextExt.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTwistie.java
Log:
Fixed SWTBotFormTextExt.click()
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotFormTextExt.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotFormTextExt.java 2012-08-06 12:47:32 UTC (rev 42860)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotFormTextExt.java 2012-08-06 13:13:23 UTC (rev 42861)
@@ -5,6 +5,7 @@
import org.eclipse.swtbot.swt.finder.ReferenceBy;
import org.eclipse.swtbot.swt.finder.SWTBotWidget;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.results.BoolResult;
import org.eclipse.swtbot.swt.finder.results.StringResult;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
@@ -35,19 +36,44 @@
}
public AbstractSWTBotControl<FormText> click() {
- syncExec(new VoidResult() {
+ /*syncExec(new VoidResult() {
@Override
public void run() {
click(widget.toDisplay(25,5).x, widget.toDisplay(25,5).y, true); //+20 is there because of icon
}
- });
- /*old version of click
- setFocus();
- keyboard().typeCharacter('\r');*/
+ });*/
+ 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();
+ }
+ });
+ }
+
+
public String selectedLinkText() {
return syncExec(new StringResult() {
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTwistie.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTwistie.java 2012-08-06 12:47:32 UTC (rev 42860)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTwistie.java 2012-08-06 13:13:23 UTC (rev 42861)
@@ -51,15 +51,8 @@
* Toggles twistie (expands its section)
*/
public AbstractSWTBotControl<Twistie> toggle() {
- syncExec(new VoidResult() {
-
- @Override
- public void run() {
- clickXY(widget.getBounds().x+3, widget.getBounds().y+3);
- }
- });
- /*setFocus();
- keyboard().typeCharacter('\r');*/
+ setFocus();
+ keyboard().typeCharacter('\r');
return this;
}
More information about the jbosstools-commits
mailing list