diff options
author | Jiri Vanek <[email protected]> | 2013-04-29 16:24:37 +0200 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-04-29 16:24:37 +0200 |
commit | 3837fdf272a4fb68962b548cad3af7ed44ac3339 (patch) | |
tree | a09bb7501e05306597f8bbe1d73fb5a18130266b /tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java | |
parent | 1ee0e5d164e1a122b5d55e1a80406d5575e1d725 (diff) |
Modularised initialization of AwtHelper and improoved performance of ImageSeeker. Added masking to ImageSeeker
Diffstat (limited to 'tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java')
-rw-r--r-- | tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java index 8a888d4..faced3a 100644 --- a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java +++ b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java @@ -354,24 +354,42 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements int count = 0; appletFound = false; while ((count < K) && !appletFound) { - robot.delay(defaultWaitForApplet); - screenshot = robot.createScreenCapture( new Rectangle( Toolkit.getDefaultToolkit().getScreenSize() ) ); - screenshotTaken = true; - actionArea = ComponentFinder.findWindowByIcon(icon, iconPosition, width, height, screenshot); - if (ImageSeeker.isRectangleValid(actionArea)) { - appletFound = true; - } - count++; + robot.delay(defaultWaitForApplet); + try { + screenshot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); + initialiseOnScreenshot(icon, iconPosition, width, height, screenshot); + } catch (ComponentNotFoundException ex) { + //keeping silent and try more-times + } + count++; } if (ImageSeeker.isRectangleValid(actionArea)) { appletFound = true; } else { - throw new ComponentNotFoundException("Applet not found in the screenshot!"); + throw new ComponentNotFoundException("Object not found in the screenshot!"); } } + public void initialiseOnScreenshot(BufferedImage icon, Point iconPosition, int width, int height, BufferedImage screenshot) throws ComponentNotFoundException { + Rectangle r = ComponentFinder.findWindowByIcon(icon, iconPosition, width, height, screenshot); + initialiseOnScreenshotAndArea(screenshot, r); + + } + + public void initialiseOnScreenshotAndArea(BufferedImage screenshot, Rectangle actionArea) throws ComponentNotFoundException { + this.screenshot = screenshot; + screenshotTaken = true; + this.actionArea = actionArea; + if (ImageSeeker.isRectangleValid(actionArea)) { + appletFound = true; + } else { + throw new ComponentNotFoundException("set invalid area!"); + } + } + + /** * auxiliary method writeAppletScreen for writing Buffered image into png * |