summaryrefslogtreecommitdiffstats
path: root/libkcddb/test/asynchttplookuptest.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch)
tree9047cf9e6b5c43878d5bf82660adae77ceee097a /libkcddb/test/asynchttplookuptest.cpp
downloadtdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz
tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkcddb/test/asynchttplookuptest.cpp')
-rw-r--r--libkcddb/test/asynchttplookuptest.cpp111
1 files changed, 111 insertions, 0 deletions
diff --git a/libkcddb/test/asynchttplookuptest.cpp b/libkcddb/test/asynchttplookuptest.cpp
new file mode 100644
index 00000000..610d9fab
--- /dev/null
+++ b/libkcddb/test/asynchttplookuptest.cpp
@@ -0,0 +1,111 @@
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+
+#include "asynchttplookuptest.h"
+#include "libkcddb/cache.h"
+#include "libkcddb/lookup.h"
+
+AsyncHTTPLookupTest::AsyncHTTPLookupTest()
+ : QObject()
+{
+ using namespace KCDDB;
+
+ client_ = new Client;
+ client_->config().setHostname("freedb.freedb.org");
+ client_->config().setPort(80);
+ client_->config().setCachePolicy(Cache::Ignore);
+ client_->config().setLookupTransport(Lookup::HTTP);
+ client_->setBlockingMode( false );
+
+ connect
+ (
+ client_,
+ SIGNAL(finished(CDDB::Result)),
+ SLOT(slotFinished(CDDB::Result))
+ );
+
+ TrackOffsetList list;
+
+ // a1107d0a - Kruder & Dorfmeister - The K&D Sessions - Disc One.
+ list
+ << 150 // First track start.
+ << 29462
+ << 66983
+ << 96785
+ << 135628
+ << 168676
+ << 194147
+ << 222158
+ << 247076
+ << 278203 // Last track start.
+ << 10 // Disc start.
+ << 316732; // Disc end.
+
+ client_->lookup(list);
+}
+
+AsyncHTTPLookupTest::~AsyncHTTPLookupTest()
+{
+ delete client_;
+}
+
+ void
+AsyncHTTPLookupTest::slotFinished(CDDB::Result r)
+{
+ kdDebug() << "AsyncHTTPLookupTest::slotFinished: Got " << KCDDB::CDDB::resultToString(r) << endl;
+
+ CDInfoList l = client_->lookupResponse();
+
+ kdDebug() << "AsyncHTTPLookupTest::slotFinished: Item count: " << l.count() << endl;
+
+ for (CDInfoList::ConstIterator it(l.begin()); it != l.end(); ++it)
+ {
+ CDInfo i(*it);
+
+ kdDebug() << "Disc artist: `" << i.artist << "'" << endl;
+ kdDebug() << "Disc title: `" << i.title << "'" << endl;
+ kdDebug() << "Disc revision: `" << i.revision << "'" << endl;
+ }
+
+ if (!l.isEmpty())
+ {
+ kdDebug() << "---------------------------------------" << endl;
+ kdDebug() << "Showing first item" << endl;
+
+ CDInfo i(l.first());
+
+ kdDebug() << "Disc artist: `" << i.artist << "'" << endl;
+ kdDebug() << "Disc title: `" << i.title << "'" << endl;
+ kdDebug() << "Disc genre: `" << i.genre << "'" << endl;
+ kdDebug() << "Disc year: `" << i.year << "'" << endl;
+ kdDebug() << "Disc length: `" << i.length << "'" << endl;
+ kdDebug() << "Disc id: `" << i.id << "'" << endl;
+ kdDebug() << "Tracks........" << endl;
+
+ for (TrackInfoList::ConstIterator it(i.trackInfoList.begin()); it != i.trackInfoList.end(); ++it)
+ {
+ kdDebug() << " Track: `" << (*it).title << "'" << endl;
+ }
+ kdDebug() << "---------------------------------------" << endl;
+ }
+ CDInfo i( client_->bestLookupResponse() );
+
+ kdDebug() << "Best CDInfo had title: " << i.title << endl;
+ kdDebug() << "and revision: " << i.revision << endl;
+
+ kapp->quit();
+}
+
+int main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app(false /* No styles */, false /* No GUI */);
+
+ AsyncHTTPLookupTest a;
+
+ return app.exec();
+}
+
+#include "asynchttplookuptest.moc"