- intuitive
- well documented
myButton.click();
...because that clicks the button without firing any listeners. Instead, within your GWTTestCase-derived unit test, put a method like this:
private native void fireClickListeners( FocusWidget w )
/*-{
w.@com.google.gwt.user.client.ui.FocusWidget::fireClickListeners()();
}-*/;
/*-{
w.@com.google.gwt.user.client.ui.FocusWidget::fireClickListeners()();
}-*/;
It looks funny I know. Make sure you:
- include the native keyword, which the GWT compiler understands to mean JavaScript Native Interface (JSNI), rather than Java Native Interface (JNI)
- include the starting and ending comment delimiters, because the code inside the function is actually JavaScript code, which
means nothing to the Java compiler
You can then call this method just as you would a normal method:
fireClickListeners( myButton );
Hope that helps somebody. I'm using this in the upcoming release of Metawidget.
0 comments:
Post a Comment