diff --git a/source/MaaDebuggingControlUnit/Screencap/ReadIndex.cpp b/source/MaaDebuggingControlUnit/Screencap/ReadIndex.cpp index 60e9edb7f..3231bb130 100644 --- a/source/MaaDebuggingControlUnit/Screencap/ReadIndex.cpp +++ b/source/MaaDebuggingControlUnit/Screencap/ReadIndex.cpp @@ -55,22 +55,24 @@ bool ReadIndex::init(int swidth, int sheight) std::optional ReadIndex::screencap() { + auto start_time = std::chrono::steady_clock::now(); + if (index_ >= filepaths_.size()) { LogInfo << "index_ >= filepaths_.size(), reset index_ to 0"; index_ = 0; } auto image_path = filepaths_[index_++]; - LogInfo << VAR(image_path); - - LogInfo << "read image" << VAR(image_path); + LogInfo << "Read image" << VAR(image_path); auto image = imread(image_path); if (image.empty()) { - LogError << "read image failed" << VAR(image_path); + LogError << "Read image failed" << VAR(image_path); return std::nullopt; } cv::resize(image, image, cv::Size(swidth_, sheight_)); + std::this_thread::sleep_until(start_time + std::chrono::milliseconds(100)); + return image; } diff --git a/test/source/main.cpp b/test/source/main.cpp index f83c9c3a4..957e31276 100644 --- a/test/source/main.cpp +++ b/test/source/main.cpp @@ -7,13 +7,17 @@ int main([[maybe_unused]] int argc, char** argv) { auto cur_dir = std::filesystem::path(argv[0]).parent_path(); + auto testset_dir = cur_dir.parent_path() / "test"; + if (argc == 2) { + testset_dir = argv[1]; + } std::string logging_dir = (cur_dir / "debug").string(); MaaSetGlobalOption(MaaGlobalOption_Logging, (void*)logging_dir.c_str(), logging_dir.size()); bool on = true; MaaSetGlobalOption(MaaGlobalOption_DebugMode, &on, sizeof(on)); - bool ret = pipeline_smoking(cur_dir); + bool ret = pipeline_smoking(testset_dir); return ret ? 0 : -1; } diff --git a/test/source/module/PipelineSmoking.cpp b/test/source/module/PipelineSmoking.cpp index aecd87d40..da1d1afe5 100644 --- a/test/source/module/PipelineSmoking.cpp +++ b/test/source/module/PipelineSmoking.cpp @@ -6,10 +6,10 @@ #include "MaaFramework/MaaAPI.h" -bool pipeline_smoking(const std::filesystem::path& cur_dir) +bool pipeline_smoking(const std::filesystem::path& testset_dir) { - auto testing_path = cur_dir.parent_path() / "test" / "PipelineSmoking"; - auto result_path = cur_dir / "debug"; + auto testing_path = testset_dir / "PipelineSmoking"; + auto result_path = testset_dir / "debug"; json::value debug_config = { { "device_info", json::object { { "uuid", testing_path.string() }, { "screen_width", 1280 }, @@ -25,7 +25,7 @@ bool pipeline_smoking(const std::filesystem::path& cur_dir) auto ctrl_id = MaaControllerPostConnection(controller_handle); auto resource_handle = MaaResourceCreate(nullptr, nullptr); - auto resource_dir = cur_dir.parent_path() / "test" / "PipelineSmoking" / "resource"; + auto resource_dir = testset_dir / "PipelineSmoking" / "resource"; auto res_id = MaaResourcePostPath(resource_handle, resource_dir.string().c_str()); MaaControllerWait(controller_handle, ctrl_id); diff --git a/test/source/module/PipelineSmoking.h b/test/source/module/PipelineSmoking.h index 5a40872cf..f97c22277 100644 --- a/test/source/module/PipelineSmoking.h +++ b/test/source/module/PipelineSmoking.h @@ -1,3 +1,3 @@ #include -bool pipeline_smoking(const std::filesystem::path& cur_dir); +bool pipeline_smoking(const std::filesystem::path& testset_dir);