manolo / gwt-polymer-elements

Polymer Web Components for GWT. A collection of Material Design widgets for desktop and mobile.
Apache License 2.0
155 stars 49 forks source link

GWTTestCase with gwt-polymer-elements #90

Closed frankstolle closed 7 years ago

frankstolle commented 8 years ago

Is there any possibility to test gwt-polymer-elements with GWTTestCase? I am also thinking about how to include webcomponents.min.js in TestCase

I tried the following Test:

    public void testName() throws Exception {
        Polymer.importHref("paper-styles");
        Polymer.whenReady(new Function() {
            @Override
            public Object call(Object o) {
                PaperButton button = new PaperButton();
                return null;
            }
        });
    }

And I got the following Exception

com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot call method "whenReady" of undefined
    at com.vaadin.polymer.Polymer.whenReady(Polymer.java:364)
    at org.jajax.gwt.polymer.client.PolymerGwtTest.testName(Polymer.java:355)
    at Unknown.anonymous(GWTTestMetadataImpl.java:8)
    at com.google.gwt.junit.client.impl.GWTTestAccessor.$invoke(GWTTestAccessor.java:35)
    at com.google.gwt.junit.client.impl.GWTRunner.$executeTestMethod(GWTRunner.java:226)
    at com.google.gwt.junit.client.GWTTestCase.$doRunTest(GWTTestCase.java:157)
    at com.google.gwt.junit.client.GWTTestCase.$runBare(TestCase.java:59)
    at com.google.gwt.junit.client.GWTTestCase.$__doRunTest(GWTTestCase.java:115)
    at com.google.gwt.junit.client.impl.GWTRunner.$runTest(GWTRunner.java:302)
    at com.google.gwt.junit.client.impl.GWTRunner.$doRunTest(GWTRunner.java:235)
    at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.$onSuccess(GWTRunner.java:106)
    at com.google.gwt.junit.client.impl.GWTRunner$InitialResponseListener.$onSuccess(GWTRunner.java:61)
    at com.google.gwt.junit.client.impl.GWTRunner$InitialResponseListener.onSuccess(GWTRunner.java:59)
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.$onResponseReceived(RequestCallbackAdapter.java:232)
    at com.google.gwt.http.client.Request.$fireOnResponseReceived(Request.java:250)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
    at Unknown.anonymous(XMLHttpRequest.java:329)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java:239)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:298)
    at Unknown.anonymous(Impl.java:77)
manolo commented 7 years ago

Include your script in your Test.gwt.xml file in this way

<script src='bower_components/webcomponentsjs/webcomponents-lite.js ' />