END_TEST;
}
+
+int UtcDaliAnimationAnimateByNonAnimateableTypeN(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(1);
+ Property::Index index = actor.RegisterProperty( "testProperty", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ try
+ {
+ // Build the animation
+ Animation animation = Animation::New( 2.0f );
+ std::string relativeValue = "relative string";
+ animation.AnimateBy( Property(actor, index), relativeValue );
+ tet_result(TET_FAIL);
+ }
+ catch ( Dali::DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
+ }
+
+
+ END_TEST;
+}
+
+
+int UtcDaliAnimationAnimateToNonAnimateableTypeN(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(1);
+ Property::Index index = actor.RegisterProperty( "testProperty", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ try
+ {
+ // Build the animation
+ Animation animation = Animation::New( 2.0f );
+ std::string relativeValue = "relative string";
+ animation.AnimateTo( Property(actor, index), relativeValue );
+
+ tet_result(TET_FAIL);
+ }
+ catch ( Dali::DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliAnimationAnimateBetweenNonAnimateableTypeN(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Register an integer property
+ int startValue(1);
+ Property::Index index = actor.RegisterProperty( "testProperty", startValue );
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetProperty<int>(index), startValue, TEST_LOCATION );
+
+ try
+ {
+ // Build the animation
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add( 0.0f, std::string("relative string1") );
+ keyFrames.Add( 1.0f, std::string("relative string2") );
+ // no need to really create the animation as keyframes do the check
+
+ tet_result(TET_FAIL);
+ }
+ catch ( Dali::DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Type not animateable", TEST_LOCATION );
+ }
+
+ END_TEST;
+}
END_TEST;
}
+
+// helper for next test
+void StringConstraintFunction( std::string& /* current */, const PropertyInputContainer& /* inputs */ )
+{
+}
+
+int UtcDaliConstraintNewFunctionNonConstrainableTypeN(void)
+{
+ // Ensure that we can create a constraint using a C function and that it is called.
+
+ TestApplication application;
+ UtcDaliConstraintNewFunction::gConstraintFunctionCalled = false;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ try
+ {
+ // Add a constraint
+ Constraint constraint = Constraint::New< std::string >( actor, Actor::Property::COLOR_MODE, &StringConstraintFunction );
+ DALI_TEST_CHECK( constraint );
+ constraint.Apply();
+ tet_result(TET_FAIL);
+ }
+ catch ( Dali::DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Property not constrainable", TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
END_TEST;
}
-int UtcDaliHandleNonAnimtableProperties(void)
+int UtcDaliHandleNonAnimatableProperties(void)
{
tet_infoline("Test Non Animatable Properties");
TestApplication application;
Actor actor = Actor::New();
- Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE);
+ Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE);
//// modify writable?
- try
- {
- actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_CHECK(!"exception");
- }
+ actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
DALI_TEST_CHECK( "yes" == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
- bool exception = false;
- try
- {
- actor.SetProperty( readonly, Property::Value(1.f) );
- }
- catch (Dali::DaliException& e)
- {
- exception = true;
- }
-
- DALI_TEST_CHECK(!exception);// trying to set a read-only property is a no-op
+ actor.SetProperty( readonly, Property::Value(1.f) );
+ // trying to set a read-only property is a no-op
DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
- exception = false;
- try
- {
- actor.SetProperty( write_anim, Property::Value(1.f) );
- }
- catch (Dali::DaliException& e)
- {
- exception = true;
- }
-
- DALI_TEST_CHECK(!exception);
+ actor.SetProperty( write_anim, Property::Value(1.f) );
- //// animate a non animatable property is a noop?
+ //// animate a non animatable property throws
float durationSeconds(2.0f);
Animation animation = Animation::New(durationSeconds);
bool relativeValue(true);
-
- exception = false;
-
try
{
animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
- animation.Play();
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*0100.0f)/* some progress */);
}
- catch (Dali::DaliException& e)
+ catch ( Dali::DaliException& e )
{
- exception = true;
+ DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
}
- DALI_TEST_CHECK(!exception);
DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
END_TEST;
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
}
END_TEST;
}
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
}
END_TEST;
}
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
}
END_TEST;
}
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
}
END_TEST;
}
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
}
END_TEST;
}
if ( bufferSubDataCalls.size() )
{
DALI_TEST_EQUALS( bufferSubDataCalls[0], sizeof(texturedQuadVertexData), TEST_LOCATION );
-
}
}
END_TEST;
}
+
+int UtcDaliPropertyBufferInvalidTypeN(void)
+{
+ TestApplication application;
+
+ Property::Map texturedQuadVertexFormat;
+ texturedQuadVertexFormat["aPosition"] = Property::MAP;
+ texturedQuadVertexFormat["aVertexCoord"] = Property::STRING;
+
+ try
+ {
+ PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat );
+ tet_result(TET_FAIL);
+ }
+ catch ( Dali::DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Property::Type not supported in PropertyBuffer", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
}
catch ( DaliException& e )
{
- DALI_TEST_ASSERT( e, "false && \"Property notification added to event side only property", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Property notification added to event side only property", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliAddPropertyNotificationEventSidePropertyN(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Currently, Type registry properties cannot be animated
+ try
+ {
+ actor.AddPropertyNotification( PROPERTY_REGISTRATION_MAX_INDEX - 1, GreaterThanCondition( 100.0f ) );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Property notification added to event side only property", TEST_LOCATION );
}
END_TEST;
}
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
}
END_TEST;
}
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
}
END_TEST;
}
}
catch ( Dali::DaliException& e )
{
- DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
}
END_TEST;
}
default:
{
- DALI_ASSERT_ALWAYS( false && "Property type enumeration out of bounds" ); // should not come here
- break;
+ // nothing to do for other types
}
} // entry.GetType
}
value = mClippingMode;
break;
}
-
- default:
- {
- DALI_ASSERT_ALWAYS( false && "Actor Property index invalid" ); // should not come here
- break;
- }
}
return value;
void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period)
{
- Object& object = dynamic_cast<Object&>( GetImplementation(target.object) );
+ Object& object = GetImplementation( target.object );
+ const Property::Type targetType = object.GetPropertyType( target.propertyIndex );
+ const Property::Type destinationType = relativeValue.GetType();
+ DALI_ASSERT_ALWAYS( targetType == destinationType && "Animated value and Property type don't match" );
ExtendDuration( period );
- switch ( relativeValue.GetType() )
+ switch ( targetType )
{
case Property::BOOLEAN:
{
}
default:
- DALI_ASSERT_ALWAYS( false && "Property type enumeration out of bounds" ); // should never come here
- break;
+ {
+ // non animatable types handled already
+ }
}
}
void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period)
{
- Object& object = dynamic_cast<Object&>( GetImplementation(target.object) );
+ Object& object = GetImplementation(target.object);
AnimateTo( object, target.propertyIndex, target.componentIndex, destinationValue, alpha, period );
}
void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period)
{
- Property::Type type = targetObject.GetPropertyType(targetPropertyIndex);
- if(componentIndex != Property::INVALID_COMPONENT_INDEX)
+ Property::Type targetType = targetObject.GetPropertyType(targetPropertyIndex);
+ if( componentIndex != Property::INVALID_COMPONENT_INDEX )
{
- if( type == Property::VECTOR2
- || type == Property::VECTOR3
- || type == Property::VECTOR4 )
+ if( ( targetType == Property::VECTOR2 ) ||
+ ( targetType == Property::VECTOR3 ) ||
+ ( targetType == Property::VECTOR4 ) )
{
- type = Property::FLOAT;
+ targetType = Property::FLOAT;
}
}
- DALI_ASSERT_ALWAYS( type == destinationValue.GetType() && "DestinationValue does not match Target Property type" );
+ const Property::Type destinationType = destinationValue.GetType();
+ DALI_ASSERT_ALWAYS( targetType == destinationType && "Animated value and Property type don't match" );
ExtendDuration( period );
- switch (destinationValue.GetType())
+ switch ( destinationType )
{
case Property::BOOLEAN:
{
}
default:
- DALI_ASSERT_ALWAYS( false && "Property type enumeration out of bounds" ); // should never come here
- break;
+ {
+ // non animatable types handled already
+ }
}
}
void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
{
- Object& object = dynamic_cast<Object&>( GetImplementation(target.object) );
+ Object& object = GetImplementation( target.object );
ExtendDuration( period );
break;
}
- default: // not all property types are animateable
- break;
+ default:
+ {
+ // non animatable types handled by keyframes
+ }
}
}
}
default:
{
- DALI_ASSERT_DEBUG(!"Type not supported");
+ DALI_ABORT( "Type not animateable" );
break;
}
}
default:
{
- DALI_ASSERT_ALWAYS( false && "Property type enumeration out of bounds" ); // should not come here
- break;
+ // ignore non-scene-graph types
}
}
}
-
- int GetPropertyComponentIndex( Property::Index index ) const
- {
- // TODO: MESH_REWORK
- DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
- return 0;
- }
};
{
if ( index <= PROPERTY_REGISTRATION_MAX_INDEX )
{
- DALI_ASSERT_ALWAYS( false && "Property notification added to event side only property." );
+ DALI_ABORT( "Property notification added to event side only property." );
}
else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
{
default:
{
- DALI_ASSERT_ALWAYS( false && "PropertyType enumeration is out of bounds" );
- break;
+ // unreachable code due to higher level logic
}
} // switch(type)
} // if animatable
switch( propertyType )
{
- case Property::NONE:
- case Property::STRING:
- case Property::ARRAY:
- case Property::MAP:
- {
- DALI_ASSERT_ALWAYS( false && "No size for properties with no type, or dynamic sizes" );
- break;
- }
case Property::BOOLEAN:
{
alignment = PropertyImplementationTypeAlignment< Property::BOOLEAN >::VALUE;
alignment = PropertyImplementationTypeAlignment< Property::ROTATION >::VALUE;
break;
}
+ case Property::NONE:
+ case Property::STRING:
+ case Property::ARRAY:
+ case Property::MAP:
+ {
+ // already handled by higher level code
+ }
}
return alignment;
Property::Type type = Property::Type( component.second.Get<int>() );
// Get the size and alignment
+ if( ( type == Property::NONE ) ||
+ ( type == Property::STRING ) ||
+ ( type == Property::ARRAY ) ||
+ ( type == Property::MAP ) )
+ {
+ DALI_ABORT( "Property::Type not supported in PropertyBuffer" );
+ }
unsigned int elementSize = GetPropertyImplementationSize( type );
unsigned int elementAlignment = GetPropertyImplementationAlignment( type );
switch( propertyType )
{
- case Property::NONE:
- case Property::STRING:
- case Property::ARRAY:
- case Property::MAP:
- {
- DALI_ASSERT_ALWAYS( "No size for properties with no type, or dynamic sizes" );
- break;
- }
case Property::BOOLEAN:
{
size = sizeof( PropertyImplementationType< Property::BOOLEAN >::Type );
size = sizeof( PropertyImplementationType< Property::ROTATION >::Type );
break;
}
+ case Property::NONE:
+ case Property::STRING:
+ case Property::ARRAY:
+ case Property::MAP:
+ {
+ // already handled by higher level code
+ }
}
return size;
*/
virtual const bool& GetBoolean( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const bool&>(*this);
}
*/
virtual const int& GetInteger( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const int&>(*this);
}
*/
virtual const float& GetFloat( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const float&>(*this);
}
*/
virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Vector2&>(*this);
}
*/
virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Vector3&>(*this);
}
*/
virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Vector4&>(*this);
}
*/
virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Quaternion&>(*this);
}
*/
virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Matrix3&>(*this);
}
*/
virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
- // the return will never be executed due to assert above so just keep the compiler happy
+ // the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Matrix&>(*this);
}
}
case Gesture::Continuing:
- DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Continuing\n" );
+ {
+ DALI_ABORT( "Incorrect state received from Integration layer: Continuing\n" );
break;
-
+ }
case Gesture::Clear:
- DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Clear\n" );
+ {
+ DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" );
break;
+ }
}
}
}
case Gesture::Clear:
- DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Clear\n" );
+ {
+ DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" );
break;
+ }
}
}
}
case Gesture::Clear:
- DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Clear\n" );
+ {
+ DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" );
break;
-
+ }
case Gesture::Possible:
- DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Possible\n" );
+ {
+ DALI_ABORT( "Incorrect state received from Integration layer: Possible\n" );
break;
+ }
}
}
}
case Gesture::Continuing:
- DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Continuing\n" );
+ {
+ DALI_ABORT( "Incorrect state received from Integration layer: Continuing\n" );
break;
-
+ }
case Gesture::Finished:
- DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Finished\n" );
+ {
+ DALI_ABORT( "Incorrect state received from Integration layer: Finished\n" );
break;
-
+ }
case Gesture::Clear:
- DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Clear\n" );
+ {
+ DALI_ABORT( "Incorrect state received from Integration layer: Clear\n" );
break;
+ }
}
}
if ( GL_FRAMEBUFFER_COMPLETE != status )
{
DALI_LOG_ERROR( "status (0x%x), glError (0x%x)\n", status, mContext.GetError() );
- DALI_ASSERT_ALWAYS( false && "Frame buffer is not complete!" );
}
return mId != 0;
default:
{
- DALI_ASSERT_ALWAYS( false && "Property type enumeration out of bounds" ); // should never come here
+ DALI_ABORT( "Property not constrainable" );
break;
}
}
}
#endif
+#define DALI_ABORT(message) \
+ { \
+ Dali::DaliAssertMessage( ASSERT_LOCATION, message ); \
+ throw Dali::DaliException( ASSERT_LOCATION, message ); \
+ }
+
/**
* @brief An invariant concurrent assertion to ensure its argument evaluates TRUE in debug builds.
*
}
}
- DALI_ASSERT_ALWAYS( false && "Callback lost in SlotDisconnected()" );
+ DALI_ABORT( "Callback lost in SlotDisconnected()" );
}
CallbackBase* BaseSignal::GetCallback( std::size_t connectionIndex ) const
}
}
- DALI_ASSERT_ALWAYS( false && "Callback lost in SignalDisconnected()" );
+ DALI_ABORT( "Callback lost in SignalDisconnected()" );
}
std::size_t ConnectionTracker::GetConnectionCount() const