On Feb 22, 1:17 pm, FKereki <[email protected]> wrote:
> On Feb 22, 6:41 am, Thomas Broyer <[email protected]> wrote:
>
> > On Feb 21, 5:42 pm, FKereki <[email protected]> wrote:
>
> > > I'm running some GWTTestCase code, and was wondering... isn't
> > > button.click() the same as creating a DOM click event and firing it
> > > for the button?
>
> > No, it calls the button's (JavaScript/DOM) click() method.
>
> > > I'm testing a View. I added a (mock) method that set variable
> > > wasCalled to true; I just want to test whether the View correctly
> > > links the button click with the method. I set wasCalled to false, I
> > > fire the click event, and I check assertTrue(wasCalled).  My test code
> > > looks, in part, like:
>
> > > wasCalled = false;
>
> > > // doing the following works:
> > > final Document doc = com.google.gwt.dom.client.Document.get();
> > > final NativeEvent evt = doc.createClickEvent(0, 0, 0, 0, 0, false,
> > > false, false, false);
> > > DomEvent.fireNativeEvent(evt, lv.loginButton);
>
> > > // doing the following doesn't:
> > > // lv.loginButton.click();
>
> > > assertTrue(wasCalled);
>
> > > If I try to fire the click event with click(), nothing happens. If I
> > > go the DOM event way, the method fires all right.
>
> > > What am I missing here?
>
> > click() doesn't fire an event, it just executes the "default 
> > action":http://www.w3.org/TR/html5/editing.html#dom-click
>
> I'm still missing something... according to the page you cited, "If
> the element has a defined activation behavior, run synthetic click
> activation steps on the element. Otherwise, fire a click event at the
> element." In the past (i.e., with earlier versions of GWT, with
> listeners instead of handlers) I'm pretty sure I wrote unit tests by
> doing button.click(), and they worked...

I just did a SVN blame on Button.java and it has *always* (from rev.
1) just deferred to the JavaScript click().
The only changes (2 only) were refactorings.

-- 
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.

Reply via email to