aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-extensions
diff options
context:
space:
mode:
authorJana Fabrikova <[email protected]>2013-04-29 13:54:26 +0200
committerJana Fabrikova <[email protected]>2013-04-29 13:54:26 +0200
commitf95c6d95d919cc41134acfb29d5a9109affe773a (patch)
tree5b3e5734bc34931ea8f9b5a21f77ea8ae744f517 /tests/test-extensions
parent2aa28d1b5aef04ceee046e7082b5fefce21563d6 (diff)
AWTFramework - fixing return values of searching methods
Diffstat (limited to 'tests/test-extensions')
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java7
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java30
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ImageSeeker.java11
3 files changed, 31 insertions, 17 deletions
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
index fb53057..af1655f 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
@@ -346,14 +346,9 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
* @param height
* @param K
* @throws ComponentNotFoundException
- * @throws AWTFrameworkException
*/
- public void captureScreenAndFindAppletByIconTryKTimes(BufferedImage icon, Rectangle iconPosition, int width, int height, int K) throws ComponentNotFoundException, AWTFrameworkException {
+ public void captureScreenAndFindAppletByIconTryKTimes(BufferedImage icon, Rectangle iconPosition, int width, int height, int K) throws ComponentNotFoundException {
- if(!markerGiven){
- throw new AWTFrameworkException("AWTFramework cannot find applet without marker!");
- }
-
int count = 0;
appletFound = false;
while ((count < K) && !appletFound) {
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 e28e877..ed85617 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
@@ -43,7 +43,7 @@ import java.awt.Rectangle;
import java.awt.image.BufferedImage;
public class ComponentFinder {
-
+
/**
* method findColoredRectangle determines coordinates of a rectangle colored
* by rectangleColor surrounded by a neighbourhood of surroundingColor
@@ -56,7 +56,11 @@ public class ComponentFinder {
public static Rectangle findColoredRectangle(Color rectangleColor, Color surroundingColor, BufferedImage screenshot) {
Rectangle r = ImageSeeker.findColoredAreaGap(screenshot, rectangleColor, surroundingColor, 0, screenshot.getHeight(), 0);
- return r;
+ if( ImageSeeker.isRectangleValid(r)){
+ return r;
+ }else{
+ return null;
+ }
}
/**
@@ -73,7 +77,11 @@ public class ComponentFinder {
public static Rectangle findColoredRectangle(Color rectangleColor, Color surroundingColor, BufferedImage screenshot, int gap) {
Rectangle r = ImageSeeker.findColoredAreaGap(screenshot, rectangleColor, surroundingColor, 0, screenshot.getHeight(), gap);
- return r;
+ if( ImageSeeker.isRectangleValid(r)){
+ return r;
+ }else{
+ return null;
+ }
}
@@ -92,16 +100,24 @@ public class ComponentFinder {
*/
public static Rectangle findWindowByIcon(BufferedImage icon, Rectangle iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot) {
Rectangle r = ImageSeeker.findExactImage(icon, screenshot);
- return windowPositionFromIconPosition(r, iconPosition, windowWidth, windowHeight);
+ if( ImageSeeker.isRectangleValid(r)){
+ return windowPositionFromIconPosition(r, iconPosition, windowWidth, windowHeight);
+ }else{
+ return null;
+ }
}
public static Rectangle findWindowByIconBlurred(BufferedImage icon, Rectangle iconPosition, int windowWidth, int windowHeight, BufferedImage screenshot, double minCorrelation) {
Rectangle r = ImageSeeker.findBlurredImage(icon, screenshot, minCorrelation);
- return windowPositionFromIconPosition(r, iconPosition, windowWidth, windowHeight);
+ if( ImageSeeker.isRectangleValid(r)){
+ return windowPositionFromIconPosition(r, iconPosition, windowWidth, windowHeight);
+ }else{
+ return null;
+ }
}
public static Rectangle windowPositionFromIconPosition(Rectangle iconAbsolute, Rectangle iconRelative, int windowWidth, int windowHeight){
- return new Rectangle( iconAbsolute.x - iconRelative.x, iconAbsolute.y - iconRelative.y,
- windowWidth, windowHeight);
+ return new Rectangle( iconAbsolute.x - iconRelative.x, iconAbsolute.y - iconRelative.y,
+ windowWidth, windowHeight);
}
}
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ImageSeeker.java b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ImageSeeker.java
index 89e8c9c..88d6604 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ImageSeeker.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ImageSeeker.java
@@ -73,12 +73,15 @@ public class ImageSeeker
result.width = marker.getWidth();
}else{
ok = true;
- }
-
+ }
}
}
- return result;
+ if(found){
+ return result;
+ }else{
+ return null;
+ }
}
public static Rectangle findBlurredImage(BufferedImage marker, BufferedImage testImage, double minCorrelation){
@@ -119,7 +122,7 @@ public class ImageSeeker
if(bestCorrelation > minCorrelation){
return new Rectangle(bestX, bestY, marker.getWidth(), marker.getHeight());
}else{
- return new Rectangle(0,0,0,0);
+ return null;
}
}