Do XML comparisons better in tests.
git-svn-id: svn://localhost/ardour2/branches/3.0@12752 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2a5bfa6dcb
commit
20ceeb6d3e
@ -31,6 +31,9 @@ using namespace ARDOUR;
|
||||
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 (
|
||||
@ -51,7 +54,7 @@ AutomationListPropertyTest::basicTest ()
|
||||
|
||||
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 ();
|
||||
@ -61,7 +64,7 @@ AutomationListPropertyTest::basicTest ()
|
||||
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 */
|
||||
@ -99,6 +102,9 @@ PropertyDescriptor<boost::shared_ptr<AutomationList> > Fred::_descriptor;
|
||||
void
|
||||
AutomationListPropertyTest::undoTest ()
|
||||
{
|
||||
list<string> ignore_properties;
|
||||
ignore_properties.push_back ("id");
|
||||
|
||||
Fred::make_property_quarks ();
|
||||
|
||||
boost::shared_ptr<Fred> sheila (new Fred);
|
||||
@ -115,9 +121,9 @@ AutomationListPropertyTest::undoTest ()
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
@ -1,16 +1,14 @@
|
||||
<?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>
|
||||
|
@ -1,23 +1,20 @@
|
||||
<?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>
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?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>
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?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>
|
||||
|
@ -10,17 +10,62 @@ using namespace std;
|
||||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
||||
void
|
||||
check_xml (XMLNode* node, string ref_file)
|
||||
static void
|
||||
check_nodes (XMLNode const * p, XMLNode const * q, list<string> const & ignore_properties)
|
||||
{
|
||||
system ("rm -f libs/ardour/test/test.xml");
|
||||
ofstream f ("libs/ardour/test/test.xml");
|
||||
node->dump (f);
|
||||
f.close ();
|
||||
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());
|
||||
}
|
||||
|
||||
stringstream cmd;
|
||||
cmd << "diff -u libs/ardour/test/test.xml " << ref_file;
|
||||
CPPUNIT_ASSERT_EQUAL (0, system (cmd.str().c_str ()));
|
||||
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
|
||||
write_ref (XMLNode* node, string ref_file)
|
||||
{
|
||||
XMLTree ref;
|
||||
ref.set_root (node);
|
||||
ref.write (ref_file);
|
||||
}
|
||||
|
||||
class TestReceiver : public Receiver
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
class XMLNode;
|
||||
|
||||
@ -6,5 +7,6 @@ namespace ARDOUR {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user