use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterConfigurationTest method testParentViewsWithoutParent.
@Test
public void testParentViewsWithoutParent() {
UI ui = new UI();
Router router = new Router();
router.reconfigure(conf -> {
conf.setRoute("route", TestView.class);
conf.setParentView(TestView.class, ParentView.class);
conf.setParentView(ParentView.class, AnotherParentView.class);
});
router.navigate(ui, new Location("route"), NavigationTrigger.PROGRAMMATIC);
Assert.assertEquals(ParentView.class, router.getConfiguration().getParentView(TestView.class).get());
Assert.assertEquals(AnotherParentView.class, router.getConfiguration().getParentView(ParentView.class).get());
Assert.assertEquals(Arrays.asList(TestView.class, ParentView.class, AnotherParentView.class), getViewChainTypes(ui));
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterConfigurationTest method getParentViewsWithoutParent.
@Test
public void getParentViewsWithoutParent() {
Router router = new Router();
router.reconfigure(conf -> {
conf.setRoute("route", TestView.class);
});
assertParentViews(router, TestView.class);
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterConfigurationTest method testSetErrorViewWithParent.
@Test
public void testSetErrorViewWithParent() {
Router router = new Router();
router.reconfigure(conf -> {
conf.setErrorView(ErrorView.class, ParentView.class);
});
assertErrorView(router, ErrorView.class);
assertParentViews(router, ErrorView.class, ParentView.class);
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterConfigurationTest method getParentViewsManyLevels.
@Test
public void getParentViewsManyLevels() {
Router router = new Router();
router.reconfigure(conf -> {
conf.setRoute("route", TestView.class);
conf.setParentView(TestView.class, ParentView.class);
conf.setParentView(ParentView.class, AnotherParentView.class);
});
assertParentViews(router, TestView.class, ParentView.class, AnotherParentView.class);
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterTest method testReconfigureThreadSafety.
@Test
public void testReconfigureThreadSafety() throws InterruptedException {
Router router = new Router();
Resolver newResolver = e -> null;
CountDownLatch configUpdated = new CountDownLatch(1);
CountDownLatch configVerified = new CountDownLatch(1);
Thread updaterThread = new Thread() {
@Override
public void run() {
router.reconfigure(config -> {
config.setResolver(newResolver);
// Signal that config has been updated
configUpdated.countDown();
// configuration is not yet in effect
try {
configVerified.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
};
updaterThread.start();
// Wait until updater thread has updated the config
configUpdated.await();
Assert.assertNotSame("Update should not yet be visible", newResolver, router.getConfiguration().getResolver());
// Allow the update thread to exit the configure method
configVerified.countDown();
// Wait for updater thread to finish
updaterThread.join();
Assert.assertSame("Update should now be visible", newResolver, router.getConfiguration().getResolver());
}
Aggregations