X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Ftest%2Ftest_needing_session.cc;h=d1ce25417b9ca923245dbfb1af2128add7241ea3;hb=6e94b1fb9f79c5bfcf22cd5b88619afa9bedb1b2;hp=9d1995a8c8108b8242fc8806153d343baba487d7;hpb=1dc8d99d78908222545e78f41cff08896f46a529;p=ardour.git diff --git a/libs/ardour/test/test_needing_session.cc b/libs/ardour/test/test_needing_session.cc index 9d1995a8c8..d1ce25417b 100644 --- a/libs/ardour/test/test_needing_session.cc +++ b/libs/ardour/test/test_needing_session.cc @@ -1,87 +1,29 @@ -#include "midi++/manager.h" -#include "pbd/textreceiver.h" +#include + #include "pbd/compose.h" #include "pbd/enumwriter.h" #include "ardour/session.h" #include "ardour/audioengine.h" #include "test_needing_session.h" +#include "test_util.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()); - - 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); - - /* We can't use VSTs here as we have a stub instead of the - required bits in gtk2_ardour. - */ - Config->set_use_lxvst (false); - - AudioEngine* engine = new AudioEngine ("test", ""); - init_post_engine (); - - CPPUNIT_ASSERT (engine->start () == 0); - - _session = new Session (*engine, test_session_path, "test_session"); - engine->set_session (_session); + const string session_name("test_session"); + std::string new_session_dir = Glib::build_filename (new_test_output_dir(), session_name); + create_and_start_dummy_backend (); + _session = load_session (new_session_dir, "test_session"); } void TestNeedingSession::tearDown () { - AudioEngine::instance()->remove_session (); delete _session; - AudioEngine::instance()->stop (true); - - MIDI::Manager::destroy (); - AudioEngine::destroy (); + stop_and_destroy_backend (); + _session = 0; }