NavigationStateRenderer extends AbstractNavigationStateRenderer { @Override protected List<Class<? extends RouterLayout>> getRouterLayoutTypes( Class<? extends Component> targetType, Router router) { NavigationState navigationState = getNavigationState(); assert targetType == navigationState .getNavigationTarget() : "Trying to get layouts for wrong route target"; return router.getRegistry() .getRouteLayouts(navigationState.getResolvedPath(), targetType); } NavigationStateRenderer(NavigationState navigationState);   }
@Test public void getRouterLayoutForSingle() throws Exception { NavigationStateRenderer childRenderer = new NavigationStateRenderer( navigationStateFromTarget(RouteParentLayout.class)); List<Class<? extends RouterLayout>> routerLayoutTypes = childRenderer .getRouterLayoutTypes(RouteParentLayout.class, router); Assert.assertEquals( "Found layout even though RouteParentLayout doesn't have any parents.", 0, routerLayoutTypes.size()); }
@Test public void getRouterLayoutForSingleParent() throws Exception { NavigationStateRenderer childRenderer = new NavigationStateRenderer( navigationStateFromTarget(SingleView.class)); RouteConfiguration.forRegistry(router.getRegistry()) .setAnnotatedRoute(SingleView.class); List<Class<? extends RouterLayout>> routerLayoutTypes = childRenderer .getRouterLayoutTypes(SingleView.class, router); Assert.assertEquals("Not all expected layouts were found", 1, routerLayoutTypes.size()); Assert.assertEquals("Wrong class found", RouteParentLayout.class, routerLayoutTypes.get(0)); }
@Test public void getRouterLayoutForMulipleLayers() throws Exception { NavigationStateRenderer childRenderer = new NavigationStateRenderer( navigationStateFromTarget(ChildConfiguration.class)); RouteConfiguration.forRegistry(router.getRegistry()) .setAnnotatedRoute(ChildConfiguration.class); List<Class<? extends RouterLayout>> routerLayoutTypes = childRenderer .getRouterLayoutTypes(ChildConfiguration.class, router); 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)); }