mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
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
7 changed files with 87 additions and 41 deletions
|
|
@ -31,6 +31,9 @@ using namespace ARDOUR;
|
||||||
void
|
void
|
||||||
AutomationListPropertyTest::basicTest ()
|
AutomationListPropertyTest::basicTest ()
|
||||||
{
|
{
|
||||||
|
list<string> ignore_properties;
|
||||||
|
ignore_properties.push_back ("id");
|
||||||
|
|
||||||
PropertyDescriptor<boost::shared_ptr<AutomationList> > descriptor;
|
PropertyDescriptor<boost::shared_ptr<AutomationList> > descriptor;
|
||||||
descriptor.property_id = g_quark_from_static_string ("FadeIn");
|
descriptor.property_id = g_quark_from_static_string ("FadeIn");
|
||||||
AutomationListProperty property (
|
AutomationListProperty property (
|
||||||
|
|
@ -51,7 +54,7 @@ AutomationListPropertyTest::basicTest ()
|
||||||
|
|
||||||
XMLNode* foo = new XMLNode ("test");
|
XMLNode* foo = new XMLNode ("test");
|
||||||
property.get_changes_as_xml (foo);
|
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 */
|
/* Do some more */
|
||||||
property.clear_changes ();
|
property.clear_changes ();
|
||||||
|
|
@ -61,7 +64,7 @@ AutomationListPropertyTest::basicTest ()
|
||||||
CPPUNIT_ASSERT_EQUAL (true, property.changed());
|
CPPUNIT_ASSERT_EQUAL (true, property.changed());
|
||||||
foo = new XMLNode ("test");
|
foo = new XMLNode ("test");
|
||||||
property.get_changes_as_xml (foo);
|
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 */
|
/** Here's a StatefulDestructible class that has a AutomationListProperty */
|
||||||
|
|
@ -99,6 +102,9 @@ PropertyDescriptor<boost::shared_ptr<AutomationList> > Fred::_descriptor;
|
||||||
void
|
void
|
||||||
AutomationListPropertyTest::undoTest ()
|
AutomationListPropertyTest::undoTest ()
|
||||||
{
|
{
|
||||||
|
list<string> ignore_properties;
|
||||||
|
ignore_properties.push_back ("id");
|
||||||
|
|
||||||
Fred::make_property_quarks ();
|
Fred::make_property_quarks ();
|
||||||
|
|
||||||
boost::shared_ptr<Fred> sheila (new Fred);
|
boost::shared_ptr<Fred> sheila (new Fred);
|
||||||
|
|
@ -115,9 +121,9 @@ AutomationListPropertyTest::undoTest ()
|
||||||
|
|
||||||
/* Undo */
|
/* Undo */
|
||||||
sdc.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 */
|
/* Redo */
|
||||||
sdc.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>
|
<test>
|
||||||
<FadeIn>
|
<FadeIn>
|
||||||
<from>
|
<from>
|
||||||
<AutomationList automation-id="fadein" id="162" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
<AutomationList automation-id="fadein" id="164" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute"/>
|
||||||
</AutomationList>
|
|
||||||
</from>
|
</from>
|
||||||
<to>
|
<to>
|
||||||
<AutomationList automation-id="fadein" id="162" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
<AutomationList automation-id="fadein" id="163" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
||||||
<events>
|
<events>1 2
|
||||||
1 2
|
|
||||||
3 4
|
3 4
|
||||||
|
</events>
|
||||||
</events>
|
|
||||||
</AutomationList>
|
</AutomationList>
|
||||||
</to>
|
</to>
|
||||||
</FadeIn>
|
</FadeIn>
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<test>
|
<test>
|
||||||
<FadeIn>
|
<FadeIn>
|
||||||
<from>
|
<from>
|
||||||
<AutomationList automation-id="fadein" id="162" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
<AutomationList automation-id="fadein" id="165" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
||||||
<events>
|
<events>1 2
|
||||||
1 2
|
|
||||||
3 4
|
3 4
|
||||||
|
</events>
|
||||||
</events>
|
|
||||||
</AutomationList>
|
</AutomationList>
|
||||||
</from>
|
</from>
|
||||||
<to>
|
<to>
|
||||||
<AutomationList automation-id="fadein" id="162" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
<AutomationList automation-id="fadein" id="163" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
||||||
<events>
|
<events>1 2
|
||||||
1 2
|
|
||||||
3 4
|
3 4
|
||||||
5 6
|
5 6
|
||||||
7 8
|
7 8
|
||||||
|
</events>
|
||||||
</events>
|
|
||||||
</AutomationList>
|
</AutomationList>
|
||||||
</to>
|
</to>
|
||||||
</FadeIn>
|
</FadeIn>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<State>
|
<State>
|
||||||
<FadeIn>
|
<FadeIn>
|
||||||
<AutomationList automation-id="fadein" id="166" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
<AutomationList automation-id="fadein" id="167" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
||||||
<events>
|
<events>1 2
|
||||||
1 2
|
|
||||||
3 4
|
3 4
|
||||||
|
</events>
|
||||||
</events>
|
|
||||||
</AutomationList>
|
</AutomationList>
|
||||||
</FadeIn>
|
</FadeIn>
|
||||||
</State>
|
</State>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<State>
|
<State>
|
||||||
<FadeIn>
|
<FadeIn>
|
||||||
<AutomationList automation-id="fadein" id="166" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
<AutomationList automation-id="fadein" id="167" default="0" min-yval="0" max-yval="2" interpolation-style="Linear" state="Off" style="Absolute">
|
||||||
<events>
|
<events>1 2
|
||||||
1 2
|
|
||||||
3 4
|
3 4
|
||||||
5 6
|
5 6
|
||||||
7 8
|
7 8
|
||||||
|
</events>
|
||||||
</events>
|
|
||||||
</AutomationList>
|
</AutomationList>
|
||||||
</FadeIn>
|
</FadeIn>
|
||||||
</State>
|
</State>
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,62 @@ using namespace std;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
|
|
||||||
void
|
static void
|
||||||
check_xml (XMLNode* node, string ref_file)
|
check_nodes (XMLNode const * p, XMLNode const * q, list<string> const & ignore_properties)
|
||||||
{
|
{
|
||||||
system ("rm -f libs/ardour/test/test.xml");
|
CPPUNIT_ASSERT_EQUAL (p->is_content(), q->is_content());
|
||||||
ofstream f ("libs/ardour/test/test.xml");
|
if (!p->is_content()) {
|
||||||
node->dump (f);
|
CPPUNIT_ASSERT_EQUAL (p->name(), q->name());
|
||||||
f.close ();
|
} else {
|
||||||
|
CPPUNIT_ASSERT_EQUAL (p->content(), q->content());
|
||||||
|
}
|
||||||
|
|
||||||
stringstream cmd;
|
XMLPropertyList const & pp = p->properties ();
|
||||||
cmd << "diff -u libs/ardour/test/test.xml " << ref_file;
|
XMLPropertyList const & qp = q->properties ();
|
||||||
CPPUNIT_ASSERT_EQUAL (0, system (cmd.str().c_str ()));
|
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
|
class TestReceiver : public Receiver
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
|
|
||||||
|
|
@ -6,5 +7,6 @@ namespace ARDOUR {
|
||||||
class Session;
|
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);
|
extern ARDOUR::Session* load_session (std::string, std::string);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue