Skip to content

Commit

Permalink
fix: pipeline smoking
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Oct 24, 2023
1 parent ad989c5 commit 14fd423
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions source/MaaDebuggingControlUnit/Screencap/ReadIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,24 @@ bool ReadIndex::init(int swidth, int sheight)

std::optional<cv::Mat> 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;
}

Expand Down
6 changes: 5 additions & 1 deletion test/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 4 additions & 4 deletions test/source/module/PipelineSmoking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/source/module/PipelineSmoking.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include <filesystem>

bool pipeline_smoking(const std::filesystem::path& cur_dir);
bool pipeline_smoking(const std::filesystem::path& testset_dir);

0 comments on commit 14fd423

Please sign in to comment.