4 #include "pbd/textreceiver.h"
5 #include "ardour/session.h"
6 #include "ardour/audioengine.h"
7 #include <cppunit/extensions/HelperMacros.h>
10 using namespace ARDOUR;
14 check_nodes (XMLNode const * p, XMLNode const * q, list<string> const & ignore_properties)
16 CPPUNIT_ASSERT_EQUAL (p->is_content(), q->is_content());
17 if (!p->is_content()) {
18 CPPUNIT_ASSERT_EQUAL (p->name(), q->name());
20 CPPUNIT_ASSERT_EQUAL (p->content(), q->content());
23 XMLPropertyList const & pp = p->properties ();
24 XMLPropertyList const & qp = q->properties ();
25 CPPUNIT_ASSERT_EQUAL (pp.size(), qp.size());
27 XMLPropertyList::const_iterator i = pp.begin ();
28 XMLPropertyList::const_iterator j = qp.begin ();
29 while (i != pp.end ()) {
30 CPPUNIT_ASSERT_EQUAL ((*i)->name(), (*j)->name());
31 if (find (ignore_properties.begin(), ignore_properties.end(), (*i)->name ()) == ignore_properties.end ()) {
32 CPPUNIT_ASSERT_EQUAL ((*i)->value(), (*j)->value());
38 XMLNodeList const & pc = p->children ();
39 XMLNodeList const & qc = q->children ();
41 CPPUNIT_ASSERT_EQUAL (pc.size(), qc.size());
42 XMLNodeList::const_iterator k = pc.begin ();
43 XMLNodeList::const_iterator l = qc.begin ();
45 while (k != pc.end ()) {
46 check_nodes (*k, *l, ignore_properties);
53 check_xml (XMLNode* node, string ref_file, list<string> const & ignore_properties)
55 XMLTree ref (ref_file);
58 XMLNode* q = ref.root ();
60 check_nodes (p, q, ignore_properties);
64 write_ref (XMLNode* node, string ref_file)
71 class TestReceiver : public Receiver
74 void receive (Transmitter::Channel chn, const char * str) {
75 const char *prefix = "";
78 case Transmitter::Error:
79 prefix = ": [ERROR]: ";
81 case Transmitter::Info:
84 case Transmitter::Warning:
85 prefix = ": [WARNING]: ";
87 case Transmitter::Fatal:
88 prefix = ": [FATAL]: ";
90 case Transmitter::Throw:
91 /* this isn't supposed to happen */
95 /* note: iostreams are already thread-safe: no external
99 cout << prefix << str << endl;
101 if (chn == Transmitter::Fatal) {
107 TestReceiver test_receiver;
109 /** @param dir Session directory.
110 * @param state Session state file, without .ardour suffix.
113 load_session (string dir, string state)
115 SessionEvent::create_per_thread_pool ("test", 512);
117 test_receiver.listen_to (error);
118 test_receiver.listen_to (info);
119 test_receiver.listen_to (fatal);
120 test_receiver.listen_to (warning);
122 /* We can't use VSTs here as we have a stub instead of the
123 required bits in gtk2_ardour.
125 Config->set_use_lxvst (false);
127 AudioEngine* engine = new AudioEngine ("test", "");
130 CPPUNIT_ASSERT (engine->start () == 0);
132 Session* session = new Session (*engine, dir, state);
133 engine->set_session (session);