Add simple framewalk_to_beats test and normalise naming
of test files. git-svn-id: svn://localhost/ardour2/branches/3.0@10954 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
33
libs/ardour/test/framewalk_to_beats_test.cc
Normal file
33
libs/ardour/test/framewalk_to_beats_test.cc
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "framewalk_to_beats_test.h"
|
||||
#include "ardour/tempo.h"
|
||||
#include "timecode/bbt_time.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (FramewalkToBeatsTest);
|
||||
|
||||
using namespace std;
|
||||
using namespace ARDOUR;
|
||||
using namespace Timecode;
|
||||
|
||||
void
|
||||
FramewalkToBeatsTest::singleTempoTest ()
|
||||
{
|
||||
int const sampling_rate = 48000;
|
||||
int const bpm = 120;
|
||||
|
||||
double const frames_per_beat = (60 / double (bpm)) * double (sampling_rate);
|
||||
|
||||
TempoMap map (sampling_rate);
|
||||
Tempo tempo (bpm);
|
||||
Meter meter (4, 4);
|
||||
|
||||
map.add_meter (meter, BBT_Time (1, 1, 0));
|
||||
map.add_tempo (tempo, BBT_Time (1, 1, 0));
|
||||
|
||||
/* Add 1 beats-worth of frames to a 2 beat starting point */
|
||||
double r = map.framewalk_to_beats (frames_per_beat * 2, frames_per_beat * 1);
|
||||
CPPUNIT_ASSERT (r == 1);
|
||||
|
||||
/* Add 6 beats-worth of frames to a 3 beat starting point */
|
||||
r = map.framewalk_to_beats (frames_per_beat * 3, frames_per_beat * 6);
|
||||
CPPUNIT_ASSERT (r == 6);
|
||||
}
|
||||
17
libs/ardour/test/framewalk_to_beats_test.h
Normal file
17
libs/ardour/test/framewalk_to_beats_test.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class FramewalkToBeatsTest : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (FramewalkToBeatsTest);
|
||||
CPPUNIT_TEST (singleTempoTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void setUp () {}
|
||||
void tearDown () {}
|
||||
|
||||
void singleTempoTest ();
|
||||
};
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
#include <stdexcept>
|
||||
#include "midi++/manager.h"
|
||||
#include "pbd/textreceiver.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/smf_source.h"
|
||||
#include "ardour/midi_model.h"
|
||||
#include "test/mantis_3356.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (Mantis3356Test);
|
||||
|
||||
using namespace std;
|
||||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
||||
TextReceiver text_receiver ("test");
|
||||
|
||||
void
|
||||
Mantis3356Test::test ()
|
||||
{
|
||||
init (false, true);
|
||||
SessionEvent::create_per_thread_pool ("test", 512);
|
||||
|
||||
text_receiver.listen_to (error);
|
||||
text_receiver.listen_to (info);
|
||||
text_receiver.listen_to (fatal);
|
||||
text_receiver.listen_to (warning);
|
||||
|
||||
AudioEngine engine ("test", "");
|
||||
MIDI::Manager::create (engine.jack ());
|
||||
CPPUNIT_ASSERT (engine.start () == 0);
|
||||
|
||||
Session session (engine, "../libs/ardour/test/data/mantis_3356", "mantis_3356");
|
||||
engine.set_session (&session);
|
||||
|
||||
Session::SourceMap sources = session.get_sources ();
|
||||
|
||||
boost::shared_ptr<SMFSource> source = boost::dynamic_pointer_cast<SMFSource> (sources[ID ("87")]);
|
||||
CPPUNIT_ASSERT (source);
|
||||
|
||||
boost::shared_ptr<MidiModel> model = source->model ();
|
||||
CPPUNIT_ASSERT (model);
|
||||
|
||||
stringstream result;
|
||||
|
||||
for (MidiModel::const_iterator i = model->begin(); i != model->end(); ++i) {
|
||||
result << *i << "\n";
|
||||
}
|
||||
|
||||
ifstream ref ("../libs/ardour/test/data/mantis_3356.ref");
|
||||
|
||||
while (1) {
|
||||
string a;
|
||||
string b;
|
||||
|
||||
getline (ref, a);
|
||||
getline (result, b);
|
||||
|
||||
CPPUNIT_ASSERT (a == b);
|
||||
|
||||
if (result.eof() && ref.eof()) {
|
||||
break;
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT (!result.eof ());
|
||||
CPPUNIT_ASSERT (!ref.eof ());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
/** Test for Mantis bug #3356 */
|
||||
class Mantis3356Test : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (Mantis3356Test);
|
||||
CPPUNIT_TEST (test);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void test ();
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "ardour/resampled_source.h"
|
||||
#include "ardour/sndfileimportable.h"
|
||||
#include "resampled_source.h"
|
||||
#include "resampled_source_test.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (ResampledSourceTest);
|
||||
|
||||
@@ -423,13 +423,17 @@ def build(bld):
|
||||
testobj = bld(features = 'cxx cxxprogram')
|
||||
testobj.source = '''
|
||||
test/dummy_lxvst.cc
|
||||
test/bbt_test.cpp
|
||||
test/interpolation_test.cpp
|
||||
test/midi_clock_slave_test.cpp
|
||||
test/resampled_source.cc
|
||||
test/mantis_3356.cc
|
||||
test/testrunner.cpp
|
||||
test/bbt_test.cc
|
||||
test/interpolation_test.cc
|
||||
test/midi_clock_slave_test.cc
|
||||
test/resampled_source_test.cc
|
||||
test/framewalk_to_beats_test.cc
|
||||
test/testrunner.cc
|
||||
'''.split()
|
||||
|
||||
# Tests that don't work
|
||||
# test/mantis_3356_test.cc
|
||||
|
||||
testobj.includes = obj.includes + ['test', '../pbd']
|
||||
testobj.uselib = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
|
||||
'SAMPLERATE','XML','LRDF','COREAUDIO']
|
||||
|
||||
Reference in New Issue
Block a user