< prev index next >

core/JemmyCore/src/org/jemmy/control/Wrap.java

Print this page

        

*** 51,119 **** */ @ControlType(Object.class) @ControlInterfaces({Mouse.class, Keyboard.class, Drag.class}) public abstract class Wrap<CONTROL extends Object> { - /** - * - */ public static final String BOUNDS_PROP_NAME = "bounds"; - /** - * - */ public static final String CLICKPOINT_PROP_NAME = "clickPoint"; - /** - * - */ public static final String CONTROL_CLASS_PROP_NAME = "control.class"; - /** - * - */ public static final String CONTROL_PROP_NAME = "control"; - /** - * - */ public static final String INPUT_FACTORY_PROPERTY = "input.control.interface.factory"; - /** - * - */ public static final String IMAGE_LOADER_PROPERTY = "image.loader"; - /** - * - */ public static final String IMAGE_CAPTURER_PROPERTY = "image.capturer"; - /** - * - */ public static final String TEXT_PROP_NAME = "text"; - /** - * - */ public static final String POSITION_PROP_NAME = "position"; - /** - * - */ public static final String VALUE_PROP_NAME = "value"; - /** - * - */ public static final String WRAPPER_CLASS_PROP_NAME = "wrapper.class"; - /** - * - */ public static final String TOOLTIP_PROP_NAME = "tooltip"; - /** - * - */ public static final String NAME_PROP_NAME = "name"; - /** - * - */ public static final Timeout WAIT_STATE_TIMEOUT = new Timeout("wait.state", 1000); ! /** ! * ! */ public static final String OUTPUT = Wrap.class.getName() + ".OUTPUT"; private static DefaultWrapper theWrapper = new DefaultWrapper(Environment.getEnvironment()); static { Environment.getEnvironment().initTimeout(WAIT_STATE_TIMEOUT); --- 51,75 ---- */ @ControlType(Object.class) @ControlInterfaces({Mouse.class, Keyboard.class, Drag.class}) public abstract class Wrap<CONTROL extends Object> { public static final String BOUNDS_PROP_NAME = "bounds"; public static final String CLICKPOINT_PROP_NAME = "clickPoint"; public static final String CONTROL_CLASS_PROP_NAME = "control.class"; public static final String CONTROL_PROP_NAME = "control"; public static final String INPUT_FACTORY_PROPERTY = "input.control.interface.factory"; public static final String IMAGE_LOADER_PROPERTY = "image.loader"; public static final String IMAGE_CAPTURER_PROPERTY = "image.capturer"; public static final String TEXT_PROP_NAME = "text"; public static final String POSITION_PROP_NAME = "position"; public static final String VALUE_PROP_NAME = "value"; public static final String WRAPPER_CLASS_PROP_NAME = "wrapper.class"; public static final String TOOLTIP_PROP_NAME = "tooltip"; public static final String NAME_PROP_NAME = "name"; public static final Timeout WAIT_STATE_TIMEOUT = new Timeout("wait.state", 1000); ! public static final String OUTPUT = Wrap.class.getName() + ".OUTPUT"; private static DefaultWrapper theWrapper = new DefaultWrapper(Environment.getEnvironment()); static { Environment.getEnvironment().initTimeout(WAIT_STATE_TIMEOUT);
*** 123,136 **** Environment.getEnvironment().initTimeout(Drag.BEFORE_DROP_TIMEOUT); Environment.getEnvironment().initTimeout(Drag.IN_DRAG_TIMEOUT); Environment.getEnvironment().initTimeout(Keyboard.PUSH); } - /** - * - * @return - */ public static DefaultWrapper getWrapper() { return theWrapper; } CONTROL node; Environment env; --- 79,88 ----
*** 182,192 **** /** * Return default point to click, drag. This implementation returns the * center must be overriden if something different is desired. * ! * @return */ @Property(CLICKPOINT_PROP_NAME) public Point getClickPoint() { return new Point(getScreenBounds().width / 2, (getScreenBounds().height / 2)); } --- 134,144 ---- /** * Return default point to click, drag. This implementation returns the * center must be overriden if something different is desired. * ! * @return the default click point */ @Property(CLICKPOINT_PROP_NAME) public Point getClickPoint() { return new Point(getScreenBounds().width / 2, (getScreenBounds().height / 2)); }
*** 205,216 **** /** * Transforms point in local control coordinate system to screen * coordinates. * ! * @param local ! * @return * @see #toLocal(org.jemmy.Point) */ public Point toAbsolute(Point local) { Rectangle bounds = getScreenBounds(); return local.translate(bounds.x, bounds.y); --- 157,168 ---- /** * Transforms point in local control coordinate system to screen * coordinates. * ! * @param local the local coordinate ! * @return a absolute translated point * @see #toLocal(org.jemmy.Point) */ public Point toAbsolute(Point local) { Rectangle bounds = getScreenBounds(); return local.translate(bounds.x, bounds.y);
*** 218,228 **** /** * Transforms point in screen coordinates to local control coordinate * system. * ! * @param local * @return coordinates which should be used for mouse operations. * @see #toAbsolute(org.jemmy.Point) */ public Point toLocal(Point local) { Rectangle bounds = getScreenBounds(); --- 170,180 ---- /** * Transforms point in screen coordinates to local control coordinate * system. * ! * @param local the local coordinate * @return coordinates which should be used for mouse operations. * @see #toAbsolute(org.jemmy.Point) */ public Point toLocal(Point local) { Rectangle bounds = getScreenBounds();
*** 256,266 **** /** * Waits for a portion of image to be exact the same as the parameter. * * @see Wrap#as(java.lang.Class) ! * @param golden * @param rect A portion of control to compare. * @param resID ID of a result image to save in case of failure. No image * saved if null. * @param diffID ID of a diff image to save in case of failure. No image * saved if null. --- 208,218 ---- /** * Waits for a portion of image to be exact the same as the parameter. * * @see Wrap#as(java.lang.Class) ! * @param golden the image to match against * @param rect A portion of control to compare. * @param resID ID of a result image to save in case of failure. No image * saved if null. * @param diffID ID of a diff image to save in case of failure. No image * saved if null.
*** 294,304 **** /** * Waits for image to be exact the same as the parameter. * * @see Wrap#as(java.lang.Class) ! * @param golden * @param resID ID of a result image to save in case of failure. No image * saved if null. * @param diffID ID of a diff image to save in case of failure. No image * saved if null. */ --- 246,256 ---- /** * Waits for image to be exact the same as the parameter. * * @see Wrap#as(java.lang.Class) ! * @param golden the image to match against * @param resID ID of a result image to save in case of failure. No image * saved if null. * @param diffID ID of a diff image to save in case of failure. No image * saved if null. */
*** 308,332 **** } /** * TODO javadoc * ! * @param <V> ! * @param state ! * @param value * @return last returned State value * @throws TimeoutExpiredException in case the wait is unsuccessful. */ public <V> V waitState(State<V> state, V value) { return getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, state); } /** ! * TODO javadoc ! * ! * @param <V> ! * @param state * @return last returned State value * @throws TimeoutExpiredException in case the wait is unsuccessful. */ public <V> V waitState(State<V> state) { return getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureState(state); --- 260,282 ---- } /** * TODO javadoc * ! * @param <V> the states type ! * @param state the state ! * @param value the state value * @return last returned State value * @throws TimeoutExpiredException in case the wait is unsuccessful. */ public <V> V waitState(State<V> state, V value) { return getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, state); } /** ! * @param <V> the states type ! * @param state the state * @return last returned State value * @throws TimeoutExpiredException in case the wait is unsuccessful. */ public <V> V waitState(State<V> state) { return getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureState(state);
*** 368,380 **** * <code>KeyTarget</code>, which implementations are encapsulated. If some * other functionality is desired, must be overriden together with * <code>as(java.lang.Class)</code> * * @see Wrap#is(java.lang.Class) ! * @param <INTERFACE> ! * @param interfaceClass ! * @return */ public <INTERFACE extends ControlInterface> boolean is(Class<INTERFACE> interfaceClass) { if (interfaceClass.isInstance(this)) { return true; } --- 318,331 ---- * <code>KeyTarget</code>, which implementations are encapsulated. If some * other functionality is desired, must be overriden together with * <code>as(java.lang.Class)</code> * * @see Wrap#is(java.lang.Class) ! * @param <INTERFACE> the control interface ! * @param interfaceClass the interface class ! * @return <code>true</code> if the control is an ControlInterface, ! * <code>false</code> otherwise */ public <INTERFACE extends ControlInterface> boolean is(Class<INTERFACE> interfaceClass) { if (interfaceClass.isInstance(this)) { return true; }
*** 391,405 **** * <code>KeyTarget</code>, which implementations are encapsulated. If some * other functionality is desired, must be overriden together with * <code>as(java.lang.Class)</code> * * @see Wrap#is(java.lang.Class) ! * @param <TYPE> ! * @param <INTERFACE> ! * @param interfaceClass * @param type The parameter class. ! * @return */ public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> boolean is(Class<INTERFACE> interfaceClass, Class<TYPE> type) { if (interfaceClass.isInstance(this)) { if (interfaceClass.cast(this).getType().isAssignableFrom(type)) { return true; --- 342,357 ---- * <code>KeyTarget</code>, which implementations are encapsulated. If some * other functionality is desired, must be overriden together with * <code>as(java.lang.Class)</code> * * @see Wrap#is(java.lang.Class) ! * @param <TYPE> the type interface ! * @param <INTERFACE> the control interface ! * @param interfaceClass the interface class * @param type The parameter class. ! * @return <code>true</code> if the control is an ControlInterface, ! * <code>false</code> otherwise */ public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> boolean is(Class<INTERFACE> interfaceClass, Class<TYPE> type) { if (interfaceClass.isInstance(this)) { if (interfaceClass.cast(this).getType().isAssignableFrom(type)) { return true;
*** 433,445 **** /** * Returns an implementation of interface associated with this object. First * it checks * * @see Wrap#is(java.lang.Class) ! * @param <INTERFACE> ! * @param interfaceClass ! * @return */ public <INTERFACE extends ControlInterface> INTERFACE as(Class<INTERFACE> interfaceClass) { if (interfaceClass.isInstance(this)) { return interfaceClass.cast(this); } --- 385,397 ---- /** * Returns an implementation of interface associated with this object. First * it checks * * @see Wrap#is(java.lang.Class) ! * @param <INTERFACE> the control interface ! * @param interfaceClass the interface class ! * @return the control interface instance */ public <INTERFACE extends ControlInterface> INTERFACE as(Class<INTERFACE> interfaceClass) { if (interfaceClass.isInstance(this)) { return interfaceClass.cast(this); }
*** 454,468 **** /** * Returns an implementation of interface associated with the object. * * @see Wrap#is(java.lang.Class) ! * @param <TYPE> ! * @param <INTERFACE> ! * @param interfaceClass * @param type The parameter class. ! * @return */ public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> INTERFACE as(Class<INTERFACE> interfaceClass, Class<TYPE> type) { if (interfaceClass.isInstance(this)) { if (interfaceClass.cast(this).getType().isAssignableFrom(type)) { return interfaceClass.cast(this); --- 406,420 ---- /** * Returns an implementation of interface associated with the object. * * @see Wrap#is(java.lang.Class) ! * @param <TYPE> the type interface ! * @param <INTERFACE> the control interface ! * @param interfaceClass the interface class * @param type The parameter class. ! * @return the type control instance */ public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> INTERFACE as(Class<INTERFACE> interfaceClass, Class<TYPE> type) { if (interfaceClass.isInstance(this)) { if (interfaceClass.cast(this).getType().isAssignableFrom(type)) { return interfaceClass.cast(this);
*** 488,529 **** private Mouse mouse = null; private Drag drag = null; private Keyboard keyboard = null; /** ! * A shortcut to ! * <code>as(MouseTarget.class).mouse()</code> * ! * @return */ @As(Mouse.class) public Mouse mouse() { if (mouse == null) { mouse = getEnvironment().getInputFactory().create(this, Mouse.class); } return mouse; } /** ! * A shortcut to ! * <code>as(MouseTarget.class).drag()</code> * ! * @return */ @As(Drag.class) public Drag drag() { if (drag == null) { drag = getEnvironment().getInputFactory().create(this, Drag.class); } return drag; } /** ! * A shortcut to ! * <code>as(KeyTarget.class).wrap()</code> * ! * @return */ @As(Keyboard.class) public Keyboard keyboard() { if (keyboard == null) { keyboard = getEnvironment().getInputFactory().create(this, Keyboard.class); --- 440,478 ---- private Mouse mouse = null; private Drag drag = null; private Keyboard keyboard = null; /** ! * A shortcut to <code>as(MouseTarget.class).mouse()</code> * ! * @return the mouse target */ @As(Mouse.class) public Mouse mouse() { if (mouse == null) { mouse = getEnvironment().getInputFactory().create(this, Mouse.class); } return mouse; } /** ! * A shortcut to <code>as(MouseTarget.class).drag()</code> * ! * @return the drag target */ @As(Drag.class) public Drag drag() { if (drag == null) { drag = getEnvironment().getInputFactory().create(this, Drag.class); } return drag; } /** ! * A shortcut to <code>as(KeyTarget.class).wrap()</code> * ! * @return the wrap target */ @As(Keyboard.class) public Keyboard keyboard() { if (keyboard == null) { keyboard = getEnvironment().getInputFactory().create(this, Keyboard.class);
*** 539,552 **** /** * *********************************************************************** */ private HashMap<String, Object> properties = new HashMap<String, Object>(); - /** - * - * @return - */ @Property(CONTROL_CLASS_PROP_NAME) public Class<?> getControlClass() { return getControl().getClass(); } --- 488,497 ----
*** 665,681 **** throw new JemmyException("Unable to obtain property \"" + ((prop != null) ? prop.value() : "null") + "\"", ex, this); } } /** ! * Get property of the wrapped object. Uses first available from <nl> ! * <li>methods annotated by ! * <code>org.jemmy.control.Property</code></li> <li>wrapped object methods ! * listed in ! * <code>org.jemmy.control.MethodProperties</code></li> <li>wrapped object ! * fields listed in ! * <code>org.jemmy.control.FieldProperties</code></li> </nl> * * @param name property name * @throws JemmyException if no property found * @see Property * @see MethodProperties --- 610,625 ---- throw new JemmyException("Unable to obtain property \"" + ((prop != null) ? prop.value() : "null") + "\"", ex, this); } } /** ! * Get property of the wrapped object. Uses first available from ! * <ol> ! * <li>methods annotated by <code>org.jemmy.control.Property</code></li> ! * <li>wrapped object methods listed in <code>org.jemmy.control.MethodProperties</code></li> ! * <li>wrapped object fields listed in <code>org.jemmy.control.FieldProperties</code></li> ! * </ol> * * @param name property name * @throws JemmyException if no property found * @see Property * @see MethodProperties
*** 709,737 **** /** * Get property out of the control interface. Refer to the interface doc to * find out what properties are provided. * ! * @param <INTERFACE> ! * @param name ! * @param intrfc ! * @return */ public <INTERFACE extends ControlInterface> Object getProperty(String name, Class<INTERFACE> intrfc) { return getInterfaceProperty(intrfc, as(intrfc), name); } /** * Get property out of the control interface. Refer to the interface doc to * find out what properties are provided. * ! * @param <TYPE> ! * @param <INTERFACE> ! * @param name ! * @param intrfc ! * @param type ! * @return */ public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> Object getProperty(String name, Class<INTERFACE> intrfc, Class<TYPE> type) { return getInterfaceProperty(intrfc, as(intrfc, type), name); } --- 653,681 ---- /** * Get property out of the control interface. Refer to the interface doc to * find out what properties are provided. * ! * @param <INTERFACE> the control interface ! * @param name the property name ! * @param intrfc the interface class ! * @return the control property */ public <INTERFACE extends ControlInterface> Object getProperty(String name, Class<INTERFACE> intrfc) { return getInterfaceProperty(intrfc, as(intrfc), name); } /** * Get property out of the control interface. Refer to the interface doc to * find out what properties are provided. * ! * @param <TYPE> the type interface ! * @param <INTERFACE> the control interface ! * @param name the property name ! * @param intrfc the interface class ! * @param type The parameter class. ! * @return the control property */ public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> Object getProperty(String name, Class<INTERFACE> intrfc, Class<TYPE> type) { return getInterfaceProperty(intrfc, as(intrfc, type), name); }
*** 760,773 **** /** * Wait for the property * <code>property</code> of control interface to get the specified value. * <code>WAIT_STATE_TIMOUT</code> timeout is used * ! * @param <INTERFACE> ! * @param property ! * @param intrfc ! * @param value */ public <INTERFACE extends ControlInterface> void waitProperty(final String property, final Class<INTERFACE> intrfc, final Object value) { Object instance = as(intrfc); getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, new State<Object>() { --- 704,717 ---- /** * Wait for the property * <code>property</code> of control interface to get the specified value. * <code>WAIT_STATE_TIMOUT</code> timeout is used * ! * @param <INTERFACE> the control interface ! * @param property the property name ! * @param intrfc the interface class ! * @param value the new parameter value */ public <INTERFACE extends ControlInterface> void waitProperty(final String property, final Class<INTERFACE> intrfc, final Object value) { Object instance = as(intrfc); getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, new State<Object>() {
*** 785,800 **** /** * Wait for the property * <code>property</code> of control interface to get the specified value. * <code>WAIT_STATE_TIMOUT</code> timeout is used * ! * @param <TYPE> ! * @param <INTERFACE> ! * @param property ! * @param intrfc ! * @param type ! * @param value */ public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> void waitProperty(final String property, final Class<INTERFACE> intrfc, final Class<TYPE> type, final Object value) { getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, new State<Object>() { public Object reached() { --- 729,744 ---- /** * Wait for the property * <code>property</code> of control interface to get the specified value. * <code>WAIT_STATE_TIMOUT</code> timeout is used * ! * @param <TYPE> the type interface ! * @param <INTERFACE> the control interface ! * @param property the property name ! * @param intrfc the interface class ! * @param type the parameter class. ! * @param value the new parameter value */ public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> void waitProperty(final String property, final Class<INTERFACE> intrfc, final Class<TYPE> type, final Object value) { getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, new State<Object>() { public Object reached() {
*** 806,820 **** return "Interface " + intrfc.getName() + " having property " + property + " expected value '" + value + "' (Property = '" + getProperty(property) + "')"; } }); } - /** - * - * @param name - * @return - */ public boolean hasFieldProperty(String name) { Class<?> cls = getClass(); do { if (cls.isAnnotationPresent(FieldProperties.class)) { FieldProperties props = cls.getAnnotation(FieldProperties.class); --- 750,759 ----
*** 824,838 **** } } while ((cls = cls.getSuperclass()) != null); return false; } - /** - * - * @param name - * @return - */ public boolean hasMethodProperty(String name) { Class<?> cls = getClass(); do { if (cls.isAnnotationPresent(MethodProperties.class)) { MethodProperties props = cls.getAnnotation(MethodProperties.class); --- 763,772 ----
*** 852,866 **** } return false; } - /** - * - * @param name - * @return - */ public Object getFieldProperty(final String name) { if (!hasFieldProperty(name)) { throw new JemmyException("No \"" + name + "\" field property specified on " + getClass().getName()); } GetAction action = new GetAction() { --- 786,795 ----
*** 875,889 **** throw new JemmyException("Unable to obtain property \"" + name + "\"", action.getThrowable(), this); } return result; } - /** - * - * @param name - * @return - */ public Object getMethodProperty(final String name) { if (!hasMethodProperty(name)) { throw new JemmyException("No \"" + name + "\" method property specified on " + getClass().getName()); } GetAction action = new GetAction() { --- 804,813 ----
*** 903,919 **** throw new JemmyException("Unable to obtain property \"" + name + "\"", action.getThrowable(), this); } return result; } - /** - * - * @param <P> - * @param valueClass - * @param name - * @return - */ public <P> P getProperty(Class<P> valueClass, String name) { return valueClass.cast(getProperty(name)); } /** --- 827,836 ----
*** 922,932 **** * <code>@Property</code> and values of methods/field from * <code>@MethodProperties</code>/ * <code>FieldProperties</code> correspondingly. * * @return a map of properties ! * @throws Runtime exception should there be an exception thrown while * getting a property */ public HashMap<String, Object> getProperties() { fillTheProps(false); return properties; --- 839,849 ---- * <code>@Property</code> and values of methods/field from * <code>@MethodProperties</code>/ * <code>FieldProperties</code> correspondingly. * * @return a map of properties ! * @throws RuntimeException should there be an exception thrown while * getting a property */ public HashMap<String, Object> getProperties() { fillTheProps(false); return properties;
< prev index next >