comparison data/fileio/test/EncodingTest.h @ 1593:d3f068153546 bqaudiostream

QDir::entryList on Mac ignores all of our files with non-ASCII filenames, I think because of variant normalisations (https://bugreports.qt.io/browse/QTBUG-70732). Hard code the file list instead.
author Chris Cannam
date Mon, 21 Jan 2019 15:49:04 +0000
parents f8e3dcbafb4d
children afa75922fe0f
comparison
equal deleted inserted replaced
1592:f8e3dcbafb4d 1593:d3f068153546
44 { utf8_name_tsprk, utf8_name_tsprk }, 44 { utf8_name_tsprk, utf8_name_tsprk },
45 { utf8_name_sprkt, utf8_name_sprkt }, 45 { utf8_name_sprkt, utf8_name_sprkt },
46 }; 46 };
47 static const int mappingCount = 4; 47 static const int mappingCount = 4;
48 48
49 static const char *testFiles[][2] = {
50 { "id3v2-iso-8859-1", "mp3" },
51 { "id3v2-ucs-2", "mp3" },
52 { utf8_name_tsprk, "flac" },
53 { utf8_name_tsprk, "m4a" },
54 { utf8_name_tsprk, "mp3" },
55 { utf8_name_tsprk, "ogg" },
56 { utf8_name_sprkt, "mp3" },
57 { utf8_name_sprkt, "ogg" },
58 };
59 static const int testFileCount = 8;
60
49 class EncodingTest : public QObject 61 class EncodingTest : public QObject
50 { 62 {
51 Q_OBJECT 63 Q_OBJECT
52 64
53 private: 65 private:
64 encodingDir = base + "/encodings"; 76 encodingDir = base + "/encodings";
65 outDir = base + "/outfiles"; 77 outDir = base + "/outfiles";
66 } 78 }
67 79
68 private: 80 private:
69 const char *strOf(QString s) {
70 return strdup(s.toLocal8Bit().data());
71 }
72
73 void addAudioFiles() { 81 void addAudioFiles() {
74 QTest::addColumn<QString>("audiofile"); 82 QTest::addColumn<QString>("audiofile");
75 QStringList files = QDir(encodingDir).entryList(QDir::Files); 83 for (int i = 0; i < testFileCount; ++i) {
76 foreach (QString filename, files) { 84 std::string s = testFiles[i][0];
77 QTest::newRow(strOf(filename)) << filename; 85 s += ".";
86 s += testFiles[i][1];
87 QTest::newRow(strdup(s.c_str())) << QString::fromStdString(s);
78 } 88 }
79 } 89 }
80 90
81 private slots: 91 private slots:
82 void init() 92 void init()
83 { 93 {
84 if (!QDir(encodingDir).exists()) { 94 if (!QDir(encodingDir).exists()) {
85 SVCERR << "ERROR: Audio encoding file directory \"" << encodingDir << "\" does not exist" << endl; 95 SVCERR << "ERROR: Audio encoding file directory \"" << encodingDir << "\" does not exist" << endl;
86 QVERIFY2(QDir(encodingDir).exists(), "Audio encoding file directory not found"); 96 QVERIFY2(QDir(encodingDir).exists(), "Audio encoding file directory not found");
87 } 97 }
88 if (!QDir(outDir).exists() && !QDir().mkpath(outDir)) { 98 if (!QDir(outDir).exists() && !QDir().mkpath(outDir)) {
89 SVCERR << "ERROR: Audio out directory \"" << outDir << "\" does not exist and could not be created" << endl; 99 SVCERR << "ERROR: Audio out directory \"" << outDir << "\" does not exist and could not be created" << endl;
90 QVERIFY2(QDir(outDir).exists(), "Audio out directory not found and could not be created"); 100 QVERIFY2(QDir(outDir).exists(), "Audio out directory not found and could not be created");
91 } 101 }
92 } 102 }