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

Less qt3support, and some test changes

svn path=/trunk/KDE/kdemultimedia/libkcddb/; revision=565154
parent fbf60dd0
......@@ -262,8 +262,7 @@ namespace KCDDB
return;
}
CDDBMatch match = matchList_.first();
matchList_.remove( match );
CDDBMatch match = matchList_.takeFirst();
sendRead( match );
......
......@@ -95,8 +95,7 @@ namespace KCDDB
return;
}
CDDBMatch match = matchList_.first();
matchList_.remove( match );
CDDBMatch match = matchList_.takeFirst();
data_ = QByteArray();
state_ = WaitingForReadResponse;
......@@ -111,10 +110,7 @@ namespace KCDDB
AsyncHTTPLookup::slotData( KIO::Job *, const QByteArray &data )
{
if (data.size() > 0)
{
QDataStream stream(&data_, QIODevice::WriteOnly | QIODevice::Append);
stream.writeRawBytes(data.data(), data.size());
}
data_.append(data);
}
void
......
......@@ -25,7 +25,7 @@ KCDDB::Categories::Categories()
const QString KCDDB::Categories::cddb2i18n(const QString &category) const
{
int index = m_cddb.findIndex(category.trimmed());
int index = m_cddb.indexOf(category.trimmed());
if (index != -1)
{
return m_i18n[index];
......@@ -38,7 +38,7 @@ const QString KCDDB::Categories::cddb2i18n(const QString &category) const
const QString KCDDB::Categories::i18n2cddb(const QString &category) const
{
int index = m_i18n.findIndex(category.trimmed());
int index = m_i18n.indexOf(category.trimmed());
if (index != -1)
{
return m_cddb[index];
......
......@@ -107,7 +107,7 @@ namespace KCDDB
QByteArray buf(line.toUtf8());
buf.append( '\n' );
return socket_->writeBlock( buf.data(), buf.length() );
return socket_->write( buf );
}
}
......
......@@ -97,7 +97,7 @@ KCDDB::Genres::Genres()
const QString KCDDB::Genres::cddb2i18n(const QString &genre) const
{
QString userDefinedGenre = genre.trimmed();
int index = m_cddb.findIndex(userDefinedGenre);
int index = m_cddb.indexOf(userDefinedGenre);
if (index != -1)
{
return m_i18n[index];
......@@ -111,7 +111,7 @@ const QString KCDDB::Genres::cddb2i18n(const QString &genre) const
const QString KCDDB::Genres::i18n2cddb(const QString &genre) const
{
QString userDefinedGenre = genre.trimmed();
int index = m_i18n.findIndex(userDefinedGenre);
int index = m_i18n.indexOf(userDefinedGenre);
if (index != -1)
{
return m_cddb[index];
......
......@@ -93,7 +93,7 @@ namespace KCDDB
void
HTTPLookup::jobFinished()
{
QStringList lineList = QStringList::split( "\n", QString::fromUtf8(data_, data_.size()) );
QStringList lineList = QString::fromUtf8(data_, data_.size()).split( "\n", QString::SkipEmptyParts );
QStringList::ConstIterator it = lineList.begin();
switch ( state_ )
......
......@@ -39,7 +39,7 @@ namespace KCDDB
KIO::Job* HTTPSubmit::createJob(const CDInfo& cdInfo)
{
KIO::TransferJob* job = KIO::http_post(url_, diskData_.utf8(), false);
KIO::TransferJob* job = KIO::http_post(url_, diskData_.toUtf8().data(), false);
job->addMetaData("content-type", "Content-Type: text/plain");
QString header;
......
......@@ -98,7 +98,7 @@ namespace KCDDB
QRegExp rexp("([^ ]+) (cddbp|http) (\\d+) ([^ ]+) [N|S]\\d{3}.\\d{2} [E|W]\\d{3}.\\d{2} (.*)");
if (rexp.search(line) != -1)
if (rexp.indexIn(line) != -1)
{
m.address = rexp.cap(1);
......
......@@ -47,7 +47,7 @@ namespace KCDDB
cdInfo.get("discid").toString(), from_));
kDebug(60010) << "Url is: " << url_.prettyUrl() << endl;
return KIO::storedPut(diskData_.utf8(), url_, -1, false, false, false);
return KIO::storedPut(diskData_.toUtf8().data(), url_, -1, false, false, false);
}
void SMTPSubmit::makeDiskData( const CDInfo& cdInfo, const TrackOffsetList& offsetList )
......
......@@ -19,21 +19,29 @@ if(KDE4_BUILD_TESTS)
kde4_add_executable(asynchttplookuptest RUN_UNINSTALLED ${asynchttplookuptest_SRCS})
target_link_libraries(asynchttplookuptest ${KDE4_KDECORE_LIBS} kcddb QtTest_debug )
add_test(asynchttplookuptest ${EXECUTABLE_OUTPUT_PATH}/asynccddblookuptest)
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 QtTest_debug )
add_test(asynccddblookuptest ${EXECUTABLE_OUTPUT_PATH}/asynccddblookuptest)
set(synccddblookuptest_SRCS synccddblookuptest.cpp )
kde4_automoc(${synccddblookuptest_SRCS})
kde4_add_executable(synccddblookuptest RUN_UNINSTALLED ${synccddblookuptest_SRCS})
target_link_libraries(synccddblookuptest ${KDE4_KDECORE_LIBS} kcddb QtTest_debug )
add_test(synccddblookuptest ${EXECUTABLE_OUTPUT_PATH}/synccddblookuptest)
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 QtTest_debug )
add_test(synchttplookuptest ${EXECUTABLE_OUTPUT_PATH}/synchttplookuptest)
set(asynchttpsubmittest_SRCS asynchttpsubmittest.cpp )
kde4_automoc(${asynchttpsubmittest_SRCS})
kde4_add_executable(asynchttpsubmittest RUN_UNINSTALLED ${asynchttpsubmittest_SRCS})
......@@ -54,16 +62,22 @@ if(KDE4_BUILD_TESTS)
kde4_add_executable(utf8test RUN_UNINSTALLED ${utf8test_SRCS})
target_link_libraries(utf8test ${KDE4_KDECORE_LIBS} kcddb QtTest_debug )
add_test(utf8test ${EXECUTABLE_OUTPUT_PATH}/utf8test)
set(musicbrainztest_SRCS musicbrainztest.cpp )
kde4_automoc(${musicbrainztest_SRCS})
kde4_add_executable(musicbrainztest RUN_UNINSTALLED ${musicbrainztest_SRCS})
target_link_libraries(musicbrainztest ${KDE4_KDECORE_LIBS} kcddb QtTest_debug )
add_test(musicbrainztest ${EXECUTABLE_OUTPUT_PATH}/musicbrainztest)
set(cdinfotest_SRCS cdinfotest.cpp )
kde4_automoc(${cdinfotest_SRCS})
kde4_add_executable(cdinfotest RUN_UNINSTALLED ${cdinfotest_SRCS})
target_link_libraries(cdinfotest ${KDE4_KDECORE_LIBS} kcddb QtTest_debug )
add_test(cdinfotest ${EXECUTABLE_OUTPUT_PATH}/cdinfotest)
endif(KDE4_BUILD_TESTS)
......@@ -65,22 +65,22 @@ void SyncCDDBLookupTest::testLookup()
{
// If revision doesn't match, test probably needs to be updated
// See: http://www.freedb.org/freedb/misc/3e0c3a05 for updated data
QCOMPARE(i.get("revision").toInt(), 11);
QCOMPARE(i.get("revision").toInt(), 12);
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(0).get(Title).toString(),QString("Atom Heart Mother: a) Father's Shout b) Breast Milky c) Mother Fore d) Funky Dung e) Mind Your Throats Please f) Remergence"));
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("Alan's Psychedelic Breakfast"));
QCOMPARE(i.track(0).get(Comment).toString(),QString("(a) - Father's Shout; (b) - Breast Milky; (c) - Mother Fore; (d) - Funky Dung; (e) - Mind Your Throats Please; (f) - 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("(a) - Rise And Shine; (b) - Subby Side Up; (c) - Morning Glory."));
QCOMPARE(i.track(4).get(Title).toString(),QString("Alan's Psychedelic Breakfast: a) Rise And Shine b) Sunny Side Up c) Morning Glory"));
QCOMPARE(i.track(0).get(Comment).toString(),QString(""));
QCOMPARE(i.track(1).get(Comment).toString(),QString(""));
QCOMPARE(i.track(2).get(Comment).toString(),QString(""));
QCOMPARE(i.track(3).get(Comment).toString(),QString(""));
QCOMPARE(i.track(4).get(Comment).toString(),QString(""));
for (int j=0; j <= 4; j++)
{
QCOMPARE(i.track(j).get(Artist).toString(),QString("Pink Floyd"));
......
......@@ -65,22 +65,22 @@ void SyncHTTPLookupTest::testLookup()
{
// If revision doesn't match, test probably needs to be updated
// See: http://www.freedb.org/freedb/misc/3e0c3a05 for updated data
QCOMPARE(i.get("revision").toInt(), 11);
QCOMPARE(i.get("revision").toInt(), 12);
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(0).get(Title).toString(),QString("Atom Heart Mother: a) Father's Shout b) Breast Milky c) Mother Fore d) Funky Dung e) Mind Your Throats Please f) Remergence"));
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("Alan's Psychedelic Breakfast"));
QCOMPARE(i.track(0).get(Comment).toString(),QString("(a) - Father's Shout; (b) - Breast Milky; (c) - Mother Fore; (d) - Funky Dung; (e) - Mind Your Throats Please; (f) - 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("(a) - Rise And Shine; (b) - Subby Side Up; (c) - Morning Glory."));
QCOMPARE(i.track(4).get(Title).toString(),QString("Alan's Psychedelic Breakfast: a) Rise And Shine b) Sunny Side Up c) Morning Glory"));
QCOMPARE(i.track(0).get(Comment).toString(),QString(""));
QCOMPARE(i.track(1).get(Comment).toString(),QString(""));
QCOMPARE(i.track(2).get(Comment).toString(),QString(""));
QCOMPARE(i.track(3).get(Comment).toString(),QString(""));
QCOMPARE(i.track(4).get(Comment).toString(),QString(""));
for (int j=0; j <= 4; j++)
{
QCOMPARE(i.track(j).get(Artist).toString(),QString("Pink Floyd"));
......
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