Commit c8d773b4 authored by Richard Lärkäng's avatar Richard Lärkäng
Browse files

Change the last two lookup-tests to use QtTestLib

Add licence where missing

svn path=/trunk/KDE/kdemultimedia/libkcddb/; revision=529153
parent d618e941
......@@ -23,7 +23,7 @@ if(KDE4_BUILD_TESTS)
set(asynccddblookuptest_SRCS asynccddblookuptest.cpp )
kde4_automoc(${asynccddblookuptest_SRCS})
kde4_add_executable(asynccddblookuptest RUN_UNINSTALLED ${asynccddblookuptest_SRCS})
target_link_libraries(asynccddblookuptest ${KDE4_KDECORE_LIBS} kcddb )
target_link_libraries(asynccddblookuptest ${KDE4_KDECORE_LIBS} kcddb QtTest_debug )
set(synccddblookuptest_SRCS synccddblookuptest.cpp )
kde4_automoc(${synccddblookuptest_SRCS})
......@@ -33,7 +33,7 @@ if(KDE4_BUILD_TESTS)
set(synchttplookuptest_SRCS synchttplookuptest.cpp )
kde4_automoc(${synchttplookuptest_SRCS})
kde4_add_executable(synchttplookuptest RUN_UNINSTALLED ${synchttplookuptest_SRCS})
target_link_libraries(synchttplookuptest ${KDE4_KDECORE_LIBS} kcddb )
target_link_libraries(synchttplookuptest ${KDE4_KDECORE_LIBS} kcddb QtTest_debug )
set(asynchttpsubmittest_SRCS asynchttpsubmittest.cpp )
kde4_automoc(${asynchttpsubmittest_SRCS})
......
......@@ -21,11 +21,11 @@ asynchttplookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la -lQtTest_debug
asynccddblookuptest_SOURCES = asynccddblookuptest.cpp
asynccddblookuptest_LDFLAGS = $(all_libraries)
asynccddblookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
asynccddblookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la -lQtTest_debug
synchttplookuptest_SOURCES = synchttplookuptest.cpp
synchttplookuptest_LDFLAGS = $(all_libraries)
synchttplookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la
synchttplookuptest_LDADD = $(top_builddir)/libkcddb/libkcddb.la -lQtTest_debug
synccddblookuptest_SOURCES = synccddblookuptest.cpp
synccddblookuptest_LDFLAGS = $(all_libraries)
......
#include <kdebug.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
/*
Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <qtest_kde.h>
#include "asynccddblookuptest.h"
#include "libkcddb/cache.h"
#include "libkcddb/lookup.h"
AsyncCDDBLookupTest::AsyncCDDBLookupTest()
: QObject()
void AsyncCDDBLookupTest::testLookup()
{
using namespace KCDDB;
......@@ -43,11 +57,39 @@ AsyncCDDBLookupTest::AsyncCDDBLookupTest()
<< 316732; // Disc end.
client_->lookup(list);
}
AsyncCDDBLookupTest::~AsyncCDDBLookupTest()
{
m_eventLoop.exec(QEventLoop::ExcludeUserInput);
delete client_;
// If revision doesn't match, test probably needs to be updated
// See: http://www.freedb.org/freedb/jazz/a1107d0a for updated data
QCOMPARE(m_info.get("revision").toInt(), 3);
QCOMPARE(m_info.get(Artist).toString(),QString("Various"));
QCOMPARE(m_info.get(Title).toString(),QString("The K&D Sessions [disc 1]"));
QCOMPARE(m_info.get(Genre).toString(),QString("Trip-Hop"));
QCOMPARE(m_info.get(Year).toInt(),1998);
QCOMPARE(m_info.track(0).get(Title).toString(),QString("Heroes [kruder's long loose bossa]"));
QCOMPARE(m_info.track(1).get(Title).toString(),QString("Jazz Master [k&d session]"));
QCOMPARE(m_info.track(2).get(Title).toString(),QString("Speechless [drum 'n' bass]"));
QCOMPARE(m_info.track(3).get(Title).toString(),QString("Going Under [main version - k&d session]"));
QCOMPARE(m_info.track(4).get(Title).toString(),QString("Bug Powder Dust [k&d session]"));
QCOMPARE(m_info.track(5).get(Title).toString(),QString("Rollin' On Chrome [wild motherfucker dub]"));
QCOMPARE(m_info.track(6).get(Title).toString(),QString("Useless [k&d session]"));
QCOMPARE(m_info.track(7).get(Title).toString(),QString("Gotta Jazz [dorfmeister remix]"));
QCOMPARE(m_info.track(8).get(Title).toString(),QString::fromUtf8("Donaueschingen [peter kruder's donaudampfschifffahrtsgesellschaftskapitänskajütenremix]"));
QCOMPARE(m_info.track(9).get(Title).toString(),QString("Trans Fatty Acid [k&d session]"));
QCOMPARE(m_info.track(0).get(Artist).toString(),QString("Roni Size"));
QCOMPARE(m_info.track(1).get(Artist).toString(),QString("Alex Reece"));
QCOMPARE(m_info.track(2).get(Artist).toString(),QString("Count Basic"));
QCOMPARE(m_info.track(3).get(Artist).toString(),QString("Rocker's HiFi"));
QCOMPARE(m_info.track(4).get(Artist).toString(),QString("Bomb The Bass"));
QCOMPARE(m_info.track(5).get(Artist).toString(),QString("Aphrodelics"));
QCOMPARE(m_info.track(6).get(Artist).toString(),QString("Depeche Mode"));
QCOMPARE(m_info.track(7).get(Artist).toString(),QString("Count Basic"));
QCOMPARE(m_info.track(8).get(Artist).toString(),QString::fromUtf8("Trüby Trio"));
QCOMPARE(m_info.track(9).get(Artist).toString(),QString("Lamb"));
}
void
......@@ -59,49 +101,19 @@ AsyncCDDBLookupTest::slotFinished(CDDB::Result r)
kDebug() << "AsyncCDDBLookupTest::slotResult: Item count: " << l.count() << endl;
for (CDInfoList::ConstIterator it(l.begin()); it != l.end(); ++it)
{
CDInfo i(*it);
kDebug() << "Disc artist: `" << i.get("artist").toString() << "'" << endl;
kDebug() << "Disc title: `" << i.get("title").toString() << "'" << endl;
kDebug() << "Disc revision: `" << i.get("revision") << "'" << endl;
}
if (!l.isEmpty())
foreach(CDInfo i, l)
{
kDebug() << "---------------------------------------" << endl;
kDebug() << "Showing first item" << endl;
CDInfo info(l.first());
kDebug() << "Disc artist: `" << info.get("artist").toString() << "'" << endl;
kDebug() << "Disc title: `" << info.get("title").toString() << "'" << endl;
kDebug() << "Disc genre: `" << info.get("genre").toString() << "'" << endl;
kDebug() << "Disc year: `" << info.get("year").toString() << "'" << endl;
kDebug() << "Disc length: `" << info.get("length").toString() << "'" << endl;
kDebug() << "Disc id: `" << info.get("discid").toString() << "'" << endl;
kDebug() << "Tracks........" << endl;
for (int i=0; i < info.numberOfTracks(); i++)
if (i.get("discid") == "a1107d0a" && i.get(Category) == "jazz")
{
kDebug() << " Track: `" << info.track(i).get("title").toString() << "'" << endl;
kDebug() << "Found the CD" << endl;
m_info = i;
break;
}
kDebug() << "---------------------------------------" << endl;
}
kapp->quit();
m_eventLoop.quit();
}
int main(int argc, char ** argv)
{
KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
KApplication app(false);
AsyncCDDBLookupTest test;
return app.exec();
}
QTEST_KDEMAIN(AsyncCDDBLookupTest, NoGUI);
#include "asynccddblookuptest.moc"
/*
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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef TEST_H
#define TEST_H
#include <qobject.h>
#include <QEventLoop>
#include <QObject>
#include <libkcddb/client.h>
using namespace KCDDB;
......@@ -9,19 +29,15 @@ using namespace KCDDB;
class AsyncCDDBLookupTest : public QObject
{
Q_OBJECT
public:
AsyncCDDBLookupTest();
~AsyncCDDBLookupTest();
public slots:
private slots:
void testLookup();
void slotFinished(CDDB::Result);
private:
QEventLoop m_eventLoop;
KCDDB::Client * client_;
CDInfo m_info;
};
#endif
/*
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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef TEST_H
#define TEST_H
......
/*
Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kdebug.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
......
/*
Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef TEST_H
#define TEST_H
......
/*
Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kdebug.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
......
/*
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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef TEST_H
#define TEST_H
......
/*
Copyright (C) 2005 Richard Lärkäng <nouseforaname@home.se>
Copyright (C) 2005-2006 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
......
......@@ -65,7 +65,7 @@ void SyncCDDBLookupTest::testLookup()
{
// If revision doesn't match, test probably needs to be updated
// See: http://www.freedb.org/freedb/rock/3e0c3a05 for updated data
QCOMPARE(i.get("revision").toInt(), 9);
QCOMPARE(i.get("revision").toInt(), 10);
QCOMPARE(i.get(Artist).toString(),QString("Pink Floyd"));
QCOMPARE(i.get(Title).toString(),QString("Atom Heart Mother"));
......
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdebug.h>
/*
Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <qtest_kde.h>
#include "libkcddb/client.h"
#include "libkcddb/cache.h"
#include "libkcddb/lookup.h"
#include "synchttplookuptest.h"
int
main(int argc, char ** argv)
void SyncHTTPLookupTest::testLookup()
{
KCmdLineArgs::init(argc, argv, "libkcddb_test", "", "", "");
KApplication app(false /* No styles */);
using namespace KCDDB;
Client c;
......@@ -21,7 +33,6 @@ main(int argc, char ** argv)
c.config().setCachePolicy(Cache::Ignore);
c.config().setLookupTransport(Lookup::HTTP);
TrackOffsetList list;
list
......@@ -32,33 +43,56 @@ main(int argc, char ** argv)
<< 176085
<< 234500;
kDebug() << "Stuff to send to server:" << endl;
kDebug()
<< CDDB::trackOffsetListToId(list)
<< " "
//<< trackOffsetListToString(list)
<< endl;
CDDB::Result r = c.lookup(list);
kDebug() << "Client::lookup gave : " << CDDB::resultToString(r) << endl;
c.lookup(list);
CDInfoList response = c.lookupResponse();
kDebug() << "Client::lookup returned : " << response.count() << " entries"
<< endl;
CDInfoList::ConstIterator it;
bool hasRunTest = false;
for (it = response.begin(); it != response.end(); ++it)
{
CDInfo i(*it);
kDebug() << "Disc title: " << i.get("title").toString() << endl;
kDebug() << "Total tracks: " << i.numberOfTracks() << endl;
kDebug() << "Disc revision: `" << i.get("revision").toInt() << "'" << endl;
if (i.get("discid") == "3e0c3a05" && i.get(Category) == "rock")
{
// If revision doesn't match, test probably needs to be updated
// See: http://www.freedb.org/freedb/rock/3e0c3a05 for updated data
QCOMPARE(i.get("revision").toInt(), 10);
QCOMPARE(i.get(Artist).toString(),QString("Pink Floyd"));
QCOMPARE(i.get(Title).toString(),QString("Atom Heart Mother"));
QCOMPARE(i.get(Genre).toString(),QString("Psychedelic Rock"));
QCOMPARE(i.get(Year).toInt(),1970);
QCOMPARE(i.track(0).get(Title).toString(),QString("Atom Heart Mother"));
QCOMPARE(i.track(1).get(Title).toString(),QString("If"));
QCOMPARE(i.track(2).get(Title).toString(),QString("Summer '68"));
QCOMPARE(i.track(3).get(Title).toString(),QString("Fat Old Sun"));
QCOMPARE(i.track(4).get(Title).toString(),QString::fromUtf8("Alan´s Psychedelic Breakfast"));
QCOMPARE(i.track(0).get(Comment).toString(),QString("ts Please\nf. Remergence"));
QCOMPARE(i.track(1).get(Comment).toString(),QString("Waters"));
QCOMPARE(i.track(2).get(Comment).toString(),QString("Wright"));
QCOMPARE(i.track(3).get(Comment).toString(),QString("Gilmour"));
QCOMPARE(i.track(4).get(Comment).toString(),QString("ide Up\nc. Morning Glory"));
for (int j=0; j <= 4; j++)
{
QCOMPARE(i.track(j).get(Artist).toString(),QString("Pink Floyd"));
}
hasRunTest = true;
}
}
return 0;
QVERIFY(hasRunTest);
}
QTEST_KDEMAIN(SyncHTTPLookupTest, NoGUI);
#include "synchttplookuptest.moc"
/*
Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef SYNCHTTPLOOKUPTEST_H
#define SYNCHTTPLOOKUPTEST_H
#include <qobject.h>
class SyncHTTPLookupTest : public QObject
{
Q_OBJECT
private slots:
void testLookup();
};
#endif
/*
Copyright (C) 2004-2005 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdebug.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment