Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "CommonTools/Images/SolidColorTest.h"
#include "CommonTools/Images/ColorClustering.h"
#include "Tests/ImageUnitTest.h"
#include "Tests/TestUtils.h"
#include "Pokemon/Inference/Pokemon_ReadHpBar.h"
#include "Pokemon/Inference/Pokemon_TypeReader.h"
#include "VideoGames/PokemonSwSh/Resources/PokemonSwSh_MaxLairDatabase.h"
Expand Down Expand Up @@ -278,18 +279,18 @@ std::set<std::string> BattleMenuReader::read_opponent_in_summary(Logger& logger,
}
logger.log(type_str);

// A type read twice is one type: in the summary's type box the "O" of a
// "NORMAL" label also matches the Normal icon (Persian: 0.368, next to
// 0.076 for the real icon), and no Pokemon has the same type twice.
type0 = PokemonType::NONE;
type1 = PokemonType::NONE;
{
auto iter = candidates.begin();
if (iter != candidates.end()){
type0 = iter->second.first;
++iter;
}
if (iter != candidates.end()){
type1 = iter->second.first;
++iter;
}
auto iter = candidates.begin();
if (iter != candidates.end()){
type0 = iter->second.first;
++iter;
}
if (iter != candidates.end() && iter->second.first != type0){
type1 = iter->second.first;
}
}

Expand Down Expand Up @@ -573,12 +574,59 @@ class Test_MaxLairBattleMenuDetector : public ImageUnitTest{



class Test_MaxLairSummaryOpponentReader : public ImageUnitTest{
public:
Test_MaxLairSummaryOpponentReader(
const std::string& image,
Language language,
std::set<std::string> expected
)
: ImageUnitTest("PokemonSwSh::MaxLairSummaryOpponentReader - " + image, {image})
, m_language(language)
, m_expected(std::move(expected))
{}

virtual UnitTestResult run_on_images(
Logger& logger, CancellableScope& scope,
const std::vector<ImageRGB32>& images
) const override{
DummyVideoOverlay overlay;
OcrFailureWatchdog ocr_watchdog(logger, m_language);
BattleMenuReader reader(overlay, m_language, ocr_watchdog);
std::set<std::string> result = reader.read_opponent_in_summary(logger, images[0]);
if (result == m_expected){
return true;
}
std::string message = "Read:";
for (const std::string& slug : result){
message += " " + slug;
}
if (result.empty()){
message += " (nothing)";
}
return UnitTestResult(UnitTestResult::FAILED, std::move(message));
};

private:
Language m_language;
std::set<std::string> m_expected;
};







void add_tests_MaxLairBattleMenuDetector(UnitTestDatabase& database){
database.add<Test_MaxLairBattleMenuDetector>("PokemonSwSh/MaxLair_BattleMenuDetector/MyPin_Q6g_BattleMenuDA_True.jpg", true);

// A single-type Normal Pokemon: the "O" of the "NORMAL" badge label also
// matches the Normal icon.
database.add<Test_MaxLairSummaryOpponentReader>(
"PokemonSwSh/MaxLair_SummaryOpponentReader/English_Persian.jpg",
Language::English, std::set<std::string>{"persian"}
);
}


Expand Down
Loading