use of elemental.events.MouseEvent in project flow by vaadin.
the class GwtTemplateBinderTest method testClientDelegateHandler_noArgs.
public void testClientDelegateHandler_noArgs() {
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
String operation = "operation";
templateNode.addEventHandler("click", "$server." + operation + "()");
stateNode.getList(NodeFeatures.CLIENT_DELEGATE_HANDLERS).set(0, operation);
Element element = createElement(templateNode);
MouseEvent event = (MouseEvent) Browser.getDocument().createEvent(Events.MOUSE);
event.initMouseEvent("click", true, true, Browser.getWindow(), 0, 0, 0, 0, 0, false, false, false, false, 0, element);
Browser.getDocument().getBody().appendChild(element);
element.dispatchEvent(event);
assertEquals(1, serverMethods.size());
JsArray<?> args = serverMethods.get(operation);
assertNotNull(args);
assertEquals(0, args.length());
}
use of elemental.events.MouseEvent in project flow by vaadin.
the class GwtTemplateBinderTest method testClientDelegateHandler_args.
public void testClientDelegateHandler_args() {
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
String operation = "operation";
templateNode.addEventHandler("click", "$server." + operation + "($wnd.booleanprop, $wnd.stringprop, $wnd.numberprop, $wnd.objectprop)");
stateNode.getList(NodeFeatures.CLIENT_DELEGATE_HANDLERS).set(0, operation);
Element element = createElement(templateNode);
WidgetUtil.setJsProperty(Browser.getWindow(), "booleanprop", true);
WidgetUtil.setJsProperty(Browser.getWindow(), "stringprop", "foo");
WidgetUtil.setJsProperty(Browser.getWindow(), "numberprop", 11);
JsonObject obj = Json.createObject();
obj.put("foo", "bar");
WidgetUtil.setJsProperty(Browser.getWindow(), "objectprop", obj);
MouseEvent event = (MouseEvent) Browser.getDocument().createEvent(Events.MOUSE);
event.initMouseEvent("click", true, true, Browser.getWindow(), 0, 0, 0, 0, 0, false, false, false, false, 0, element);
Browser.getDocument().getBody().appendChild(element);
element.dispatchEvent(event);
assertEquals(1, serverMethods.size());
JsArray<?> args = serverMethods.get(operation);
assertNotNull(args);
assertEquals(4, args.length());
assertEquals(true, args.get(0));
assertEquals("foo", args.get(1));
assertEquals(11, args.get(2));
assertTrue(args.get(3) instanceof JsonObject);
assertEquals(obj, args.get(3));
}
Aggregations