Ejemplo n.º 1
0
int UtcDaliPropertyArrayPushBackP(void)
{
  Property::Array array;

  DALI_TEST_CHECK( 0 == array.Size() );

  array.PushBack( 1 );

  DALI_TEST_CHECK( 1 == array.Size() );

  DALI_TEST_CHECK( array[0].Get<int>() == 1 );

  END_TEST;
}
Actor NewActor( const Property::Map& map )
{
  BaseHandle handle;

  // First find type and create Actor
  Property::Value* typeValue = map.Find( "type" );
  if ( typeValue )
  {
    TypeInfo type = TypeRegistry::Get().GetTypeInfo( typeValue->Get< std::string >() );
    if ( type )
    {
      handle = type.CreateInstance();
    }
  }

  if ( !handle )
  {
    DALI_LOG_ERROR( "Actor type not provided\n" );
    return Actor();
  }

  Actor actor( Actor::DownCast( handle ) );

  if ( actor )
  {
    // Now set the properties, or create children
    for ( unsigned int i = 0, mapCount = map.Count(); i < mapCount; ++i )
    {
      const StringValuePair& pair( map.GetPair( i ) );
      const std::string& key( pair.first );
      if ( key == "type" )
      {
        continue;
      }

      const Property::Value& value( pair.second );

      if ( key == "actors" )
      {
        // Create children
        Property::Array actorArray = value.Get< Property::Array >();
        for ( Property::Array::SizeType i = 0; i < actorArray.Size(); ++i)
        {
          actor.Add( NewActor( actorArray[i].Get< Property::Map >() ) );
        }
      }
      else
      {
        Property::Index index( actor.GetPropertyIndex( key ) );

        if ( index != Property::INVALID_INDEX )
        {
          actor.SetProperty( index, value );
        }
      }
    }
  }

  return actor;
}
Ejemplo n.º 3
0
int UtcDaliPropertyArraySizeP(void)
{
  Property::Array array;
  DALI_TEST_CHECK( 0 == array.Capacity() );
  DALI_TEST_CHECK( 0 == array.Size() );

  array.Reserve(3);

  DALI_TEST_CHECK( 3 == array.Capacity() );
  DALI_TEST_CHECK( 0 == array.Size() );

  array.PushBack( 1 );
  array.PushBack( "world" );
  array.PushBack( 3 );

  DALI_TEST_CHECK( 3 == array.Size() );

  END_TEST;
}