1#ifndef YAZE_APP_TEST_GRAPHICS_EDITOR_TEST_SUITE_H
2#define YAZE_APP_TEST_GRAPHICS_EDITOR_TEST_SUITE_H
7#include "absl/strings/str_format.h"
22 std::string
GetName()
const override {
return "Graphics Editor Tests"; }
30 if (!current_rom || !current_rom->
is_loaded()) {
32 return absl::OkStatus();
43 return absl::OkStatus();
55 const std::string& reason) {
57 result.
name = test_name;
62 result.
duration = std::chrono::milliseconds{0};
63 result.
timestamp = std::chrono::steady_clock::now();
68 auto start_time = std::chrono::steady_clock::now();
71 result.
name =
"Graphics_Pixel_Editing";
79 test_manager.TestRomWithCopy(rom, [&](
Rom* test_rom) -> absl::Status {
91 uint16_t sheet_id = 0;
98 return absl::InternalError(
"No graphics sheets loaded");
102 uint8_t original_pixel = sheet.GetPixel(0, 0);
103 uint8_t new_pixel = (original_pixel + 1) % 16;
105 sheet.SetPixel(0, 0, new_pixel);
107 if (sheet.GetPixel(0, 0) != new_pixel) {
108 return absl::InternalError(
"Failed to set pixel in bitmap");
114 return absl::OkStatus();
117 if (test_status.ok()) {
119 result.
error_message =
"Pixel editing verified in data layer";
125 }
catch (
const std::exception& e) {
130 auto end_time = std::chrono::steady_clock::now();
131 result.
duration = std::chrono::duration_cast<std::chrono::milliseconds>(
132 end_time - start_time);
138 auto start_time = std::chrono::steady_clock::now();
141 result.
name =
"Graphics_Palette_Editing";
149 test_manager.TestRomWithCopy(rom, [&](
Rom* test_rom) -> absl::Status {
160 return absl::InternalError(
"No dungeon palettes loaded");
164 SDL_Color original_color = palette.GetColor(0);
165 SDL_Color new_color = {255, 0, 0, 255};
167 palette.SetColor(0, new_color);
169 SDL_Color actual_color = palette.GetColor(0);
170 if (actual_color.r != 255 || actual_color.g != 0 || actual_color.b != 0) {
171 return absl::InternalError(
"Palette color update failed");
174 return absl::OkStatus();
177 if (test_status.ok()) {
179 result.
error_message =
"Palette editing verified in data layer";
185 }
catch (
const std::exception& e) {
190 auto end_time = std::chrono::steady_clock::now();
191 result.
duration = std::chrono::duration_cast<std::chrono::milliseconds>(
192 end_time - start_time);
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Allows the user to edit graphics sheets from the game or view prototype graphics.
void SelectSheet(uint16_t sheet_id)
absl::Status Load() override
void Initialize() override
void SetGameData(zelda3::GameData *game_data) override
bool test_palette_editing_
void RunPaletteEditingTest(TestResults &results, Rom *rom)
void DrawConfiguration() override
GraphicsEditorTestSuite()=default
std::string GetName() const override
~GraphicsEditorTestSuite() override=default
void RunPixelEditingTest(TestResults &results, Rom *rom)
absl::Status RunTests(TestResults &results) override
void AddSkippedTest(TestResults &results, const std::string &test_name, const std::string &reason)
TestCategory GetCategory() const override
Rom * GetCurrentRom() const
static TestManager & Get()
absl::Status LoadGameData(Rom &rom, GameData &data, const LoadOptions &options)
Loads all Zelda3-specific game data from a generic ROM.
#define RETURN_IF_ERROR(expr)
std::chrono::milliseconds duration
std::string error_message
std::chrono::time_point< std::chrono::steady_clock > timestamp
void AddResult(const TestResult &result)
gfx::PaletteGroupMap palette_groups
std::array< gfx::Bitmap, kNumGfxSheets > gfx_bitmaps