From 7f60ddcd42c2b440406e05ae46e0db01e615f0bd Mon Sep 17 00:00:00 2001 From: scawful Date: Thu, 21 Aug 2025 19:01:40 -0400 Subject: [PATCH] test housekeeping --- test/emu/ppu_test.cc | 2 -- test/test_editor.cc | 11 ++++------- test/zelda3/dungeon_room_test.cc | 13 +++++++------ test/zelda3/message_test.cc | 9 +++++---- test/zelda3/overworld_test.cc | 5 +++-- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/test/emu/ppu_test.cc b/test/emu/ppu_test.cc index a7491cbd..2e7effe6 100644 --- a/test/emu/ppu_test.cc +++ b/test/emu/ppu_test.cc @@ -7,7 +7,6 @@ namespace yaze { namespace test { -using yaze::emu::MockClock; using yaze::emu::MockMemory; using yaze::emu::BackgroundMode; using yaze::emu::PpuInterface; @@ -35,7 +34,6 @@ class MockPpu : public PpuInterface { class PpuTest : public ::testing::Test { protected: MockMemory mock_memory; - MockClock mock_clock; MockPpu mock_ppu; PpuTest() {} diff --git a/test/test_editor.cc b/test/test_editor.cc index dcac0a59..967d0de7 100644 --- a/test/test_editor.cc +++ b/test/test_editor.cc @@ -3,7 +3,7 @@ #include #include "app/core/controller.h" -#include "app/core/platform/renderer.h" +#include "app/core/window.h" #include "app/gui/style.h" #include "imgui/backends/imgui_impl_sdl2.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() { yaze::core::Controller controller; - if (!controller.CreateWindow().ok()) { - return EXIT_FAILURE; - } - if (!controller.CreateRenderer().ok()) { - return EXIT_FAILURE; - } + yaze::core::Window window; + yaze::core::CreateWindow(&window); IMGUI_CHECKVERSION(); ImGui::CreateContext(); diff --git a/test/zelda3/dungeon_room_test.cc b/test/zelda3/dungeon_room_test.cc index 29c611be..5fef31ff 100644 --- a/test/zelda3/dungeon_room_test.cc +++ b/test/zelda3/dungeon_room_test.cc @@ -7,26 +7,27 @@ namespace yaze { namespace test { -class DungeonRoomTest : public ::testing::Test, public SharedRom { +class DungeonRoomTest : public ::testing::Test { protected: void SetUp() override { // Skip tests on Linux for automated github builds #if defined(__linux__) GTEST_SKIP(); #else - if (!rom()->LoadFromFile("./zelda3.sfc").ok()) { + if (!rom_.LoadFromFile("./zelda3.sfc").ok()) { GTEST_SKIP_("Failed to load test ROM"); } #endif } void TearDown() override {} + + Rom rom_; }; TEST_F(DungeonRoomTest, SingleRoomLoadOk) { - zelda3::Room test_room(/*room_id=*/0); - test_room.LoadHeader(); - // Do some assertions based on the output in ZS - test_room.LoadRoomFromROM(); + zelda3::Room test_room(/*room_id=*/0, &rom_); + + test_room = zelda3::LoadRoomFromRom(&rom_, /*room_id=*/0); } } // namespace test diff --git a/test/zelda3/message_test.cc b/test/zelda3/message_test.cc index 594a90ee..c09d3f77 100644 --- a/test/zelda3/message_test.cc +++ b/test/zelda3/message_test.cc @@ -7,17 +7,18 @@ namespace yaze { namespace test { -class MessageTest : public ::testing::Test, public SharedRom { +class MessageTest : public ::testing::Test { protected: void SetUp() override { #if defined(__linux__) GTEST_SKIP(); #endif - EXPECT_OK(rom()->LoadFromFile("zelda3.sfc")); - dictionary_ = editor::BuildDictionaryEntries(rom()); + EXPECT_OK(rom_.LoadFromFile("zelda3.sfc")); + dictionary_ = editor::BuildDictionaryEntries(&rom_); } void TearDown() override {} + Rom rom_; editor::MessageEditor message_editor_; std::vector dictionary_; }; @@ -193,7 +194,7 @@ TEST_F(MessageTest, FindMatchingElement_InvalidCommand) { } TEST_F(MessageTest, BuildDictionaryEntries_CorrectSize) { - auto result = editor::BuildDictionaryEntries(rom()); + auto result = editor::BuildDictionaryEntries(&rom_); EXPECT_EQ(result.size(), editor::kNumDictionaryEntries); EXPECT_FALSE(result.empty()); } diff --git a/test/zelda3/overworld_test.cc b/test/zelda3/overworld_test.cc index 9283b3f0..9b6c4c40 100644 --- a/test/zelda3/overworld_test.cc +++ b/test/zelda3/overworld_test.cc @@ -10,7 +10,7 @@ namespace yaze { namespace test { -class OverworldTest : public ::testing::Test, public SharedRom { +class OverworldTest : public ::testing::Test { protected: void SetUp() override { // Skip tests on Linux for automated github builds @@ -20,7 +20,8 @@ class OverworldTest : public ::testing::Test, public SharedRom { } void TearDown() override {} - zelda3::Overworld overworld_{rom()}; + Rom rom_; + zelda3::Overworld overworld_{&rom_}; }; TEST_F(OverworldTest, OverworldLoadNoRomDataError) {