From aaad0ca872133f18ae1afebc6ef07e6d674f641d Mon Sep 17 00:00:00 2001 From: Ray Burgemeestre Date: Mon, 6 Nov 2023 07:41:02 +0000 Subject: [PATCH] Add integration test for selected IDs feature --- test/system_under_test.hpp | 7 +++++-- test/test_integration.cpp | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/system_under_test.hpp b/test/system_under_test.hpp index 90b36605..9843bb38 100644 --- a/test/system_under_test.hpp +++ b/test/system_under_test.hpp @@ -17,7 +17,7 @@ class sut { public: starcry_options options; sut(); - double test_create_image(const std::string& image_name); + double test_create_image(const std::string& image_name, const std::vector& selected_ids = {}); double test_create_video(const std::string& video_name, int frames, int fps); double compare(const std::string& file1, const std::string& file2); }; @@ -43,7 +43,7 @@ sut::sut() { options.stdout_ = false; } -double sut::test_create_image(const std::string& image_name) { +double sut::test_create_image(const std::string& image_name, const std::vector& selected_ids) { std::filesystem::create_directories("test/integration/last-run"); std::filesystem::create_directories("test/integration/reference"); options.output_file = fmt::format("test/integration/last-run/{}", image_name); @@ -58,6 +58,9 @@ double sut::test_create_image(const std::string& image_name) { sc.setup_server(); auto req = std::make_shared(options.script_file, options.frame_of_interest, options.num_chunks); // req->enable_compressed_image(); // compressed image is currently only for Web UI + if (!selected_ids.empty()) { + req->set_selected_ids(selected_ids); + } req->set_output(options.output_file); req->enable_raw_image(); req->enable_raw_bitmap(); diff --git a/test/test_integration.cpp b/test/test_integration.cpp index f90a9f9a..cbc0b11b 100644 --- a/test/test_integration.cpp +++ b/test/test_integration.cpp @@ -124,3 +124,12 @@ TEST_CASE("Test scale image.") { REQUIRE(sc.test_create_image("unittest_013_scale_frame1") == double(0)); } + +TEST_CASE("Test rendering selected IDs") { + sut sc; + sc.options.script_file = "input/test.js"; + // part of the video (full = 175) + std::vector selected_ids; + selected_ids.push_back(20); + REQUIRE(sc.test_create_image("unittest_014_test_frame1", selected_ids) == double(0)); +}