Merge "(Actor) Add ability to connect to new touch signal via scripts" into devel...
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-PropertyNotification.cpp
index 9849825..17ae6cc 100644 (file)
@@ -18,7 +18,6 @@
 #include <iostream>
 
 #include <stdlib.h>
-#include <boost/bind.hpp>
 #include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
 
@@ -63,7 +62,7 @@ public:
   {
     mActor = Actor::New();
     Stage::GetCurrent().Add( mActor );
-    mNotification = mActor.AddPropertyNotification( Actor::Property::PositionX, GreaterThanCondition(100.0f) );
+    mNotification = mActor.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(100.0f) );
     mNotification.NotifySignal().Connect( this, &TestClass::OnPropertyNotify );
   }
 
@@ -128,7 +127,7 @@ int UtcDaliPropertyNotificationDownCast(void)
   tet_infoline(" UtcDaliPropertyNotificationDownCast");
 
   Actor actor = Actor::New();
-  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::PositionX, GreaterThanCondition(100.0f));
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X, GreaterThanCondition(100.0f));
   BaseHandle handle = notification;
   PropertyNotification notificationHandle;
 
@@ -152,7 +151,7 @@ int UtcDaliPropertyNotificationDownCastNegative(void)
   Actor somethingElse = Actor::New();
 
   Actor actor = Actor::New();
-  actor.AddPropertyNotification(Actor::Property::PositionX, GreaterThanCondition(100.0f));
+  actor.AddPropertyNotification(Actor::Property::POSITION_X, GreaterThanCondition(100.0f));
   BaseHandle handle = somethingElse;
   PropertyNotification notificationHandle;
 
@@ -168,7 +167,7 @@ int UtcDaliAddPropertyNotification(void)
 
   Actor actor = Actor::New();
 
-  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::PositionX, GreaterThanCondition(100.0f));
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X, GreaterThanCondition(100.0f));
   DALI_TEST_CHECK( notification );
   END_TEST;
 }
@@ -273,7 +272,7 @@ int UtcDaliPropertyNotificationGetCondition(void)
   Actor actor = Actor::New();
 
   PropertyCondition condition = GreaterThanCondition(100.0f);
-  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::PositionX, condition);
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X, condition);
   DALI_TEST_CHECK( condition == notification.GetCondition() );
   END_TEST;
 }
@@ -308,7 +307,7 @@ int UtcDaliPropertyNotificationGetConditionConst(void)
   Actor actor = Actor::New();
 
   PropertyCondition condition = GreaterThanCondition(100.0f);
-  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::PositionX, condition);
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X, condition);
   PropertyNotificationConstWrapper notificationConst(notification);
   const PropertyCondition& conditionReference1 = notificationConst.GetCondition();
   const PropertyCondition& conditionReference2 = notificationConst.GetCondition();
@@ -326,7 +325,7 @@ int UtcDaliPropertyNotificationGetTarget(void)
   Actor actor = Actor::New();
   Actor actor2 = Actor::New();
 
-  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::PositionX,
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X,
                                                                     GreaterThanCondition(100.0f));
   Actor targetActor = Actor::DownCast( notification.GetTarget() );
 
@@ -341,11 +340,11 @@ int UtcDaliPropertyNotificationGetProperty(void)
 
   Actor actor = Actor::New();
 
-  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::PositionX,
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X,
                                                                     GreaterThanCondition(100.0f));
   Property::Index targetProperty = notification.GetTargetProperty();
 
-  DALI_TEST_EQUALS( targetProperty, Actor::Property::PositionX, TEST_LOCATION );
+  DALI_TEST_EQUALS( targetProperty, (Property::Index)Actor::Property::POSITION_X, TEST_LOCATION );
   END_TEST;
 }
 
@@ -356,7 +355,7 @@ int UtcDaliPropertyNotificationGetNotifyMode(void)
 
   Actor actor = Actor::New();
 
-  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::PositionX,
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X,
                                                                     GreaterThanCondition(100.0f));
   notification.SetNotifyMode(PropertyNotification::NotifyOnChanged);
   PropertyNotification::NotifyMode notifyMode = notification.GetNotifyMode();
@@ -365,6 +364,33 @@ int UtcDaliPropertyNotificationGetNotifyMode(void)
   END_TEST;
 }
 
+int UtcDaliPropertyNotificationGetNotifyResultP(void)
+{
+  TestApplication application;
+  tet_infoline(" UtcDaliPropertyNotificationGetNotifyMode");
+
+  Actor actor = Actor::New();
+
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X,
+                                                                    GreaterThanCondition(100.0f));
+  notification.SetNotifyMode(PropertyNotification::NotifyOnChanged);
+  gCallBackCalled = false;
+  notification.NotifySignal().Connect( &TestCallback );
+
+  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
+
+  application.Render(RENDER_FRAME_INTERVAL);
+  application.SendNotification();
+  application.Render(RENDER_FRAME_INTERVAL);
+  application.SendNotification();
+
+  bool notifyResult = notification.GetNotifyResult();
+
+  DALI_TEST_EQUALS( notifyResult, false, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliPropertyNotificationGreaterThan(void)
 {
   TestApplication application;
@@ -373,7 +399,7 @@ int UtcDaliPropertyNotificationGreaterThan(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::PositionX, GreaterThanCondition(100.0f) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
 
   actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
@@ -408,7 +434,7 @@ int UtcDaliPropertyNotificationLessThan(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::PositionX, LessThanCondition(100.0f ) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION_X, LessThanCondition(100.0f ) );
   notification.NotifySignal().Connect( &TestCallback );
 
   actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
@@ -443,7 +469,7 @@ int UtcDaliPropertyNotificationInside(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::PositionX, InsideCondition(100.0f, 200.0f) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION_X, InsideCondition(100.0f, 200.0f) );
   notification.NotifySignal().Connect( &TestCallback );
 
   actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
@@ -478,7 +504,7 @@ int UtcDaliPropertyNotificationOutside(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::PositionX, OutsideCondition(100.0f, 200.0f) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION_X, OutsideCondition(100.0f, 200.0f) );
   notification.NotifySignal().Connect( &TestCallback );
 
   actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f));
@@ -513,13 +539,13 @@ int UtcDaliPropertyNotificationVectorComponentGreaterThan(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::Position, 0, GreaterThanCondition(100.0f) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION, 0, GreaterThanCondition(100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Position, 1, GreaterThanCondition(100.0f) );
+  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 1, GreaterThanCondition(100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Position, 2, GreaterThanCondition(100.0f) );
+  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 2, GreaterThanCondition(100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Color, 3, GreaterThanCondition(0.5f) );
+  notification = actor.AddPropertyNotification( Actor::Property::COLOR, 3, GreaterThanCondition(0.5f) );
   notification.NotifySignal().Connect( &TestCallback );
 
   actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
@@ -562,13 +588,13 @@ int UtcDaliPropertyNotificationVectorComponentLessThan(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::Position, 0, LessThanCondition(-100.0f) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION, 0, LessThanCondition(-100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Position, 1, LessThanCondition(-100.0f) );
+  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 1, LessThanCondition(-100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Position, 2, LessThanCondition(-100.0f) );
+  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 2, LessThanCondition(-100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Color, 3, LessThanCondition(0.5f) );
+  notification = actor.AddPropertyNotification( Actor::Property::COLOR, 3, LessThanCondition(0.5f) );
   notification.NotifySignal().Connect( &TestCallback );
 
   actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
@@ -611,13 +637,13 @@ int UtcDaliPropertyNotificationVectorComponentInside(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::Position, 0, InsideCondition(-100.0f, 100.0f) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION, 0, InsideCondition(-100.0f, 100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Position, 1, InsideCondition(-100.0f, 100.0f) );
+  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 1, InsideCondition(-100.0f, 100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Position, 2, InsideCondition(-100.0f, 100.0f) );
+  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 2, InsideCondition(-100.0f, 100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Color, 3, InsideCondition(0.25f, 0.75f) );
+  notification = actor.AddPropertyNotification( Actor::Property::COLOR, 3, InsideCondition(0.25f, 0.75f) );
   notification.NotifySignal().Connect( &TestCallback );
 
   // set outside all conditions
@@ -661,13 +687,13 @@ int UtcDaliPropertyNotificationVectorComponentOutside(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::Position, 0, OutsideCondition(-100.0f, 100.0f) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION, 0, OutsideCondition(-100.0f, 100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Position, 1, OutsideCondition(-100.0f, 100.0f) );
+  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 1, OutsideCondition(-100.0f, 100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Position, 2, OutsideCondition(-100.0f, 100.0f) );
+  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 2, OutsideCondition(-100.0f, 100.0f) );
   notification.NotifySignal().Connect( &TestCallback );
-  notification = actor.AddPropertyNotification( Actor::Property::Color, 3, OutsideCondition(0.25f, 0.75f) );
+  notification = actor.AddPropertyNotification( Actor::Property::COLOR, 3, OutsideCondition(0.25f, 0.75f) );
   notification.NotifySignal().Connect( &TestCallback );
 
   // set inside all conditions
@@ -709,63 +735,18 @@ int UtcDaliPropertyConditionGetArguments(void)
   tet_infoline(" UtcDaliPropertyConditionGetArguments");
 
   PropertyCondition condition = GreaterThanCondition( 50.0f );
-  PropertyCondition::ArgumentContainer arguments = condition.GetArguments();
 
-  DALI_TEST_EQUALS( arguments.size(), 1u, TEST_LOCATION );
-  Property::Value value = arguments[0];
-  DALI_TEST_EQUALS( value.Get<float>(), 50.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( condition.GetArgumentCount(), 1u, TEST_LOCATION );
+  float value = condition.GetArgument( 0 );
+  DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION );
 
   condition = InsideCondition( 125.0f, 250.0f );
-  arguments = condition.GetArguments();
 
-  DALI_TEST_EQUALS( arguments.size(), 2u, TEST_LOCATION );
-  Property::Value value1 = arguments[0];
-  Property::Value value2 = arguments[1];
-  DALI_TEST_EQUALS( value1.Get<float>(), 125.0f, TEST_LOCATION );
-  DALI_TEST_EQUALS( value2.Get<float>(), 250.0f, TEST_LOCATION );
-  END_TEST;
-}
-
-namespace
-{
-
-class PropertyConditionConstWrapper
-{
-public:
-
-  PropertyConditionConstWrapper(PropertyCondition propertyCondition)
-  :mPropertyCondition(propertyCondition)
-  {
-
-  }
-
-  /**
-   * Returns const reference to property arguments.
-   * @return const reference.
-   */
-  const PropertyCondition::ArgumentContainer& GetArguments() const
-  {
-    return mPropertyCondition.GetArguments();
-  }
-
-  PropertyCondition mPropertyCondition;
-};
-} // anon namespace
-
-int UtcDaliPropertyConditionGetArgumentsConst(void)
-{
-  TestApplication application;
-  tet_infoline(" UtcDaliPropertyConditionGetArgumentsConst");
-
-  PropertyCondition condition = GreaterThanCondition( 50.0f );
-  PropertyConditionConstWrapper conditionConst(condition);
-  const PropertyCondition::ArgumentContainer& argumentsRef1 = conditionConst.GetArguments();
-  const PropertyCondition::ArgumentContainer& argumentsRef2 = conditionConst.GetArguments();
-
-  DALI_TEST_CHECK( (&argumentsRef1) == (&argumentsRef2) );
-  DALI_TEST_EQUALS( argumentsRef1.size(), 1u, TEST_LOCATION );
-  Property::Value value = argumentsRef1[0];
-  DALI_TEST_EQUALS( value.Get<float>(), 50.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( condition.GetArgumentCount(), 2u, TEST_LOCATION );
+  float value1 = condition.GetArgument( 0 );
+  float value2 = condition.GetArgument( 1 );
+  DALI_TEST_EQUALS( value1, 125.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( value2, 250.0f, TEST_LOCATION );
   END_TEST;
 }
 
@@ -779,7 +760,7 @@ int UtcDaliPropertyNotificationStep(void)
 
   const float step = 100.0f;
   // float
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::Position, 0, StepCondition(step, 50.0f) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION, 0, StepCondition(step, 50.0f) );
   notification.NotifySignal().Connect( &TestCallback );
 
   // set initial position
@@ -815,23 +796,23 @@ int UtcDaliPropertyNotificationVariableStep(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
 
-  std::vector<float> values;
+  Dali::Vector<float> values;
 
   const float averageStep = 100.0f;
 
   for( int i = 1 ; i < 10 ; i++ )
   {
-    values.push_back(i * averageStep + (i % 2 == 0 ? -(averageStep * 0.2f) : (averageStep * 0.2f)));
+    values.PushBack(i * averageStep + (i % 2 == 0 ? -(averageStep * 0.2f) : (averageStep * 0.2f)));
   }
   // float
-  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::Position, 0, VariableStepCondition(values) );
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION, 0, VariableStepCondition(values) );
   notification.NotifySignal().Connect( &TestCallback );
 
   // set initial position lower than first position in list
   actor.SetPosition(Vector3(values[0] - averageStep, 0.0f, 0.0f));
   Wait(application, DEFAULT_WAIT_PERIOD);
 
-  for( unsigned int i = 0 ; i < values.size() - 1 ; ++i )
+  for( unsigned int i = 0 ; i < values.Count() - 1 ; ++i )
   {
     gCallBackCalled = false;
     // set position half way between the current values
@@ -856,13 +837,13 @@ int UtcDaliPropertyNotificationOrder(void)
   Actor actor = Actor::New();
   Stage::GetCurrent().Add(actor);
   // this should complete in first frame
-  PropertyNotification notification1 = actor.AddPropertyNotification( Actor::Property::PositionX, GreaterThanCondition(90.0f) );
+  PropertyNotification notification1 = actor.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(90.0f) );
   notification1.NotifySignal().Connect( &TestCallback );
   // this should complete in second frame
-  PropertyNotification notification2 = actor.AddPropertyNotification( Actor::Property::PositionX, GreaterThanCondition(150.0f) );
+  PropertyNotification notification2 = actor.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(150.0f) );
   notification2.NotifySignal().Connect( &TestCallback2 );
   Animation animation = Animation::New( 0.032f ); // finishes in 32 ms
-  animation.AnimateTo( Property(actor, Actor::Property::Position ), Vector3( 200.0f, 0.0f, 0.0f ), AlphaFunctions::Linear );
+  animation.AnimateTo( Property(actor, Actor::Property::POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), AlphaFunction::LINEAR );
   animation.Play();
 
   // flush the queue