use of com.vaadin.flow.router.internal.NavigationStateRenderer in project flow by vaadin.
the class NavigationStateRendererTest method getRouterLayoutForSingle.
@Test
public void getRouterLayoutForSingle() throws Exception {
NavigationStateRenderer childRenderer = new NavigationStateRenderer(navigationStateFromTarget(RouteParentLayout.class));
List<Class<? extends RouterLayout>> routerLayoutTypes = childRenderer.getRouterLayoutTypes(RouteParentLayout.class);
Assert.assertEquals("Found layout even though RouteParentLayout doesn't have any parents.", 0, routerLayoutTypes.size());
}
use of com.vaadin.flow.router.internal.NavigationStateRenderer in project flow by vaadin.
the class LocationChangeEvent method rerouteTo.
/**
* Reroutes the navigation to show the given component instead of the
* component that is currently about to be displayed.
*
* @param rerouteTargetState
* the target navigation state of the rerouting, not {@code null}
*/
public void rerouteTo(NavigationState rerouteTargetState) {
Objects.requireNonNull(rerouteTargetState, "rerouteTargetState cannot be null");
rerouteTo(new NavigationStateRenderer(rerouteTargetState));
}
use of com.vaadin.flow.router.internal.NavigationStateRenderer in project flow by vaadin.
the class NavigationStateRendererTest method getRouterLayoutForMulipleLayers.
@Test
public void getRouterLayoutForMulipleLayers() throws Exception {
NavigationStateRenderer childRenderer = new NavigationStateRenderer(navigationStateFromTarget(ChildConfiguration.class));
List<Class<? extends RouterLayout>> routerLayoutTypes = childRenderer.getRouterLayoutTypes(ChildConfiguration.class);
Assert.assertEquals("Not all expected layouts were found", 2, routerLayoutTypes.size());
Assert.assertEquals("Wrong class found as first in array", MiddleLayout.class, routerLayoutTypes.get(0));
Assert.assertEquals("Wrong class found as second in array", RouteParentLayout.class, routerLayoutTypes.get(1));
}
use of com.vaadin.flow.router.internal.NavigationStateRenderer in project flow by vaadin.
the class NavigationStateRendererTest method instantiatorUse.
@Test
public void instantiatorUse() throws ServiceException {
MockVaadinServletService service = new MockVaadinServletService();
service.init(new MockInstantiator() {
@Override
public <T extends HasElement> T createRouteTarget(Class<T> routeTargetType, NavigationEvent event) {
Assert.assertEquals(Component.class, routeTargetType);
return (T) new Text("foo");
}
});
MockUI ui = new MockUI(new MockVaadinSession(service));
NavigationEvent event = new NavigationEvent(new Router(new TestRouteRegistry()), new Location(""), ui, NavigationTrigger.PAGE_LOAD);
NavigationStateRenderer renderer = new NavigationStateRenderer(navigationStateFromTarget(ChildConfiguration.class));
Component routeTarget = renderer.getRouteTarget(Component.class, event);
Assert.assertEquals(Text.class, routeTarget.getClass());
UI.setCurrent(null);
}
use of com.vaadin.flow.router.internal.NavigationStateRenderer in project flow by vaadin.
the class NavigationStateRendererTest method getRouterLayoutForSingleParent.
@Test
public void getRouterLayoutForSingleParent() throws Exception {
NavigationStateRenderer childRenderer = new NavigationStateRenderer(navigationStateFromTarget(SingleView.class));
List<Class<? extends RouterLayout>> routerLayoutTypes = childRenderer.getRouterLayoutTypes(SingleView.class);
Assert.assertEquals("Not all expected layouts were found", 1, routerLayoutTypes.size());
Assert.assertEquals("Wrong class found", RouteParentLayout.class, routerLayoutTypes.get(0));
}
Aggregations