Mercurial > hg > ThermostatQA
changeset 53:c2965d2bbb2a
GuiRobot modification of findPattern
author | Jana Fabrikova <jfabriko@redhat.com> |
---|---|
date | Wed, 05 Jun 2013 13:14:51 +0200 |
parents | 9ff89dc73864 |
children | 7a3350258b2f |
files | ChangeLog src/org/thermostat/qa/framework/GuiRobot.java |
diffstat | 2 files changed, 49 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jun 05 12:59:56 2013 +0200 +++ b/ChangeLog Wed Jun 05 13:14:51 2013 +0200 @@ -1,4 +1,9 @@ -2012-06-05 Jana Fabrikova <jfabriko@redhta.com> +2013-06-05 Jana Fabrikova <jfabriko@redhat.com> + + * src/org/thermostat/qa/framework/GuiRobot.java: + modifying methods (findPattern) and (findBlurredPattern) + +2013-06-05 Jana Fabrikova <jfabriko@redhat.com> * src/org/thermostat/qa/framework/ThermostatGuiTest.java: modifying one line - initialization of variable useAntialiasedText
--- a/src/org/thermostat/qa/framework/GuiRobot.java Wed Jun 05 12:59:56 2013 +0200 +++ b/src/org/thermostat/qa/framework/GuiRobot.java Wed Jun 05 13:14:51 2013 +0200 @@ -266,7 +266,42 @@ } } - private static Rectangle findPattern(BufferedImage marker, BufferedImage testImage) + public static Rectangle findPattern(BufferedImage marker, BufferedImage screen){ + Rectangle actionArea = new Rectangle(0,0,screen.getWidth(),screen.getHeight()); + Rectangle result = new Rectangle(0,0,0,0); + boolean found = false; + boolean ok = true; + + for(int x = actionArea.x; (x < (actionArea.x + actionArea.width - marker.getWidth()) ) && !found; x++){ + for(int y= actionArea.y; (y < (actionArea.y + actionArea.height - marker.getHeight()) ) && !found; y++){ + + for(int mx = 0; (mx < marker.getWidth()) && ok; mx++){ + for(int my = 0; (my < marker.getHeight()) && ok; my++){ + if(marker.getRGB(mx, my) != screen.getRGB(x+mx,y+my)){ + ok = false; + } + } + } + if( ok ){ + found = true; + result.x = x; + result.y = y; + result.height = marker.getHeight(); + result.width = marker.getWidth(); + }else{ + ok = true; + } + } + } + + if(found){ + return result; + }else{ + return null; + } + } + + private static Rectangle findBlurredPattern(BufferedImage marker, BufferedImage testImage) { int maxX = testImage.getWidth() - marker.getWidth() - 1; int maxY = testImage.getHeight() - marker.getHeight() - 1; @@ -287,11 +322,12 @@ int bestX = -1; int bestY = -1; double bestCorrelation = -1; + boolean foundExact = false; - for (int yoffset = 0; yoffset < maxY; yoffset++ ) + for (int yoffset = 0; (yoffset < maxY) && !foundExact; yoffset++ ) { //System.out.println("Processing line: " + yoffset + " of " + (maxY - 1)); - for (int xoffset = 0; xoffset < maxX; xoffset++) + for (int xoffset = 0; (xoffset < maxX) && !foundExact; xoffset++) { double correlation = computeCorrelation(markerMaxX, markerMaxY, testImageArray, markerImageArray, yoffset, xoffset); if (correlation > bestCorrelation) @@ -299,6 +335,10 @@ bestCorrelation = correlation; bestX = xoffset; bestY = yoffset; + if (correlation == autocorrelation) + { + foundExact = true; + } } } }