backend-infra-engineer: Release v0.3.2 snapshot
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#ifndef YAZE_TEST_TEST_UTILS_H
|
||||
#define YAZE_TEST_TEST_UTILS_H
|
||||
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
@@ -10,6 +14,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "imgui_test_engine/imgui_te_context.h"
|
||||
#include "app/rom.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace test {
|
||||
|
||||
@@ -18,6 +26,8 @@ namespace test {
|
||||
*/
|
||||
class TestRomManager {
|
||||
public:
|
||||
class BoundRomTest;
|
||||
|
||||
/**
|
||||
* @brief Check if ROM testing is enabled and ROM file exists
|
||||
* @return True if ROM tests can be run
|
||||
@@ -126,6 +136,37 @@ class TestRomManager {
|
||||
}
|
||||
};
|
||||
|
||||
class TestRomManager::BoundRomTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
rom_instance_ = std::make_unique<Rom>();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
rom_instance_.reset();
|
||||
rom_loaded_ = false;
|
||||
}
|
||||
|
||||
Rom* rom() { EnsureRomLoaded(); return rom_instance_.get(); }
|
||||
const Rom* rom() const { return rom_instance_.get(); }
|
||||
|
||||
std::string GetBoundRomPath() const { return TestRomManager::GetTestRomPath(); }
|
||||
|
||||
private:
|
||||
std::unique_ptr<Rom> rom_instance_;
|
||||
bool rom_loaded_ = false;
|
||||
|
||||
void EnsureRomLoaded() {
|
||||
if (rom_loaded_) {
|
||||
return;
|
||||
}
|
||||
const std::string rom_path = TestRomManager::GetTestRomPath();
|
||||
ASSERT_TRUE(rom_instance_->LoadFromFile(rom_path).ok())
|
||||
<< "Failed to load test ROM from " << rom_path;
|
||||
rom_loaded_ = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Test macro for ROM-dependent tests
|
||||
*/
|
||||
@@ -150,6 +191,13 @@ class RomDependentTest : public ::testing::Test {
|
||||
std::vector<uint8_t> test_rom_;
|
||||
};
|
||||
|
||||
namespace gui {
|
||||
|
||||
void LoadRomInTest(ImGuiTestContext* ctx, const std::string& rom_path);
|
||||
void OpenEditorInTest(ImGuiTestContext* ctx, const std::string& editor_name);
|
||||
|
||||
} // namespace gui
|
||||
|
||||
} // namespace test
|
||||
} // namespace yaze
|
||||
|
||||
|
||||
Reference in New Issue
Block a user