aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-extensions/net/sourceforge/jnlp
diff options
context:
space:
mode:
authorJana Fabrikova <[email protected]>2013-04-29 15:29:46 +0200
committerJana Fabrikova <[email protected]>2013-04-29 15:29:46 +0200
commit1ee0e5d164e1a122b5d55e1a80406d5575e1d725 (patch)
tree3cb824ce7eb82b362d4a6b75578837929138b96c /tests/test-extensions/net/sourceforge/jnlp
parent3042f77a9585a2fe96cd72f47a284b423ecfc85a (diff)
refactoring AWTFramework - iconPosition is of type Point
Diffstat (limited to 'tests/test-extensions/net/sourceforge/jnlp')
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java18
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java16
2 files changed, 18 insertions, 16 deletions
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
index af1655f..8a888d4 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
@@ -38,6 +38,7 @@ package net.sourceforge.jnlp.awt;
import java.awt.AWTException;
import java.awt.Color;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
@@ -62,7 +63,7 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
private String initStr = "";
private Color appletColor;
private BufferedImage marker;
- private Rectangle markerPosition;
+ private Point markerPosition;
private int appletHeight;
private int appletWidth;
private int tryKTimes = DEFAULT_K;
@@ -132,7 +133,7 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
* @param appletHeight
*/
- public AWTHelper(BufferedImage icon, Rectangle iconPosition, int appletWidth, int appletHeight){
+ public AWTHelper(BufferedImage icon, Point iconPosition, int appletWidth, int appletHeight){
this();
this.marker = icon;
this.markerPosition = iconPosition;
@@ -143,7 +144,7 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
this.appletDimensionGiven = true;
}
- public AWTHelper(String initString, BufferedImage icon, Rectangle iconPosition, int appletWidth, int appletHeight) throws AWTException{
+ public AWTHelper(String initString, BufferedImage icon, Point iconPosition, int appletWidth, int appletHeight) throws AWTException{
this(icon, iconPosition, appletWidth, appletHeight);
this.initStr = initString;
@@ -160,16 +161,17 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
*/
public AWTHelper(int appletWidth, int appletHeight){
this();
+
String test_server_dir_path = System.getProperty("test.server.dir");
try {
this.marker = ImageIO.read(new File(test_server_dir_path + "/marker.png"));
- this.markerPosition = new Rectangle(0,0,marker.getWidth(),marker.getHeight());
+ this.markerPosition = new Point(0,0);
this.markerGiven = true;
} catch (IOException e) {
throw new RuntimeException("AWTHelper could not read marker.png.",e);
}
-
+
this.appletWidth = appletWidth;
this.appletHeight = appletHeight;
this.appletDimensionGiven = true;
@@ -297,7 +299,7 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
this.initStrGiven = true;
}
- public void setMarker(BufferedImage marker, Rectangle markerPosition) {
+ public void setMarker(BufferedImage marker, Point markerPosition) {
this.marker = marker;
this.markerPosition = markerPosition;
this.markerGiven = true;
@@ -347,7 +349,7 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
* @param K
* @throws ComponentNotFoundException
*/
- public void captureScreenAndFindAppletByIconTryKTimes(BufferedImage icon, Rectangle iconPosition, int width, int height, int K) throws ComponentNotFoundException {
+ public void captureScreenAndFindAppletByIconTryKTimes(BufferedImage icon, Point iconPosition, int width, int height, int K) throws ComponentNotFoundException {
int count = 0;
appletFound = false;
@@ -551,4 +553,4 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
public void typeKey(int key) {
KeyboardActions.typeKey(this.robot, key);
}
-}
+ }
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
index ed85617..5d3a25e 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
@@ -39,6 +39,7 @@ exception statement from your version.
package net.sourceforge.jnlp.awt.imagesearch;
import java.awt.Color;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
@@ -86,10 +87,9 @@ public class ComponentFinder {
/**
- * method findWindowByIcon finds the application area assuming there is a
+ * Method findWindowByIcon finds the application area assuming there is a
* given icon in given position on the application window
- * (the left upper corner by default) the dimension of the window has to
- * be given
+ * the dimension of the window has to be given.
*
* @param icon
* @param iconPosition
@@ -98,25 +98,25 @@ public class ComponentFinder {
* @param screenshot
* @return Rectangle rectangle where the applet resides
*/
- public static Rectangle findWindowByIcon(BufferedImage icon, Rectangle iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot) {
+ public static Rectangle findWindowByIcon(BufferedImage icon, Point iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot) {
Rectangle r = ImageSeeker.findExactImage(icon, screenshot);
if( ImageSeeker.isRectangleValid(r)){
- return windowPositionFromIconPosition(r, iconPosition, windowWidth, windowHeight);
+ return windowPositionFromIconPosition(r.getLocation(), iconPosition, windowWidth, windowHeight);
}else{
return null;
}
}
- public static Rectangle findWindowByIconBlurred(BufferedImage icon, Rectangle iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot, double minCorrelation) {
+ public static Rectangle findWindowByIconBlurred(BufferedImage icon, Point iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot, double minCorrelation) {
Rectangle r = ImageSeeker.findBlurredImage(icon, screenshot, minCorrelation);
if( ImageSeeker.isRectangleValid(r)){
- return windowPositionFromIconPosition(r, iconPosition, windowWidth, windowHeight);
+ return windowPositionFromIconPosition(r.getLocation(), iconPosition, windowWidth, windowHeight);
}else{
return null;
}
}
- public static Rectangle windowPositionFromIconPosition(Rectangle iconAbsolute, Rectangle iconRelative, int windowWidth, int windowHeight){
+ public static Rectangle windowPositionFromIconPosition(Point iconAbsolute, Point iconRelative, int windowWidth, int windowHeight){
return new Rectangle( iconAbsolute.x - iconRelative.x, iconAbsolute.y - iconRelative.y,
windowWidth, windowHeight);
}