test housekeeping

This commit is contained in:
scawful
2025-08-21 19:01:40 -04:00
parent 9cbae49cb0
commit 7f60ddcd42
5 changed files with 19 additions and 21 deletions

View File

@@ -7,7 +7,6 @@
namespace yaze { namespace yaze {
namespace test { namespace test {
using yaze::emu::MockClock;
using yaze::emu::MockMemory; using yaze::emu::MockMemory;
using yaze::emu::BackgroundMode; using yaze::emu::BackgroundMode;
using yaze::emu::PpuInterface; using yaze::emu::PpuInterface;
@@ -35,7 +34,6 @@ class MockPpu : public PpuInterface {
class PpuTest : public ::testing::Test { class PpuTest : public ::testing::Test {
protected: protected:
MockMemory mock_memory; MockMemory mock_memory;
MockClock mock_clock;
MockPpu mock_ppu; MockPpu mock_ppu;
PpuTest() {} PpuTest() {}

View File

@@ -3,7 +3,7 @@
#include <SDL.h> #include <SDL.h>
#include "app/core/controller.h" #include "app/core/controller.h"
#include "app/core/platform/renderer.h" #include "app/core/window.h"
#include "app/gui/style.h" #include "app/gui/style.h"
#include "imgui/backends/imgui_impl_sdl2.h" #include "imgui/backends/imgui_impl_sdl2.h"
#include "imgui/backends/imgui_impl_sdlrenderer2.h" #include "imgui/backends/imgui_impl_sdlrenderer2.h"
@@ -42,14 +42,11 @@ void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
}; };
} }
// TODO: Fix the window/controller management
int RunIntegrationTest() { int RunIntegrationTest() {
yaze::core::Controller controller; yaze::core::Controller controller;
if (!controller.CreateWindow().ok()) { yaze::core::Window window;
return EXIT_FAILURE; yaze::core::CreateWindow(&window);
}
if (!controller.CreateRenderer().ok()) {
return EXIT_FAILURE;
}
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
ImGui::CreateContext(); ImGui::CreateContext();

View File

@@ -7,26 +7,27 @@
namespace yaze { namespace yaze {
namespace test { namespace test {
class DungeonRoomTest : public ::testing::Test, public SharedRom { class DungeonRoomTest : public ::testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
// Skip tests on Linux for automated github builds // Skip tests on Linux for automated github builds
#if defined(__linux__) #if defined(__linux__)
GTEST_SKIP(); GTEST_SKIP();
#else #else
if (!rom()->LoadFromFile("./zelda3.sfc").ok()) { if (!rom_.LoadFromFile("./zelda3.sfc").ok()) {
GTEST_SKIP_("Failed to load test ROM"); GTEST_SKIP_("Failed to load test ROM");
} }
#endif #endif
} }
void TearDown() override {} void TearDown() override {}
Rom rom_;
}; };
TEST_F(DungeonRoomTest, SingleRoomLoadOk) { TEST_F(DungeonRoomTest, SingleRoomLoadOk) {
zelda3::Room test_room(/*room_id=*/0); zelda3::Room test_room(/*room_id=*/0, &rom_);
test_room.LoadHeader();
// Do some assertions based on the output in ZS test_room = zelda3::LoadRoomFromRom(&rom_, /*room_id=*/0);
test_room.LoadRoomFromROM();
} }
} // namespace test } // namespace test

View File

@@ -7,17 +7,18 @@
namespace yaze { namespace yaze {
namespace test { namespace test {
class MessageTest : public ::testing::Test, public SharedRom { class MessageTest : public ::testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
#if defined(__linux__) #if defined(__linux__)
GTEST_SKIP(); GTEST_SKIP();
#endif #endif
EXPECT_OK(rom()->LoadFromFile("zelda3.sfc")); EXPECT_OK(rom_.LoadFromFile("zelda3.sfc"));
dictionary_ = editor::BuildDictionaryEntries(rom()); dictionary_ = editor::BuildDictionaryEntries(&rom_);
} }
void TearDown() override {} void TearDown() override {}
Rom rom_;
editor::MessageEditor message_editor_; editor::MessageEditor message_editor_;
std::vector<editor::DictionaryEntry> dictionary_; std::vector<editor::DictionaryEntry> dictionary_;
}; };
@@ -193,7 +194,7 @@ TEST_F(MessageTest, FindMatchingElement_InvalidCommand) {
} }
TEST_F(MessageTest, BuildDictionaryEntries_CorrectSize) { TEST_F(MessageTest, BuildDictionaryEntries_CorrectSize) {
auto result = editor::BuildDictionaryEntries(rom()); auto result = editor::BuildDictionaryEntries(&rom_);
EXPECT_EQ(result.size(), editor::kNumDictionaryEntries); EXPECT_EQ(result.size(), editor::kNumDictionaryEntries);
EXPECT_FALSE(result.empty()); EXPECT_FALSE(result.empty());
} }

View File

@@ -10,7 +10,7 @@
namespace yaze { namespace yaze {
namespace test { namespace test {
class OverworldTest : public ::testing::Test, public SharedRom { class OverworldTest : public ::testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
// Skip tests on Linux for automated github builds // Skip tests on Linux for automated github builds
@@ -20,7 +20,8 @@ class OverworldTest : public ::testing::Test, public SharedRom {
} }
void TearDown() override {} void TearDown() override {}
zelda3::Overworld overworld_{rom()}; Rom rom_;
zelda3::Overworld overworld_{&rom_};
}; };
TEST_F(OverworldTest, OverworldLoadNoRomDataError) { TEST_F(OverworldTest, OverworldLoadNoRomDataError) {