Make some of the c.g.g.view.client.*SelectionModelTest tests async.#10365
Make some of the c.g.g.view.client.*SelectionModelTest tests async.#10365niloc132 wants to merge 1 commit into
Conversation
SelectionModel fires selection events using a finally command and some tests using SelectionChangeEvent.Handler were not async. In addition these tests had an implementation that let the test fail (but ANT never noticed because tests were sync). This CL makes sure all tests using SelectionChangeEvent.Handler are async and updates implementation slightly to correclty assert event behavior. Bug: gwtproject#9622 Bug-Link: gwtproject#9622 Change-Id: I66ba1170d2a1335d3ad921346017b5b5bc1accf8
There was a problem hiding this comment.
Here the AssertOneSelectionChangeEventOnlyHandler is still listening, so it would fail in case another event is fired. We shouldn't need to ad a second handler for that.
There was a problem hiding this comment.
MockSelectionChangeHandler requires you to call assertEventFired and it will clear its internal state after that call, so you always have to do event -> check -> event -> check. MockSelectionChangeHandler will fail if it sees a second event in a row without calling assertEventFired in between.
If we would remove the failing handler then the first model.setSelected() following this line would only be recorded and only the second call would trigger the exception in MockSelectionChangeHandler because you haven't called assertEventFired in between two events. That makes the test a little imprecise. If you would want to call assertEventFired in between then it must happen async again which bloats the code.
The failing handler exists to simplify the logic and to make sure that the first additional event already fails the test and not the second.
There was a problem hiding this comment.
Again, this handler may not be needed.
There was a problem hiding this comment.
Again, this handler may not be needed.
zbynek
left a comment
There was a problem hiding this comment.
The code looks correct, but some of the handlers are not needed as far as I understand (see inline comments).
Alternatively, instead of two types of mock handlers it should be possible to have one type that counts events and let the test make assertions on those counts.
SelectionModel fires selection events using a finally command and some tests using SelectionChangeEvent.Handler were not async. In addition these tests had an implementation that let the test fail (but ANT never noticed because tests were sync).
This CL makes sure all tests using SelectionChangeEvent.Handler are async and updates implementation slightly to correclty assert event behavior.
Previously submitted as https://gwt-review.googlesource.com/c/gwt/+/21060.
Fixes #9622