Skip to content

Commit

Permalink
Fix lock screen detection and other fixes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
leivos-unikie committed Dec 3, 2024
1 parent cb1f96e commit ddf5e01
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
26 changes: 16 additions & 10 deletions Robot-Framework/resources/gui_keywords.resource
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# SPDX-FileCopyrightText: 2022-2024 Technology Innovation Institute (TII)
# SPDX-License-Identifier: Apache-2.0

Expand All @@ -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}
Expand All @@ -36,22 +37,25 @@ 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}

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
Expand Down Expand Up @@ -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}
Expand Down
18 changes: 10 additions & 8 deletions Robot-Framework/test-suites/gui-tests/__init__.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
13 changes: 11 additions & 2 deletions Robot-Framework/test-suites/gui-tests/gui_apps.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ***
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit ddf5e01

Please sign in to comment.