Search in sources :

Example 21 with PatchMethod

use of com.googlecode.gwt.test.patchers.PatchMethod in project gwt-test-utils by gwt-test-utils.

the class DOMImplPatcher method dispatchEvent.

@PatchMethod
static void dispatchEvent(Object domImpl, Element target, NativeEvent evt) {
    EventListener listener = DOM.getEventListener(target);
    if (listener != null && evt instanceof Event) {
        listener.onBrowserEvent((Event) evt);
    }
    // dispatch to parent if needed
    boolean propagationStopped = JavaScriptObjects.getBoolean(evt, JsoProperties.EVENT_IS_STOPPED);
    if (target.getParentElement() != null && propagationStopped) {
        target.getParentElement().dispatchEvent(evt);
    }
}
Also used : Event(com.google.gwt.user.client.Event) EventListener(com.google.gwt.user.client.EventListener) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 22 with PatchMethod

use of com.googlecode.gwt.test.patchers.PatchMethod in project gwt-test-utils by gwt-test-utils.

the class DOMPatcher method getParent.

@PatchMethod
static Element getParent(Element elem) {
    com.google.gwt.dom.client.Element parentElem = elem.getParentElement();
    if (parentElem == null) {
        return null;
    }
    Element parent = parentElem.cast();
    return parent;
}
Also used : Element(com.google.gwt.dom.client.Element) Element(com.google.gwt.dom.client.Element) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 23 with PatchMethod

use of com.googlecode.gwt.test.patchers.PatchMethod in project gwt-test-utils by gwt-test-utils.

the class DocumentPatcher method nativeGet.

@PatchMethod
static Document nativeGet() {
    if (DOCUMENT_HOLDER.document == null) {
        try {
            DOCUMENT_HOLDER.document = JsoUtils.newDocument();
            Element e = parseHTMLElement(DOCUMENT_HOLDER.document);
            DOCUMENT_HOLDER.document.appendChild(e);
            JavaScriptObjects.setProperty(DOCUMENT_HOLDER.document, DOCUMENT_ELEMENT, e);
            return DOCUMENT_HOLDER.document;
        } catch (Exception e) {
            if (GwtTestException.class.isInstance(e)) {
                throw (GwtTestException) e;
            } else {
                throw new GwtTestDomException("Unable to create Document", e);
            }
        }
    }
    return DOCUMENT_HOLDER.document;
}
Also used : GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) GwtTestDomException(com.googlecode.gwt.test.exceptions.GwtTestDomException) GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) GwtTestConfigurationException(com.googlecode.gwt.test.exceptions.GwtTestConfigurationException) GwtTestDomException(com.googlecode.gwt.test.exceptions.GwtTestDomException) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 24 with PatchMethod

use of com.googlecode.gwt.test.patchers.PatchMethod in project gwt-test-utils by gwt-test-utils.

the class PotentialElementPatcher method build.

@PatchMethod
static PotentialElement build(UIObject o, String tagName) {
    PotentialElement e = JsoUtils.newNode(Node.ELEMENT_NODE).cast();
    Element wrappedElement = JsoUtils.newElement(tagName, o.getElement().getOwnerDocument());
    JavaScriptObjects.setProperty(e, POTENTIALELEMENT_TAG, true);
    JavaScriptObjects.setProperty(e, POTENTIALELEMENT_WRAPPED_ELEMENT, wrappedElement);
    JavaScriptObjects.setProperty(e, POTENTIALELEMENT_UIOBJECT, o);
    return e;
}
Also used : PotentialElement(com.google.gwt.user.client.ui.PotentialElement) Element(com.google.gwt.dom.client.Element) PotentialElement(com.google.gwt.user.client.ui.PotentialElement) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 25 with PatchMethod

use of com.googlecode.gwt.test.patchers.PatchMethod in project gwt-test-utils by gwt-test-utils.

the class TableSectionElementPatcher method deleteRow.

@PatchMethod
static void deleteRow(TableSectionElement e, int index) {
    NodeList<TableRowElement> rows = e.getRows();
    if (rows.getLength() < 1) {
        return;
    }
    if (index == -1) {
        index = rows.getLength() - 1;
    }
    TableRowElement rowToDelete = rows.getItem(index);
    e.removeChild(rowToDelete);
}
Also used : TableRowElement(com.google.gwt.dom.client.TableRowElement) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Aggregations

PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)26 Element (com.google.gwt.dom.client.Element)8 Event (com.google.gwt.user.client.Event)3 PotentialElement (com.google.gwt.user.client.ui.PotentialElement)3 TableRowElement (com.google.gwt.dom.client.TableRowElement)2 Timer (com.google.gwt.user.client.Timer)2 GwtTestException (com.googlecode.gwt.test.exceptions.GwtTestException)2 GwtTestPatchException (com.googlecode.gwt.test.exceptions.GwtTestPatchException)2 TimerTask (java.util.TimerTask)2 CtClass (javassist.CtClass)2 CtMethod (javassist.CtMethod)2 GWT (com.google.gwt.core.client.GWT)1 BodyElement (com.google.gwt.dom.client.BodyElement)1 IFrameElement (com.google.gwt.dom.client.IFrameElement)1 Node (com.google.gwt.dom.client.Node)1 AutoDirectionHandler (com.google.gwt.i18n.client.AutoDirectionHandler)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 EventListener (com.google.gwt.user.client.EventListener)1 FormPanel (com.google.gwt.user.client.ui.FormPanel)1 SubmitCompleteEvent (com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent)1