use of com.vaadin.flow.component.page.Page.ExecutionCanceler in project flow by vaadin.
the class PageTest method executeJavaScript_delegatesToExecJs.
@Test
public void executeJavaScript_delegatesToExecJs() {
AtomicReference<String> invokedExpression = new AtomicReference<>();
AtomicReference<Serializable[]> invokedParams = new AtomicReference<>();
Page page = new Page(new MockUI()) {
@Override
public PendingJavaScriptResult executeJs(String expression, Serializable... parameters) {
String oldExpression = invokedExpression.getAndSet(expression);
Assert.assertNull("There should be no old expression", oldExpression);
Serializable[] oldParams = invokedParams.getAndSet(parameters);
Assert.assertNull("There should be no old params", oldParams);
return null;
}
};
ExecutionCanceler executionCanceler = page.executeJavaScript("foo", 1, true);
Assert.assertNull(executionCanceler);
Assert.assertEquals("foo", invokedExpression.get());
Assert.assertEquals(Integer.valueOf(1), invokedParams.get()[0]);
Assert.assertEquals(Boolean.TRUE, invokedParams.get()[1]);
}
Aggregations