yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::test::MockRom Class Reference

Enhanced ROM for testing that behaves like a real ROM but with test data. More...

#include <mock_rom.h>

Inheritance diagram for yaze::test::MockRom:
Collaboration diagram for yaze::test::MockRom:

Public Member Functions

 MockRom ()=default
 
 MOCK_METHOD (absl::Status, WriteHelper,(const WriteAction &),(override))
 
absl::Status SetTestData (const std::vector< uint8_t > &data)
 Load test data into the ROM.
 
void SetObjectData (int object_id, const std::vector< uint8_t > &data)
 Store object-specific test data for validation.
 
void SetRoomData (int room_id, const std::vector< uint8_t > &data)
 Store room-specific test data for validation.
 
bool HasObjectData (int object_id) const
 Check if object data has been set for testing.
 
bool HasRoomData (int room_id) const
 Check if room data has been set for testing.
 
bool IsValid () const
 Check if the mock ROM is valid for testing.
 
const std::vector< uint8_t > & GetObjectData (int object_id) const
 Get the stored object data for validation.
 
const std::vector< uint8_t > & GetRoomData (int room_id) const
 Get the stored room data for validation.
 
- Public Member Functions inherited from yaze::Rom
absl::Status LoadFromFile (const std::string &filename, bool z3_load=true)
 
absl::Status LoadFromFile (const std::string &filename, const RomLoadOptions &options)
 
absl::Status LoadFromData (const std::vector< uint8_t > &data, bool z3_load=true)
 
absl::Status LoadFromData (const std::vector< uint8_t > &data, const RomLoadOptions &options)
 
absl::Status LoadZelda3 ()
 
absl::Status LoadZelda3 (const RomLoadOptions &options)
 
absl::Status LoadGfxGroups ()
 
absl::Status InitializeForTesting ()
 
absl::Status SaveGfxGroups ()
 
absl::Status SaveToFile (const SaveSettings &settings)
 
absl::Status SavePalette (int index, const std::string &group_name, gfx::SnesPalette &palette)
 
absl::Status SaveAllPalettes ()
 
void Expand (int size)
 
void Close ()
 
absl::StatusOr< uint8_tReadByte (int offset)
 
absl::StatusOr< uint16_tReadWord (int offset)
 
absl::StatusOr< uint32_tReadLong (int offset)
 
absl::StatusOr< std::vector< uint8_t > > ReadByteVector (uint32_t offset, uint32_t length) const
 
absl::StatusOr< gfx::Tile16ReadTile16 (uint32_t tile16_id)
 
absl::Status WriteTile16 (int tile16_id, const gfx::Tile16 &tile)
 
absl::Status WriteByte (int addr, uint8_t value)
 
absl::Status WriteWord (int addr, uint16_t value)
 
absl::Status WriteShort (int addr, uint16_t value)
 
absl::Status WriteLong (uint32_t addr, uint32_t value)
 
absl::Status WriteVector (int addr, std::vector< uint8_t > data)
 
absl::Status WriteColor (uint32_t address, const gfx::SnesColor &color)
 
template<typename... Args>
absl::Status WriteTransaction (Args... args)
 
template<typename T , typename... Args>
absl::Status ReadTransaction (T &var, int address, Args &&... args)
 
virtual absl::Status WriteHelper (const WriteAction &action)
 
template<typename T >
absl::Status ReadHelper (T &var, int address)
 
uint8_toperator[] (unsigned long i)
 
bool is_loaded () const
 
bool dirty () const
 
void set_dirty (bool dirty)
 
void ClearDirty ()
 
auto title () const
 
auto size () const
 
auto data () const
 
auto mutable_data ()
 
auto begin ()
 
auto end ()
 
auto vector () const
 
auto filename () const
 
auto set_filename (std::string_view name)
 
auto short_name () const
 
auto graphics_buffer () const
 
auto mutable_graphics_buffer ()
 
auto palette_group () const
 
auto mutable_palette_group ()
 
auto dungeon_palette (int i)
 
auto mutable_dungeon_palette (int i)
 
core::ResourceLabelManagerresource_label ()
 
zelda3_version_pointers version_constants () const
 

Private Attributes

bool test_data_loaded_ = false
 
std::map< int, std::vector< uint8_t > > object_data_
 
std::map< int, std::vector< uint8_t > > room_data_
 

Additional Inherited Members

- Public Attributes inherited from yaze::Rom
std::array< std::array< uint8_t, 8 >, kNumMainBlocksetsmain_blockset_ids
 
std::array< std::array< uint8_t, 4 >, kNumRoomBlocksetsroom_blockset_ids
 
std::array< std::array< uint8_t, 4 >, kNumSpritesetsspriteset_ids
 
std::array< std::array< uint8_t, 4 >, kNumPalettesetspaletteset_ids
 

Detailed Description

Enhanced ROM for testing that behaves like a real ROM but with test data.

This class extends Rom to provide testing utilities while maintaining all the real ROM functionality. Instead of mocking methods, it loads real test data into the ROM.

Definition at line 21 of file mock_rom.h.

Constructor & Destructor Documentation

◆ MockRom()

yaze::test::MockRom::MockRom ( )
default

Member Function Documentation

◆ MOCK_METHOD()

yaze::test::MockRom::MOCK_METHOD ( absl::Status  ,
WriteHelper  ,
(const WriteAction &)  ,
(override  
)

◆ SetTestData()

absl::Status yaze::test::MockRom::SetTestData ( const std::vector< uint8_t > &  data)
inline

Load test data into the ROM.

Parameters
dataThe test ROM data to load
Returns
Status of the operation

Definition at line 33 of file mock_rom.h.

References yaze::Rom::data(), yaze::Rom::LoadFromData(), and test_data_loaded_.

Referenced by yaze::cli::resources::CommandContextTest::SetUp().

Here is the call graph for this function:

◆ SetObjectData()

void yaze::test::MockRom::SetObjectData ( int  object_id,
const std::vector< uint8_t > &  data 
)
inline

Store object-specific test data for validation.

Definition at line 44 of file mock_rom.h.

References yaze::Rom::data(), and object_data_.

Here is the call graph for this function:

◆ SetRoomData()

void yaze::test::MockRom::SetRoomData ( int  room_id,
const std::vector< uint8_t > &  data 
)
inline

Store room-specific test data for validation.

Definition at line 51 of file mock_rom.h.

References yaze::Rom::data(), and room_data_.

Here is the call graph for this function:

◆ HasObjectData()

bool yaze::test::MockRom::HasObjectData ( int  object_id) const
inline

Check if object data has been set for testing.

Definition at line 58 of file mock_rom.h.

References object_data_.

◆ HasRoomData()

bool yaze::test::MockRom::HasRoomData ( int  room_id) const
inline

Check if room data has been set for testing.

Definition at line 65 of file mock_rom.h.

References room_data_.

◆ IsValid()

bool yaze::test::MockRom::IsValid ( ) const
inline

Check if the mock ROM is valid for testing.

Definition at line 72 of file mock_rom.h.

References yaze::Rom::is_loaded(), yaze::Rom::size(), and test_data_loaded_.

Here is the call graph for this function:

◆ GetObjectData()

const std::vector< uint8_t > & yaze::test::MockRom::GetObjectData ( int  object_id) const
inline

Get the stored object data for validation.

Definition at line 79 of file mock_rom.h.

References object_data_, and yaze::Rom::vector().

Here is the call graph for this function:

◆ GetRoomData()

const std::vector< uint8_t > & yaze::test::MockRom::GetRoomData ( int  room_id) const
inline

Get the stored room data for validation.

Definition at line 88 of file mock_rom.h.

References room_data_, and yaze::Rom::vector().

Here is the call graph for this function:

Member Data Documentation

◆ test_data_loaded_

bool yaze::test::MockRom::test_data_loaded_ = false
private

Definition at line 95 of file mock_rom.h.

Referenced by IsValid(), and SetTestData().

◆ object_data_

std::map<int, std::vector<uint8_t> > yaze::test::MockRom::object_data_
private

Definition at line 96 of file mock_rom.h.

Referenced by GetObjectData(), HasObjectData(), and SetObjectData().

◆ room_data_

std::map<int, std::vector<uint8_t> > yaze::test::MockRom::room_data_
private

Definition at line 97 of file mock_rom.h.

Referenced by GetRoomData(), HasRoomData(), and SetRoomData().


The documentation for this class was generated from the following file: