use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.
the class ViewRendererTest method testViewTitle_nullPageTitleGenerated_noTitleUpdate.
@Test(expected = AssertionError.class)
public void testViewTitle_nullPageTitleGenerated_noTitleUpdate() {
setPageTitleGenerator(lce -> null);
new TestViewRenderer(DynamicTitleView.class).handle(dummyEvent);
}
use of com.vaadin.flow.router.legacy.TestViewRenderer 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);
}
use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.
the class ViewRendererTest method testStatusCode.
@Test
public void testStatusCode() {
TestViewRenderer renderer = new TestViewRenderer(StatusCodeView.class);
int statusCode = renderer.handle(dummyEvent);
// StatusCodeView increments default status code with 1
Assert.assertEquals(201, statusCode);
}
use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.
the class ViewRendererTest method reuseFirstParentView.
@Test
public void reuseFirstParentView() {
new TestViewRenderer(TestView.class, ParentView.class, AnotherParentView.class).handle(dummyEvent);
List<View> firstChain = ui.getInternals().getActiveViewChain();
new TestViewRenderer(AnotherTestView.class, AnotherParentView.class).handle(dummyEvent);
List<View> secondChain = ui.getInternals().getActiveViewChain();
// Last item in each chain should be reused
Assert.assertSame(firstChain.get(2), secondChain.get(1));
}
use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.
the class ViewRendererTest method testReuse_orderChanged.
@Test
public void testReuse_orderChanged() {
new TestViewRenderer(TestView.class, ParentView.class, AnotherParentView.class).handle(dummyEvent);
List<View> firstChain = ui.getInternals().getActiveViewChain();
new TestViewRenderer(TestView.class, AnotherParentView.class, ParentView.class).handle(dummyEvent);
List<View> secondChain = ui.getInternals().getActiveViewChain();
Assert.assertEquals(Arrays.asList(firstChain.get(0), firstChain.get(2), firstChain.get(1)), secondChain);
}
Aggregations