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;
}
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);
}
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;
}
}
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);
}
}
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);
}
Aggregations