diff --git a/src/tests/allocinefetchertest.cpp b/src/tests/allocinefetchertest.cpp index 4b42a4c3..cdbffe86 100644 --- a/src/tests/allocinefetchertest.cpp +++ b/src/tests/allocinefetchertest.cpp @@ -1,238 +1,238 @@ /*************************************************************************** Copyright (C) 2010-2012 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #undef QT_NO_CAST_FROM_ASCII #include "allocinefetchertest.h" #include "../fetch/execexternalfetcher.h" #include "../fetch/allocinefetcher.h" #include "../collections/videocollection.h" #include "../collectionfactory.h" #include "../entry.h" #include "../images/imagefactory.h" #include #include #include QTEST_GUILESS_MAIN( AllocineFetcherTest ) AllocineFetcherTest::AllocineFetcherTest() : AbstractFetcherTest() { } void AllocineFetcherTest::initTestCase() { Tellico::RegisterCollection registerVideo(Tellico::Data::Collection::Video, "video"); Tellico::ImageFactory::init(); } void AllocineFetcherTest::cleanupTestCase() { Tellico::ImageFactory::clean(true); } void AllocineFetcherTest::testTitle() { // Allocine script is currently failing return; Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Title, QStringLiteral("Superman Returns")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::ExecExternalFetcher(this)); KConfig config(QFINDTESTDATA("../fetch/scripts/fr.allocine.py.spec"), KConfig::SimpleConfig); KConfigGroup cg = config.group(QStringLiteral("")); cg.writeEntry("ExecPath", QFINDTESTDATA("../fetch/scripts/fr.allocine.py")); // don't sync() and save the new path cg.markAsClean(); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Superman Returns")); QCOMPARE(entry->field(QStringLiteral("director")), QStringLiteral("Bryan Singer")); QCOMPARE(entry->field(QStringLiteral("producer")), QStringLiteral("Jon Peters; Gilbert Adler; Bryan Singer; Lorne Orleans")); QCOMPARE(entry->field(QStringLiteral("studio")), QStringLiteral("Warner Bros. France")); QCOMPARE(entry->field(QStringLiteral("year")), QStringLiteral("2006")); QCOMPARE(entry->field(QStringLiteral("genre")), QStringLiteral("Fantastique; Action")); QCOMPARE(entry->field(QStringLiteral("nationality")), QString::fromUtf8("Américain; Australien")); QCOMPARE(entry->field(QStringLiteral("running-time")), QStringLiteral("154")); QStringList castList = Tellico::FieldFormat::splitTable(entry->field(QStringLiteral("cast"))); QVERIFY(!castList.isEmpty()); QCOMPARE(castList.at(0), QStringLiteral("Brandon Routh::Clark Kent / Superman")); QCOMPARE(castList.size(), 8); QVERIFY(!entry->field(QStringLiteral("plot")).isEmpty()); QVERIFY(!entry->field(QStringLiteral("cover")).isEmpty()); QVERIFY(!entry->field(QStringLiteral("cover")).contains(QLatin1Char('/'))); } void AllocineFetcherTest::testTitleAccented() { // Allocine script is currently failing return; Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Title, QStringLiteral("Opération Tonnerre")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::ExecExternalFetcher(this)); KConfig config(QFINDTESTDATA("../fetch/scripts/fr.allocine.py.spec"), KConfig::SimpleConfig); KConfigGroup cg = config.group(QStringLiteral("")); cg.writeEntry("ExecPath", QFINDTESTDATA("../fetch/scripts/fr.allocine.py")); // don't sync() and save the new path cg.markAsClean(); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QString::fromUtf8("Opération Tonnerre")); QCOMPARE(entry->field(QStringLiteral("titre-original")), QStringLiteral("Thunderball")); - QCOMPARE(entry->field(QStringLiteral("studio")), QStringLiteral("")); + QCOMPARE(entry->field(QStringLiteral("studio")), QString()); } void AllocineFetcherTest::testTitleAccentRemoved() { // Allocine script is currently failing return; Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Title, QStringLiteral("Operation Tonnerre")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::ExecExternalFetcher(this)); KConfig config(QFINDTESTDATA("../fetch/scripts/fr.allocine.py.spec"), KConfig::SimpleConfig); KConfigGroup cg = config.group(QStringLiteral("")); cg.writeEntry("ExecPath", QFINDTESTDATA("../fetch/scripts/fr.allocine.py")); // don't sync() and save the new path cg.markAsClean(); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QString::fromUtf8("Opération Tonnerre")); } void AllocineFetcherTest::testPlotQuote() { // Allocine script is currently failing return; Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Title, QStringLiteral("Goldfinger")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::ExecExternalFetcher(this)); KConfig config(QFINDTESTDATA("../fetch/scripts/fr.allocine.py.spec"), KConfig::SimpleConfig); KConfigGroup cg = config.group(QStringLiteral("")); cg.writeEntry("ExecPath", QFINDTESTDATA("../fetch/scripts/fr.allocine.py")); // don't sync() and save the new path cg.markAsClean(); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Goldfinger")); QVERIFY(!entry->field(QStringLiteral("plot")).contains(QStringLiteral("""))); } void AllocineFetcherTest::testTitleAPI() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QStringLiteral("allocine"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, QStringLiteral("Superman Returns")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AllocineFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Superman Returns")); QCOMPARE(entry->field(QStringLiteral("director")), QStringLiteral("Bryan Singer")); QCOMPARE(entry->field(QStringLiteral("producer")), QStringLiteral("Jon Peters; Gilbert Adler; Bryan Singer; Lorne Orleans")); QCOMPARE(entry->field(QStringLiteral("studio")), QStringLiteral("Warner Bros. France")); QCOMPARE(entry->field(QStringLiteral("year")), QStringLiteral("2006")); QCOMPARE(entry->field(QStringLiteral("genre")), QStringLiteral("Fantastique; Action")); QCOMPARE(entry->field(QStringLiteral("nationality")), QStringLiteral("U.S.A.; Australie")); QCOMPARE(entry->field(QStringLiteral("running-time")), QStringLiteral("154")); QStringList castList = Tellico::FieldFormat::splitTable(entry->field(QStringLiteral("cast"))); QVERIFY(!castList.isEmpty()); QCOMPARE(castList.at(0), QStringLiteral("Brandon Routh::Clark Kent / Superman")); QCOMPARE(castList.size(), 5); QVERIFY(!entry->field(QStringLiteral("plot")).isEmpty()); QVERIFY(!entry->field(QStringLiteral("cover")).isEmpty()); QVERIFY(!entry->field(QStringLiteral("cover")).contains(QLatin1Char('/'))); } void AllocineFetcherTest::testTitleAPIAccented() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QStringLiteral("allocine"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, QStringLiteral("Opération Tonnerre")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AllocineFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QString::fromUtf8("Opération Tonnerre")); QCOMPARE(entry->field(QStringLiteral("origtitle")), QStringLiteral("Thunderball")); - QCOMPARE(entry->field(QStringLiteral("studio")), QStringLiteral("")); + QCOMPARE(entry->field(QStringLiteral("studio")), QString()); QCOMPARE(entry->field(QStringLiteral("director")), QStringLiteral("Terence Young")); QCOMPARE(entry->field(QStringLiteral("color")), QStringLiteral("Color")); QVERIFY(!entry->field(QStringLiteral("allocine")).isEmpty()); } // mentioned in https://bugs.kde.org/show_bug.cgi?id=337432 void AllocineFetcherTest::testGhostDog() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QStringLiteral("allocine"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, QStringLiteral("Ghost Dog: la voie du samourai")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AllocineFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Ghost Dog: la voie du samourai")); } diff --git a/src/tests/dblpfetchertest.cpp b/src/tests/dblpfetchertest.cpp index 63ef3f92..d9916be6 100644 --- a/src/tests/dblpfetchertest.cpp +++ b/src/tests/dblpfetchertest.cpp @@ -1,91 +1,91 @@ /*************************************************************************** Copyright (C) 2012 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #undef QT_NO_CAST_FROM_ASCII #include "dblpfetchertest.h" #include "../fetch/dblpfetcher.h" #include "../collections/bibtexcollection.h" #include "../collectionfactory.h" #include "../entry.h" #include "../utils/datafileregistry.h" #include QTEST_GUILESS_MAIN( DBLPFetcherTest ) DBLPFetcherTest::DBLPFetcherTest() : AbstractFetcherTest() { } void DBLPFetcherTest::initTestCase() { Tellico::RegisterCollection registerBibtex(Tellico::Data::Collection::Bibtex, "bibtex"); Tellico::DataFileRegistry::self()->addDataLocation(QFINDTESTDATA("../../xslt/dblp2tellico.xsl")); } void DBLPFetcherTest::testProceedings() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Keyword, QStringLiteral("Chip and PIN is Broken")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::DBLPFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Chip and PIN is Broken.")); QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("Steven J. Murdoch; Saar Drimer; Ross J. Anderson; Mike Bond")); QCOMPARE(entry->field(QStringLiteral("year")), QStringLiteral("2010")); QCOMPARE(entry->field(QStringLiteral("pages")), QStringLiteral("433-446")); QCOMPARE(entry->field(QStringLiteral("booktitle")), QStringLiteral("IEEE Symposium on Security and Privacy")); - QCOMPARE(entry->field(QStringLiteral("journal")), QStringLiteral("")); + QCOMPARE(entry->field(QStringLiteral("journal")), QString()); QCOMPARE(entry->field(QStringLiteral("url")), QStringLiteral("https://dblp.org/rec/conf/sp/MurdochDAB10")); // QCOMPARE(entry->field(QStringLiteral("doi")), QStringLiteral("10.1109/SP.2010.33")); QCOMPARE(entry->field(QStringLiteral("entry-type")), QStringLiteral("inproceedings")); QCOMPARE(entry->field(QStringLiteral("bibtex-key")), QStringLiteral("MurdochDAB10")); } void DBLPFetcherTest::testArticle() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Keyword, QStringLiteral("Nontrivial independent sets of bipartite graphs")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::DBLPFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Nontrivial independent sets of bipartite graphs and cross-intersecting families.")); QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("Jun Wang; Huajun Zhang")); QCOMPARE(entry->field(QStringLiteral("year")), QStringLiteral("2013")); QCOMPARE(entry->field(QStringLiteral("pages")), QStringLiteral("129-141")); QCOMPARE(entry->field(QStringLiteral("volume")), QStringLiteral("120")); QCOMPARE(entry->field(QStringLiteral("number")), QStringLiteral("1")); QCOMPARE(entry->field(QStringLiteral("journal")), QStringLiteral("J. Comb. Theory, Ser. A")); - QCOMPARE(entry->field(QStringLiteral("booktitle")), QStringLiteral("")); + QCOMPARE(entry->field(QStringLiteral("booktitle")), QString()); QCOMPARE(entry->field(QStringLiteral("url")), QStringLiteral("https://dblp.org/rec/journals/jct/WangZ13")); // QCOMPARE(entry->field(QStringLiteral("doi")), QStringLiteral("10.1016/j.jcta.2012.07.005")); QCOMPARE(entry->field(QStringLiteral("entry-type")), QStringLiteral("article")); QCOMPARE(entry->field(QStringLiteral("bibtex-key")), QStringLiteral("WangZ13")); } diff --git a/src/tests/filelistingtest.cpp b/src/tests/filelistingtest.cpp index 9858eef0..6efe13d2 100644 --- a/src/tests/filelistingtest.cpp +++ b/src/tests/filelistingtest.cpp @@ -1,114 +1,114 @@ /*************************************************************************** Copyright (C) 2015 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #undef QT_NO_CAST_FROM_ASCII #include #include "filelistingtest.h" #include "../translators/filelistingimporter.h" #include "../translators/xmphandler.h" #include "../images/imagefactory.h" #include // KIO::listDir in FileListingImporter seems to require a GUI Application QTEST_MAIN( FileListingTest ) void FileListingTest::initTestCase() { Tellico::ImageFactory::init(); } void FileListingTest::testCpp() { QUrl url = QUrl::fromLocalFile(QFINDTESTDATA("filelistingtest.cpp")); Tellico::Import::FileListingImporter importer(url.adjusted(QUrl::RemoveFilename)); // can't import images for local test // importer.setOptions(importer.options() & ~Tellico::Import::ImportShowImageErrors); Tellico::Data::CollPtr coll = importer.collection(); QVERIFY(coll); QCOMPARE(coll->type(), Tellico::Data::Collection::File); QVERIFY(coll->entryCount() > 0); Tellico::Data::EntryPtr entry; foreach(Tellico::Data::EntryPtr tmpEntry, coll->entries()) { if(tmpEntry->field(QStringLiteral("title")) == QStringLiteral("filelistingtest.cpp")) { entry = tmpEntry; } } QVERIFY(entry); QCOMPARE(entry->field("title"), QStringLiteral("filelistingtest.cpp")); QCOMPARE(entry->field("url"), url.url()); QVERIFY(entry->field("description").contains("C++")); - QCOMPARE(entry->field("folder"), QStringLiteral("")); // empty relative folder location + QCOMPARE(entry->field("folder"), QString()); // empty relative folder location QCOMPARE(entry->field("mimetype"), QStringLiteral("text/x-c++src")); QVERIFY(!entry->field("size").isEmpty()); QVERIFY(!entry->field("permissions").isEmpty()); QVERIFY(!entry->field("owner").isEmpty()); QVERIFY(!entry->field("group").isEmpty()); // for some reason, the Creation time isn't populated for this test // QVERIFY(!entry->field("created").isEmpty()); QVERIFY(!entry->field("modified").isEmpty()); #ifdef HAVE_KFILEMETADATA QCOMPARE(entry->field("metainfo"), QString()); #endif // icon name does not get set for the jenkins build service // QVERIFY(!entry->field("icon").isEmpty()); } void FileListingTest::testXMPData() { { Tellico::XMPHandler xmp; #ifdef HAVE_EXEMPI QVERIFY(xmp.isXMPEnabled()); QVERIFY(!xmp.extractXMP(QFINDTESTDATA("data/BlueSquare.jpg")).isEmpty()); #endif } // initializing exempi can cause a crash in Exiv for files with XMP data // see https://bugs.kde.org/show_bug.cgi?id=390744 QUrl url = QUrl::fromLocalFile(QFINDTESTDATA("data/BlueSquare.jpg")); Tellico::Import::FileListingImporter importer(url.adjusted(QUrl::RemoveFilename)); Tellico::Data::CollPtr coll = importer.collection(); QVERIFY(coll); QCOMPARE(coll->type(), Tellico::Data::Collection::File); QVERIFY(coll->entryCount() > 0); Tellico::Data::EntryPtr entry; foreach(Tellico::Data::EntryPtr tmpEntry, coll->entries()) { if(tmpEntry->field(QStringLiteral("title")) == QStringLiteral("BlueSquare.jpg")) { entry = tmpEntry; } } QVERIFY(entry); QCOMPARE(entry->field("title"), QStringLiteral("BlueSquare.jpg")); QCOMPARE(entry->field("mimetype"), QStringLiteral("image/jpeg")); QCOMPARE(entry->field("size"), QStringLiteral("23.6 KiB")); #ifdef HAVE_KFILEMETADATA #ifdef HAVE_EXEMPI QEXPECT_FAIL("", "Because of a crash related to exempi and kfilemetadata linking, no metadata is read", Continue); #endif QVERIFY(!entry->field("metainfo").isEmpty()); #endif }