use of com.vaadin.flow.router.legacy.View in project flow by vaadin.
the class ViewRendererTest method testViewInstantiationCustomization.
@Test
public void testViewInstantiationCustomization() {
// override default implementation of reusing the views if possible
ViewRenderer renderer = new TestViewRenderer(TestView.class, ParentView.class) {
@Override
protected <T extends View> T getView(Class<T> viewType, NavigationEvent event) {
// always return a new view
return ReflectTools.createInstance(viewType);
}
};
renderer.handle(dummyEvent);
View view1 = dummyEvent.getUI().getInternals().getActiveViewChain().get(0);
View parentView1 = dummyEvent.getUI().getInternals().getActiveViewChain().get(1);
renderer.handle(dummyEvent);
View view2 = dummyEvent.getUI().getInternals().getActiveViewChain().get(0);
View parentView2 = dummyEvent.getUI().getInternals().getActiveViewChain().get(1);
Assert.assertNotSame(view1, view2);
Assert.assertNotSame(parentView1, parentView2);
}
Aggregations