Remove deprecated APIs in Tizen 3.0
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Scripting.cpp
index 151b770..793a5ba 100644 (file)
@@ -37,15 +37,6 @@ const StringEnum COLOR_MODE_VALUES[] =
 };
 const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
 
-const StringEnum POSITION_INHERITANCE_MODE_VALUES[] =
-{
-    { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
-    { "USE_PARENT_POSITION", USE_PARENT_POSITION },
-    { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION },
-    { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
-};
-const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] );
-
 const StringEnum DRAW_MODE_VALUES[] =
 {
     { "NORMAL", DrawMode::NORMAL },
@@ -82,14 +73,7 @@ void TestEnumStrings(
   }
 }
 
-/// Helper method to create ResourceImage using property
-ResourceImage NewResourceImage( const Property::Value& map )
-{
-  ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
-  return image;
-}
-
-/// Helper method to create ResourceImage using property
+/// Helper method to create BufferImage using property
 BufferImage NewBufferImage( const Property::Value& map )
 {
   BufferImage image = BufferImage::DownCast( NewImage( map ) );
@@ -159,6 +143,7 @@ int UtcDaliScriptingNewImageNegative06(void)
   map[ "width" ] = "Invalid";
   map[ "height" ] = 100;
   // will give us a valid image
+  PrepareResourceImage( application, 0u, 100u, Pixel::RGBA8888 );
   Image image = NewImage( map );
   DALI_TEST_CHECK( image );
   ResourceImage resImage = ResourceImage::DownCast( image );
@@ -177,6 +162,7 @@ int UtcDaliScriptingNewImageNegative07(void)
   map[ "width" ] = 10;
   map[ "height" ] = "Invalid";
   // will give us a valid image
+  PrepareResourceImage( application, 10u, 0u, Pixel::RGBA8888 );
   Image image = NewImage( map );
   DALI_TEST_CHECK( image );
   ResourceImage resImage = ResourceImage::DownCast( image );
@@ -314,6 +300,7 @@ int UtcDaliScriptingNewImage04P(void)
   // float width and height
   map[ "width" ] = (float) 10.0f;
   map[ "height" ] = (float) 20.0f;
+  PrepareResourceImage( application, 10u, 20u, Pixel::RGBA8888 );
   Image image = NewImage( map );
   DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION );
   DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION );
@@ -330,6 +317,7 @@ int UtcDaliScriptingNewImage05P(void)
   // width and height
   map[ "width"] = 50;
   map[ "height" ] = 70;
+  PrepareResourceImage( application, 50u, 70u, Pixel::RGBA8888 );
   Image image = NewImage( map );
   DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
   DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
@@ -482,7 +470,6 @@ int UtcDaliScriptingNewActorProperties(void)
   map[ "colorMode" ] = "USE_PARENT_COLOR";
   map[ "sensitive" ] = false;
   map[ "leaveRequired" ] = true;
-  map[ "positionInheritance" ] = "DONT_INHERIT_POSITION";
   map[ "drawMode" ] = "OVERLAY_2D";
   map[ "inheritOrientation" ] = false;
   map[ "inheritScale" ] = false;
@@ -505,7 +492,6 @@ int UtcDaliScriptingNewActorProperties(void)
     DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
     DALI_TEST_EQUALS( handle.IsSensitive(), false, TEST_LOCATION );
     DALI_TEST_EQUALS( handle.GetLeaveRequired(), true, TEST_LOCATION );
-    DALI_TEST_EQUALS( handle.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
     DALI_TEST_EQUALS( handle.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
     DALI_TEST_EQUALS( handle.IsOrientationInherited(), false, TEST_LOCATION );
     DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );
@@ -549,6 +535,46 @@ int UtcDaliScriptingNewActorProperties(void)
   END_TEST;
 }
 
+int UtcDaliScriptingNewAnimation(void)
+{
+  TestApplication application;
+
+  Property::Map map;
+  map["actor"] = "Actor1";
+  map["property"] = "color";
+  map["value"] = Color::MAGENTA;
+  map["alphaFunction"] = "EASE_IN_OUT";
+
+  Property::Map timePeriod;
+  timePeriod["delay"] = 0.5f;
+  timePeriod["duration"] = 1.0f;
+  map["timePeriod"] = timePeriod;
+
+  Dali::AnimationData data;
+  Scripting::NewAnimation( map, data );
+
+  Actor actor = Actor::New();
+  actor.SetName("Actor1");
+  actor.SetColor(Color::CYAN);
+  Stage::GetCurrent().Add(actor);
+
+  Animation anim = data.CreateAnimation( actor, 0.5f );
+  anim.Play();
+
+  application.SendNotification();
+  application.Render(0);
+  application.Render(500); // Start animation
+  application.Render(500); // Halfway thru anim
+  application.SendNotification();
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::CYAN)*0.5f, TEST_LOCATION);
+
+  application.Render(500); // Halfway thru anim
+  application.SendNotification();
+  DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliScriptingNewActorChildren(void)
 {
   TestApplication application;
@@ -675,9 +701,6 @@ int UtcDaliScriptingCreatePropertyMapActor(void)
   // ColorMode
   TestEnumStrings< ColorMode >( "colorMode",  application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
 
-  // PositionInheritanceMode
-  TestEnumStrings< PositionInheritanceMode >( "positionInheritance",  application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
-
   // DrawMode
   TestEnumStrings< DrawMode::Type >( "drawMode",  application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
 
@@ -741,6 +764,7 @@ int UtcDaliScriptingCreatePropertyMapImage(void)
 
   // Change values
   {
+    PrepareResourceImage( application, 300, 400, Pixel::RGBA8888 );
     ResourceImage image = ResourceImage::New( "MY_PATH", ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
 
     Property::Map map;