+
+namespace
+{
+struct PropertyStringIndex
+{
+ const char * const name;
+ const Property::Index index;
+ const Property::Type type;
+};
+
+const PropertyStringIndex PROPERTY_TABLE[] =
+{
+ { "parent-origin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
+ { "parent-origin-x", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
+ { "parent-origin-y", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
+ { "parent-origin-z", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
+ { "anchor-point", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
+ { "anchor-point-x", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
+ { "anchor-point-y", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
+ { "anchor-point-z", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
+ { "size", Actor::Property::SIZE, Property::VECTOR3 },
+ { "size-width", Actor::Property::SIZE_WIDTH, Property::FLOAT },
+ { "size-height", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
+ { "size-depth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
+ { "position", Actor::Property::POSITION, Property::VECTOR3 },
+ { "position-x", Actor::Property::POSITION_X, Property::FLOAT },
+ { "position-y", Actor::Property::POSITION_Y, Property::FLOAT },
+ { "position-z", Actor::Property::POSITION_Z, Property::FLOAT },
+ { "world-position", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
+ { "world-position-x", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
+ { "world-position-y", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
+ { "world-position-z", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
+ { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
+ { "world-orientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
+ { "scale", Actor::Property::SCALE, Property::VECTOR3 },
+ { "scale-x", Actor::Property::SCALE_X, Property::FLOAT },
+ { "scale-y", Actor::Property::SCALE_Y, Property::FLOAT },
+ { "scale-z", Actor::Property::SCALE_Z, Property::FLOAT },
+ { "world-scale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
+ { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
+ { "color", Actor::Property::COLOR, Property::VECTOR4 },
+ { "color-red", Actor::Property::COLOR_RED, Property::FLOAT },
+ { "color-green", Actor::Property::COLOR_GREEN, Property::FLOAT },
+ { "color-blue", Actor::Property::COLOR_BLUE, Property::FLOAT },
+ { "color-alpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
+ { "world-color", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
+ { "world-matrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
+ { "name", Actor::Property::NAME, Property::STRING },
+ { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
+ { "leave-required", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
+ { "inherit-orientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
+ { "inherit-scale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
+ { "color-mode", Actor::Property::COLOR_MODE, Property::STRING },
+ { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
+ { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
+ { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
+ { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
+ { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
+ { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
+ { "width-for-height", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
+ { "height-for-width", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
+ { "padding", Actor::Property::PADDING, Property::VECTOR4 },
+ { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
+ { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
+};
+const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
+} // unnamed namespace
+
+int UtcDaliActorProperties(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
+ {
+ tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
+ DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliRelayoutProperties_ResizePolicies(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ // Defaults
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
+
+ // Set resize policy for all dimensions
+ actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
+ {
+ DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
+ }
+
+ // Set individual dimensions
+ const char* const widthPolicy = "FILL_TO_PARENT";
+ const char* const heightPolicy = "FIXED";
+
+ actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
+ actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
+
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRelayoutProperties_SizeScalePolicy(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ // Defaults
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
+
+ SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
+ actor.SetSizeScalePolicy( policy );
+ DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
+
+ // Set
+ const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
+ const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
+
+ actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRelayoutProperties_SizeModeFactor(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ // Defaults
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
+
+ Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
+ actor.SetSizeModeFactor( sizeMode );
+ DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
+
+ // Set
+ Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
+
+ actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRelayoutProperties_DimensionDependency(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ // Defaults
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
+
+ // Set
+ actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
+
+ // Test setting another resize policy
+ actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
+ DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRelayoutProperties_Padding(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ // Data
+ Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
+
+ // PADDING
+ actor.SetProperty( Actor::Property::PADDING, padding );
+ Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
+
+ DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ // Data
+ Vector2 minSize( 1.0f, 2.0f );
+
+ actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
+ Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
+
+ DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ Vector2 maxSize( 3.0f, 4.0f );
+
+ actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
+ Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
+
+ DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorGetHeightForWidth(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorGetWidthForHeight(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorGetRelayoutSize(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ // Add actor to stage
+ Stage::GetCurrent().Add( actor );
+
+ DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
+
+ actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
+ actor.SetSize( Vector2( 1.0f, 0.0f ) );
+
+ // Flush the queue and render once
+ app.SendNotification();
+ app.Render();
+
+ DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorSetPadding(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ Padding padding;
+ actor.GetPadding( padding );
+
+ DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
+
+ Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
+ actor.SetPadding( padding2 );
+
+ actor.GetPadding( padding );
+
+ DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
+ DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
+ DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
+ DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorSetMinimumSize(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ Vector2 size = actor.GetMinimumSize();
+
+ DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
+
+ Vector2 size2( 1.0f, 2.0f );
+ actor.SetMinimumSize( size2 );
+
+ size = actor.GetMinimumSize();
+
+ DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorSetMaximumSize(void)
+{
+ TestApplication app;
+
+ Actor actor = Actor::New();
+
+ Vector2 size = actor.GetMaximumSize();
+
+ DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
+
+ Vector2 size2( 1.0f, 2.0f );
+ actor.SetMaximumSize( size2 );
+
+ size = actor.GetMaximumSize();
+
+ DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorOnRelayoutSignal(void)
+{
+ tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
+
+ TestApplication application;
+
+ // Clean test data
+ gOnRelayoutCallBackCalled = 0;
+ gActorNamesRelayout.clear();
+
+ Actor actor = Actor::New();
+ actor.SetName( "actor" );
+ actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
+
+ // Sanity check
+ DALI_TEST_CHECK( gOnRelayoutCallBackCalled == 0 );
+
+ // Add actor to stage
+ Stage::GetCurrent().Add( actor );
+
+ actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ actor.SetSize( Vector2( 1.0f, 2.0 ) );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // OnRelayout emitted
+ DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
+
+ END_TEST;
+}