/*
- * 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.
#include <stdlib.h>
#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/scripting/scripting.h>
#include <dali-test-suite-utils.h>
using namespace Dali;
namespace
{
-const StringEnum< int > COLOR_MODE_VALUES[] =
+const StringEnum COLOR_MODE_VALUES[] =
{
{ "USE_OWN_COLOR", USE_OWN_COLOR },
{ "USE_PARENT_COLOR", USE_PARENT_COLOR },
};
const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
-const StringEnum< int > POSITION_INHERITANCE_MODE_VALUES[] =
+const StringEnum POSITION_INHERITANCE_MODE_VALUES[] =
{
{ "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
{ "USE_PARENT_POSITION", USE_PARENT_POSITION },
};
const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] );
-const StringEnum< int > DRAW_MODE_VALUES[] =
+const StringEnum DRAW_MODE_VALUES[] =
{
{ "NORMAL", DrawMode::NORMAL },
- { "OVERLAY", DrawMode::OVERLAY },
- { "STENCIL", DrawMode::STENCIL },
+ { "OVERLAY_2D", DrawMode::OVERLAY_2D }
};
const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
-//////////////////////////////////////////////////////////////////////////////
-// Helpers for string to enum comparisons for Image and ImageAttributes
-//////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// Helpers for string to enum comparisons for Image and Image loading parameters
+////////////////////////////////////////////////////////////////////////////////
/**
* Template to check enumerations of type T, with a class of type X
template< typename T, typename X >
void TestEnumStrings(
Property::Map& map, // The map used to create instance of type X
- const StringEnum< int >* values, // An array of string values
+ const char * const keyName, // the name of the key to iterate through
+ const StringEnum* values, // An array of string values
unsigned int num, // Number of items in the array
T ( X::*method )() const, // The member method of X to call to get the enum
X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X
)
{
- const unsigned int lastIndex( map.Count() - 1 );
- const std::string& key = map.GetKey( lastIndex );
- Property::Value& value = map.GetValue( lastIndex );
-
+ // get the key reference so we can change its value
+ Property::Value* value = map.Find( keyName );
for ( unsigned int i = 0; i < num; ++i )
{
- value = values[i].string;
- tet_printf("Checking: %s: %s\n", key.c_str(), values[i].string );
+ *value = values[i].string;
+ tet_printf("Checking: %s: %s\n", keyName, values[i].string );
X instance = creator( map );
- DALI_TEST_EQUALS( values[i].value, ( instance.*method )(), TEST_LOCATION );
+ DALI_TEST_EQUALS( values[i].value, (int)( instance.*method )(), TEST_LOCATION );
}
}
return image;
}
-/// Helper method to create ImageAttributes using an Image
-ImageAttributes NewImageAttributes( const Property::Value& map )
-{
- ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
- return image.GetAttributes();
-}
-
//////////////////////////////////////////////////////////////////////////////
// Helpers for string to enum comparisons for Actor to Property::Map
//////////////////////////////////////////////////////////////////////////////
void TestEnumStrings(
const char * const keyName, // The name of the key to check
TestApplication& application, // Reference to the application class
- const StringEnum< int >* values, // An array of string values
+ 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
)
Property::Map map;
CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( map.Count() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( keyName ) );
- DALI_TEST_EQUALS( value.GetValue( keyName ).Get< std::string >(), values[i].string, TEST_LOCATION );
+ DALI_TEST_CHECK( 0 < map.Count() );
+ DALI_TEST_CHECK( NULL != map.Find( keyName ) );
+ DALI_TEST_EQUALS( map.Find( keyName )->Get< std::string >(), values[i].string, TEST_LOCATION );
Stage::GetCurrent().Remove( actor );
}
} // anon namespace
-
-
-int UtcDaliScriptingGetColorMode(void)
+int UtcDaliScriptingNewImageNegative01(void)
{
- TestApplication application;
-
- for ( unsigned int i = 0; i < COLOR_MODE_VALUES_COUNT; ++i )
- {
- tet_printf( "Checking %s == %d\n", COLOR_MODE_VALUES[i].string, COLOR_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].value, GetColorMode( COLOR_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].string, GetColorMode( (ColorMode) COLOR_MODE_VALUES[i].value ), TEST_LOCATION );
- }
-
- try
- {
- (void)GetColorMode("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
+ // 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 UtcDaliScriptingGetPositionInheritanceMode(void)
+int UtcDaliScriptingNewImageNegative06(void)
{
- TestApplication application;
-
- for ( unsigned int i = 0; i < POSITION_INHERITANCE_MODE_VALUES_COUNT; ++i )
- {
- tet_printf( "Checking %s == %d\n", POSITION_INHERITANCE_MODE_VALUES[i].string, POSITION_INHERITANCE_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].value, GetPositionInheritanceMode( POSITION_INHERITANCE_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].string, GetPositionInheritanceMode( (PositionInheritanceMode) POSITION_INHERITANCE_MODE_VALUES[i].value ), TEST_LOCATION );
- }
-
- try
- {
- (void)GetPositionInheritanceMode("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
+ 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 UtcDaliScriptingGetDrawMode(void)
+int UtcDaliScriptingNewImageNegative07(void)
{
- TestApplication application;
-
- for ( unsigned int i = 0; i < DRAW_MODE_VALUES_COUNT; ++i )
- {
- tet_printf( "Checking %s == %d\n", DRAW_MODE_VALUES[i].string, DRAW_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].value, GetDrawMode( DRAW_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].string, GetDrawMode( (DrawMode::Type) DRAW_MODE_VALUES[i].value ), TEST_LOCATION );
- }
-
- try
- {
- (void)GetDrawMode("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
+ 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 UtcDaliScriptingGetAnchorConstant(void)
+int UtcDaliScriptingNewImageNegative08(void)
{
- TestApplication application;
-
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_LEFT, GetAnchorConstant( "TOP_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_CENTER, GetAnchorConstant( "TOP_CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_RIGHT, GetAnchorConstant( "TOP_RIGHT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_LEFT, GetAnchorConstant( "CENTER_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER, GetAnchorConstant( "CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_RIGHT, GetAnchorConstant( "CENTER_RIGHT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_LEFT, GetAnchorConstant( "BOTTOM_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_CENTER, GetAnchorConstant( "BOTTOM_CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_RIGHT, GetAnchorConstant( "BOTTOM_RIGHT" ), TEST_LOCATION );
-
- try
- {
- (void)GetAnchorConstant("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
+ 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 UtcDaliScriptingNewImageNegative(void)
+int UtcDaliScriptingNewImageNegative09(void)
{
- TestApplication application;
-
- // Invalid filename
- try
- {
- Property::Map map;
- map[ "filename" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
- }
-
- // Invalid load-policy
- try
- {
- Property::Map map;
- map[ "load-policy" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "load-policy" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
-
- // Invalid release-policy
- try
- {
- Property::Map map;
- map[ "release-policy" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "release-policy" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
-
- // Invalid width
- try
- {
- Property::Map map;
- map[ "width" ] = "Invalid";
- map[ "height" ] = "Invalid";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
- }
-
- // Invalid height
- try
- {
- Property::Map map;
- map[ "width" ] = 10;
- map[ "height" ] = "Invalid";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
- }
-
- // Invalid pixel-format
- try
- {
- Property::Map map;
- map[ "pixel-format" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "pixel-format" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
+ 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
- try
- {
- Property::Map map;
- map[ "scaling-mode" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+ 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;
+}
- // Invalid value
- try
- {
- Property::Map map;
- map[ "scaling-mode" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
+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
- try
- {
- Property::Map map;
- map[ "type" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(\"type\").GetType()", TEST_LOCATION );
+ 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;
+}
- // Invalid value
- try
- {
- Property::Map map;
- map[ "type" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
+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 UtcDaliScriptingNewImage(void)
+int UtcDaliScriptingNewImage01P(void)
{
- TestApplication application;
+ 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 );
- }
+ ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
+ DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION );
+ END_TEST;
+}
- // load-policy
- map[ "load-policy" ] = "";
- {
- const StringEnum< int > values[] =
- {
- { "IMMEDIATE", ResourceImage::IMMEDIATE },
- { "ON_DEMAND", ResourceImage::ON_DEMAND }
- };
- TestEnumStrings< ResourceImage::LoadPolicy, ResourceImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ResourceImage::GetLoadPolicy, &NewResourceImage );
- }
+int UtcDaliScriptingNewImage04P(void)
+{
+ TestApplication application;
- // release-policy
- map[ "release-policy" ] = "";
- {
- const StringEnum< int > values[] =
- {
- { "UNUSED", Image::UNUSED },
- { "NEVER", Image::NEVER }
- };
- TestEnumStrings< Image::ReleasePolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
- }
+ 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(), 10.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 20.0f, TEST_LOCATION );
- }
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION );
+ DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION );
+ END_TEST;
+}
- // int width and height
- map[ "width"] = (int) 50;
- map[ "height" ] = (int) 70;
- {
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
- }
+int UtcDaliScriptingNewImage05P(void)
+{
+ TestApplication application;
- //map.erase( map.end() - 2, map.end() );
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
- // scaling-mode
- map[ "scaling-mode" ] = "";
- {
- const StringEnum< int > values[] =
- {
- { "SHRINK_TO_FIT", ImageAttributes::ShrinkToFit },
- { "SCALE_TO_FILL", ImageAttributes::ScaleToFill },
- { "FIT_WIDTH", ImageAttributes::FitWidth },
- { "FIT_HEIGHT", ImageAttributes::FitHeight },
- };
- TestEnumStrings< ImageAttributes::ScalingMode, ImageAttributes >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ImageAttributes::GetScalingMode, &NewImageAttributes );
- }
+ // 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)
+{
+ TestApplication application;
+
+ Property::Map map;
// type FrameBufferImage
map[ "type" ] = "FrameBufferImage";
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
- }
+ // 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";
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( BufferImage::DownCast( image ) );
- DALI_TEST_CHECK((BufferImage::DownCast( image )).GetPixelFormat()== Pixel::RGBA8888);
- }
-
- // pixel-format
- map[ "pixel-format" ] = "";
- {
- const StringEnum< int > values[] =
- {
- { "A8", Pixel::A8 },
- { "L8", Pixel::L8 },
- { "LA88", Pixel::LA88 },
- { "RGB565", Pixel::RGB565 },
- { "BGR565", Pixel::BGR565 },
- { "RGBA4444", Pixel::RGBA4444 },
- { "BGRA4444", Pixel::BGRA4444 },
- { "RGBA5551", Pixel::RGBA5551 },
- { "BGRA5551", Pixel::BGRA5551 },
- { "RGB888", Pixel::RGB888 },
- { "RGB8888", Pixel::RGB8888 },
- { "BGR8888", Pixel::BGR8888 },
- { "RGBA8888", Pixel::RGBA8888 },
- { "BGRA8888", Pixel::BGRA8888 },
- /*{ "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
- { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
- { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
- { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
- { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
- { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
- { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
- { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
- { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
- { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },*/
- // BufferImage doesnot support compressed format
- };
-
- TestEnumStrings< Pixel::Format, BufferImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
- }
+ map[ "type" ] = "BufferImage";
+ // width and height
+ map[ "width"] = 50;
+ map[ "height" ] = 70;
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ DALI_TEST_CHECK( BufferImage::DownCast( image ) );
+ DALI_TEST_EQUALS( (BufferImage::DownCast( image )).GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage08P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "type" ] = "BufferImage";
+ // width and height
+ map[ "width"] = 66;
+ map[ "height" ] = 99;
+ // pixel-format
+ map[ "pixelFormat" ] = "";
+ const StringEnum values[] =
+ {
+ { "A8", Pixel::A8 },
+ { "L8", Pixel::L8 },
+ { "LA88", Pixel::LA88 },
+ { "RGB565", Pixel::RGB565 },
+ { "BGR565", Pixel::BGR565 },
+ { "RGBA4444", Pixel::RGBA4444 },
+ { "BGRA4444", Pixel::BGRA4444 },
+ { "RGBA5551", Pixel::RGBA5551 },
+ { "BGRA5551", Pixel::BGRA5551 },
+ { "RGB888", Pixel::RGB888 },
+ { "RGB8888", Pixel::RGB8888 },
+ { "BGR8888", Pixel::BGR8888 },
+ { "RGBA8888", Pixel::RGBA8888 },
+ { "BGRA8888", Pixel::BGRA8888 },
+ // BufferImage does not support compressed formats
+ };
+ TestEnumStrings< Pixel::Format, BufferImage >( map, "pixelFormat", values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
+
+ END_TEST;
+}
+int UtcDaliScriptingNewImage09P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
// type Image
map[ "type" ] = "ResourceImage";
+ map[ "filename" ] = "TEST_FILE";
+
{
Image image = NewImage( map );
DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
END_TEST;
}
-int UtcDaliScriptingNewShaderEffect(void)
+int UtcDaliScriptingNewImage10P(void)
{
TestApplication application;
- Property::Map programMap;
- programMap[ "vertex-filename" ] = "bump.vert";
- programMap[ "fragment-filename" ] = "bump.frag";
-
- Property::Map imageMap;
- imageMap[ "filename" ] = "image.png";
-
Property::Map map;
- map[ "image" ] = imageMap;
- map[ "program" ] = programMap;
- map[ "uLightPosition" ] = Vector3( 0.0, 0.0, -1.5);
- map[ "uAmbientLight" ] = (int)10;
-
- ShaderEffect shader = NewShaderEffect( map );
-
- DALI_TEST_CHECK( shader );
+ // type FrameBufferImage, empty size gives us stage size
+ map[ "type" ] = "FrameBufferImage";
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
END_TEST;
}
// Map with only properties
{
Property::Map map;
- map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
- map[ "anchor-point" ] = AnchorPoint::TOP_CENTER;
+ map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER;
+ map[ "anchorPoint" ] = AnchorPoint::TOP_CENTER;
Actor handle = NewActor( map );
DALI_TEST_CHECK( !handle );
}
map[ "signals" ] = Property::MAP;
Actor handle = NewActor( map );
DALI_TEST_CHECK( handle );
- DALI_TEST_CHECK( !handle.MouseWheelEventSignal().GetConnectionCount() );
+ 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[ "visible" ] = false;
map[ "color" ] = Color::MAGENTA;
map[ "name" ] = "MyActor";
- map[ "color-mode" ] = "USE_PARENT_COLOR";
- map[ "inherit-shader-effect" ] = false;
+ map[ "colorMode" ] = "USE_PARENT_COLOR";
map[ "sensitive" ] = false;
- map[ "leave-required" ] = true;
- map[ "position-inheritance" ] = "DONT_INHERIT_POSITION";
- map[ "draw-mode" ] = "STENCIL";
- map[ "inherit-orientation" ] = false;
- map[ "inherit-scale" ] = false;
+ map[ "leaveRequired" ] = true;
+ map[ "positionInheritance" ] = "DONT_INHERIT_POSITION";
+ map[ "drawMode" ] = "OVERLAY_2D";
+ map[ "inheritOrientation" ] = false;
+ map[ "inheritScale" ] = false;
// Default properties
{
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 );
}
// Check Anchor point and parent origin vector3s
- map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
- map[ "anchor-point" ] = AnchorPoint::TOP_LEFT;
+ map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER;
+ map[ "anchorPoint" ] = AnchorPoint::TOP_LEFT;
{
Actor handle = NewActor( map );
DALI_TEST_CHECK( handle );
}
// Check Anchor point and parent origin STRINGS
- map[ "parent-origin" ] = "TOP_LEFT";
- map[ "anchor-point" ] = "CENTER_LEFT";
+ map[ "parentOrigin" ] = "TOP_LEFT";
+ map[ "anchorPoint" ] = "CENTER_LEFT";
{
Actor handle = NewActor( map );
DALI_TEST_CHECK( 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.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;
map[ "position" ] = Vector3::XAXIS;
Property::Map child1Map;
- child1Map[ "type" ] = "ImageActor";
+ child1Map[ "type" ] = "CameraActor";
child1Map[ "position" ] = Vector3::YAXIS;
Property::Array childArray;
- childArray.push_back( child1Map );
+ childArray.PushBack( child1Map );
map[ "actors" ] = childArray;
// Create
Actor child1 = handle.GetChildAt(0);
DALI_TEST_CHECK( child1 );
- DALI_TEST_CHECK( ImageActor::DownCast( child1 ) );
+ DALI_TEST_CHECK( CameraActor::DownCast( child1 ) );
DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION );
DALI_TEST_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION );
Property::Map map;
CreatePropertyMap( actor, map );
DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "Actor", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type")->Get< std::string >(), "Actor", TEST_LOCATION );
Stage::GetCurrent().Remove( actor );
}
- // ImageActor Type
+ // Layer Type
{
- Actor actor = ImageActor::New();
+ Actor actor = Layer::New();
Property::Map map;
CreatePropertyMap( actor, map );
DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "ImageActor", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
Stage::GetCurrent().Remove( actor );
}
actor.SetLeaveRequired( true );
actor.SetInheritOrientation( false );
actor.SetInheritScale( false );
- actor.SetSizeMode( USE_OWN_SIZE );
actor.SetSizeModeFactor( Vector3::ONE );
Stage::GetCurrent().Add( actor );
CreatePropertyMap( actor, map );
DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "size" ) );
- DALI_TEST_EQUALS( value.GetValue( "size" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "position" ) );
- DALI_TEST_EQUALS( value.GetValue( "position" ).Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "scale" ) );
- DALI_TEST_EQUALS( value.GetValue( "scale" ).Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "visible" ) );
- DALI_TEST_EQUALS( value.GetValue( "visible" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "color" ) );
- DALI_TEST_EQUALS( value.GetValue( "color" ).Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "name" ) );
- DALI_TEST_EQUALS( value.GetValue( "name").Get< std::string >(), "MyActor", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "anchor-point" ) );
- DALI_TEST_EQUALS( value.GetValue( "anchor-point" ).Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "parent-origin" ) );
- DALI_TEST_EQUALS( value.GetValue( "parent-origin" ).Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "sensitive" ) );
- DALI_TEST_EQUALS( value.GetValue( "sensitive" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "leave-required" ) );
- DALI_TEST_EQUALS( value.GetValue( "leave-required" ).Get< bool >(), true, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "inherit-orientation" ) );
- DALI_TEST_EQUALS( value.GetValue( "inherit-orientation" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "inherit-scale" ) );
- DALI_TEST_EQUALS( value.GetValue( "inherit-scale" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "size-mode-factor" ) );
- DALI_TEST_EQUALS( value.GetValue( "size-mode-factor" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+ 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 );
}
// ColorMode
- TestEnumStrings< ColorMode >( "color-mode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
+ TestEnumStrings< ColorMode >( "colorMode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
// PositionInheritanceMode
- TestEnumStrings< PositionInheritanceMode >( "position-inheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
+ TestEnumStrings< PositionInheritanceMode >( "positionInheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
// DrawMode
- TestEnumStrings< DrawMode::Type >( "draw-mode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
+ TestEnumStrings< DrawMode::Type >( "drawMode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
// Children
{
Actor actor = Actor::New();
- Actor child = ImageActor::New();
+ Actor child = Layer::New();
actor.Add( child );
Stage::GetCurrent().Add( actor );
CreatePropertyMap( actor, map );
DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Actor", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Actor", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "actors" ) );
- Property::Array children( value.GetValue( "actors").Get< Property::Array >() );
- DALI_TEST_CHECK( !children.empty() );
+ 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() );
- Property::Value childValue( childMap );
- DALI_TEST_CHECK( childValue.HasKey( "type" ) );
- DALI_TEST_EQUALS( childValue.GetValue( "type" ).Get< std::string >(), "ImageActor", TEST_LOCATION );
+ DALI_TEST_CHECK( childMap.Find( "type" ) );
+ DALI_TEST_EQUALS( childMap.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
Stage::GetCurrent().Remove( actor );
}
CreatePropertyMap( image, map );
DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "filename" ) );
- DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "load-policy") );
- DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "release-policy") );
- DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "NEVER", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "scaling-mode") );
- DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "SHRINK_TO_FIT", TEST_LOCATION );
- DALI_TEST_CHECK( !value.HasKey( "width" ) );
- DALI_TEST_CHECK( !value.HasKey( "height" ) );
+ DALI_TEST_CHECK( 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
{
- ImageAttributes attributes;
- attributes.SetScalingMode( ImageAttributes::FitWidth );
- attributes.SetSize( 300, 400 );
- Image image = ResourceImage::New( "MY_PATH", attributes, ResourceImage::ON_DEMAND, Image::UNUSED );
+ ResourceImage image = ResourceImage::New( "MY_PATH", ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
Property::Map map;
CreatePropertyMap( image, map );
DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "filename" ) );
- DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "load-policy") );
- DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "release-policy") );
- DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "UNUSED", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "scaling-mode") );
- DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "FIT_WIDTH", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "width" ) );
- DALI_TEST_EQUALS( value.GetValue( "width" ).Get< int >(), 300, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "height" ) );
- DALI_TEST_EQUALS( value.GetValue( "height" ).Get< int >(), 400, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
+ DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "width" ) );
+ DALI_TEST_EQUALS( map.Find( "width" )->Get< int >(), 300, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "height" ) );
+ DALI_TEST_EQUALS( map.Find( "height" )->Get< int >(), 400, TEST_LOCATION );
}
// BufferImage
Image image = BufferImage::New( 200, 300, Pixel::A8 );
Property::Map map;
CreatePropertyMap( image, map );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BufferImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "pixel-format") );
- DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "BufferImage", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "pixelFormat") );
+ DALI_TEST_EQUALS( map.Find( "pixelFormat" )->Get< std::string >(), "A8", TEST_LOCATION );
}
// FrameBufferImage
Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
Property::Map map;
CreatePropertyMap( image, map );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
}
END_TEST;
}
int UtcDaliScriptingGetEnumerationTemplates(void)
{
- TestApplication application;
-
- const Scripting::StringEnum< int > myTable[] =
+ const Scripting::StringEnum myTable[] =
{
{ "ONE", 1 },
{ "TWO", 2 },
for ( unsigned int i = 0; i < myTableCount; ++i )
{
tet_printf("Checking: %s\n", myTable[ i ].string );
- DALI_TEST_EQUALS( myTable[ i ].value, GetEnumeration( myTable[ i ].string, myTable, myTableCount ), TEST_LOCATION );
+ int value;
+ DALI_TEST_CHECK( GetEnumeration<int>( myTable[ i ].string, myTable, myTableCount, value ) );
+ DALI_TEST_EQUALS( myTable[ i ].value, value, TEST_LOCATION );
}
for ( unsigned int i = 0; i < myTableCount; ++i )
END_TEST;
}
-int UtcDaliScriptingCompareEnums(void)
+int UtcDaliScriptingGetEnumerationNameN(void)
+{
+ const char* value = GetEnumerationName( 10, NULL, 0 );
+ 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 );
+
+ value = GetLinearEnumerationName( 10, NULL, 1 );
+ DALI_TEST_CHECK( NULL == value );
+
+ 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)
{
- // EQUAL
- DALI_TEST_CHECK( CompareEnums( "", "" ) );
- DALI_TEST_CHECK( CompareEnums( "HELLO", "HELLO" ) );
- DALI_TEST_CHECK( CompareEnums( "HELLO", "hello" ) );
- DALI_TEST_CHECK( CompareEnums( "hello", "HELLO" ) );
- DALI_TEST_CHECK( CompareEnums( "hello-world", "HELLO_WORLD" ) );
- DALI_TEST_CHECK( CompareEnums( "hello_WORLD", "HELLO-world" ) );
- DALI_TEST_CHECK( CompareEnums( "hello_WORLD-", "HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "_hello_WORLD-", "-HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "-hello_WORLD-", "_HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "hello123", "HELLO123" ) );
+ const Scripting::StringEnum myTable[] =
+ {
+ { "ONE", (1<<1) },
+ { "TWO", (1<<2) },
+ { "THREE", (1<<3) },
+ { "FOUR", (1<<4) },
+ { "FIVE", (1<<5) },
+ };
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+ DALI_TEST_EQUALS( myTableCount, FindEnumIndex( "Foo", myTable, myTableCount ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingEnumStringToIntegerP(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "ONE", (1<<1) },
+ { "TWO", (1<<2) },
+ { "THREE", (1<<3) },
+ { "FOUR", (1<<4) },
+ { "FIVE", (1<<5) },
+ };
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+
+ int integerEnum = 0;
+ DALI_TEST_CHECK( EnumStringToInteger( "ONE", myTable, myTableCount, integerEnum ) );
+
+ 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,THREE", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3), 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", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), 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,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;
+}
+
+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] );
+
+ int integerEnum = 0;
+ 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( ",ONE,SEVEN", myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( "ONE", myTable, 0, integerEnum ) );
+
+ DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingEnumStringToIntegerInvalidEnumP(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "", 1 },
+ { "", 2 },
+ { "", 3 },
+ };
+
+ 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 );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingEnumStringToIntegerInvalidEnumN(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "", 1 },
+ { "", 1 },
+ { "", 1 },
+ };
+
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+
+ int integerEnum = 0;
+ DALI_TEST_CHECK( !EnumStringToInteger( NULL, NULL, 0, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, 0, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, 0, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, myTableCount, integerEnum ) );
- // NOT EQUAL
- DALI_TEST_CHECK( ! CompareEnums( "hello", "HELLOWORLD" ) );
+ DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION );
END_TEST;
}