Renamed TouchSignal to TouchedSignal
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Scripting.cpp
index a911567..2ae4abf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 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.
@@ -73,13 +73,6 @@ void TestEnumStrings(
   }
 }
 
-/// Helper method to create BufferImage using property
-BufferImage NewBufferImage( const Property::Value& map )
-{
-  BufferImage image = BufferImage::DownCast( NewImage( map ) );
-  return image;
-}
-
 //////////////////////////////////////////////////////////////////////////////
 // Helpers for string to enum comparisons for Actor to Property::Map
 //////////////////////////////////////////////////////////////////////////////
@@ -103,7 +96,7 @@ void TestEnumStrings(
     Actor actor = Actor::New();
     (actor.*method)( ( T ) values[i].value );
 
-    Stage::GetCurrent().Add( actor );
+    application.GetScene().Add( actor );
     application.SendNotification();
     application.Render();
 
@@ -114,7 +107,7 @@ void TestEnumStrings(
     DALI_TEST_CHECK( NULL != map.Find( keyName ) );
     DALI_TEST_EQUALS( map.Find( keyName )->Get< std::string >(), values[i].string, TEST_LOCATION );
 
-    Stage::GetCurrent().Remove( actor );
+    application.GetScene().Remove( actor );
   }
 }
 
@@ -141,304 +134,6 @@ int UtcDaliValueFromEnum(void)
   END_TEST;
 }
 
-int UtcDaliScriptingNewImageNegative01(void)
-{
-  // Invalid filename
-  Property::Map map;
-  map[ "filename" ] = Vector3::ZERO;
-  // will give us an empty image handle
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( !image );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative06(void)
-{
-  TestApplication application; // Image needs application
-  // Invalid width and height
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-  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 );
-  DALI_TEST_CHECK( resImage );
-  DALI_TEST_EQUALS( resImage.GetWidth(), 0u, TEST_LOCATION );
-  DALI_TEST_EQUALS( resImage.GetHeight(), 100u, TEST_LOCATION );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative07(void)
-{
-  TestApplication application; // Image needs application
-  // Invalid height
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-  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 );
-  DALI_TEST_CHECK( resImage );
-  DALI_TEST_EQUALS( resImage.GetWidth(), 10u, TEST_LOCATION );
-  DALI_TEST_EQUALS( resImage.GetHeight(), 0u, TEST_LOCATION );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative08(void)
-{
-  TestApplication application; // Image needs application
-  // Invalid fitting-mode
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-  map[ "fittingMode" ] = Vector3::ZERO;
-  // will give us a valid image
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( image );
-  ResourceImage resImage = ResourceImage::DownCast( image );
-  DALI_TEST_CHECK( resImage );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative09(void)
-{
-  TestApplication application; // Image needs application
-  // Invalid value
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-  map[ "fittingMode" ] = "INVALID";
-  // will give us a valid image
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( image );
-  ResourceImage resImage = ResourceImage::DownCast( image );
-  DALI_TEST_CHECK( resImage );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative10(void)
-{
-  TestApplication application; // Image needs application
-  // Invalid scaling-mode
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-  map[ "samplingMode" ] = Vector3::ZERO;
-  // will give us a valid image
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( image );
-  ResourceImage resImage = ResourceImage::DownCast( image );
-  DALI_TEST_CHECK( resImage );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative12(void)
-{
-  TestApplication application; // Image needs application
-  // Invalid orientation-correction
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-  map[ "orientation" ] = Vector3::ZERO;
-  // will give us a valid image
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( image );
-  ResourceImage resImage = ResourceImage::DownCast( image );
-  DALI_TEST_CHECK( resImage );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative13(void)
-{
-  TestApplication application; // Image needs application
-  // Invalid type
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-  map[ "type" ] = Vector3::ZERO;
-  // will give us a valid image
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( image );
-  ResourceImage resImage = ResourceImage::DownCast( image );
-  DALI_TEST_CHECK( resImage );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative14(void)
-{
-  // Invalid value
-  Property::Map map;
-  map[ "type" ] = "INVALID";
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( !image );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative15(void)
-{
-  // Invalid pixel-format
-  Property::Map map;
-  map[ "pixelFormat" ] = Vector3::ZERO;
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( !image );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative16(void)
-{
-  // Invalid value
-  Property::Map map;
-  map[ "pixelFormat" ] = "INVALID";
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( !image );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImage01P(void)
-{
-  TestApplication application; // Image needs application
-
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-
-  // Filename only
-  ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
-  DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImage04P(void)
-{
-  TestApplication application;
-
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-
-  // 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 );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImage05P(void)
-{
-  TestApplication application;
-
-  Property::Map map;
-  map[ "filename" ] = "TEST_FILE";
-
-  // 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 );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImage06P(void)
-{
-  TestApplication application;
-
-  Property::Map map;
-  // type FrameBufferImage
-  map[ "type" ] = "FrameBufferImage";
-  // width and height
-  map[ "width"] = 50;
-  map[ "height" ] = 70;
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( image );
-  DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImage07P(void)
-{
-  TestApplication application;
-
-  Property::Map map;
-  // type BufferImage
-  map[ "type" ] = "BufferImage";
-  // width and height
-  map[ "width"] = 50;
-  map[ "height" ] = 70;
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( image );
-  DALI_TEST_CHECK( BufferImage::DownCast( image ) );
-  DALI_TEST_EQUALS( (BufferImage::DownCast( image )).GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImage08P(void)
-{
-  TestApplication application;
-
-  Property::Map map;
-  map[ "type" ] = "BufferImage";
-  // width and height
-  map[ "width"] = 66;
-  map[ "height" ] = 99;
-  // pixel-format
-  map[ "pixelFormat" ] = "";
-  const StringEnum values[] =
-  {
-    { "A8", Pixel::A8 },
-    { "L8", Pixel::L8 },
-    { "LA88", Pixel::LA88 },
-    { "RGB565", Pixel::RGB565 },
-    { "BGR565", Pixel::BGR565 },
-    { "RGBA4444", Pixel::RGBA4444 },
-    { "BGRA4444", Pixel::BGRA4444 },
-    { "RGBA5551", Pixel::RGBA5551 },
-    { "BGRA5551", Pixel::BGRA5551 },
-    { "RGB888", Pixel::RGB888 },
-    { "RGB8888", Pixel::RGB8888 },
-    { "BGR8888", Pixel::BGR8888 },
-    { "RGBA8888", Pixel::RGBA8888 },
-    { "BGRA8888", Pixel::BGRA8888 },
-    // BufferImage does not support compressed formats
-  };
-  TestEnumStrings< Pixel::Format, BufferImage >( map, "pixelFormat",  values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
-
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImage09P(void)
-{
-  TestApplication application;
-
-  Property::Map map;
-  // type Image
-  map[ "type" ] = "ResourceImage";
-  map[ "filename" ] = "TEST_FILE";
-
-  {
-    Image image = NewImage( map );
-    DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
-    DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
-    DALI_TEST_CHECK( !BufferImage::DownCast( image ) );
-  }
-  END_TEST;
-}
-
-int UtcDaliScriptingNewImage10P(void)
-{
-  TestApplication application;
-
-  Property::Map map;
-  // type FrameBufferImage, empty size gives us stage size
-  map[ "type" ] = "FrameBufferImage";
-  Image image = NewImage( map );
-  DALI_TEST_CHECK( image );
-  END_TEST;
-}
-
 int UtcDaliScriptingNewActorNegative(void)
 {
   TestApplication application;
@@ -466,8 +161,8 @@ int UtcDaliScriptingNewActorNegative(void)
     Actor handle = NewActor( map );
     DALI_TEST_CHECK( handle );
     DALI_TEST_CHECK( !handle.WheelEventSignal().GetConnectionCount() );
-    DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
-    DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
+    DALI_TEST_CHECK( !handle.OffSceneSignal().GetConnectionCount() );
+    DALI_TEST_CHECK( !handle.OnSceneSignal().GetConnectionCount() );
     DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
   }
   END_TEST;
@@ -497,7 +192,7 @@ int UtcDaliScriptingNewActorProperties(void)
     Actor handle = NewActor( map );
     DALI_TEST_CHECK( handle );
 
-    Stage::GetCurrent().Add( handle );
+    application.GetScene().Add( handle );
     application.SendNotification();
     application.Render();
 
@@ -514,7 +209,7 @@ int UtcDaliScriptingNewActorProperties(void)
     DALI_TEST_EQUALS( handle.GetProperty< bool >( Actor::Property::INHERIT_ORIENTATION ), false, TEST_LOCATION );
     DALI_TEST_EQUALS( handle.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), false, TEST_LOCATION );
 
-    Stage::GetCurrent().Remove( handle );
+    application.GetScene().Remove( handle );
   }
 
   // Check Anchor point and parent origin vector3s
@@ -524,14 +219,14 @@ int UtcDaliScriptingNewActorProperties(void)
     Actor handle = NewActor( map );
     DALI_TEST_CHECK( handle );
 
-    Stage::GetCurrent().Add( handle );
+    application.GetScene().Add( handle );
     application.SendNotification();
     application.Render();
 
     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), AnchorPoint::TOP_LEFT, TEST_LOCATION );
 
-    Stage::GetCurrent().Remove( handle );
+    application.GetScene().Remove( handle );
   }
 
   // Check Anchor point and parent origin STRINGS
@@ -541,14 +236,14 @@ int UtcDaliScriptingNewActorProperties(void)
     Actor handle = NewActor( map );
     DALI_TEST_CHECK( handle );
 
-    Stage::GetCurrent().Add( handle );
+    application.GetScene().Add( handle );
     application.SendNotification();
     application.Render();
 
     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
 
-    Stage::GetCurrent().Remove( handle );
+    application.GetScene().Remove( handle );
   }
   END_TEST;
 }
@@ -574,7 +269,7 @@ int UtcDaliScriptingNewAnimation(void)
   Actor actor = Actor::New();
   actor.SetProperty( Actor::Property::NAME,"Actor1");
   actor.SetProperty( Actor::Property::COLOR,Color::CYAN);
-  Stage::GetCurrent().Add(actor);
+  application.GetScene().Add(actor);
 
   Animation anim = data.CreateAnimation( actor, 0.5f );
   anim.Play();
@@ -613,7 +308,7 @@ int UtcDaliScriptingNewActorChildren(void)
   Actor handle = NewActor( map );
   DALI_TEST_CHECK( handle );
 
-  Stage::GetCurrent().Add( handle );
+  application.GetScene().Add( handle );
   application.SendNotification();
   application.Render();
 
@@ -626,7 +321,7 @@ int UtcDaliScriptingNewActorChildren(void)
   DALI_TEST_EQUALS( child1.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::YAXIS, TEST_LOCATION );
   DALI_TEST_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION );
 
-  Stage::GetCurrent().Remove( handle );
+  application.GetScene().Remove( handle );
   END_TEST;
 }
 
@@ -645,7 +340,7 @@ int UtcDaliScriptingCreatePropertyMapActor(void)
     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
     DALI_TEST_EQUALS( map.Find( "type")->Get< std::string >(), "Actor", TEST_LOCATION );
 
-    Stage::GetCurrent().Remove( actor );
+    application.GetScene().Remove( actor );
   }
 
   // Layer Type
@@ -658,7 +353,7 @@ int UtcDaliScriptingCreatePropertyMapActor(void)
     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
     DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
 
-    Stage::GetCurrent().Remove( actor );
+    application.GetScene().Remove( actor );
   }
 
   // Default properties
@@ -678,7 +373,7 @@ int UtcDaliScriptingCreatePropertyMapActor(void)
     actor.SetProperty( Actor::Property::INHERIT_SCALE, false );
     actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3::ONE );
 
-    Stage::GetCurrent().Add( actor );
+    application.GetScene().Add( actor );
     application.SendNotification();
     application.Render();
 
@@ -713,7 +408,7 @@ int UtcDaliScriptingCreatePropertyMapActor(void)
     DALI_TEST_CHECK( NULL != map.Find( "sizeModeFactor" ) );
     DALI_TEST_EQUALS( map.Find( "sizeModeFactor" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
 
-    Stage::GetCurrent().Remove( actor );
+    application.GetScene().Remove( actor );
   }
 
   // Children
@@ -722,7 +417,7 @@ int UtcDaliScriptingCreatePropertyMapActor(void)
     Actor child = Layer::New();
     actor.Add( child );
 
-    Stage::GetCurrent().Add( actor );
+    application.GetScene().Add( actor );
     application.SendNotification();
     application.Render();
 
@@ -741,76 +436,7 @@ int UtcDaliScriptingCreatePropertyMapActor(void)
     DALI_TEST_CHECK( childMap.Find( "type" ) );
     DALI_TEST_EQUALS( childMap.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
 
-    Stage::GetCurrent().Remove( actor );
-  }
-  END_TEST;
-}
-
-int UtcDaliScriptingCreatePropertyMapImage(void)
-{
-  TestApplication application;
-
-  // Empty
-  {
-    Image image;
-    Property::Map map;
-    CreatePropertyMap( image, map );
-    DALI_TEST_CHECK( map.Empty() );
-  }
-
-  // Default
-  {
-    Image image = ResourceImage::New( "MY_PATH" );
-
-    Property::Map map;
-    CreatePropertyMap( image, map );
-    DALI_TEST_CHECK( !map.Empty() );
-
-    DALI_TEST_CHECK( NULL != map.Find( "type" ) );
-    DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
-    DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
-    DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
-    DALI_TEST_CHECK( NULL == map.Find( "width" ) );
-    DALI_TEST_CHECK( NULL == map.Find( "height" ) );
-  }
-
-  // Change values
-  {
-    PrepareResourceImage( application, 300, 400, Pixel::RGBA8888 );
-    ResourceImage image = ResourceImage::New( "MY_PATH", ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
-
-    Property::Map map;
-    CreatePropertyMap( image, map );
-    DALI_TEST_CHECK( !map.Empty() );
-
-    DALI_TEST_CHECK( NULL != map.Find( "type" ) );
-    DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
-    DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
-    DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
-    DALI_TEST_CHECK( NULL != map.Find( "width" ) );
-    DALI_TEST_EQUALS( map.Find( "width" )->Get< int >(), 300, TEST_LOCATION );
-    DALI_TEST_CHECK( NULL != map.Find( "height" ) );
-    DALI_TEST_EQUALS( map.Find( "height" )->Get< int >(), 400, TEST_LOCATION );
-  }
-
-  // BufferImage
-  {
-    Image image = BufferImage::New( 200, 300, Pixel::A8 );
-    Property::Map map;
-    CreatePropertyMap( image, map );
-    DALI_TEST_CHECK( NULL != map.Find( "type" ) );
-    DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "BufferImage", TEST_LOCATION );
-    DALI_TEST_CHECK( NULL != map.Find( "pixelFormat") );
-    DALI_TEST_EQUALS( map.Find( "pixelFormat" )->Get< std::string >(), "A8", TEST_LOCATION );
-  }
-
-  // FrameBufferImage
-  {
-    Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
-    Property::Map map;
-    CreatePropertyMap( image, map );
-    DALI_TEST_CHECK( NULL != map.Find( "type" ) );
-    DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
+    application.GetScene().Remove( actor );
   }
   END_TEST;
 }