mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-18 20:40:43 +01:00
Fix some of the comments on r1148
This commit is contained in:
parent
a27b6d3561
commit
2c3e9276aa
@ -65,10 +65,10 @@ SongLoader::Result SongLoader::LoadLocal() {
|
||||
return Error;
|
||||
QByteArray data(file.read(PlaylistParser::kMagicSize));
|
||||
|
||||
ParserBase* parser = playlist_parser_->TryMagic(data);
|
||||
ParserBase* parser = playlist_parser_->MaybeGetParserForMagic(data);
|
||||
if (parser) {
|
||||
// It's a playlist!
|
||||
file.seek(0);
|
||||
file.reset();
|
||||
songs_ = parser->Load(&file, QFileInfo(filename).path());
|
||||
} else {
|
||||
// Not a playlist, so just assume it's a song
|
||||
@ -252,7 +252,7 @@ void SongLoader::EndOfStreamReached() {
|
||||
}
|
||||
|
||||
void SongLoader::MagicReady() {
|
||||
parser_ = playlist_parser_->TryMagic(buffer_);
|
||||
parser_ = playlist_parser_->MaybeGetParserForMagic(buffer_);
|
||||
|
||||
if (!parser_) {
|
||||
// It doesn't look like a playlist, so just finish
|
||||
|
@ -70,7 +70,7 @@ ParserBase* PlaylistParser::ParserForExtension(const QString& suffix) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ParserBase* PlaylistParser::ParserForData(const QByteArray &data) const {
|
||||
ParserBase* PlaylistParser::MaybeGetParserForMagic(const QByteArray &data) const {
|
||||
foreach (ParserBase* p, parsers_) {
|
||||
if (p->TryMagic(data))
|
||||
return p;
|
||||
@ -78,10 +78,6 @@ ParserBase* PlaylistParser::ParserForData(const QByteArray &data) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ParserBase* PlaylistParser::TryMagic(const QByteArray &data) const {
|
||||
return ParserForData(data);
|
||||
}
|
||||
|
||||
SongList PlaylistParser::Load(const QString &filename, ParserBase* p) const {
|
||||
QFileInfo info(filename);
|
||||
|
||||
|
@ -34,14 +34,13 @@ public:
|
||||
QStringList file_extensions() const;
|
||||
QString filters() const;
|
||||
|
||||
ParserBase* TryMagic(const QByteArray& data) const;
|
||||
ParserBase* MaybeGetParserForMagic(const QByteArray& data) const;
|
||||
|
||||
SongList Load(const QString& filename, ParserBase* parser = 0) const;
|
||||
void Save(const SongList& songs, const QString& filename) const;
|
||||
|
||||
private:
|
||||
ParserBase* ParserForExtension(const QString& suffix) const;
|
||||
ParserBase* ParserForData(const QByteArray& data) const;
|
||||
|
||||
QList<ParserBase*> parsers_;
|
||||
};
|
||||
|
@ -91,7 +91,7 @@ void PLSParser::Save(const SongList &songs, QIODevice *device, const QDir &dir)
|
||||
|
||||
s.sync();
|
||||
|
||||
temp_file.seek(0);
|
||||
temp_file.reset();
|
||||
device->write(temp_file.readAll());
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,5 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir)
|
||||
}
|
||||
|
||||
bool XSPFParser::TryMagic(const QByteArray &data) const {
|
||||
QByteArray lower(data.toLower());
|
||||
return lower.contains("<playlist") && lower.contains("<tracklist");
|
||||
return data.contains("<playlist") && data.contains("<trackList");
|
||||
}
|
||||
|
@ -29,15 +29,15 @@
|
||||
|
||||
class SongLoaderTest : public ::testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase() {
|
||||
sGstEngine = new GstEngine;
|
||||
ASSERT_TRUE(sGstEngine->Init());
|
||||
}
|
||||
static void SetUpTestCase() {
|
||||
sGstEngine = new GstEngine;
|
||||
ASSERT_TRUE(sGstEngine->Init());
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
delete sGstEngine;
|
||||
sGstEngine = NULL;
|
||||
}
|
||||
static void TearDownTestCase() {
|
||||
delete sGstEngine;
|
||||
sGstEngine = NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() {
|
||||
@ -109,7 +109,7 @@ TEST_F(SongLoaderTest, LoadRemoteMp3) {
|
||||
QEventLoop loop;
|
||||
QObject::connect(loader_.get(), SIGNAL(LoadFinished(bool)),
|
||||
&loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
// Check the signal was emitted with Success
|
||||
ASSERT_EQ(1, spy.count());
|
||||
@ -129,7 +129,7 @@ TEST_F(SongLoaderTest, LoadRemote404) {
|
||||
QEventLoop loop;
|
||||
QObject::connect(loader_.get(), SIGNAL(LoadFinished(bool)),
|
||||
&loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
// Check the signal was emitted with Error
|
||||
ASSERT_EQ(1, spy.count());
|
||||
@ -146,7 +146,7 @@ TEST_F(SongLoaderTest, LoadRemotePls) {
|
||||
QEventLoop loop;
|
||||
QObject::connect(loader_.get(), SIGNAL(LoadFinished(bool)),
|
||||
&loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
// Check the signal was emitted with Success
|
||||
ASSERT_EQ(1, spy.count());
|
||||
@ -169,7 +169,7 @@ TEST_F(SongLoaderTest, LoadRemotePlainText) {
|
||||
QEventLoop loop;
|
||||
QObject::connect(loader_.get(), SIGNAL(LoadFinished(bool)),
|
||||
&loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
// Check the signal was emitted with Error
|
||||
ASSERT_EQ(1, spy.count());
|
||||
|
@ -58,5 +58,5 @@ TemporaryResource::TemporaryResource(const QString& filename) {
|
||||
resource.open(QIODevice::ReadOnly);
|
||||
write(resource.readAll());
|
||||
|
||||
seek(0);
|
||||
reset();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user