Ardour  9.0-pre0-582-g084a23a80d
SMFTest.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2009-2016 David Robillard <d@drobilla.net>
4  * Copyright (C) 2009 Hans Baier <hansfbaier@googlemail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include <cassert>
22 #include <stdint.h>
23 #include <sigc++/sigc++.h>
24 #include <cppunit/TestFixture.h>
25 #include <cppunit/extensions/HelperMacros.h>
26 #include "temporal/beats.h"
27 #include "temporal/tempo.h"
28 #include "evoral/SMF.h"
29 #include "SequenceTest.h"
30 
31 using namespace Evoral;
32 
33 class TestSMF : public SMF {
34 public:
35  std::string path() const { return _path; }
36 
37  int open(const std::string& path) {
38  _path = path;
39  return SMF::open(path);
40  }
41 
42  void close() {
43  return SMF::close();
44  }
45 
46  int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const {
47  event_id_t id;
48  return SMF::read_event(delta_t, size, buf, &id);
49  }
50 
51 private:
52  std::string _path;
53 };
54 
55 class SMFTest : public CppUnit::TestFixture
56 {
58  CPPUNIT_TEST(createNewFileTest);
59  CPPUNIT_TEST(takeFiveTest);
60  CPPUNIT_TEST(writeTest);
62 
63 public:
65 
66  void setUp() {
68  type_map = new DummyTypeMap();
69  assert(type_map);
70  seq = new MySequence<Time>(*type_map);
71  assert(seq);
72  }
73 
74  void tearDown() {
75  delete seq;
76  delete type_map;
77  }
78 
80  void takeFiveTest();
81  void writeTest();
82 
83 private:
86 };
87 
int read_event(uint32_t *delta_t, uint32_t *size, uint8_t **buf, event_id_t *note_id) const
void close()
int open(const std::string &path, int track=1, bool scan=true)
DummyTypeMap * type_map
Definition: SMFTest.h:84
MySequence< Time > * seq
Definition: SMFTest.h:85
void writeTest()
CPPUNIT_TEST(createNewFileTest)
void takeFiveTest()
CPPUNIT_TEST_SUITE(SMFTest)
void setUp()
Definition: SMFTest.h:66
Temporal::Beats Time
Definition: SMFTest.h:64
CPPUNIT_TEST(writeTest)
CPPUNIT_TEST_SUITE_END()
void createNewFileTest()
CPPUNIT_TEST(takeFiveTest)
void tearDown()
Definition: SMFTest.h:74
static SharedPtr fetch()
std::string _path
Definition: SMFTest.h:52
void close()
Definition: SMFTest.h:42
std::string path() const
Definition: SMFTest.h:35
int open(const std::string &path)
Definition: SMFTest.h:37
int read_event(uint32_t *delta_t, uint32_t *size, uint8_t **buf) const
Definition: SMFTest.h:46
Definition: editor.h:86
int32_t event_id_t