Oh! of course. That's perfect, thank you. Nancy Deschenes
On Oct 5, 11:12 am, Thomas Broyer <[email protected]> wrote: > On 5 oct, 16:18, Nala <[email protected]> wrote: > > > > > > > I have started writing a few tests, and I have successfully confirmed > > that the events I expect to see fired are fired. I`m using variations > > on > > > public void testEventFired() { > > delayTestFinish(2000); > > Foo myFoo = new Foo(); > > myFoo.addChangeHander(new ChangeHandler() { > > public void onChange(ChangeEvent event) { > > // assert that all the parts of the event are set correctly > > finishTest(); > > } > > }); > > myFoo.doThingThatTriggersChangeEvent(); > > } > > > Now I'd like to test that myFoo.doThingThatDoesNotTriggerChangeEvent() > > doesn't fire a ChangeEvent. I have to wait to give the event a chance > > to fire, but when the delay runs out, I want the test to be successful > > instead of fail. > > > Is there any way to do that? > > Yes, using a timer and a non-anonymous handler class; something like: > > private class CountingChangeHandler implements ChangeHandler { > public int callCount; > > public void onChange(ChangeEvent event) { > callCount++; > }} > > ... > Foo myFoo = new Foo(); > final CountingChangeHandler handler = new CountingChangeHandler(); > delayTestFinish(3000); > (new Timer() { > public void run() { > // if handler.callCount isn't 0, it means it has been called! > assertEquals(0, handler.callCount); > finishTest(); > }}).shedule(2500); > > myFoo.doSomethingThatTriggersChangeEvent(); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
