Search in sources :

Example 1 with TextResource

use of com.google.gwt.resources.client.TextResource in project actor-platform by actorapp.

the class JsAssetsProvider method loadAsset.

@Override
public String loadAsset(String name) {
    name = name.replace('.', '_');
    Log.d("AssetsRuntime", "loadAsset: " + name);
    for (ClientBundleWithLookup b : bundles) {
        ResourcePrototype res = b.getResource(name);
        if (res != null) {
            Log.d("AssetsRuntime", "loadAsset " + res);
            return ((TextResource) res).getText();
        }
    }
    return null;
}
Also used : TextResource(com.google.gwt.resources.client.TextResource) ClientBundleWithLookup(com.google.gwt.resources.client.ClientBundleWithLookup) ResourcePrototype(com.google.gwt.resources.client.ResourcePrototype)

Example 2 with TextResource

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

the class ClientBundleTest method textResource_Txt.

@Test
public void textResource_Txt() {
    // Given
    TextResource textResource = MyClientBundle.INSTANCE.textResourceTxt();
    String expectedText = "Hello gwt-test-utils !\r\nThis is a test with a simple text file";
    // When
    String name = textResource.getName();
    String text = textResource.getText();
    String toString = textResource.toString();
    // Then
    assertThat(name).isEqualTo("textResourceTxt");
    assertThat(text).isEqualTo(expectedText);
    assertThat(toString).isEqualTo("com.googlecode.gwt.test.internal.resources.TextResourceCallback generated for 'com.googlecode.gwt.test.resources.MyClientBundle.textResourceTxt()'");
    assertThat(MyClientBundle.INSTANCE.textResourceTxt()).isEqualTo(textResource);
}
Also used : TextResource(com.google.gwt.resources.client.TextResource) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 3 with TextResource

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

the class ClientBundleTest method textResource_Xml.

@Test
public void textResource_Xml() {
    // Given
    TextResource textResource = MyClientBundle.INSTANCE.textResourceXml();
    String expectedText = "<gwt-test-utils>\r\n    <test>this is a test</test>\r\n</gwt-test-utils>";
    // When
    String name = textResource.getName();
    String text = textResource.getText();
    String toString = textResource.toString();
    // Then
    assertThat(name).isEqualTo("textResourceXml");
    assertThat(text).isEqualTo(expectedText);
    assertThat(toString).isEqualTo("com.googlecode.gwt.test.internal.resources.TextResourceCallback generated for 'com.googlecode.gwt.test.resources.MyClientBundle.textResourceXml()'");
    assertThat(MyClientBundle.INSTANCE.textResourceXml()).isEqualTo(textResource);
}
Also used : TextResource(com.google.gwt.resources.client.TextResource) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 4 with TextResource

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

the class MyOverridedClientBundleTest method textResourceTxt_OverrideWithoutAnnotation.

@Test
public void textResourceTxt_OverrideWithoutAnnotation() {
    // Given
    TextResource textResource = MyOverridedClientBundle.INSTANCE.textResourceTxt();
    String expectedText = "Overrided text resource !";
    // When
    String name = textResource.getName();
    String text = textResource.getText();
    // Then
    assertThat(name).isEqualTo("textResourceTxt");
    assertThat(text).isEqualTo(expectedText);
    assertThat(MyOverridedClientBundle.INSTANCE.textResourceTxt()).isEqualTo(textResource);
}
Also used : TextResource(com.google.gwt.resources.client.TextResource) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Aggregations

TextResource (com.google.gwt.resources.client.TextResource)4 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)3 Test (org.junit.Test)3 ClientBundleWithLookup (com.google.gwt.resources.client.ClientBundleWithLookup)1 ResourcePrototype (com.google.gwt.resources.client.ResourcePrototype)1