From 40f98d2b981b1c791fdb8941e04dff0751592a53 Mon Sep 17 00:00:00 2001 From: Samuli Leivo Date: Wed, 4 Dec 2024 11:46:52 +0200 Subject: [PATCH] Add gui tests for suspend, lock and unlock Marked power menu gui test cases with GUI preposition and removed GUI from the resource keyword names. Combined GUI Log in and GUI Log out into a single test case. Signed-off-by: Samuli Leivo --- .../resources/gui_keywords.resource | 14 ++- .../test-suites/gui-tests/__init__.robot | 4 +- .../test-suites/gui-tests/gui_apps.robot | 2 +- .../gui-tests/gui_power_options.robot | 86 +++++++++++++++---- 4 files changed, 77 insertions(+), 29 deletions(-) diff --git a/Robot-Framework/resources/gui_keywords.resource b/Robot-Framework/resources/gui_keywords.resource index 4d3b988..50eeae7 100644 --- a/Robot-Framework/resources/gui_keywords.resource +++ b/Robot-Framework/resources/gui_keywords.resource @@ -15,7 +15,7 @@ ${LOGGED_IN_STATUS} ${True} *** Keywords *** -GUI Log in +Log in via GUI [Documentation] Login and verify that task bar is available Switch Connection ${CONNECTION} Verify logout @@ -30,7 +30,7 @@ GUI Log in END Verify login -GUI Log out +Log out [Documentation] Log out and optionally verify that desktop is not available [Arguments] ${log_out_icon}=./logout.png Switch Connection ${CONNECTION} @@ -120,21 +120,19 @@ Move cursor Verify logout [Documentation] Check that dekstop is not available by running 'grim' which should have return code 1 in this case [Arguments] ${iterations}=5 - - ${status}= Set Variable ${EMPTY} - Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} + ${status}= Set Variable ${EMPTY} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} FOR ${i} IN RANGE ${iterations} ${rc}= Execute Command grim check.png return_stdout=False return_rc=${true} IF "${rc}" == "1" Set Global Variable ${LOGGED_IN_STATUS} ${False} - Connect to VM ${GUI_VM} BREAK ELSE Set Global Variable ${LOGGED_IN_STATUS} ${True} END Sleep 1 END - Connect to VM ${GUI_VM} + [Teardown] Connect to VM ${GUI_VM} Get icon [Documentation] Copy icon svg file to test agent machine. Crop and convert the svg file to png. @@ -163,7 +161,7 @@ Check if locked END RETURN ${False} -GUI Unlock +Unlock [Documentation] Unlock the screen be typing password Start ydotoold Log To Console Typing password to unlock diff --git a/Robot-Framework/test-suites/gui-tests/__init__.robot b/Robot-Framework/test-suites/gui-tests/__init__.robot index 0223d34..4883b4e 100644 --- a/Robot-Framework/test-suites/gui-tests/__init__.robot +++ b/Robot-Framework/test-suites/gui-tests/__init__.robot @@ -27,10 +27,10 @@ GUI Tests Setup ${lock} Check if locked IF ${lock} Log To Console Screen lock detected - GUI Unlock + Unlock ELSE Log To Console Screen lock not active. Checking if logged in... - GUI Log in + Log in via GUI END Verify login # Open and close app launcher menu to workaround a bug (icons not visible at first launch of app menu) diff --git a/Robot-Framework/test-suites/gui-tests/gui_apps.robot b/Robot-Framework/test-suites/gui-tests/gui_apps.robot index 3bc0f9f..abb7d47 100644 --- a/Robot-Framework/test-suites/gui-tests/gui_apps.robot +++ b/Robot-Framework/test-suites/gui-tests/gui_apps.robot @@ -3,7 +3,7 @@ *** Settings *** Documentation Testing launching applications via GUI -Force Tags gui +Force Tags gui gui-apps Resource ../../resources/ssh_keywords.resource Resource ../../config/variables.robot Resource ../../resources/common_keywords.resource diff --git a/Robot-Framework/test-suites/gui-tests/gui_power_options.robot b/Robot-Framework/test-suites/gui-tests/gui_power_options.robot index 14c7b57..9ef24a2 100644 --- a/Robot-Framework/test-suites/gui-tests/gui_power_options.robot +++ b/Robot-Framework/test-suites/gui-tests/gui_power_options.robot @@ -3,28 +3,68 @@ *** Settings *** Documentation Testing taskbar power widget options -Force Tags gui +Force Tags gui gui-power-menu Resource ../../resources/ssh_keywords.resource Resource ../../config/variables.robot Resource ../../resources/gui_keywords.resource Resource ../../resources/common_keywords.resource +Library ../../lib/SwitchbotLibrary.py ${SWITCH_TOKEN} ${SWITCH_SECRET} Suite Teardown Close All Connections *** Test Cases *** +GUI Suspend and wake up + [Documentation] Suspend the device via GUI taskbar suspend icon. + ... Check that the device is suspended. + ... Wake up by pressing the power button for 1 sec. + ... Check that the device is awake. + [Tags] lenovo-x1 SP-T208-2 + Click power menu item suspend + ${device_not_available} Run Keyword And Return Status Wait Until Keyword Succeeds 15s 2s Check If Ping Fails + IF ${device_not_available} == True + Log To Console Device suspended. + ELSE + FAIL Device failed to suspend. + END + Log To Console Waking the device up by pressing the power button for 1 sec + Press Button ${SWITCH_BOT}-ON + Check If Device Is Up + IF ${IS_AVAILABLE} == False + FAIL The device did suspend but failed to wake up + ELSE + Log To Console Device succesfully woke up after suspend + END + Log To Console Checking if the screen is in locked state after wake up + ${lock} Check if locked + IF ${lock} + Log To Console Screen lock detected + ELSE + Log To Console Screen lock not active. + FAIL Screen lock not active after wake up + END + Unlock + +GUI Lock and Unlock + [Documentation] Lock the screen via GUI taskbar lock icon and check that the screen is locked. + ... Unlock lock screen by typing the password and check that desktop is available + [Tags] lenovo-x1 SP-T208-3 SP-T208-4 lock + Click power menu item lock + ${lock} Check if locked + IF ${lock} + Log To Console Screen lock detected + ELSE + Log To Console Screen lock not active + FAIL Failed to lock the screen + END + Unlock + Verify login + GUI Reboot [Documentation] Reboot the device via GUI reboot icon. ... Check that it shuts down. Check that it turns on and boots to login screen. [Tags] lenovo-x1 SP-T208-1 - Connect to VM if not already connected gui-vm - Start ydotoold - Log To Console Going to click the power icon - Get icon ghaf-artwork power.svg crop=0 background=black - Locate and click ./icon.png 0.95 5 - Log To Console Going to click the reboot icon - Get icon ghaf-artwork restart.svg crop=0 background=black - Locate and click ./icon.png 0.95 5 + Click power menu item restart ${device_not_available} Run Keyword And Return Status Wait Until Keyword Succeeds 15s 2s Check If Ping Fails IF ${device_not_available} == True Log To Console Device is down @@ -47,17 +87,27 @@ GUI Reboot Log To Console ${LOGGED_IN_STATUS} Run Keyword If ${LOGGED_IN_STATUS} FAIL Desktop detected. Device failed to boot to login screen. -Log in +GUI Log in and log out [Documentation] Login and verify logged in state. - [Tags] lenovo-x1 SP-T149 login + ... Logout via gui icon and verify that desktop is not available. + [Tags] lenovo-x1 SP-T149 loginlogout Connect to VM if not already connected gui-vm - GUI Log in + Log in via GUI Verify login - -Log out - [Documentation] Logout via gui icon and verify that desktop is not available - [Tags] lenovo-x1 SP-T149 logout - Connect to VM if not already connected gui-vm - GUI Log out + Log out Verify logout iterations=5 Run Keyword If ${LOGGED_IN_STATUS} FAIL Logout failed. Desktop still detected after 5 sec. + + +*** Keywords *** + +Click power menu item + [Arguments] ${icon_name} + Connect to VM if not already connected gui-vm + Start ydotoold + Log To Console Going to click the power icon + Get icon ghaf-artwork power.svg crop=0 background=black + Locate and click ./icon.png 0.95 5 + Log To Console Going to click the ${icon_name} icon + Get icon ghaf-artwork ${icon_name}.svg crop=0 background=black + Locate and click ./icon.png 0.95 5 \ No newline at end of file