Search in sources :

Example 6 with TestViewRenderer

use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.

the class ViewRendererTest method testViewTitle_titleSetPreviouslyButNotDefinedForNextView_emptyTitleSet.

@Test
public void testViewTitle_titleSetPreviouslyButNotDefinedForNextView_emptyTitleSet() {
    new TestViewRenderer(AnotherTestView.class).handle(dummyEvent);
    verifyViewTitleUpdate(ANOTHER_VIEW_TITLE);
    new TestViewRenderer(TestView.class).handle(dummyEvent);
    verifyViewTitleUpdate("");
}
Also used : TestViewRenderer(com.vaadin.flow.router.legacy.TestViewRenderer) Test(org.junit.Test)

Example 7 with TestViewRenderer

use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.

the class ViewRendererTest method showNestedView.

@Test
public void showNestedView() {
    new TestViewRenderer(TestView.class, ParentView.class, AnotherParentView.class).handle(dummyEvent);
    List<View> viewChain = ui.getInternals().getActiveViewChain();
    Assert.assertEquals(3, viewChain.size());
    Assert.assertEquals(Arrays.asList(TestView.class, ParentView.class, AnotherParentView.class), viewChain.stream().map(Object::getClass).collect(Collectors.toList()));
    Element element = null;
    for (View view : viewChain) {
        Assert.assertEquals(Arrays.asList(dummyEvent.getLocation()), ((TestView) view).locations);
        Element viewElement = view.getElement();
        if (element != null) {
            Assert.assertEquals(viewElement, element.getParent());
        }
        element = viewElement;
    }
    Assert.assertEquals(ui.getElement(), element.getParent());
    Assert.assertEquals(1, ui.getElement().getChildCount());
}
Also used : TestViewRenderer(com.vaadin.flow.router.legacy.TestViewRenderer) Element(com.vaadin.flow.dom.Element) HasChildView(com.vaadin.flow.router.legacy.HasChildView) View(com.vaadin.flow.router.legacy.View) DefaultErrorView(com.vaadin.flow.router.legacy.DefaultErrorView) Test(org.junit.Test)

Example 8 with TestViewRenderer

use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.

the class ViewRendererTest method testViewDynamicTitle.

@Test
public void testViewDynamicTitle() {
    new TestViewRenderer(DynamicTitleView.class).handle(dummyEvent);
    verifyViewTitleUpdate(DYNAMIC_VIEW_TITLE);
}
Also used : TestViewRenderer(com.vaadin.flow.router.legacy.TestViewRenderer) Test(org.junit.Test)

Example 9 with TestViewRenderer

use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.

the class ViewRendererTest method testViewReroute.

@Test
public void testViewReroute() {
    TestViewRenderer renderer = new TestViewRenderer(RerouteView.class);
    int statusCode = renderer.handle(dummyEvent);
    Assert.assertEquals(404, statusCode);
    List<View> activeViewChain = ui.getInternals().getActiveViewChain();
    Assert.assertEquals(1, activeViewChain.size());
    Assert.assertSame(DefaultErrorView.class, activeViewChain.get(0).getClass());
}
Also used : TestViewRenderer(com.vaadin.flow.router.legacy.TestViewRenderer) HasChildView(com.vaadin.flow.router.legacy.HasChildView) View(com.vaadin.flow.router.legacy.View) DefaultErrorView(com.vaadin.flow.router.legacy.DefaultErrorView) Test(org.junit.Test)

Example 10 with TestViewRenderer

use of com.vaadin.flow.router.legacy.TestViewRenderer in project flow by vaadin.

the class ViewRendererTest method testViewTitle_onlyParentHasTitle_defaultTitleUsed.

@Test
public void testViewTitle_onlyParentHasTitle_defaultTitleUsed() {
    new TestViewRenderer(TestView.class, ParentView.class).handle(dummyEvent);
    verifyViewTitleUpdate("");
}
Also used : TestViewRenderer(com.vaadin.flow.router.legacy.TestViewRenderer) Test(org.junit.Test)

Aggregations

TestViewRenderer (com.vaadin.flow.router.legacy.TestViewRenderer)17 Test (org.junit.Test)17 DefaultErrorView (com.vaadin.flow.router.legacy.DefaultErrorView)7 HasChildView (com.vaadin.flow.router.legacy.HasChildView)7 View (com.vaadin.flow.router.legacy.View)7 Element (com.vaadin.flow.dom.Element)1 NavigationEvent (com.vaadin.flow.router.NavigationEvent)1 DefaultPageTitleGenerator (com.vaadin.flow.router.legacy.DefaultPageTitleGenerator)1 ViewRenderer (com.vaadin.flow.router.legacy.ViewRenderer)1