Search in sources :

Example 1 with TestViewRenderer

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

the class ViewRendererTest method testRemoveChildView.

@Test
public void testRemoveChildView() {
    new TestViewRenderer(TestView.class, ParentView.class, AnotherParentView.class).handle(dummyEvent);
    ParentView parentView = (ParentView) ui.getInternals().getActiveViewChain().get(1);
    new TestViewRenderer(ParentView.class, AnotherParentView.class).handle(dummyEvent);
    Assert.assertEquals(0, parentView.getElement().getChildCount());
}
Also used : TestViewRenderer(com.vaadin.flow.router.legacy.TestViewRenderer) Test(org.junit.Test)

Example 2 with TestViewRenderer

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

the class ViewRendererTest method reuseSingleView.

@Test
public void reuseSingleView() {
    new TestViewRenderer(TestView.class).handle(dummyEvent);
    List<View> firstChain = ui.getInternals().getActiveViewChain();
    TestView view = (TestView) firstChain.get(0);
    Assert.assertEquals(1, view.locations.size());
    new TestViewRenderer(TestView.class).handle(dummyEvent);
    Assert.assertEquals(2, view.locations.size());
    List<View> secondChain = ui.getInternals().getActiveViewChain();
    Assert.assertNotSame(firstChain, secondChain);
    Assert.assertSame(view, secondChain.get(0));
}
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 3 with TestViewRenderer

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

the class ViewRendererTest method testReuseAllViews.

@Test
public void testReuseAllViews() {
    new TestViewRenderer(TestView.class, ParentView.class, AnotherParentView.class).handle(dummyEvent);
    try {
        blockNewViewInstances.set(Boolean.TRUE);
        // setChildView and view constructors throws if invoked
        new TestViewRenderer(TestView.class, ParentView.class, AnotherParentView.class).handle(dummyEvent);
    } finally {
        blockNewViewInstances.remove();
    }
}
Also used : TestViewRenderer(com.vaadin.flow.router.legacy.TestViewRenderer) Test(org.junit.Test)

Example 4 with TestViewRenderer

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

the class ViewRendererTest method testViewTitle_titleAnnotation_titleUpdated.

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

Example 5 with TestViewRenderer

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

the class ViewRendererTest method testViewTitle_nullTitleReturned_noTitleSet.

@Test(expected = AssertionError.class)
public void testViewTitle_nullTitleReturned_noTitleSet() {
    new TestViewRenderer(AnotherTestView.class).handle(dummyEvent);
    verifyViewTitleUpdate(ANOTHER_VIEW_TITLE);
    new TestViewRenderer(NullTitleView.class).handle(dummyEvent);
}
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