From b0d9fb70e18e6f76ff597400aa93388f509b11f5 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 29 Oct 2026 21:03:00 -0700 Subject: [PATCH 1/9] FRLG BagDetector: screenshot tests The Items pocket at the top of its list is the bag; a party menu, a box screen and the overworld are not. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Menus/PokemonFRLG_BagDetector_Tests.cpp | 59 +++++++++++++++++++ .../Menus/PokemonFRLG_BagDetector_Tests.h | 24 ++++++++ .../PokemonFRLG/PokemonFRLG_Tests.cpp | 2 + SerialPrograms/cmake/SourceFiles.cmake | 2 + 4 files changed, 87 insertions(+) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp new file mode 100644 index 0000000000..e78a1aca69 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp @@ -0,0 +1,59 @@ +/* Bag Detector Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "CommonFramework/GlobalAutoPaths.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "PokemonFRLG_BagDetector.h" +#include "PokemonFRLG_BagDetector_Tests.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +class Test_BagDetector : public UnitTest{ +public: + Test_BagDetector(const std::string& image, bool expected) + : UnitTest("PokemonFRLG::BagDetector - " + image) + , m_image(UNIT_TEST_RESOURCE_PATH() + image) + , m_expected(expected) + {} + + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + BagDetector detector(COLOR_RED); + ImageRGB32 image(m_image); + const bool result = detector.detect(image); + if (result != m_expected){ + return std::string("Expected bag = ") + (m_expected ? "true" : "false") + + ", got " + (result ? "true" : "false"); + } + return true; + } + +private: + std::string m_image; + bool m_expected; +}; + +} + + +void add_tests_BagDetector(UnitTestDatabase& database){ + database.add("PokemonFRLG/Bag/Items_Top.png", true); + + database.add("PokemonFRLG/Party/Party_1.png", false); + database.add("PokemonFRLG/Box/BoxSelection_White.png", false); + database.add("PokemonFRLG/Bag/Overworld_Route24.png", false); +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h new file mode 100644 index 0000000000..ab720b5242 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h @@ -0,0 +1,24 @@ +/* Bag Detector Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_BagDetector_Tests_H +#define PokemonAutomation_PokemonFRLG_BagDetector_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +void add_tests_BagDetector(UnitTestDatabase& database); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index d51e585590..9f449b4876 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -13,6 +13,7 @@ #include "Inference/Dialogs/PokemonFRLG_DialogDetector.h" #include "Inference/Dialogs/PokemonFRLG_PrizeSelectDetector.h" #include "Inference/Map/PokemonFRLG_PokemonLeagueDetectors.h" +#include "Inference/Menus/PokemonFRLG_BagDetector_Tests.h" #include "Inference/Menus/PokemonFRLG_PartyEmptySlotDetector.h" #include "Inference/Menus/PokemonFRLG_PartyHeldItemDetector.h" #include "Inference/Menus/PokemonFRLG_PartyMenuDetector.h" @@ -277,6 +278,7 @@ void add_tests(UnitTestDatabase& database){ add_tests_EliteFourRoomDetector(database); add_tests_HallOfFameSavingDetector(database); add_tests_BattleMoveSelectionArrow(database); + add_tests_BagDetector(database); add_tests_ExitWildBattle(database); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 9e4e0895bb..1790e38490 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1671,6 +1671,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Inference/Map/PokemonFRLG_PokemonLeagueDetectors.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h + Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp + Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.cpp Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_PartyEmptySlotDetector.cpp From 17219cf5368b63594b2646f521c2a7d67eb67494 Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 30 Oct 2026 17:00:47 -0700 Subject: [PATCH 2/9] FRLG BagDetector tests: the Key Items pocket, unscrolled Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp index e78a1aca69..1972298d5f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp @@ -46,6 +46,7 @@ class Test_BagDetector : public UnitTest{ void add_tests_BagDetector(UnitTestDatabase& database){ database.add("PokemonFRLG/Bag/Items_Top.png", true); + database.add("PokemonFRLG/Bag/KeyItems_Top.png", true); database.add("PokemonFRLG/Party/Party_1.png", false); database.add("PokemonFRLG/Box/BoxSelection_White.png", false); From 1e1112bb6d4398d93a0557c68076e5066e368194 Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 30 Oct 2026 17:04:37 -0700 Subject: [PATCH 3/9] FRLG BagDetector: screenshot tests Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Menus/PokemonFRLG_BagDetector_Tests.cpp | 63 +++++++++++++++++++ .../Menus/PokemonFRLG_BagDetector_Tests.h | 24 +++++++ .../PokemonFRLG/PokemonFRLG_Tests.cpp | 2 + SerialPrograms/cmake/SourceFiles.cmake | 2 + 4 files changed, 91 insertions(+) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp new file mode 100644 index 0000000000..fb2eb83e89 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp @@ -0,0 +1,63 @@ +/* Bag Detector Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "CommonFramework/GlobalAutoPaths.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "PokemonFRLG_BagDetector.h" +#include "PokemonFRLG_BagDetector_Tests.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +class Test_BagDetector : public UnitTest{ +public: + Test_BagDetector(const std::string& image, bool expected) + : UnitTest("PokemonFRLG::BagDetector - " + image) + , m_image(UNIT_TEST_RESOURCE_PATH() + image) + , m_expected(expected) + {} + + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + BagDetector detector(COLOR_RED); + ImageRGB32 image(m_image); + const bool result = detector.detect(image); + if (result != m_expected){ + return std::string("Expected bag = ") + (m_expected ? "true" : "false") + + ", got " + (result ? "true" : "false"); + } + return true; + } + +private: + std::string m_image; + bool m_expected; +}; + +} + + +void add_tests_BagDetector(UnitTestDatabase& database){ + database.add("PokemonFRLG/Bag/Items_Top.png", true); + database.add("PokemonFRLG/Bag/KeyItems_Top.png", true); + // Scrolled down, so a red up-arrow covers the middle of the top frame. + // Fails with the current detector: its top-frame strip runs under the arrow. + database.add("PokemonFRLG/Bag/Items_Scrolled.png", true); + + database.add("PokemonFRLG/Party/Party_1.png", false); + database.add("PokemonFRLG/Box/BoxSelection_White.png", false); + database.add("PokemonFRLG/Bag/Overworld_Route24.png", false); +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h new file mode 100644 index 0000000000..ab720b5242 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h @@ -0,0 +1,24 @@ +/* Bag Detector Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_BagDetector_Tests_H +#define PokemonAutomation_PokemonFRLG_BagDetector_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +void add_tests_BagDetector(UnitTestDatabase& database); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index d51e585590..9f449b4876 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -13,6 +13,7 @@ #include "Inference/Dialogs/PokemonFRLG_DialogDetector.h" #include "Inference/Dialogs/PokemonFRLG_PrizeSelectDetector.h" #include "Inference/Map/PokemonFRLG_PokemonLeagueDetectors.h" +#include "Inference/Menus/PokemonFRLG_BagDetector_Tests.h" #include "Inference/Menus/PokemonFRLG_PartyEmptySlotDetector.h" #include "Inference/Menus/PokemonFRLG_PartyHeldItemDetector.h" #include "Inference/Menus/PokemonFRLG_PartyMenuDetector.h" @@ -277,6 +278,7 @@ void add_tests(UnitTestDatabase& database){ add_tests_EliteFourRoomDetector(database); add_tests_HallOfFameSavingDetector(database); add_tests_BattleMoveSelectionArrow(database); + add_tests_BagDetector(database); add_tests_ExitWildBattle(database); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 9e4e0895bb..1790e38490 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1671,6 +1671,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Inference/Map/PokemonFRLG_PokemonLeagueDetectors.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h + Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp + Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.cpp Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_PartyEmptySlotDetector.cpp From 2a932626c451e94f2d86bf55b0cde096e3234600 Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 30 Oct 2026 17:09:29 -0700 Subject: [PATCH 4/9] FRLG BagDetector tests: the scrolled Items pocket reads as no bag today Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp index fb2eb83e89..06204914d6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp @@ -47,9 +47,9 @@ class Test_BagDetector : public UnitTest{ void add_tests_BagDetector(UnitTestDatabase& database){ database.add("PokemonFRLG/Bag/Items_Top.png", true); database.add("PokemonFRLG/Bag/KeyItems_Top.png", true); - // Scrolled down, so a red up-arrow covers the middle of the top frame. - // Fails with the current detector: its top-frame strip runs under the arrow. - database.add("PokemonFRLG/Bag/Items_Scrolled.png", true); + // Scrolled down: a bag, but a red up-arrow covers the middle of the top + // frame, and the detector's strip there runs under it, so it reads no bag. + database.add("PokemonFRLG/Bag/Items_Scrolled.png", false); database.add("PokemonFRLG/Party/Party_1.png", false); database.add("PokemonFRLG/Box/BoxSelection_White.png", false); From d2bb731f0f752b5938d443f3feaefcacbbe8dae2 Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 30 Oct 2026 22:49:48 -0700 Subject: [PATCH 5/9] FRLG BagDetector: leave the scroll arrow out of the top frame check The red up-arrow drawn over the bag's top frame once the pocket list is scrolled made the check fail, so a scrolled bag read as no bag. The strip now stops short of it, and the scrolled test expects a bag. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp | 4 +++- .../Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp index efd44bf464..46f2e5facc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp @@ -23,7 +23,9 @@ namespace PokemonFRLG{ BagDetector::BagDetector(Color color) : m_bag_shadow_box(0.131250, 0.608173, 0.068269, 0.001442) , m_pocket_underline_box(0.043269, 0.137259, 0.279808, 0.005769) - , m_menu_top_box(0.029808, 0.029086, 0.947115, 0.003606) + // Stops short of the red arrow drawn over the frame once the list is + // scrolled down. + , m_menu_top_box(0.029808, 0.029086, 0.550000, 0.003606) , m_menu_right_box(0.977404, 0.034134, 0.005288, 0.597837) {} void BagDetector::make_overlays(VideoOverlaySet& items) const{ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp index 06204914d6..afe0562f44 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp @@ -47,9 +47,8 @@ class Test_BagDetector : public UnitTest{ void add_tests_BagDetector(UnitTestDatabase& database){ database.add("PokemonFRLG/Bag/Items_Top.png", true); database.add("PokemonFRLG/Bag/KeyItems_Top.png", true); - // Scrolled down: a bag, but a red up-arrow covers the middle of the top - // frame, and the detector's strip there runs under it, so it reads no bag. - database.add("PokemonFRLG/Bag/Items_Scrolled.png", false); + // Scrolled down: a red up-arrow covers the middle of the top frame. + database.add("PokemonFRLG/Bag/Items_Scrolled.png", true); database.add("PokemonFRLG/Party/Party_1.png", false); database.add("PokemonFRLG/Box/BoxSelection_White.png", false); From e5af9f4d70e8e20c8870da10fd3ff5c75c78cf5e Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 00:35:33 -0700 Subject: [PATCH 6/9] FRLG BagDetector tests: image names carry the expected result Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp index afe0562f44..f48a9c8e29 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp @@ -45,14 +45,14 @@ class Test_BagDetector : public UnitTest{ void add_tests_BagDetector(UnitTestDatabase& database){ - database.add("PokemonFRLG/Bag/Items_Top.png", true); - database.add("PokemonFRLG/Bag/KeyItems_Top.png", true); + database.add("PokemonFRLG/Bag/Items_Top_True.png", true); + database.add("PokemonFRLG/Bag/KeyItems_Top_True.png", true); // Scrolled down: a red up-arrow covers the middle of the top frame. - database.add("PokemonFRLG/Bag/Items_Scrolled.png", true); + database.add("PokemonFRLG/Bag/Items_Scrolled_True.png", true); database.add("PokemonFRLG/Party/Party_1.png", false); database.add("PokemonFRLG/Box/BoxSelection_White.png", false); - database.add("PokemonFRLG/Bag/Overworld_Route24.png", false); + database.add("PokemonFRLG/Bag/Overworld_Route24_False.png", false); } From f035103047bb10d100bdd07809d148d00a66ddcb Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 01:11:27 -0700 Subject: [PATCH 7/9] FRLG BagDetector tests: a girl's bag, and the start menu and bedroom with no bag Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp index f48a9c8e29..46b40484e4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp @@ -50,9 +50,17 @@ void add_tests_BagDetector(UnitTestDatabase& database){ // Scrolled down: a red up-arrow covers the middle of the top frame. database.add("PokemonFRLG/Bag/Items_Scrolled_True.png", true); + // A girl's bag, drawn differently from the boy's. + database.add("PokemonFRLG/Bag/Items_Top_Girl_True.png", true); + database.add("PokemonFRLG/Bag/Items_Potion_Girl_True.png", true); + database.add("PokemonFRLG/Bag/KeyItems_Top_Girl_True.png", true); + database.add("PokemonFRLG/Bag/PokeBalls_Top_Girl_True.png", true); + database.add("PokemonFRLG/Party/Party_1.png", false); database.add("PokemonFRLG/Box/BoxSelection_White.png", false); database.add("PokemonFRLG/Bag/Overworld_Route24_False.png", false); + database.add("PokemonFRLG/Bag/Overworld_Bedroom_Girl_False.png", false); + database.add("PokemonFRLG/Bag/StartMenu_Girl_False.png", false); } From 12886cc8c92c0e29f3a4cf1d48389585a22d15b9 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 10:36:59 -0700 Subject: [PATCH 8/9] FRLG BagDetector tests: move into PokemonFRLG_BagDetector.cpp/.h Register the tests in the detector's own files, as the other FRLG detectors do, and drop the negative controls that read images from other detectors' directories (Party/Party_1.png, Box/BoxSelection_White.png). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Menus/PokemonFRLG_BagDetector.cpp | 44 ++++++++++++ .../Inference/Menus/PokemonFRLG_BagDetector.h | 4 ++ .../Menus/PokemonFRLG_BagDetector_Tests.cpp | 70 ------------------- .../Menus/PokemonFRLG_BagDetector_Tests.h | 24 ------- .../PokemonFRLG/PokemonFRLG_Tests.cpp | 2 +- SerialPrograms/cmake/SourceFiles.cmake | 2 - 6 files changed, 49 insertions(+), 97 deletions(-) delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp index 46f2e5facc..2a08829a0b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp @@ -7,8 +7,10 @@ #include "Common/Cpp/Exceptions.h" #include "CommonFramework/ImageTools/ImageBoxes.h" #include "CommonFramework/ImageTools/ImageStats.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "CommonFramework/GlobalAutoPaths.h" #include "CommonTools/Images/SolidColorTest.h" #include "CommonTools/Images/ImageFilter.h" #include "CommonTools/Images/WaterfillUtilities.h" @@ -56,6 +58,48 @@ bool BagDetector::detect(const ImageViewRGB32& screen){ } +class Test_BagDetector : public UnitTest{ +public: + Test_BagDetector(const std::string& image, bool expected) + : UnitTest("PokemonFRLG::BagDetector - " + image) + , m_image(UNIT_TEST_RESOURCE_PATH() + image) + , m_expected(expected) + {} + + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + BagDetector detector(COLOR_RED); + ImageRGB32 image(m_image); + const bool result = detector.detect(image); + if (result != m_expected){ + return std::string("Expected bag = ") + (m_expected ? "true" : "false") + + ", got " + (result ? "true" : "false"); + } + return true; + } + +private: + std::string m_image; + bool m_expected; +}; + +void add_tests_BagDetector(UnitTestDatabase& database){ + database.add("PokemonFRLG/Bag/Items_Top_True.png", true); + database.add("PokemonFRLG/Bag/KeyItems_Top_True.png", true); + // Scrolled down: a red up-arrow covers the middle of the top frame. + database.add("PokemonFRLG/Bag/Items_Scrolled_True.png", true); + + // A girl's bag, drawn differently from the boy's. + database.add("PokemonFRLG/Bag/Items_Top_Girl_True.png", true); + database.add("PokemonFRLG/Bag/Items_Potion_Girl_True.png", true); + database.add("PokemonFRLG/Bag/KeyItems_Top_Girl_True.png", true); + database.add("PokemonFRLG/Bag/PokeBalls_Top_Girl_True.png", true); + + database.add("PokemonFRLG/Bag/Overworld_Route24_False.png", false); + database.add("PokemonFRLG/Bag/Overworld_Bedroom_Girl_False.png", false); + database.add("PokemonFRLG/Bag/StartMenu_Girl_False.png", false); +} + + } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h index ee3d4bd1a4..d8170289a8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h @@ -9,6 +9,7 @@ #include #include "Common/Cpp/Color.h" +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" #include "CommonFramework/ImageTools/ImageBoxes.h" #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "CommonTools/VisualDetector.h" @@ -42,6 +43,9 @@ class BagWatcher : public DetectorToFinder{ }; +void add_tests_BagDetector(UnitTestDatabase& database); + + } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp deleted file mode 100644 index 46b40484e4..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* Bag Detector Tests - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "CommonFramework/GlobalAutoPaths.h" -#include "CommonFramework/ImageTypes/ImageRGB32.h" -#include "PokemonFRLG_BagDetector.h" -#include "PokemonFRLG_BagDetector_Tests.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -class Test_BagDetector : public UnitTest{ -public: - Test_BagDetector(const std::string& image, bool expected) - : UnitTest("PokemonFRLG::BagDetector - " + image) - , m_image(UNIT_TEST_RESOURCE_PATH() + image) - , m_expected(expected) - {} - - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - BagDetector detector(COLOR_RED); - ImageRGB32 image(m_image); - const bool result = detector.detect(image); - if (result != m_expected){ - return std::string("Expected bag = ") + (m_expected ? "true" : "false") + - ", got " + (result ? "true" : "false"); - } - return true; - } - -private: - std::string m_image; - bool m_expected; -}; - -} - - -void add_tests_BagDetector(UnitTestDatabase& database){ - database.add("PokemonFRLG/Bag/Items_Top_True.png", true); - database.add("PokemonFRLG/Bag/KeyItems_Top_True.png", true); - // Scrolled down: a red up-arrow covers the middle of the top frame. - database.add("PokemonFRLG/Bag/Items_Scrolled_True.png", true); - - // A girl's bag, drawn differently from the boy's. - database.add("PokemonFRLG/Bag/Items_Top_Girl_True.png", true); - database.add("PokemonFRLG/Bag/Items_Potion_Girl_True.png", true); - database.add("PokemonFRLG/Bag/KeyItems_Top_Girl_True.png", true); - database.add("PokemonFRLG/Bag/PokeBalls_Top_Girl_True.png", true); - - database.add("PokemonFRLG/Party/Party_1.png", false); - database.add("PokemonFRLG/Box/BoxSelection_White.png", false); - database.add("PokemonFRLG/Bag/Overworld_Route24_False.png", false); - database.add("PokemonFRLG/Bag/Overworld_Bedroom_Girl_False.png", false); - database.add("PokemonFRLG/Bag/StartMenu_Girl_False.png", false); -} - - - -} -} -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h deleted file mode 100644 index ab720b5242..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Bag Detector Tests - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#ifndef PokemonAutomation_PokemonFRLG_BagDetector_Tests_H -#define PokemonAutomation_PokemonFRLG_BagDetector_Tests_H - -#include "Common/Cpp/TestRunners/UnitTestDatabase.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -void add_tests_BagDetector(UnitTestDatabase& database); - - - -} -} -} -#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 9f449b4876..23e40ab5da 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -13,7 +13,7 @@ #include "Inference/Dialogs/PokemonFRLG_DialogDetector.h" #include "Inference/Dialogs/PokemonFRLG_PrizeSelectDetector.h" #include "Inference/Map/PokemonFRLG_PokemonLeagueDetectors.h" -#include "Inference/Menus/PokemonFRLG_BagDetector_Tests.h" +#include "Inference/Menus/PokemonFRLG_BagDetector.h" #include "Inference/Menus/PokemonFRLG_PartyEmptySlotDetector.h" #include "Inference/Menus/PokemonFRLG_PartyHeldItemDetector.h" #include "Inference/Menus/PokemonFRLG_PartyMenuDetector.h" diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 1790e38490..9e4e0895bb 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1671,8 +1671,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Inference/Map/PokemonFRLG_PokemonLeagueDetectors.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h - Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.cpp - Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector_Tests.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.cpp Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.h Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_PartyEmptySlotDetector.cpp From b4f26fc9394e3e5c6a577ff102864487a68b7c8e Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 10:38:08 -0700 Subject: [PATCH 9/9] FRLG BagDetector tests: run on ImageUnitTest, like the other FRLG detector tests Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Inference/Menus/PokemonFRLG_BagDetector.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp index 2a08829a0b..323a0f3899 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.cpp @@ -7,13 +7,12 @@ #include "Common/Cpp/Exceptions.h" #include "CommonFramework/ImageTools/ImageBoxes.h" #include "CommonFramework/ImageTools/ImageStats.h" -#include "CommonFramework/ImageTypes/ImageRGB32.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" -#include "CommonFramework/GlobalAutoPaths.h" #include "CommonTools/Images/SolidColorTest.h" #include "CommonTools/Images/ImageFilter.h" #include "CommonTools/Images/WaterfillUtilities.h" +#include "Tests/ImageUnitTest.h" #include "PokemonFRLG_BagDetector.h" @@ -58,17 +57,19 @@ bool BagDetector::detect(const ImageViewRGB32& screen){ } -class Test_BagDetector : public UnitTest{ +class Test_BagDetector : public ImageUnitTest{ public: Test_BagDetector(const std::string& image, bool expected) - : UnitTest("PokemonFRLG::BagDetector - " + image) - , m_image(UNIT_TEST_RESOURCE_PATH() + image) + : ImageUnitTest("PokemonFRLG::BagDetector - " + image, {image}) , m_expected(expected) {} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + virtual UnitTestResult run_on_images( + Logger&, CancellableScope&, + const std::vector& images + ) const override{ BagDetector detector(COLOR_RED); - ImageRGB32 image(m_image); + const ImageRGB32& image = images[0]; const bool result = detector.detect(image); if (result != m_expected){ return std::string("Expected bag = ") + (m_expected ? "true" : "false") + @@ -78,7 +79,6 @@ class Test_BagDetector : public UnitTest{ } private: - std::string m_image; bool m_expected; };