X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Ftest%2Fscalar_properties.cc;h=3586fc3a957bb7a30244c96aa9e2bb1b33ebfe30;hb=c046b7c9d36d54600907565271a8ea2ceb004300;hp=f85b1081a40ded2e0bb47e064bb2e5107d611005;hpb=eecb8c496a7585b51e112860cc92388ca27e4403;p=ardour.git diff --git a/libs/pbd/test/scalar_properties.cc b/libs/pbd/test/scalar_properties.cc index f85b1081a4..3586fc3a95 100644 --- a/libs/pbd/test/scalar_properties.cc +++ b/libs/pbd/test/scalar_properties.cc @@ -1,20 +1,47 @@ #include "scalar_properties.h" +CPPUNIT_TEST_SUITE_REGISTRATION (ScalarPropertiesTest); + +using namespace std; using namespace PBD; +namespace Properties { + PBD::PropertyDescriptor fred; +}; + +void +ScalarPropertiesTest::make_property_quarks () +{ + Properties::fred.property_id = g_quark_from_static_string ("fred"); +} + +ScalarPropertiesTest::ScalarPropertiesTest () + : _fred (Properties::fred, 0) +{ +} + +void ScalarPropertiesTest::testBasic () { - CPPUNIT_ASSERT (_property.changed() == false); + CPPUNIT_ASSERT (_fred.changed() == false); + + _fred = 4; + CPPUNIT_ASSERT (_fred == 4); + CPPUNIT_ASSERT (_fred.changed() == true); + + _fred.clear_changes (); + CPPUNIT_ASSERT (_fred.changed() == false); - _property = 4; - CPPUNIT_ASSERT (_property == 4); - CPPUNIT_ASSERT (_property.changed() == true); + _fred = 5; + CPPUNIT_ASSERT (_fred == 5); + CPPUNIT_ASSERT (_fred.changed() == true); + + PropertyList changes; + _fred.get_changes_as_properties (changes, 0); - _property = 5; - CPPUNIT_ASSERT (_property == 5); - CPPUNIT_ASSERT (_property.changed() == true); + CPPUNIT_ASSERT (changes.size() == 1); - PropertyList undo; - PropertyList redo; - _property.diff (undo, redo); + PropertyTemplate* t = dynamic_cast*> (changes.begin()->second); + CPPUNIT_ASSERT (t); + CPPUNIT_ASSERT (t->val() == 5); }