Search in sources :

Example 1 with InitMethod

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

the class WidgetPatcher method initClass.

@InitMethod
static void initClass(CtClass c) throws CannotCompileException, NotFoundException {
    // add behavior to Widget.onAttach method
    CtMethod onAttach = c.getMethod("onAttach", "()V");
    onAttach.insertBefore(GwtFinder.class.getName() + ".onAttach(this);");
    // add behavior to RadioButton.setName method
    CtMethod onDetach = c.getMethod("onDetach", "()V");
    onDetach.insertBefore(GwtFinder.class.getName() + ".onDetach(this);");
}
Also used : CtMethod(javassist.CtMethod) InitMethod(com.googlecode.gwt.test.patchers.InitMethod)

Example 2 with InitMethod

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

the class DomEventPatcher method initClass.

@InitMethod
static void initClass(CtClass c) throws CannotCompileException, NotFoundException {
    CtMethod fireNativeEvent = c.getMethod("fireNativeEvent", "(Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/event/shared/HasHandlers;Lcom/google/gwt/dom/client/Element;)V");
    // fire browser event loop first because some command or async callback may modify the DOM
    // structure + fire NativePreviewHandler
    fireNativeEvent.insertBefore(BrowserSimulatorImpl.class.getName() + ".get().fireLoopEnd(); " + DomEventPatcher.class.getName() + ".triggerNativeEvent($1, $3);");
    // fire browser event loop at the end because some command may have been scheduled or RPC call
    // made when the event was dispatched.
    fireNativeEvent.insertAfter(BrowserSimulatorImpl.class.getName() + ".get().fireLoopEnd();");
}
Also used : CtMethod(javassist.CtMethod) InitMethod(com.googlecode.gwt.test.patchers.InitMethod)

Example 3 with InitMethod

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

the class GwtDotCreateProviderPatcher method initClass.

@InitMethod
static void initClass(CtClass ctClass) throws CannotCompileException {
    CtField field = CtField.make("private Class " + BINDED_CLASS_FIELD + ";", ctClass);
    ctClass.addField(field);
}
Also used : CtField(javassist.CtField) InitMethod(com.googlecode.gwt.test.patchers.InitMethod)

Example 4 with InitMethod

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

the class RadioButtonPatcher method initClass.

@InitMethod
static void initClass(CtClass c) throws CannotCompileException, NotFoundException {
    // add overrided RadioButton.setValue method
    CtMethod setValue = CtMethod.make("public void setValue(Boolean value, boolean fireEvents) { super.setValue($1, $2); " + RadioButtonManager.class.getName() + ".onRadioGroupChanged(this, $1, $2); }", c);
    c.addMethod(setValue);
    // add behavior to RadioButton.setName method
    CtMethod setName = c.getMethod("setName", "(Ljava/lang/String;)V");
    setName.insertBefore(RadioButtonManager.class.getName() + ".beforeSetName(this, $1);");
    // Add overrided RadioButton.onLoad method
    CtMethod onLoad = CtMethod.make("protected void onLoad() { super.onLoad(); " + RadioButtonManager.class.getName() + ".onLoad(this); }", c);
    c.addMethod(onLoad);
    // Add overrided RadioButton.onUnLoad method
    CtMethod onUnload = CtMethod.make("protected void onUnLoad() { super.onUnload(); " + RadioButtonManager.class.getName() + ".onUnload(this); }", c);
    c.addMethod(onUnload);
}
Also used : RadioButtonManager(com.googlecode.gwt.test.internal.utils.RadioButtonManager) CtMethod(javassist.CtMethod) InitMethod(com.googlecode.gwt.test.patchers.InitMethod)

Example 5 with InitMethod

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

the class ValueBoxBasePatcher method initClass.

@InitMethod
static void initClass(CtClass c) throws CannotCompileException {
    CtConstructor cons = JavassistUtils.findConstructor(c, Element.class, Renderer.class, Parser.class);
    cons.insertAfter("setText(\"\");");
}
Also used : CtConstructor(javassist.CtConstructor) InitMethod(com.googlecode.gwt.test.patchers.InitMethod)

Aggregations

InitMethod (com.googlecode.gwt.test.patchers.InitMethod)11 CtMethod (javassist.CtMethod)7 GwtTestPatchException (com.googlecode.gwt.test.exceptions.GwtTestPatchException)2 CtClass (javassist.CtClass)2 CtConstructor (javassist.CtConstructor)2 CtField (javassist.CtField)2 NotFoundException (javassist.NotFoundException)2 GwtTestGWTBridge (com.googlecode.gwt.test.internal.handlers.GwtTestGWTBridge)1 RadioButtonManager (com.googlecode.gwt.test.internal.utils.RadioButtonManager)1 PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1