/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
const StringEnum DRAW_MODE_VALUES[] =
{
{ "NORMAL", DrawMode::NORMAL },
- { "OVERLAY_2D", DrawMode::OVERLAY_2D },
- { "STENCIL", DrawMode::STENCIL },
+ { "OVERLAY_2D", DrawMode::OVERLAY_2D }
};
const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
}
}
-/// 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 ) );
END_TEST;
}
-int UtcDaliScriptingNewImageNegative02(void)
-{
- TestApplication application; // Image needs application
- // Invalid load-policy value type
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "loadPolicy" ] = Vector3::ZERO;
- // will give us a valid image handle with default load policy
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetLoadPolicy(), ResourceImage::IMMEDIATE, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative03(void)
-{
- TestApplication application; // Image needs application
- // Invalid load-policy value
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "loadPolicy" ] = "INVALID";
- // will give us a valid image with default load policy
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetLoadPolicy(), ResourceImage::IMMEDIATE, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative04(void)
-{
- TestApplication application; // Image needs application
- // Invalid release-policy value type
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "releasePolicy" ] = Vector3::ZERO;
- // will give us a valid image with default release policy
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative05(void)
-{
- TestApplication application; // Image needs application
- // Invalid release-policy value
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "releasePolicy" ] = "INVALID";
- // will give us a valid image with default release policy
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
- END_TEST;
-}
-
int UtcDaliScriptingNewImageNegative06(void)
{
TestApplication application; // Image needs application
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 );
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 );
END_TEST;
}
-int UtcDaliScriptingNewImage02P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // load-policy
- map[ "loadPolicy" ] = "";
- const StringEnum values[] =
- {
- { "IMMEDIATE", ResourceImage::IMMEDIATE },
- { "ON_DEMAND", ResourceImage::ON_DEMAND }
- };
- TestEnumStrings< ResourceImage::LoadPolicy, ResourceImage >( map, "loadPolicy", values, ( sizeof( values ) / sizeof ( values[0] ) ), &ResourceImage::GetLoadPolicy, &NewResourceImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage03P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // release-policy
- map[ "releasePolicy" ] = "";
- const StringEnum values[] =
- {
- { "UNUSED", Image::UNUSED },
- { "NEVER", Image::NEVER }
- };
- TestEnumStrings< Image::ReleasePolicy, Image >( map, "releasePolicy", values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
- END_TEST;
-}
-
int UtcDaliScriptingNewImage04P(void)
{
TestApplication application;
// 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 );
// 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 );
map[ "sensitive" ] = false;
map[ "leaveRequired" ] = true;
map[ "positionInheritance" ] = "DONT_INHERIT_POSITION";
- map[ "drawMode" ] = "STENCIL";
+ map[ "drawMode" ] = "OVERLAY_2D";
map[ "inheritOrientation" ] = false;
map[ "inheritScale" ] = false;
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.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
DALI_TEST_EQUALS( handle.IsOrientationInherited(), false, TEST_LOCATION );
DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );
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;
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( "loadPolicy") );
- DALI_TEST_EQUALS( map.Find( "loadPolicy" )->Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "releasePolicy") );
- DALI_TEST_EQUALS( map.Find( "releasePolicy" )->Get< std::string >(), "NEVER", TEST_LOCATION );
DALI_TEST_CHECK( NULL == map.Find( "width" ) );
DALI_TEST_CHECK( NULL == map.Find( "height" ) );
}
// Change values
{
- ResourceImage image = ResourceImage::New( "MY_PATH", ResourceImage::ON_DEMAND, Image::UNUSED, ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
+ 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_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( "loadPolicy") );
- DALI_TEST_EQUALS( map.Find( "loadPolicy" )->Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "releasePolicy") );
- DALI_TEST_EQUALS( map.Find( "releasePolicy" )->Get< std::string >(), "UNUSED", 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" ) );
END_TEST;
}
+int UtcDaliScriptingGetEnumerationProperty(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 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).
+ */
+
+ // 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 = GetEnumerationProperty< 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 );
+
+ // Now emulate a property-set with the same value. false should be returned.
+ returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueInteger, testTable, testTableCount, result );
+
+ // TEST: The return value is "false" if the property can be successfully converted BUT it has NOT changed.
+ DALI_TEST_CHECK( !returnValue );
+
+ // The result should remain the same.
+ 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 = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueString, testTable, testTableCount, result );
+
+ DALI_TEST_CHECK( returnValue );
+
+ // The result should remain the same.
+ DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::BACK ), TEST_LOCATION );
+
+ returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueString, testTable, testTableCount, result );
+
+ DALI_TEST_CHECK( !returnValue );
+
+ // The result should remain the same.
+ DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::BACK ), TEST_LOCATION );
+
+ // TEST: An enum can NOT be looked up for other Property::Value types.
+ Property::Value propertyValueBoolean( true );
+
+ returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueBoolean, 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 );
+
+ END_TEST;
+}
+
+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 );
+
+ // Set the initial value to non-zero, so we can test it does not change.
+ result = FaceCullingMode::FRONT_AND_BACK;
+
+ returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyArrayInvalid, testTable, testTableCount, result );
+
+ // 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 );
+
+ END_TEST;
+}
+
int UtcDaliScriptingFindEnumIndexN(void)
{
const Scripting::StringEnum myTable[] =
};
const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
- unsigned int integerEnum = 0;
+ int integerEnum = 0;
DALI_TEST_CHECK( EnumStringToInteger( "ONE", myTable, myTableCount, integerEnum ) );
DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
};
const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
- unsigned int integerEnum = 0;
+ int integerEnum = 0;
DALI_TEST_CHECK( !EnumStringToInteger( "Foo", myTable, myTableCount, integerEnum ) );
DALI_TEST_CHECK( !EnumStringToInteger( "", myTable, myTableCount, integerEnum ) );
const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
- unsigned int integerEnum = 0;
+ int integerEnum = 0;
DALI_TEST_CHECK( EnumStringToInteger( "", myTable, myTableCount, integerEnum ) );
DALI_TEST_EQUALS( integerEnum, 1, TEST_LOCATION );
const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
- unsigned int integerEnum = 0;
+ int integerEnum = 0;
DALI_TEST_CHECK( !EnumStringToInteger( NULL, NULL, 0, integerEnum ) );
DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, 0, integerEnum ) );