Further Setter/Getter public API removal from Dali::Actor
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-BaseHandle.cpp
index 626fb37..8bf71c4 100644 (file)
@@ -48,7 +48,7 @@ struct AnimationFinishCheck
   {
   }
 
-  void operator()(Animation& animation)
+  void operator()()
   {
     mSignalReceived = true;
   }
@@ -96,6 +96,20 @@ struct TestCallback
   }
 };
 
+// Used for testing BaseObject::GetTypeName with an object that is not registered
+class FakeObject : public BaseObject
+{
+};
+// used for testing ThisIsSaferThanReturningVoidStar
+class FakeHandle :  public BaseHandle
+{
+public:
+
+  void RunTest()
+  {
+    return ThisIsSaferThanReturningVoidStar();
+  }
+};
 } // anon namespace
 
 int UtcDaliBaseHandleConstructorVoid(void)
@@ -109,7 +123,6 @@ int UtcDaliBaseHandleConstructorVoid(void)
   END_TEST;
 }
 
-
 int UtcDaliBaseHandleCopyConstructor(void)
 {
   TestApplication application;
@@ -275,18 +288,18 @@ int UtcDaliBaseHandleStlVector(void)
 
     std::stringstream stream;
     stream << "Actor " << i+1;
-    actor.SetName(stream.str());
+    actor.SetProperty( Actor::Property::NAME,stream.str());
 
     myVector.push_back(actor);
   }
 
   DALI_TEST_EQUALS(TargetVectorSize, static_cast<int>(myVector.size()), TEST_LOCATION);
 
-  DALI_TEST_CHECK(myVector[0].GetName() == "Actor 1");
-  DALI_TEST_CHECK(myVector[1].GetName() == "Actor 2");
-  DALI_TEST_CHECK(myVector[2].GetName() == "Actor 3");
-  DALI_TEST_CHECK(myVector[3].GetName() == "Actor 4");
-  DALI_TEST_CHECK(myVector[4].GetName() == "Actor 5");
+  DALI_TEST_CHECK(myVector[0].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 1");
+  DALI_TEST_CHECK(myVector[1].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 2");
+  DALI_TEST_CHECK(myVector[2].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 3");
+  DALI_TEST_CHECK(myVector[3].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 4");
+  DALI_TEST_CHECK(myVector[4].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 5");
   END_TEST;
 }
 
@@ -301,12 +314,12 @@ int UtcDaliBaseHandleDoAction(void)
   DALI_TEST_CHECK(actorObject);
 
   // Check that an invalid command is not performed
-  std::vector<Property::Value> attributes;
+  Property::Map attributes;
   DALI_TEST_CHECK(actorObject.DoAction("invalidCommand", attributes) == false);
 
   // Check that the actor is visible
-  actor.SetVisible(true);
-  DALI_TEST_CHECK(actor.IsVisible() == true);
+  actor.SetProperty( Actor::Property::VISIBLE,true);
+  DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
 
   // Check the actor performed an action to hide itself
   DALI_TEST_CHECK(actorObject.DoAction("hide", attributes) == true);
@@ -316,7 +329,7 @@ int UtcDaliBaseHandleDoAction(void)
   application.Render();
 
   // Check that the actor is now invisible
-  DALI_TEST_CHECK(actor.IsVisible() == false);
+  DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
 
   // Check the actor performed an action to show itself
   DALI_TEST_CHECK(actorObject.DoAction("show", attributes) == true);
@@ -326,7 +339,7 @@ int UtcDaliBaseHandleDoAction(void)
   application.Render();
 
   // Check that the actor is now visible
-  DALI_TEST_CHECK(actor.IsVisible() == true);
+  DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
 
   Stage::GetCurrent().Add(actor);
 
@@ -341,27 +354,54 @@ int UtcDaliBaseHandleDoAction(void)
   DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION);
 
   Vector3 targetPosition(100.0f, 100.0f, 100.0f);
-  animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear);
+  animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
 
   // Set the new duration to be 2 seconds
   float newDurationSeconds(2.0f);
   Property::Value newDurationSecondsValue = Property::Value( newDurationSeconds );
-  attributes.push_back(newDurationSecondsValue);
+  attributes["duration"] = newDurationSecondsValue;
 
   // Check the animation performed an action to play itself with the specified duration of 2 seconds
   animationObject.DoAction("play", attributes);
 
   bool signalReceived(false);
   AnimationFinishCheck finishCheck(signalReceived);
-  animation.FinishedSignal().Connect(&application, finishCheck);
+  // use the handle API to connect the signal
+  animation.ConnectSignal( &application, "finished", finishCheck );
+  // just for coverage connect to non-existant signal as well
+  animation.ConnectSignal( &application, "foo", finishCheck );
+  DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<uint32_t>(newDurationSeconds * 500.0f) /* half of time */);
+  DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
 
+  // pause
+  animationObject.DoAction("pause", attributes);
+  application.SendNotification();
+  application.Render(static_cast<uint32_t>(newDurationSeconds * 500.0f) + 1u/*just beyond the animation duration*/);
+  DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+
+  // continue
+  animationObject.DoAction("play", attributes);
   application.SendNotification();
-  application.Render(static_cast<unsigned int>(newDurationSeconds * 1000.0f) + 1u/*just beyond the animation duration*/);
+  application.Render(static_cast<uint32_t>(newDurationSeconds * 500.0f) + 1u/*just beyond the animation duration*/);
 
   // We expect the animation to finish
   application.SendNotification();
   finishCheck.CheckSignalReceived();
-  DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION );
+
+  // play again
+  signalReceived = false;
+  animationObject.DoAction("play", attributes);
+  DALI_TEST_EQUALS(animation.GetCurrentProgress(), 0.f, TEST_LOCATION);
+  application.SendNotification();
+  application.Render(static_cast<uint32_t>(newDurationSeconds * 500.0f) /* half of time */);
+  animationObject.DoAction("stop", attributes);
+  application.SendNotification();
+  application.Render(static_cast<uint32_t>(newDurationSeconds * 1000.0f) /* full time */);
+  DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
 
   // Check the new animation duration is 2 seconds
   DALI_TEST_EQUALS(animation.GetDuration(), newDurationSeconds, TEST_LOCATION);
@@ -378,10 +418,10 @@ int UtcDaliBaseHandleConnectSignal(void)
 
   // get the root layer
   Actor actor = Actor::New();
-  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  actor.SetPosition( 240, 400 );
-  actor.SetSize( 100, 100 );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  actor.SetProperty( Actor::Property::POSITION, Vector2( 240, 400 ));
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
 
   Stage::GetCurrent().Add( actor );
 
@@ -396,7 +436,9 @@ int UtcDaliBaseHandleConnectSignal(void)
   application.Render(1000);
 
   // simulate a touch event
-  Dali::TouchPoint point( 0, TouchPoint::Down, 240, 400  );
+  Dali::Integration::Point point;
+  point.SetState( PointState::DOWN );
+  point.SetScreenPosition( Vector2( 240, 400 ) );
   Dali::Integration::TouchEvent event;
   event.AddPoint( point );
   application.ProcessEvent( event );
@@ -419,7 +461,7 @@ int UtcDaliBaseHandleConnectSignal(void)
   END_TEST;
 }
 
-int UtcDaliBaseHandleGetTypeName(void)
+int UtcDaliBaseHandleGetTypeNameP(void)
 {
   TestApplication application;
   tet_infoline("Testing Dali::BaseHandle::GetTypeName");
@@ -434,6 +476,55 @@ int UtcDaliBaseHandleGetTypeName(void)
   END_TEST;
 }
 
+int UtcDaliBaseHandleGetTypeNameN(void)
+{
+
+  TestApplication application;
+  tet_infoline("Testing Dali::BaseObject::GetTypeName");
+  FakeObject object;
+  std::string typeName = object.GetTypeName();
+
+  DALI_TEST_CHECK( typeName.empty() );
+  END_TEST;
+}
+
+int UtcDaliBaseHandleGetTypeInfoP(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Dali::BaseHandle::GetTypeInfo");
+
+  Dali::TypeInfo info;
+  Actor actor = Actor::New();
+
+  bool ok = actor.GetTypeInfo( info );
+  DALI_TEST_CHECK( ok );
+  END_TEST;
+}
+
+int UtcDaliBaseHandleThisIsSaferThanReturningVoidStar(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Dali::BaseHandle::GetTypeInfo");
+  FakeHandle handle;
+  handle.RunTest();
+  tet_result(TET_PASS);
+  END_TEST;
+
+}
+
+int UtcDaliBaseHandleGetTypeInfoN(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Dali::BaseHandle::GetTypeInfo");
+
+  Dali::TypeInfo info;
+  FakeObject object;
+
+  bool ok = object.GetTypeInfo( info );
+  DALI_TEST_CHECK( !ok );
+  END_TEST;
+}
+
 int UtcDaliBaseHandleGetObjectPtr(void)
 {
   TestApplication application;
@@ -459,3 +550,14 @@ int UtcDaliBaseHandleBooleanCast(void)
   DALI_TEST_CHECK( static_cast<BaseHandle::BooleanType>( handle ) );
   END_TEST;
 }
+
+int UtcDaliBaseHandleCompareOperatorN(void)
+{
+  TestApplication application;
+  BaseHandle handle1 = Actor::New();
+  BaseHandle handle2 = handle1;
+
+  DALI_TEST_CHECK( (handle1 < handle2) == false );
+
+  END_TEST;
+}