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-04-02 12:38:23 -04:00
|
|
|
_fred.clear_history ();
|
|
|
|
CPPUNIT_ASSERT (_fred.changed() == false);
|
|
|
|
|
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
|
|
|
|
|
|
|
PropertyList undo;
|
|
|
|
PropertyList redo;
|
2010-04-02 11:45:01 -04:00
|
|
|
_fred.diff (undo, redo);
|
2010-04-02 12:38:23 -04:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT (undo.size() == 1);
|
|
|
|
CPPUNIT_ASSERT (redo.size() == 1);
|
|
|
|
|
|
|
|
PropertyTemplate<int>* t = dynamic_cast<Property<int>*> (undo.begin()->second);
|
|
|
|
CPPUNIT_ASSERT (t);
|
|
|
|
CPPUNIT_ASSERT (t->val() == 4);
|
|
|
|
|
|
|
|
t = dynamic_cast<Property<int>*> (redo.begin()->second);
|
|
|
|
CPPUNIT_ASSERT (t);
|
|
|
|
CPPUNIT_ASSERT (t->val() == 5);
|
2010-04-02 11:35:36 -04:00
|
|
|
}
|