/*
- * Copyright (c) 2014 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/devel-api/scripting/scripting.h>
+#include <dali/public-api/dali-core.h>
+#include <stdlib.h>
+
+#include <iostream>
using namespace Dali;
using namespace Dali::Scripting;
namespace
{
-
-const StringEnum< int > COLOR_MODE_VALUES[] =
-{
- { "USE_OWN_COLOR", USE_OWN_COLOR },
- { "USE_PARENT_COLOR", USE_PARENT_COLOR },
- { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR },
- { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
-};
-const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
-
-const StringEnum< int > 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< int > DRAW_MODE_VALUES[] =
-{
- { "NORMAL", DrawMode::NORMAL },
- { "OVERLAY", DrawMode::OVERLAY },
- { "STENCIL", DrawMode::STENCIL },
+const StringEnum COLOR_MODE_VALUES[] =
+ {
+ {"USE_OWN_COLOR", USE_OWN_COLOR},
+ {"USE_PARENT_COLOR", USE_PARENT_COLOR},
+ {"USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR},
+ {"USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA},
};
-const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
+const unsigned int COLOR_MODE_VALUES_COUNT = sizeof(COLOR_MODE_VALUES) / sizeof(COLOR_MODE_VALUES[0]);
+const StringEnum DRAW_MODE_VALUES[] =
+ {
+ {"NORMAL", DrawMode::NORMAL},
+ {"OVERLAY_2D", DrawMode::OVERLAY_2D}};
+const unsigned int DRAW_MODE_VALUES_COUNT = sizeof(DRAW_MODE_VALUES) / sizeof(DRAW_MODE_VALUES[0]);
-//////////////////////////////////////////////////////////////////////////////
-// Helpers for string to enum comparisons for Image and ImageAttributes
-//////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// Helpers for string to enum comparisons for Image and Image loading parameters
+////////////////////////////////////////////////////////////////////////////////
/**
* Template to check enumerations of type T, with a class of type X
*/
-template< typename T, typename X >
+template<typename T, typename X>
void TestEnumStrings(
- Property::Map& map, // The map used to create instance of type X
- const StringEnum< int >* values, // An array of string values
- unsigned int num, // Number of items in the array
- T ( X::*method )() const, // The member method of X to call to get the enum
- X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X
+ Property::Map& map, // The map used to create instance of type X
+ const char* const keyName, // the name of the key to iterate through
+ const StringEnum* values, // An array of string values
+ unsigned int num, // Number of items in the array
+ T (X::*method)() const, // The member method of X to call to get the enum
+ X (*creator)(const Property::Value&) // The method which creates an instance of type X
)
{
- const unsigned int lastIndex( map.Count() - 1 );
- const std::string& key = map.GetKey( lastIndex );
- Property::Value& value = map.GetValue( lastIndex );
-
- for ( unsigned int i = 0; i < num; ++i )
+ // get the key reference so we can change its value
+ Property::Value* value = map.Find(keyName);
+ for(unsigned int i = 0; i < num; ++i)
{
- value = values[i].string;
- tet_printf("Checking: %s: %s\n", key.c_str(), values[i].string );
- X instance = creator( map );
- DALI_TEST_EQUALS( values[i].value, ( instance.*method )(), TEST_LOCATION );
+ *value = values[i].string;
+ tet_printf("Checking: %s: %s\n", keyName, values[i].string);
+ X instance = creator(map);
+ DALI_TEST_EQUALS(values[i].value, (int)(instance.*method)(), TEST_LOCATION);
}
}
-/// 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
-BufferImage NewBufferImage( const Property::Value& map )
-{
- BufferImage image = BufferImage::DownCast( NewImage( map ) );
- return image;
-}
-
-/// Helper method to create ImageAttributes using an Image
-ImageAttributes NewImageAttributes( const Property::Value& map )
-{
- ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
- return image.GetAttributes();
-}
-
//////////////////////////////////////////////////////////////////////////////
// Helpers for string to enum comparisons for Actor to Property::Map
//////////////////////////////////////////////////////////////////////////////
/**
* Template to check enumerations of type T
*/
-template< typename T >
+template<typename T>
void TestEnumStrings(
- const char * const keyName, // The name of the key to check
- TestApplication& application, // Reference to the application class
- const StringEnum< int >* values, // An array of string values
- unsigned int num, // Number of items in the array
- void ( Actor::*method )( T ) // The Actor member method to set the enumeration
+ const char* const keyName, // The name of the key to check
+ TestApplication& application, // Reference to the application class
+ const StringEnum* values, // An array of string values
+ unsigned int num, // Number of items in the array
+ void (Actor::*method)(T) // The Actor member method to set the enumeration
)
{
- for ( unsigned int i = 0; i < num; ++i )
+ for(unsigned int i = 0; i < num; ++i)
{
- tet_printf("Checking: %s: %s\n", keyName, values[i].string );
+ tet_printf("Checking: %s: %s\n", keyName, values[i].string);
Actor actor = Actor::New();
- (actor.*method)( ( T ) values[i].value );
+ (actor.*method)((T)values[i].value);
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add(actor);
application.SendNotification();
application.Render();
Property::Map map;
- CreatePropertyMap( actor, map );
+ CreatePropertyMap(actor, map);
- DALI_TEST_CHECK( map.Count() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( keyName ) );
- DALI_TEST_EQUALS( value.GetValue( keyName ).Get< std::string >(), values[i].string, TEST_LOCATION );
+ DALI_TEST_CHECK(0 < map.Count());
+ 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);
}
}
//////////////////////////////////////////////////////////////////////////////
+} // namespace
-} // anon namespace
+int UtcDaliValueFromEnum(void)
+{
+ enum class T
+ {
+ None,
+ V1 = 1,
+ V2 = 2
+ };
+ Property::Value v1 = T::V1;
+ Property::Value v2 = T::V2;
+ T t = T::None;
+ DALI_TEST_CHECK(v1.Get<T>() == T::V1);
+ DALI_TEST_CHECK(v2.Get<T>() == T::V2);
+ DALI_TEST_CHECK(v1.Get(t) && t == T::V1);
+ DALI_TEST_CHECK(v2.Get(t) && t == T::V2);
-int UtcDaliScriptingGetColorMode(void)
+ END_TEST;
+}
+
+int UtcDaliScriptingNewActorNegative(void)
{
TestApplication application;
- for ( unsigned int i = 0; i < COLOR_MODE_VALUES_COUNT; ++i )
+ // Empty map
{
- tet_printf( "Checking %s == %d\n", COLOR_MODE_VALUES[i].string, COLOR_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].value, GetColorMode( COLOR_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].string, GetColorMode( (ColorMode) COLOR_MODE_VALUES[i].value ), TEST_LOCATION );
+ Actor handle = NewActor(Property::Map());
+ DALI_TEST_CHECK(!handle);
}
- try
+ // Map with only properties
{
- (void)GetColorMode("INVALID_ARG");
- tet_result( TET_FAIL );
+ Property::Map map;
+ map["parentOrigin"] = ParentOrigin::TOP_CENTER;
+ map["anchorPoint"] = AnchorPoint::TOP_CENTER;
+ Actor handle = NewActor(map);
+ DALI_TEST_CHECK(!handle);
}
- catch ( DaliException& e )
+
+ // Add some signals to the map, we should have no signal connections as its not yet supported
{
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ Property::Map map;
+ map["type"] = "Actor";
+ map["signals"] = Property::MAP;
+ Actor handle = NewActor(map);
+ DALI_TEST_CHECK(handle);
+ DALI_TEST_CHECK(!handle.WheelEventSignal().GetConnectionCount());
+ DALI_TEST_CHECK(!handle.OffSceneSignal().GetConnectionCount());
+ DALI_TEST_CHECK(!handle.OnSceneSignal().GetConnectionCount());
+ DALI_TEST_CHECK(!handle.TouchedSignal().GetConnectionCount());
}
END_TEST;
}
-int UtcDaliScriptingGetPositionInheritanceMode(void)
+int UtcDaliScriptingNewActorProperties(void)
{
TestApplication application;
- for ( unsigned int i = 0; i < POSITION_INHERITANCE_MODE_VALUES_COUNT; ++i )
+ Property::Map map;
+ map["type"] = "Actor";
+ map["size"] = Vector3::ONE;
+ map["position"] = Vector3::XAXIS;
+ map["scale"] = Vector3::ONE;
+ map["visible"] = false;
+ map["color"] = Color::MAGENTA;
+ map["name"] = "MyActor";
+ map["colorMode"] = "USE_PARENT_COLOR";
+ map["sensitive"] = false;
+ map["leaveRequired"] = true;
+ map["drawMode"] = "OVERLAY_2D";
+ map["inheritOrientation"] = false;
+ map["inheritScale"] = false;
+
+ // Default properties
{
- tet_printf( "Checking %s == %d\n", POSITION_INHERITANCE_MODE_VALUES[i].string, POSITION_INHERITANCE_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].value, GetPositionInheritanceMode( POSITION_INHERITANCE_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].string, GetPositionInheritanceMode( (PositionInheritanceMode) POSITION_INHERITANCE_MODE_VALUES[i].value ), TEST_LOCATION );
+ Actor handle = NewActor(map);
+ DALI_TEST_CHECK(handle);
+
+ application.GetScene().Add(handle);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(handle.GetCurrentProperty<Vector3>(Actor::Property::SIZE), Vector3::ONE, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3::XAXIS, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::MAGENTA, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetProperty<std::string>(Actor::Property::NAME), "MyActor", TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetProperty<bool>(Actor::Property::SENSITIVE), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
+ 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);
+
+ application.GetScene().Remove(handle);
}
- try
+ // Check Anchor point and parent origin vector3s
+ map["parentOrigin"] = ParentOrigin::TOP_CENTER;
+ map["anchorPoint"] = AnchorPoint::TOP_LEFT;
{
- (void)GetPositionInheritanceMode("INVALID_ARG");
- tet_result( TET_FAIL );
+ Actor handle = NewActor(map);
+ DALI_TEST_CHECK(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);
+
+ application.GetScene().Remove(handle);
}
- catch ( DaliException& e )
+
+ // Check Anchor point and parent origin STRINGS
+ map["parentOrigin"] = "TOP_LEFT";
+ map["anchorPoint"] = "CENTER_LEFT";
{
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ Actor handle = NewActor(map);
+ DALI_TEST_CHECK(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);
+
+ application.GetScene().Remove(handle);
}
END_TEST;
}
-
-int UtcDaliScriptingGetDrawMode(void)
+int UtcDaliScriptingNewAnimation(void)
{
TestApplication application;
- for ( unsigned int i = 0; i < DRAW_MODE_VALUES_COUNT; ++i )
- {
- tet_printf( "Checking %s == %d\n", DRAW_MODE_VALUES[i].string, DRAW_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].value, GetDrawMode( DRAW_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].string, GetDrawMode( (DrawMode::Type) DRAW_MODE_VALUES[i].value ), TEST_LOCATION );
- }
+ 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.SetProperty(Actor::Property::NAME, "Actor1");
+ actor.SetProperty(Actor::Property::COLOR, Color::CYAN);
+ application.GetScene().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.GetCurrentProperty<Vector4>(Actor::Property::COLOR), (Color::MAGENTA + Color::CYAN) * 0.5f, TEST_LOCATION);
+
+ application.Render(500); // Halfway thru anim
+ application.SendNotification();
+ DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::MAGENTA, TEST_LOCATION);
- try
- {
- (void)GetDrawMode("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
END_TEST;
}
-int UtcDaliScriptingGetAnchorConstant(void)
+int UtcDaliScriptingNewActorChildren(void)
{
TestApplication application;
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_LEFT, GetAnchorConstant( "TOP_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_CENTER, GetAnchorConstant( "TOP_CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_RIGHT, GetAnchorConstant( "TOP_RIGHT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_LEFT, GetAnchorConstant( "CENTER_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER, GetAnchorConstant( "CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_RIGHT, GetAnchorConstant( "CENTER_RIGHT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_LEFT, GetAnchorConstant( "BOTTOM_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_CENTER, GetAnchorConstant( "BOTTOM_CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_RIGHT, GetAnchorConstant( "BOTTOM_RIGHT" ), TEST_LOCATION );
-
- try
- {
- (void)GetAnchorConstant("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
+ Property::Map map;
+ map["type"] = "Actor";
+ map["position"] = Vector3::XAXIS;
+
+ Property::Map child1Map;
+ child1Map["type"] = "Layer";
+ child1Map["position"] = Vector3::YAXIS;
+
+ Property::Array childArray;
+ childArray.PushBack(child1Map);
+ map["actors"] = childArray;
+
+ // Create
+ Actor handle = NewActor(map);
+ DALI_TEST_CHECK(handle);
+
+ application.GetScene().Add(handle);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(handle.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3::XAXIS, TEST_LOCATION);
+ DALI_TEST_EQUALS(handle.GetChildCount(), 1u, TEST_LOCATION);
+
+ Actor child1 = handle.GetChildAt(0);
+ DALI_TEST_CHECK(child1);
+ DALI_TEST_CHECK(Layer::DownCast(child1));
+ DALI_TEST_EQUALS(child1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3::YAXIS, TEST_LOCATION);
+ DALI_TEST_EQUALS(child1.GetChildCount(), 0u, TEST_LOCATION);
+
+ application.GetScene().Remove(handle);
END_TEST;
}
-int UtcDaliScriptingNewImageNegative(void)
+int UtcDaliScriptingCreatePropertyMapActor(void)
{
TestApplication application;
- // Invalid filename
- try
- {
- Property::Map map;
- map[ "filename" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
+ // Actor Type
{
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
- }
+ Actor actor = Actor::New();
- // Invalid load-policy
- try
- {
Property::Map map;
- map[ "load-policy" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+ CreatePropertyMap(actor, map);
+ DALI_TEST_CHECK(!map.Empty());
+ DALI_TEST_CHECK(NULL != map.Find("type"));
+ DALI_TEST_EQUALS(map.Find("type")->Get<std::string>(), "Actor", TEST_LOCATION);
- // Invalid value
- try
- {
- Property::Map map;
- map[ "load-policy" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
+ application.GetScene().Remove(actor);
}
- // Invalid release-policy
- try
+ // Layer Type
{
+ Actor actor = Layer::New();
+
Property::Map map;
- map[ "release-policy" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+ CreatePropertyMap(actor, map);
+ DALI_TEST_CHECK(!map.Empty());
+ DALI_TEST_CHECK(NULL != map.Find("type"));
+ DALI_TEST_EQUALS(map.Find("type")->Get<std::string>(), "Layer", TEST_LOCATION);
- // Invalid value
- try
- {
- Property::Map map;
- map[ "release-policy" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
+ application.GetScene().Remove(actor);
}
- // Invalid width
- try
- {
- Property::Map map;
- map[ "width" ] = "Invalid";
- map[ "height" ] = "Invalid";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
+ // Default properties
{
- DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
- }
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::SIZE, Vector3::ONE);
+ actor.SetProperty(Actor::Property::POSITION, Vector3::XAXIS);
+ actor.SetProperty(Actor::Property::SCALE, Vector3::ZAXIS);
+ actor.SetProperty(Actor::Property::VISIBLE, false);
+ actor.SetProperty(Actor::Property::COLOR, Color::MAGENTA);
+ actor.SetProperty(Actor::Property::NAME, "MyActor");
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
+ actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
+ actor.SetProperty(Actor::Property::SENSITIVE, false);
+ actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
+ actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
+ actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
+ actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3::ONE);
+
+ application.GetScene().Add(actor);
+ application.SendNotification();
+ application.Render();
- // Invalid height
- try
- {
Property::Map map;
- map[ "width" ] = 10;
- map[ "height" ] = "Invalid";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
+ CreatePropertyMap(actor, map);
+
+ DALI_TEST_CHECK(!map.Empty());
+ DALI_TEST_CHECK(NULL != map.Find("size"));
+ DALI_TEST_EQUALS(map.Find("size")->Get<Vector3>(), Vector3::ONE, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("position"));
+ DALI_TEST_EQUALS(map.Find("position")->Get<Vector3>(), Vector3::XAXIS, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("scale"));
+ DALI_TEST_EQUALS(map.Find("scale")->Get<Vector3>(), Vector3::ZAXIS, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("visible"));
+ DALI_TEST_EQUALS(map.Find("visible")->Get<bool>(), false, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("color"));
+ DALI_TEST_EQUALS(map.Find("color")->Get<Vector4>(), Color::MAGENTA, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("name"));
+ DALI_TEST_EQUALS(map.Find("name")->Get<std::string>(), "MyActor", TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("anchorPoint"));
+ DALI_TEST_EQUALS(map.Find("anchorPoint")->Get<Vector3>(), AnchorPoint::CENTER_LEFT, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("parentOrigin"));
+ DALI_TEST_EQUALS(map.Find("parentOrigin")->Get<Vector3>(), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("sensitive"));
+ DALI_TEST_EQUALS(map.Find("sensitive")->Get<bool>(), false, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("leaveRequired"));
+ DALI_TEST_EQUALS(map.Find("leaveRequired")->Get<bool>(), true, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("inheritOrientation"));
+ DALI_TEST_EQUALS(map.Find("inheritOrientation")->Get<bool>(), false, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("inheritScale"));
+ DALI_TEST_EQUALS(map.Find("inheritScale")->Get<bool>(), false, TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != map.Find("sizeModeFactor"));
+ DALI_TEST_EQUALS(map.Find("sizeModeFactor")->Get<Vector3>(), Vector3::ONE, TEST_LOCATION);
+
+ application.GetScene().Remove(actor);
}
- // Invalid pixel-format
- try
- {
- Property::Map map;
- map[ "pixel-format" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
+ // Children
{
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+ Actor actor = Actor::New();
+ Actor child = Layer::New();
+ actor.Add(child);
- // Invalid value
- try
- {
- Property::Map map;
- map[ "pixel-format" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
+ application.GetScene().Add(actor);
+ application.SendNotification();
+ application.Render();
- // Invalid scaling-mode
- try
- {
Property::Map map;
- map[ "scaling-mode" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+ CreatePropertyMap(actor, map);
+ DALI_TEST_CHECK(!map.Empty());
- // Invalid value
- try
- {
- Property::Map map;
- map[ "scaling-mode" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
+ DALI_TEST_CHECK(NULL != map.Find("type"));
+ DALI_TEST_EQUALS(map.Find("type")->Get<std::string>(), "Actor", TEST_LOCATION);
- // Invalid type
- try
- {
- Property::Map map;
- map[ "type" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(\"type\").GetType()", TEST_LOCATION );
+ DALI_TEST_CHECK(NULL != map.Find("actors"));
+ Property::Array children(map.Find("actors")->Get<Property::Array>());
+ DALI_TEST_CHECK(!children.Empty());
+ Property::Map childMap(children[0].Get<Property::Map>());
+ DALI_TEST_CHECK(!childMap.Empty());
+ DALI_TEST_CHECK(childMap.Find("type"));
+ DALI_TEST_EQUALS(childMap.Find("type")->Get<std::string>(), "Layer", TEST_LOCATION);
- // Invalid value
- try
- {
- Property::Map map;
- map[ "type" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
+ application.GetScene().Remove(actor);
}
END_TEST;
}
-
-int UtcDaliScriptingNewImage(void)
+int UtcDaliScriptingGetEnumerationTemplates(void)
{
- TestApplication 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 );
- }
-
- // load-policy
- map[ "load-policy" ] = "";
- {
- const StringEnum< int > values[] =
+ const Scripting::StringEnum myTable[] =
{
- { "IMMEDIATE", ResourceImage::IMMEDIATE },
- { "ON_DEMAND", ResourceImage::ON_DEMAND }
+ {"ONE", 1},
+ {"TWO", 2},
+ {"THREE", 3},
+ {"FOUR", 4},
+ {"FIVE", 5},
};
- TestEnumStrings< ResourceImage::LoadPolicy, ResourceImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ResourceImage::GetLoadPolicy, &NewResourceImage );
- }
+ const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]);
- // release-policy
- map[ "release-policy" ] = "";
+ for(unsigned int i = 0; i < myTableCount; ++i)
{
- const StringEnum< int > values[] =
- {
- { "UNUSED", Image::UNUSED },
- { "NEVER", Image::NEVER }
- };
- TestEnumStrings< Image::ReleasePolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
- }
-
- // float width and height
- map[ "width" ] = (float) 10.0f;
- map[ "height" ] = (float) 20.0f;
- {
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 10.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 20.0f, TEST_LOCATION );
+ tet_printf("Checking: %s\n", myTable[i].string);
+ int value;
+ DALI_TEST_CHECK(GetEnumeration<int>(myTable[i].string, myTable, myTableCount, value));
+ DALI_TEST_EQUALS(myTable[i].value, value, TEST_LOCATION);
}
- // int width and height
- map[ "width"] = (int) 50;
- map[ "height" ] = (int) 70;
- {
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
- }
-
- //map.erase( map.end() - 2, map.end() );
-
- // scaling-mode
- map[ "scaling-mode" ] = "";
+ for(unsigned int i = 0; i < myTableCount; ++i)
{
- const StringEnum< int > values[] =
- {
- { "SHRINK_TO_FIT", ImageAttributes::ShrinkToFit },
- { "SCALE_TO_FILL", ImageAttributes::ScaleToFill },
- { "FIT_WIDTH", ImageAttributes::FitWidth },
- { "FIT_HEIGHT", ImageAttributes::FitHeight },
- };
- TestEnumStrings< ImageAttributes::ScalingMode, ImageAttributes >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ImageAttributes::GetScalingMode, &NewImageAttributes );
+ tet_printf("Checking: %d\n", myTable[i].value);
+ DALI_TEST_EQUALS(myTable[i].string, GetEnumerationName(myTable[i].value, myTable, myTableCount), TEST_LOCATION);
}
- // type FrameBufferImage
- map[ "type" ] = "FrameBufferImage";
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
- }
- // type BufferImage
- map[ "type" ] = "BufferImage";
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( BufferImage::DownCast( image ) );
- DALI_TEST_CHECK((BufferImage::DownCast( image )).GetPixelFormat()== Pixel::RGBA8888);
- }
-
- // pixel-format
- map[ "pixel-format" ] = "";
- {
- const StringEnum< int > 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 },
- /*{ "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
- { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
- { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
- { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
- { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
- { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
- { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
- { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
- { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
- { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },*/
- // BufferImage doesnot support compressed format
- };
-
- TestEnumStrings< Pixel::Format, BufferImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
- }
-
- // type Image
- map[ "type" ] = "ResourceImage";
- {
- 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 UtcDaliScriptingNewShaderEffect(void)
+int UtcDaliScriptingGetEnumerationNameN(void)
{
- TestApplication application;
+ const char* value = GetEnumerationName(10, NULL, 0);
+ DALI_TEST_CHECK(NULL == value);
- Property::Map programMap;
- programMap[ "vertex-filename" ] = "bump.vert";
- programMap[ "fragment-filename" ] = "bump.frag";
+ value = GetEnumerationName(10, NULL, 1);
+ DALI_TEST_CHECK(NULL == value);
- Property::Map imageMap;
- imageMap[ "filename" ] = "image.png";
+ END_TEST;
+}
- Property::Map map;
- map[ "image" ] = imageMap;
- map[ "program" ] = programMap;
- map[ "uLightPosition" ] = Vector3( 0.0, 0.0, -1.5);
- map[ "uAmbientLight" ] = (int)10;
+int UtcDaliScriptingGetLinearEnumerationNameN(void)
+{
+ const char* value = GetLinearEnumerationName(10, NULL, 0);
+ DALI_TEST_CHECK(NULL == value);
- ShaderEffect shader = NewShaderEffect( map );
+ value = GetLinearEnumerationName(10, NULL, 1);
+ DALI_TEST_CHECK(NULL == value);
- DALI_TEST_CHECK( shader );
END_TEST;
}
-int UtcDaliScriptingNewActorNegative(void)
+int UtcDaliScriptingGetEnumerationProperty(void)
{
- TestApplication application;
+ /*
+ * This test function performs the following checks:
+ * - An enum can be looked up from a Property::Value of type INTEGER.
+ * - An enum can be looked up from a Property::Value of type STRING.
+ * - An enum can NOT be looked up for other Property::Value types.
+ * - The return value is "true" if the property can be successfully converted AND it has changed.
+ * - The return value is "false" if the property can be successfully converted BUT it has NOT changed.
+ * - The return value is "false" if the property can not be successfully converted.
+ * - The result value is only updated if the return value is "true" (IE. successful conversion and property value has changed).
+ */
- // Empty map
- {
- Actor handle = NewActor( Property::Map() );
- DALI_TEST_CHECK( !handle );
- }
+ // String to Enum property table to test with (equivalent to ones used within DALi).
+ const Dali::Scripting::StringEnum testTable[] = {
+ {"NONE", FaceCullingMode::NONE},
+ {"FRONT", FaceCullingMode::FRONT},
+ {"BACK", FaceCullingMode::BACK},
+ {"FRONT_AND_BACK", FaceCullingMode::FRONT_AND_BACK}};
+ const unsigned int testTableCount = sizeof(testTable) / sizeof(testTable[0]);
- // Map with only properties
- {
- Property::Map map;
- map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
- map[ "anchor-point" ] = AnchorPoint::TOP_CENTER;
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( !handle );
- }
+ // TEST: An enum can be looked up from a Property::Value of type INTEGER.
+ // Initialise to first element.
+ FaceCullingMode::Type result = FaceCullingMode::NONE;
+ // Set the input property value to a different value (to emulate a change).
+ Property::Value propertyValueInteger(FaceCullingMode::FRONT);
- // Add some signals to the map, we should have no signal connections as its not yet supported
- {
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "signals" ] = Property::MAP;
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
- DALI_TEST_CHECK( !handle.MouseWheelEventSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
- }
- END_TEST;
-}
+ // Perform the lookup.
+ bool returnValue = GetEnumerationProperty<FaceCullingMode::Type>(propertyValueInteger, testTable, testTableCount, result);
-int UtcDaliScriptingNewActorProperties(void)
-{
- TestApplication application;
+ // TEST: The return value is "true" if the property can be successfully converted AND it has changed
+ // Check the property could be converted.
+ DALI_TEST_CHECK(returnValue);
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "size" ] = Vector3::ONE;
- map[ "position" ] = Vector3::XAXIS;
- map[ "scale" ] = Vector3::ONE;
- map[ "visible" ] = false;
- map[ "color" ] = Color::MAGENTA;
- map[ "name" ] = "MyActor";
- map[ "color-mode" ] = "USE_PARENT_COLOR";
- map[ "inherit-shader-effect" ] = false;
- map[ "sensitive" ] = false;
- map[ "leave-required" ] = true;
- map[ "position-inheritance" ] = "DONT_INHERIT_POSITION";
- map[ "draw-mode" ] = "STENCIL";
- map[ "inherit-rotation" ] = false;
- map[ "inherit-scale" ] = false;
+ DALI_TEST_EQUALS(static_cast<int>(result), static_cast<int>(FaceCullingMode::FRONT), TEST_LOCATION);
- // Default properties
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
+ // Now emulate a property-set with the same value. false should be returned.
+ returnValue = GetEnumerationProperty<FaceCullingMode::Type>(propertyValueInteger, testTable, testTableCount, result);
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
+ // TEST: The return value is "false" if the property can be successfully converted BUT it has NOT changed.
+ DALI_TEST_CHECK(!returnValue);
- DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION );
- 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::STENCIL, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsRotationInherited(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- }
+ // The result should remain the same.
+ DALI_TEST_EQUALS(static_cast<int>(result), static_cast<int>(FaceCullingMode::FRONT), TEST_LOCATION);
- // Check Anchor point and parent origin vector3s
- map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
- map[ "anchor-point" ] = AnchorPoint::TOP_LEFT;
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
+ // TEST: An enum can be looked up from a Property::Value of type STRING.
+ // Set the input property value to a different value (to emulate a change).
+ Property::Value propertyValueString("BACK");
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
+ returnValue = GetEnumerationProperty<FaceCullingMode::Type>(propertyValueString, testTable, testTableCount, result);
- DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION );
+ DALI_TEST_CHECK(returnValue);
- Stage::GetCurrent().Remove( handle );
- }
+ // The result should remain the same.
+ DALI_TEST_EQUALS(static_cast<int>(result), static_cast<int>(FaceCullingMode::BACK), TEST_LOCATION);
- // Check Anchor point and parent origin STRINGS
- map[ "parent-origin" ] = "TOP_LEFT";
- map[ "anchor-point" ] = "CENTER_LEFT";
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
+ returnValue = GetEnumerationProperty<FaceCullingMode::Type>(propertyValueString, testTable, testTableCount, result);
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
+ DALI_TEST_CHECK(!returnValue);
- DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
+ // The result should remain the same.
+ DALI_TEST_EQUALS(static_cast<int>(result), static_cast<int>(FaceCullingMode::BACK), TEST_LOCATION);
- Stage::GetCurrent().Remove( handle );
- }
- END_TEST;
-}
+ // TEST: An enum can NOT be looked up for other Property::Value types.
+ Property::Value propertyValueBoolean(true);
-int UtcDaliScriptingNewActorChildren(void)
-{
- TestApplication application;
+ returnValue = GetEnumerationProperty<FaceCullingMode::Type>(propertyValueBoolean, testTable, testTableCount, result);
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "position" ] = Vector3::XAXIS;
+ // TEST: The return value is "false" if the property can not be successfully converted.
+ // Return value should be false as Property::Value was of an unsupported type for enum properties.
+ DALI_TEST_CHECK(!returnValue);
- Property::Map child1Map;
- child1Map[ "type" ] = "ImageActor";
- child1Map[ "position" ] = Vector3::YAXIS;
+ // TEST: The result value is only updated if the return value is "true" (IE. successful conversion and property value has changed).
+ // The result should remain the same.
+ DALI_TEST_EQUALS(static_cast<int>(result), static_cast<int>(FaceCullingMode::BACK), TEST_LOCATION);
- Property::Map child2Map;
- child2Map[ "type" ] = "TextActor";
- child2Map[ "position" ] = Vector3::ZAXIS;
+ END_TEST;
+}
- Property::Array childArray;
- childArray.push_back( child1Map );
- childArray.push_back( child2Map );
- map[ "actors" ] = childArray;
+int UtcDaliScriptingGetBitmaskEnumerationProperty(void)
+{
+ /*
+ * This test function performs the following checks:
+ * - An enum can be looked up from a Property::Value of type INTEGER.
+ * - An enum can be looked up from a Property::Value of type STRING.
+ * - An enum can NOT be looked up from other Property::Value types.
+ * - The return value is "true" if the property can be successfully converted AND it has changed.
+ * - The return value is "false" if the property can not be successfully converted.
+ * - The result value is only updated if the return value is "true" (IE. successful conversion and property value has changed).
+ * PropertyArrays:
+ * - The return value when checking an array with 2 INTEGERS is "true" if the properties can be successfully converted.
+ * - The result value when checking an array with 2 INTEGERS is the ORd value of the 2 integers.
+ * - The return value when checking an array with 2 STRINGS is "true" if the properties can be successfully converted.
+ * - The result value when checking an array with 2 STRINGS is the ORd value of the 2 integer equivalents of the strings.
+ * - The return value when checking an array with an INTEGER and a STRING is "true" if the properties can be successfully converted.
+ * - The result value when checking an array with an INTEGER and a STRING is the ORd value of the 2 integer equivalents of the strings.
+ * - The return value when checking an array with an INTEGER and a Vector3 is "false" as the properties can not be successfully converted.
+ * - The result value when checking an array with an INTEGER and a Vector3 is unchanged.
+ */
+
+ // String to Enum property table to test with (equivalent to ones used within DALi).
+ const Dali::Scripting::StringEnum testTable[] = {
+ {"NONE", FaceCullingMode::NONE},
+ {"FRONT", FaceCullingMode::FRONT},
+ {"BACK", FaceCullingMode::BACK},
+ {"FRONT_AND_BACK", FaceCullingMode::FRONT_AND_BACK}};
+ const unsigned int testTableCount = sizeof(testTable) / sizeof(testTable[0]);
+
+ // TEST: An enum can be looked up from a Property::Value of type INTEGER.
+ // Initialise to first element.
+ FaceCullingMode::Type result = FaceCullingMode::NONE;
+ // Set the input property value to a different value (to emulate a change).
+ Property::Value propertyValueInteger(FaceCullingMode::FRONT);
+
+ // Perform the lookup.
+ bool returnValue = GetBitmaskEnumerationProperty<FaceCullingMode::Type>(propertyValueInteger, testTable, testTableCount, result);
+
+ // TEST: The return value is "true" if the property can be successfully converted AND it has changed
+ // Check the property could be converted.
+ DALI_TEST_CHECK(returnValue);
+
+ DALI_TEST_EQUALS(static_cast<int>(result), static_cast<int>(FaceCullingMode::FRONT), TEST_LOCATION);
+
+ // TEST: An enum can be looked up from a Property::Value of type STRING.
+ // Set the input property value to a different value (to emulate a change).
+ Property::Value propertyValueString("BACK");
+
+ returnValue = GetBitmaskEnumerationProperty<FaceCullingMode::Type>(propertyValueString, testTable, testTableCount, result);
+
+ DALI_TEST_CHECK(returnValue);
+
+ DALI_TEST_EQUALS(static_cast<int>(result), static_cast<int>(FaceCullingMode::BACK), TEST_LOCATION);
+
+ // TEST: An enum can NOT be looked up from other Property::Value types.
+ Property::Value propertyValueVector(Vector3::ZERO);
+
+ returnValue = GetBitmaskEnumerationProperty<FaceCullingMode::Type>(propertyValueVector, testTable, testTableCount, result);
+
+ // TEST: The return value is "false" if the property can not be successfully converted.
+ // Return value should be false as Property::Value was of an unsupported type for enum properties.
+ DALI_TEST_CHECK(!returnValue);
+
+ // TEST: The result value is only updated if the return value is "true" (IE. successful conversion and property value has changed).
+ // The result should remain the same.
+ DALI_TEST_EQUALS(static_cast<int>(result), static_cast<int>(FaceCullingMode::BACK), TEST_LOCATION);
+
+ // Test PropertyArrays:
+
+ // Property array of 2 integers.
+ Property::Array propertyArrayIntegers;
+ propertyArrayIntegers.PushBack(FaceCullingMode::FRONT);
+ propertyArrayIntegers.PushBack(FaceCullingMode::BACK);
+ result = FaceCullingMode::NONE;
+
+ returnValue = GetBitmaskEnumerationProperty<FaceCullingMode::Type>(propertyArrayIntegers, testTable, testTableCount, result);
+
+ // TEST: The return value when checking an array with 2 INTEGERS is "true" if the properties can be successfully converted.
+ DALI_TEST_CHECK(returnValue);
+ // TEST: The result value when checking an array with 2 INTEGERS is the ORd value of the 2 integers.
+ DALI_TEST_CHECK(result == (FaceCullingMode::FRONT | FaceCullingMode::BACK));
+
+ // Property array of 2 strings.
+ Property::Array propertyArrayStrings;
+ propertyArrayStrings.PushBack("FRONT");
+ propertyArrayStrings.PushBack("BACK");
+ result = FaceCullingMode::NONE;
+
+ returnValue = GetBitmaskEnumerationProperty<FaceCullingMode::Type>(propertyArrayStrings, testTable, testTableCount, result);
+
+ // TEST: The return value when checking an array with 2 STRINGS is "true" if the properties can be successfully converted.
+ DALI_TEST_CHECK(returnValue);
+ // TEST: The result value when checking an array with 2 STRINGS is the ORd value of the 2 integer equivalents of the strings.
+ DALI_TEST_CHECK(result == (FaceCullingMode::FRONT | FaceCullingMode::BACK));
+
+ // Property array of an int and a string.
+ Property::Array propertyArrayMixed;
+ propertyArrayMixed.PushBack(FaceCullingMode::FRONT);
+ propertyArrayMixed.PushBack("BACK");
+ result = FaceCullingMode::NONE;
+
+ returnValue = GetBitmaskEnumerationProperty<FaceCullingMode::Type>(propertyArrayMixed, testTable, testTableCount, result);
+
+ // TEST: The return value when checking an array with an INTEGER and a STRING is "true" if the properties can be successfully converted.
+ DALI_TEST_CHECK(returnValue);
+ // TEST: The result value when checking an array with an INTEGER and a STRING is the ORd value of the 2 integer equivalents of the strings.
+ DALI_TEST_CHECK(result == (FaceCullingMode::FRONT | FaceCullingMode::BACK));
+
+ // Property array of an int and a string.
+ Property::Array propertyArrayInvalid;
+ propertyArrayInvalid.PushBack(FaceCullingMode::FRONT);
+ propertyArrayInvalid.PushBack(Vector3::ZERO);
- // Create
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
+ // Set the initial value to non-zero, so we can test it does not change.
+ result = FaceCullingMode::FRONT_AND_BACK;
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
+ returnValue = GetBitmaskEnumerationProperty<FaceCullingMode::Type>(propertyArrayInvalid, testTable, testTableCount, result);
- DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetChildCount(), 2u, TEST_LOCATION );
+ // TEST: The return value when checking an array with an INTEGER and a Vector3 is "false" as the properties can not be successfully converted.
+ DALI_TEST_CHECK(!returnValue);
+ // TEST: The result value when checking an array with an INTEGER and a Vector3 is unchanged.
+ DALI_TEST_CHECK(result == FaceCullingMode::FRONT_AND_BACK);
- Actor child1 = handle.GetChildAt(0);
- DALI_TEST_CHECK( child1 );
- DALI_TEST_CHECK( ImageActor::DownCast( child1 ) );
- DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION );
-
- Actor child2 = handle.GetChildAt(1);
- DALI_TEST_CHECK( child2 );
- DALI_TEST_CHECK( TextActor::DownCast( child2 ) );
- DALI_TEST_EQUALS( child2.GetCurrentPosition(), Vector3::ZAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( child2.GetChildCount(), 0u, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
END_TEST;
}
-
-int UtcDaliScriptingCreatePropertyMapActor(void)
+int UtcDaliScriptingFindEnumIndexN(void)
{
- TestApplication application;
-
- // Actor Type
- {
- Actor actor = Actor::New();
+ const Scripting::StringEnum myTable[] =
+ {
+ {"ONE", (1 << 1)},
+ {"TWO", (1 << 2)},
+ {"THREE", (1 << 3)},
+ {"FOUR", (1 << 4)},
+ {"FIVE", (1 << 5)},
+ };
+ const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]);
+ DALI_TEST_EQUALS(myTableCount, FindEnumIndex("Foo", myTable, myTableCount), TEST_LOCATION);
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "Actor", TEST_LOCATION );
+ END_TEST;
+}
- Stage::GetCurrent().Remove( actor );
- }
+int UtcDaliScriptingEnumStringToIntegerP(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ {"ONE", (1 << 1)},
+ {"TWO", (1 << 2)},
+ {"THREE", (1 << 3)},
+ {"FOUR", (1 << 4)},
+ {"FIVE", (1 << 5)},
+ };
+ const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]);
- // ImageActor Type
- {
- Actor actor = ImageActor::New();
+ int integerEnum = 0;
+ DALI_TEST_CHECK(EnumStringToInteger("ONE", myTable, myTableCount, integerEnum));
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "ImageActor", TEST_LOCATION );
+ DALI_TEST_EQUALS(integerEnum, (1 << 1), TEST_LOCATION);
- Stage::GetCurrent().Remove( actor );
- }
+ integerEnum = 0;
+ DALI_TEST_CHECK(EnumStringToInteger("ONE,TWO", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2), TEST_LOCATION);
- // Default properties
- {
- Actor actor = Actor::New();
- actor.SetSize( Vector3::ONE );
- actor.SetPosition( Vector3::XAXIS );
- actor.SetScale( Vector3::ZAXIS );
- actor.SetVisible( false );
- actor.SetColor( Color::MAGENTA );
- actor.SetName( "MyActor" );
- actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- actor.SetParentOrigin( ParentOrigin::TOP_RIGHT );
- actor.SetSensitive( false );
- actor.SetLeaveRequired( true );
- actor.SetInheritRotation( false );
- actor.SetInheritScale( false );
- actor.SetSizeMode( USE_OWN_SIZE );
- actor.SetSizeModeFactor( Vector3::ONE );
-
- Stage::GetCurrent().Add( actor );
- application.SendNotification();
- application.Render();
+ DALI_TEST_CHECK(EnumStringToInteger("ONE,,TWO", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2), TEST_LOCATION);
- Property::Map map;
- CreatePropertyMap( actor, map );
-
- DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "size" ) );
- DALI_TEST_EQUALS( value.GetValue( "size" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "position" ) );
- DALI_TEST_EQUALS( value.GetValue( "position" ).Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "scale" ) );
- DALI_TEST_EQUALS( value.GetValue( "scale" ).Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "visible" ) );
- DALI_TEST_EQUALS( value.GetValue( "visible" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "color" ) );
- DALI_TEST_EQUALS( value.GetValue( "color" ).Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "name" ) );
- DALI_TEST_EQUALS( value.GetValue( "name").Get< std::string >(), "MyActor", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "anchor-point" ) );
- DALI_TEST_EQUALS( value.GetValue( "anchor-point" ).Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "parent-origin" ) );
- DALI_TEST_EQUALS( value.GetValue( "parent-origin" ).Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "sensitive" ) );
- DALI_TEST_EQUALS( value.GetValue( "sensitive" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "leave-required" ) );
- DALI_TEST_EQUALS( value.GetValue( "leave-required" ).Get< bool >(), true, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "inherit-rotation" ) );
- DALI_TEST_EQUALS( value.GetValue( "inherit-rotation" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "inherit-scale" ) );
- DALI_TEST_EQUALS( value.GetValue( "inherit-scale" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "size-mode-factor" ) );
- DALI_TEST_EQUALS( value.GetValue( "size-mode-factor" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
+ DALI_TEST_CHECK(EnumStringToInteger("ONE,TWO,THREE", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2) | (1 << 3), TEST_LOCATION);
- // ColorMode
- TestEnumStrings< ColorMode >( "color-mode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
+ DALI_TEST_CHECK(EnumStringToInteger("ONE,TWO,THREE,FOUR,FIVE", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5), TEST_LOCATION);
- // PositionInheritanceMode
- TestEnumStrings< PositionInheritanceMode >( "position-inheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
+ DALI_TEST_CHECK(EnumStringToInteger("TWO,ONE", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2), TEST_LOCATION);
- // DrawMode
- TestEnumStrings< DrawMode::Type >( "draw-mode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
+ DALI_TEST_CHECK(EnumStringToInteger("TWO,ONE,FOUR,THREE,FIVE", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5), TEST_LOCATION);
- // Children
- {
- Actor actor = Actor::New();
- Actor child = ImageActor::New();
- actor.Add( child );
+ DALI_TEST_CHECK(EnumStringToInteger("ONE,SEVEN", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, (1 << 1), TEST_LOCATION);
- Stage::GetCurrent().Add( actor );
- application.SendNotification();
- application.Render();
+ DALI_TEST_CHECK(EnumStringToInteger("ONE,", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, (1 << 1), TEST_LOCATION);
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Actor", TEST_LOCATION );
-
- DALI_TEST_CHECK( value.HasKey( "actors" ) );
- Property::Array children( value.GetValue( "actors").Get< Property::Array >() );
- DALI_TEST_CHECK( !children.empty() );
- Property::Map childMap( children[0].Get< Property::Map >() );
- DALI_TEST_CHECK( !childMap.Empty() );
- Property::Value childValue( childMap );
- DALI_TEST_CHECK( childValue.HasKey( "type" ) );
- DALI_TEST_EQUALS( childValue.GetValue( "type" ).Get< std::string >(), "ImageActor", TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
END_TEST;
}
-int UtcDaliScriptingCreatePropertyMapImage(void)
+int UtcDaliScriptingEnumStringToIntegerN(void)
{
- TestApplication application;
+ const Scripting::StringEnum myTable[] =
+ {
+ {"ONE", 1},
+ {"TWO", 2},
+ {"THREE", 3},
+ {"FOUR", 4},
+ {"FIVE", 5},
+ };
+ const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]);
- // Empty
- {
- Image image;
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( map.Empty() );
- }
+ int integerEnum = 0;
+ DALI_TEST_CHECK(!EnumStringToInteger("Foo", myTable, myTableCount, integerEnum));
- // Default
- {
- Image image = ResourceImage::New( "MY_PATH" );
+ DALI_TEST_CHECK(!EnumStringToInteger("", myTable, myTableCount, integerEnum));
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "filename" ) );
- DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "load-policy") );
- DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "release-policy") );
- DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "NEVER", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "scaling-mode") );
- DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "SHRINK_TO_FIT", TEST_LOCATION );
- DALI_TEST_CHECK( !value.HasKey( "width" ) );
- DALI_TEST_CHECK( !value.HasKey( "height" ) );
- }
+ DALI_TEST_CHECK(!EnumStringToInteger(",", myTable, myTableCount, integerEnum));
- // Change values
- {
- ImageAttributes attributes;
- attributes.SetScalingMode( ImageAttributes::FitWidth );
- attributes.SetSize( 300, 400 );
- Image image = ResourceImage::New( "MY_PATH", attributes, ResourceImage::ON_DEMAND, Image::UNUSED );
+ DALI_TEST_CHECK(!EnumStringToInteger(",ONE,SEVEN", myTable, myTableCount, integerEnum));
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "filename" ) );
- DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "load-policy") );
- DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "release-policy") );
- DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "UNUSED", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "scaling-mode") );
- DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "FIT_WIDTH", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "width" ) );
- DALI_TEST_EQUALS( value.GetValue( "width" ).Get< int >(), 300, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "height" ) );
- DALI_TEST_EQUALS( value.GetValue( "height" ).Get< int >(), 400, TEST_LOCATION );
- }
+ DALI_TEST_CHECK(!EnumStringToInteger(",", myTable, myTableCount, integerEnum));
- // BufferImage
- {
- Image image = BufferImage::New( 200, 300, Pixel::A8 );
- Property::Map map;
- CreatePropertyMap( image, map );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BufferImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "pixel-format") );
- DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION );
- }
+ DALI_TEST_CHECK(!EnumStringToInteger("ONE", myTable, 0, integerEnum));
+
+ DALI_TEST_EQUALS(integerEnum, 0, TEST_LOCATION);
- // FrameBufferImage
- {
- Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
- Property::Map map;
- CreatePropertyMap( image, map );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
- }
END_TEST;
}
-int UtcDaliScriptingGetEnumerationTemplates(void)
+int UtcDaliScriptingEnumStringToIntegerInvalidEnumP(void)
{
- TestApplication application;
+ const Scripting::StringEnum myTable[] =
+ {
+ {"", 1},
+ {"", 2},
+ {"", 3},
+ };
- const Scripting::StringEnum< int > myTable[] =
- {
- { "ONE", 1 },
- { "TWO", 2 },
- { "THREE", 3 },
- { "FOUR", 4 },
- { "FIVE", 5 },
- };
- const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+ const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]);
- for ( unsigned int i = 0; i < myTableCount; ++i )
- {
- tet_printf("Checking: %s\n", myTable[ i ].string );
- DALI_TEST_EQUALS( myTable[ i ].value, GetEnumeration( myTable[ i ].string, myTable, myTableCount ), TEST_LOCATION );
- }
-
- for ( unsigned int i = 0; i < myTableCount; ++i )
- {
- tet_printf("Checking: %d\n", myTable[ i ].value );
- DALI_TEST_EQUALS( myTable[ i ].string, GetEnumerationName( myTable[ i ].value, myTable, myTableCount ), TEST_LOCATION );
- }
+ int integerEnum = 0;
+ DALI_TEST_CHECK(EnumStringToInteger("", myTable, myTableCount, integerEnum));
+ DALI_TEST_EQUALS(integerEnum, 1, TEST_LOCATION);
END_TEST;
}
-int UtcDaliScriptingCompareEnums(void)
+int UtcDaliScriptingEnumStringToIntegerInvalidEnumN(void)
{
- // EQUAL
- DALI_TEST_CHECK( CompareEnums( "", "" ) );
- DALI_TEST_CHECK( CompareEnums( "HELLO", "HELLO" ) );
- DALI_TEST_CHECK( CompareEnums( "HELLO", "hello" ) );
- DALI_TEST_CHECK( CompareEnums( "hello", "HELLO" ) );
- DALI_TEST_CHECK( CompareEnums( "hello-world", "HELLO_WORLD" ) );
- DALI_TEST_CHECK( CompareEnums( "hello_WORLD", "HELLO-world" ) );
- DALI_TEST_CHECK( CompareEnums( "hello_WORLD-", "HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "_hello_WORLD-", "-HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "-hello_WORLD-", "_HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "hello123", "HELLO123" ) );
-
- // NOT EQUAL
- DALI_TEST_CHECK( ! CompareEnums( "hello", "HELLOWORLD" ) );
+ const Scripting::StringEnum myTable[] =
+ {
+ {"", 1},
+ {"", 1},
+ {"", 1},
+ };
+
+ const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]);
+
+ int integerEnum = 0;
+ DALI_TEST_CHECK(!EnumStringToInteger(NULL, NULL, 0, integerEnum));
+
+ DALI_TEST_CHECK(!EnumStringToInteger("ONE", NULL, 0, integerEnum));
+
+ DALI_TEST_CHECK(!EnumStringToInteger(NULL, myTable, 0, integerEnum));
+
+ DALI_TEST_CHECK(!EnumStringToInteger(NULL, myTable, myTableCount, integerEnum));
+
+ DALI_TEST_CHECK(!EnumStringToInteger("ONE", NULL, myTableCount, integerEnum));
+
+ DALI_TEST_EQUALS(integerEnum, 0, TEST_LOCATION);
END_TEST;
}