In my tool, I record events generated from user application. Now user can use my tool to replay his scenario.
While replaying user's recorded scenario, I post recorded events to "EventQueue" one by one using:
eventQueueObj.postEvent(eventObj);
In most of the cases there is no problem in replaying user's recorded scenario.
To explain my problem, I will give short example.
User of my tool want to check whether in his application, "Close" button under "File" menu works or not. His scenario is:
1) Click File Menu.
2) Click Open Menu Item
3) Select File from File Chooser.
4) Click Open on File Chooser.
5) After File is Opened, Click File Menu.
6) Click Close Menu Item.
There is no problem in replaying Step 1 to Step 4. Now at Step 5, I am supposed to wait until file is opened (file being opened is quite large and going to take some time). If I do not wait until file is opened and move forward, "Close" menu item under "File" menu remains disabled. So there is no use of firing Mouse Click Event on "Close" menu item.
My question is "How can I get information from Event Dispatch Thread that it has finished processing of current events?"
After this I can go for clicking on "File" menu and then Step 6.
I don't want to use sleep() to recursively check whether "Close" menu item is enabled or not. Because I want to wait only for required amount of time and not some approximate time.
If I use sleep(), in most of cases I am going to waste some execution time even if user's file open operation is finished.