From c59a4592c3bab9ff0f07272e616eb2e5d231b219 Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 4 Oct 2025 14:01:30 -0400 Subject: [PATCH] feat: Add dungeon editor smoke test and register it in the test suite - Introduced a new smoke test for the Dungeon Editor to verify UI elements and functionality. - Registered the Dungeon Editor smoke test in the main test suite for automated execution. - Updated the integration test setup to ensure proper ROM loading from multiple locations. --- test/e2e/dungeon_editor_smoke_test.cc | 47 ++++++++++++++++++++++++++ test/e2e/dungeon_editor_smoke_test.h | 9 +++++ test/integration/dungeon_editor_test.h | 11 ++++-- test/yaze_test.cc | 6 ++++ 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 test/e2e/dungeon_editor_smoke_test.cc create mode 100644 test/e2e/dungeon_editor_smoke_test.h diff --git a/test/e2e/dungeon_editor_smoke_test.cc b/test/e2e/dungeon_editor_smoke_test.cc new file mode 100644 index 00000000..d89b9d61 --- /dev/null +++ b/test/e2e/dungeon_editor_smoke_test.cc @@ -0,0 +1,47 @@ +#include "e2e/dungeon_editor_smoke_test.h" +#include "test_utils.h" +#include "app/core/controller.h" +#include "imgui_test_engine/imgui_te_context.h" + +// Simple smoke test for dungeon editor +// Verifies that the editor opens and basic UI elements are present +void E2ETest_DungeonEditorSmokeTest(ImGuiTestContext* ctx) +{ + // Load ROM first + yaze::test::gui::LoadRomInTest(ctx, "zelda3.sfc"); + + // Open the Dungeon Editor + yaze::test::gui::OpenEditorInTest(ctx, "Dungeon Editor"); + + // Focus on the dungeon editor window + ctx->WindowFocus("Dungeon Editor"); + + // Log that we opened the editor + ctx->LogInfo("Dungeon Editor window opened successfully"); + + // Verify the 3-column layout exists + // Check for Room Selector on the left + ctx->SetRef("Dungeon Editor"); + + // Check basic tabs exist + ctx->ItemClick("Rooms##TabItemButton"); + ctx->LogInfo("Room selector tab clicked"); + + // Check that we can see room list + // Room 0 should exist in any valid zelda3.sfc + ctx->ItemClick("Room 0x00"); + ctx->LogInfo("Selected room 0x00"); + + // Verify canvas is present (center column) + // The canvas should be focusable + ctx->ItemClick("##Canvas"); + ctx->LogInfo("Canvas clicked"); + + // Check Object Selector tab on right + ctx->ItemClick("Object Selector##TabItemButton"); + ctx->LogInfo("Object selector tab clicked"); + + // Log success + ctx->LogInfo("Dungeon Editor smoke test completed successfully"); +} + diff --git a/test/e2e/dungeon_editor_smoke_test.h b/test/e2e/dungeon_editor_smoke_test.h new file mode 100644 index 00000000..e8ac9807 --- /dev/null +++ b/test/e2e/dungeon_editor_smoke_test.h @@ -0,0 +1,9 @@ +#ifndef YAZE_TEST_E2E_DUNGEON_EDITOR_SMOKE_TEST_H +#define YAZE_TEST_E2E_DUNGEON_EDITOR_SMOKE_TEST_H + +#include "imgui_test_engine/imgui_te_context.h" + +void E2ETest_DungeonEditorSmokeTest(ImGuiTestContext* ctx); + +#endif // YAZE_TEST_E2E_DUNGEON_EDITOR_SMOKE_TEST_H + diff --git a/test/integration/dungeon_editor_test.h b/test/integration/dungeon_editor_test.h index e05f56de..92f9a1f2 100644 --- a/test/integration/dungeon_editor_test.h +++ b/test/integration/dungeon_editor_test.h @@ -18,9 +18,16 @@ namespace test { class DungeonEditorIntegrationTest : public ::testing::Test { protected: void SetUp() override { - // Use the real ROM + // Use the real ROM (try multiple locations) rom_ = std::make_unique(); - ASSERT_TRUE(rom_->LoadFromFile("build/bin/zelda3.sfc").ok()); + 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"; dungeon_editor_ = std::make_unique(); dungeon_editor_->set_rom(rom_.get()); } diff --git a/test/yaze_test.cc b/test/yaze_test.cc index a614eff2..a030e241 100644 --- a/test/yaze_test.cc +++ b/test/yaze_test.cc @@ -19,6 +19,7 @@ #include "app/core/controller.h" #include "e2e/canvas_selection_test.h" #include "e2e/framework_smoke_test.h" +#include "e2e/dungeon_editor_smoke_test.h" // #include "test_editor.h" // Not used in main @@ -285,6 +286,11 @@ int main(int argc, char* argv[]) { ImGuiTest* canvas_test = IM_REGISTER_TEST(engine, "E2ETest", "CanvasSelectionTest"); canvas_test->TestFunc = E2ETest_CanvasSelectionTest; canvas_test->UserData = &controller; + + // Register dungeon editor smoke test + ImGuiTest* dungeon_test = IM_REGISTER_TEST(engine, "E2ETest", "DungeonEditorSmokeTest"); + dungeon_test->TestFunc = E2ETest_DungeonEditorSmokeTest; + dungeon_test->UserData = &controller; // Main loop bool done = false;