8197549: Implement a new method similar to waitState() on Operator which run the check on event queue
authorakolarkunnu
Fri, 16 Feb 2018 18:27:35 +0530
changeset 49089 149647adb633
parent 49088 1fc095fa0cd7
child 49090 82c1fe23c469
8197549: Implement a new method similar to waitState() on Operator which run the check on event queue Reviewed-by: serb
test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java
--- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java	Fri Feb 16 18:17:34 2018 +0530
+++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java	Fri Feb 16 18:27:35 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -718,6 +718,25 @@
         }
     }
 
+    /**
+     * Waits a state specified by a ComponentChooser instance on EDT queue.
+     *
+     * @param state a ComponentChooser defining the state criteria.
+     * @throws TimeoutExpiredException if the state has not achieved in a value
+     * defined by {@code "ComponentOperator.WaitStateTimeout"}
+     */
+    public void waitStateOnQueue(final ComponentChooser state) {
+        waitState((comp) -> {
+            return (boolean) (queueTool.invokeSmoothly(
+                    new QueueTool.QueueAction<Object>("checkComponent") {
+                @Override
+                public final Object launch() throws Exception {
+                    return state.checkComponent(comp);
+                }
+            }));
+        });
+    }
+
     ////////////////////////////////////////////////////////
     //Mapping                                             //
     ////////////////////////////////////////////////////////