changeset 24:079c447a1c3e

7902342: Add a mechanism to set WaitToolTipTimeout in JToolTipOperator Reviewed-by: shurailine Contributed-by: abdul.kolarkunnu@oracle.com
author akolarkunnu
date Thu, 08 Nov 2018 23:09:10 -0800
parents 93cfbd0e4d48
children ff728c4de6d0
files src/org/netbeans/jemmy/operators/JToolTipOperator.java src/org/netbeans/jemmy/version_info test/org/netbeans/jemmy/operators/JToolTipOperatorTest.java
diffstat 3 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/netbeans/jemmy/operators/JToolTipOperator.java	Mon Oct 29 21:52:18 2018 -0700
+++ b/src/org/netbeans/jemmy/operators/JToolTipOperator.java	Thu Nov 08 23:09:10 2018 -0800
@@ -37,8 +37,11 @@
 
 import org.netbeans.jemmy.ComponentChooser;
 import org.netbeans.jemmy.ComponentSearcher;
+import org.netbeans.jemmy.JemmyException;
 import org.netbeans.jemmy.TimeoutExpiredException;
+import org.netbeans.jemmy.Timeouts;
 import org.netbeans.jemmy.Waitable;
+import org.netbeans.jemmy.Waiter;
 
 /**
  * <BR>
@@ -52,6 +55,8 @@
  */
 public class JToolTipOperator extends JComponentOperator {
 
+    private static long WAIT_TOOLTIP_TIMEOUT = 60000;
+
     /**
      * Identifier for a "tip text" property.
      *
@@ -59,6 +64,9 @@
      */
     public static final String TIP_TEXT_DPROP = "TipText";
 
+    static {
+        Timeouts.initDefault("JToolTipOperator.WaitToolTipTimeout", WAIT_TOOLTIP_TIMEOUT);
+    }
     /**
      * Constructs a JToolTipOperator object, waiting for a shown
      * JToolTip.
@@ -286,8 +294,7 @@
      */
     public static JToolTip waitJToolTip(ComponentOperator comp,
             ComponentChooser chooser) {
-        return Operator.getEnvironmentOperator().
-                waitState(new Waitable<JToolTip, Void>() {
+        Waitable<JToolTip, Void> waitable = new Waitable<JToolTip, Void>() {
             @Override
             public JToolTip actionProduced(Void obj) {
                 return findJToolTip(comp, chooser);
@@ -304,7 +311,19 @@
                 return "JToolTipOperator.waitJToolTip.Waitable{description = "
                         + getDescription() + '}';
             }
-        });
+        };
+        Waiter<JToolTip, Void> stateWaiter = new Waiter<>(waitable);
+        stateWaiter.setTimeoutsToCloneOf(Operator.getEnvironmentOperator().
+                getTimeouts(), "JToolTipOperator.WaitToolTipTimeout");
+        stateWaiter.setOutput(Operator.getEnvironmentOperator().
+                getOutput().createErrorOutput());
+        try {
+            return stateWaiter.waitAction(null);
+        } catch (InterruptedException e) {
+           Thread.currentThread().interrupt();
+           throw (new JemmyException("Waiting of " + waitable.getDescription()
+               + " state has been interrupted!"));
+        }
     }
 
     /**
--- a/src/org/netbeans/jemmy/version_info	Mon Oct 29 21:52:18 2018 -0700
+++ b/src/org/netbeans/jemmy/version_info	Thu Nov 08 23:09:10 2018 -0800
@@ -1,6 +1,6 @@
 Manifest-version: 1.0
 Main-Class: org.netbeans.jemmy.JemmyProperties
 Jemmy-MajorVersion: 3.0
-Jemmy-MinorVersion: 6.0
+Jemmy-MinorVersion: 7.0
 Jemmy-Build: @BUILD_NUMBER@
 
--- a/test/org/netbeans/jemmy/operators/JToolTipOperatorTest.java	Mon Oct 29 21:52:18 2018 -0700
+++ b/test/org/netbeans/jemmy/operators/JToolTipOperatorTest.java	Thu Nov 08 23:09:10 2018 -0800
@@ -30,6 +30,7 @@
 
 import org.netbeans.jemmy.ComponentChooser;
 import org.netbeans.jemmy.TimeoutExpiredException;
+import org.netbeans.jemmy.Timeouts;
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
@@ -45,6 +46,8 @@
         frame = new JFrame();
         frame.setSize(400,400);
         frame.setLocationRelativeTo(null);
+        Timeouts timeouts = Operator.getEnvironmentOperator().getTimeouts();
+        timeouts.setTimeout("JToolTipOperator.WaitToolTipTimeout", 5000);
     }
 
     @AfterClass