Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LayoutComposite requires that its wrapped widget implement RequiresResize #15

Closed
nikp opened this issue Sep 13, 2013 · 2 comments
Closed

Comments

@nikp
Copy link

nikp commented Sep 13, 2013

I have a widget which extends ResizeComposite, and I'm using the GwtMockitoTestRunner

The call inside the constructor initWidget(uiBinder.createAndBindUi(this)); fails with this exception because initWidget inside ResizeComposite has the following assert:

    assert widget instanceof RequiresResize :
      "LayoutComposite requires that its wrapped widget implement RequiresResize";

I have a feeling this is related to #4, but perhaps not.

I realize uiBinder is a FakeUiBinder, but I think it should ensure that the mocks it returns do more than just initialize the UiFields, it should also ensure to implement all the original interfaces of the owner widget.

@ekuefler
Copy link
Collaborator

Could you show how you're setting up your UiBinder? This seems to work for me:

interface MyUiBinder extends UiBinder<DataGrid, MyClass> {}
private final MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
MyClass() {
  initWidget(uiBinder.createAndBindUi(this));
}

However, it only works if I declare the UiBinder to extend UiBinder<DataGrid, MyClass>, not UiBinder<Widget, MyClass>. This makes sense, since if you declare it to return a widget there's no way for GwtMockito to know you need to implement RequiresResize. Any chance this is the problem, or am I misunderstanding?

While debugging this I did find an unrelated bug that GwtMockito wasn't handling UiBinders that return a generic type properly - I fixed that in 8706592 in case you run into it.

@nikp
Copy link
Author

nikp commented Sep 19, 2013

You are absolutely right, that is the difference!

Though your bug fix seems like it could be related too, because my UI binder was defined like:

interface MyViewImplUiBinder extends UiBinder<Widget, MyViewImpl<T>> {}

@nikp nikp closed this as completed Sep 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants