Search in sources :

Example 6 with PatchMethod

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

the class RootPanelPatcher method isElementChildOfWidget.

@PatchMethod
static boolean isElementChildOfWidget(Element element) {
    // Walk up the DOM hierarchy, looking for any widget with an event
    // listener
    // set. Though it is not dependable in the general case that a widget will
    // have set its element's event listener at all times, it *is* dependable
    // if the widget is attached. Which it will be in this case.
    element = element.getParentElement();
    BodyElement body = Document.get().getBody();
    while (element != null && body != element) {
        if (Event.getEventListener(element) != null) {
            return true;
        }
        element = element.getParentElement();
    }
    return false;
}
Also used : BodyElement(com.google.gwt.dom.client.BodyElement) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 7 with PatchMethod

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

the class DOMImplPatcher method buttonClick.

@PatchMethod
static void buttonClick(Object domImpl, ButtonElement button) {
    EventTarget relatedTarget = button.cast();
    Event onMouseOver = EventBuilder.create(Event.ONMOUSEOVER).setTarget(button).setRelatedTarget(relatedTarget).build();
    dispatchEvent(domImpl, button, onMouseOver);
    Event onMouseDown = EventBuilder.create(Event.ONMOUSEDOWN).setTarget(button).setRelatedTarget(relatedTarget).setButton(Event.BUTTON_LEFT).build();
    dispatchEvent(domImpl, button, onMouseDown);
    Event onMouseUp = EventBuilder.create(Event.ONMOUSEUP).setTarget(button).setRelatedTarget(relatedTarget).setButton(Event.BUTTON_LEFT).build();
    dispatchEvent(domImpl, button, onMouseUp);
    Event onClick = EventBuilder.create(Event.ONCLICK).setTarget(button).setRelatedTarget(relatedTarget).build();
    dispatchEvent(domImpl, button, onClick);
}
Also used : Event(com.google.gwt.user.client.Event) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 8 with PatchMethod

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

the class PotentialElementPatcher method resolve.

@PatchMethod
static Element resolve(Element maybePotential) {
    if (isPotential(maybePotential)) {
        UIObject o = JavaScriptObjects.getObject(maybePotential, POTENTIALELEMENT_UIOBJECT);
        GwtReflectionUtils.callPrivateMethod(o, "resolvePotentialElement");
        return JavaScriptObjects.getObject(maybePotential, POTENTIALELEMENT_WRAPPED_ELEMENT);
    } else {
        return maybePotential;
    }
}
Also used : UIObject(com.google.gwt.user.client.ui.UIObject) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 9 with PatchMethod

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

the class UIObjectPatcher method replaceNode.

@PatchMethod
static void replaceNode(UIObject uiObject, Element node, Element newNode) {
    Node parent = node.getParentNode();
    if (parent != null) {
        parent.insertBefore(newNode, node);
        parent.removeChild(node);
    }
}
Also used : Node(com.google.gwt.dom.client.Node) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 10 with PatchMethod

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

the class WindowPatcher method resizeTo.

@PatchMethod
static void resizeTo(int width, int height) {
    Element viewportElement = GwtReflectionUtils.callPrivateMethod(Document.get(), "getViewportElement", "com.google.gwt.dom.client.Document");
    GwtDomUtils.setClientWidth(viewportElement, width);
    GwtDomUtils.setClientHeight(viewportElement, height);
}
Also used : Element(com.google.gwt.dom.client.Element) 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