From 3715cbe450be825950219d90eebb2f4b876b6069 Mon Sep 17 00:00:00 2001
From: Abdul Kolarkunnu <akolarkunnu@openjdk.org>
Date: Fri, 16 Feb 2018 18:27:35 +0530
Subject: [PATCH] 8197549: Implement a new method similar to waitState() on
 Operator which run the check on event queue

Reviewed-by: serb
---
 .../netbeans/jemmy/operators/Operator.java    | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java
index 86d274f7ffc..2681527ab6d 100644
--- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java
+++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/Operator.java
@@ -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 @@ public abstract class Operator
         }
     }
 
+    /**
+     * 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                                             //
     ////////////////////////////////////////////////////////