use of com.vaadin.client.flow.binding.ServerEventObject in project flow by vaadin.
the class GwtEventHandlerTest method assertPolymerMethods.
private void assertPolymerMethods(Element element, String[] expected) {
ServerEventObject object = WidgetUtil.crazyJsoCast(element);
assertEventHandlerMethods(() -> getPublishedServerMethods(object), expected);
}
use of com.vaadin.client.flow.binding.ServerEventObject in project flow by vaadin.
the class GwtEventHandlerTest method testClientCallablePromises.
public void testClientCallablePromises() {
String methodName = "publishedMethod";
node.getList(NodeFeatures.CLIENT_DELEGATE_HANDLERS).add(0, methodName);
Binder.bind(node, element);
Reactive.flush();
ServerEventObject serverObject = ServerEventObject.get(element);
NativeFunction publishedMethod = new NativeFunction("return this." + methodName + "()");
Object promise0 = publishedMethod.apply(serverObject, JsCollections.array());
assertNotNull(promise0);
assertEquals(Integer.valueOf(0), serverPromiseIds.get(methodName));
assertTrue(hasPromise(element, 0));
Object promise1 = publishedMethod.apply(serverObject, JsCollections.array());
assertEquals(Integer.valueOf(1), serverPromiseIds.get(methodName));
assertTrue(hasPromise(element, 1));
addThen(promise0, value -> {
assertEquals("promise0", value);
assertFalse("Promise handlers should be cleared", hasPromise(element, 0));
completePromise(element, 1, false, null);
});
addCatch(promise1, message -> {
assertEquals("Error: Something went wrong. Check server-side logs for more information.", message);
assertFalse("Promise handlers should be cleared", hasPromise(element, 1));
finishTest();
});
completePromise(element, 0, true, "promise0");
delayTestFinish(100);
}
Aggregations