X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Scripting.cpp;h=3d543fa3d1a9c81afed4cdc792f5d51473214643;hb=fe58df83b2d72c4beceb101eb9cffcc5442f3d6e;hp=151b7700a41a55684af1ddfdfc755821623ae0fe;hpb=cf8382280ea70e3f56b4007d6e3ed4922fc6885a;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 151b770..3d543fa 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) 2016 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. @@ -15,44 +15,32 @@ * */ -#include - -#include -#include -#include #include +#include +#include +#include + +#include using namespace Dali; using namespace Dali::Scripting; namespace { - 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 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 }, + { + {"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 POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_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] ); - + { + {"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 Image loading parameters @@ -61,41 +49,27 @@ const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( /** * Template to check enumerations of type T, with a class of type X */ -template< typename T, typename X > +template void TestEnumStrings( - 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 + 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 ) { // get the key reference so we can change its value - Property::Value* value = map.Find( keyName ); - for ( unsigned int i = 0; i < num; ++i ) + Property::Value* value = map.Find(keyName); + for(unsigned int i = 0; i < num; ++i) { *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 ); + 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; -} - ////////////////////////////////////////////////////////////////////////////// // Helpers for string to enum comparisons for Actor to Property::Map ////////////////////////////////////////////////////////////////////////////// @@ -103,333 +77,59 @@ BufferImage NewBufferImage( const Property::Value& map ) /** * Template to check enumerations of type T */ -template< typename T > +template void TestEnumStrings( - 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 + 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( 0 < map.Count() ); - DALI_TEST_CHECK( NULL != map.Find( keyName ) ); - DALI_TEST_EQUALS( map.Find( 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(), values[i].string, TEST_LOCATION); - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove(actor); } } ////////////////////////////////////////////////////////////////////////////// +} // namespace -} // anon namespace - -int UtcDaliScriptingNewImageNegative01(void) -{ - // Invalid filename - Property::Map map; - map[ "filename" ] = Vector3::ZERO; - // will give us an empty image handle - Image image = NewImage( map ); - DALI_TEST_CHECK( !image ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative06(void) -{ - TestApplication application; // Image needs application - // Invalid width and height - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - map[ "width" ] = "Invalid"; - map[ "height" ] = 100; - // will give us a valid image - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - ResourceImage resImage = ResourceImage::DownCast( image ); - DALI_TEST_CHECK( resImage ); - DALI_TEST_EQUALS( resImage.GetWidth(), 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( resImage.GetHeight(), 100u, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative07(void) -{ - TestApplication application; // Image needs application - // Invalid height - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - map[ "width" ] = 10; - map[ "height" ] = "Invalid"; - // will give us a valid image - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - ResourceImage resImage = ResourceImage::DownCast( image ); - DALI_TEST_CHECK( resImage ); - DALI_TEST_EQUALS( resImage.GetWidth(), 10u, TEST_LOCATION ); - DALI_TEST_EQUALS( resImage.GetHeight(), 0u, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative08(void) -{ - TestApplication application; // Image needs application - // Invalid fitting-mode - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - map[ "fittingMode" ] = Vector3::ZERO; - // will give us a valid image - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - ResourceImage resImage = ResourceImage::DownCast( image ); - DALI_TEST_CHECK( resImage ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative09(void) -{ - TestApplication application; // Image needs application - // Invalid value - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - map[ "fittingMode" ] = "INVALID"; - // will give us a valid image - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - ResourceImage resImage = ResourceImage::DownCast( image ); - DALI_TEST_CHECK( resImage ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative10(void) -{ - TestApplication application; // Image needs application - // Invalid scaling-mode - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - map[ "samplingMode" ] = Vector3::ZERO; - // will give us a valid image - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - ResourceImage resImage = ResourceImage::DownCast( image ); - DALI_TEST_CHECK( resImage ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative12(void) -{ - TestApplication application; // Image needs application - // Invalid orientation-correction - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - map[ "orientation" ] = Vector3::ZERO; - // will give us a valid image - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - ResourceImage resImage = ResourceImage::DownCast( image ); - DALI_TEST_CHECK( resImage ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative13(void) -{ - TestApplication application; // Image needs application - // Invalid type - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - map[ "type" ] = Vector3::ZERO; - // will give us a valid image - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - ResourceImage resImage = ResourceImage::DownCast( image ); - DALI_TEST_CHECK( resImage ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative14(void) -{ - // Invalid value - Property::Map map; - map[ "type" ] = "INVALID"; - Image image = NewImage( map ); - DALI_TEST_CHECK( !image ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative15(void) -{ - // Invalid pixel-format - Property::Map map; - map[ "pixelFormat" ] = Vector3::ZERO; - Image image = NewImage( map ); - DALI_TEST_CHECK( !image ); - END_TEST; -} - -int UtcDaliScriptingNewImageNegative16(void) -{ - // Invalid value - Property::Map map; - map[ "pixelFormat" ] = "INVALID"; - Image image = NewImage( map ); - DALI_TEST_CHECK( !image ); - END_TEST; -} - -int UtcDaliScriptingNewImage01P(void) -{ - TestApplication application; // Image needs application - - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - - // Filename only - ResourceImage image = ResourceImage::DownCast( NewImage( map ) ); - DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION ); - END_TEST; -} - -int UtcDaliScriptingNewImage04P(void) -{ - TestApplication application; - - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - - // float width and height - map[ "width" ] = (float) 10.0f; - map[ "height" ] = (float) 20.0f; - Image image = NewImage( map ); - DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION ); - DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliScriptingNewImage05P(void) -{ - TestApplication application; - - Property::Map map; - map[ "filename" ] = "TEST_FILE"; - - // width and height - map[ "width"] = 50; - map[ "height" ] = 70; - Image image = NewImage( map ); - DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION ); - DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliScriptingNewImage06P(void) +int UtcDaliValueFromEnum(void) { - TestApplication application; - - Property::Map map; - // type FrameBufferImage - map[ "type" ] = "FrameBufferImage"; - // width and height - map[ "width"] = 50; - map[ "height" ] = 70; - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) ); - END_TEST; -} - -int UtcDaliScriptingNewImage07P(void) -{ - TestApplication application; - - Property::Map map; - // type BufferImage - map[ "type" ] = "BufferImage"; - // width and height - map[ "width"] = 50; - map[ "height" ] = 70; - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); - DALI_TEST_CHECK( BufferImage::DownCast( image ) ); - DALI_TEST_EQUALS( (BufferImage::DownCast( image )).GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliScriptingNewImage08P(void) -{ - TestApplication application; - - Property::Map map; - map[ "type" ] = "BufferImage"; - // width and height - map[ "width"] = 66; - map[ "height" ] = 99; - // pixel-format - map[ "pixelFormat" ] = ""; - const StringEnum values[] = + enum class T { - { "A8", Pixel::A8 }, - { "L8", Pixel::L8 }, - { "LA88", Pixel::LA88 }, - { "RGB565", Pixel::RGB565 }, - { "BGR565", Pixel::BGR565 }, - { "RGBA4444", Pixel::RGBA4444 }, - { "BGRA4444", Pixel::BGRA4444 }, - { "RGBA5551", Pixel::RGBA5551 }, - { "BGRA5551", Pixel::BGRA5551 }, - { "RGB888", Pixel::RGB888 }, - { "RGB8888", Pixel::RGB8888 }, - { "BGR8888", Pixel::BGR8888 }, - { "RGBA8888", Pixel::RGBA8888 }, - { "BGRA8888", Pixel::BGRA8888 }, - // BufferImage does not support compressed formats + None, + V1 = 1, + V2 = 2 }; - TestEnumStrings< Pixel::Format, BufferImage >( map, "pixelFormat", values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage ); - - END_TEST; -} - -int UtcDaliScriptingNewImage09P(void) -{ - TestApplication application; - Property::Map map; - // type Image - map[ "type" ] = "ResourceImage"; - map[ "filename" ] = "TEST_FILE"; + Property::Value v1 = T::V1; + Property::Value v2 = T::V2; - { - Image image = NewImage( map ); - DALI_TEST_CHECK( ResourceImage::DownCast( image ) ); - DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) ); - DALI_TEST_CHECK( !BufferImage::DownCast( image ) ); - } - END_TEST; -} + 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); -int UtcDaliScriptingNewImage10P(void) -{ - TestApplication application; - - Property::Map map; - // type FrameBufferImage, empty size gives us stage size - map[ "type" ] = "FrameBufferImage"; - Image image = NewImage( map ); - DALI_TEST_CHECK( image ); END_TEST; } @@ -439,30 +139,30 @@ int UtcDaliScriptingNewActorNegative(void) // Empty map { - Actor handle = NewActor( Property::Map() ); - DALI_TEST_CHECK( !handle ); + Actor handle = NewActor(Property::Map()); + DALI_TEST_CHECK(!handle); } // Map with only properties { Property::Map map; - map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER; - map[ "anchorPoint" ] = AnchorPoint::TOP_CENTER; - Actor handle = NewActor( map ); - DALI_TEST_CHECK( !handle ); + map["parentOrigin"] = ParentOrigin::TOP_CENTER; + map["anchorPoint"] = AnchorPoint::TOP_CENTER; + Actor handle = NewActor(map); + DALI_TEST_CHECK(!handle); } // 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.WheelEventSignal().GetConnectionCount() ); - DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() ); - DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() ); - DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() ); + 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; } @@ -472,121 +172,158 @@ int UtcDaliScriptingNewActorProperties(void) TestApplication application; 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[ "positionInheritance" ] = "DONT_INHERIT_POSITION"; - map[ "drawMode" ] = "OVERLAY_2D"; - map[ "inheritOrientation" ] = false; - map[ "inheritScale" ] = false; + 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 { - Actor handle = NewActor( map ); - DALI_TEST_CHECK( handle ); + Actor handle = NewActor(map); + DALI_TEST_CHECK(handle); - Stage::GetCurrent().Add( handle ); + application.GetScene().Add(handle); 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::OVERLAY_2D, TEST_LOCATION ); - DALI_TEST_EQUALS( handle.IsOrientationInherited(), false, TEST_LOCATION ); - DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION ); - - Stage::GetCurrent().Remove( handle ); + DALI_TEST_EQUALS(handle.GetCurrentProperty(Actor::Property::SIZE), Vector3::ONE, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetCurrentProperty(Actor::Property::POSITION), Vector3::XAXIS, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetCurrentProperty(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetCurrentProperty(Actor::Property::VISIBLE), false, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetCurrentProperty(Actor::Property::COLOR), Color::MAGENTA, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::NAME), "MyActor", TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SENSITIVE), false, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::LEAVE_REQUIRED), true, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION); + + application.GetScene().Remove(handle); } // Check Anchor point and parent origin vector3s - map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER; - map[ "anchorPoint" ] = AnchorPoint::TOP_LEFT; + map["parentOrigin"] = ParentOrigin::TOP_CENTER; + map["anchorPoint"] = AnchorPoint::TOP_LEFT; { - Actor handle = NewActor( map ); - DALI_TEST_CHECK( handle ); + Actor handle = NewActor(map); + DALI_TEST_CHECK(handle); - Stage::GetCurrent().Add( handle ); + application.GetScene().Add(handle); 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(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetCurrentProperty(Actor::Property::ANCHOR_POINT), AnchorPoint::TOP_LEFT, TEST_LOCATION); - Stage::GetCurrent().Remove( handle ); + application.GetScene().Remove(handle); } // Check Anchor point and parent origin STRINGS - map[ "parentOrigin" ] = "TOP_LEFT"; - map[ "anchorPoint" ] = "CENTER_LEFT"; + map["parentOrigin"] = "TOP_LEFT"; + map["anchorPoint"] = "CENTER_LEFT"; { - Actor handle = NewActor( map ); - DALI_TEST_CHECK( handle ); + Actor handle = NewActor(map); + DALI_TEST_CHECK(handle); - Stage::GetCurrent().Add( handle ); + application.GetScene().Add(handle); 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(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION); + DALI_TEST_EQUALS(handle.GetCurrentProperty(Actor::Property::ANCHOR_POINT), AnchorPoint::CENTER_LEFT, TEST_LOCATION); - Stage::GetCurrent().Remove( handle ); + application.GetScene().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); + 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(Actor::Property::COLOR), (Color::MAGENTA + Color::CYAN) * 0.5f, TEST_LOCATION); + + application.Render(500); // Halfway thru anim + application.SendNotification(); + DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::COLOR), Color::MAGENTA, TEST_LOCATION); + + END_TEST; +} + int UtcDaliScriptingNewActorChildren(void) { TestApplication application; Property::Map map; - map[ "type" ] = "Actor"; - map[ "position" ] = Vector3::XAXIS; + map["type"] = "Actor"; + map["position"] = Vector3::XAXIS; Property::Map child1Map; - child1Map[ "type" ] = "CameraActor"; - child1Map[ "position" ] = Vector3::YAXIS; + child1Map["type"] = "Layer"; + child1Map["position"] = Vector3::YAXIS; Property::Array childArray; - childArray.PushBack( child1Map ); - map[ "actors" ] = childArray; + childArray.PushBack(child1Map); + map["actors"] = childArray; // Create - Actor handle = NewActor( map ); - DALI_TEST_CHECK( handle ); + Actor handle = NewActor(map); + DALI_TEST_CHECK(handle); - Stage::GetCurrent().Add( handle ); + application.GetScene().Add(handle); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION ); - DALI_TEST_EQUALS( handle.GetChildCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS(handle.GetCurrentProperty(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_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION ); + DALI_TEST_CHECK(child1); + DALI_TEST_CHECK(Layer::DownCast(child1)); + DALI_TEST_EQUALS(child1.GetCurrentProperty(Actor::Property::POSITION), Vector3::YAXIS, TEST_LOCATION); + DALI_TEST_EQUALS(child1.GetChildCount(), 0u, TEST_LOCATION); - Stage::GetCurrent().Remove( handle ); + application.GetScene().Remove(handle); END_TEST; } - int UtcDaliScriptingCreatePropertyMapActor(void) { TestApplication application; @@ -596,12 +333,12 @@ int UtcDaliScriptingCreatePropertyMapActor(void) Actor actor = Actor::New(); Property::Map map; - 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 ); + CreatePropertyMap(actor, map); + DALI_TEST_CHECK(!map.Empty()); + DALI_TEST_CHECK(NULL != map.Find("type")); + DALI_TEST_EQUALS(map.Find("type")->Get(), "Actor", TEST_LOCATION); - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove(actor); } // Layer Type @@ -609,172 +346,95 @@ int UtcDaliScriptingCreatePropertyMapActor(void) Actor actor = Layer::New(); Property::Map map; - 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 ); + CreatePropertyMap(actor, map); + DALI_TEST_CHECK(!map.Empty()); + DALI_TEST_CHECK(NULL != map.Find("type")); + DALI_TEST_EQUALS(map.Find("type")->Get(), "Layer", TEST_LOCATION); - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove(actor); } // 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.SetInheritOrientation( false ); - actor.SetInheritScale( false ); - actor.SetSizeModeFactor( Vector3::ONE ); - - Stage::GetCurrent().Add( actor ); + 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(); Property::Map map; - 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 ); - - Stage::GetCurrent().Remove( actor ); + CreatePropertyMap(actor, map); + + DALI_TEST_CHECK(!map.Empty()); + DALI_TEST_CHECK(NULL != map.Find("size")); + DALI_TEST_EQUALS(map.Find("size")->Get(), Vector3::ONE, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("position")); + DALI_TEST_EQUALS(map.Find("position")->Get(), Vector3::XAXIS, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("scale")); + DALI_TEST_EQUALS(map.Find("scale")->Get(), Vector3::ZAXIS, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("visible")); + DALI_TEST_EQUALS(map.Find("visible")->Get(), false, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("color")); + DALI_TEST_EQUALS(map.Find("color")->Get(), Color::MAGENTA, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("name")); + DALI_TEST_EQUALS(map.Find("name")->Get(), "MyActor", TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("anchorPoint")); + DALI_TEST_EQUALS(map.Find("anchorPoint")->Get(), AnchorPoint::CENTER_LEFT, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("parentOrigin")); + DALI_TEST_EQUALS(map.Find("parentOrigin")->Get(), ParentOrigin::TOP_RIGHT, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("sensitive")); + DALI_TEST_EQUALS(map.Find("sensitive")->Get(), false, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("leaveRequired")); + DALI_TEST_EQUALS(map.Find("leaveRequired")->Get(), true, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("inheritOrientation")); + DALI_TEST_EQUALS(map.Find("inheritOrientation")->Get(), false, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("inheritScale")); + DALI_TEST_EQUALS(map.Find("inheritScale")->Get(), false, TEST_LOCATION); + DALI_TEST_CHECK(NULL != map.Find("sizeModeFactor")); + DALI_TEST_EQUALS(map.Find("sizeModeFactor")->Get(), Vector3::ONE, TEST_LOCATION); + + application.GetScene().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(); Actor child = Layer::New(); - actor.Add( child ); + actor.Add(child); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add(actor); application.SendNotification(); application.Render(); Property::Map map; - 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 ); - - 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 ); - - Stage::GetCurrent().Remove( actor ); - } - END_TEST; -} - -int UtcDaliScriptingCreatePropertyMapImage(void) -{ - TestApplication application; - - // Empty - { - Image image; - Property::Map map; - CreatePropertyMap( image, map ); - DALI_TEST_CHECK( map.Empty() ); - } - - // Default - { - Image image = ResourceImage::New( "MY_PATH" ); - - Property::Map map; - CreatePropertyMap( image, map ); - DALI_TEST_CHECK( !map.Empty() ); - - DALI_TEST_CHECK( NULL != map.Find( "type" ) ); - DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION ); - DALI_TEST_CHECK( NULL != map.Find( "filename" ) ); - DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION ); - DALI_TEST_CHECK( NULL == map.Find( "width" ) ); - DALI_TEST_CHECK( NULL == map.Find( "height" ) ); - } - - // Change values - { - ResourceImage image = ResourceImage::New( "MY_PATH", ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH ); + CreatePropertyMap(actor, map); + DALI_TEST_CHECK(!map.Empty()); - Property::Map map; - CreatePropertyMap( image, map ); - DALI_TEST_CHECK( !map.Empty() ); - - DALI_TEST_CHECK( NULL != map.Find( "type" ) ); - DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION ); - DALI_TEST_CHECK( NULL != map.Find( "filename" ) ); - DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION ); - DALI_TEST_CHECK( NULL != map.Find( "width" ) ); - DALI_TEST_EQUALS( map.Find( "width" )->Get< int >(), 300, TEST_LOCATION ); - DALI_TEST_CHECK( NULL != map.Find( "height" ) ); - DALI_TEST_EQUALS( map.Find( "height" )->Get< int >(), 400, TEST_LOCATION ); - } + DALI_TEST_CHECK(NULL != map.Find("type")); + DALI_TEST_EQUALS(map.Find("type")->Get(), "Actor", TEST_LOCATION); - // BufferImage - { - Image image = BufferImage::New( 200, 300, Pixel::A8 ); - Property::Map map; - CreatePropertyMap( image, map ); - DALI_TEST_CHECK( NULL != map.Find( "type" ) ); - DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "BufferImage", TEST_LOCATION ); - DALI_TEST_CHECK( NULL != map.Find( "pixelFormat") ); - DALI_TEST_EQUALS( map.Find( "pixelFormat" )->Get< std::string >(), "A8", TEST_LOCATION ); - } + DALI_TEST_CHECK(NULL != map.Find("actors")); + Property::Array children(map.Find("actors")->Get()); + DALI_TEST_CHECK(!children.Empty()); + Property::Map childMap(children[0].Get()); + DALI_TEST_CHECK(!childMap.Empty()); + DALI_TEST_CHECK(childMap.Find("type")); + DALI_TEST_EQUALS(childMap.Find("type")->Get(), "Layer", TEST_LOCATION); - // FrameBufferImage - { - Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 ); - Property::Map map; - CreatePropertyMap( image, map ); - DALI_TEST_CHECK( NULL != map.Find( "type" ) ); - DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "FrameBufferImage", TEST_LOCATION ); + application.GetScene().Remove(actor); } END_TEST; } @@ -782,27 +442,27 @@ int UtcDaliScriptingCreatePropertyMapImage(void) int UtcDaliScriptingGetEnumerationTemplates(void) { const Scripting::StringEnum myTable[] = - { - { "ONE", 1 }, - { "TWO", 2 }, - { "THREE", 3 }, - { "FOUR", 4 }, - { "FIVE", 5 }, - }; - const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] ); + { + {"ONE", 1}, + {"TWO", 2}, + {"THREE", 3}, + {"FOUR", 4}, + {"FIVE", 5}, + }; + const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]); - for ( unsigned int i = 0; i < myTableCount; ++i ) + for(unsigned int i = 0; i < myTableCount; ++i) { - tet_printf("Checking: %s\n", myTable[ i ].string ); + tet_printf("Checking: %s\n", myTable[i].string); int value; - DALI_TEST_CHECK( GetEnumeration( myTable[ i ].string, myTable, myTableCount, value ) ); - DALI_TEST_EQUALS( myTable[ i ].value, value, TEST_LOCATION ); + DALI_TEST_CHECK(GetEnumeration(myTable[i].string, myTable, myTableCount, value)); + DALI_TEST_EQUALS(myTable[i].value, value, TEST_LOCATION); } - for ( unsigned int i = 0; i < myTableCount; ++i ) + 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 ); + tet_printf("Checking: %d\n", myTable[i].value); + DALI_TEST_EQUALS(myTable[i].string, GetEnumerationName(myTable[i].value, myTable, myTableCount), TEST_LOCATION); } END_TEST; @@ -810,22 +470,22 @@ int UtcDaliScriptingGetEnumerationTemplates(void) int UtcDaliScriptingGetEnumerationNameN(void) { - const char* value = GetEnumerationName( 10, NULL, 0 ); - DALI_TEST_CHECK( NULL == value ); + const char* value = GetEnumerationName(10, NULL, 0); + DALI_TEST_CHECK(NULL == value); - value = GetEnumerationName( 10, NULL, 1 ); - DALI_TEST_CHECK( NULL == value ); + value = GetEnumerationName(10, NULL, 1); + DALI_TEST_CHECK(NULL == value); END_TEST; } int UtcDaliScriptingGetLinearEnumerationNameN(void) { - const char* value = GetLinearEnumerationName( 10, NULL, 0 ); - DALI_TEST_CHECK( NULL == value ); + const char* value = GetLinearEnumerationName(10, NULL, 0); + DALI_TEST_CHECK(NULL == value); - value = GetLinearEnumerationName( 10, NULL, 1 ); - DALI_TEST_CHECK( NULL == value ); + value = GetLinearEnumerationName(10, NULL, 1); + DALI_TEST_CHECK(NULL == value); END_TEST; } @@ -844,67 +504,67 @@ int UtcDaliScriptingGetEnumerationProperty(void) */ // 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] ); + 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 ); + Property::Value propertyValueInteger(FaceCullingMode::FRONT); // Perform the lookup. - bool returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueInteger, testTable, testTableCount, result ); + bool returnValue = GetEnumerationProperty(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_CHECK(returnValue); - DALI_TEST_EQUALS( static_cast( result ), static_cast( FaceCullingMode::FRONT ), TEST_LOCATION ); + 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 ); + returnValue = GetEnumerationProperty(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 ); + DALI_TEST_CHECK(!returnValue); // The result should remain the same. - DALI_TEST_EQUALS( static_cast( result ), static_cast( FaceCullingMode::FRONT ), TEST_LOCATION ); + 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" ); + Property::Value propertyValueString("BACK"); - returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueString, testTable, testTableCount, result ); + returnValue = GetEnumerationProperty(propertyValueString, testTable, testTableCount, result); - DALI_TEST_CHECK( returnValue ); + DALI_TEST_CHECK(returnValue); // The result should remain the same. - DALI_TEST_EQUALS( static_cast( result ), static_cast( FaceCullingMode::BACK ), TEST_LOCATION ); + DALI_TEST_EQUALS(static_cast(result), static_cast(FaceCullingMode::BACK), TEST_LOCATION); - returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueString, testTable, testTableCount, result ); + returnValue = GetEnumerationProperty(propertyValueString, testTable, testTableCount, result); - DALI_TEST_CHECK( !returnValue ); + DALI_TEST_CHECK(!returnValue); // The result should remain the same. - DALI_TEST_EQUALS( static_cast( result ), static_cast( FaceCullingMode::BACK ), TEST_LOCATION ); + 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 ); + Property::Value propertyValueBoolean(true); - returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueBoolean, testTable, testTableCount, result ); + returnValue = GetEnumerationProperty(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 ); + 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 ); + DALI_TEST_EQUALS(static_cast(result), static_cast(FaceCullingMode::BACK), TEST_LOCATION); END_TEST; } @@ -931,106 +591,106 @@ int UtcDaliScriptingGetBitmaskEnumerationProperty(void) */ // 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] ); + 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 ); + Property::Value propertyValueInteger(FaceCullingMode::FRONT); // Perform the lookup. - bool returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyValueInteger, testTable, testTableCount, result ); + bool returnValue = GetBitmaskEnumerationProperty(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_CHECK(returnValue); - DALI_TEST_EQUALS( static_cast( result ), static_cast( FaceCullingMode::FRONT ), TEST_LOCATION ); + 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" ); + Property::Value propertyValueString("BACK"); - returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyValueString, testTable, testTableCount, result ); + returnValue = GetBitmaskEnumerationProperty(propertyValueString, testTable, testTableCount, result); - DALI_TEST_CHECK( returnValue ); + DALI_TEST_CHECK(returnValue); - DALI_TEST_EQUALS( static_cast( result ), static_cast( FaceCullingMode::BACK ), TEST_LOCATION ); + 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 ); + Property::Value propertyValueVector(Vector3::ZERO); - returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyValueVector, testTable, testTableCount, result ); + returnValue = GetBitmaskEnumerationProperty(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 ); + 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 ); + 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 ); + propertyArrayIntegers.PushBack(FaceCullingMode::FRONT); + propertyArrayIntegers.PushBack(FaceCullingMode::BACK); result = FaceCullingMode::NONE; - returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyArrayIntegers, testTable, testTableCount, result ); + returnValue = GetBitmaskEnumerationProperty(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 ); + 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 ) ); + DALI_TEST_CHECK(result == (FaceCullingMode::FRONT | FaceCullingMode::BACK)); // Property array of 2 strings. Property::Array propertyArrayStrings; - propertyArrayStrings.PushBack( "FRONT" ); - propertyArrayStrings.PushBack( "BACK" ); + propertyArrayStrings.PushBack("FRONT"); + propertyArrayStrings.PushBack("BACK"); result = FaceCullingMode::NONE; - returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyArrayStrings, testTable, testTableCount, result ); + returnValue = GetBitmaskEnumerationProperty(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 ); + 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 ) ); + 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" ); + propertyArrayMixed.PushBack(FaceCullingMode::FRONT); + propertyArrayMixed.PushBack("BACK"); result = FaceCullingMode::NONE; - returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyArrayMixed, testTable, testTableCount, result ); + returnValue = GetBitmaskEnumerationProperty(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 ); + 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 ) ); + 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 ); + 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 ); + returnValue = GetBitmaskEnumerationProperty(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 ); + 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 ); + DALI_TEST_CHECK(result == FaceCullingMode::FRONT_AND_BACK); END_TEST; } @@ -1039,14 +699,14 @@ int UtcDaliScriptingFindEnumIndexN(void) { const Scripting::StringEnum myTable[] = { - { "ONE", (1<<1) }, - { "TWO", (1<<2) }, - { "THREE", (1<<3) }, - { "FOUR", (1<<4) }, - { "FIVE", (1<<5) }, + {"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 ); + const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]); + DALI_TEST_EQUALS(myTableCount, FindEnumIndex("Foo", myTable, myTableCount), TEST_LOCATION); END_TEST; } @@ -1055,44 +715,43 @@ int UtcDaliScriptingEnumStringToIntegerP(void) { const Scripting::StringEnum myTable[] = { - { "ONE", (1<<1) }, - { "TWO", (1<<2) }, - { "THREE", (1<<3) }, - { "FOUR", (1<<4) }, - { "FIVE", (1<<5) }, + {"ONE", (1 << 1)}, + {"TWO", (1 << 2)}, + {"THREE", (1 << 3)}, + {"FOUR", (1 << 4)}, + {"FIVE", (1 << 5)}, }; - const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] ); + const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]); int integerEnum = 0; - DALI_TEST_CHECK( EnumStringToInteger( "ONE", myTable, myTableCount, integerEnum ) ); + DALI_TEST_CHECK(EnumStringToInteger("ONE", myTable, myTableCount, integerEnum)); - DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION ); + DALI_TEST_EQUALS(integerEnum, (1 << 1), TEST_LOCATION); integerEnum = 0; - DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO", myTable, myTableCount, integerEnum ) ); - DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION ); - - DALI_TEST_CHECK( EnumStringToInteger( "ONE,,TWO", myTable, myTableCount, integerEnum ) ); - DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION ); + DALI_TEST_CHECK(EnumStringToInteger("ONE,TWO", myTable, myTableCount, integerEnum)); + DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2), TEST_LOCATION); - DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO,THREE", myTable, myTableCount, integerEnum ) ); - DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3), TEST_LOCATION ); + DALI_TEST_CHECK(EnumStringToInteger("ONE,,TWO", myTable, myTableCount, integerEnum)); + DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2), TEST_LOCATION); - 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 ); + DALI_TEST_CHECK(EnumStringToInteger("ONE,TWO,THREE", myTable, myTableCount, integerEnum)); + DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2) | (1 << 3), TEST_LOCATION); - DALI_TEST_CHECK( EnumStringToInteger( "TWO,ONE", myTable, myTableCount, integerEnum ) ); - DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION ); + 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); - 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 ); + DALI_TEST_CHECK(EnumStringToInteger("TWO,ONE", myTable, myTableCount, integerEnum)); + DALI_TEST_EQUALS(integerEnum, (1 << 1) | (1 << 2), TEST_LOCATION); - DALI_TEST_CHECK( EnumStringToInteger( "ONE,SEVEN", myTable, myTableCount, integerEnum ) ); - DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION ); + 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); - DALI_TEST_CHECK( EnumStringToInteger( "ONE,", myTable, myTableCount, integerEnum ) ); - DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION ); + DALI_TEST_CHECK(EnumStringToInteger("ONE,SEVEN", myTable, myTableCount, integerEnum)); + DALI_TEST_EQUALS(integerEnum, (1 << 1), TEST_LOCATION); + DALI_TEST_CHECK(EnumStringToInteger("ONE,", myTable, myTableCount, integerEnum)); + DALI_TEST_EQUALS(integerEnum, (1 << 1), TEST_LOCATION); END_TEST; } @@ -1100,29 +759,29 @@ int UtcDaliScriptingEnumStringToIntegerP(void) int UtcDaliScriptingEnumStringToIntegerN(void) { const Scripting::StringEnum myTable[] = - { - { "ONE", 1 }, - { "TWO", 2 }, - { "THREE", 3 }, - { "FOUR", 4 }, - { "FIVE", 5 }, - }; - const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] ); + { + {"ONE", 1}, + {"TWO", 2}, + {"THREE", 3}, + {"FOUR", 4}, + {"FIVE", 5}, + }; + const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]); int integerEnum = 0; - DALI_TEST_CHECK( !EnumStringToInteger( "Foo", myTable, myTableCount, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger("Foo", myTable, myTableCount, integerEnum)); - DALI_TEST_CHECK( !EnumStringToInteger( "", myTable, myTableCount, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger("", myTable, myTableCount, integerEnum)); - DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger(",", myTable, myTableCount, integerEnum)); - DALI_TEST_CHECK( !EnumStringToInteger( ",ONE,SEVEN", myTable, myTableCount, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger(",ONE,SEVEN", myTable, myTableCount, integerEnum)); - DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger(",", myTable, myTableCount, integerEnum)); - DALI_TEST_CHECK( !EnumStringToInteger( "ONE", myTable, 0, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger("ONE", myTable, 0, integerEnum)); - DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION ); + DALI_TEST_EQUALS(integerEnum, 0, TEST_LOCATION); END_TEST; } @@ -1130,17 +789,17 @@ int UtcDaliScriptingEnumStringToIntegerN(void) int UtcDaliScriptingEnumStringToIntegerInvalidEnumP(void) { const Scripting::StringEnum myTable[] = - { - { "", 1 }, - { "", 2 }, - { "", 3 }, - }; + { + {"", 1}, + {"", 2}, + {"", 3}, + }; - const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] ); + const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]); int integerEnum = 0; - DALI_TEST_CHECK( EnumStringToInteger( "", myTable, myTableCount, integerEnum ) ); - DALI_TEST_EQUALS( integerEnum, 1, TEST_LOCATION ); + DALI_TEST_CHECK(EnumStringToInteger("", myTable, myTableCount, integerEnum)); + DALI_TEST_EQUALS(integerEnum, 1, TEST_LOCATION); END_TEST; } @@ -1148,26 +807,26 @@ int UtcDaliScriptingEnumStringToIntegerInvalidEnumP(void) int UtcDaliScriptingEnumStringToIntegerInvalidEnumN(void) { const Scripting::StringEnum myTable[] = - { - { "", 1 }, - { "", 1 }, - { "", 1 }, - }; + { + {"", 1}, + {"", 1}, + {"", 1}, + }; - const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] ); + const unsigned int myTableCount = sizeof(myTable) / sizeof(myTable[0]); int integerEnum = 0; - DALI_TEST_CHECK( !EnumStringToInteger( NULL, NULL, 0, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger(NULL, NULL, 0, integerEnum)); - DALI_TEST_CHECK( !EnumStringToInteger( "ONE", 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, 0, integerEnum)); - DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, myTableCount, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger(NULL, myTable, myTableCount, integerEnum)); - DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, myTableCount, integerEnum ) ); + DALI_TEST_CHECK(!EnumStringToInteger("ONE", NULL, myTableCount, integerEnum)); - DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION ); + DALI_TEST_EQUALS(integerEnum, 0, TEST_LOCATION); END_TEST; }