END_TEST;
}
+namespace Impl
+{
/**
* A custom actor that is not type registered on purpose
*/
virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
{ }
};
-
-struct UnregisteredCustomActorHandle : public Dali::CustomActor
+}
+struct UnregisteredCustomActor : public Dali::CustomActor
{
- static UnregisteredCustomActorHandle New()
+ static UnregisteredCustomActor New()
{
- UnregisteredCustomActor* impl = new UnregisteredCustomActor;
- UnregisteredCustomActorHandle custom( *impl ); // takes ownership
+ Impl::UnregisteredCustomActor* impl = new Impl::UnregisteredCustomActor;
+ UnregisteredCustomActor custom( *impl ); // takes ownership
return custom;
}
- UnregisteredCustomActorHandle()
- {
- }
- UnregisteredCustomActorHandle( Internal::CustomActor* impl )
+ UnregisteredCustomActor()
+ { }
+ ~UnregisteredCustomActor()
+ { }
+ UnregisteredCustomActor( Internal::CustomActor* impl )
: CustomActor( impl )
- {
- }
- UnregisteredCustomActorHandle( UnregisteredCustomActor& impl )
+ { }
+ UnregisteredCustomActor( Impl::UnregisteredCustomActor& impl )
: CustomActor( impl )
+ { }
+ static UnregisteredCustomActor DownCast( BaseHandle handle )
{
- }
- static UnregisteredCustomActorHandle DownCast( BaseHandle handle )
- {
- UnregisteredCustomActorHandle hndl;
+ UnregisteredCustomActor hndl;
CustomActor custom = Dali::CustomActor::DownCast( handle );
if( custom )
{
CustomActorImpl& customImpl = custom.GetImplementation();
- UnregisteredCustomActor* impl = dynamic_cast<UnregisteredCustomActor*>(&customImpl);
+ Impl::UnregisteredCustomActor* impl = dynamic_cast<Impl::UnregisteredCustomActor*>( &customImpl );
if( impl )
{
- hndl = UnregisteredCustomActorHandle(customImpl.GetOwner());
+ hndl = UnregisteredCustomActor( customImpl.GetOwner() );
}
}
return hndl;
}
-
};
int UtcDaliCustomActorSetGetActorPropertyActionSignal(void)
{
TestApplication application; // Need the type registry
- auto custom = UnregisteredCustomActorHandle::New();
+ auto custom = UnregisteredCustomActor::New();
Stage::GetCurrent().Add( custom );
// should have all actor properties
DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetProperty( Actor::Property::POSITION ).Get<Vector3>(), TEST_LOCATION );
DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetCurrentPosition(), TEST_LOCATION );
- Dali::WeakHandle<UnregisteredCustomActorHandle> weakRef( custom );
+ Dali::WeakHandle<UnregisteredCustomActor> weakRef( custom );
// should have actor signals
custom.ConnectSignal( &application, "offStage",
[weakRef]()
Stage::GetCurrent().Remove( custom );
Stage::GetCurrent().Add( custom );
+ END_TEST;
+}
+
+namespace Impl
+{
+struct DerivedCustomActor : public UnregisteredCustomActor
+{ };
+}
+
+struct DerivedCustomActor : public UnregisteredCustomActor
+{
+ static DerivedCustomActor New()
+ {
+ Impl::DerivedCustomActor* impl = new Impl::DerivedCustomActor;
+ DerivedCustomActor custom( *impl ); // takes ownership
+ return custom;
+ }
+ DerivedCustomActor()
+ { }
+ ~DerivedCustomActor()
+ { }
+ DerivedCustomActor( Internal::CustomActor* impl )
+ : UnregisteredCustomActor( impl )
+ { }
+ DerivedCustomActor( Impl::UnregisteredCustomActor& impl )
+ : UnregisteredCustomActor( impl )
+ { }
+};
+
+// register custom
+DALI_TYPE_REGISTRATION_BEGIN( DerivedCustomActor, UnregisteredCustomActor, nullptr );
+DALI_TYPE_REGISTRATION_END()
+
+int UtcDaliCustomActorPropertyRegistrationDefaultValue(void)
+{
+ TestApplication application; // Need the type registry
+
+ // register our base and add a property with default value for it
+ Dali::TypeRegistration typeRegistration( typeid( UnregisteredCustomActor ), typeid( Dali::CustomActor ), nullptr );
+
+ auto derived = DerivedCustomActor::New();
+ Stage::GetCurrent().Add( derived );
+
+ // should have all actor properties
+ DALI_TEST_EQUALS( derived.GetPropertyType( Actor::Property::WORLD_MATRIX ), Property::MATRIX, TEST_LOCATION );
+ auto actorHandle = Actor::New();
+ DALI_TEST_EQUALS( derived.GetPropertyCount(), actorHandle.GetPropertyCount(), TEST_LOCATION );
+
+ // add a property in base class
+ AnimatablePropertyRegistration( typeRegistration, "Foobar", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, 10.f );
+
+ // should be one more property now
+ DALI_TEST_EQUALS( derived.GetPropertyCount(), actorHandle.GetPropertyCount() + 1, TEST_LOCATION );
+ // check that the default value is set for base class
+ DALI_TEST_EQUALS( UnregisteredCustomActor::New().GetProperty(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX).Get<float>(), 10.f, TEST_LOCATION );
+ // check that the default value is set for the derived instance as well
+ DALI_TEST_EQUALS( derived.GetProperty(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX).Get<float>(), 10.f, TEST_LOCATION );
END_TEST;
}