Search in sources :

Example 1 with BeforeLeaveHandler

use of com.vaadin.flow.router.internal.BeforeLeaveHandler in project flow by vaadin.

the class UITest method before_Leave_listener_priority_should_dictate_sort_order.

@Test
public void before_Leave_listener_priority_should_dictate_sort_order() throws InvalidRouteConfigurationException {
    UI ui = createTestUI();
    initUI(ui, "", null);
    ui.addBeforeLeaveListener(new BeforeLeaveListenerFirst());
    ui.addBeforeLeaveListener(new BeforeLeaveListenerThird());
    ui.addBeforeLeaveListener(new BeforeLeaveListenerSecond());
    ui.addBeforeLeaveListener(new BeforeLeaveListenerThird());
    final List<BeforeLeaveHandler> beforeLeaveListeners = ui.getNavigationListeners(BeforeLeaveHandler.class);
    assertEquals(4, beforeLeaveListeners.size());
    assertTrue(beforeLeaveListeners.get(0) instanceof BeforeLeaveListenerFirst);
    assertTrue(beforeLeaveListeners.get(1) instanceof BeforeLeaveListenerSecond);
    assertTrue(beforeLeaveListeners.get(2) instanceof BeforeLeaveListenerThird);
    assertTrue(beforeLeaveListeners.get(3) instanceof BeforeLeaveListenerThird);
}
Also used : MockUI(com.vaadin.tests.util.MockUI) BeforeLeaveHandler(com.vaadin.flow.router.internal.BeforeLeaveHandler) BootstrapHandlerTest(com.vaadin.flow.server.BootstrapHandlerTest) Test(org.junit.Test)

Aggregations

BeforeLeaveHandler (com.vaadin.flow.router.internal.BeforeLeaveHandler)1 BootstrapHandlerTest (com.vaadin.flow.server.BootstrapHandlerTest)1 MockUI (com.vaadin.tests.util.MockUI)1 Test (org.junit.Test)1