mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 03:09:57 +01:00
4219dfa718
Dave: I'm sorry.
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#include "mock_taglib.h"
|
|
|
|
#include <QTemporaryFile>
|
|
|
|
using ::testing::Return;
|
|
|
|
MockFile::MockFile(TagLib::Tag* tag, const QString& filename)
|
|
: TagLib::File(QFile::encodeName(filename).constData()),
|
|
tag_(tag) {
|
|
}
|
|
|
|
TagLib::Tag* MockFile::tag() const {
|
|
return tag_.get();
|
|
}
|
|
|
|
TagLib::AudioProperties* MockFile::audioProperties() const {
|
|
return NULL;
|
|
}
|
|
|
|
bool MockFile::save() {
|
|
return true;
|
|
}
|
|
|
|
void MockFileRefFactory::ExpectCall(const QString& filename,
|
|
const QString& title,
|
|
const QString& artist,
|
|
const QString& album) {
|
|
MockTag* tag = new MockTag;
|
|
EXPECT_CALL(*tag, title()).WillRepeatedly(Return(title.toStdString()));
|
|
EXPECT_CALL(*tag, artist()).WillRepeatedly(Return(artist.toStdString()));
|
|
EXPECT_CALL(*tag, album()).WillRepeatedly(Return(album.toStdString()));
|
|
tags_[filename] = tag;
|
|
}
|
|
|
|
TagLib::FileRef* MockFileRefFactory::GetFileRef(const QString& filename) {
|
|
MockTag* tag = tags_.take(filename);
|
|
QTemporaryFile temp_file;
|
|
temp_file.open();
|
|
MockFile* file = new MockFile(tag, temp_file.fileName());
|
|
TagLib::FileRef* fileref = new TagLib::FileRef(file);
|
|
return fileref;
|
|
}
|