Friday, September 2, 2011

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

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

==> Can you elaborate more on this? My only question here is if my
presenter implements the interface and view has the method call
setPresenter which basically binds that presenter to the View, how
does the view calls back those methods implemented in the Presenter?
Does view need to pass every UIField in the method call to Presenter?
That is where I am lost here. Sorry I am new to GWT but I want to be
perfect so asking lot of questions.

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