Search in sources :

Example 1 with HTMLBodyElement

use of elemental2.dom.HTMLBodyElement 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 HTMLBodyElement

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

the class PrintHelperTest method testWriteElementIntoDocument.

@Test
public void testWriteElementIntoDocument() {
    final HTMLElement element = mock(HTMLElement.class);
    final HTMLDocument document = mock(HTMLDocument.class);
    final HTMLBodyElement body = mock(HTMLBodyElement.class);
    final String elementHTML = "<html />";
    final DOMTokenList classList = mock(DOMTokenList.class);
    element.innerHTML = elementHTML;
    document.body = body;
    body.classList = classList;
    helper.writeElementIntoDocument(element, document);
    verify(document).open();
    verify(document).write(elementHTML);
    verify(document).close();
    verify(classList).add(PREVIEW_SCREEN_CSS_CLASS);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) HTMLDocument(elemental2.dom.HTMLDocument) HTMLBodyElement(elemental2.dom.HTMLBodyElement) Test(org.junit.Test)

Aggregations

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