From ddf5e0101d0a23181017378a36f25bc89cb72be9 Mon Sep 17 00:00:00 2001 From: Samuli Leivo Date: Fri, 29 Nov 2024 13:15:51 +0200 Subject: [PATCH] Fix lock screen detection and other fixes Modified lock screen detection to work with new lock screen. Have to press enter before searching for the eye symbol. Open and close app menu at gui init to workaround a bug (app icons not visible at first launch). Increased tolerance in image detection of window close button and changed icon theme from Papirus-Dark to Papirus to fix the failures in closing the app window. Saving journalctl from gui-vm didn't work in gui suite teardown because gui test include reboot which wipes gui-vm and the journalctl logging process in gui-vm. Now journalctl logs of gui-vm are saved only after gui apps tests. Signed-off-by: Samuli Leivo --- .../resources/gui_keywords.resource | 26 ++++++++++++------- .../test-suites/gui-tests/__init__.robot | 18 +++++++------ .../test-suites/gui-tests/gui_apps.robot | 13 ++++++++-- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/Robot-Framework/resources/gui_keywords.resource b/Robot-Framework/resources/gui_keywords.resource index 63c2e10d..8d2b0ef5 100644 --- a/Robot-Framework/resources/gui_keywords.resource +++ b/Robot-Framework/resources/gui_keywords.resource @@ -1,3 +1,4 @@ + # SPDX-FileCopyrightText: 2022-2024 Technology Innovation Institute (TII) # SPDX-License-Identifier: Apache-2.0 @@ -19,7 +20,7 @@ GUI Log in IF ${LOGGED_IN_STATUS} Log To Console Already logged in. Skipping login. ELSE - Log To Console Logging in + Log To Console Logged out state detected. Logging in. Start ydotoold Log To Console Typing username and password to login Type string and press enter ${LOGIN} @@ -36,9 +37,11 @@ GUI Log out Locate and click ./icon.png 0.95 5 Type string and press enter - [Arguments] ${string} + [Arguments] ${string}=${EMPTY} Log To Console Typing - Execute Command ydotool type ${string} sudo=True sudo_password=${PASSWORD} + IF $string != '${EMPTY}' + Execute Command ydotool type ${string} sudo=True sudo_password=${PASSWORD} + END Log To Console Pressing Enter Execute Command ydotool key -d 0 28:1 28:0 sudo=True sudo_password=${PASSWORD} @@ -46,12 +49,13 @@ Locate image on screen [Documentation] Take a screenshot. Locate given image on the screenshot. ... Return center coordinates of the image in mouse coordinate system [Arguments] ${image_to_be_searched} ${confidence}=0.999 ${iterations}=5 - ${coordinates}= Set Variable ${EMPTY} - ${pass_status}= Set Variable FAIL + ${coordinates}= Set Variable ${EMPTY} + ${pass_status}= Set Variable FAIL FOR ${i} IN RANGE ${iterations} - Log To Console Taking screenshot - Execute Command rm screenshot.png - ${rc} = Execute Command grim screenshot.png return_stdout=False return_rc=${true} + Log To Console Taking screenshot + Execute Command rm screenshot.png + ${rc}= Set Variable 1 + ${rc}= Execute Command grim screenshot.png return_stdout=False return_rc=${true} timeout=5 IF "${rc}" == "0" SSHLibrary.Get File screenshot.png screenshot.png Log To Console Locating image ${image_to_be_searched} on screenshot @@ -129,10 +133,12 @@ Get icon Check if locked [Documentation] Check if the screen lock has been activated - Log To Console Searching for view-reveal-symbolic.svg - Get icon ${ICON_THEME}/symbolic/actions view-reveal-symbolic.svg background=black Verify logout 2 IF ${LOGGED_IN_STATUS} + Start ydotoold + Type string and press enter + Log To Console Searching for view-reveal-symbolic.svg + Get icon ${ICON_THEME}/symbolic/actions view-reveal-symbolic.svg background=black ${status} ${output} Run Keyword And Ignore Error Locate image on screen ./icon.png 0.95 3 IF '${status}' == 'PASS' RETURN ${True} diff --git a/Robot-Framework/test-suites/gui-tests/__init__.robot b/Robot-Framework/test-suites/gui-tests/__init__.robot index 88e4ea9a..6eabae41 100644 --- a/Robot-Framework/test-suites/gui-tests/__init__.robot +++ b/Robot-Framework/test-suites/gui-tests/__init__.robot @@ -35,25 +35,27 @@ Common Setup Log To Console Screen lock detected GUI Unlock ELSE - Log To Console Screen lock not active + Log To Console Screen lock not active. Checking if logged in... GUI Log in END Verify login + # Open and close app launcher menu to workaround a bug (icons not visible at first launch of app menu) + Log To Console Opening and closing the app menu + Log To Console Going to click the app menu icon + Locate and click ${start_menu} 0.95 5 + Move cursor to corner + Log To Console Going to click the app menu icon + Locate and click ${start_menu} 0.95 5 + Move cursor to corner Common Teardown - Connect - IF "Lenovo" in "${DEVICE}" - Connect to netvm - Connect to VM ${GUI_VM} - END - Log journctl Close All Connections Save most common icons and paths to icons [Documentation] Save those icons by name which will be used in multiple test cases ... Śave paths to icon packs in gui-vm nix store ${icons} Execute Command find $(echo $XDG_DATA_DIRS | tr ':' ' ') -type d -name "icons" 2>/dev/null - Set Global Variable ${ICON_THEME} ${icons}/Papirus-Dark + Set Global Variable ${ICON_THEME} ${icons}/Papirus Log To Console Saving path to app icon-pack Set Global Variable ${APP_ICON_PATH} ${ICON_THEME}/128x128/apps Log To Console ${APP_ICON_PATH} diff --git a/Robot-Framework/test-suites/gui-tests/gui_apps.robot b/Robot-Framework/test-suites/gui-tests/gui_apps.robot index e7816c35..334194b3 100644 --- a/Robot-Framework/test-suites/gui-tests/gui_apps.robot +++ b/Robot-Framework/test-suites/gui-tests/gui_apps.robot @@ -9,7 +9,7 @@ Resource ../../config/variables.robot Resource ../../resources/common_keywords.resource Resource ../../resources/gui_keywords.resource Library ../../lib/gui_testing.py -Suite Teardown Close All Connections +Suite Teardown GUI Apps Teardown *** Variables *** @@ -74,7 +74,7 @@ Close app via GUI on LenovoX1 Start ydotoold Log To Console Going to click the close button of the application window - Locate and click ${close_button} 0.85 5 + Locate and click ${close_button} 0.8 5 Connect to VM ${app-vm} Check that the application is not running ${app} 5 @@ -123,3 +123,12 @@ Close app via GUI on Orin AGX [Teardown] Run Keywords Kill process @{app_pids} ... AND Move cursor to corner ... AND Stop ydotoold + +GUI Apps Teardown + Connect + IF "Lenovo" in "${DEVICE}" + Connect to netvm + Connect to VM ${GUI_VM} + END + Log journctl + Close All Connections