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 PropertyDescriptor<boost::shared_ptr<AutomationList> > descriptor;
35 descriptor.property_id = g_quark_from_static_string ("FadeIn");
36 AutomationListProperty property (
38 boost::shared_ptr<AutomationList> (new AutomationList (Evoral::Parameter (FadeInAutomation)))
41 property.clear_changes ();
43 /* No change since we just cleared them */
44 CPPUNIT_ASSERT_EQUAL (false, property.changed());
49 /* Now it has changed */
50 CPPUNIT_ASSERT_EQUAL (true, property.changed());
52 XMLNode* foo = new XMLNode ("test");
53 property.get_changes_as_xml (foo);
54 check_xml (foo, "../libs/ardour/test/data/automation_list_property_test1.ref");
57 property.clear_changes ();
58 CPPUNIT_ASSERT_EQUAL (false, property.changed());
61 CPPUNIT_ASSERT_EQUAL (true, property.changed());
62 foo = new XMLNode ("test");
63 property.get_changes_as_xml (foo);
64 check_xml (foo, "../libs/ardour/test/data/automation_list_property_test2.ref");
67 /** Here's a StatefulDestructible class that has a AutomationListProperty */
68 class Fred : public StatefulDestructible
72 : _jim (_descriptor, boost::shared_ptr<AutomationList> (new AutomationList (Evoral::Parameter (FadeInAutomation))))
78 XMLNode & get_state () {
79 XMLNode* n = new XMLNode ("State");
84 int set_state (XMLNode const & node, int) {
89 static void make_property_quarks () {
90 _descriptor.property_id = g_quark_from_static_string ("FadeIn");
93 AutomationListProperty _jim;
94 static PropertyDescriptor<boost::shared_ptr<AutomationList> > _descriptor;
97 PropertyDescriptor<boost::shared_ptr<AutomationList> > Fred::_descriptor;
100 AutomationListPropertyTest::undoTest ()
102 Fred::make_property_quarks ();
104 boost::shared_ptr<Fred> sheila (new Fred);
107 sheila->_jim->add (1, 2);
108 sheila->_jim->add (3, 4);
111 sheila->clear_changes ();
112 sheila->_jim->add (5, 6);
113 sheila->_jim->add (7, 8);
114 StatefulDiffCommand sdc (sheila);
118 check_xml (&sheila->get_state(), "../libs/ardour/test/data/automation_list_property_test3.ref");
122 check_xml (&sheila->get_state(), "../libs/ardour/test/data/automation_list_property_test4.ref");