Skip to content

Commit

Permalink
ci: Add screenshot validation and navigation bar test
Browse files Browse the repository at this point in the history
* Introduced screenshot validation using `Remote Weston Capture Screenshot`
  and `Remote Weston Check Screenshot` keywords.
* Implemented a new test: `Test Check Navigation Bar` to verify navigation
  bar transitions using screenshots.
* Updated dependencies in `keywords_common.robot` to include `DocTest.VisualTest`.
  • Loading branch information
psaavedra committed Jan 23, 2025
1 parent 79ff756 commit 6edd386
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .ci/robot_framework/html/home-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Home Page</title>
</head>
<body>
<h1>Welcome to the Home Page</h1>
<p>Click the link below to go to the search page.</p>
<a href="search-page.html">Go to Search Page</a>
</body>
</html>
18 changes: 18 additions & 0 deletions .ci/robot_framework/html/search-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Search Page</title>
</head>
<body>
<h1>Welcome to the Search Page</h1>
<form action="/search" method="get">
<label for="query">Search:</label>
<input type="text" id="query"
name="query">
<button type="submit">Search</button>
</form>
</body>
</html>
Binary file added .ci/robot_framework/images/home-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .ci/robot_framework/images/init-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .ci/robot_framework/images/search-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion .ci/robot_framework/tests/keywords_common.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*** Variables ***
${BASELINE_IMAGES_PATH} /app/robot_framework/images/

*** Settings ***
Library Collections
Library DocTest.VisualTest
Library OperatingSystem
Library ../libs/TestUtils.py

Expand Down Expand Up @@ -31,6 +35,19 @@ Get Remote Memory Used
${value}= Evaluate float(${stdout}[0])
RETURN ${value}

Remote Weston Capture Screenshot
[Arguments] ${capture_name}

${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
SSH Command ${TEST_BOARD_IP} rm -rf wayland-screenshot-*.png && export XDG_RUNTIME_DIR=/run/user/1000 WAYLAND_DISPLAY=wayland-1 && weston-screenshooter
Run scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%{TEST_BOARD_IP}:~/wayland-screenshot-*.png ${capture_name}
Log <img src="${capture_name}" width="50%" /> html

Remote Weston Check Screenshot
[Arguments] ${image}
Remote Weston Capture Screenshot ${image}
Compare Images ${BASELINE_IMAGES_PATH}/${image} ${image} threshold=0.0050

Webdriver Remote Start
[Arguments] @{other_params}
[Timeout] 2 minutes
Expand All @@ -57,4 +74,3 @@ Webdriver Remote Stop
Close All Browsers
SSH Webdriver Remote Stop ${TEST_BOARD_IP}
SSH Force Kill ${TEST_BOARD_IP} cog

75 changes: 75 additions & 0 deletions .ci/robot_framework/tests/tests_011_navigation_bar.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
*** Variables ***
${INIT_SCREEN_IMAGE} init-screen.png
${HOME_SCREEN_IMAGE} home-screen.png
${SEARCH_SCREEN_IMAGE} search-screen.png

*** Settings ***
Test Timeout 60 seconds

Suite Setup Configure Mockup Pages

Library ../libs/TestUtils.py

Resource variables.robot
Resource keywords_common.robot

*** Keywords ***
Browser Reload
${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
SSH Command ${TEST_BOARD_IP} /root/scripts/touch-one-finger-gesture.py --duration 1 --steps 1 --delay-on-touch-up 0 470 15 470 15
Wait Until Keyword Succeeds 20x 1000ms Remote Weston Check Screenshot ${SEARCH_SCREEN_IMAGE}

Click On Search Link In Home
${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
SSH Command ${TEST_BOARD_IP} /root/scripts/touch-one-finger-gesture.py --duration 0.2 --steps 2 --delay-on-touch-up 0 90 160 90 160
Wait Until Keyword Succeeds 20x 1000ms Remote Weston Check Screenshot ${SEARCH_SCREEN_IMAGE}

Configure Mockup Pages
${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
${TEST_WEBSERVER_IP} Get Environment Variable TEST_WEBSERVER_IP
${TEST_WEBSERVER_PORT} Get Environment Variable TEST_WEBSERVER_PORT
${HOME_PAGE} Set Variable http://${TEST_WEBSERVER_IP}:${TEST_WEBSERVER_PORT}/robot_framework/html/home-page.html
${SEARCH_PAGE} Set Variable http://${TEST_WEBSERVER_IP}:${TEST_WEBSERVER_PORT}/robot_framework/html/search-page.html

SSH Command ${TEST_BOARD_IP} sed -i 's|ExecStart=/usr/bin/weston --continue-without-input --modules=systemd-notify.so|ExecStart=/usr/bin/weston --continue-without-input --modules=systemd-notify.so --debug|' /lib/systemd/system/weston.service
SSH Command ${TEST_BOARD_IP} sed -i 's|https://www.wpewebkit.org|${HOME_PAGE}|g' /usr/bin/demo-wpe-website
SSH Command ${TEST_BOARD_IP} sed -i 's|https://duckduckgo.com/|${SEARCH_PAGE}|g' /usr/bin/demo-wpe-duckduckgo
SSH Command ${TEST_BOARD_IP} systemctl daemon-reload && systemctl restart weston
Wait Until Keyword Succeeds 20x 1000ms Remote Weston Check Screenshot ${HOME_SCREEN_IMAGE}

Open Home
${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
SSH Command ${TEST_BOARD_IP} /root/scripts/touch-one-finger-gesture.py --duration 1 --steps 1 --delay-on-touch-up 0 215 15 215 15
Wait Until Keyword Succeeds 20x 1000ms Remote Weston Check Screenshot ${HOME_SCREEN_IMAGE}

Open Search
${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
SSH Command ${TEST_BOARD_IP} /root/scripts/touch-one-finger-gesture.py --duration 1 --steps 1 --delay-on-touch-up 0 275 15 275 15
Wait Until Keyword Succeeds 20x 1000ms Remote Weston Check Screenshot ${SEARCH_SCREEN_IMAGE}

Navigation Back
${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
SSH Command ${TEST_BOARD_IP} /root/scripts/touch-one-finger-gesture.py --duration 1 --steps 1 --delay-on-touch-up 0 345 15 345 15
Wait Until Keyword Succeeds 20x 1000ms Remote Weston Check Screenshot ${HOME_SCREEN_IMAGE}

Navigation Forward
${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
SSH Command ${TEST_BOARD_IP} /root/scripts/touch-one-finger-gesture.py --duration 1 --steps 1 --delay-on-touch-up 0 400 15 400 15
Wait Until Keyword Succeeds 20x 1000ms Remote Weston Check Screenshot ${SEARCH_SCREEN_IMAGE}

Terminate Browser
${TEST_BOARD_IP} Get Environment Variable TEST_BOARD_IP
SSH Command ${TEST_BOARD_IP} /root/scripts/touch-one-finger-gesture.py --duration 1 --steps 1 --delay-on-touch-up 0 595 15 595 15
Wait Until Keyword Succeeds 20x 1000ms Remote Weston Check Screenshot ${INIT_SCREEN_IMAGE}

*** Test Cases ***
Test Check Navigation Bar
Terminate Browser
Open Home
Click On Search Link In Home
Navigation Back
Navigation Forward
Browser Reload
Navigation Back
Open Search
Terminate Browser

0 comments on commit 6edd386

Please sign in to comment.