changeset 61:9e0089514225

adding methods for dealing with several versions of a pattern to ThermostatGuiTest
author Jana Fabrikova <jfabriko@redhat.com>
date Thu, 06 Jun 2013 12:15:06 +0200
parents 11d675ee56e3
children e6e06be9af7c
files ChangeLog src/org/thermostat/qa/framework/Patterns.java src/org/thermostat/qa/framework/ThermostatGuiTest.java src/org/thermostat/qa/testsuites/GuiClientDBModificationsSmokeTest.java
diffstat 4 files changed, 58 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jun 06 10:02:04 2013 +0200
+++ b/ChangeLog	Thu Jun 06 12:15:06 2013 +0200
@@ -1,3 +1,16 @@
+2013-06-06  Jana Fabrikova  <jfabriko@redhat.com>
+
+	* src/org/thermostat/qa/framework/ThermostatGuiTest.java:
+	adding methods (checkForPattern) and (findPattern),
+	where patternFileNames is a String array
+	* patterns/AA/AllAgentsDialog/close_button2:
+	* patterns/noAA/AllAgentsDialog/close_button2:
+	adding second version of the same button pattern
+	* src/org/thermostat/qa/framework/Patterns.java:
+	several String constants modified to String[] constants
+	* src/org/thermostat/qa/testsuites/GuiClientDBModificationsSmokeTest.java:
+	modification of one testcase according to above change
+
 2013-06-06  Jana Fabrikova  <jfabriko@redhat.com>
 
 	* src/org/thermostat/qa/testsuites/GuiClientSmokeTest.java:
--- a/src/org/thermostat/qa/framework/Patterns.java	Thu Jun 06 10:02:04 2013 +0200
+++ b/src/org/thermostat/qa/framework/Patterns.java	Thu Jun 06 12:15:06 2013 +0200
@@ -110,8 +110,7 @@
 
     public static class AllAgentsDialog
     {
-        public static final String CLOSE_BUTTON = "AllAgentsDialog/close_button";
-        public static final String ADDED_AGENT = "AllAgentsDialog/added_agent";
-        public static final String ADDED_AGENT_WHITE = "AllAgentsDialog/added_agent_white";
+        public static final String[] CLOSE_BUTTON = {"AllAgentsDialog/close_button", "AllAgentsDialog/close_button2"};
+        public static final String[] ADDED_AGENT = {"AllAgentsDialog/added_agent", "AllAgentsDialog/added_agent2"};
     }
 }
--- a/src/org/thermostat/qa/framework/ThermostatGuiTest.java	Thu Jun 06 10:02:04 2013 +0200
+++ b/src/org/thermostat/qa/framework/ThermostatGuiTest.java	Thu Jun 06 12:15:06 2013 +0200
@@ -156,6 +156,25 @@
     }
 
     /**
+     * Try to find some pattern on the screenshot.
+     *
+     * @return rectangle with pattern coordinates if pattern is found, null otherwise.
+     */
+    protected Rectangle findPattern(GuiRobot robot, String[] patternFileNames, String patternName) throws IOException
+    {
+        Rectangle result = null;
+        int version = 1;
+        for (String pattern : patternFileNames)
+        {
+            result = findPattern(robot, pattern, patternName + " version " + version);
+            version++;
+            if (result != null)
+                break;
+        }
+        return result;
+    }
+
+    /**
      * Check if some pattern can really be located on a screenshot.
      *
      * @return rectangle with pattern coordinates if pattern is found, null otherwise.
@@ -178,6 +197,28 @@
     }
 
     /**
+     * Check if one of the patterns can really be located on a screenshot.
+     *
+     * @return rectangle with pattern coordinates if pattern is found, null otherwise.
+     */
+    protected Rectangle checkForPattern(GuiRobot robot, String[] patternFileNames, String patternName) throws IOException
+    {
+        Rectangle rectangle = findPattern(robot, patternFileNames, patternName);
+
+        if (rectangle == null)
+        {
+            stopThermostatAndStorage(robot);
+        }
+        else
+        {
+            logInfo("checkForPattern", "pattern found at " + rectangle.toString());
+        }
+        Assert.assertNotNull(rectangle, "Error: " + patternName + " pattern can't be found!");
+        robot.highlightRectangle(rectangle);
+        return rectangle;
+    }
+
+    /**
      * Stop Thermostat storage and also Thermostat GUI client.
      */
     protected void stopThermostatAndStorage(GuiRobot robot) throws IOException
--- a/src/org/thermostat/qa/testsuites/GuiClientDBModificationsSmokeTest.java	Thu Jun 06 10:02:04 2013 +0200
+++ b/src/org/thermostat/qa/testsuites/GuiClientDBModificationsSmokeTest.java	Thu Jun 06 12:15:06 2013 +0200
@@ -88,12 +88,9 @@
         
         createScreenshot(robot, "testAddAgentAndSeeItInGUITest1");
         
-        Rectangle r1 = findPattern(robot, Patterns.AllAgentsDialog.ADDED_AGENT,
-                        "all agents dialog/added agent 1st possibility");
-        Rectangle r2 = findPattern(robot, Patterns.AllAgentsDialog.ADDED_AGENT_WHITE,
-                        "all agents dialog/added agent 2nd possibility");
+        Rectangle r1 = findPattern(robot, Patterns.AllAgentsDialog.ADDED_AGENT, "all agents dialog/added agent");
         
-        Assert.assertTrue((r1 != null || r2 != null), "all agents dialog/added agent cannot be found");
+        Assert.assertNotNull(r1, "all agents dialog/added agent cannot be found");
         
         robot.saveScreenshot("testAddAgentAndSeeItInGUITest2");