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