Add TestNeedingSession and add missing tempo_test.h

git-svn-id: svn://localhost/ardour2/branches/3.0@11140 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2012-01-03 16:05:25 +00:00
parent dd57700445
commit b6438ed1f6
6 changed files with 119 additions and 67 deletions

View File

@ -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

View File

@ -1,13 +1,11 @@
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#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<ARDOUR::Playlist> _playlist;
boost::shared_ptr<ARDOUR::Source> _source;
boost::shared_ptr<ARDOUR::Region> _region[16];

View File

@ -0,0 +1,17 @@
#include <sigc++/sigc++.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
class TempoTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE (TempoTest);
CPPUNIT_TEST (recomputeMapTest);
CPPUNIT_TEST_SUITE_END ();
public:
void setUp () {}
void tearDown () {}
void recomputeMapTest ();
};

View File

@ -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 ();
}

View File

@ -0,0 +1,12 @@
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
class TestNeedingSession : public CppUnit::TestFixture
{
public:
virtual void setUp ();
virtual void tearDown ();
protected:
ARDOUR::Session* _session;
};

View File

@ -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