void
AutomationListPropertyTest::basicTest ()
{
+ list<string> ignore_properties;
+ ignore_properties.push_back ("id");
+
PropertyDescriptor<boost::shared_ptr<AutomationList> > descriptor;
descriptor.property_id = g_quark_from_static_string ("FadeIn");
AutomationListProperty property (
XMLNode* foo = new XMLNode ("test");
property.get_changes_as_xml (foo);
- check_xml (foo, "../libs/ardour/test/data/automation_list_property_test1.ref");
+ check_xml (foo, "../libs/ardour/test/data/automation_list_property_test1.ref", ignore_properties);
/* Do some more */
property.clear_changes ();
CPPUNIT_ASSERT_EQUAL (true, property.changed());
foo = new XMLNode ("test");
property.get_changes_as_xml (foo);
- check_xml (foo, "../libs/ardour/test/data/automation_list_property_test2.ref");
+ check_xml (foo, "../libs/ardour/test/data/automation_list_property_test2.ref", ignore_properties);
}
/** Here's a StatefulDestructible class that has a AutomationListProperty */
void
AutomationListPropertyTest::undoTest ()
{
+ list<string> ignore_properties;
+ ignore_properties.push_back ("id");
+
Fred::make_property_quarks ();
boost::shared_ptr<Fred> sheila (new Fred);
/* Undo */
sdc.undo ();
- check_xml (&sheila->get_state(), "../libs/ardour/test/data/automation_list_property_test3.ref");
+ check_xml (&sheila->get_state(), "../libs/ardour/test/data/automation_list_property_test3.ref", ignore_properties);
/* Redo */
sdc.redo ();
- check_xml (&sheila->get_state(), "../libs/ardour/test/data/automation_list_property_test4.ref");
+ check_xml (&sheila->get_state(), "../libs/ardour/test/data/automation_list_property_test4.ref", ignore_properties);
}
+<?xml version="1.0" encoding="UTF-8"?>
<test>
<FadeIn>
<from>
- <AutomationList automation-id="fadein" id="162" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
- </AutomationList>
+ <AutomationList automation-id="fadein" id="164" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute"/>
</from>
<to>
- <AutomationList automation-id="fadein" id="162" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
- <events>
- 1 2
+ <AutomationList automation-id="fadein" id="163" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
+ <events>1 2
3 4
-
- </events>
+</events>
</AutomationList>
</to>
</FadeIn>
+<?xml version="1.0" encoding="UTF-8"?>
<test>
<FadeIn>
<from>
- <AutomationList automation-id="fadein" id="162" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
- <events>
- 1 2
+ <AutomationList automation-id="fadein" id="165" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
+ <events>1 2
3 4
-
- </events>
+</events>
</AutomationList>
</from>
<to>
- <AutomationList automation-id="fadein" id="162" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
- <events>
- 1 2
+ <AutomationList automation-id="fadein" id="163" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
+ <events>1 2
3 4
5 6
7 8
-
- </events>
+</events>
</AutomationList>
</to>
</FadeIn>
+<?xml version="1.0" encoding="UTF-8"?>
<State>
<FadeIn>
- <AutomationList automation-id="fadein" id="166" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
- <events>
- 1 2
+ <AutomationList automation-id="fadein" id="167" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
+ <events>1 2
3 4
-
- </events>
+</events>
</AutomationList>
</FadeIn>
</State>
+<?xml version="1.0" encoding="UTF-8"?>
<State>
<FadeIn>
- <AutomationList automation-id="fadein" id="166" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
- <events>
- 1 2
+ <AutomationList automation-id="fadein" id="167" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
+ <events>1 2
3 4
5 6
7 8
-
- </events>
+</events>
</AutomationList>
</FadeIn>
</State>
using namespace ARDOUR;
using namespace PBD;
+static void
+check_nodes (XMLNode const * p, XMLNode const * q, list<string> const & ignore_properties)
+{
+ CPPUNIT_ASSERT_EQUAL (p->is_content(), q->is_content());
+ if (!p->is_content()) {
+ CPPUNIT_ASSERT_EQUAL (p->name(), q->name());
+ } else {
+ CPPUNIT_ASSERT_EQUAL (p->content(), q->content());
+ }
+
+ XMLPropertyList const & pp = p->properties ();
+ XMLPropertyList const & qp = q->properties ();
+ CPPUNIT_ASSERT_EQUAL (pp.size(), qp.size());
+
+ XMLPropertyList::const_iterator i = pp.begin ();
+ XMLPropertyList::const_iterator j = qp.begin ();
+ while (i != pp.end ()) {
+ CPPUNIT_ASSERT_EQUAL ((*i)->name(), (*j)->name());
+ if (find (ignore_properties.begin(), ignore_properties.end(), (*i)->name ()) == ignore_properties.end ()) {
+ CPPUNIT_ASSERT_EQUAL ((*i)->value(), (*j)->value());
+ }
+ ++i;
+ ++j;
+ }
+
+ XMLNodeList const & pc = p->children ();
+ XMLNodeList const & qc = q->children ();
+
+ CPPUNIT_ASSERT_EQUAL (pc.size(), qc.size());
+ XMLNodeList::const_iterator k = pc.begin ();
+ XMLNodeList::const_iterator l = qc.begin ();
+
+ while (k != pc.end ()) {
+ check_nodes (*k, *l, ignore_properties);
+ ++k;
+ ++l;
+ }
+}
+
+void
+check_xml (XMLNode* node, string ref_file, list<string> const & ignore_properties)
+{
+ XMLTree ref (ref_file);
+
+ XMLNode* p = node;
+ XMLNode* q = ref.root ();
+
+ check_nodes (p, q, ignore_properties);
+}
+
void
-check_xml (XMLNode* node, string ref_file)
+write_ref (XMLNode* node, string ref_file)
{
- system ("rm -f libs/ardour/test/test.xml");
- ofstream f ("libs/ardour/test/test.xml");
- node->dump (f);
- f.close ();
-
- stringstream cmd;
- cmd << "diff -u libs/ardour/test/test.xml " << ref_file;
- CPPUNIT_ASSERT_EQUAL (0, system (cmd.str().c_str ()));
+ XMLTree ref;
+ ref.set_root (node);
+ ref.write (ref_file);
}
class TestReceiver : public Receiver
#include <string>
+#include <list>
class XMLNode;
class Session;
}
-extern void check_xml (XMLNode *, std::string);
+extern void check_xml (XMLNode *, std::string, std::list<std::string> const &);
+extern void write_ref (XMLNode *, std::string);
extern ARDOUR::Session* load_session (std::string, std::string);