2 * Copyright(C) 2000-2008 Paul Davis
5 * Evoral is free software; you can redistribute it and/or modify it under the
6 * terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or(at your option) any later
10 * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <cppunit/TestFixture.h>
22 #include <cppunit/extensions/HelperMacros.h>
24 #include "ardour/tempo.h"
25 #include "ardour/slave.h"
29 class TestSlaveSessionProxy : public ISlaveSessionProxy {
30 #define FRAME_RATE 44100
31 framecnt_t _period_size;
33 double transport_speed;
34 framepos_t _transport_frame;
35 framepos_t _frame_time;
42 TestSlaveSessionProxy() :
43 transport_speed (1.0),
45 _frame_time (1000000),
50 _tempo_map = new TempoMap (FRAME_RATE);
51 _tempo_map->add_tempo (tempo, 0.0, 0, AudioTime);
52 _tempo_map->add_meter (meter, Timecode::BBT_Time(1, 1, 0), 0, AudioTime);
55 // Controlling the mock object
56 void set_period_size (framecnt_t a_size) { _period_size = a_size; }
57 framecnt_t period_size () const { return _period_size; }
59 _transport_frame += double(_period_size) * double(transport_speed);
60 _frame_time += _period_size;
64 TempoMap& tempo_map () const { return *_tempo_map; }
65 framecnt_t frame_rate () const { return FRAME_RATE; }
66 framepos_t audible_frame () const { return _transport_frame; }
67 framepos_t transport_frame () const { return _transport_frame; }
68 pframes_t frames_since_cycle_start () const { return 0; }
69 framepos_t frame_time () const { return _frame_time; }
71 void request_locate (framepos_t frame, bool with_roll = false) {
72 _transport_frame = frame;
75 void request_transport_speed (const double speed) { transport_speed = speed; }
78 class MIDIClock_SlaveTest : public CppUnit::TestFixture, ARDOUR::MIDIClock_Slave
80 CPPUNIT_TEST_SUITE(MIDIClock_SlaveTest);
81 CPPUNIT_TEST(testStepResponse);
82 CPPUNIT_TEST_SUITE_END();
85 MIDIClock_SlaveTest () : MIDIClock_Slave (new TestSlaveSessionProxy) {}
93 void testStepResponse();