2010-04-02 11:35:36 -04:00
|
|
|
#include "scalar_properties.h"
|
|
|
|
|
2010-04-02 12:38:23 -04:00
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION (ScalarPropertiesTest);
|
|
|
|
|
|
|
|
using namespace std;
|
2010-04-02 11:35:36 -04:00
|
|
|
using namespace PBD;
|
|
|
|
|
2010-04-02 11:45:01 -04:00
|
|
|
namespace Properties {
|
|
|
|
PBD::PropertyDescriptor<int> fred;
|
|
|
|
};
|
|
|
|
|
2010-04-02 12:38:23 -04:00
|
|
|
void
|
|
|
|
ScalarPropertiesTest::make_property_quarks ()
|
|
|
|
{
|
|
|
|
Properties::fred.property_id = g_quark_from_static_string ("fred");
|
|
|
|
}
|
|
|
|
|
2010-04-02 11:45:01 -04:00
|
|
|
ScalarPropertiesTest::ScalarPropertiesTest ()
|
|
|
|
: _fred (Properties::fred, 0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-04-02 11:35:36 -04:00
|
|
|
ScalarPropertiesTest::testBasic ()
|
|
|
|
{
|
2010-04-02 11:45:01 -04:00
|
|
|
CPPUNIT_ASSERT (_fred.changed() == false);
|
2010-04-02 12:38:23 -04:00
|
|
|
|
2010-04-02 11:45:01 -04:00
|
|
|
_fred = 4;
|
|
|
|
CPPUNIT_ASSERT (_fred == 4);
|
|
|
|
CPPUNIT_ASSERT (_fred.changed() == true);
|
2010-04-02 11:35:36 -04:00
|
|
|
|
2010-08-25 13:32:08 -04:00
|
|
|
_fred.clear_changes ();
|
2010-04-02 12:38:23 -04:00
|
|
|
CPPUNIT_ASSERT (_fred.changed() == false);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2010-04-02 11:45:01 -04:00
|
|
|
_fred = 5;
|
|
|
|
CPPUNIT_ASSERT (_fred == 5);
|
|
|
|
CPPUNIT_ASSERT (_fred.changed() == true);
|
2010-04-02 11:35:36 -04:00
|
|
|
|
2010-08-25 16:53:27 -04:00
|
|
|
PropertyList changes;
|
|
|
|
_fred.get_changes_as_properties (changes, 0);
|
2010-04-02 12:38:23 -04:00
|
|
|
|
2010-08-25 16:53:27 -04:00
|
|
|
CPPUNIT_ASSERT (changes.size() == 1);
|
2010-04-02 12:38:23 -04:00
|
|
|
|
2010-08-25 16:53:27 -04:00
|
|
|
PropertyTemplate<int>* t = dynamic_cast<Property<int>*> (changes.begin()->second);
|
2010-04-02 12:38:23 -04:00
|
|
|
CPPUNIT_ASSERT (t);
|
2011-03-04 12:35:10 -05:00
|
|
|
CPPUNIT_ASSERT (t->val() == 5);
|
2010-04-02 11:35:36 -04:00
|
|
|
}
|