Commit fa0587c3 authored by Bart van der Velden's avatar Bart van der Velden

Yet anoteher attempt (#65)

parent ff5824e4
......@@ -12,6 +12,26 @@ using namespace std;
using namespace mc::collection;
using namespace TagLib;
class TestFileName
{
public:
TestFileName(const QString& fileName) : m_fileName(fileName)
{
}
TagLib::FileName TagLibFileName() const
{
#ifdef WIN32
return reinterpret_cast<const wchar_t*> (m_fileName.constData());
#else
return QFile::encodeName(path).constData();
#endif
}
private:
QString m_fileName;
};
QString datapath(const QString& relPath)
{
return QDir::toNativeSeparators(QString(MUSICCOLLECTION_TEST_DIR) + '/' + relPath );
......@@ -29,24 +49,24 @@ TagLib::FileName QStringToFileName(const QString& path)
TEST(FileTypeResolverTest, EmptyPath)
{
FileTypeResolver ftr;
QString fileName = "";
File* file = ftr.createFile(QStringToFileName(fileName));
TestFileName fileName = "";
File* file = ftr.createFile(fileName.TagLibFileName());
EXPECT_EQ(0, file);
}
TEST(FileTypeResolverTest, FileDoesNotExist)
{
FileTypeResolver ftr;
QString fileName = "ThisDoesNotExist";
File* file = ftr.createFile(QStringToFileName(fileName));
TestFileName fileName = "ThisDoesNotExist";
File* file = ftr.createFile(fileName.TagLibFileName());
EXPECT_EQ(0, file);
}
TEST(FileTypeResolverTest, FileDoesNotExistMp3Ext)
{
FileTypeResolver ftr;
QString fileName = "ThisDoesNotExist.mp3";
File* file = ftr.createFile(QStringToFileName(fileName));
TestFileName fileName = "ThisDoesNotExist.mp3";
File* file = ftr.createFile(fileName.TagLibFileName());
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<MPEG::File*>(file) != 0);
ASSERT_FALSE(file->isOpen());
......@@ -55,8 +75,8 @@ TEST(FileTypeResolverTest, FileDoesNotExistMp3Ext)
TEST(FileTypeResolverTest, OggFileExists)
{
FileTypeResolver ftr;
QString fileName = datapath("test.ogg");
File* file = ftr.createFile(QStringToFileName(fileName));
TestFileName fileName = datapath("test.ogg");
File* file = ftr.createFile(fileName.TagLibFileName());
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<Ogg::Vorbis::File*>(file) != 0);
ASSERT_TRUE(file->isOpen());
......@@ -65,8 +85,8 @@ TEST(FileTypeResolverTest, OggFileExists)
TEST(FileTypeResolverTest, JapaneseOggFile)
{
FileTypeResolver ftr;
QString fileName = datapath("テスト.ogg");
File* file = ftr.createFile(QStringToFileName(fileName));
TestFileName fileName = datapath("テスト.ogg");
File* file = ftr.createFile(fileName.TagLibFileName());
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<Ogg::Vorbis::File*>(file) != 0);
ASSERT_TRUE(file->isOpen());
......@@ -75,8 +95,8 @@ TEST(FileTypeResolverTest, JapaneseOggFile)
TEST(FileTypeResolverTest, ArabicOggFile)
{
FileTypeResolver ftr;
QString fileName = datapath("اختبار.ogg");
File* file = ftr.createFile(QStringToFileName(fileName));
TestFileName fileName = datapath("اختبار.ogg");
File* file = ftr.createFile(fileName.TagLibFileName());
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<Ogg::Vorbis::File*>(file) != 0);
ASSERT_TRUE(file->isOpen());
......@@ -85,8 +105,8 @@ TEST(FileTypeResolverTest, ArabicOggFile)
TEST(FileTypeResolverTest, RussianOggFile)
{
FileTypeResolver ftr;
QString fileName = datapath("тест.ogg");
File* file = ftr.createFile(QStringToFileName(fileName));
TestFileName fileName = datapath("тест.ogg");
File* file = ftr.createFile(fileName.TagLibFileName());
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<Ogg::Vorbis::File*>(file) != 0);
ASSERT_TRUE(file->isOpen());
......
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