Search in sources :

Example 16 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class DNDListComponentViewTest method testGetNewDraggingYPosition.

@Test
public void testGetNewDraggingYPosition() {
    final MouseEvent event = mock(MouseEvent.class);
    final HTMLElement draggingElement = mock(HTMLElement.class);
    final DOMRect rect = mock(DOMRect.class);
    event.y = 100;
    rect.top = 25;
    draggingElement.style = mock(CSSStyleDeclaration.class);
    dragArea.offsetHeight = 300;
    when(presenter.getItemHeight()).thenReturn(50);
    when(dragArea.getBoundingClientRect()).thenReturn(rect);
    doReturn(draggingElement).when(view).getDragging();
    final int actualYPosition = view.getNewDraggingYPosition(event);
    final int expectedYPosition = 50;
    assertEquals(expectedYPosition, actualYPosition);
}
Also used : MouseEvent(elemental2.dom.MouseEvent) HTMLElement(elemental2.dom.HTMLElement) DOMRect(elemental2.dom.DOMRect) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 17 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class DNDListComponentViewTest method testGetNewDraggingYPositionWhenNewYPositionIsGreaterThanMax.

@Test
public void testGetNewDraggingYPositionWhenNewYPositionIsGreaterThanMax() {
    final MouseEvent event = mock(MouseEvent.class);
    final HTMLElement draggingElement = mock(HTMLElement.class);
    final DOMRect rect = mock(DOMRect.class);
    event.y = 1000;
    rect.top = 25;
    draggingElement.style = mock(CSSStyleDeclaration.class);
    dragArea.offsetHeight = 300;
    when(presenter.getItemHeight()).thenReturn(50);
    when(dragArea.getBoundingClientRect()).thenReturn(rect);
    doReturn(draggingElement).when(view).getDragging();
    final int actualYPosition = view.getNewDraggingYPosition(event);
    final int expectedYPosition = 325;
    assertEquals(expectedYPosition, actualYPosition);
}
Also used : MouseEvent(elemental2.dom.MouseEvent) HTMLElement(elemental2.dom.HTMLElement) DOMRect(elemental2.dom.DOMRect) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 18 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class TimeSelectorViewTest method testOnTimeInputBlurToChildrenElement.

@Test
public void testOnTimeInputBlurToChildrenElement() {
    final BlurEvent event = mock(BlurEvent.class);
    final Element target = mock(Element.class);
    doReturn(target).when(view).getEventTarget(event);
    doReturn(true).when(view).isChildOfView(target);
    view.onTimeInputBlur(event);
    verify(onValueInputBlur, never()).accept(event);
}
Also used : Element(elemental2.dom.Element) HTMLOptionElement(elemental2.dom.HTMLOptionElement) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(elemental2.dom.HTMLElement) HTMLSelectElement(elemental2.dom.HTMLSelectElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) Test(org.junit.Test)

Example 19 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class DNDListComponentViewTest method testOnStartDragWhenTargetIsGrip.

@Test
public void testOnStartDragWhenTargetIsGrip() {
    final Event event = mock(Event.class);
    final HTMLElement parent = mock(HTMLElement.class);
    final HTMLElement target = mock(HTMLElement.class);
    event.target = target;
    target.parentNode = parent;
    target.classList = mock(DOMTokenList.class);
    when(target.classList.contains(GRIP)).thenReturn(true);
    doNothing().when(view).holdDraggingElement(any());
    view.onStartDrag(event);
    verify(view).holdDraggingElement(parent);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) Event(elemental2.dom.Event) MouseEvent(elemental2.dom.MouseEvent) Test(org.junit.Test)

Example 20 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class DNDListComponentViewTest method testOnDragWhenUserIsDragging.

@Test
public void testOnDragWhenUserIsDragging() {
    final Event event = mock(Event.class);
    doReturn(false).when(view).isNotDragging();
    doNothing().when(view).updateDraggingElementY(event);
    doNothing().when(view).updateDraggingElementX(event);
    doNothing().when(view).updateHoverElement();
    doNothing().when(view).updateDependentsPosition();
    view.onDrag(event);
    verify(view).updateDraggingElementY(event);
    verify(view).updateDraggingElementX(event);
    verify(view).updateHoverElement();
    verify(view).updateDependentsPosition();
}
Also used : Event(elemental2.dom.Event) MouseEvent(elemental2.dom.MouseEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)50 HTMLElement (elemental2.dom.HTMLElement)27 Event (elemental2.dom.Event)26 KeyboardEvent (elemental2.dom.KeyboardEvent)19 Element (elemental2.dom.Element)18 MouseEvent (elemental2.dom.MouseEvent)16 HTMLDivElement (elemental2.dom.HTMLDivElement)15 HTMLInputElement (elemental2.dom.HTMLInputElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)7 CSSStyleDeclaration (elemental2.dom.CSSStyleDeclaration)7 JQuery (org.uberfire.client.views.pfly.selectpicker.JQuery)7 DOMRect (elemental2.dom.DOMRect)5 DOMTokenList (elemental2.dom.DOMTokenList)5 DomGlobal (elemental2.dom.DomGlobal)5 LazyReverseView (com.github.mvp4g.mvp4g2.core.ui.LazyReverseView)4 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 Elements.button (org.jboss.gwt.elemento.core.Elements.button)4 Elements.div (org.jboss.gwt.elemento.core.Elements.div)4