Skip to content

Commit

Permalink
Add integration test for selected IDs feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rayburgemeestre committed Nov 6, 2023
1 parent 2bd488b commit aaad0ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/system_under_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>& 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);
};
Expand All @@ -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<int64_t>& 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);
Expand All @@ -58,6 +58,9 @@ double sut::test_create_image(const std::string& image_name) {
sc.setup_server();
auto req = std::make_shared<data::frame_request>(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();
Expand Down
9 changes: 9 additions & 0 deletions test/test_integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t> selected_ids;
selected_ids.push_back(20);
REQUIRE(sc.test_create_image("unittest_014_test_frame1", selected_ids) == double(0));
}

0 comments on commit aaad0ca

Please sign in to comment.