int Property::Value::AppendItem(const Property::Value &value) { DALI_ASSERT_DEBUG(Property::ARRAY == GetType() && "Property type invalid"); Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue)); if(container) { container->push_back(value); return container->size() - 1; } else { return -1; } }
int UtcDaliScriptingNewActorChildren(void) { TestApplication application; Property::Map map; map.push_back( Property::StringValuePair( "type", "Actor" ) ); map.push_back( Property::StringValuePair( "position", Vector3::XAXIS ) ); Property::Map child1Map; child1Map.push_back( Property::StringValuePair( "type", "ImageActor" ) ); child1Map.push_back( Property::StringValuePair( "position", Vector3::YAXIS ) ); Property::Map child2Map; child2Map.push_back( Property::StringValuePair( "type", "TextActor" ) ); child2Map.push_back( Property::StringValuePair( "position", Vector3::ZAXIS ) ); Property::Map grandChildMap; grandChildMap.push_back( Property::StringValuePair( "type", "LightActor" ) ); grandChildMap.push_back( Property::StringValuePair( "position", Vector3::ONE ) ); // Add arrays to appropriate maps Property::Array grandChildArray; grandChildArray.push_back( grandChildMap ); Property::Array childArray; child1Map.push_back( Property::StringValuePair( "actors", grandChildArray ) ); childArray.push_back( child1Map ); childArray.push_back( child2Map ); map.push_back( Property::StringValuePair( "actors", childArray ) ); // Create Actor handle = NewActor( map ); DALI_TEST_CHECK( handle ); Stage::GetCurrent().Add( handle ); application.SendNotification(); application.Render(); DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION ); DALI_TEST_EQUALS( handle.GetChildCount(), 2u, TEST_LOCATION ); Actor child1 = handle.GetChildAt(0); DALI_TEST_CHECK( child1 ); DALI_TEST_CHECK( ImageActor::DownCast( child1 ) ); DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION ); DALI_TEST_EQUALS( child1.GetChildCount(), 1u, TEST_LOCATION ); Actor child2 = handle.GetChildAt(1); DALI_TEST_CHECK( child2 ); DALI_TEST_CHECK( TextActor::DownCast( child2 ) ); DALI_TEST_EQUALS( child2.GetCurrentPosition(), Vector3::ZAXIS, TEST_LOCATION ); DALI_TEST_EQUALS( child2.GetChildCount(), 0u, TEST_LOCATION ); Actor grandChild = child1.GetChildAt( 0 ); DALI_TEST_CHECK( grandChild ); DALI_TEST_CHECK( LightActor::DownCast( grandChild ) ); DALI_TEST_EQUALS( grandChild.GetCurrentPosition(), Vector3::ONE, TEST_LOCATION ); DALI_TEST_EQUALS( grandChild.GetChildCount(), 0u, TEST_LOCATION ); Stage::GetCurrent().Remove( handle ); END_TEST; }