changeset 48:9c76203e77e8

Refactoring, added method findPattern() which can be used to locate given widget on the screen for example.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Tue, 04 Jun 2013 14:13:49 +0200
parents 322af8bcf4b3
children 936a247eca8f
files ChangeLog src/org/thermostat/qa/framework/ThermostatGuiTest.java
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jun 04 11:33:52 2013 +0200
+++ b/ChangeLog	Tue Jun 04 14:13:49 2013 +0200
@@ -1,3 +1,9 @@
+2013-06-04  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/thermostat/qa/framework/ThermostatGuiTest.java:
+	Refactoring, added method findPattern() which can be used to locate
+	given widget on the screen for example.
+
 2013-06-04  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/thermostat/qa/framework/ThermostatGuiTest.java:
--- a/src/org/thermostat/qa/framework/ThermostatGuiTest.java	Tue Jun 04 11:33:52 2013 +0200
+++ b/src/org/thermostat/qa/framework/ThermostatGuiTest.java	Tue Jun 04 14:13:49 2013 +0200
@@ -139,9 +139,11 @@
     }
 
     /**
-     * Check if some pattern can really be located on a screenshot.
+     * Try to find some pattern on the screenshot.
+     *
+     * @return rectangle with pattern coordinates if pattern is found, null otherwise.
      */
-    protected Rectangle checkForPattern(GuiRobot robot, String patternFileName, String patternName) throws IOException
+    protected Rectangle findPattern(GuiRobot robot, String patternFileName, String patternName) throws IOException
     {
         logInfo("checkForPattern", "looking for pattern " + patternName);
 
@@ -150,14 +152,25 @@
         String subdir = this.useAntialiasedText ? AA_SUBDIR : NOAA_SUBDIR;
         String fullPatternName = PATTERNS_DIRECTORY + "/" + subdir + "/" + patternFileName + ".png";
 
-        Rectangle rectangle = robot.findPattern(fullPatternName);
+        return robot.findPattern(fullPatternName);
+    }
+
+    /**
+     * Check if some pattern can really be located on a screenshot.
+     *
+     * @return rectangle with pattern coordinates if pattern is found, null otherwise.
+     */
+    protected Rectangle checkForPattern(GuiRobot robot, String patternFileName, String patternName) throws IOException
+    {
+        Rectangle rectangle = findPattern(robot, patternFileName, patternName);
+
         if (rectangle == null)
         {
             stopThermostatAndStorage(robot);
         }
         else
         {
-            logInfo("checkForPattern", "    found at " + rectangle.toString());
+            logInfo("checkForPattern", "pattern found at " + rectangle.toString());
         }
         Assert.assertNotNull(rectangle, "Error: " + patternName + " pattern can't be found!");
         robot.highlightRectangle(rectangle);