Files
Anthias/bin/test_webview_cpp.sh
Viktor Petersson 3091fec349 feat(api,viewer): viewer REST shim + rename AnthiasWebview → AnthiasViewer (#2907)
* feat(api,viewer): viewer REST shim + rename AnthiasWebview → AnthiasViewer

- Add GET /api/v2/viewer/playlist returning server-evaluated active
  assets, next deadline, and ``now``; gated by internal token.
- Add GET /api/v2/viewer/settings exposing only the viewer-relevant
  settings subset (shuffle/show_splash/screen_rotation/audio_output/
  debug_logging) so the internal-auth path doesn't surface operator
  credentials.
- Rename the C++ binary AnthiasWebview → AnthiasViewer (.pro file,
  Dockerfile copies, sh.Command spawn, test runner) and the D-Bus
  service anthias.webview → anthias.viewer (atomic because both
  endpoints ship in the same image).
- Migrate runtime state paths /data/.local/share/AnthiasWebview and
  /data/.cache/AnthiasWebview to AnthiasViewer with a one-shot
  symlink so existing devices keep QtWebEngine cookies / local-
  storage across the upgrade.
- Source tree src/anthias_webview/ stays put; the directory rename
  is deferred to Phase 5 when the Python viewer package is deleted.

First step of GH #2906; sets up the contract the C++ viewer will
consume in Phase 3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(api,viewer): address review feedback on viewer REST shim

- ViewerPlaylistViewV2 now reloads anthias.conf on read so an
  in-flight settings PATCH doesn't shuffle off a stale cached
  value — mirrors what ViewerSettingsViewV2 already did.
- AssetSerializerV2.get_is_active accepts ``now`` via context so
  ViewerPlaylistViewV2 can render the ``is_active`` field against
  the same instant the filter used; closes the millisecond race
  where a row right on a window boundary could be returned in
  ``assets`` while its ``is_active`` re-evaluated to False.
- Simplify the windowed-deadline-cap test assertion: parse the
  ISO timestamp and compare datetimes directly instead of the
  awkward dual-format string-prefix check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(tests): use https in viewer API fixture URI

Silences SonarCloud python:S5332 on tests/test_viewer_api.py.
The fixture URIs are never fetched — they just satisfy the
``uri`` field on Asset.objects.create — but matching the existing
test_recheck_endpoint.py convention keeps the linter quiet without
sprinkling NOSONAR comments through test data.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(viewer): drop QtWebEngine state symlink-migration on rename

Validated on real hardware: a fresh AnthiasViewer cache rebuilds
itself on the next page load, so the bookkeeping to preserve
cookies / local-storage across the AnthiasWebview → AnthiasViewer
rename isn't worth the code. Upgraded devices just get fresh state
dirs alongside the (now-orphaned) old AnthiasWebview tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 13:31:01 +02:00

39 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build and run AnthiasViewer's QtTest unit tests.
#
# Requires Qt 6 (qt6-base-dev, qt6-multimedia-dev). The viewer
# Docker image already ships those for the per-board builder stage
# — running this inside that container is the canonical
# environment.
#
# Usage: bin/test_webview_cpp.sh
#
# The tests run under ``QT_QPA_PLATFORM=offscreen`` so no real
# display server is needed; QtMultimedia's playback pipeline won't
# fully initialise (no rendering target) but the API surface plus
# the QGraphicsVideoItem rotation transform are testable that way.
# Decoder engagement + drop counts are exercised on real devices
# via the BBB test bed. CI integration is a follow-up.
set -euo pipefail
cd "$(dirname "$0")/.."
WEBVIEW_DIR="src/anthias_webview"
BUILD_DIR="${WEBVIEW_DIR}/tests/build"
mkdir -p "${BUILD_DIR}"
pushd "${BUILD_DIR}" >/dev/null
qmake6 ../tests.pro
make -j"$(nproc)"
# QTEST_MAIN's generated binary exits non-zero on any test failure.
# ``QT_QPA_PLATFORM=offscreen`` skips connecting to a real display
# server / framebuffer — the tests don't render, they exercise
# the QMediaPlayer / QGraphicsVideoItem API surface plus the
# rotation transform.
QT_QPA_PLATFORM=offscreen ./AnthiasViewerTests
popd >/dev/null