/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/object/handle-devel.h>
#include "dali-test-suite-utils/dali-test-suite-utils.h"
+#include "dali-test-suite-utils/test-custom-actor.h"
+
#include <mesh-builder.h>
using namespace Dali;
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_ORIENTATION ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_SCALE ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_MODE ) );
- DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_INHERITANCE ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::DRAW_MODE ) );
DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE_FACTOR ) );
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Property type is not animatable", TEST_LOCATION );
}
DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
END_TEST;
}
+int UtcDaliHandleCustomPropertyNone(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ Property::Value value( Property::NONE );
+ Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
+
+ // Negative test i.e. setting a property of type NONE is meaningless
+ handle.SetProperty( index, 5.0f );
+
+ DALI_TEST_CHECK( true ); // got here without crashing
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyIntToFloat(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ float startValue(5.0f);
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue );
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
+
+ handle.SetProperty( index, int(1) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == 1.0f );
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyFloatToInt(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ int startValue(5);
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue );
+ DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
+
+ handle.SetProperty( index, float(1.5) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<int>(index) == 1 );
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToRect(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ Rect<int> startValue(1,2,3,4);
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
+ DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
+
+ // Negative test i.e. there is no conversion from float to Rect
+ handle.SetProperty( index, float(1.5) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
+
+ // Positive test (sanity check)
+ Rect<int> endValue(5,6,7,8);
+ handle.SetProperty( index, endValue );
+ DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToString(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ std::string startValue( "Libraries gave us power" );
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
+ DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
+
+ // No conversion from Vector3 to std::string, therefore this should be a NOOP
+ handle.SetProperty( index, Vector3(1,2,3) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
+
+ // Positive test (sanity check)
+ std::string endValue( "Then work came and made us free" );
+ handle.SetProperty( index, endValue );
+ DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToArray(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ Property::Value value( Property::ARRAY );
+ std::string startValue( "The future teaches you to be alone" );
+ value.GetArray()->PushBack( startValue );
+
+ Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
+ Property::Array check1 = handle.GetProperty< Property::Array >( index );
+ DALI_TEST_EQUALS( check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ Property::Array check2 = handle.GetProperty< Property::Array >( index );
+ DALI_TEST_EQUALS( check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
+
+ // No conversion from int to ARRAY, therefore this should be a NOOP
+ handle.SetProperty( index, int(2) );
+
+ application.SendNotification();
+ application.Render(0);
+ Property::Array check3 = handle.GetProperty< Property::Array >( index );
+ DALI_TEST_EQUALS( check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
+
+ // Positive test (sanity check)
+ Property::Value value2(Property::ARRAY);
+ std::string endValue( "The present to be afraid and cold" );
+ value2.GetArray()->PushBack( endValue );
+ handle.SetProperty( index, value2 );
+
+ Property::Array check4 = handle.GetProperty< Property::Array >( index );
+ DALI_TEST_EQUALS( check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ Property::Array check5 = handle.GetProperty< Property::Array >( index );
+ DALI_TEST_EQUALS( check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToMap(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ Property::Value value( Property::MAP );
+ std::string startValue( "Culture sucks down words" );
+ value.GetMap()->Insert( "1", startValue );
+
+ Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE );
+ Property::Value* check1 = handle.GetProperty< Property::Map >( index ).Find("1");
+ DALI_TEST_CHECK( NULL != check1 );
+
+ // No conversion from float to MAP, therefore this should be a NOOP
+ handle.SetProperty( index, float(3.0) );
+
+ // Positive test (sanity check)
+ Property::Value value2( Property::MAP );
+ std::string endValue( "Itemise loathing and feed yourself smiles" );
+ value.GetMap()->Insert( "1", endValue );
+ handle.SetProperty( index, value2 );
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToExtents(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ Extents startValue(1,2,3,4);
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
+ DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
+
+ // Negative test i.e. there is no conversion from float to Extents
+ handle.SetProperty( index, float(1.5) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
+
+ // Positive test (sanity check)
+ Extents endValue(5,6,7,8);
+ handle.SetProperty( index, endValue );
+ DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToBool(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ bool startValue(true);
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
+ DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
+
+ // Negative test i.e. there is no conversion from float to bool
+ handle.SetProperty( index, float(0.0) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
+
+ // Positive test (sanity check)
+ bool endValue(false);
+ handle.SetProperty( index, endValue );
+ DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToInt(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ int startValue(5);
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue );
+ DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
+
+ // Negative test i.e. there is no conversion from Vector3 to int
+ handle.SetProperty( index, Vector3(1,2,3) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToFloat(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ float startValue(5.0);
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue );
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
+
+ // Negative test i.e. there is no conversion from Vector3 to float
+ handle.SetProperty( index, Vector3(1,2,3) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToRotation(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ Quaternion startValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue );
+ DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
+
+ // Negative test i.e. there is no conversion from float to Quaternion
+ handle.SetProperty( index, float(7.0) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
+
+ // Positive test (sanity check)
+ Quaternion endValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
+ handle.SetProperty( index, endValue );
+ DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == endValue );
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
+ Matrix startValue(rotation);
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue );
+ DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
+
+ // Negative test i.e. there is no conversion from float to Matrix
+ handle.SetProperty( index, float(7.0) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
+
+ // Positive test (sanity check)
+ Quaternion endRotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
+ Matrix endValue(endRotation);
+ handle.SetProperty( index, endValue );
+ DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == endValue );
+
+ END_TEST;
+}
+
+int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New();
+
+ Matrix3 startValue(11,12,13,
+ 21,22,23,
+ 31,32,33);
+
+ Property::Index index = handle.RegisterProperty( "testProperty", startValue );
+ DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
+
+ // Negative test i.e. there is no conversion from float to Matrix3
+ handle.SetProperty( index, float(7.0) );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
+
+ // Positive test (sanity check)
+ Matrix3 endValue(31,32,33,
+ 21,22,23,
+ 11,12,13);
+ handle.SetProperty( index, endValue );
+ DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == endValue );
+
+ END_TEST;
+}
+
int UtcDaliHandleWeightNew(void)
{
TestApplication application;
END_TEST;
}
+
+int UtcDaliHandleDoesCustomPropertyExistP1(void)
+{
+ TestApplication application; // Needs type registry
+
+ tet_infoline( "Test if a registered custom property exists on object" );
+
+ Actor actor = Actor::New();
+ auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
+
+ DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex ), true, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliHandleDoesCustomPropertyExistN1(void)
+{
+ TestApplication application; // Needs type registry
+
+ tet_infoline( "Test if a registered custom property does not exist on object" );
+
+ Actor actor = Actor::New();
+ auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
+
+ DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex+1 ), false, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliHandleDoesCustomPropertyExistN2(void)
+{
+ TestApplication application; // Needs type registry
+
+ tet_infoline( "Test that a default property does not show as a custom property on object" );
+
+ Actor actor = Actor::New();
+ DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, Actor::Property::POSITION ), false, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliHandleDoesCustomPropertyExistN3(void)
+{
+ TestApplication application; // Needs type registry
+
+ tet_infoline( "Test that a child property does not exist on actor after parenting to container" );
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
+
+ const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ const char* CHILD_PROPERTY_NAME( "childProperty" );
+
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
+
+ auto container = Test::TestCustomActor::New();
+ Stage::GetCurrent().Add( container );
+ auto child = Actor::New();
+ container.Add( child ); // Resolve child properties (if any)
+
+ DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), false, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliHandleDoesCustomPropertyExistP2(void)
+{
+ TestApplication application; // Needs type registry
+
+ tet_infoline( "Test that a child property exists after being set" );
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
+
+ const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ const char* CHILD_PROPERTY_NAME( "childProperty" );
+
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
+
+ auto container = Test::TestCustomActor::New();
+ Stage::GetCurrent().Add( container );
+ auto child = Actor::New();
+ container.Add( child ); // Resolve child properties (if any)
+ child.SetProperty( CHILD_PROPERTY, 2 );
+
+ DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 2, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliHandleDoesCustomPropertyExistP3(void)
+{
+ TestApplication application; // Needs type registry
+
+ tet_infoline( "Test that a child property is re-indexed after registration, and that it exists" );
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
+
+ const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ const char* CHILD_PROPERTY_NAME( "childProperty" );
+
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
+
+ auto container = Test::TestCustomActor::New();
+ Stage::GetCurrent().Add( container );
+ auto child = Actor::New();
+ child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
+ container.Add( child ); // Resolve child properties (if any)
+
+ DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
+ END_TEST;
+}
+
+namespace
+{
+
+struct PropertySetSignalCheck
+{
+ PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
+ : mSignalReceived(signalReceived),
+ mValue(value)
+ {
+ }
+
+ void operator()(Handle& handle, Property::Index index, Property::Value value)
+ {
+ mSignalReceived = true;
+ mValue = value;
+ }
+
+ void Reset()
+ {
+ mSignalReceived = false;
+ }
+
+ void CheckSignalReceived()
+ {
+ if (!mSignalReceived)
+ {
+ tet_printf("Expected Property Set signal was not received\n");
+ tet_result(TET_FAIL);
+ }
+ else
+ {
+ tet_result(TET_PASS);
+ }
+ }
+
+ bool& mSignalReceived; // owned by individual tests
+ Property::Value& mValue;
+};
+
+} // anon namespace
+
+int UtcDaliHandlePropertySetSignal01(void)
+{
+ TestApplication app;
+
+ bool signalReceived(false);
+ Property::Value value;
+ PropertySetSignalCheck propertySetCheck(signalReceived, value);
+
+ tet_infoline( "Test that setting a default property triggers a signal" );
+
+ auto actor = Actor::New();
+ DevelHandle::PropertySetSignal(actor).Connect(&app, propertySetCheck);
+
+ actor.SetProperty( Actor::Property::POSITION, Vector3::XAXIS );
+ propertySetCheck.CheckSignalReceived();
+
+ END_TEST;
+}
+
+
+int UtcDaliHandlePropertySetSignal02(void)
+{
+ TestApplication app;
+
+ bool signalReceived(false);
+ Property::Value value;
+ PropertySetSignalCheck propertySetCheck(signalReceived, value);
+
+ tet_infoline( "Test that setting a custom property triggers a signal" );
+
+ auto actor = Actor::New();
+ DevelHandle::PropertySetSignal(actor).Connect(&app, propertySetCheck);
+
+ auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
+ actor.SetProperty( propertyIndex, 5.0f );
+ propertySetCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 5.0f ), 0.001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliHandlePropertySetSignal03(void)
+{
+ TestApplication app;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ bool signalReceived(false);
+ Property::Value value;
+ PropertySetSignalCheck propertySetCheck(signalReceived, value);
+
+ tet_infoline( "Test that setting a child property triggers a signal" );
+
+ auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
+
+ const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ const char* CHILD_PROPERTY_NAME( "childProperty" );
+
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
+
+ auto container = Test::TestCustomActor::New();
+ Stage::GetCurrent().Add( container );
+ auto child = Actor::New();
+ child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
+ DevelHandle::PropertySetSignal(child).Connect(&app, propertySetCheck);
+ container.Add( child ); // Resolve child properties (if any)
+
+ DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
+
+ child.SetProperty( CHILD_PROPERTY, 29 );
+ propertySetCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 29 ), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliHandlePropertySetProperties(void)
+{
+ TestApplication application;
+ const Vector3 actorSize( 10.0f, 20.0f, 30.0f );
+ const Vector3 anchorPoint( 1.0f, 0.5f, 0.0f );
+ const Vector4 color( 0.1f, 0.2, 0.3f, 0.4f );
+
+ Handle handle = Actor::New();
+ DevelHandle::SetProperties(
+ handle,
+ Property::Map
+ {
+ { Actor::Property::SIZE, actorSize },
+ { Actor::Property::ANCHOR_POINT, anchorPoint },
+ { "color", color },
+ { "invalid", Vector2::ZERO } // It should quietly ignore invalid data
+ }
+ );
+ DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(), actorSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::ANCHOR_POINT ).Get< Vector3 >(), anchorPoint, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::COLOR ).Get< Vector4 >(), color, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliHandleTemplateNew(void)
+{
+ TestApplication application;
+ const Vector3 actorSize( 10.0f, 20.0f, 30.0f );
+ const Vector3 anchorPoint( 1.0f, 0.5f, 0.0f );
+ const Vector4 color( 0.1f, 0.2, 0.3f, 0.4f );
+
+ Handle handle = DevelHandle::New< Actor >(
+ Property::Map
+ {
+ { Actor::Property::SIZE, actorSize },
+ { Actor::Property::ANCHOR_POINT, anchorPoint },
+ { "color", color },
+ { "invalid", Vector2::ZERO } // It should quietly ignore invalid data
+ }
+ );
+
+ DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(), actorSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::ANCHOR_POINT ).Get< Vector3 >(), anchorPoint, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::COLOR ).Get< Vector4 >(), color, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliHandleGetProperties(void)
+{
+ TestApplication application;
+
+ Handle handle = Actor::New();
+ DevelHandle::SetProperties(
+ handle,
+ Property::Map
+ {
+ { Actor::Property::SIZE, Vector3( 400.0f, 200.0f, 100.0f ) },
+ { Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER },
+ { Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER },
+ { Actor::Property::NAME, "Actor" },
+ { Actor::Property::LEAVE_REQUIRED, true },
+ { "color", Color::RED },
+ }
+ );
+
+ Property::Map map;
+ DevelHandle::GetProperties( handle, map );
+
+ // Get all the properties and ensure they match
+
+ DALI_TEST_EQUALS( handle.GetPropertyCount(), map.Count(), TEST_LOCATION );
+
+ for( auto position = 0u; position < map.Count(); ++position )
+ {
+ auto keyValuePair = map.GetKeyValue( position );
+ const auto& index = keyValuePair.first.indexKey;
+ const auto& value = keyValuePair.second;
+ auto handleValue = handle.GetProperty( index );
+
+ switch( value.GetType() )
+ {
+ case Property::NONE: break;
+ case Property::BOOLEAN: DALI_TEST_EQUALS( value.Get< bool >(), handleValue.Get< bool >(), TEST_LOCATION ); break;
+ case Property::FLOAT: DALI_TEST_EQUALS( value.Get< float >(), handleValue.Get< float >(), TEST_LOCATION ); break;
+ case Property::INTEGER: DALI_TEST_EQUALS( value.Get< int >(), handleValue.Get< int >(), TEST_LOCATION ); break;
+ case Property::VECTOR2: DALI_TEST_EQUALS( value.Get< Vector2 >(), handleValue.Get< Vector2 >(), TEST_LOCATION ); break;
+ case Property::VECTOR3: DALI_TEST_EQUALS( value.Get< Vector3 >(), handleValue.Get< Vector3 >(), TEST_LOCATION ); break;
+ case Property::VECTOR4: DALI_TEST_EQUALS( value.Get< Vector4 >(), handleValue.Get< Vector4 >(), TEST_LOCATION ); break;
+ case Property::MATRIX3: DALI_TEST_EQUALS( value.Get< Matrix3 >(), handleValue.Get< Matrix3 >(), TEST_LOCATION ); break;
+ case Property::MATRIX: DALI_TEST_EQUALS( value.Get< Matrix >(), handleValue.Get< Matrix >(), TEST_LOCATION ); break;
+ case Property::RECTANGLE: DALI_TEST_EQUALS( value.Get< Rect< int > >(), handleValue.Get< Rect< int > >(), TEST_LOCATION ); break;
+ case Property::ROTATION: DALI_TEST_EQUALS( value.Get< Quaternion >(), handleValue.Get< Quaternion >(), TEST_LOCATION ); break;
+ case Property::STRING: DALI_TEST_EQUALS( value.Get< std::string >(), handleValue.Get< std::string >(), TEST_LOCATION ); break;
+ case Property::ARRAY: DALI_TEST_EQUALS( value.GetArray()->Count(), handleValue.GetArray()->Count(), TEST_LOCATION ); break;
+ case Property::MAP: DALI_TEST_EQUALS( value.GetMap()->Count(), handleValue.GetMap()->Count(), TEST_LOCATION ); break;
+ case Property::EXTENTS: DALI_TEST_EQUALS( value.Get< Extents >(), handleValue.Get< Extents >(), TEST_LOCATION ); break;
+ }
+ }
+
+ // Add a custom property and ensure the count goes up by one.
+ const auto countBefore = map.Count();
+ handle.RegisterProperty( "tempProperty", Color::GREEN );
+ DevelHandle::GetProperties( handle, map );
+ DALI_TEST_EQUALS( countBefore + 1, map.Count(), TEST_LOCATION );
+
+ END_TEST;
+}