Search in sources :

Example 1 with DataResource

use of com.google.gwt.resources.client.DataResource in project gwt-test-utils by gwt-test-utils.

the class ClientBundleTest method dataResource.

@Test
public void dataResource() {
    // Given
    DataResource testDataResource = MyClientBundle.INSTANCE.dataResource();
    // When
    String name = testDataResource.getName();
    String url = testDataResource.getSafeUri().asString();
    String toString = testDataResource.toString();
    // Then
    assertThat(name).isEqualTo("dataResource");
    assertThat(url).isEqualTo("http://127.0.0.1:8888/gwt_test_utils_module/textResourceXml.xml");
    assertThat(toString).isEqualTo("com.googlecode.gwt.test.internal.resources.DataResourceCallback generated for 'com.googlecode.gwt.test.resources.MyClientBundle.dataResource()'");
    assertThat(MyClientBundle.INSTANCE.dataResource()).isEqualTo(testDataResource);
}
Also used : DataResource(com.google.gwt.resources.client.DataResource) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 2 with DataResource

use of com.google.gwt.resources.client.DataResource in project gerrit by GerritCodeReview.

the class ModeInfo method indexModes.

private static void indexModes(DataResource[] all) {
    for (DataResource r : all) {
        modeUris.put(r.getName(), r.getSafeUri());
    }
    JsArray<ModeInfo> modeList = all();
    modeList.push(gerrit_commit());
    byMime = NativeMap.create();
    JsArray<ModeInfo> filtered = JsArray.createArray().cast();
    for (ModeInfo m : Natives.asList(modeList)) {
        if (modeUris.containsKey(m.mode())) {
            filtered.push(m);
            for (String mimeType : Natives.asList(m.mimes())) {
                byMime.put(mimeType, m);
            }
            byMime.put(m.mode(), m);
        }
    }
    Collections.sort(Natives.asList(filtered), new Comparator<ModeInfo>() {

        @Override
        public int compare(ModeInfo a, ModeInfo b) {
            return a.name().toLowerCase().compareTo(b.name().toLowerCase());
        }
    });
    setAll(filtered);
}
Also used : DataResource(com.google.gwt.resources.client.DataResource) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 3 with DataResource

use of com.google.gwt.resources.client.DataResource in project gwt-test-utils by gwt-test-utils.

the class MyOverridedClientBundleTest method testDataResource_NoOverride.

@Test
public void testDataResource_NoOverride() {
    // Given
    DataResource testDataResource = MyOverridedClientBundle.INSTANCE.dataResource();
    // When
    String name = testDataResource.getName();
    String url = testDataResource.getSafeUri().asString();
    String toString = testDataResource.toString();
    // Then
    assertThat(name).isEqualTo("dataResource");
    assertThat(url).isEqualTo("http://127.0.0.1:8888/gwt_test_utils_module/textResourceXml.xml");
    assertThat(toString).isEqualTo("com.googlecode.gwt.test.internal.resources.DataResourceCallback generated for 'com.googlecode.gwt.test.resources.override.MyOverridedClientBundle.dataResource()'");
    assertThat(MyOverridedClientBundle.INSTANCE.dataResource()).isEqualTo(testDataResource);
}
Also used : DataResource(com.google.gwt.resources.client.DataResource) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 4 with DataResource

use of com.google.gwt.resources.client.DataResource in project playn by threerings.

the class HtmlAssets method getSound.

@Override
public Sound getSound(String path) {
    String url = pathPrefix + path;
    AutoClientBundleWithLookup clientBundle = getBundle(path);
    if (clientBundle != null) {
        String key = getKey(path);
        DataResource resource = (DataResource) getResource(key, clientBundle);
        if (resource != null) {
            url = resource.getSafeUri().asString();
        }
    } else {
        url += ".mp3";
    }
    return adaptSound(url);
}
Also used : DataResource(com.google.gwt.resources.client.DataResource) AutoClientBundleWithLookup(playn.core.AutoClientBundleWithLookup)

Aggregations

DataResource (com.google.gwt.resources.client.DataResource)4 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)2 Test (org.junit.Test)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 AutoClientBundleWithLookup (playn.core.AutoClientBundleWithLookup)1