backend-infra-engineer: Post v0.3.9-hotfix7 snapshot (build cleanup)

This commit is contained in:
scawful
2025-12-22 00:20:49 +00:00
parent 2934c82b75
commit 5c4cd57ff8
1259 changed files with 239160 additions and 43801 deletions

View File

@@ -0,0 +1,78 @@
#ifndef YAZE_TEST_FRAMEWORK_HEADLESS_EDITOR_TEST_H_
#define YAZE_TEST_FRAMEWORK_HEADLESS_EDITOR_TEST_H_
#include <memory>
#include <string>
#include "app/editor/system/panel_manager.h"
#include "gtest/gtest.h"
#include "rom/rom.h"
#include "framework/mock_renderer.h"
#include "zelda3/game_data.h"
#include "imgui.h"
namespace yaze {
namespace test {
class HeadlessEditorTest : public ::testing::Test {
protected:
void SetUp() override {
// Initialize ImGui context
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2(1920, 1080);
io.DeltaTime = 1.0f / 60.0f;
// Build font atlas to satisfy NewFrame
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
// Start a frame so we can call ImGui functions
ImGui::NewFrame();
// Initialize mock renderer
renderer_ = std::make_unique<MockRenderer>();
// Initialize panel manager
panel_manager_ = std::make_unique<editor::PanelManager>();
// Initialize game data
game_data_ = std::make_unique<zelda3::GameData>();
}
void TearDown() override {
// Cleanup
panel_manager_.reset();
renderer_.reset();
rom_.reset();
// End frame and cleanup ImGui context
ImGui::Render();
ImGui::DestroyContext();
}
void LoadRom(const std::string& path) {
rom_ = std::make_unique<Rom>();
auto status = rom_->LoadFromFile(path);
ASSERT_TRUE(status.ok()) << "Failed to load ROM: " << status.message();
}
void CreateEmptyRom(size_t size = 1024 * 1024) {
rom_ = std::make_unique<Rom>();
// Manually set up an empty ROM buffer
// This is a bit hacky as Rom class doesn't expose a way to create empty ROMs easily
// For now, we rely on tests loading actual files or using mocks if we expand this
}
std::unique_ptr<MockRenderer> renderer_;
std::unique_ptr<editor::PanelManager> panel_manager_;
std::unique_ptr<zelda3::GameData> game_data_;
std::unique_ptr<Rom> rom_;
};
} // namespace test
} // namespace yaze
#endif // YAZE_TEST_FRAMEWORK_HEADLESS_EDITOR_TEST_H_

View File

@@ -0,0 +1,38 @@
#ifndef YAZE_TEST_FRAMEWORK_MOCK_RENDERER_H_
#define YAZE_TEST_FRAMEWORK_MOCK_RENDERER_H_
#include "app/gfx/backend/irenderer.h"
#include "gmock/gmock.h"
namespace yaze {
namespace test {
class MockRenderer : public gfx::IRenderer {
public:
MOCK_METHOD(bool, Initialize, (SDL_Window* window), (override));
MOCK_METHOD(void, Shutdown, (), (override));
MOCK_METHOD(gfx::TextureHandle, CreateTexture, (int width, int height), (override));
MOCK_METHOD(gfx::TextureHandle, CreateTextureWithFormat,
(int width, int height, uint32_t format, int access), (override));
MOCK_METHOD(void, UpdateTexture, (gfx::TextureHandle texture, const gfx::Bitmap& bitmap), (override));
MOCK_METHOD(void, DestroyTexture, (gfx::TextureHandle texture), (override));
MOCK_METHOD(bool, LockTexture, (gfx::TextureHandle texture, SDL_Rect* rect, void** pixels, int* pitch), (override));
MOCK_METHOD(void, UnlockTexture, (gfx::TextureHandle texture), (override));
MOCK_METHOD(void, Clear, (), (override));
MOCK_METHOD(void, Present, (), (override));
MOCK_METHOD(void, RenderCopy, (gfx::TextureHandle texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect), (override));
MOCK_METHOD(void, SetRenderTarget, (gfx::TextureHandle texture), (override));
MOCK_METHOD(void, SetDrawColor, (SDL_Color color), (override));
MOCK_METHOD(void*, GetBackendRenderer, (), (override));
};
} // namespace test
} // namespace yaze
#endif // YAZE_TEST_FRAMEWORK_MOCK_RENDERER_H_