コード例 #1
0
int UtcDaliPropertyMapPopulate(void)
{
  Property::Map map;
  DALI_TEST_CHECK( map.Empty() );

  map[ "hello" ] = 1;
  map[ "world" ] = "world";
  map[ "world" ] = 3; // same item as line above
  DALI_TEST_CHECK( !map.Empty() ); // Should no longer be empty
  DALI_TEST_CHECK( map.Count() == 2 ); // Should only have two items, not three!!
  DALI_TEST_CHECK( map["hello"].Get<int>() == 1 );
  DALI_TEST_CHECK( map["world"].Get<int>() == 3 );

  map.Clear();
  DALI_TEST_CHECK( map.Empty() );
  END_TEST;
}
コード例 #2
0
ファイル: utc-Dali-Scripting.cpp プロジェクト: mettalla/dali
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( "load-policy") );
    DALI_TEST_EQUALS( map.Find( "load-policy" )->Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
    DALI_TEST_CHECK( NULL != map.Find( "release-policy") );
    DALI_TEST_EQUALS( map.Find( "release-policy" )->Get< std::string >(), "NEVER", TEST_LOCATION );
    DALI_TEST_CHECK( NULL == map.Find( "width" ) );
    DALI_TEST_CHECK( NULL == map.Find( "height" ) );
  }

  // Change values
  {
    ResourceImage image = ResourceImage::New( "MY_PATH", ResourceImage::ON_DEMAND, Image::UNUSED, ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );

    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( "load-policy") );
    DALI_TEST_EQUALS( map.Find( "load-policy" )->Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
    DALI_TEST_CHECK( NULL != map.Find( "release-policy") );
    DALI_TEST_EQUALS( map.Find( "release-policy" )->Get< std::string >(), "UNUSED", 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 );
    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( "pixel-format") );
    DALI_TEST_EQUALS( map.Find( "pixel-format" )->Get< std::string >(), "A8", 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 );
  }
  END_TEST;
}
コード例 #3
0
ファイル: utc-Dali-Scripting.cpp プロジェクト: mettalla/dali
int UtcDaliScriptingCreatePropertyMapActor(void)
{
  TestApplication application;

  // Actor Type
  {
    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 );

    Stage::GetCurrent().Remove( actor );
  }

  // ImageActor Type
  {
    Actor actor = ImageActor::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 >(), "ImageActor", TEST_LOCATION );

    Stage::GetCurrent().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 );
    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( "anchor-point" ) );
    DALI_TEST_EQUALS( map.Find( "anchor-point" )->Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
    DALI_TEST_CHECK( NULL != map.Find( "parent-origin" ) );
    DALI_TEST_EQUALS( map.Find( "parent-origin" )->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( "leave-required" ) );
    DALI_TEST_EQUALS( map.Find( "leave-required" )->Get< bool >(), true, TEST_LOCATION );
    DALI_TEST_CHECK( NULL != map.Find( "inherit-orientation" ) );
    DALI_TEST_EQUALS( map.Find( "inherit-orientation" )->Get< bool >(), false, TEST_LOCATION );
    DALI_TEST_CHECK( NULL != map.Find( "inherit-scale" ) );
    DALI_TEST_EQUALS( map.Find( "inherit-scale" )->Get< bool >(), false, TEST_LOCATION );
    DALI_TEST_CHECK( NULL != map.Find( "size-mode-factor" ) );
    DALI_TEST_EQUALS( map.Find( "size-mode-factor" )->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 );

  // PositionInheritanceMode
  TestEnumStrings< PositionInheritanceMode >( "position-inheritance", 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 );

  // Children
  {
    Actor actor = Actor::New();
    Actor child = ImageActor::New();
    actor.Add( child );

    Stage::GetCurrent().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 >(), "ImageActor", TEST_LOCATION );

    Stage::GetCurrent().Remove( actor );
  }
  END_TEST;
}