tests: Add infrastructure for testing plugins (#1538)

This PR adds a test architecture to be able to test plugins

Main infrastructure done by @WerWolv

---------

Co-authored-by: WerWolv <werwolv98@gmail.com>
This commit is contained in:
iTrooz
2024-02-26 20:51:08 +01:00
committed by GitHub
parent 032ef0722d
commit 47362559ef
28 changed files with 205 additions and 69 deletions

View File

@@ -11,13 +11,13 @@
#include <content/providers/process_memory_provider.hpp>
#include <content/providers/base64_provider.hpp>
#include <popups/popup_notification.hpp>
#include "content/helpers/notification.hpp"
#include <hex/api/project_file_manager.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/helpers/fmt.hpp>
#include <nlohmann/json.hpp>
#include <toasts/toast_notification.hpp>
#include <wolv/utils/guards.hpp>
@@ -70,9 +70,11 @@ namespace hex::plugin::builtin {
if (newProvider == nullptr) {
// If a provider is not created, it will be overwritten when saving the project,
// so we should prevent the project from loading at all
showError(hex::format("hex.builtin.popup.error.project.load"_lang,
hex::format("hex.builtin.popup.error.project.load.create_provider"_lang, providerType)
));
ui::ToastError::open(
hex::format("hex.builtin.popup.error.project.load"_lang,
hex::format("hex.builtin.popup.error.project.load.create_provider"_lang, providerType)
)
);
success = false;
break;
}
@@ -94,29 +96,27 @@ namespace hex::plugin::builtin {
}
}
std::string warningMsg;
std::string warningMessage;
for (const auto &warning : providerWarnings){
ImHexApi::Provider::remove(warning.first);
warningMsg.append(
warningMessage.append(
hex::format("\n - {} : {}", warning.first->getName(), warning.second));
}
// If no providers were opened, display an error with
// the warnings that happened when opening them
if (ImHexApi::Provider::getProviders().size() == 0) {
showError(hex::format("hex.builtin.popup.error.project.load"_lang,
hex::format("hex.builtin.popup.error.project.load.no_providers"_lang)) + warningMsg);
if (ImHexApi::Provider::getProviders().empty()) {
ui::ToastError::open(hex::format("{}{}", "hex.builtin.popup.error.project.load"_lang, "hex.builtin.popup.error.project.load.no_providers"_lang, warningMessage));
return false;
} else {
// Else, if are warnings, still display them
if (warningMsg.empty()) {
} else {
// Else, if there are warnings, still display them
if (warningMessage.empty()) {
return true;
} else {
showWarning(
hex::format("hex.builtin.popup.error.project.load.some_providers_failed"_lang, warningMsg));
ui::ToastWarning::open(hex::format("hex.builtin.popup.error.project.load.some_providers_failed"_lang, warningMessage));
}
return success;
}
},