I got this HyperlinkCell class somewhere and it works pretty good.
public class HyperlinkCell extends AbstractCell<Hyperlink>
{
@Override
public void render( com.google.gwt.cell.client.Cell.Context context,
Hyperlink h, SafeHtmlBuilder sb )
{
sb.append( SafeHtmlUtils.fromTrustedString( h.toString() ) );
}
}
As I thought about it more I ask myself what do I want to test. I'd like
to test that the data in the view is retrieved properly, put into a query
properly, and that the query works. I don't need to test that the view
displays things properly. I'll assume Google tested its widgets.
Given that, what do you think about this idea for testing? I got this idea
by examining the Display interface technique.
Add getters and setters to for each view field. Using the above example,
public class PersonSearchViewImpl extends ResizeComposite implements
PersonSearchView
{
public void setFirstname( String firstname )
{
this.firstname.setText( firstname );
}
public String getFirstname()
{
firstname.getText();
}
}
Then a GWTTestCase could be written to call all the setters (which fill in
the form fields) and press the Find button (need to add a method to
simulate the pressing of the Find button).
On Wednesday, June 13, 2012 3:30:26 AM UTC-7, Thomas Broyer wrote:
>
>
>
> On Wednesday, June 13, 2012 2:59:33 AM UTC+2, Mike Dee wrote:
>>
>>
>> A couple of questions regarding a test I'd like to perform. Let's assume
>> that testing occurs with a live database (and GWT-RPC). I know that
>> contest of the database and what should be returned for certain queries.
>> I'd like to run tests that execute certain queries and make sure they
>> appear in the table (at certain positions).
>>
>
> I'd probably rather use Selenium/WebDriver tests here.
>
>
>> 1) How would I test the clicking within the results. For example, each
>> person's name appears (per row) as a Hyperlink in the results. This is
>> implemented in a CellTable with Hyperlinks. Normal behavior is that when
>> the Hyperlink is clicked, GWT goes to the new place. There is no
>> notification to the activity. I suppose a ClickHandler could be added, but
>> it would have no usefulness other than testing. Would it be better to not
>> use a Hyperlink (maybe a Label with a click handler) and add a
>> selectPerson() method to the Presenter. Then the activity could test the
>> selection and handle the advancing to the new Place?
>>
>
> How can you possibly use a Hyperlink (widget) in a CellTable?!
> You might want to handle the "click" event from within your cell and call
> History.newItem() or PlaceController#goTo() from there (still not
> testable), or use a callback (similar to ButtonCell, ActionCell, or
> ClickableTextCell) where you put the History/PlaceController stuff, or
> route it through the Presenter.
>
>
>> 2) I've seen a technique where a Display interface is created within the
>> Presenter. It contains a list of HasText and HasClickHandlers that
>> conceptually define the View. It seems pretty fine grained. Of course,
>> this has the same issue related to Hyperlinks.
>>
>
> Don't do that, if you ever write tests with a mock view, it'll be a pain
> to mock.
>
--
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/-/tW8FwX5ZMiUJ.
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.