Chris@1359: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@1359: Chris@1359: /* Chris@1359: Sonic Visualiser Chris@1359: An audio file viewer and annotation editor. Chris@1359: Centre for Digital Music, Queen Mary, University of London. Chris@1359: This file copyright 2013 Chris Cannam. Chris@1359: Chris@1359: This program is free software; you can redistribute it and/or Chris@1359: modify it under the terms of the GNU General Public License as Chris@1359: published by the Free Software Foundation; either version 2 of the Chris@1359: License, or (at your option) any later version. See the file Chris@1359: COPYING included with this distribution for more information. Chris@1359: */ Chris@1359: Chris@1359: #ifndef TEST_MIDI_FILE_READER_H Chris@1359: #define TEST_MIDI_FILE_READER_H Chris@1359: Chris@1359: #include "../MIDIFileReader.h" Chris@1359: Chris@1359: #include Chris@1359: Chris@1359: #include Chris@1359: #include Chris@1359: #include Chris@1359: Chris@1359: #include "base/Debug.h" Chris@1359: Chris@1359: #include Chris@1359: Chris@1359: using namespace std; Chris@1359: Chris@1359: class MIDIFileReaderTest : public QObject Chris@1359: { Chris@1359: Q_OBJECT Chris@1359: Chris@1359: private: Chris@1359: QString testDirBase; Chris@1359: QString midiDir; Chris@1359: Chris@1359: const char *strOf(QString s) { Chris@1359: return strdup(s.toLocal8Bit().data()); Chris@1359: } Chris@1359: Chris@1359: public: Chris@1359: MIDIFileReaderTest(QString base) { Chris@1359: if (base == "") { Chris@1359: base = "svcore/data/fileio/test"; Chris@1359: } Chris@1359: testDirBase = base; Chris@1359: midiDir = base + "/midi"; Chris@1359: } Chris@1359: Chris@1359: private slots: Chris@1359: void init() Chris@1359: { Chris@1359: if (!QDir(midiDir).exists()) { Chris@1428: SVCERR << "ERROR: MIDI file directory \"" << midiDir << "\" does not exist" << endl; Chris@1359: QVERIFY2(QDir(midiDir).exists(), "MIDI file directory not found"); Chris@1359: } Chris@1359: } Chris@1359: Chris@1359: void read_data() Chris@1359: { Chris@1359: QTest::addColumn("filename"); Chris@1359: QStringList files = QDir(midiDir).entryList(QDir::Files); Chris@1359: foreach (QString filename, files) { Chris@1359: QTest::newRow(strOf(filename)) << filename; Chris@1359: } Chris@1359: } Chris@1359: Chris@1359: void read() Chris@1359: { Chris@1359: QFETCH(QString, filename); Chris@1359: QString path = midiDir + "/" + filename; Chris@1359: MIDIFileReader reader(path, nullptr, 44100); Chris@1359: Model *m = reader.load(); Chris@1359: if (!m) { Chris@1428: SVCERR << "MIDI load failed for path: \"" << path << "\"" << endl; Chris@1359: } Chris@1359: QVERIFY(m != nullptr); Chris@1359: //!!! Ah, now here we could do something a bit more informative Chris@1359: } Chris@1359: Chris@1359: }; Chris@1359: Chris@1359: #endif Chris@1359: