Search in sources :

Example 1 with DOMRect

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

the class StructureTypesTooltipView method isTooltipOverflowing.

private boolean isTooltipOverflowing() {
    final DOMRect dataTypesListRect = getListItems().getBoundingClientRect();
    final DOMRect tooltipRect = tooltip.getBoundingClientRect();
    return tooltipRect.y + tooltipRect.height > dataTypesListRect.y + dataTypesListRect.height;
}
Also used : DOMRect(elemental2.dom.DOMRect)

Example 2 with DOMRect

use of elemental2.dom.DOMRect 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 3 with DOMRect

use of elemental2.dom.DOMRect 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 4 with DOMRect

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

the class StructureTypesTooltipViewTest method testUpdateTooltipPosition.

@Test
public void testUpdateTooltipPosition() {
    final HTMLElement refElement = mock(HTMLElement.class);
    final DOMRect domRect = mock(DOMRect.class);
    domRect.x = 2;
    domRect.y = 4;
    domRect.width = 8;
    when(refElement.getBoundingClientRect()).thenReturn(domRect);
    view.updateTooltipPosition(refElement);
    assertEquals("4.0px", tooltip.style.top);
    assertEquals("30.0px", tooltip.style.left);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) DOMRect(elemental2.dom.DOMRect) Test(org.junit.Test)

Example 5 with DOMRect

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

the class StructureTypesTooltipViewTest method testUpdateTooltipClassWhenItsOverflowing.

@Test
public void testUpdateTooltipClassWhenItsOverflowing() {
    final HTMLElement listItems = mock(HTMLElement.class);
    final DOMRect dataTypesListRect = mock(DOMRect.class);
    final DOMRect tooltipRect = mock(DOMRect.class);
    when(presenter.getListItems()).thenReturn(listItems);
    when(listItems.getBoundingClientRect()).thenReturn(dataTypesListRect);
    when(tooltip.getBoundingClientRect()).thenReturn(tooltipRect);
    tooltipRect.y = 150;
    tooltipRect.height = 100;
    dataTypesListRect.y = 100;
    dataTypesListRect.height = 100;
    view.updateTooltipClass();
    verify(tooltip.classList).toggle("overflow", true);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) DOMRect(elemental2.dom.DOMRect) Test(org.junit.Test)

Aggregations

DOMRect (elemental2.dom.DOMRect)11 Test (org.junit.Test)9 HTMLElement (elemental2.dom.HTMLElement)8 CSSStyleDeclaration (elemental2.dom.CSSStyleDeclaration)5 MouseEvent (elemental2.dom.MouseEvent)5 Element (elemental2.dom.Element)1 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)1 HTMLDivElement (elemental2.dom.HTMLDivElement)1 HTMLLabelElement (elemental2.dom.HTMLLabelElement)1 Button (org.gwtbootstrap3.client.ui.Button)1