Revert "[Tizen] Appendix log for ttrace + Print keycode and timestamp"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-AlphaFunction.cpp
index 858a3eb..4caa599 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 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.
  *
  */
 
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
+#include <dali/public-api/dali-core.h>
+#include <stdlib.h>
+
+#include <iostream>
 
 using namespace Dali;
 
-float customAlphaFunction( float progress )
+float customAlphaFunction(float progress)
 {
   return progress;
 }
@@ -41,13 +41,13 @@ void utc_dali_alpha_function_cleanup(void)
 int UtcDaliAlphaFunctionDefaultConstructorP(void)
 {
   TestApplication application;
-  AlphaFunction alpha;
+  AlphaFunction   alpha;
 
   //Should return the default alpha function
-  DALI_TEST_EQUALS( alpha.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION);
 
   //Check the mode is BUILTIN_FUNCTION
-  DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION);
 
   END_TEST;
 }
@@ -57,13 +57,13 @@ int UtcDaliAlphaFunctionConstructorFromBuiltinP(void)
   TestApplication application;
 
   //Construct the alpha function with a built-in function
-  AlphaFunction alpha( AlphaFunction::EASE_IN_OUT);
+  AlphaFunction alpha(AlphaFunction::EASE_IN_OUT);
 
   //Check if the built-in alpha function is EASE_IN_OUT
-  DALI_TEST_EQUALS( alpha.GetBuiltinFunction(), AlphaFunction::EASE_IN_OUT, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetBuiltinFunction(), AlphaFunction::EASE_IN_OUT, TEST_LOCATION);
 
   //Check the mode is BUILTIN_FUNCTION
-  DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION);
 
   END_TEST;
 }
@@ -73,14 +73,13 @@ int UtcDaliAlphaFunctionConstructorFromFunctionPointerdP(void)
   TestApplication application;
 
   //Construct the alpha function with a function pointer
-  AlphaFunction alpha( &customAlphaFunction );
+  AlphaFunction alpha(&customAlphaFunction);
 
   //Check that the custom function points to the custom alpha function
-  DALI_TEST_EQUALS( alpha.GetCustomFunction(), &customAlphaFunction, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetCustomFunction(), &customAlphaFunction, TEST_LOCATION);
 
   //Check the mode is CUSTOM_FUNCTION
-  DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION);
-
+  DALI_TEST_EQUALS(alpha.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION);
 
   END_TEST;
 }
@@ -90,17 +89,17 @@ int UtcDaliAlphaFunctionConstructorFromControlPointsP(void)
   TestApplication application;
 
   //Construct the alpha function with two control points
-  Vector2 controlPoint0 = Vector2(0.0f,1.0f);
-  Vector2 controlPoint1 = Vector2(1.0f,0.0f);
-  AlphaFunction alpha(controlPoint0,controlPoint1);
+  Vector2       controlPoint0 = Vector2(0.0f, 1.0f);
+  Vector2       controlPoint1 = Vector2(1.0f, 0.0f);
+  AlphaFunction alpha(controlPoint0, controlPoint1);
 
   //Check if the control points have the correct value
   Vector4 controlPoints = alpha.GetBezierControlPoints();
-  DALI_TEST_EQUALS( Vector2(controlPoints.x,controlPoints.y), controlPoint0, TEST_LOCATION);
-  DALI_TEST_EQUALS( Vector2(controlPoints.z,controlPoints.w), controlPoint1, TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(controlPoints.x, controlPoints.y), controlPoint0, TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(controlPoints.z, controlPoints.w), controlPoint1, TEST_LOCATION);
 
   //Check the mode is BEZIER
-  DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION);
 
   END_TEST;
 }
@@ -110,17 +109,17 @@ int UtcDaliAlphaFunctionConstructorFromControlPointsN(void)
   TestApplication application;
 
   //Construct the alpha function with two control points
-  Vector2 controlPoint0 = Vector2(-10.0f,1.0f);
-  Vector2 controlPoint1 = Vector2(10.0f,0.0f);
-  AlphaFunction alpha(controlPoint0,controlPoint1);
+  Vector2       controlPoint0 = Vector2(-10.0f, 1.0f);
+  Vector2       controlPoint1 = Vector2(10.0f, 0.0f);
+  AlphaFunction alpha(controlPoint0, controlPoint1);
 
   //x components of the control points should have been clamped to [0,1] to ensure the curve is monotonic
   Vector4 controlPoints = alpha.GetBezierControlPoints();
-  DALI_TEST_EQUALS( Vector2(controlPoints.x,controlPoints.y), Vector2(0.0f,1.0f), TEST_LOCATION);
-  DALI_TEST_EQUALS( Vector2(controlPoints.z,controlPoints.w), Vector2(1.0f,0.0f), TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(controlPoints.x, controlPoints.y), Vector2(0.0f, 1.0f), TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(controlPoints.z, controlPoints.w), Vector2(1.0f, 0.0f), TEST_LOCATION);
 
   //Check the mode is BEZIER
-  DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION);
 
   END_TEST;
 }
@@ -128,13 +127,13 @@ int UtcDaliAlphaFunctionConstructorFromControlPointsN(void)
 int UtcDaliAlphaFunctionGetBuiltinFunctionP(void)
 {
   TestApplication application;
-  AlphaFunction alpha( AlphaFunction::EASE_IN);
+  AlphaFunction   alpha(AlphaFunction::EASE_IN);
 
   //Check if the builtin alpha function is EASE_IN
-  DALI_TEST_EQUALS( alpha.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION);
 
   //Check the mode is BUILTIN_FUNCTION
-  DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION);
 
   END_TEST;
 }
@@ -142,13 +141,13 @@ int UtcDaliAlphaFunctionGetBuiltinFunctionP(void)
 int UtcDaliAlphaFunctionGetCustomFunctionP(void)
 {
   TestApplication application;
-  AlphaFunction alpha( &customAlphaFunction );
+  AlphaFunction   alpha(&customAlphaFunction);
 
   //Check that the custom function points to the custom alpha function
-  DALI_TEST_EQUALS( alpha.GetCustomFunction(), &customAlphaFunction, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetCustomFunction(), &customAlphaFunction, TEST_LOCATION);
 
   //Check the mode is CUSTOM_FUNCTION
-  DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION);
 
   END_TEST;
 }
@@ -157,17 +156,17 @@ int UtcDaliAlphaFunctionGetControlPointsFunctionP(void)
 {
   TestApplication application;
 
-  Vector2 controlPoint0 = Vector2(0.0f,1.0f);
-  Vector2 controlPoint1 = Vector2(1.0f,0.0f);
-  AlphaFunction alpha( controlPoint0,controlPoint1 );
+  Vector2       controlPoint0 = Vector2(0.0f, 1.0f);
+  Vector2       controlPoint1 = Vector2(1.0f, 0.0f);
+  AlphaFunction alpha(controlPoint0, controlPoint1);
 
   //Check if the control points have the correct value
   Vector4 controlPoints = alpha.GetBezierControlPoints();
-  DALI_TEST_EQUALS( Vector2(controlPoints.x,controlPoints.y), controlPoint0, TEST_LOCATION);
-  DALI_TEST_EQUALS( Vector2(controlPoints.z,controlPoints.w), controlPoint1, TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(controlPoints.x, controlPoints.y), controlPoint0, TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(controlPoints.z, controlPoints.w), controlPoint1, TEST_LOCATION);
 
   //Check the mode is BEZIER
-  DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION);
+  DALI_TEST_EQUALS(alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION);
 
   END_TEST;
 }
@@ -177,22 +176,22 @@ int UtcDaliAlphaFunctionGetModeP(void)
   TestApplication application;
 
   //Create alpha function using a built-in function
-  AlphaFunction alphaBuiltin( AlphaFunction::EASE_IN);
+  AlphaFunction alphaBuiltin(AlphaFunction::EASE_IN);
 
   //Check the mode is BUILTIN_FUNCTION
-  DALI_TEST_EQUALS( alphaBuiltin.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION);
+  DALI_TEST_EQUALS(alphaBuiltin.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION);
 
   //Create alpha function with pointer to function
-  AlphaFunction alphaCustom( &customAlphaFunction );
+  AlphaFunction alphaCustom(&customAlphaFunction);
   //Check the mode is CUSTOM_FUNCTION
-  DALI_TEST_EQUALS( alphaCustom.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION);
+  DALI_TEST_EQUALS(alphaCustom.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION);
 
   //Create alpha function with control points
-  Vector2 controlPoint0 = Vector2(0.0f,1.0f);
-  Vector2 controlPoint1 = Vector2(1.0f,0.0f);
-  AlphaFunction alphaBezier( controlPoint0,controlPoint1 );
+  Vector2       controlPoint0 = Vector2(0.0f, 1.0f);
+  Vector2       controlPoint1 = Vector2(1.0f, 0.0f);
+  AlphaFunction alphaBezier(controlPoint0, controlPoint1);
   //Check the mode is BEZIER
-  DALI_TEST_EQUALS( alphaBezier.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION);
+  DALI_TEST_EQUALS(alphaBezier.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION);
 
   END_TEST;
 }
@@ -204,49 +203,48 @@ int UtcDaliAlphaFunctionBezier(void)
   Actor actor = Actor::New();
 
   // Register a float property
-  float startValue(0.0f);
-  Property::Index index = actor.RegisterProperty( "test-property", startValue );
-  Stage::GetCurrent().Add(actor);
-  DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
+  float           startValue(0.0f);
+  Property::Index index = actor.RegisterProperty("testProperty", startValue);
+  application.GetScene().Add(actor);
+  DALI_TEST_EQUALS(actor.GetProperty<float>(index), startValue, TEST_LOCATION);
 
   // Build the animation
-  float durationSeconds(1.0f);
+  float     durationSeconds(1.0f);
   Animation animation = Animation::New(durationSeconds);
-  float targetValue(1.0f);
+  float     targetValue(1.0f);
 
-  Vector2 controlPoint0 = Vector2(0.25f,0.5f);
-  Vector2 controlPoint1 = Vector2(0.75f,0.5f);
-  animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunction(controlPoint0,controlPoint1));
+  Vector2 controlPoint0 = Vector2(0.25f, 0.5f);
+  Vector2 controlPoint1 = Vector2(0.75f, 0.5f);
+  animation.AnimateTo(Property(actor, "testProperty"), targetValue, AlphaFunction(controlPoint0, controlPoint1));
 
   // Start the animation
   animation.Play();
 
   application.SendNotification();
-  application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+  application.Render(static_cast<unsigned int>(durationSeconds * 200.0f) /* 20% progress */);
   application.SendNotification();
   float epsilon(0.01f);
-  DALI_TEST_EQUALS( actor.GetProperty<float>(index), 0.271964f, epsilon, TEST_LOCATION );
+  DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 0.271964f, epsilon, TEST_LOCATION);
 
   application.SendNotification();
-  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*40% progress*/);
+  application.Render(static_cast<unsigned int>(durationSeconds * 200.0f) + 1u /*40% progress*/);
   application.SendNotification();
-  DALI_TEST_EQUALS( actor.GetProperty<float>(index), 0.432387f, epsilon, TEST_LOCATION );
+  DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 0.432387f, epsilon, TEST_LOCATION);
 
   application.SendNotification();
-  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*60% progress*/);
+  application.Render(static_cast<unsigned int>(durationSeconds * 200.0f) + 1u /*60% progress*/);
   application.SendNotification();
-  DALI_TEST_EQUALS( actor.GetProperty<float>(index), 0.567613f, epsilon, TEST_LOCATION );
+  DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 0.567613f, epsilon, TEST_LOCATION);
 
   application.SendNotification();
-  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*80% progress*/);
+  application.Render(static_cast<unsigned int>(durationSeconds * 200.0f) + 1u /*80% progress*/);
   application.SendNotification();
-  DALI_TEST_EQUALS( actor.GetProperty<float>(index), 0.728037f, epsilon, TEST_LOCATION );
+  DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 0.728037f, epsilon, TEST_LOCATION);
 
   application.SendNotification();
-  application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
+  application.Render(static_cast<unsigned int>(durationSeconds * 200.0f) + 1u /*just beyond the animation duration*/);
   application.SendNotification();
-  DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetValue, TEST_LOCATION );
+  DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), targetValue, TEST_LOCATION);
 
   END_TEST;
 }
-