Mercurial > hg > ThermostatQA
view src/org/thermostat/qa/testsuites/GuiClientDBModificationsSmokeTest.java @ 150:3d06e2d323cb
refactoring of the framework+testsuites for gui tests so Xvfb+fluxbox may be used
author | Jana Fabrikova <jfabriko@redhat.com> |
---|---|
date | Tue, 01 Apr 2014 15:09:08 +0200 |
parents | bd5e2b6d3e55 |
children |
line wrap: on
line source
/* ThermostatQA - test framework for Thermostat Monitoring Tool Copyright 2013 Red Hat, Inc. This file is part of ThermostatQA ThermostatQA is distributed under the GNU General Public License, version 2 or any later version (with a special exception described below, commonly known as the "Classpath Exception"). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING. Linking ThermostatQA code with other modules is making a combined work based on ThermostatQA. Thus, the terms and conditions of the GPL cover the whole combination. As a special exception, the copyright holders of ThermostatQA give you permission to link this code with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on ThermostatQA code. If you modify ThermostatQA, you may extend this exception to your version of the software, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package org.thermostat.qa.testsuites; import java.awt.AWTException; import java.awt.Rectangle; import java.awt.event.KeyEvent; import java.io.IOException; import java.util.List; import org.thermostat.qa.annotations.TestType; import org.thermostat.qa.annotations.TestTypes; import org.thermostat.qa.framework.Assert; import org.thermostat.qa.framework.GuiRobot; import org.thermostat.qa.framework.Patterns; import org.thermostat.qa.framework.ThermostatGuiTest; /** * Class GuiClientDBModificationsSmokeTest * tests if the changes made in the database are reflected in Thermostat gui. */ @TestType(TestTypes.GUI_TEST) public class GuiClientDBModificationsSmokeTest extends ThermostatGuiTest { @Override protected void setUp() { // TODO Auto-generated method stub } @Override protected void tearDown() { // TODO Auto-generated method stub } /** * Method testAddAgentAndSeeItInGuiTest * tests if an agent added to the thermostat database is visible in * the gui in the All Agents Dialog. * * Following patterns are checked for its presence:<br /><br /> * Text antialiasing enabled:<br /> * <img src="patterns/AA/AllAgentsDialog/added_agent.png"><br /><br /> * <img src="patterns/AA/AllAgentsDialog/added_agent2.png"><br /><br /> * <img src="patterns/AA/AllAgentsDialog/close_button.png"><br /><br /> * <img src="patterns/AA/AllAgentsDialog/close_button2.png"><br /><br /> * Text antialiasing disabled:<br /> * <img src="patterns/noAA/AllAgentsDialog/added_agent.png"><br /><br /> * <img src="patterns/noAA/AllAgentsDialog/added_agent2.png"><br /><br /> * <img src="patterns/noAA/AllAgentsDialog/close_button.png"><br /><br /> * <img src="patterns/noAA/AllAgentsDialog/close_button2.png"><br /><br /> * This method uses scripts and files * <ul> * <li><a href="scripts/delete_all_agents_from_db.sh">delete_all_agents_from_db.sh</a>, * <li><a href="scripts/delete_agents_db_commands.txt">delete_agents_db_commands.txt</a> * <li><a href="scripts/find_mongo_port_and_add_agent.sh">find_mongo_port_and_add_agent.sh</a>, * <li><a href="scripts/add_agent_db_commands.txt">add_agent_db_commands.txt</a>, * <li><a href="scripts/delete_added_agent.sh">delete_added_agent.sh</a>, * <li><a href="scripts/remove_agent_db_commands.txt">remove_agent_db_commands.txt</a> * <ul> * and rewrites text file * <a href="../../../../../../scripts/mongoPortNumber.txt">mongoPortNumber.txt</a>. * * @throws IOException * @throws AWTException */ public void testAddAgentAndSeeItInGUITest() throws IOException, AWTException { // start storage GuiRobot robot = startStorageOnly(); runHelperBashScript("delete_all_agents_from_db.sh"); // find out on which port to connect to db and add new agent to db List<String> output1 = runHelperBashScript("find_mongo_port_and_add_agent.sh"); for (String s : output1) { System.out.println(s); } // start gui runThermostatGuiInANewThread(); sleep(FIVE_SEC+2000); // see agent in the list of all agents enterMainMenu(robot); robot.pressRightKey(); robot.pressRightKey(); robot.pressDownKey(); robot.pressEnterKey(); prepareScreenshot(robot, "testAddAgentAndSeeItInGUITest1"); Rectangle r1 = findPattern(robot, Patterns.AllAgentsDialog.ADDED_AGENT, "all agents dialog/added agent"); Assert.assertNotNull(r1, "all agents dialog/added agent cannot be found"); robot.saveScreenshot("testAddAgentAndSeeItInGUITest2"); // close all agents view // we need to click on "Close" button that does not have focus :-/ Rectangle rect = findPattern(robot, Patterns.AllAgentsDialog.CLOSE_BUTTON, "all agents dialog/close button"); robot.clickToRectangle(rect); // remove the added agent from db List<String> output2 = runHelperBashScript("delete_added_agent.sh"); for (String s : output2) { System.out.println(s); } stopThermostatAndStorage(robot); Assert.assertNotNull(rect, "Close button can't be found!"); robot.saveScreenshot("testAllAgentsDialogTest2"); } public static void main(String[] args) { new GuiClientDBModificationsSmokeTest().doTests(args); } }