Mercurial > hg > ThermostatQA
changeset 128:49c76d19d687
modifying (testOverviewTab) from GuiHostViewSmokeTest testsuite, adding resizing of the window
author | Jana Fabrikova <jfabriko@redhat.com> |
---|---|
date | Thu, 28 Nov 2013 15:29:28 +0100 |
parents | 35d1d67b575d |
children | 167a4f9adb46 |
files | ChangeLog patterns/1.1.0/AA/MainWindow/resizable.png src/org/thermostat/qa/framework/GuiRobot.java src/org/thermostat/qa/framework/Patterns.java src/org/thermostat/qa/testsuites/GuiHostViewSmokeTest.java |
diffstat | 5 files changed, 131 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Nov 28 11:29:58 2013 +0100 +++ b/ChangeLog Thu Nov 28 15:29:28 2013 +0100 @@ -1,3 +1,16 @@ +2013-11-28 Jana Fabrikova <jfabriko@redhat.com> + + * src/org/thermostat/qa/framework/GuiRobot.java: + Adding methods (resize) and (press2Keys), refactoring of (pressCtrlAndKey) + * src/org/thermostat/qa/framework/Patterns.java: + * patterns/1.1.0/AA/MainWindow/resizable.png: + Adding pattern for the right lower corner of the thermostat gui, for resizing + * src/org/thermostat/qa/testsuites/GuiHostViewSmokeTest.java: + Adding annotation TillVersion 0.18.1 to the method (testOverviewTab), + adding a modified version of this testcase (testOverviewTab2) with annotation + SinceVersion 1.1.0, which incorporates resizing of the gui, so all the contents + of the host view overview tab are visible during the testcase + 2013-11-28 Jana Fabrikova <jfabriko@redhat.com> * src/org/thermostat/qa/framework/ThermostatTest.java:
--- a/src/org/thermostat/qa/framework/GuiRobot.java Thu Nov 28 11:29:58 2013 +0100 +++ b/src/org/thermostat/qa/framework/GuiRobot.java Thu Nov 28 15:29:28 2013 +0100 @@ -179,18 +179,59 @@ robot.keyRelease(keycode); } + /** + * Method press2Keys + * presses key2 while key1 is pressed, then release both. + * Can be used e.g. to press key1=CTRL and key2=S to get CTRL+S. + * + * @param key1 + * @param key2 + */ + public void press2Keys(int key1, int key2) + { + robot.keyPress(key1); + robot.delay(KEY_PRESS_DELAY); + robot.keyPress(key2); + robot.delay(KEY_PRESS_DELAY); + robot.keyRelease(key2); + robot.delay(KEY_PRESS_DELAY); + robot.keyRelease(key1); + } + public void pressCtrlPlusKey(int keycode) { - robot.keyPress(KeyEvent.VK_CONTROL); - robot.delay(KEY_PRESS_DELAY); - robot.keyPress(keycode); - robot.delay(KEY_PRESS_DELAY); - robot.keyRelease(keycode); - robot.delay(KEY_PRESS_DELAY); - robot.keyRelease(KeyEvent.VK_CONTROL); + press2Keys(KeyEvent.VK_CONTROL, keycode); } /** + * Method resize + * gets a small rectangle where the right lower corner of the gui is, + * and number of x and y pixels by which the window should be resized. + * It uses mouse and resizes the gui window, while adding sufficient + * time delays between the mouse actions. + * + * @param from + * @param xd + * @param yd + */ + public void resize(Rectangle from, int xd, int yd) + { + int x = from.x + from.width - 4; + int y = from.y + from.height - 4; + robot.mouseMove(x, y); + robot.delay(ROBOT_DELAY); + x += 4; + y += 4; + robot.mouseMove(x, y); + robot.delay(ROBOT_DELAY); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(ROBOT_DELAY); + robot.mouseMove(x+xd, y+yd); + robot.delay(ROBOT_DELAY); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } + + /** * Add some offset to a rectangle. * * @param rect
--- a/src/org/thermostat/qa/framework/Patterns.java Thu Nov 28 11:29:58 2013 +0100 +++ b/src/org/thermostat/qa/framework/Patterns.java Thu Nov 28 15:29:28 2013 +0100 @@ -52,6 +52,7 @@ public static final String[] HOST_VIEW_ICON_ACTIVE = {"MainWindow/host_icon_blue", "MainWindow/host_icon_blue2"}; public static final String VM_VIEW_ICON = "MainWindow/vm_icon_grey"; public static final String VM_VIEW_ICON_ACTIVE = "MainWindow/vm_icon_blue"; + public static final String RESIZABLE = "MainWindow/resizable"; } public static class MainWindowMenuBar
--- a/src/org/thermostat/qa/testsuites/GuiHostViewSmokeTest.java Thu Nov 28 11:29:58 2013 +0100 +++ b/src/org/thermostat/qa/testsuites/GuiHostViewSmokeTest.java Thu Nov 28 15:29:28 2013 +0100 @@ -120,7 +120,7 @@ } - + @TillVersion("0.18.1") public void testOverviewTab() throws IOException, AWTException { GuiRobot robot = clickOnHostView(); @@ -168,6 +168,74 @@ stopThermostatParts(robot); } + @SinceVersion("1.1.0") + public void testOverviewTab2() throws IOException, AWTException + { + GuiRobot robot = clickOnHostView(); + + //click on the window somewhere + + if (this.configuration.useDummyGfxTests()) + { + robot.loadScreenshot("HostViewOverviewTab1"); + } + else + { + robot.createScreenCapture(); + robot.saveScreenshot("HostViewOverviewTab1"); + } + + //the overview tab should be active + checkForPattern(robot, Patterns.HostView.OVERVIEW_TAB_CHOSEN, "overview tab active"); + + //all other tabs are not active + checkForPattern(robot, Patterns.HostView.PROCESSOR_TAB, "processor tab"); + checkForPattern(robot, Patterns.HostView.MEMORY_TAB, "memory tab"); + checkForPattern(robot, Patterns.HostView.NUMA_TAB, "numa tab"); + + //maximize the window so all components of the Overview tab are visible + /* robot.press2Keys(KeyEvent.VK_WINDOWS, KeyEvent.VK_UP); + does not work, makes only gnome help visible */ + Rectangle from = checkForPattern(robot, Patterns.MainWindow.RESIZABLE, "resizable r l corner"); + robot.resize(from, 400, 300); + + sleep(2000); + + if (this.configuration.useDummyGfxTests()) + { + robot.loadScreenshot("HostViewProcessorTab2"); + } + else + { + robot.createScreenCapture(); + robot.saveScreenshot("HostViewProcessorTab2"); + } + + //the small texts should be visible + checkForPattern(robot, Patterns.HostView.TINY_HOST_LABEL, "tiny host label"); + checkForPattern(robot, Patterns.HostView.TINY_ID_LABEL, "tiny id label"); + + //specific patterns inside the overview tab + checkForPattern(robot, Patterns.HostViewOverviewTab.BASICS_LABEL, "basic label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.HOST_LABEL, "host label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.HW_LABEL, "hw label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.INTERFACE_LABEL, "interface label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.IPV4_ADDRESS_LABEL, "ipv4 address label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.IPV6_ADDRESS_LABEL, "ipv6 address label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.NETWORK_LABEL,"network label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.OS_KERNEL_LABEL, "os kernel label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.OS_NAME_LABEL, "os name label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.PROCESSOR_COUNT_LABEL, "processor count label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.PROCESSOR_MODEL_LABEL, "processor model label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.SW_LABEL, "sw label"); + checkForPattern(robot, Patterns.HostViewOverviewTab.TOTAL_MEMORY_LABEL, "total memory label"); + + robot.saveScreenshot("HostViewOverviewTab2"); + + //stop the gui, agent, storage + stopThermostatParts(robot); + } + private void stopThermostatParts(GuiRobot robot) throws IOException { stopGUI(robot); stopStorage();