Search in sources :

Example 26 with Document

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

Example 27 with Document

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

the class DNDListComponentViewTest method testCreateItem.

@Test
public void testCreateItem() {
    final HTMLDocument document = mock(HTMLDocument.class);
    final HTMLElement expectedItem = mock(HTMLElement.class);
    final HTMLElement htmlElement = mock(HTMLElement.class);
    final HTMLElement grip = mock(HTMLElement.class);
    final HTMLElement i0 = mock(HTMLElement.class);
    final HTMLElement i1 = mock(HTMLElement.class);
    DNDListDOMHelper.Factory.DOCUMENT = document;
    expectedItem.classList = mock(DOMTokenList.class);
    grip.classList = mock(DOMTokenList.class);
    i0.classList = mock(DOMTokenList.class);
    i1.classList = mock(DOMTokenList.class);
    when(document.createElement("div")).thenReturn(expectedItem, grip);
    when(document.createElement("i")).thenReturn(i0, i1);
    final HTMLElement actualItem = view.createItem(htmlElement);
    verify(actualItem).appendChild(grip);
    verify(actualItem).appendChild(htmlElement);
    verify(actualItem.classList).add(DRAGGABLE);
    assertEquals(expectedItem, actualItem);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) HTMLDocument(elemental2.dom.HTMLDocument) Test(org.junit.Test)

Example 28 with Document

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

the class DNDListDOMHelperTest method testCreateGripElement.

@Test
public void testCreateGripElement() {
    final HTMLDocument document = mock(HTMLDocument.class);
    final HTMLElement expectedGrip = mock(HTMLElement.class);
    final HTMLElement firstI = mock(HTMLElement.class);
    final HTMLElement secondI = mock(HTMLElement.class);
    final String div = "div";
    final String i = "i";
    DNDListDOMHelper.Factory.DOCUMENT = document;
    expectedGrip.classList = mock(DOMTokenList.class);
    firstI.classList = mock(DOMTokenList.class);
    secondI.classList = mock(DOMTokenList.class);
    when(document.createElement(div)).thenReturn(expectedGrip);
    when(document.createElement(i)).thenReturn(firstI, secondI);
    final HTMLElement actualGrip = createGripElement();
    verify(expectedGrip).appendChild(firstI);
    verify(expectedGrip).appendChild(secondI);
    verify(expectedGrip.classList).add(GRIP);
    verify(firstI.classList).add(ICON_CLASS);
    verify(secondI.classList).add(ICON_CLASS);
    verify(firstI.classList).add(ELLIPSIS_CLASS);
    verify(secondI.classList).add(ELLIPSIS_CLASS);
    assertEquals(expectedGrip, actualGrip);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) HTMLDocument(elemental2.dom.HTMLDocument) Test(org.junit.Test)

Example 29 with Document

use of elemental2.dom.Document in project gwtproject by treblereel.

the class RichTextAreaImplStandard method queryCommandStateAssumingFocus.

boolean queryCommandStateAssumingFocus(String cmd) {
    HTMLIFrameElement iframe = Js.uncheckedCast(elem);
    Document document = Js.uncheckedCast(Js.asPropertyMap(iframe.contentWindow).get("document"));
    return ((QueryCommandState) Js.uncheckedCast(Js.asPropertyMap(document).get("queryCommandState"))).onInvoke(cmd);
}
Also used : HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) Document(org.gwtproject.dom.client.Document)

Example 30 with Document

use of elemental2.dom.Document in project gwtproject by treblereel.

the class RichTextAreaImplStandard method setEnabledImpl.

protected void setEnabledImpl(boolean enabled) {
    HTMLIFrameElement iframe = Js.uncheckedCast(elem);
    ((JsPropertyMap) ((JsPropertyMap) iframe.contentWindow).get("document")).set("designMode", enabled ? "On" : "Off");
}
Also used : HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) JsPropertyMap(jsinterop.base.JsPropertyMap)

Aggregations

Document (org.apache.tapestry5.dom.Document)20 Test (org.testng.annotations.Test)17 PageTester (org.apache.tapestry5.test.PageTester)11 Test (org.junit.Test)10 HTMLDocument (elemental2.dom.HTMLDocument)9 HTMLElement (elemental2.dom.HTMLElement)9 HTMLIFrameElement (elemental2.dom.HTMLIFrameElement)9 HTMLBodyElement (elemental2.dom.HTMLBodyElement)5 Element (elemental2.dom.Element)4 Element (org.apache.tapestry5.dom.Element)4 DOMTokenList (elemental2.dom.DOMTokenList)3 JsPropertyMap (jsinterop.base.JsPropertyMap)3 Document (org.gwtproject.dom.client.Document)3 Element (org.gwtproject.dom.client.Element)3 InputElement (org.gwtproject.dom.client.InputElement)3 Document (elemental2.dom.Document)2 File (elemental2.dom.File)2 Window (elemental2.dom.Window)2 Field (java.lang.reflect.Field)2 List (java.util.List)2