X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-TypeRegistry.cpp;h=fd6d4cb2b0f2597e3cc688d3821e1e260dd10fa5;hb=3b1dbdc4b4cdbfbdfb558aa53eca064bb97bdb32;hp=8362803592b8633d04168aa2d503df22b19eab3e;hpb=34cdcd658cf987f6659bbd3b3fc7a1e4a6fb2003;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp index 8362803..fd6d4cb 100644 --- a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp +++ b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -21,12 +21,9 @@ #include #include #include -#include -#include -#include -#include #include #include +#include using namespace Dali; @@ -82,70 +79,6 @@ struct GestureReceivedFunctor SignalData& signalData; }; -// Generate a LongPressGestureEvent to send to Core -Integration::LongPressGestureEvent GenerateLongPress( - Gesture::State state, - unsigned int numberOfTouches, - Vector2 point) -{ - Integration::LongPressGestureEvent longPress( state ); - - longPress.numberOfTouches = numberOfTouches; - longPress.point = point; - - return longPress; -} - -// Generate a PanGestureEvent to send to Core -Integration::PanGestureEvent GeneratePan( - Gesture::State state, - Vector2 previousPosition, - Vector2 currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1, - unsigned int time = 1u) -{ - Integration::PanGestureEvent pan(state); - - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - pan.time = time; - - return pan; -} -// Generate a PinchGestureEvent to send to Core -Integration::PinchGestureEvent GeneratePinch( - Gesture::State state, - float scale, - float speed, - Vector2 centerpoint) -{ - Integration::PinchGestureEvent pinch(state); - - pinch.scale = scale; - pinch.speed = speed; - pinch.centerPoint = centerpoint; - - return pinch; -} -// Generate a TapGestureEvent to send to Core -Integration::TapGestureEvent GenerateTap( - Gesture::State state, - unsigned int numberOfTaps, - unsigned int numberOfTouches, - Vector2 point) -{ - Integration::TapGestureEvent tap( state ); - - tap.numberOfTaps = numberOfTaps; - tap.numberOfTouches = numberOfTouches; - tap.point = point; - - return tap; -} - // // Create function as Init function called // @@ -880,7 +813,7 @@ int UtcDaliTypeRegistryRegisteredNameN(void) } catch ( DaliException& e ) { - DALI_TEST_ASSERT( e, "Duplicate type name for Type Registation", TEST_LOCATION ); + DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION ); } END_TEST; @@ -1053,6 +986,12 @@ int UtcDaliTypeRegistryPropertyRegistrationP(void) (void)customActor.GetProperty< bool >( propertyIndex ); DALI_TEST_CHECK( getPropertyCalled ); + // Get the property using GetCurrentProperty and ensure GetProperty is called + getPropertyCalled = false; + DALI_TEST_CHECK( !getPropertyCalled ); + customActor.GetCurrentProperty< bool >( propertyIndex ); + DALI_TEST_CHECK( getPropertyCalled ); + // Check the property name DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION ); DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION ); @@ -1068,7 +1007,7 @@ int UtcDaliTypeRegistryPropertyRegistrationP(void) typeInfo.GetPropertyIndices( indices ); size_t typePropertyCount = typeInfo.GetPropertyCount(); - DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION ); DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION ); // Ensure indices returned from actor and customActor differ by two @@ -1158,7 +1097,7 @@ int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void) // Check property count of type-info is 1 Property::IndexContainer indices; typeInfo.GetPropertyIndices( indices ); - DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION ); // Ensure indices returned from actor and customActor differ by one Actor actor = Actor::New(); @@ -1172,16 +1111,21 @@ int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void) Animation animation = Animation::New(0.2f); animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR ); animation.Play(); + + // Target value should change straight away + DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION ); + // Render and notify, animation play for 0.05 seconds application.SendNotification(); application.Render(50); DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION ); + // Render and notify, animation play for another 0.1 seconds application.SendNotification(); application.Render(100); DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION ); END_TEST; } @@ -1256,10 +1200,10 @@ int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void) // Check the animatable property type DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION ); - // Check property count of type-info is 1 + // Check property count of type-info Property::IndexContainer indices; typeInfo.GetPropertyIndices( indices ); - DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION ); // Ensure indices returned from actor and customActor differ by one Actor actor = Actor::New(); @@ -1273,16 +1217,21 @@ int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void) Animation animation = Animation::New(0.2f); animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR ); animation.Play(); + + // Target value should change straight away + DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION ); + // Render and notify, animation play for 0.05 seconds application.SendNotification(); application.Render(50); DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION ); + // Render and notify, animation play for another 0.1 seconds application.SendNotification(); application.Render(100); DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION ); END_TEST; } @@ -1360,10 +1309,10 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void) // Check the animatable property type DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION ); - // Check property count of type-info is 1 + // Check property count of type-info Property::IndexContainer indices; typeInfo.GetPropertyIndices( indices ); - DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION ); // Register animatable property components std::string animatablePropertyComponentName1( "animatableProp1X" ); @@ -1378,8 +1327,8 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void) DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION ); // Check the animatable property component value - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION ); // Set the animatable property component value customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f ); @@ -1389,9 +1338,9 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void) application.Render(); // Check the animatable property value - DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION ); // Set the animatable property component value customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f ); @@ -1401,9 +1350,9 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void) application.Render(); // Check the animatable property value - DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION ); // Ensure indices returned from actor and customActor differ by three Actor actor = Actor::New(); @@ -1413,6 +1362,193 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void) unsigned int customActorIndices = indices.Size(); DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property + // Attempt to animate component property, it should not crash + Animation animation = Animation::New( 1.0f ); + animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f ); + animation.Play(); + + // Check the property value + DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + + const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX; + const unsigned int xComponentIndex = index + 1; + const unsigned int yComponentIndex = index + 2; + const Vector2 initialValue( 20.0f, 40.0f ); + + // Register animatable property & its components + AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue ); + AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 ); + AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 ); + + // Check the animatable property value + DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check the animatable property current value + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION ); + + // Do an AnimateBy + const Vector2 targetValue( 45.0f, 53.0f ); + const Vector2 relativeValue( targetValue - initialValue ); + + Animation animation = Animation::New( 1.0f ); + animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x ); + animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y ); + animation.Play(); + + // Target values should change straight away + DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + + const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX; + const unsigned int xComponentIndex = index + 1; + const unsigned int yComponentIndex = index + 2; + const unsigned int zComponentIndex = index + 3; + const Vector3 initialValue( 20.0f, 40.0f, 50.0f ); + + // Register animatable property & its components + AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue ); + AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 ); + AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 ); + AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 ); + + // Check the animatable property value + DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check the animatable property current value + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION ); + + // Do an AnimateBy + const Vector3 targetValue( 45.0f, 53.0f, 25.0f ); + const Vector3 relativeValue( targetValue - initialValue ); + + Animation animation = Animation::New( 1.0f ); + animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x ); + animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y ); + animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z ); + animation.Play(); + + // Target values should change straight away + DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + + const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX; + const unsigned int xComponentIndex = index + 1; + const unsigned int yComponentIndex = index + 2; + const unsigned int zComponentIndex = index + 3; + const unsigned int wComponentIndex = index + 4; + const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f ); + + // Register animatable property & its components + AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue ); + AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 ); + AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 ); + AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 ); + AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 ); + + // Check the animatable property value + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check the animatable property current value + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION ); + + // Do an AnimateBy + const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f ); + const Vector4 relativeValue( targetValue - initialValue ); + + Animation animation = Animation::New( 1.0f ); + animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x ); + animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y ); + animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z ); + animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w ); + animation.Play(); + + // Target values should change straight away + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION ); + END_TEST; } @@ -1522,6 +1658,8 @@ int UtcDaliTypeRegistryChildPropertyRegistrationP(void) Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") ); DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION ); + std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) ); + DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION ); // Create a child actor Actor childActor = Actor::New(); @@ -1852,24 +1990,14 @@ int UtcDaliPropertyRegistrationPropertyWritableP(void) int UtcDaliPropertyRegistrationPropertyWritableN(void) { - // Currently Actors don't register properties with the type registry - TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) ); Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo ); - try - { - typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR); - tet_result( TET_FAIL ); + DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "Cannot find property index", TEST_LOCATION ); - } END_TEST; - } + int UtcDaliPropertyRegistrationPropertyAnimatable(void) { TestApplication application; @@ -1906,7 +2034,7 @@ int UtcDaliPropertyRegistrationPropertyAnimatable(void) END_TEST; } -int UtcDaliPropertyRegistrationInvalidGetAndSet(void) +int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void) { TestApplication application; int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000; @@ -1920,47 +2048,14 @@ int UtcDaliPropertyRegistrationInvalidGetAndSet(void) Actor customActor = Actor::DownCast( handle ); DALI_TEST_CHECK( customActor ); - // Try to set an index that hasn't been added - try - { - customActor.SetProperty( propertyIndex, true ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); - } - - try - { - customActor.SetProperty( animatablePropertyIndex, true ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); - } + // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future + customActor.SetProperty( propertyIndex, true ); +// DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get(), TEST_LOCATION); - // Try to get an index that hasn't been added - try - { - (void) customActor.GetProperty< bool >( propertyIndex ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); - } + // Try to set an index that hasn't been registered + customActor.SetProperty( animatablePropertyIndex, true ); + DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get(), TEST_LOCATION); - try - { - (void) customActor.GetProperty< bool >( animatablePropertyIndex ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); - } END_TEST; } @@ -1996,9 +2091,9 @@ int UtcDaliLongPressGestureDetectorTypeRegistry(void) application.Render(); // Emit gesture - application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); - application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); - application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + TestGenerateLongPress( application, 50.0f, 10.0f ); + TestEndLongPress( application, 50.0f, 10.0f ); + DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); END_TEST; } @@ -2034,9 +2129,7 @@ int UtcDaliPanGestureDetectorTypeRegistry(void) application.Render(); // Emit gesture - application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + TestGenerateMiniPan( application ); DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); END_TEST; } @@ -2072,7 +2165,45 @@ int UtcDaliPinchGestureDetectorTypeRegistry(void) application.Render(); // Emit gesture - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestGeneratePinch( application ); + + DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRotationGestureDetectorTypeRegistry(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Register Type + TypeInfo type; + type = TypeRegistry::Get().GetTypeInfo( "RotationGestureDetector" ); + DALI_TEST_CHECK( type ); + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + RotationGestureDetector detector = RotationGestureDetector::DownCast( handle ); + DALI_TEST_CHECK( detector ); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + detector.Attach(actor); + + // Connect to signal through type + handle.ConnectSignal( &application, "rotationDetected", functor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit gesture + TestGenerateRotation( application ); + DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); END_TEST; } @@ -2108,8 +2239,8 @@ int UtcDaliTapGestureDetectorTypeRegistry(void) application.Render(); // Emit gesture - application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); - application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + TestGenerateTap( application, 50.0, 10.0, 100 ); + DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); END_TEST; } @@ -2285,7 +2416,7 @@ int UtcDaliTypeInfoGetPropertyCountP1(void) DALI_TEST_CHECK( typeInfo ); size_t actorPropertyCount = typeInfo.GetPropertyCount(); - DALI_TEST_EQUALS( actorPropertyCount == 0 , true, TEST_LOCATION ); // No event only props + DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props END_TEST; } @@ -2301,7 +2432,411 @@ int UtcDaliTypeInfoGetPropertyCountP2(void) typeInfo.GetPropertyIndices( indices ); DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION ); - DALI_TEST_EQUALS( propertyCount == 2, true, TEST_LOCATION ); + DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" ); + + // Register animatable property + const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ); + AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT ); + + // Check property count before property registration + TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + Stage::GetCurrent().Add(customActor); + + tet_infoline( "Set the value and ensure it changes straight away" ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION ); + customActor.SetProperty( animatablePropertyIndex, 25.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION ); + + tet_infoline( "Check latest scene-graph value is unchanged" ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + tet_infoline( "Check values after rendering and both retrieval methods should return the latest" ); + + DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" ); + + // Register the animatable propeties + const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ); + const int componentZeroPropertyIndex( basePropertyIndex + 1 ); + const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 ); + AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) ); + AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 ); + AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 ); + + // Check property count before property registration + TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + Stage::GetCurrent().Add(customActor); + + tet_infoline( "Get the component values, they should be the default value of the base-property" ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION ); + + tet_infoline( "Set a component value and ensure it changes for the base property as well" ); + customActor.SetProperty( componentZeroPropertyIndex, 125.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION ); + + customActor.SetProperty( componentOnePropertyIndex, 225.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION ); + + tet_infoline( "Check latest scene-graph value is unchanged" ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + tet_infoline( "Check values after rendering and both retrieval methods should return the latest" ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + + tet_infoline( "Set the base property value and ensure the component values reflect the change" ); + customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" ); + + // Register the animatable propeties + const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ); + const int componentZeroPropertyIndex( basePropertyIndex + 1 ); + const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 ); + const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 ); + AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) ); + AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 ); + AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 ); + AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 ); + + // Check property count before property registration + TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + Stage::GetCurrent().Add(customActor); + + tet_infoline( "Get the component values, they should be the default value of the base-property" ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION ); + + tet_infoline( "Set a component value and ensure it changes for the base property as well" ); + customActor.SetProperty( componentZeroPropertyIndex, 125.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION ); + + customActor.SetProperty( componentOnePropertyIndex, 225.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION ); + + customActor.SetProperty( componentTwoPropertyIndex, 325.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION ); + + tet_infoline( "Check latest scene-graph value is unchanged" ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + tet_infoline( "Check values after rendering and both retrieval methods should return the latest" ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION ); + + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION ); + + tet_infoline( "Set the base property value and ensure the component values reflect the change" ); + customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" ); + + // Register the animatable propeties + const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ); + const int componentZeroPropertyIndex( basePropertyIndex + 1 ); + const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 ); + const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 ); + const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 ); + AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) ); + AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 ); + AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 ); + AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 ); + AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 ); + + // Check property count before property registration + TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + Stage::GetCurrent().Add(customActor); + + tet_infoline( "Get the component values, they should be the default value of the base-property" ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION ); + + tet_infoline( "Set a component value and ensure it changes for the base property as well" ); + customActor.SetProperty( componentZeroPropertyIndex, 125.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION ); + + customActor.SetProperty( componentOnePropertyIndex, 225.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION ); + + customActor.SetProperty( componentTwoPropertyIndex, 325.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION ); + + customActor.SetProperty( componentThreePropertyIndex, 435.0f ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION ); + + tet_infoline( "Check latest scene-graph value is unchanged" ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + tet_infoline( "Check values after rendering and both retrieval methods should return the latest" ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION ); + + DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION ); + + tet_infoline( "Set the base property value and ensure the component values reflect the change" ); + customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION ); + + END_TEST; +} + + +int UtcDaliTypeInfoRegisterChildProperties01(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + tet_infoline( "Register child properties on a type via name" ); + + auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) ); + auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( customActorTypeInfo ); + DALI_TEST_CHECK( myCustomTypeInfo ); + + const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX ); + const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1); + const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100); + + ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER ); + ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER ); + ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS ); + + auto customActor = MyTestCustomActor::New(); + Stage::GetCurrent().Add( customActor ); + auto child = Actor::New(); + customActor.Add( child ); + + child.SetProperty( WIDTH_SPECIFICATION, 33 ); + + auto value = child.GetProperty( WIDTH_SPECIFICATION ); + DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION ); + + child.SetProperty( HEIGHT_SPECIFICATION, 44 ); + value = child.GetProperty( HEIGHT_SPECIFICATION ); + DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION ); + + child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) ); + value = child.GetProperty( MARGIN_SPECIFICATION ); + DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION ); + + END_TEST; +} + + +int UtcDaliTypeInfoRegisterChildProperties02(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + tet_infoline( "Register child properties on a type via name" ); + + auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) ); + auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( customActorTypeInfo ); + DALI_TEST_CHECK( myCustomTypeInfo ); + + const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX ); + const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1); + const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100); + + ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER ); + ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER ); + ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS ); + + + auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" ); + DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION ); + + index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" ); + DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION ); + + index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" ); + DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION ); + + index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" ); + DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION ); + + + auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION ); + DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION ); + + name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION ); + DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION ); + + name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION ); + DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION ); + + + auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION ); + DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION ); + + type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION ); + DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION ); + + type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION ); + DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION ); + + + END_TEST; +} + + +int UtcDaliTypeInfoRegisterChildProperties03(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + tet_infoline( "Check registered child properties can be retrieved" ); + + auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) ); + auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( customActorTypeInfo ); + DALI_TEST_CHECK( myCustomTypeInfo ); + + const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX ); + const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1); + const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100); + + ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER ); + ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER ); + ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS ); + + Property::IndexContainer indices; + myCustomTypeInfo.GetChildPropertyIndices( indices ); + + auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION ); + DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION ); + + result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION ); + DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION ); + + result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION ); + DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION ); END_TEST; }