Re: Simulating button click in GWT Unit test?

2011-06-05 Thread Ed
Thanks for the tip Thomas.
At the moment I am busy getting it all to work.
I use the mvp pattern. Only this this view part is important so need
some more testing...
It's a bit difficult to change it to use the AsWidget interface as the
code is already 3 years old, and the code iterates through a
panel. etc..

Let's see how it all works out...
Thanks all for the feedback.
- Ed

On Jun 4, 7:33 pm, Thomas Broyer t.bro...@gmail.com wrote:
 How about: myButton.getElement().ButtonElementcast().click() ?

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Simulating button click in GWT Unit test?

2011-06-04 Thread Ed
I have to simulate a button click on a button that is created in a GWT
Unit test (that extends from GWTTestCase).
However, it's almost impossible to get a direct reference to the
button to simulate the click directly on the button event.

The button, however, has a unique id through the HTML tag id property.
Is there away to find the button element and then simulate the button
click in a GWT Unit test ?

I am not sure how to do this.
Finding the element through Document.get().getElementById(bla) I
don't think works as RootPanel.get() doesn't contain the expected
application elements but rather GWT Junit stuff...? :(
And then how to simulate a button click on the found element :(...

Please some advice?
- Ed

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Simulating button click in GWT Unit test?

2011-06-04 Thread Magno Machado
Shouldn't this test be an acceptance test run by something like selenium,
instead of using GWTTestCase?

On Sat, Jun 4, 2011 at 10:51 AM, Ed post2edb...@gmail.com wrote:

 I have to simulate a button click on a button that is created in a GWT
 Unit test (that extends from GWTTestCase).
 However, it's almost impossible to get a direct reference to the
 button to simulate the click directly on the button event.

 The button, however, has a unique id through the HTML tag id property.
 Is there away to find the button element and then simulate the button
 click in a GWT Unit test ?

 I am not sure how to do this.
 Finding the element through Document.get().getElementById(bla) I
 don't think works as RootPanel.get() doesn't contain the expected
 application elements but rather GWT Junit stuff...? :(
 And then how to simulate a button click on the found element :(...

 Please some advice?
 - Ed

 --
 You received this message because you are subscribed to the Google Groups
 Google Web Toolkit group.
 To post to this group, send email to google-web-toolkit@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.




-- 
Magno Machado Paulo
http://blog.magnomachado.com.br
http://code.google.com/p/emballo/

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Simulating button click in GWT Unit test?

2011-06-04 Thread Ed
 Shouldn't this test be an acceptance test run by something like selenium,
 instead of using GWTTestCase?

It's also run by Selenium under different circumstances (that's why it
has an idea).

So you know how to do the above test?

On Jun 4, 4:06 pm, Magno Machado magn...@gmail.com wrote:
 Shouldn't this test be an acceptance test run by something like selenium,
 instead of using GWTTestCase?









 On Sat, Jun 4, 2011 at 10:51 AM, Ed post2edb...@gmail.com wrote:
  I have to simulate a button click on a button that is created in a GWT
  Unit test (that extends from GWTTestCase).
  However, it's almost impossible to get a direct reference to the
  button to simulate the click directly on the button event.

  The button, however, has a unique id through the HTML tag id property.
  Is there away to find the button element and then simulate the button
  click in a GWT Unit test ?

  I am not sure how to do this.
  Finding the element through Document.get().getElementById(bla) I
  don't think works as RootPanel.get() doesn't contain the expected
  application elements but rather GWT Junit stuff...? :(
  And then how to simulate a button click on the found element :(...

  Please some advice?
  - Ed

  --
  You received this message because you are subscribed to the Google Groups
  Google Web Toolkit group.
  To post to this group, send email to google-web-toolkit@googlegroups.com.
  To unsubscribe from this group, send email to
  google-web-toolkit+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.

 --
 Magno Machado 
 Paulohttp://blog.magnomachado.com.brhttp://code.google.com/p/emballo/

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Simulating button click in GWT Unit test?

2011-06-04 Thread Deanna Bonds
Can you directly call the click handler in the activity.  If you are testing 
the functionality that seems the best place to test.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/dXNDVURLd0UxRVlK.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Simulating button click in GWT Unit test?

2011-06-04 Thread Jeff Chimene
On 06/04/2011 06:51 AM, Ed wrote:
 I have to simulate a button click on a button that is created in a GWT
 Unit test (that extends from GWTTestCase).
 However, it's almost impossible to get a direct reference to the
 button to simulate the click directly on the button event.
 
 The button, however, has a unique id through the HTML tag id property.
 Is there away to find the button element and then simulate the button
 click in a GWT Unit test ?
 
 I am not sure how to do this.
 Finding the element through Document.get().getElementById(bla) I
 don't think works as RootPanel.get() doesn't contain the expected
 application elements but rather GWT Junit stuff...? :(
 And then how to simulate a button click on the found element :(...
 
 Please some advice?
 - Ed
 

Create a MouseOutEvent. You'll want to modify to fit your circumstances.
This includes locating tb.

final Button tb;

/*
* Synthesize and fire an event
*/
final
NativeEvent evt = Document.get().createMouseOutEvent(1 /* detail */
, 0 /* screenX */
, 0 /* screenY */
, 0 /* clientX */
, 0 /* clientY */
, false /* ctrlKey */
, false /* altKey */
, false /* shiftKey */
, false /* metaKey */
, NativeEvent.BUTTON_LEFT /* button */
, null /* relatedTarget */);

tb.getElement().dispatchEvent(evt);

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Simulating button click in GWT Unit test?

2011-06-04 Thread Thomas Broyer
How about: myButton.getElement().ButtonElementcast().click() ?

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/WFExLXQ0NXdxSWdK.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.