2009-02-14 12:35:34 -05:00
|
|
|
/* This file is part of Evoral.
|
|
|
|
* Copyright(C) 2000-2008 Paul Davis
|
|
|
|
* Author: Hans Baier
|
2009-10-19 11:26:56 -04:00
|
|
|
*
|
2009-02-14 12:35:34 -05:00
|
|
|
* Evoral is free software; you can redistribute it and/or modify it under the
|
|
|
|
* terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or(at your option) any later
|
|
|
|
* version.
|
2009-10-19 11:26:56 -04:00
|
|
|
*
|
2009-02-14 12:35:34 -05:00
|
|
|
* Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
2009-10-19 11:26:56 -04:00
|
|
|
*
|
2009-02-14 12:35:34 -05:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cassert>
|
2009-05-17 20:21:17 -04:00
|
|
|
#include <stdint.h>
|
2009-02-14 12:35:34 -05:00
|
|
|
#include <sigc++/sigc++.h>
|
2009-02-09 17:32:38 -05:00
|
|
|
#include <cppunit/TestFixture.h>
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
2014-11-22 04:05:42 -05:00
|
|
|
#include "evoral/types.hpp"
|
2009-02-14 12:35:34 -05:00
|
|
|
#include "evoral/SMF.hpp"
|
2009-02-10 18:58:02 -05:00
|
|
|
#include "SequenceTest.hpp"
|
|
|
|
|
|
|
|
using namespace Evoral;
|
|
|
|
|
2009-02-14 20:32:41 -05:00
|
|
|
class TestSMF : public SMF {
|
2009-02-10 18:58:02 -05:00
|
|
|
public:
|
2009-02-12 18:28:51 -05:00
|
|
|
std::string path() const { return _path; }
|
2009-10-19 11:26:56 -04:00
|
|
|
|
2009-02-11 12:59:33 -05:00
|
|
|
int open(const std::string& path) THROW_FILE_ERROR {
|
2009-02-12 18:28:51 -05:00
|
|
|
_path = path;
|
2009-02-14 20:32:41 -05:00
|
|
|
return SMF::open(path);
|
2009-02-10 18:58:02 -05:00
|
|
|
}
|
2009-10-19 11:26:56 -04:00
|
|
|
|
2009-02-12 18:28:51 -05:00
|
|
|
void close() THROW_FILE_ERROR {
|
2009-02-14 20:32:41 -05:00
|
|
|
return SMF::close();
|
2009-02-12 18:28:51 -05:00
|
|
|
}
|
2009-10-19 11:26:56 -04:00
|
|
|
|
2009-02-10 18:58:02 -05:00
|
|
|
int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
|
2010-07-24 20:39:04 -04:00
|
|
|
event_id_t id;
|
|
|
|
return SMF::read_event(delta_t, size, buf, &id);
|
2009-02-10 18:58:02 -05:00
|
|
|
}
|
2009-02-12 18:28:51 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _path;
|
2009-02-10 18:58:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class SMFTest : public CppUnit::TestFixture
|
|
|
|
{
|
2009-10-19 11:26:56 -04:00
|
|
|
CPPUNIT_TEST_SUITE(SMFTest);
|
|
|
|
CPPUNIT_TEST(createNewFileTest);
|
|
|
|
CPPUNIT_TEST(takeFiveTest);
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
2009-02-10 18:58:02 -05:00
|
|
|
|
2009-10-19 11:26:56 -04:00
|
|
|
public:
|
2014-11-22 04:05:42 -05:00
|
|
|
typedef Evoral::MusicalTime Time;
|
2009-02-10 18:58:02 -05:00
|
|
|
|
2009-10-19 11:26:56 -04:00
|
|
|
void setUp() {
|
|
|
|
type_map = new DummyTypeMap();
|
|
|
|
assert(type_map);
|
|
|
|
seq = new MySequence<Time>(*type_map);
|
|
|
|
assert(seq);
|
|
|
|
}
|
2009-02-10 18:58:02 -05:00
|
|
|
|
2009-10-19 11:26:56 -04:00
|
|
|
void tearDown() {
|
|
|
|
delete seq;
|
|
|
|
delete type_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
void createNewFileTest();
|
|
|
|
void takeFiveTest();
|
|
|
|
|
|
|
|
private:
|
|
|
|
DummyTypeMap* type_map;
|
|
|
|
MySequence<Time>* seq;
|
2009-02-10 18:58:02 -05:00
|
|
|
};
|
2009-02-14 12:35:34 -05:00
|
|
|
|