use of org.gwtproject.core.client.JavaScriptObject in project gwtproject by treblereel.
the class ElementTest method testProperties.
/**
* setProperty*, getProperty*.
*/
@Test
public void testProperties() {
DivElement div = Document.get().createDivElement();
div.setPropertyString("foo", "bar");
assertEquals("bar", div.getPropertyString("foo"));
div.setPropertyInt("foo", 42);
assertEquals(42, div.getPropertyInt("foo"));
div.setPropertyBoolean("foo", true);
div.setPropertyBoolean("bar", false);
assertTrue(div.getPropertyBoolean("foo"));
assertFalse(div.getPropertyBoolean("bar"));
Object obj = new Object();
div.setPropertyObject("baz", obj);
assertEquals(obj, div.getPropertyObject("baz"));
JavaScriptObject jso = JavaScriptObject.createObject();
div.setPropertyJSO("tintin", jso);
assertEquals(jso, div.getPropertyJSO("tintin"));
assertNull(div.getPropertyObject("inexistant_property_at_least_we_hope_so"));
div.setPropertyObject("baz", Boolean.TRUE);
assertEquals(Boolean.TRUE, div.getPropertyObject("baz"));
div.setPropertyObject("baz", Boolean.FALSE);
assertEquals(Boolean.FALSE, div.getPropertyObject("baz"));
div.setPropertyObject("baz", 42.0);
assertEquals(42.0, div.getPropertyObject("baz"));
div.setPropertyObject("baz", 0.0);
assertEquals(0.0, div.getPropertyObject("baz"));
div.setPropertyObject("baz", Double.NaN);
assertTrue(Double.isNaN((Double) div.getPropertyObject("baz")));
div.setPropertyObject("baz", "tintin");
assertEquals("tintin", div.getPropertyObject("baz"));
div.setPropertyObject("baz", "");
assertEquals("", div.getPropertyObject("baz"));
}
use of org.gwtproject.core.client.JavaScriptObject in project gwtproject by treblereel.
the class NodeTest method testIsAndAs.
/**
* Tests Element.is() and Element.as().
*/
@Test
public void testIsAndAs() {
assertTrue(Node.is(Document.get()));
JavaScriptObject text = Document.get().createTextNode("foo");
assertTrue(Node.is(text));
// Node.is(null) is allowed and should return false.
assertFalse(Node.is(null));
}
use of org.gwtproject.core.client.JavaScriptObject in project gwtproject by treblereel.
the class CustomEventsTest method getBitlessCustomDisptachers.
private static JavaScriptObject getBitlessCustomDisptachers() {
JsPropertyMap result = JsPropertyMap.of();
Fn fn = event -> {
DOMImplStandard.dispatchEvent(event);
String title = Js.uncheckedCast(Js.asPropertyMap(Js.asPropertyMap(event).get("target")).get("title"));
Js.asPropertyMap(Js.asPropertyMap(event).get("target")).set("title", title + "-custom_method");
};
result.set("c2", fn);
return Js.uncheckedCast(result);
}
Aggregations