test(rom): add role-based ROM selection
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "app/editor/dungeon/dungeon_editor_v2.h"
|
||||
#include "rom/rom.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "test/test_utils.h"
|
||||
#include "zelda3/dungeon/room.h"
|
||||
#include "zelda3/game_data.h"
|
||||
|
||||
@@ -21,16 +22,12 @@ namespace test {
|
||||
class DungeonEditorIntegrationTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
// Use the real ROM (try multiple locations)
|
||||
TestRomManager::SkipIfRomMissing(RomRole::kVanilla,
|
||||
"DungeonEditorIntegrationTest");
|
||||
rom_ = std::make_unique<Rom>();
|
||||
auto status = rom_->LoadFromFile("assets/zelda3.sfc");
|
||||
if (!status.ok()) {
|
||||
status = rom_->LoadFromFile("build/bin/zelda3.sfc");
|
||||
}
|
||||
if (!status.ok()) {
|
||||
status = rom_->LoadFromFile("zelda3.sfc");
|
||||
}
|
||||
ASSERT_TRUE(status.ok()) << "Could not load zelda3.sfc from any location";
|
||||
const std::string rom_path = TestRomManager::GetRomPath(RomRole::kVanilla);
|
||||
auto status = rom_->LoadFromFile(rom_path);
|
||||
ASSERT_TRUE(status.ok()) << "Could not load ROM from " << rom_path;
|
||||
|
||||
// Load Zelda3-specific game data
|
||||
game_data_ = std::make_unique<zelda3::GameData>(rom_.get());
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "rom/snes.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "imgui.h"
|
||||
#include "test/test_utils.h"
|
||||
#include "zelda3/game_data.h"
|
||||
#include "zelda3/dungeon/dungeon_rom_addresses.h"
|
||||
#include "framework/headless_editor_test.h"
|
||||
@@ -26,22 +27,12 @@ class DungeonEditorV2IntegrationTest : public HeadlessEditorTest {
|
||||
void SetUp() override {
|
||||
HeadlessEditorTest::SetUp();
|
||||
|
||||
// Use the real ROM (try multiple locations)
|
||||
// We use the base class helper but need to handle the path logic
|
||||
// TODO: Make LoadRom return status or boolean to allow fallbacks
|
||||
// For now, we'll just try to load directly
|
||||
|
||||
// Try loading from standard locations
|
||||
const char* paths[] = {"assets/zelda3.sfc", "build/bin/zelda3.sfc", "zelda3.sfc"};
|
||||
bool loaded = false;
|
||||
for (const char* path : paths) {
|
||||
rom_ = std::make_unique<Rom>();
|
||||
if (rom_->LoadFromFile(path).ok()) {
|
||||
loaded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT_TRUE(loaded) << "Could not load zelda3.sfc from any location";
|
||||
TestRomManager::SkipIfRomMissing(RomRole::kVanilla,
|
||||
"DungeonEditorV2IntegrationTest");
|
||||
const std::string rom_path = TestRomManager::GetRomPath(RomRole::kVanilla);
|
||||
rom_ = std::make_unique<Rom>();
|
||||
ASSERT_TRUE(rom_->LoadFromFile(rom_path).ok())
|
||||
<< "Could not load ROM from " << rom_path;
|
||||
|
||||
// Patch ROM to ensure Room 0 and Room 1 sprite pointers are sequential
|
||||
// This fixes "Cannot determine available sprite space" error if the loaded ROM is non-standard
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app/gfx/backend/renderer_factory.h"
|
||||
@@ -12,6 +13,7 @@
|
||||
#include "app/gfx/resource/arena.h"
|
||||
#include "app/platform/window.h"
|
||||
#include "rom/rom.h"
|
||||
#include "test/test_utils.h"
|
||||
#include "zelda3/overworld/overworld.h"
|
||||
|
||||
namespace yaze {
|
||||
@@ -42,7 +44,12 @@ class Tile16EditorIntegrationTest : public ::testing::Test {
|
||||
|
||||
// Load the test ROM
|
||||
rom_ = std::make_unique<Rom>();
|
||||
auto load_result = rom_->LoadFromFile(YAZE_TEST_ROM_PATH);
|
||||
yaze::test::TestRomManager::SkipIfRomMissing(
|
||||
yaze::test::RomRole::kVanilla,
|
||||
"Tile16EditorIntegrationTest");
|
||||
const std::string rom_path =
|
||||
yaze::test::TestRomManager::GetRomPath(yaze::test::RomRole::kVanilla);
|
||||
auto load_result = rom_->LoadFromFile(rom_path);
|
||||
ASSERT_TRUE(load_result.ok())
|
||||
<< "Failed to load test ROM: " << load_result.message();
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "framework/headless_editor_test.h"
|
||||
#include "app/editor/overworld/overworld_editor.h"
|
||||
#include "rom/rom.h"
|
||||
#include "rom/snes.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "test/test_utils.h"
|
||||
#include "zelda3/game_data.h"
|
||||
|
||||
namespace yaze {
|
||||
@@ -16,16 +19,11 @@ class OverworldEditorTest : public HeadlessEditorTest {
|
||||
HeadlessEditorTest::SetUp();
|
||||
|
||||
// Load ROM
|
||||
const char* paths[] = {"assets/zelda3.sfc", "build/bin/zelda3.sfc", "zelda3.sfc"};
|
||||
bool loaded = false;
|
||||
for (const char* path : paths) {
|
||||
rom_ = std::make_unique<Rom>();
|
||||
if (rom_->LoadFromFile(path).ok()) {
|
||||
loaded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT_TRUE(loaded) << "Could not load zelda3.sfc from any location";
|
||||
TestRomManager::SkipIfRomMissing(RomRole::kVanilla, "OverworldEditorTest");
|
||||
const std::string rom_path = TestRomManager::GetRomPath(RomRole::kVanilla);
|
||||
rom_ = std::make_unique<Rom>();
|
||||
ASSERT_TRUE(rom_->LoadFromFile(rom_path).ok())
|
||||
<< "Could not load ROM from " << rom_path;
|
||||
|
||||
// Load GameData
|
||||
game_data_ = std::make_unique<zelda3::GameData>(rom_.get());
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include "app/editor/message/message_data.h"
|
||||
#include "app/editor/message/message_editor.h"
|
||||
#include "test/test_utils.h"
|
||||
#include "testing.h"
|
||||
|
||||
namespace yaze {
|
||||
@@ -12,17 +13,8 @@ namespace test {
|
||||
class MessageRomTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
// Skip tests if ROM is not available
|
||||
if (getenv("YAZE_SKIP_ROM_TESTS")) {
|
||||
GTEST_SKIP() << "ROM tests disabled";
|
||||
}
|
||||
|
||||
// Check if ROM file exists
|
||||
std::string rom_path = "zelda3.sfc";
|
||||
if (!std::filesystem::exists(rom_path)) {
|
||||
GTEST_SKIP() << "Test ROM not found: " << rom_path;
|
||||
}
|
||||
|
||||
TestRomManager::SkipIfRomMissing(RomRole::kVanilla, "MessageRomTest");
|
||||
const std::string rom_path = TestRomManager::GetRomPath(RomRole::kVanilla);
|
||||
EXPECT_OK(rom_.LoadFromFile(rom_path));
|
||||
dictionary_ = editor::BuildDictionaryEntries(&rom_);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "app/emu/emulator.h"
|
||||
#include "rom/rom.h"
|
||||
#include "test/test_utils.h"
|
||||
#include "zelda3/music/music_bank.h"
|
||||
#include "zelda3/music/song_data.h"
|
||||
#include "zelda3/music/spc_parser.h"
|
||||
@@ -25,12 +28,10 @@ class MusicIntegrationTest : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
rom_ = std::make_unique<Rom>();
|
||||
|
||||
// Check if ROM file exists
|
||||
const char* rom_path = std::getenv("YAZE_TEST_ROM_PATH");
|
||||
if (!rom_path) {
|
||||
rom_path = "zelda3.sfc";
|
||||
}
|
||||
|
||||
yaze::test::TestRomManager::SkipIfRomMissing(
|
||||
yaze::test::RomRole::kVanilla, "MusicIntegrationTest");
|
||||
const std::string rom_path =
|
||||
yaze::test::TestRomManager::GetRomPath(yaze::test::RomRole::kVanilla);
|
||||
auto status = rom_->LoadFromFile(rom_path);
|
||||
if (!status.ok()) {
|
||||
GTEST_SKIP() << "ROM file not available: " << status.message();
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "rom/rom.h"
|
||||
#include "test/test_utils.h"
|
||||
#include "zelda3/overworld/overworld.h"
|
||||
#include "zelda3/overworld/overworld_map.h"
|
||||
|
||||
@@ -15,19 +16,13 @@ namespace zelda3 {
|
||||
class SpritePositionTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
// Try to load a vanilla ROM for testing
|
||||
rom_ = std::make_unique<Rom>();
|
||||
std::string rom_path = "bin/zelda3.sfc";
|
||||
|
||||
// Check if ROM exists in build directory
|
||||
std::ifstream rom_file(rom_path);
|
||||
if (rom_file.good()) {
|
||||
ASSERT_TRUE(rom_->LoadFromFile(rom_path).ok())
|
||||
<< "Failed to load ROM from " << rom_path;
|
||||
} else {
|
||||
// Skip test if ROM not found
|
||||
GTEST_SKIP() << "ROM file not found at " << rom_path;
|
||||
}
|
||||
yaze::test::TestRomManager::SkipIfRomMissing(
|
||||
yaze::test::RomRole::kVanilla, "SpritePositionTest");
|
||||
const std::string rom_path =
|
||||
yaze::test::TestRomManager::GetRomPath(yaze::test::RomRole::kVanilla);
|
||||
ASSERT_TRUE(rom_->LoadFromFile(rom_path).ok())
|
||||
<< "Failed to load ROM from " << rom_path;
|
||||
|
||||
overworld_ = std::make_unique<Overworld>(rom_.get());
|
||||
ASSERT_TRUE(overworld_->Load(rom_.get()).ok())
|
||||
|
||||
Reference in New Issue
Block a user