diff --git a/libs/ardour/test/playlist_layering_test.cc b/libs/ardour/test/playlist_layering_test.cc index fd0b6bc09c..1753635584 100644 --- a/libs/ardour/test/playlist_layering_test.cc +++ b/libs/ardour/test/playlist_layering_test.cc @@ -15,66 +15,12 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -class TestReceiver : public Receiver -{ -protected: - void receive (Transmitter::Channel chn, const char * str) { - const char *prefix = ""; - - switch (chn) { - case Transmitter::Error: - prefix = ": [ERROR]: "; - break; - case Transmitter::Info: - /* ignore */ - return; - case Transmitter::Warning: - prefix = ": [WARNING]: "; - break; - case Transmitter::Fatal: - prefix = ": [FATAL]: "; - break; - case Transmitter::Throw: - /* this isn't supposed to happen */ - abort (); - } - - /* note: iostreams are already thread-safe: no external - lock required. - */ - - cout << prefix << str << endl; - - if (chn == Transmitter::Fatal) { - exit (9); - } - } -}; - -TestReceiver test_receiver; - void PlaylistLayeringTest::setUp () { - string const test_session_path = "libs/ardour/test/playlist_layering_test"; - string const test_wav_path = "libs/ardour/test/playlist_layering_test/playlist_layering_test.wav"; - system (string_compose ("rm -rf %1", test_session_path).c_str()); + TestNeedingSession::setUp (); - init (false, true); - SessionEvent::create_per_thread_pool ("test", 512); - - test_receiver.listen_to (error); - test_receiver.listen_to (info); - test_receiver.listen_to (fatal); - test_receiver.listen_to (warning); - - AudioEngine* engine = new AudioEngine ("test", ""); - MIDI::Manager::create (engine->jack ()); - CPPUNIT_ASSERT (engine->start () == 0); - - _session = new Session (*engine, test_session_path, "playlist_layering_test"); - engine->set_session (_session); - + string const test_wav_path = "libs/ardour/test/playlist_layering_test/playlist_layering_test.wav"; _playlist = PlaylistFactory::create (DataType::AUDIO, *_session, "test"); _source = SourceFactory::createWritable (DataType::AUDIO, *_session, test_wav_path, "", false, 44100); } @@ -87,12 +33,8 @@ PlaylistLayeringTest::tearDown () for (int i = 0; i < 16; ++i) { _region[i].reset (); } - - AudioEngine::instance()->remove_session (); - delete _session; - EnumWriter::destroy (); - MIDI::Manager::destroy (); - AudioEngine::destroy (); + + TestNeedingSession::tearDown (); } void diff --git a/libs/ardour/test/playlist_layering_test.h b/libs/ardour/test/playlist_layering_test.h index 46285459ca..2200fa8f9f 100644 --- a/libs/ardour/test/playlist_layering_test.h +++ b/libs/ardour/test/playlist_layering_test.h @@ -1,13 +1,11 @@ -#include -#include +#include "test_needing_session.h" namespace ARDOUR { - class Session; class Playlist; class Source; } -class PlaylistLayeringTest : public CppUnit::TestFixture +class PlaylistLayeringTest : public TestNeedingSession { CPPUNIT_TEST_SUITE (PlaylistLayeringTest); CPPUNIT_TEST (basicsTest); @@ -22,7 +20,6 @@ public: private: void create_three_short_regions (); - ARDOUR::Session* _session; boost::shared_ptr _playlist; boost::shared_ptr _source; boost::shared_ptr _region[16]; diff --git a/libs/ardour/test/tempo_test.h b/libs/ardour/test/tempo_test.h new file mode 100644 index 0000000000..3252650b03 --- /dev/null +++ b/libs/ardour/test/tempo_test.h @@ -0,0 +1,17 @@ +#include +#include +#include + +class TempoTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (TempoTest); + CPPUNIT_TEST (recomputeMapTest); + CPPUNIT_TEST_SUITE_END (); + +public: + void setUp () {} + void tearDown () {} + + void recomputeMapTest (); +}; + diff --git a/libs/ardour/test/test_needing_session.cc b/libs/ardour/test/test_needing_session.cc new file mode 100644 index 0000000000..e2da42c475 --- /dev/null +++ b/libs/ardour/test/test_needing_session.cc @@ -0,0 +1,83 @@ +#include "midi++/manager.h" +#include "pbd/textreceiver.h" +#include "pbd/compose.h" +#include "pbd/enumwriter.h" +#include "ardour/session.h" +#include "ardour/audioengine.h" +#include "test_needing_session.h" + +using namespace std; +using namespace ARDOUR; +using namespace PBD; + +class TestReceiver : public Receiver +{ +protected: + void receive (Transmitter::Channel chn, const char * str) { + const char *prefix = ""; + + switch (chn) { + case Transmitter::Error: + prefix = ": [ERROR]: "; + break; + case Transmitter::Info: + /* ignore */ + return; + case Transmitter::Warning: + prefix = ": [WARNING]: "; + break; + case Transmitter::Fatal: + prefix = ": [FATAL]: "; + break; + case Transmitter::Throw: + /* this isn't supposed to happen */ + abort (); + } + + /* note: iostreams are already thread-safe: no external + lock required. + */ + + cout << prefix << str << endl; + + if (chn == Transmitter::Fatal) { + exit (9); + } + } +}; + +TestReceiver test_receiver; + +void +TestNeedingSession::setUp () +{ + string const test_session_path = "libs/ardour/test/test_session"; + system (string_compose ("rm -rf %1", test_session_path).c_str()); + + init (false, true); + SessionEvent::create_per_thread_pool ("test", 512); + + test_receiver.listen_to (error); + test_receiver.listen_to (info); + test_receiver.listen_to (fatal); + test_receiver.listen_to (warning); + + AudioEngine* engine = new AudioEngine ("test", ""); + MIDI::Manager::create (engine->jack ()); + CPPUNIT_ASSERT (engine->start () == 0); + + _session = new Session (*engine, test_session_path, "test_session"); + engine->set_session (_session); +} + +void +TestNeedingSession::tearDown () +{ + AudioEngine::instance()->remove_session (); + + delete _session; + + EnumWriter::destroy (); + MIDI::Manager::destroy (); + AudioEngine::destroy (); +} diff --git a/libs/ardour/test/test_needing_session.h b/libs/ardour/test/test_needing_session.h new file mode 100644 index 0000000000..57acd9287c --- /dev/null +++ b/libs/ardour/test/test_needing_session.h @@ -0,0 +1,12 @@ +#include +#include + +class TestNeedingSession : public CppUnit::TestFixture +{ +public: + virtual void setUp (); + virtual void tearDown (); + +protected: + ARDOUR::Session* _session; +}; diff --git a/libs/ardour/wscript b/libs/ardour/wscript index a3b39d4dc7..43ce7cdb71 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -423,6 +423,7 @@ def build(bld): testobj = bld(features = 'cxx cxxprogram') testobj.source = ''' test/dummy_lxvst.cc + test/test_needing_session.cc test/bbt_test.cc test/tempo_test.cc test/interpolation_test.cc