Search in sources :

Example 16 with PatchMethod

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

the class UIObjectPatcher method setElement.

@PatchMethod
static void setElement(UIObject uiObject, com.google.gwt.user.client.Element elem) {
    Element element = GwtReflectionUtils.getPrivateFieldValue(uiObject, "element");
    assert element == null || PotentialElement.isPotential(element) : "Element may only be set once";
    GwtReflectionUtils.setPrivateFieldValue(uiObject, "element", elem);
    // if the widget has not been attached yet
    if (Widget.class.isInstance(uiObject)) {
        DOM.setEventListener(elem, (Widget) uiObject);
    }
}
Also used : PotentialElement(com.google.gwt.user.client.ui.PotentialElement) Element(com.google.gwt.dom.client.Element) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 17 with PatchMethod

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

the class UIObjectPatcher method replaceElement.

@PatchMethod
static void replaceElement(UIObject uiObject, Element elem) {
    Element element = GwtReflectionUtils.getPrivateFieldValue(uiObject, "element");
    if (element != null) {
        // replace this.element in its parent with elem.
        replaceNode(uiObject, element, elem);
    }
    GwtReflectionUtils.setPrivateFieldValue(uiObject, "element", elem);
}
Also used : PotentialElement(com.google.gwt.user.client.ui.PotentialElement) Element(com.google.gwt.dom.client.Element) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 18 with PatchMethod

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

the class ValueBoxBasePatcher method setText.

@PatchMethod
static void setText(ValueBoxBase<?> valueBoxBase, String text) {
    DOM.setElementProperty(valueBoxBase.getElement(), "value", text != null ? text : "");
    AutoDirectionHandler autoDirHandler = GwtReflectionUtils.getPrivateFieldValue(valueBoxBase, "autoDirHandler");
    autoDirHandler.refreshDirection();
    int cursorPos = text != null ? text.length() : 0;
    valueBoxBase.setCursorPos(cursorPos);
}
Also used : AutoDirectionHandler(com.google.gwt.i18n.client.AutoDirectionHandler) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 19 with PatchMethod

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

the class WindowPatcher method resizeBy.

@PatchMethod
static void resizeBy(int width, int height) {
    Element viewportElement = GwtReflectionUtils.callPrivateMethod(Document.get(), "getViewportElement", "com.google.gwt.dom.client.Document");
    int currentWidth = Document.get().getClientWidth();
    GwtDomUtils.setClientWidth(viewportElement, currentWidth + width);
    int currentHeight = Document.get().getClientHeight();
    GwtDomUtils.setClientHeight(viewportElement, currentHeight + height);
}
Also used : Element(com.google.gwt.dom.client.Element) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 20 with PatchMethod

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

the class ImageStatePatcher method fireSyntheticLoadEvent.

@PatchMethod
static void fireSyntheticLoadEvent(Object state, Image image) {
    Event loadEvent = EventBuilder.create(Event.ONLOAD).build();
    Browser.dispatchEvent(image, loadEvent);
}
Also used : Event(com.google.gwt.user.client.Event) 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