Add LVGL emulator for UI regression testing with enhanced build support#109
Merged
zjwhitehead merged 6 commits intomasterfrom Apr 1, 2026
Merged
Conversation
Introduces a native (non-embedded) build that compiles the real LVGL UI code against a framebuffer-backed display driver, enabling pixel-perfect screenshot capture of every screen state. Screenshots are saved as BMP and compared against checked-in references to catch UI regressions. Key components: - test/screenshot_stubs/: Hardware stubs (Arduino, FreeRTOS, SPI, etc.) - test/test_screenshots/: Emulator display driver, test harness, CMake build - 12 test scenarios: splash (light/dark), idle, armed, cruising, charging, low battery, high altitude, high power, ESC disconnected, full battery - CI job in GitHub Actions runs tests and uploads artifacts on failure - build_and_run.sh script for local development Also fixes LV_USE_ANIMIMAGE -> LV_USE_ANIMIMG in lv_conf.h (LVGL v9 rename). https://claude.ai/code/session_01K42v6du5RXbJ4qz5H1Fsb5
Add a --local option (and EPPG_SCREENSHOT_LOCAL env) to use Ninja, ccache and a portable CPU-count for faster local builds. Introduce argument parsing to separate flags passed to the test binary, detect --update-references robustly, and add build_parallel_jobs() to choose a sensible parallelism across platforms. Configure CMake with generator and ccache launchers when available, warn when ninja/ccache are missing, and clear the build dir when switching generators so Ninja can be used. Also simplify/configure the cmake invocation and ensure arguments are forwarded to the screenshot_tests executable.
build_and_run.sh: clear the build directory when the cached CMake generator or CMAKE_BUILD_TYPE no longer matches the desired values, and choose RelWithDebInfo for local runs (Debug for CI). Introduce BUILD_TYPE and pass it to CMake so generator/build-type mismatches are handled cleanly. emulator_display.cpp: align the LVGL draw buffer to 4 bytes to satisfy LV_DRAW_BUF_ALIGN (avoids LVGL v9 assert) and call lv_timer_handler() repeatedly before lv_refr_now to drain timers/deferred layout work so the first render doesn't block.
Implement emulator_save_diff_bmp to produce a 3-panel side-by-side BMP (reference | output | diff) where differing pixels are shown in magenta and matching pixels are dimmed. Add declaration to the header and update screenshot tests to save diff images on regression and include diff paths in failure messages for easier debugging. Files changed: test/test_screenshots/emulator_display.cpp, .h, and test/test_screenshots/test_screenshots.cpp.
Split many existing screenshot tests into light and dark variants and add corresponding reference bitmaps. Renamed several reference files to *_dark/_light and added new BMP references for charging, alerts, temps, battery, armed states, ESC disconnected, high power/altitude, etc. Refactored test/test_screenshots.cpp: added new test cases for light/dark modes, alert/temperature scenarios, helpers save_and_compare and render_splash, and improved splash rendering to support dark mode. Tests now generate initial references when missing and save diff images on regression. Binary screenshot files were added/renamed under test/test_screenshots/reference/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces infrastructure for automated screenshot regression testing of the LVGL UI, enabling reliable detection of visual changes and improving test coverage. It adds a new native build environment, CMake project, CI job, and a comprehensive set of stubs to allow the UI code to be tested on a standard Linux host using GoogleTest and LVGL. The most significant changes are grouped below.
Screenshot Regression Testing Infrastructure
screenshot-testsjob to the GitHub Actions workflow, which builds and runs screenshot regression tests, uploading output artifacts on failure for easier debugging. (.github/workflows/config.yml)build_and_run.sh) for local and CI environments, supporting fast builds, generator switching, and reference screenshot updates. (test/test_screenshots/build_and_run.sh)native-screenshot) for integration with the rest of the project, specifying build flags, source filters, and dependencies for native screenshot tests. (platformio.ini)Stubs and Compatibility Layer for Native Testing
Configuration Fixes and Maintenance
LV_USE_ANIMIMAGEtoLV_USE_ANIMIMGfor compatibility with LVGL 9.x. (inc/sp140/lvgl/lv_conf.h)