Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Force flushing of pending UI events
Force flushing of pending UI events [message #1408476] Fri, 15 August 2014 06:27 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Hi,
I have the following SWTBot test scenario (Test suite started as SWTBot test):

= Test method A started
- trigger changes to an object (non UI)
which itself asynchronously triggers UI events which are not immediately dispatched
- verify the object
- quit test

= Test method B started
- do something
-> UI events from method A are dispatched now, method B fails as UI events are dispatched with stale data (NPE, widget disposed)

How do I prevent such cases? How do I wait or flush the pending UI events before quitting test method A? I tried to Display.readAndDispatch() in a loop but that is no guarantee to always work as I do not know how long to readAndDispatch()...
I know the asynchronously triggered UI events have to be safe against stale data, but that would clutter the code with lots of isDisposed() calls.
Re: Force flushing of pending UI events [message #1409580 is a reply to message #1408476] Mon, 18 August 2014 12:56 Go to previous message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Are you running your tests in the UI Thread? If yes, you should not.

I wouldn't advise writing any code depending on SWT events inside
SWTBot. SWTBot is better for higher level check (such as availability of
a widget) and it's better to use high-level check than relying on event
processing assumption.
Maybe you could write your testA in a way that it also checks that the
event it generated had the right effect.


--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Previous Topic:editor's cursor disappear
Next Topic:JRuby Support
Goto Forum:
  


Current Time: Fri Apr 19 20:48:50 GMT 2024

Powered by FUDForum. Page generated in 0.02524 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top