Search in sources :

Example 1 with MockUI

use of com.vaadin.tests.util.MockUI in project flow by vaadin.

the class DependencyListTest method before.

@Before
public void before() {
    ui = new MockUI();
    deps = ui.getInternals().getDependencyList();
    assertEquals(0, deps.getPendingSendToClient().size());
}
Also used : MockUI(com.vaadin.tests.util.MockUI) Before(org.junit.Before)

Example 2 with MockUI

use of com.vaadin.tests.util.MockUI in project flow by vaadin.

the class NavigationStateRendererTest method instantiatorUse.

@Test
public void instantiatorUse() throws ServiceException {
    MockVaadinServletService service = new MockVaadinServletService();
    service.init(new MockInstantiator() {

        @Override
        public <T extends HasElement> T createRouteTarget(Class<T> routeTargetType, NavigationEvent event) {
            Assert.assertEquals(Component.class, routeTargetType);
            return (T) new Text("foo");
        }
    });
    MockUI ui = new MockUI(new MockVaadinSession(service));
    NavigationEvent event = new NavigationEvent(new Router(new TestRouteRegistry()), new Location(""), ui, NavigationTrigger.PAGE_LOAD);
    NavigationStateRenderer renderer = new NavigationStateRenderer(navigationStateFromTarget(ChildConfiguration.class));
    Component routeTarget = renderer.getRouteTarget(Component.class, event);
    Assert.assertEquals(Text.class, routeTarget.getClass());
    UI.setCurrent(null);
}
Also used : NavigationEvent(com.vaadin.flow.router.NavigationEvent) MockVaadinServletService(com.vaadin.flow.server.MockVaadinServletService) Router(com.vaadin.flow.router.Router) Text(com.vaadin.flow.component.Text) TestRouteRegistry(com.vaadin.flow.router.TestRouteRegistry) MockUI(com.vaadin.tests.util.MockUI) MockVaadinSession(com.vaadin.flow.server.MockVaadinSession) MockInstantiator(com.vaadin.flow.server.MockInstantiator) Component(com.vaadin.flow.component.Component) Location(com.vaadin.flow.router.Location) NavigationStateRenderer(com.vaadin.flow.router.internal.NavigationStateRenderer) Test(org.junit.Test)

Aggregations

MockUI (com.vaadin.tests.util.MockUI)2 Component (com.vaadin.flow.component.Component)1 Text (com.vaadin.flow.component.Text)1 Location (com.vaadin.flow.router.Location)1 NavigationEvent (com.vaadin.flow.router.NavigationEvent)1 Router (com.vaadin.flow.router.Router)1 TestRouteRegistry (com.vaadin.flow.router.TestRouteRegistry)1 NavigationStateRenderer (com.vaadin.flow.router.internal.NavigationStateRenderer)1 MockInstantiator (com.vaadin.flow.server.MockInstantiator)1 MockVaadinServletService (com.vaadin.flow.server.MockVaadinServletService)1 MockVaadinSession (com.vaadin.flow.server.MockVaadinSession)1 Before (org.junit.Before)1 Test (org.junit.Test)1