Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ flags=(
--simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT'
--disable-component-update
--overscroll-history-navigation=0
--disable-features=TranslateUI
--autoplay-policy=no-user-gesture-required
--disk-cache-size=500000000
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"TranslateEnabled": false
}
1 change: 1 addition & 0 deletions testing/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COPY --from=custompios /CustomPiOS/distro_testing/tests/ /test/tests/

COPY tests/ /test/tests/
COPY hooks/ /test/hooks/
COPY fixtures/ /test/fixtures/

RUN chmod +x /test/scripts/*.sh /test/tests/*.sh; \
chmod +x /test/hooks/*.sh 2>/dev/null || true
Expand Down
35 changes: 35 additions & 0 deletions testing/fixtures/german_test_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Language" content="de">
<title>Deutsche Testseite für Übersetzung</title>
</head>
<body>
<h1>Willkommen auf unserer deutschen Testseite</h1>
<p>
Dies ist eine ausführliche Testseite auf Deutsch, die dazu dient, den
Übersetzungsdialog in Chromium zuverlässig auszulösen.
</p>
<p>
Bitte beachten Sie, dass diese Seite ausschließlich zu Testzwecken
erstellt wurde. Der folgende Text enthält zusätzliche deutsche Sätze,
damit die Spracherkennung des Browsers eindeutig Deutsch erkennt.
</p>
<h2>Weitere Informationen</h2>
<p>
Guten Tag! Wie geht es Ihnen heute? Wir hoffen, dass Sie einen schönen
Tag haben. Dieser Absatz beschreibt allgemeine Informationen auf
Deutsch, ohne besondere Bedeutung für den eigentlichen Test.
</p>
<p>
Die Stadt Berlin ist die Hauptstadt von Deutschland. Viele Menschen
sprechen dort Deutsch und besuchen Museen, Parks und historische
Gebäude. Auch in anderen Regionen wird Deutsch gesprochen.
</p>
<p>
Vielen Dank für Ihre Aufmerksamkeit. Wir wünschen Ihnen alles Gute
und hoffen, dass der Übersetzungsdialog nun erscheint.
</p>
</body>
</html>
5 changes: 5 additions & 0 deletions testing/hooks/prepare-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ touch /etc/gpu_enabled
# Pre-create the lightdm conf directory so the hook can write to it.
mkdir-p /etc/lightdm/lightdm.conf.d

# The shared QEMU prep bypasses userconf-pi, so seed the tty1 autologin
# side effect that `raspi-config do_boot_behaviour B4` would normally create.
mkdir-p /etc/systemd/system/getty@tty1.service.d
write /etc/systemd/system/getty@tty1.service.d/autologin.conf "[Service]\nExecStart=\nExecStart=-/sbin/agetty --autologin pi --noclear %I \$TERM\n"

umount /
GFEOF

Expand Down
135 changes: 135 additions & 0 deletions testing/tests/test_translation_disabled.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/bin/bash
set -e

export E2E_SSH_HOST="${1:-localhost}"
export E2E_SSH_PORT="${2:-2222}"
ARTIFACTS_DIR="${3:-}"
source /test/scripts/ssh-helpers.sh

GERMAN_PAGE_URL="http://localhost/german_test.html"
FIXTURE="/test/fixtures/german_test_page.html"
SCREENSHOT_NAME="translation_disabled.png"
FULLPAGEOS_TXT="/boot/firmware/fullpageos.txt"

echo "Test: Chromium translate dialog on German page (visual evidence)"

if [ ! -f "$FIXTURE" ]; then
echo " FAIL: German test fixture not found at $FIXTURE"
exit 1
fi

echo " Uploading German test page to lighttpd document root..."
scp_cmd "$FIXTURE" "pi@${E2E_SSH_HOST}:/tmp/german_test_page.html"
ssh_cmd "sudo cp /tmp/german_test_page.html /var/www/html/german_test.html"
ssh_cmd "sudo chown www-data:www-data /var/www/html/german_test.html 2>/dev/null || true"

HTTP_CODE=$(ssh_cmd "curl -s -o /dev/null -w '%{http_code}' '$GERMAN_PAGE_URL' || true" 2>/dev/null)
if [ "$HTTP_CODE" != "200" ]; then
echo " FAIL: German test page returned HTTP $HTTP_CODE"
exit 1
fi
echo " German test page served (HTTP 200)"

# Running a second windowed Chromium on a fresh Xvfb display proved unreliable in
# QEMU (the network service crashes and pages never load). Instead we drive the
# already-working production kiosk on :0: point it at the German page, let the
# run_onepageos respawn loop reload it, screenshot, then restore the dashboard.
# This is also the environment where the translate bug actually manifests.
echo " Saving current kiosk URL..."
ORIG_URL=$(ssh_cmd "cat ${FULLPAGEOS_TXT} 2>/dev/null || true" 2>/dev/null || true)
echo " Current URL: ${ORIG_URL:-<empty>}"

restore_url() {
echo " Restoring original kiosk URL..."
if [ -n "$ORIG_URL" ]; then
ssh_cmd "printf '%s\n' \"$ORIG_URL\" | sudo tee ${FULLPAGEOS_TXT} >/dev/null" 2>/dev/null || true
fi
ssh_cmd "killall chromium 2>/dev/null || true; exit 0" || true
}

echo " Pointing kiosk at German test page..."
ssh_cmd "printf '%s\n' '${GERMAN_PAGE_URL}' | sudo tee ${FULLPAGEOS_TXT} >/dev/null"

echo " Reloading kiosk (run_onepageos will relaunch with new URL)..."
ssh_cmd "killall chromium 2>/dev/null || true; exit 0" || true

echo " Waiting for kiosk to load the German page on :0..."
PAGE_LOADED=0
for i in $(seq 1 60); do
RENDERED_URL=$(ssh_cmd "cat ${FULLPAGEOS_TXT} 2>/dev/null || true" 2>/dev/null || true)
KIOSK=$(ssh_cmd "pgrep -f 'chromium.*--app=.*german_test' 2>/dev/null || true" 2>/dev/null || true)
if [ -n "$KIOSK" ]; then
PAGE_LOADED=1
echo " Kiosk relaunched on German page (pid: $(echo "$KIOSK" | head -1))"
break
fi
sleep 2
done

if [ "$PAGE_LOADED" -eq 0 ]; then
echo " WARNING: Did not confirm kiosk relaunch on German page"
ssh_cmd "pgrep -a chromium || true" 2>/dev/null || true
fi

echo " Waiting for the German page to actually paint on :0..."
TITLE_SEEN=0
for i in $(seq 1 45); do
TITLES=$(ssh_cmd "DISPLAY=:0 xdotool search --name . getwindowname 2>/dev/null || true" 2>/dev/null || true)
if echo "$TITLES" | grep -qi "Deutsche\|Testseite\|Übersetzung\|german_test"; then
TITLE_SEEN=1
echo " German page window visible (titles: $(echo "$TITLES" | tr '\n' ' '))"
break
fi
sleep 1
done
if [ "$TITLE_SEEN" -eq 0 ]; then
echo " WARNING: German page title not detected on :0 (titles: $(ssh_cmd "DISPLAY=:0 xdotool search --name . getwindowname 2>/dev/null || true" 2>/dev/null | tr '\n' ' '))"
fi

echo " Waiting for any translate UI to settle..."
sleep 12

CAPTURED=0
if [ -n "$ARTIFACTS_DIR" ]; then
mkdir -p "$ARTIFACTS_DIR"
echo " Capturing screenshot to $ARTIFACTS_DIR/$SCREENSHOT_NAME ..."
DISPLAY_SCREENSHOT=false
ssh_cmd "DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 xwd -root -out /tmp/translate-test.xwd" 2>/dev/null && DISPLAY_SCREENSHOT=true
if [ "$DISPLAY_SCREENSHOT" = false ]; then
ssh_cmd "DISPLAY=:0 xwd -root -out /tmp/translate-test.xwd" 2>/dev/null && DISPLAY_SCREENSHOT=true
fi

if [ "$DISPLAY_SCREENSHOT" = true ] && ssh_cmd "test -s /tmp/translate-test.xwd" 2>/dev/null; then
if ssh_cmd "convert /tmp/translate-test.xwd /tmp/translate-test.png" 2>/dev/null && \
ssh_cmd "test -s /tmp/translate-test.png" 2>/dev/null; then
scp_cmd "pi@${E2E_SSH_HOST}:/tmp/translate-test.png" "$ARTIFACTS_DIR/$SCREENSHOT_NAME"
CAPTURED=1
echo " Screenshot saved (converted on guest): $ARTIFACTS_DIR/$SCREENSHOT_NAME"
else
scp_cmd "pi@${E2E_SSH_HOST}:/tmp/translate-test.xwd" "$ARTIFACTS_DIR/translate-test.xwd"
if command -v convert >/dev/null 2>&1 && \
convert "$ARTIFACTS_DIR/translate-test.xwd" "$ARTIFACTS_DIR/$SCREENSHOT_NAME" 2>/dev/null; then
rm -f "$ARTIFACTS_DIR/translate-test.xwd"
CAPTURED=1
echo " Screenshot saved (converted on host): $ARTIFACTS_DIR/$SCREENSHOT_NAME"
else
echo " WARNING: Could not convert XWD to PNG; keeping raw XWD"
CAPTURED=1
fi
fi
else
echo " WARNING: xwd capture failed; screenshot artifact may be missing"
fi
else
echo " WARNING: No ARTIFACTS_DIR set; skipping screenshot capture"
fi

restore_url

if [ "$CAPTURED" -eq 0 ] && [ -n "$ARTIFACTS_DIR" ]; then
echo " FAIL: No screenshot evidence captured"
exit 1
fi

echo " PASS: Translation test completed (see $SCREENSHOT_NAME for visual evidence)"
exit 0
Loading