add --screenshot-after option and fix test app document access

- Add --screenshot-after CLI option to capture screenshot after playback
- Fix sandbox test app to cache document reference for onclick handlers
- Add getDocument() helper that works with RmlUi Lua proxy objects

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-19 10:36:14 +01:00
parent a583ef64a1
commit 02db0d849c
2 changed files with 62 additions and 8 deletions

View File

@@ -262,6 +262,9 @@ int main(int argc, char* argv[]) {
} else if (arg == "--playback" && i + 1 < argc) {
g_test_mode = TestMode::Playback;
g_test_input_path = argv[++i];
} else if (arg == "--screenshot-after" && i + 1 < argc) {
// Capture screenshot after playback completes (used with --playback)
g_test_output_path = argv[++i];
} else if (arg == "--screenshot" && i + 1 < argc) {
g_test_mode = TestMode::Screenshot;
g_test_output_path = argv[++i];
@@ -515,7 +518,20 @@ int main(int argc, char* argv[]) {
// Check if playback finished
if (g_action_player->IsFinished()) {
std::cout << "Playback complete" << std::endl;
// Optionally exit after playback
// Capture screenshot if --screenshot-after was specified
if (!g_test_output_path.empty()) {
int fb_width, fb_height;
glfwGetFramebufferSize(g_window, &fb_width, &fb_height);
mosis::testing::VisualCapture capture(fb_width, fb_height);
if (capture.CaptureScreenshot(g_test_output_path)) {
std::cout << "Screenshot saved to: " << g_test_output_path << std::endl;
} else {
std::cerr << "Failed to save screenshot" << std::endl;
}
}
// Exit after playback
glfwSetWindowShouldClose(g_window, GLFW_TRUE);
}
}