Search in sources :

Example 6 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class AbstractDnDUnitTest method testExtension_staticApiNotIosNotCompatibilityMode_connectorDependencyAndPolyfillNotAddedDynamically.

@Test
public void testExtension_staticApiNotIosNotCompatibilityMode_connectorDependencyAndPolyfillNotAddedDynamically() {
    ui.getInternals().getDependencyList().clearPendingSendToClient();
    RouterLink component = new RouterLink();
    ui.add(component);
    runStaticCreateMethodForExtension(component);
    DependencyList dependencyList = ui.getInternals().getDependencyList();
    Collection<Dependency> pendingSendToClient = dependencyList.getPendingSendToClient();
    Assert.assertEquals("No dependencies should be added", 0, pendingSendToClient.size());
}
Also used : DependencyList(com.vaadin.flow.component.internal.DependencyList) RouterLink(com.vaadin.flow.router.RouterLink) Dependency(com.vaadin.flow.shared.ui.Dependency) Test(org.junit.Test)

Example 7 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class DropTargetTest method testDropTarget_notAttachedToUIAndReceivesDropEvent_throws.

@Test(expected = IllegalStateException.class)
public void testDropTarget_notAttachedToUIAndReceivesDropEvent_throws() {
    RouterLink component = new RouterLink();
    DropTarget<RouterLink> dropTarget = DropTarget.create(component);
    DropEvent<RouterLink> dropEvent = new DropEvent<>(component, true, "all");
    ComponentUtil.fireEvent(component, dropEvent);
}
Also used : RouterLink(com.vaadin.flow.router.RouterLink) Test(org.junit.Test)

Example 8 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class NavigationRpcHandlerTest method handleRouterLinkClick_uiIsInert_navigationNotTriggered.

@Test
public void handleRouterLinkClick_uiIsInert_navigationNotTriggered() {
    ui.addModal(new RouterLink());
    ui.getInternals().getStateTree().collectChanges(nodeChange -> {
    });
    invocation.put(JsonConstants.RPC_NAVIGATION_ROUTERLINK, true);
    rpcHandler.handle(ui, invocation);
    Mockito.verifyNoInteractions(historyStateChangeHandler);
}
Also used : RouterLink(com.vaadin.flow.router.RouterLink) Test(org.junit.Test)

Example 9 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class NavigationRpcHandlerTest method setup.

@Before
public void setup() {
    ui = new UI();
    historyStateChangeHandler = Mockito.mock(History.HistoryStateChangeHandler.class);
    ui.getPage().getHistory().setHistoryStateChangeHandler(historyStateChangeHandler);
    ui.add(new RouterLink());
    rpcHandler = new NavigationRpcHandler();
    invocation = Json.createObject();
    invocation.put(JsonConstants.RPC_NAVIGATION_LOCATION, "foo");
}
Also used : RouterLink(com.vaadin.flow.router.RouterLink) UI(com.vaadin.flow.component.UI) Before(org.junit.Before)

Example 10 with RouterLink

use of com.vaadin.flow.router.RouterLink in project flow by vaadin.

the class ShortcutsTest method setShortcutListenOnElementLocatorJs_storesLocatorOnComponentData.

@Test
public void setShortcutListenOnElementLocatorJs_storesLocatorOnComponentData() {
    final RouterLink routerLink = new RouterLink();
    final String locator = "foobar";
    final Registration registration = Shortcuts.setShortcutListenOnElement(locator, routerLink);
    Assert.assertEquals(locator, ComponentUtil.getData(routerLink, Shortcuts.ELEMENT_LOCATOR_JS_KEY));
    registration.remove();
    Assert.assertNull(ComponentUtil.getData(routerLink, Shortcuts.ELEMENT_LOCATOR_JS_KEY));
}
Also used : RouterLink(com.vaadin.flow.router.RouterLink) Registration(com.vaadin.flow.shared.Registration) Test(org.junit.Test)

Aggregations

RouterLink (com.vaadin.flow.router.RouterLink)30 Test (org.junit.Test)23 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 TestComponent (com.vaadin.flow.component.ComponentTest.TestComponent)3 Element (com.vaadin.flow.dom.Element)3 MockUI (com.vaadin.tests.util.MockUI)3 Component (com.vaadin.flow.component.Component)2 Div (com.vaadin.flow.component.html.Div)2 DependencyList (com.vaadin.flow.component.internal.DependencyList)2 PendingJavaScriptInvocation (com.vaadin.flow.component.internal.PendingJavaScriptInvocation)2 Registration (com.vaadin.flow.shared.Registration)2 Dependency (com.vaadin.flow.shared.ui.Dependency)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2 ComponentEventListener (com.vaadin.flow.component.ComponentEventListener)1 ComponentUtil (com.vaadin.flow.component.ComponentUtil)1 HasComponents (com.vaadin.flow.component.HasComponents)1 Tag (com.vaadin.flow.component.Tag)1 UI (com.vaadin.flow.component.UI)1 DnDUtilHelper (com.vaadin.flow.component.dnd.internal.DnDUtilHelper)1