2 Copyright (C) 2012 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "pbd/properties.h"
20 #include "pbd/stateful_diff_command.h"
21 #include "ardour/automation_list.h"
22 #include "automation_list_property_test.h"
23 #include "test_util.h"
25 CPPUNIT_TEST_SUITE_REGISTRATION (AutomationListPropertyTest);
29 using namespace ARDOUR;
32 AutomationListPropertyTest::basicTest ()
34 list<string> ignore_properties;
35 ignore_properties.push_back ("id");
37 PropertyDescriptor<boost::shared_ptr<AutomationList> > descriptor;
38 descriptor.property_id = g_quark_from_static_string ("FadeIn");
39 AutomationListProperty property (
41 boost::shared_ptr<AutomationList> (new AutomationList (Evoral::Parameter (FadeInAutomation)))
44 property.clear_changes ();
46 /* No change since we just cleared them */
47 CPPUNIT_ASSERT_EQUAL (false, property.changed());
52 /* Now it has changed */
53 CPPUNIT_ASSERT_EQUAL (true, property.changed());
55 XMLNode* foo = new XMLNode ("test");
56 property.get_changes_as_xml (foo);
57 check_xml (foo, "../libs/ardour/test/data/automation_list_property_test1.ref", ignore_properties);
60 property.clear_changes ();
61 CPPUNIT_ASSERT_EQUAL (false, property.changed());
64 CPPUNIT_ASSERT_EQUAL (true, property.changed());
65 foo = new XMLNode ("test");
66 property.get_changes_as_xml (foo);
67 check_xml (foo, "../libs/ardour/test/data/automation_list_property_test2.ref", ignore_properties);
70 /** Here's a StatefulDestructible class that has a AutomationListProperty */
71 class Fred : public StatefulDestructible
75 : _jim (_descriptor, boost::shared_ptr<AutomationList> (new AutomationList (Evoral::Parameter (FadeInAutomation))))
81 XMLNode & get_state () {
82 XMLNode* n = new XMLNode ("State");
87 int set_state (XMLNode const & node, int) {
92 static void make_property_quarks () {
93 _descriptor.property_id = g_quark_from_static_string ("FadeIn");
96 AutomationListProperty _jim;
97 static PropertyDescriptor<boost::shared_ptr<AutomationList> > _descriptor;
100 PropertyDescriptor<boost::shared_ptr<AutomationList> > Fred::_descriptor;
103 AutomationListPropertyTest::undoTest ()
105 list<string> ignore_properties;
106 ignore_properties.push_back ("id");
108 Fred::make_property_quarks ();
110 boost::shared_ptr<Fred> sheila (new Fred);
113 sheila->_jim->add (1, 2);
114 sheila->_jim->add (3, 4);
117 sheila->clear_changes ();
118 sheila->_jim->add (5, 6);
119 sheila->_jim->add (7, 8);
120 StatefulDiffCommand sdc (sheila);
124 check_xml (&sheila->get_state(), "../libs/ardour/test/data/automation_list_property_test3.ref", ignore_properties);
128 check_xml (&sheila->get_state(), "../libs/ardour/test/data/automation_list_property_test4.ref", ignore_properties);