diff --git a/test/getsearchnames/.gitignore b/test/getsearchnames/.gitignore new file mode 100644 index 00000000..b4c081ec --- /dev/null +++ b/test/getsearchnames/.gitignore @@ -0,0 +1,5 @@ +Makefile +*.o +moc_* +*.moc +test_getsearchnames diff --git a/test/getsearchnames/rom_samples/empty (0 bytes).zip b/test/getsearchnames/rom_samples/empty (0 bytes).zip new file mode 100644 index 00000000..e69de29b diff --git a/test/getsearchnames/rom_samples/zaxxon.zip b/test/getsearchnames/rom_samples/zaxxon.zip new file mode 100644 index 00000000..1f800cbf Binary files /dev/null and b/test/getsearchnames/rom_samples/zaxxon.zip differ diff --git a/test/getsearchnames/scummvm.ini b/test/getsearchnames/scummvm.ini new file mode 100644 index 00000000..42dec2b0 --- /dev/null +++ b/test/getsearchnames/scummvm.ini @@ -0,0 +1,12 @@ +[scummvm] +native_mt32=false + +[tentacle] +description=Day of the Tentacle (Floppy/DOS/English) +extra=Floppy +path=c:\what\ever\Day-of-the-Tentacle +engineid=scumm +gameid=tentacle + +[dig] +description=The Dig diff --git a/test/getsearchnames/test_getsearchnames.cpp b/test/getsearchnames/test_getsearchnames.cpp new file mode 100644 index 00000000..d16dc519 --- /dev/null +++ b/test/getsearchnames/test_getsearchnames.cpp @@ -0,0 +1,316 @@ +#include "arcadedb.h" +#include "config.h" +#include "esgamelist.h" +#include "igdb.h" +#include "mobygames.h" +#include "openretro.h" +#include "screenscraper.h" + +#include +#include + +/* + Tests the getSearchNames() method of the different scrapers. + WorldOfSpectrum and Import-Scraper and TGDB are covered by Mobygames scraper: + These use getSearchNames() in the AbstractScraper. + + If testing against v3.10.3 or earlier set the define VER_3_10_3 in the *.pro + file. +*/ +class TestGetSearchNames : public QObject { + Q_OBJECT + +private: + void match(const QMap> &tests) { + QString dbgStr; + + for (auto t : tests.keys()) { + qInfo() << "Testing" << t << "..."; + QString input = tests.value(t).first; + QFile f = QFile(input); + QFileInfo fi(f); + QStringList exp = tests.value(t).second; +#ifdef VER_3_10_3 + QList out = scraper->getSearchNames(fi); +#else + QList out = scraper->getSearchNames(fi, dbgStr); +#endif + // qDebug() << out; + + QCOMPARE(out.size(), exp.size()); + int i = 0; + for (const auto &e : exp) { + QCOMPARE(out[i++], e); + } + qInfo() << "... done testing" << t; + } + } + + Settings settings; + AbstractScraper *scraper; + +private slots: + void initTestCase() { + + settings.aliasMap = { + // explictly change first word in the replacement + // to spot possible errors (MotherX) + {"Mother 25th Restoration Hack", {"MotherX (Japan)"}}}; + } + + void testArcadeDB() { + scraper = new ArcadeDB(&settings, NULL); + QMap> tests_adb = { +#ifndef VER_3_10_3 + {"ArcadeDB, with aliasMap match", + QPair( + "./rom_samples/Mother 25th Restoration Hack.zip", + {"MotherX (Japan)"})}, +#endif + {"ArcadeDB, w/o aliasMap match", + QPair("./rom_samples/1942.zip", {"1942"})}, + + }; + + match(tests_adb); + } + + void testESGamelist() { + QMap> tests_esgl = { + {"ESgl, with aliasMap match (aliasMap should be ignored)", + QPair( + "./rom_samples/Mother 25th Restoration Hack.zip", + {"Mother 25th Restoration Hack.zip"})}, + {"ESgl, w/o aliasMap match", + QPair("./rom_samples/1942.zip", + {"1942.zip"})}, + + }; + + scraper = new ESGameList(&settings, NULL); + match(tests_esgl); + } + + void testOpenRetro() { + scraper = new OpenRetro(&settings, NULL); + QMap> tests_matchone = { + {"OpenRetro, with aliasMap match", + QPair( + "./rom_samples/Mother 25th Restoration Hack.zip", + {"/browse?q=motherx"})}, + {"OpenRetro, with ROM hack and no aliasMap entry", + QPair( + "./rom_samples/Mother 25th Restoration Hack_Hack.zip", + {"/browse?q=mother+25th"})}, + {"OpenRetro, w/o aliasMap match 1 word", + QPair("./rom_samples/1942.zip", + {"/browse?q=1942"})}, + {"OpenRetro, w/o aliasMap match 2+ words", + QPair("./rom_samples/abclimax.zip", + {"/browse?q=after+burner"})}, + + }; + + settings.platform = "fba"; + settings.mameMap = {{"1942", "1942 (Revision B)"}, + {"abclimax", "After Burner Climax (Export)"} + + }; + match(tests_matchone); + } + + void testOpenRetroMatchMany() { + scraper = new OpenRetro(&settings, NULL); + settings.platform = "amiga"; + settings.whdLoadMap = { + {"BillsTomatoGame_v2.0_1748", + {"Bill's Tomato Game", "307c1c7f-1f31-5b7d-ac71-57a9f035679f"}}, + {"Burntime_v1.2_AGA_2213", + {"Burntime [AGA]", "930a2652-50e0-5b89-8076-3ec478f0e6ad"}}, + + }; + + QMap> tests_matchmany = { + {"OpenRetro, with amiga whdl match", + QPair( + "./rom_samples/BillsTomatoGame_v2.0_1748.lha", + {"/game/307c1c7f-1f31-5b7d-ac71-57a9f035679f", + "/browse?q=bill%27s+tomato"})}, + {"OpenRetro, w/o amiga whdl match", + QPair( + "./rom_samples/Some game-here V1.0.lha", + {"/browse?q=some+game-here", "/browse?q=some+game"})}, + {"OpenRetro, with amiga whdl and aga match", + QPair( + "./rom_samples/Burntime_v1.2_AGA_2213.lha", + {"/game/930a2652-50e0-5b89-8076-3ec478f0e6ad", + "/browse?q=burntime+aga", "/browse?q=burntime"})}, + + }; + + match(tests_matchmany); + + QMap> tests_scummvm = { + {"OpenRetro, with scummvm.ini match", + QPair("./rom_samples/tentacle.svm", + {"/browse?q=day+of"})}, + {"OpenRetro, w/o scummvm.ini match", + QPair( + "./rom_samples/the yabba dabba doo.svm", + {"/browse?q=yabba+dabba"})}, + + }; + + settings.platform = "scummvm"; + settings.scummIni = + QCoreApplication::applicationDirPath() + "/scummvm.ini"; + + match(tests_scummvm); + } + + void testIgdb() { + scraper = new Igdb(&settings, NULL); + settings.platform = "amiga"; + settings.whdLoadMap = { + {"BillsTomatoGame_v2.0_1748", + {"Bill's Tomato Game", "307c1c7f-1f31-5b7d-ac71-57a9f035679f"}}, + {"Burntime_v1.2_AGA_2213", + {"Burntime [AGA]", "930a2652-50e0-5b89-8076-3ec478f0e6ad"}}, + + }; + + settings.aliasMap.insert("Mother.25th.Restoration.Hack", "Dot.dot.dot"); + + QMap> tests_matchmany = { + {"Igdb, with amiga whdl match", + QPair( + "./rom_samples/BillsTomatoGame_v2.0_1748.lha", + {"Bill's Tomato Game"})}, + {"Igdb, w/o amiga whdl match", + QPair( + "./rom_samples/Some game-here V99.33.lha", + {"Some game-here V99.33"})}, + {"Igdb, with amiga whdl and aga match", + QPair( + "./rom_samples/Burntime_v1.2_AGA_2213.lha", {"Burntime"})}, + {"Igdb, with aliasMap match", + QPair( + "./rom_samples/Mother 25th Restoration Hack.zip", + {"MotherX"})}, + {"Igdb, with aliasMap match, ROM with dots", + QPair( + "./rom_samples/Mother.25th.Restoration.Hack.zip", + {"Dot.dot.dot"})}, + {"Igdb, with ROM hack and no aliasMap entry", + QPair( + "./rom_samples/Mother 25th Restoration Hack_Hack.zip", + {"Mother 25th Restoration Hack_Hack"})}, + + }; + + match(tests_matchmany); + + QMap> tests_scummvm = { + {"Igdb, with scummvm.ini match", + QPair("./rom_samples/tentacle.svm", + {"Day of the Tentacle"})}, + {"Igdb, w/o scummvm.ini match", + QPair( + "./rom_samples/the yabba dabba doo.svm", + {"the yabba dabba doo"})}, + + }; + + settings.platform = "scummvm"; + settings.scummIni = + QCoreApplication::applicationDirPath() + "/scummvm.ini"; + + match(tests_scummvm); + } + + void testMobyGames() { + scraper = new MobyGames(&settings, NULL); + settings.platform = "amiga"; + settings.whdLoadMap = { + {"BillsTomatoGame_v2.0_1748", + {"Bill's Tomato Game", "307c1c7f-1f31-5b7d-ac71-57a9f035679f"}}, + {"Burntime_v1.2_AGA_2213", + {"Burntime [AGA]", "930a2652-50e0-5b89-8076-3ec478f0e6ad"}}, + + }; + + QMap> tests_matchmany = { + {"Mobygames, with amiga whdl match", + QPair( + "./rom_samples/BillsTomatoGame_v2.0_1748.lha", + {"bill%27s+tomato+game"})}, + {"Mobygames, w/o amiga whdl match", + QPair( + "./rom_samples/Some game-here V99.33.lha", + {"some+game-here+v99.33"})}, + {"Mobygames, with amiga whdl and aga match", + QPair( + "./rom_samples/Burntime_v1.2_AGA_2213.lha", {"burntime"})}, + {"Mobygames, with aliasMap match", + QPair( + "./rom_samples/Mother 25th Restoration Hack.zip", + {"motherx"})}, + {"Mobygames, with ROM hack and no aliasMap entry", + QPair( + "./rom_samples/Mother 25th Restoration Hack_Hack.zip", + {"mother+25th+restoration+hack+hack"})}, + + }; + + match(tests_matchmany); + + QMap> tests_scummvm = { + {"Mobygames, with scummvm.ini match", + QPair("./rom_samples/tentacle.svm", + {"day+of+the+tentacle"})}, + {"Mobygames, w/o scummvm.ini match", + QPair( + "./rom_samples/the yabba dabba doo.svm", {"yabba+dabba+doo"})}, + + }; + + settings.platform = "scummvm"; + settings.scummIni = + QCoreApplication::applicationDirPath() + "/scummvm.ini"; + + match(tests_scummvm); + } + void testScreenscraper() { + scraper = new ScreenScraper(&settings, NULL); + settings.platform = "mame-libretro"; + QStringList zaxxon_expected = { + "crc=BB2E0146", "md5=852605F01A3E2D21FBAF35FCAB385B94", + "sha1=05F32B2286ECE2F30CB1EFBC2B4C7C2AEF2F9662", + "romnom=zaxxon.zip", "romtaille=32768"}; + QMap> tests = { +#ifndef VER_3_10_3 + {"Screenscraper, with aliasMap match", + QPair( + "./rom_samples/Mother 25th Restoration Hack.zip", + {"romnom=MotherX%20(Japan)"})}, +#endif + {"Screenscraper, with arcade match", + QPair("./rom_samples/zaxxon.zip", + {zaxxon_expected.join("&")})}, + {"Screenscraper, 0 byte ROM", + QPair("./rom_samples/empty (0 bytes).zip", + {"romnom=empty%20(0%20bytes).zip"})}, + {"Screenscraper, with amiga whdl match", + QPair( + "./rom_samples/BillsTomatoGame_v2.0_1748.lha", + {"romnom=BillsTomatoGame_v2.0_1748.lha"})}, + + }; + settings.mameMap.insert("zaxxon.zip", "Should not break the test.zip"); + + match(tests); + } +}; + +QTEST_MAIN(TestGetSearchNames) +#include "test_getsearchnames.moc" diff --git a/test/getsearchnames/test_getsearchnames.pro b/test/getsearchnames/test_getsearchnames.pro new file mode 100644 index 00000000..9a8fc1ee --- /dev/null +++ b/test/getsearchnames/test_getsearchnames.pro @@ -0,0 +1,50 @@ +QT += core network xml testlib +TEMPLATE = app +TARGET = test_getsearchnames +DEPENDPATH += . +INCLUDEPATH += ../../src +CONFIG += debug +QMAKE_CXXFLAGS += -std=c++17 + +CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT + +include(../../VERSION) +DEFINES+=VERSION=\\\"$$VERSION\\\" + +# set if testing against v3.10.3 or earlier +###DEFINES+=VER_3_10_3 + +HEADERS += ../../src/abstractscraper.h \ + ../../src/arcadedb.h \ + ../../src/cli.h \ + ../../src/crc32.h \ + ../../src/esgamelist.h \ + ../../src/gameentry.h \ + ../../src/igdb.h \ + ../../src/mobygames.h \ + ../../src/nametools.h \ + ../../src/netcomm.h \ + ../../src/netmanager.h \ + ../../src/openretro.h \ + ../../src/platform.h \ + ../../src/screenscraper.h \ + ../../src/settings.h \ + ../../src/strtools.h + +SOURCES += test_getsearchnames.cpp \ + ../../src/abstractscraper.cpp \ + ../../src/arcadedb.cpp \ + ../../src/cli.cpp \ + ../../src/crc32.cpp \ + ../../src/esgamelist.cpp \ + ../../src/gameentry.cpp \ + ../../src/igdb.cpp \ + ../../src/mobygames.cpp \ + ../../src/nametools.cpp \ + ../../src/netcomm.cpp \ + ../../src/netmanager.cpp \ + ../../src/openretro.cpp \ + ../../src/platform.cpp \ + ../../src/screenscraper.cpp \ + ../../src/settings.cpp \ + ../../src/strtools.cpp