This is a problem we've dealt with by using either assisted injection or a setter method.
To use the former, the pattern is this:
// Some common marker interfaces
interface View { }
interface Presenter { }
// A common factory interface
interface ViewFactory<P extends Presenter, V extends View> {
V create(P presenter);
}
// You can also do this based on a subclass, etc
interface YourView extends View {
//...define its methods
interface YourViewFactory extends ViewFactory<YourPresenter, YourView> { }
}
class YourPresenter {
private final YourView view;
@Inject(YourViewFactory factory, ...) {
this.view = factory.create(this);
}
...
}
Depending on your abstraction needs, you can collapse / pull up the interface definitions as you wish.
The most important thing here IMO is to keep the presenter free of GWT logic, and as long as you do that, your unit testing of the presenter can be done using plain testing code (i.e., no GWT testing code is necessary).
Some folks don't mind having the "presenter" variable non-final in the view, and define a setter() method on the view:
class YourPresenter {
private final YourView view;
@Inject(YourView view, ...) {
this.view = view;
view.setPresenter(this);
}
...
}
There is more detail in this GWT issue, fwiw: