Search in sources :

Example 1 with ExecutionCanceler

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]);
}
Also used : ExecutionCanceler(com.vaadin.flow.component.page.Page.ExecutionCanceler) MockUI(com.vaadin.tests.util.MockUI) Serializable(java.io.Serializable) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.Test)

Aggregations

ExecutionCanceler (com.vaadin.flow.component.page.Page.ExecutionCanceler)1 MockUI (com.vaadin.tests.util.MockUI)1 Serializable (java.io.Serializable)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.Test)1