summaryrefslogtreecommitdiffstats
path: root/libkcddb/test
diff options
context:
space:
mode:
Diffstat (limited to 'libkcddb/test')
-rw-r--r--libkcddb/test/Makefile.am48
-rw-r--r--libkcddb/test/asynccddblookuptest.cpp113
-rw-r--r--libkcddb/test/asynccddblookuptest.h27
-rw-r--r--libkcddb/test/asynchttplookuptest.cpp111
-rw-r--r--libkcddb/test/asynchttplookuptest.h27
-rw-r--r--libkcddb/test/asynchttpsubmittest.cpp80
-rw-r--r--libkcddb/test/asynchttpsubmittest.h25
-rw-r--r--libkcddb/test/asyncsmtpsubmittest.cpp81
-rw-r--r--libkcddb/test/asyncsmtpsubmittest.h25
-rw-r--r--libkcddb/test/sitestest.cpp47
-rw-r--r--libkcddb/test/synccddblookuptest.cpp84
-rw-r--r--libkcddb/test/synchttplookuptest.cpp84
-rw-r--r--libkcddb/test/synchttpsubmittest.cpp79
-rw-r--r--libkcddb/test/syncsmtpsubmittest.cpp81
-rw-r--r--libkcddb/test/utf8test.cpp50
15 files changed, 962 insertions, 0 deletions
diff --git a/libkcddb/test/Makefile.am b/libkcddb/test/Makefile.am
new file mode 100644
index 00000000..ab814db4
--- /dev/null
+++ b/libkcddb/test/Makefile.am
@@ -0,0 +1,48 @@
+INCLUDES = -I$(top_srcdir) -I$(top_builddir)/libkcddb $(all_includes)
+
+check_PROGRAMS = syncsmtpsubmittest asyncsmtpsubmittest asynchttplookuptest \
+ asynccddblookuptest synccddblookuptest synchttplookuptest \
+ asynchttpsubmittest synchttpsubmittest sitestest utf8test
+
+syncsmtpsubmittest_SOURCES = syncsmtpsubmittest.cpp
+syncsmtpsubmittest_LDFLAGS = $(all_libraries)
+syncsmtpsubmittest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+asyncsmtpsubmittest_SOURCES = asyncsmtpsubmittest.cpp
+asyncsmtpsubmittest_LDFLAGS = $(all_libraries)
+asyncsmtpsubmittest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+asynchttplookuptest_SOURCES = asynchttplookuptest.cpp
+asynchttplookuptest_LDFLAGS = $(all_libraries)
+asynchttplookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+asynccddblookuptest_SOURCES = asynccddblookuptest.cpp
+asynccddblookuptest_LDFLAGS = $(all_libraries)
+asynccddblookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+synchttplookuptest_SOURCES = synchttplookuptest.cpp
+synchttplookuptest_LDFLAGS = $(all_libraries)
+synchttplookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+synccddblookuptest_SOURCES = synccddblookuptest.cpp
+synccddblookuptest_LDFLAGS = $(all_libraries)
+synccddblookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+synchttpsubmittest_SOURCES = synchttpsubmittest.cpp
+synchttpsubmittest_LDFLAGS = $(all_libraries)
+synchttpsubmittest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+asynchttpsubmittest_SOURCES = asynchttpsubmittest.cpp
+asynchttpsubmittest_LDFLAGS = $(all_libraries)
+asynchttpsubmittest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+utf8test_SOURCES = utf8test.cpp
+utf8test_LDFLAGS = $(all_libraries)
+utf8test_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+sitestest_SOURCES = sitestest.cpp
+sitestest_LDFLAGS = $(all_libraries)
+sitestest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
+
+METASOURCES = AUTO
+
diff --git a/libkcddb/test/asynccddblookuptest.cpp b/libkcddb/test/asynccddblookuptest.cpp
new file mode 100644
index 00000000..afbd326a
--- /dev/null
+++ b/libkcddb/test/asynccddblookuptest.cpp
@@ -0,0 +1,113 @@
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+
+#include "asynccddblookuptest.h"
+
+#include "libkcddb/cache.h"
+#include "libkcddb/lookup.h"
+
+AsyncCDDBLookupTest::AsyncCDDBLookupTest()
+ : QObject()
+{
+ using namespace KCDDB;
+
+ client_ = new Client;
+ client_->config().setHostname("freedb.freedb.org");
+ client_->config().setPort(8880);
+ client_->config().setCachePolicy(Cache::Ignore);
+ client_->config().setLookupTransport(Lookup::CDDBP);
+ 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);
+}
+
+AsyncCDDBLookupTest::~AsyncCDDBLookupTest()
+{
+ delete client_;
+}
+
+ void
+AsyncCDDBLookupTest::slotFinished(CDDB::Result r)
+{
+ kdDebug() << "AsyncCDDBLookupTest::slotResult: Got " << KCDDB::CDDB::resultToString(r) << endl;
+
+ CDInfoList l = client_->lookupResponse();
+
+ kdDebug() << "AsyncCDDBLookupTest::slotResult: 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 */);
+
+ AsyncCDDBLookupTest test;
+
+ return app.exec();
+}
+
+#include "asynccddblookuptest.moc"
diff --git a/libkcddb/test/asynccddblookuptest.h b/libkcddb/test/asynccddblookuptest.h
new file mode 100644
index 00000000..5e0a3efb
--- /dev/null
+++ b/libkcddb/test/asynccddblookuptest.h
@@ -0,0 +1,27 @@
+#ifndef TEST_H
+#define TEST_H
+
+#include <qobject.h>
+#include <libkcddb/client.h>
+
+using namespace KCDDB;
+
+class AsyncCDDBLookupTest : public QObject
+{
+ Q_OBJECT
+
+ public:
+
+ AsyncCDDBLookupTest();
+ ~AsyncCDDBLookupTest();
+
+ public slots:
+
+ void slotFinished(CDDB::Result);
+
+ private:
+
+ KCDDB::Client * client_;
+};
+
+#endif
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"
diff --git a/libkcddb/test/asynchttplookuptest.h b/libkcddb/test/asynchttplookuptest.h
new file mode 100644
index 00000000..c8e3e86c
--- /dev/null
+++ b/libkcddb/test/asynchttplookuptest.h
@@ -0,0 +1,27 @@
+#ifndef TEST_H
+#define TEST_H
+
+#include <qobject.h>
+#include <libkcddb/client.h>
+
+using namespace KCDDB;
+
+class AsyncHTTPLookupTest : public QObject
+{
+ Q_OBJECT
+
+ public:
+
+ AsyncHTTPLookupTest();
+ ~AsyncHTTPLookupTest();
+
+ public slots:
+
+ void slotFinished(CDDB::Result);
+
+ private:
+
+ KCDDB::Client * client_;
+};
+
+#endif
diff --git a/libkcddb/test/asynchttpsubmittest.cpp b/libkcddb/test/asynchttpsubmittest.cpp
new file mode 100644
index 00000000..9981f8a7
--- /dev/null
+++ b/libkcddb/test/asynchttpsubmittest.cpp
@@ -0,0 +1,80 @@
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+
+#include "asynchttpsubmittest.h"
+#include "libkcddb/submit.h"
+
+AsyncHTTPSubmitTest::AsyncHTTPSubmitTest()
+ : QObject()
+{
+ using namespace KCDDB;
+
+ client_ = new Client;
+ client_->config().setSubmitTransport(Submit::HTTP);
+ client_->setBlockingMode( false );
+
+ TrackOffsetList list;
+
+ list
+ << 150 // First track start.
+ << 2592
+ << 35472
+ << 47891
+ << 123310
+ << 150 // Disc start.
+ << 133125; // Disc end.
+
+ CDInfo cdInfo;
+
+ cdInfo.id = "3606ed05";
+ cdInfo.revision = 4;
+ cdInfo.title = "Bamse och Bronto";
+ cdInfo.artist = "Musiksage";
+ cdInfo.year = 2001;
+ cdInfo.category = "misc";
+ cdInfo.genre = "Barnsaga";
+ cdInfo.extd = QString::fromUtf8("Berättare: Olof Thunberg");
+
+ TrackInfo info;
+ info.title = "Bamses signaturmelodi";
+ cdInfo.trackInfoList.append(info);
+ info.title = "*";
+ cdInfo.trackInfoList.append(info);
+ info.title = "Brummavisan";
+ cdInfo.trackInfoList.append(info);
+ info.title = "*";
+ cdInfo.trackInfoList.append(info);
+ info.title = QString::fromUtf8("Jätteödlan Bronto");
+ cdInfo.trackInfoList.append(info);
+
+ connect
+ (
+ client_,
+ SIGNAL(finished(CDDB::Result)),
+ SLOT(slotFinished(CDDB::Result))
+ );
+
+ client_->submit(cdInfo, list);
+}
+
+ void
+AsyncHTTPSubmitTest::slotFinished(CDDB::Result r)
+{
+ kdDebug() << "AsyncHTTPSubmitTest::slotFinished: Got " << KCDDB::CDDB::resultToString(r) << endl;
+
+ kapp->quit();
+}
+
+int main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app(false /* No styles */, false /* No GUI */);
+
+ new AsyncHTTPSubmitTest;
+
+ return app.exec();
+}
+
+#include "asynchttpsubmittest.moc"
diff --git a/libkcddb/test/asynchttpsubmittest.h b/libkcddb/test/asynchttpsubmittest.h
new file mode 100644
index 00000000..27053836
--- /dev/null
+++ b/libkcddb/test/asynchttpsubmittest.h
@@ -0,0 +1,25 @@
+#ifndef TEST_H
+#define TEST_H
+
+#include <qobject.h>
+#include <libkcddb/client.h>
+
+using namespace KCDDB;
+
+class AsyncHTTPSubmitTest : public QObject
+{
+ Q_OBJECT
+
+ public:
+ AsyncHTTPSubmitTest();
+
+ public slots:
+
+ void slotFinished(CDDB::Result);
+
+ private:
+
+ KCDDB::Client * client_;
+};
+
+#endif
diff --git a/libkcddb/test/asyncsmtpsubmittest.cpp b/libkcddb/test/asyncsmtpsubmittest.cpp
new file mode 100644
index 00000000..224288e3
--- /dev/null
+++ b/libkcddb/test/asyncsmtpsubmittest.cpp
@@ -0,0 +1,81 @@
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+
+#include "asyncsmtpsubmittest.h"
+#include "libkcddb/submit.h"
+
+AsyncSMTPSubmitTest::AsyncSMTPSubmitTest()
+ : QObject()
+{
+ using namespace KCDDB;
+
+ client_ = new Client;
+ client_->config().setSubmitTransport(Submit::SMTP);
+ client_->config().setSubmitAddress("test-submit@freedb.org");
+ client_->setBlockingMode( false );
+
+ TrackOffsetList list;
+
+ list
+ << 150 // First track start.
+ << 2592
+ << 35472
+ << 47891
+ << 123310
+ << 150 // Disc start.
+ << 133125; // Disc end.
+
+ CDInfo cdInfo;
+
+ cdInfo.id = "3606ed05";
+ cdInfo.revision = 4;
+ cdInfo.title = "Bamse och Bronto";
+ cdInfo.artist = "Musiksage";
+ cdInfo.year = 2001;
+ cdInfo.category = "misc";
+ cdInfo.genre = "Barnsaga";
+ cdInfo.extd = QString::fromUtf8("Berättare: Olof Thunberg");
+
+ TrackInfo info;
+ info.title = "Bamses signaturmelodi";
+ cdInfo.trackInfoList.append(info);
+ info.title = "*";
+ cdInfo.trackInfoList.append(info);
+ info.title = "Brummavisan";
+ cdInfo.trackInfoList.append(info);
+ info.title = "*";
+ cdInfo.trackInfoList.append(info);
+ info.title = QString::fromUtf8("Jätteödlan Bronto");
+ cdInfo.trackInfoList.append(info);
+
+ connect
+ (
+ client_,
+ SIGNAL(finished(CDDB::Result)),
+ SLOT(slotFinished(CDDB::Result))
+ );
+
+ client_->submit(cdInfo, list);
+}
+
+ void
+AsyncSMTPSubmitTest::slotFinished(CDDB::Result r)
+{
+ kdDebug() << "AsyncSMTPSubmitTest::slotFinished: Got " << KCDDB::CDDB::resultToString(r) << endl;
+
+ kapp->quit();
+}
+
+int main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app(false /* No styles */, false /* No GUI */);
+
+ new AsyncSMTPSubmitTest;
+
+ return app.exec();
+}
+
+#include "asyncsmtpsubmittest.moc"
diff --git a/libkcddb/test/asyncsmtpsubmittest.h b/libkcddb/test/asyncsmtpsubmittest.h
new file mode 100644
index 00000000..3528798d
--- /dev/null
+++ b/libkcddb/test/asyncsmtpsubmittest.h
@@ -0,0 +1,25 @@
+#ifndef TEST_H
+#define TEST_H
+
+#include <qobject.h>
+#include <libkcddb/client.h>
+
+using namespace KCDDB;
+
+class AsyncSMTPSubmitTest : public QObject
+{
+ Q_OBJECT
+
+ public:
+ AsyncSMTPSubmitTest();
+
+ public slots:
+
+ void slotFinished(CDDB::Result);
+
+ private:
+
+ KCDDB::Client * client_;
+};
+
+#endif
diff --git a/libkcddb/test/sitestest.cpp b/libkcddb/test/sitestest.cpp
new file mode 100644
index 00000000..3876ae2c
--- /dev/null
+++ b/libkcddb/test/sitestest.cpp
@@ -0,0 +1,47 @@
+/*
+ Copyright (C) 2003 Richard Lärkäng <nouseforaname@home.se>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+
+#include "libkcddb/sites.h"
+
+ int
+main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app(false /* No styles */);
+
+ using namespace KCDDB;
+
+ Sites s;
+
+ kdDebug() << "Sites: " << endl;
+
+ QValueList<Mirror> sites = s.siteList();
+ for (QValueList<Mirror>::Iterator it = sites.begin(); it != sites.end(); ++it)
+ if ((*it).transport == Lookup::CDDBP)
+ kdDebug() << (*it).address << " CDDBP " << (*it).port << " " << (*it).description << endl;
+ else
+ kdDebug() << (*it).address << " HTTP " << (*it).port << " " << (*it).description << endl;
+
+ return 0;
+}
diff --git a/libkcddb/test/synccddblookuptest.cpp b/libkcddb/test/synccddblookuptest.cpp
new file mode 100644
index 00000000..0b71e864
--- /dev/null
+++ b/libkcddb/test/synccddblookuptest.cpp
@@ -0,0 +1,84 @@
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+
+#include "libkcddb/client.h"
+#include "libkcddb/cache.h"
+#include "libkcddb/lookup.h"
+
+
+ int
+main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app(false /* No styles */, false /* No GUI */);
+
+ using namespace KCDDB;
+
+ Client c;
+ c.config().setHostname("freedb.freedb.org");
+ c.config().setPort(8880);
+ c.config().setCachePolicy(Cache::Ignore);
+ c.config().setLookupTransport(Lookup::CDDBP);
+
+ 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.
+ list
+ << 150
+ << 106965
+ << 127220
+ << 151925
+ << 176085
+ << 5
+ << 234500;
+
+ kdDebug() << "Stuff to send to server:" << endl;
+
+ kdDebug()
+ << CDDB::trackOffsetListToId(list)
+ << " "
+ //<< trackOffsetListToString(list)
+ << endl;
+
+ CDDB::Result r = c.lookup(list);
+
+ kdDebug() << "Client::lookup gave : " << CDDB::resultToString(r) << endl;
+
+ CDInfoList response = c.lookupResponse();
+
+ kdDebug() << "Client::lookup returned : " << response.count() << " entries"
+ << endl;
+
+ CDInfoList::ConstIterator it;
+
+ for (it = response.begin(); it != response.end(); ++it)
+ {
+ CDInfo i(*it);
+
+ kdDebug() << "Disc title: " << i.title << endl;
+ kdDebug() << "Total tracks: " << i.trackInfoList.count() << endl;
+ kdDebug() << "Disc revision: `" << i.revision << "'" << endl;
+ }
+
+ CDInfo i( c.bestLookupResponse() );
+
+ kdDebug() << "Best CDInfo had title: " << i.title << endl;
+ kdDebug() << "and revision: " << i.revision << endl;
+
+ return 0;
+}
diff --git a/libkcddb/test/synchttplookuptest.cpp b/libkcddb/test/synchttplookuptest.cpp
new file mode 100644
index 00000000..8bc05c18
--- /dev/null
+++ b/libkcddb/test/synchttplookuptest.cpp
@@ -0,0 +1,84 @@
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+
+#include "libkcddb/client.h"
+#include "libkcddb/cache.h"
+#include "libkcddb/lookup.h"
+
+ int
+main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app(false /* No styles */);
+
+ using namespace KCDDB;
+
+ Client c;
+ c.config().setHostname("freedb.freedb.org");
+ c.config().setPort(80);
+ c.config().setCachePolicy(Cache::Ignore);
+ c.config().setLookupTransport(Lookup::HTTP);
+
+
+ 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.
+ list
+ << 150
+ << 106965
+ << 127220
+ << 151925
+ << 176085
+ << 5
+ << 234500;
+
+ kdDebug() << "Stuff to send to server:" << endl;
+
+ kdDebug()
+ << CDDB::trackOffsetListToId(list)
+ << " "
+ //<< trackOffsetListToString(list)
+ << endl;
+
+ CDDB::Result r = c.lookup(list);
+
+ kdDebug() << "Client::lookup gave : " << CDDB::resultToString(r) << endl;
+
+ CDInfoList response = c.lookupResponse();
+
+ kdDebug() << "Client::lookup returned : " << response.count() << " entries"
+ << endl;
+
+ CDInfoList::ConstIterator it;
+
+ for (it = response.begin(); it != response.end(); ++it)
+ {
+ CDInfo i(*it);
+
+ kdDebug() << "Disc title: " << i.title << endl;
+ kdDebug() << "Total tracks: " << i.trackInfoList.count() << endl;
+ kdDebug() << "Disc revision: `" << i.revision << "'" << endl;
+ }
+
+ CDInfo i( c.bestLookupResponse() );
+
+ kdDebug() << "Best CDInfo had title: " << i.title << endl;
+ kdDebug() << "and revision: " << i.revision << endl;
+
+ return 0;
+}
diff --git a/libkcddb/test/synchttpsubmittest.cpp b/libkcddb/test/synchttpsubmittest.cpp
new file mode 100644
index 00000000..67c42dac
--- /dev/null
+++ b/libkcddb/test/synchttpsubmittest.cpp
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2003 Richard Lärkäng <nouseforaname@home.se>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+
+#include "libkcddb/client.h"
+#include "libkcddb/config.h"
+#include "libkcddb/submit.h"
+
+ int
+main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app(false /* No styles */);
+
+ using namespace KCDDB;
+
+ TrackOffsetList list;
+
+ list
+ << 150 // First track start.
+ << 2592
+ << 35472
+ << 47891
+ << 123310
+ << 150 // Disc start.
+ << 133125; // Disc end.
+
+ CDInfo cdInfo;
+
+ cdInfo.id = "3606ed05";
+ cdInfo.revision = 4;
+ cdInfo.title = "Bamse och Bronto";
+ cdInfo.artist = "Musiksage";
+ cdInfo.year = 2001;
+ cdInfo.category = "misc";
+ cdInfo.genre = "Barnsaga";
+ cdInfo.extd = QString::fromUtf8("Berättare: Olof Thunberg");
+
+ TrackInfo info;
+ info.title = "Bamses signaturmelodi";
+ cdInfo.trackInfoList.append(info);
+ info.title = "*";
+ cdInfo.trackInfoList.append(info);
+ info.title = "Brummavisan";
+ cdInfo.trackInfoList.append(info);
+ info.title = "*";
+ cdInfo.trackInfoList.append(info);
+ info.title = QString::fromUtf8("Jätteödlan Bronto");
+ cdInfo.trackInfoList.append(info);
+
+ Client c;
+ c.config().setSubmitTransport(Submit::HTTP);
+ c.setBlockingMode( true );
+
+ CDDB::Result r = c.submit(cdInfo, list);
+
+ kdDebug() << "Result: " << CDDB::resultToString(r) << endl;
+}
+
diff --git a/libkcddb/test/syncsmtpsubmittest.cpp b/libkcddb/test/syncsmtpsubmittest.cpp
new file mode 100644
index 00000000..1d608dda
--- /dev/null
+++ b/libkcddb/test/syncsmtpsubmittest.cpp
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2003 Richard Lärkäng <nouseforaname@home.se>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+
+#include "libkcddb/client.h"
+#include "libkcddb/config.h"
+#include "libkcddb/submit.h"
+
+ int
+main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app(false /* No styles */);
+
+ using namespace KCDDB;
+
+ TrackOffsetList list;
+
+ list
+ << 150 // First track start.
+ << 2592
+ << 35472
+ << 47891
+ << 123310
+ << 150 // Disc start.
+ << 133125; // Disc end.
+
+ CDInfo cdInfo;
+
+ cdInfo.id = "3606ed05";
+ cdInfo.revision = 4;
+ cdInfo.title = "Bamse och Bronto";
+ cdInfo.artist = "Musiksage";
+ cdInfo.year = 2001;
+ cdInfo.category = "misc";
+ cdInfo.genre = "Barnsaga";
+ cdInfo.extd = QString::fromUtf8("Berättare: Olof Thunberg");
+
+ TrackInfo info;
+ info.title = "Bamses signaturmelodi";
+ cdInfo.trackInfoList.append(info);
+ info.title = "*";
+ cdInfo.trackInfoList.append(info);
+ info.title = "Brummavisan";
+ cdInfo.trackInfoList.append(info);
+ info.title = "*";
+ cdInfo.trackInfoList.append(info);
+ info.title = QString::fromUtf8("Jätteödlan Bronto");
+ cdInfo.trackInfoList.append(info);
+
+ Client c;
+ c.config().setSubmitTransport(Submit::SMTP);
+ c.config().setSubmitAddress("test-submit@freedb.org");
+
+ c.setBlockingMode( true );
+
+ CDDB::Result r = c.submit(cdInfo, list);
+
+ kdDebug() << "Result: " << CDDB::resultToString(r) << endl;
+}
+
diff --git a/libkcddb/test/utf8test.cpp b/libkcddb/test/utf8test.cpp
new file mode 100644
index 00000000..05d8b83e
--- /dev/null
+++ b/libkcddb/test/utf8test.cpp
@@ -0,0 +1,50 @@
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+
+#include "libkcddb/client.h"
+#include "libkcddb/cache.h"
+#include "libkcddb/lookup.h"
+
+ int
+main(int argc, char ** argv)
+{
+ KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
+
+ KApplication app;
+
+ using namespace KCDDB;
+
+ Client c;
+
+ TrackOffsetList list;
+
+ list
+ << 150
+ << 61408
+ << 0
+ << 177675;
+
+ kdDebug() << "Stuff to send to server:" << endl;
+
+ kdDebug()
+ << CDDB::trackOffsetListToId(list)
+ << " "
+ //<< trackOffsetListToString(list)
+ << endl;
+
+ CDDB::Result r = c.lookup(list);
+
+ kdDebug() << "Client::lookup gave : " << CDDB::resultToString(r) << endl;
+
+ CDInfoList response = c.lookupResponse();
+
+ kdDebug() << "Client::lookup returned : " << response.count() << " entries"
+ << endl;
+
+ CDInfo i( c.bestLookupResponse() );
+
+ kdDebug() << "Best CDInfo had title: " << i.title << endl;
+
+ return 0;
+}