File indexing completed on 2024-05-12 05:10:03
0001 /*************************************************************************** 0002 Copyright (C) 2017 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #undef QT_NO_CAST_FROM_ASCII 0026 0027 #include "kinofetchertest.h" 0028 0029 #include "../fetch/kinofetcher.h" 0030 #include "../entry.h" 0031 #include "../collections/videocollection.h" 0032 #include "../collectionfactory.h" 0033 #include "../images/imagefactory.h" 0034 #include "../fieldformat.h" 0035 #include "../fetch/fetcherjob.h" 0036 0037 #include <QTest> 0038 0039 QTEST_GUILESS_MAIN( KinoFetcherTest ) 0040 0041 KinoFetcherTest::KinoFetcherTest() : AbstractFetcherTest() { 0042 } 0043 0044 void KinoFetcherTest::initTestCase() { 0045 Tellico::ImageFactory::init(); 0046 Tellico::RegisterCollection<Tellico::Data::VideoCollection> registerVideo(Tellico::Data::Collection::Video, "video"); 0047 } 0048 0049 void KinoFetcherTest::testTitle() { 0050 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Title, QStringLiteral("Superman Returns")); 0051 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::KinoFetcher(this)); 0052 0053 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0054 0055 QCOMPARE(results.size(), 1); 0056 0057 // the first entry had better be the right one 0058 Tellico::Data::EntryPtr entry = results.at(0); 0059 0060 QCOMPARE(entry->field("title"), QStringLiteral("Superman Returns")); 0061 QCOMPARE(entry->field("year"), QStringLiteral("2006")); 0062 QCOMPARE(set(entry, "genre"), set("Superhelden-Film; Comicverfilmung; Fantasyfilm; Actionfilm")); 0063 // QCOMPARE(entry->field("director"), QStringLiteral("Bryan Singer")); 0064 QStringList castList = Tellico::FieldFormat::splitTable(entry->field(QStringLiteral("cast"))); 0065 // QCOMPARE(castList.size(), 8); 0066 // QCOMPARE(castList.at(0), QStringLiteral("Brandon Routh")); 0067 QCOMPARE(entry->field("nationality"), QStringLiteral("USA")); 0068 QCOMPARE(entry->field("studio"), QStringLiteral("Warner")); 0069 QCOMPARE(entry->field("running-time"), QStringLiteral("154")); 0070 QCOMPARE(entry->field("certification"), QStringLiteral("FSK 12 (DE)")); 0071 QVERIFY(!entry->field("plot").isEmpty()); 0072 QVERIFY(!entry->field("cover").isEmpty()); 0073 QVERIFY(!entry->field(QStringLiteral("cover")).contains(QLatin1Char('/'))); 0074 }