Thursday, September 1, 2011

Re: How to mock Listbox when testing the Presenter class?

I think I got it what you saying. I got caught up with MVP-Part 2 in
terms of activities and places and kind of lost the major
understanding of what it is ultimately trying to tell you to avoid
HasXxxHandlers.

So I have one question here.. If my presenter implements the interface
which view calls back and how does presenter will get hold of my
listbox defined in the view?

On Sep 1, 11:40 am, Thomas Broyer <t.bro...@gmail.com> wrote:
> I'd highly encourage you to use the pattern from the "MVP - part 2" article
> from the GWT doc, where the presenter itself implements an interface that
> the view calls back, rather than exposing the view through HasXxxHandlers
> and the like. It makes mocking so much painful! (having to mock
> HasXxxHandlers is a PITA compared to simply mocking your View interface, and
> capturing the presenter from the setPresenter method so you can call methods
> on it as if the view did it).
>
> To answer your question, your view should expose the methods you use from
> the ListBox (and simply delegate them to the listbox); you shouldn't try to
> expose "the listbox" as an object from your view (because as you said,
> there's no "matching" interface). So you'll add those 7 methods to your view
> (possibly using a naming scheme such as getAdmin, setAdmin, etc.).
> Also, instead of a ListBox, you could use a ValueListBox so you can directly
> "push" your "model" to your view, and get the selected object back from the
> view.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment