X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Scripting.cpp;h=39cbb194b0602acfe85e095023c5a537aa6e6438;hb=e97ce3673ceda34d252bb13a320a7947a552c1ac;hp=c0208b7f5d5807f6fa40a258b27307a03b6fb50a;hpb=41c2c3ebf3e03604f4194fdbf16eb4f6297a3a7e;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Scripting.cpp b/automated-tests/src/dali/utc-Dali-Scripting.cpp index c0208b7..39cbb19 100644 --- a/automated-tests/src/dali/utc-Dali-Scripting.cpp +++ b/automated-tests/src/dali/utc-Dali-Scripting.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -37,20 +37,10 @@ const StringEnum COLOR_MODE_VALUES[] = }; const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] ); -const StringEnum POSITION_INHERITANCE_MODE_VALUES[] = -{ - { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION }, - { "USE_PARENT_POSITION", USE_PARENT_POSITION }, - { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION }, - { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION }, -}; -const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] ); - const StringEnum DRAW_MODE_VALUES[] = { { "NORMAL", DrawMode::NORMAL }, - { "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] ); @@ -83,14 +73,7 @@ void TestEnumStrings( } } -/// Helper method to create ResourceImage using property -ResourceImage NewResourceImage( const Property::Value& map ) -{ - ResourceImage image = ResourceImage::DownCast( NewImage( map ) ); - return image; -} - -/// Helper method to create ResourceImage using property +/// Helper method to create BufferImage using property BufferImage NewBufferImage( const Property::Value& map ) { BufferImage image = BufferImage::DownCast( NewImage( map ) ); @@ -140,6 +123,24 @@ void TestEnumStrings( } // 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::V1 ); + DALI_TEST_CHECK( v2.Get() == T::V2 ); + DALI_TEST_CHECK( v1.Get(t) && t == T::V1 ); + DALI_TEST_CHECK( v2.Get(t) && t == T::V2 ); + + END_TEST; +} + int UtcDaliScriptingNewImageNegative01(void) { // Invalid filename @@ -160,6 +161,7 @@ int UtcDaliScriptingNewImageNegative06(void) map[ "width" ] = "Invalid"; map[ "height" ] = 100; // will give us a valid image + PrepareResourceImage( application, 0u, 100u, Pixel::RGBA8888 ); Image image = NewImage( map ); DALI_TEST_CHECK( image ); ResourceImage resImage = ResourceImage::DownCast( image ); @@ -178,6 +180,7 @@ int UtcDaliScriptingNewImageNegative07(void) map[ "width" ] = 10; map[ "height" ] = "Invalid"; // will give us a valid image + PrepareResourceImage( application, 10u, 0u, Pixel::RGBA8888 ); Image image = NewImage( map ); DALI_TEST_CHECK( image ); ResourceImage resImage = ResourceImage::DownCast( image ); @@ -315,6 +318,7 @@ int UtcDaliScriptingNewImage04P(void) // float width and height map[ "width" ] = (float) 10.0f; map[ "height" ] = (float) 20.0f; + PrepareResourceImage( application, 10u, 20u, Pixel::RGBA8888 ); Image image = NewImage( map ); DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION ); DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION ); @@ -331,6 +335,7 @@ int UtcDaliScriptingNewImage05P(void) // width and height map[ "width"] = 50; map[ "height" ] = 70; + PrepareResourceImage( application, 50u, 70u, Pixel::RGBA8888 ); Image image = NewImage( map ); DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION ); DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION ); @@ -483,8 +488,7 @@ int UtcDaliScriptingNewActorProperties(void) map[ "colorMode" ] = "USE_PARENT_COLOR"; map[ "sensitive" ] = false; map[ "leaveRequired" ] = true; - map[ "positionInheritance" ] = "DONT_INHERIT_POSITION"; - map[ "drawMode" ] = "STENCIL"; + map[ "drawMode" ] = "OVERLAY_2D"; map[ "inheritOrientation" ] = false; map[ "inheritScale" ] = false; @@ -497,19 +501,18 @@ int UtcDaliScriptingNewActorProperties(void) application.SendNotification(); application.Render(); - 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.IsOrientationInherited(), false, TEST_LOCATION ); - DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION ); + 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 ); Stage::GetCurrent().Remove( handle ); } @@ -525,8 +528,8 @@ int UtcDaliScriptingNewActorProperties(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION ); - DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION ); + 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 ); } @@ -542,14 +545,54 @@ int UtcDaliScriptingNewActorProperties(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION ); - DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::CENTER_LEFT, TEST_LOCATION ); + 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 ); } 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.SetProperty( Actor::Property::NAME,"Actor1"); + actor.SetProperty( Actor::Property::COLOR,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.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 ); + + END_TEST; +} + int UtcDaliScriptingNewActorChildren(void) { TestApplication application; @@ -559,7 +602,7 @@ int UtcDaliScriptingNewActorChildren(void) map[ "position" ] = Vector3::XAXIS; Property::Map child1Map; - child1Map[ "type" ] = "CameraActor"; + child1Map[ "type" ] = "Layer"; child1Map[ "position" ] = Vector3::YAXIS; Property::Array childArray; @@ -574,13 +617,13 @@ int UtcDaliScriptingNewActorChildren(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION ); + 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( CameraActor::DownCast( child1 ) ); - DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION ); + 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 ); Stage::GetCurrent().Remove( handle ); @@ -624,16 +667,16 @@ int UtcDaliScriptingCreatePropertyMapActor(void) 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.SetInheritOrientation( false ); - actor.SetInheritScale( false ); - actor.SetSizeModeFactor( Vector3::ONE ); + 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 ); Stage::GetCurrent().Add( actor ); application.SendNotification(); @@ -673,15 +716,6 @@ int UtcDaliScriptingCreatePropertyMapActor(void) Stage::GetCurrent().Remove( actor ); } - // ColorMode - TestEnumStrings< ColorMode >( "colorMode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode ); - - // PositionInheritanceMode - TestEnumStrings< PositionInheritanceMode >( "positionInheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode ); - - // DrawMode - TestEnumStrings< DrawMode::Type >( "drawMode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode ); - // Children { Actor actor = Actor::New(); @@ -742,7 +776,8 @@ int UtcDaliScriptingCreatePropertyMapImage(void) // 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 ); @@ -831,6 +866,211 @@ int UtcDaliScriptingGetLinearEnumerationNameN(void) 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( result ), static_cast( 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( result ), static_cast( 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( result ), static_cast( 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( result ), static_cast( 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( result ), static_cast( 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( result ), static_cast( 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( result ), static_cast( 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( result ), static_cast( 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[] = @@ -859,7 +1099,7 @@ int UtcDaliScriptingEnumStringToIntegerP(void) }; 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 ); @@ -905,7 +1145,7 @@ int UtcDaliScriptingEnumStringToIntegerN(void) }; 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 ) ); @@ -934,7 +1174,7 @@ int UtcDaliScriptingEnumStringToIntegerInvalidEnumP(void) 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 ); @@ -952,7 +1192,7 @@ int UtcDaliScriptingEnumStringToIntegerInvalidEnumN(void) 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 ) );