Search in sources :

Example 1 with CSSStyleDeclaration

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

the class DMNEditDRDToolboxActionTest method testOnMouseClick.

@Test
public void testOnMouseClick() throws NoSuchFieldException, IllegalAccessException {
    final HTMLElement htmlElement = new HTMLElement();
    htmlElement.style = new CSSStyleDeclaration();
    final HTMLDocument htmlDocument = new HTMLDocument();
    htmlDocument.body = new HTMLBodyElement();
    final Field field = DomGlobal.class.getDeclaredField("document");
    field.setAccessible(true);
    Field modifiersField = Field.class.getDeclaredField("modifiers");
    modifiersField.setAccessible(true);
    modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    field.set(DomGlobal.class, htmlDocument);
    when(drdContextMenu.getElement()).thenReturn(htmlElement);
    dmnEditDRDToolboxAction.onMouseClick(canvasHandler, UUID, mouseClickEvent);
    verify(drdContextMenu, times(1)).show(Mockito.<Collection>any());
}
Also used : Field(java.lang.reflect.Field) HTMLElement(elemental2.dom.HTMLElement) HTMLDocument(elemental2.dom.HTMLDocument) HTMLBodyElement(elemental2.dom.HTMLBodyElement) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 2 with CSSStyleDeclaration

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

the class DragAndDropHelperTest method testRefreshItemsPosition.

@Test
public void testRefreshItemsPosition() {
    final HTMLElement element1 = mock(HTMLElement.class);
    final HTMLElement element2 = mock(HTMLElement.class);
    final HTMLElement element3 = mock(HTMLElement.class);
    final CSSStyleDeclaration element1Style = mock(CSSStyleDeclaration.class);
    final CSSStyleDeclaration element2Style = mock(CSSStyleDeclaration.class);
    final CSSStyleDeclaration element3Style = mock(CSSStyleDeclaration.class);
    element1.style = element1Style;
    element2.style = element2Style;
    element3.style = element3Style;
    element1.offsetHeight = 50;
    final NodeList<Element> draggableItems = spy(new NodeList<>());
    doReturn(element1).when(draggableItems).getAt(0);
    doReturn(element2).when(draggableItems).getAt(1);
    doReturn(element3).when(draggableItems).getAt(2);
    when(element1.getAttribute(DATA_POSITION)).thenReturn("0");
    when(element2.getAttribute(DATA_POSITION)).thenReturn("1");
    when(element3.getAttribute(DATA_POSITION)).thenReturn("2");
    draggableItems.length = 3;
    when(dragArea.querySelectorAll(DragAndDropHelper.DRAGGABLE_ITEM_CLASS)).thenReturn(draggableItems);
    helper.refreshItemsPosition();
    verify(element1Style).setProperty(TOP, 0 + PX);
    verify(element2Style).setProperty(TOP, 50 + PX);
    verify(element3Style).setProperty(TOP, 100 + PX);
    verify(addButtonContainerStyle).setProperty(TOP, 150 + PX);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 3 with CSSStyleDeclaration

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

the class DragAndDropHelperTest method testGetTop.

@Test
public void testGetTop() {
    final HTMLElement element = mock(HTMLElement.class);
    final CSSStyleDeclaration style = mock(CSSStyleDeclaration.class);
    final int expected = 123;
    element.style = style;
    when(style.getPropertyValue(TOP)).thenReturn("123" + PX);
    final int actual = helper.getTop(element);
    assertEquals(expected, actual);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 4 with CSSStyleDeclaration

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

the class DragAndDropHelperTest method testSetTop.

@Test
public void testSetTop() {
    final HTMLElement element = mock(HTMLElement.class);
    final CSSStyleDeclaration style = mock(CSSStyleDeclaration.class);
    final int expected = 123;
    element.style = style;
    helper.setTop(element, expected);
    verify(style).setProperty(TOP, expected + PX);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Aggregations

CSSStyleDeclaration (elemental2.dom.CSSStyleDeclaration)4 HTMLElement (elemental2.dom.HTMLElement)4 Test (org.junit.Test)4 Element (elemental2.dom.Element)1 HTMLBodyElement (elemental2.dom.HTMLBodyElement)1 HTMLDocument (elemental2.dom.HTMLDocument)1 Field (java.lang.reflect.Field)1