File indexing completed on 2024-03-24 04:57:13
0001 /* 0002 SPDX-FileCopyrightText: 2006 Richard Lärkäng <nouseforaname@home.se> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "synchttplookuptest.h" 0008 #include "libkcddb/client.h" 0009 #include "libkcddb/cache.h" 0010 #include "libkcddb/lookup.h" 0011 #include <QTest> 0012 0013 void SyncHTTPLookupTest::testLookup() 0014 { 0015 using namespace KCDDB; 0016 0017 Client c; 0018 c.config().setHostname(QString::fromUtf8("gnudb.gnudb.org")); 0019 c.config().setPort(80); 0020 c.config().setCacheLookupEnabled(false); 0021 c.config().setFreedbLookupEnabled(true); 0022 c.config().setMusicBrainzLookupEnabled(false); 0023 c.config().setFreedbLookupTransport(Lookup::HTTP); 0024 0025 TrackOffsetList list; 0026 0027 list 0028 << 150 0029 << 106965 0030 << 127220 0031 << 151925 0032 << 176085 0033 << 234500; 0034 0035 Result r = c.lookup(list); 0036 0037 QVERIFY(r == Success); 0038 0039 CDInfoList response = c.lookupResponse(); 0040 0041 CDInfoList::ConstIterator it; 0042 0043 bool hasRunTest = false; 0044 0045 for (it = response.constBegin(); it != response.constEnd(); ++it) 0046 { 0047 CDInfo i(*it); 0048 0049 if (i.get(QString::fromUtf8("discid")) == QString::fromUtf8("3e0c3a05") && i.get(Category) == QString::fromUtf8("misc")) 0050 { 0051 // If revision doesn't match, test probably needs to be updated 0052 // See: http://www.gnudb.org/gnudb/misc/3e0c3a05 for updated data 0053 QCOMPARE(i.get(QString::fromUtf8("revision")).toInt(), 17); 0054 0055 QCOMPARE(i.get(Artist).toString(),QString::fromUtf8("Pink Floyd")); 0056 QCOMPARE(i.get(Title).toString(),QString::fromUtf8("Atom Heart Mother")); 0057 QCOMPARE(i.get(Genre).toString(),QString::fromUtf8("Psychedelic Rock")); 0058 QCOMPARE(i.get(Year).toInt(),1970); 0059 QCOMPARE(i.track(0).get(Title).toString(),QString::fromUtf8("Atom Heart Mother: Father's Shout/Breast Milky/Mother Fore/Funky Dung/Mind Your Throats Please/Remergence")); 0060 QCOMPARE(i.track(1).get(Title).toString(),QString::fromUtf8("If")); 0061 QCOMPARE(i.track(2).get(Title).toString(),QString::fromUtf8("Summer '68")); 0062 QCOMPARE(i.track(3).get(Title).toString(),QString::fromUtf8("Fat Old Sun")); 0063 QCOMPARE(i.track(4).get(Title).toString(),QString::fromUtf8("Alan's Psychedelic Breakfast: Rise and Shine/Sunny Side Up/Morning Glory")); 0064 QCOMPARE(i.track(0).get(Comment).toString(),QString::fromUtf8("")); 0065 QCOMPARE(i.track(1).get(Comment).toString(),QString::fromUtf8("")); 0066 QCOMPARE(i.track(2).get(Comment).toString(),QString::fromUtf8("")); 0067 QCOMPARE(i.track(3).get(Comment).toString(),QString::fromUtf8("")); 0068 QCOMPARE(i.track(4).get(Comment).toString(),QString::fromUtf8("")); 0069 for (int j=0; j <= 4; j++) 0070 { 0071 QCOMPARE(i.track(j).get(Artist).toString(),QString::fromUtf8("Pink Floyd")); 0072 } 0073 0074 hasRunTest = true; 0075 } 0076 } 0077 0078 QVERIFY(hasRunTest); 0079 } 0080 0081 QTEST_GUILESS_MAIN(SyncHTTPLookupTest) 0082 0083 #include "moc_synchttplookuptest.cpp"