comparison data/fileio/test/MIDIFileReaderTest.h @ 1527:710e6250a401 zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:14 +0100
parents 87ae75da6527
children
comparison
equal deleted inserted replaced
1324:d4a28d1479a8 1527:710e6250a401
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2013 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef TEST_MIDI_FILE_READER_H
17 #define TEST_MIDI_FILE_READER_H
18
19 #include "../MIDIFileReader.h"
20
21 #include <cmath>
22
23 #include <QObject>
24 #include <QtTest>
25 #include <QDir>
26
27 #include "base/Debug.h"
28
29 #include <iostream>
30
31 using namespace std;
32
33 class MIDIFileReaderTest : public QObject
34 {
35 Q_OBJECT
36
37 private:
38 QString testDirBase;
39 QString midiDir;
40
41 const char *strOf(QString s) {
42 return strdup(s.toLocal8Bit().data());
43 }
44
45 public:
46 MIDIFileReaderTest(QString base) {
47 if (base == "") {
48 base = "svcore/data/fileio/test";
49 }
50 testDirBase = base;
51 midiDir = base + "/midi";
52 }
53
54 private slots:
55 void init()
56 {
57 if (!QDir(midiDir).exists()) {
58 SVCERR << "ERROR: MIDI file directory \"" << midiDir << "\" does not exist" << endl;
59 QVERIFY2(QDir(midiDir).exists(), "MIDI file directory not found");
60 }
61 }
62
63 void read_data()
64 {
65 QTest::addColumn<QString>("filename");
66 QStringList files = QDir(midiDir).entryList(QDir::Files);
67 foreach (QString filename, files) {
68 QTest::newRow(strOf(filename)) << filename;
69 }
70 }
71
72 void read()
73 {
74 QFETCH(QString, filename);
75 QString path = midiDir + "/" + filename;
76 MIDIFileReader reader(path, nullptr, 44100);
77 Model *m = reader.load();
78 if (!m) {
79 SVCERR << "MIDI load failed for path: \"" << path << "\"" << endl;
80 }
81 QVERIFY(m != nullptr);
82 //!!! Ah, now here we could do something a bit more informative
83 }
84
85 };
86
87 #endif
88