Renaming of enum values for coding standards compliance.
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Constraint.cpp
index 3f4d5dc..2e4b354 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -121,7 +121,7 @@ int UtcDaliConstraintNewFunctionP(void)
   UtcDaliConstraintNewFunction::gConstraintFunctionCalled = false;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
@@ -160,6 +160,41 @@ int UtcDaliConstraintNewFunctionN(void)
 
   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();
+  application.GetScene().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;
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -176,7 +211,7 @@ int UtcDaliConstraintNewFunctorP(void)
   bool functorCalled = false;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
@@ -259,7 +294,7 @@ int UtcDaliConstraintNewFunctorMemberP(void)
   bool sizeFunctorCalled = false;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
@@ -340,7 +375,7 @@ int UtcDaliConstraintCloneP(void)
   Actor actor = Actor::New();
   Actor clone = Actor::New();
 
-  Stage stage = Stage::GetCurrent();
+  Integration::Scene stage = application.GetScene();
   stage.Add( actor );
   stage.Add( clone );
 
@@ -365,11 +400,10 @@ int UtcDaliConstraintCloneP(void)
   // Reset
   calledCount = 0;
 
-  // Ensure constraint isn't called again if scene doesn't change
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( calledCount, 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( calledCount, 1, TEST_LOCATION );
 
   // Apply the clone constraint
   constraintClone.Apply();
@@ -377,15 +411,15 @@ int UtcDaliConstraintCloneP(void)
   application.SendNotification();
   application.Render();
 
-  // Should only be called once for the new constraint clone ONLY
-  DALI_TEST_EQUALS( calledCount, 1, TEST_LOCATION );
+  // Should be called once for the new constraint clone and once for the original constraint
+  DALI_TEST_EQUALS( calledCount, 3, TEST_LOCATION );
 
   // Reset
   calledCount = 0;
 
   // Change the position of both actors
-  actor.SetPosition( 100.0f, 100.0f );
-  clone.SetPosition( 100.0f, 100.0f );
+  actor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
+  clone.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
 
   application.SendNotification();
   application.Render();
@@ -438,7 +472,7 @@ int UtcDaliConstraintCloneCheckSourcesAndSetters(void)
   Actor actor = Actor::New();
   Actor clone = Actor::New();
 
-  Stage stage = Stage::GetCurrent();
+  Integration::Scene stage = application.GetScene();
   stage.Add( actor );
   stage.Add( clone );
 
@@ -451,7 +485,7 @@ int UtcDaliConstraintCloneCheckSourcesAndSetters(void)
   constraint.AddSource( LocalSource( Actor::Property::ORIENTATION ) );
   constraint.AddSource( LocalSource( Actor::Property::COLOR ) );
   constraint.AddSource( LocalSource( Actor::Property::VISIBLE ) );
-  constraint.SetRemoveAction( Constraint::Discard );
+  constraint.SetRemoveAction( Constraint::DISCARD );
   constraint.SetTag( 123 );
 
   // Clone the constraint & apply the clone
@@ -479,7 +513,7 @@ int UtcDaliConstraintCopyAndAssignment(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &BasicFunction< Vector3 > );
   Constraint copied( constraint );
@@ -494,6 +528,53 @@ int UtcDaliConstraintCopyAndAssignment(void)
 }
 ///////////////////////////////////////////////////////////////////////////////
 
+int UtcDaliConstraintMoveConstructor(void)
+{
+  // Ensure copy constructor & assignment operators work
+
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  application.GetScene().Add( actor );
+
+  Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &BasicFunction< Vector3 > );
+  DALI_TEST_CHECK( constraint );
+  DALI_TEST_EQUALS( 1, constraint.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( constraint.GetTargetObject() == actor );
+
+  Constraint moved = std::move( constraint );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( moved.GetTargetObject() == actor );
+  DALI_TEST_CHECK( !constraint );
+
+  END_TEST;
+}
+
+int UtcDaliConstraintMoveAssignment(void)
+{
+  // Ensure copy constructor & assignment operators work
+
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  application.GetScene().Add( actor );
+
+  Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &BasicFunction< Vector3 > );
+  DALI_TEST_CHECK( constraint );
+  DALI_TEST_EQUALS( 1, constraint.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( constraint.GetTargetObject() == actor );
+
+  Constraint moved;
+  moved = std::move( constraint );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( moved.GetTargetObject() == actor );
+  DALI_TEST_CHECK( !constraint );
+
+  END_TEST;
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // Constraint::DownCast
 ///////////////////////////////////////////////////////////////////////////////
@@ -569,7 +650,7 @@ int UtcDaliConstraintGetTargetPropertyP(void)
 
   Actor actor = Actor::New();
   Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &BasicFunction< Vector3 > );
-  DALI_TEST_EQUALS( constraint.GetTargetProperty(), Actor::Property::POSITION, TEST_LOCATION );
+  DALI_TEST_EQUALS( constraint.GetTargetProperty(), (Property::Index)Actor::Property::POSITION, TEST_LOCATION );
 
   END_TEST;
 }
@@ -606,9 +687,9 @@ int UtcDaliConstraintTagP(void)
 
   Actor actor = Actor::New();
   Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &BasicFunction< Vector3 > );
-  DALI_TEST_EQUALS( constraint.GetTag(), 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( constraint.GetTag(), 0u, TEST_LOCATION );
 
-  const int tag = 123;
+  const unsigned int tag = 123;
   constraint.SetTag( tag );
   DALI_TEST_EQUALS( constraint.GetTag(), tag, TEST_LOCATION );
 
@@ -670,11 +751,11 @@ int UtcDaliConstraintRemoveActionP(void)
   Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &BasicFunction< Vector3 > );
   DALI_TEST_EQUALS( constraint.GetRemoveAction(), Constraint::DEFAULT_REMOVE_ACTION, TEST_LOCATION );
 
-  constraint.SetRemoveAction( Constraint::Discard );
-  DALI_TEST_EQUALS( constraint.GetRemoveAction(), Constraint::Discard, TEST_LOCATION );
+  constraint.SetRemoveAction( Constraint::DISCARD );
+  DALI_TEST_EQUALS( constraint.GetRemoveAction(), Constraint::DISCARD, TEST_LOCATION );
 
-  constraint.SetRemoveAction( Constraint::Bake );
-  DALI_TEST_EQUALS( constraint.GetRemoveAction(), Constraint::Bake, TEST_LOCATION );
+  constraint.SetRemoveAction( Constraint::BAKE );
+  DALI_TEST_EQUALS( constraint.GetRemoveAction(), Constraint::BAKE, TEST_LOCATION );
 
   END_TEST;
 }
@@ -688,7 +769,7 @@ int UtcDaliConstraintSetRemoveActionN(void)
   Constraint constraint;
   try
   {
-    constraint.SetRemoveAction( Constraint::Discard );
+    constraint.SetRemoveAction( Constraint::DISCARD );
     DALI_TEST_CHECK( false ); // Should not reach here!
   }
   catch( ... )
@@ -727,24 +808,24 @@ int UtcDaliConstraintBakeRemoveAction(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
 
   // Should not equal position by default
   Vector3 position( 10.0f, 20.0f, 30.0f );
-  DALI_TEST_CHECK( actor.GetCurrentPosition() != position );
+  DALI_TEST_CHECK( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) != position );
 
   // Create a constraint that constrains to position
   Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, SetValueFunctor< Vector3 >( position ) );
-  constraint.SetRemoveAction( Constraint::Bake );
+  constraint.SetRemoveAction( Constraint::BAKE );
   constraint.Apply();
 
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
 
   // Remove the constraint, it should still be at position
   constraint.Remove();
@@ -752,7 +833,7 @@ int UtcDaliConstraintBakeRemoveAction(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
 
   END_TEST;
 }
@@ -764,27 +845,27 @@ int UtcDaliConstraintDiscardRemoveAction(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
 
   // Get and store current position
-  Vector3 originalPosition = actor.GetCurrentPosition();
+  Vector3 originalPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
 
   // Should not equal position by default
   Vector3 position( 10.0f, 20.0f, 30.0f );
-  DALI_TEST_CHECK( actor.GetCurrentPosition() != position );
+  DALI_TEST_CHECK( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) != position );
 
   // Create a constraint that constrains to position
   Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, SetValueFunctor< Vector3 >( position ) );
-  constraint.SetRemoveAction( Constraint::Discard );
+  constraint.SetRemoveAction( Constraint::DISCARD );
   constraint.Apply();
 
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), position, TEST_LOCATION );
 
   // Remove the constraint, it should still be at position
   constraint.Remove();
@@ -792,8 +873,8 @@ int UtcDaliConstraintDiscardRemoveAction(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( actor.GetCurrentPosition(), originalPosition, TEST_LOCATION );
-  DALI_TEST_CHECK( actor.GetCurrentPosition() != position );
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), originalPosition, TEST_LOCATION );
+  DALI_TEST_CHECK( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) != position );
 
   END_TEST;
 }
@@ -812,7 +893,7 @@ int UtcDaliConstraintApplyRemove(void)
   bool functorCalled = false;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
@@ -870,7 +951,7 @@ int UtcDaliConstraintApplyBeforeAddedToStage(void)
   DALI_TEST_EQUALS( functorCalled, false, TEST_LOCATION );
 
   // Add actor to stage
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
@@ -904,7 +985,7 @@ int UtcDaliConstraintApplyAndRemoveBeforeAddedToStage(void)
   constraint.Remove();
 
   // Add actor to stage
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
@@ -925,7 +1006,7 @@ int UtcDaliConstraintApplyActorStagedUnstaged(void)
 
   // Create an actor and add to stage
   Actor actor = Actor::New();
-  Stage stage = Stage::GetCurrent();
+  Integration::Scene stage = application.GetScene();
   stage.Add( actor );
 
   // Create a constraint and apply
@@ -972,7 +1053,7 @@ int UtcDaliConstraintApplySeveralTimes(void)
 
   // Create an actor and add to stage
   Actor actor = Actor::New();
-  Stage stage = Stage::GetCurrent();
+  Integration::Scene stage = application.GetScene();
   stage.Add( actor );
 
   // Create a constraint and apply
@@ -997,14 +1078,13 @@ int UtcDaliConstraintApplySeveralTimes(void)
   application.SendNotification();
   application.Render();
 
-  // Constraint should not have been called as the input-properties (none) have not changed for the constraint
-  DALI_TEST_EQUALS( count, 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( count, 1, TEST_LOCATION );
 
   // Reset
   count = 0;
 
   // Change the position property, apply again
-  actor.SetPosition( 10.0f, 10.0f );
+  actor.SetProperty( Actor::Property::POSITION, Vector2( 10.0f, 10.0f ));
   constraint.Apply();
 
   application.SendNotification();
@@ -1040,7 +1120,7 @@ int UtcDaliConstraintAddSourceP(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   // Create a constraint, add sources
   Constraint constraint = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &UtcDaliConstraintAddSource::Function );
@@ -1133,7 +1213,7 @@ int UtcDaliConstraintChaining(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   Constraint constraint1 = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &TestChaining::Function1 );
   Constraint constraint2 = Constraint::New< Vector3 >( actor, Actor::Property::POSITION, &TestChaining::Function2 );
@@ -1166,7 +1246,7 @@ void Execute( T value )
   Actor actor = Actor::New();
   Property::Index index = actor.RegisterProperty( "TEMP_PROPERTY_NAME", value );
 
-  Stage::GetCurrent().Add( actor );
+  application.GetScene().Add( actor );
 
   application.SendNotification();
   application.Render();
@@ -1202,22 +1282,273 @@ int UtcDaliConstraintTestPropertyTypesP(void)
   END_TEST;
 }
 
-int UtcDaliConstraintTestPropertyTypesN(void)
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+namespace
+{
+void SetHalfOpacity( Vector4& current, const PropertyInputContainer& inputs )
+{
+  current.a = 0.5f;
+}
+} // unnamed namespace
+
+int UtcDaliConstraintEnsureResetterAppliedOnSceneRemoval(void)
+{
+  // Ensure BOTH double-buffered values of our color property is reset when a constraint is applied to it.
+
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  application.GetScene().Add( actor );
+
+  // Check initial value is fully opaque
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 1.0f, TEST_LOCATION );
+
+  // Create a constraint whose value is discarded when it is removed
+  Constraint constraint = Constraint::New< Vector4 >( actor, Actor::Property::COLOR, SetHalfOpacity );
+  constraint.SetRemoveAction( Constraint::RemoveAction::DISCARD );
+  constraint.Apply();
+
+  // Check value after one render, it should be constrained
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.5f, TEST_LOCATION );
+
+  // Render another frame, ensure the other value has also been updated
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.5f, TEST_LOCATION );
+
+  // Remove the actor from the stage and delete the constraint
+  actor.Unparent();
+  constraint.Remove();
+  constraint.Reset();
+
+  // Check value while off-stage, it should be fully opaque
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 1.0f, TEST_LOCATION );
+
+  // Add the actor back to the stage and check the value, it should be fully opaque again
+  application.GetScene().Add( actor );
+
+  // Check value when back on-stage, it should be fully opaque as the constraint is no longer applied to it.
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 1.0f, TEST_LOCATION );
+
+  // Render for another frame to ensure both buffers have the correct value
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 1.0f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliConstraintOnActorAddedAndRemoved(void)
 {
-  // unsigned int not supported so we should assert
+  // Ensure adding and removing an actor from stage with a constraint still has it applied when it is re-added back to the stage
+
+  TestApplication application;
 
+  Actor actor = Actor::New();
+  application.GetScene().Add( actor );
+
+  // Check initial value is fully opaque
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 1.0f, TEST_LOCATION );
+
+  // Create a constraint whose value is discarded when it is removed
+  Constraint constraint = Constraint::New< Vector4 >( actor, Actor::Property::COLOR, SetHalfOpacity );
+  constraint.SetRemoveAction( Constraint::RemoveAction::DISCARD );
+  constraint.Apply();
+
+  // Check value after one render, it should be constrained
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.5f, TEST_LOCATION );
+
+  // Render another frame, ensure the other value has also been updated
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.5f, TEST_LOCATION );
+
+  // Remove the actor from the stage
+  actor.Unparent();
+
+  // Check value while off-stage, the constraint is no longer being applied as it's off-stage
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 1.0f, TEST_LOCATION );
+
+  // Check the other buffer, the constraint should not be applied to this either.
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 1.0f, TEST_LOCATION );
+
+  // Add the actor back to the stage and check the value, the constraint should have been re-applied
+  application.GetScene().Add( actor );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.5f, TEST_LOCATION );
+
+  // Render for another frame to ensure both buffers have the correct value
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, 0.5f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+int UtcDaliConstraintGetTargetObjectNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
   try
   {
-    TestPropertyTypes::Execute< unsigned int >( 0u );
-    DALI_TEST_CHECK( false ); // Should not come here
+    instance.GetTargetObject();
+    DALI_TEST_CHECK(false); // Should not get here
   }
-  catch( ... )
+  catch(...)
   {
-    DALI_TEST_CHECK( true );
+    DALI_TEST_CHECK(true); // We expect an assert
   }
+  END_TEST;
+}
 
+int UtcDaliConstraintSetRemoveActionNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
+  try
+  {
+    Dali::Constraint::RemoveAction arg1(Constraint::BAKE);
+    instance.SetRemoveAction(arg1);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
 
+int UtcDaliConstraintGetTargetPropertyNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
+  try
+  {
+    instance.GetTargetProperty();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
   END_TEST;
 }
-///////////////////////////////////////////////////////////////////////////////
 
+int UtcDaliConstraintApplyNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
+  try
+  {
+    instance.Apply();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliConstraintCloneNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
+  try
+  {
+    Dali::Handle arg1;
+    instance.Clone(arg1);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliConstraintRemoveNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
+  try
+  {
+    instance.Remove();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliConstraintSetTagNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
+  try
+  {
+    unsigned int arg1(0u);
+    instance.SetTag(arg1);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliConstraintGetRemoveActionNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
+  try
+  {
+    instance.GetRemoveAction();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliConstraintGetTagNegative(void)
+{
+  TestApplication application;
+  Dali::Constraint instance;
+  try
+  {
+    instance.GetTag();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}