예제 #1
0
int UtcDaliScriptingNewActorProperties(void)
{
  TestApplication application;

  Property::Map map;
  map.push_back( Property::StringValuePair( "type", "Actor" ) );
  map.push_back( Property::StringValuePair( "size", Vector3::ONE ) );
  map.push_back( Property::StringValuePair( "position", Vector3::XAXIS ) );
  map.push_back( Property::StringValuePair( "scale", Vector3::ONE ) );
  map.push_back( Property::StringValuePair( "visible", false ) );
  map.push_back( Property::StringValuePair( "color", Color::MAGENTA ) );
  map.push_back( Property::StringValuePair( "name", "MyActor" ) );
  map.push_back( Property::StringValuePair( "color-mode", "USE_PARENT_COLOR" ) );
  map.push_back( Property::StringValuePair( "inherit-shader-effect", false ) );
  map.push_back( Property::StringValuePair( "sensitive", false ) );
  map.push_back( Property::StringValuePair( "leave-required", true ) );
  map.push_back( Property::StringValuePair( "position-inheritance", "DONT_INHERIT_POSITION" ) );
  map.push_back( Property::StringValuePair( "draw-mode", "STENCIL" ) );
  map.push_back( Property::StringValuePair( "inherit-rotation", false ) );
  map.push_back( Property::StringValuePair( "inherit-scale", false ) );

  // Default properties
  {
    Actor handle = NewActor( map );
    DALI_TEST_CHECK( handle );

    Stage::GetCurrent().Add( handle );
    application.SendNotification();
    application.Render();

    DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetInheritShaderEffect(), false, TEST_LOCATION );
    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.IsRotationInherited(), false, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );

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

  // Check Anchor point and parent origin vector3s
  map.push_back( Property::StringValuePair( "parent-origin", ParentOrigin::TOP_CENTER ) );
  map.push_back( Property::StringValuePair( "anchor-point", AnchorPoint::TOP_LEFT ) );
  {
    Actor handle = NewActor( map );
    DALI_TEST_CHECK( handle );

    Stage::GetCurrent().Add( handle );
    application.SendNotification();
    application.Render();

    DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION );

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

  // Check Anchor point and parent origin STRINGS
  map.erase( map.end() - 2, map.end() ); // delete previously added parent origin and anchor point
  map.push_back( Property::StringValuePair( "parent-origin", "BACK_TOP_LEFT" ) );
  map.push_back( Property::StringValuePair( "anchor-point", "FRONT_CENTER_LEFT" ) );
  {
    Actor handle = NewActor( map );
    DALI_TEST_CHECK( handle );

    Stage::GetCurrent().Add( handle );
    application.SendNotification();
    application.Render();

    DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::BACK_TOP_LEFT, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::FRONT_CENTER_LEFT, TEST_LOCATION );

    Stage::GetCurrent().Remove( handle );
  }
  END_TEST;
}
예제 #2
0
int UtcDaliScriptingNewImage(void)
{
  TestApplication application;

  Property::Map map;
  map.push_back( Property::StringValuePair( "filename", "TEST_FILE" ) );

  // Filename only
  {
    Image image = NewImage( map );
    DALI_TEST_EQUALS( "TEST_FILE", image.GetFilename(), TEST_LOCATION );
  }

  // load-policy
  map.push_back( Property::StringValuePair( "load-policy", "" ) );
  {
    const StringEnum values[] =
    {
        { "IMMEDIATE", Image::Immediate },
        { "ON_DEMAND", Image::OnDemand }
    };
    TestEnumStrings< Image::LoadPolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetLoadPolicy, &NewImage );
  }

  // release-policy
  map.push_back( Property::StringValuePair( "release-policy", "" ) );
  {
    const StringEnum values[] =
    {
        { "UNUSED", Image::Unused },
        { "NEVER", Image::Never }
    };
    TestEnumStrings< Image::ReleasePolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
  }

  // float width and height
  map.push_back( Property::StringValuePair( "width", (float) 10.0f ) );
  map.push_back( Property::StringValuePair( "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 );
  }

  // int width and height
  map.erase( map.end() - 2, map.end() );
  map.push_back( Property::StringValuePair( "width", 50 ) );
  map.push_back( Property::StringValuePair( "height", 70 ) );
  {
    Image image = NewImage( map );
    DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
    DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
  }

  //map.erase( map.end() - 2, map.end() );

  // pixel-format
  map.push_back( Property::StringValuePair( "pixel-format", "" ) );
  {
    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 },
        { "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 },
        { "A8", Pixel::A8 }, // Checked already but reset so that BitmapImage works
    };
    TestEnumStrings< Pixel::Format, ImageAttributes >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ImageAttributes::GetPixelFormat, &NewImageAttributes );
  }

  // scaling-mode
  map.push_back( Property::StringValuePair( "scaling-mode", "" ) );
  {
    const StringEnum 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 );
  }

  // crop
  map.push_back( Property::StringValuePair( "crop", Vector4( 50, 60, 70, 80 ) ) );
  {
    Image image = NewImage( map );
    ImageAttributes attributes = image.GetAttributes();
    Rect<float> crop = attributes.GetCrop();
    DALI_TEST_EQUALS( crop.x, 50, TEST_LOCATION );
    DALI_TEST_EQUALS( crop.y, 60, TEST_LOCATION );
    DALI_TEST_EQUALS( crop.width, 70, TEST_LOCATION );
    DALI_TEST_EQUALS( crop.height, 80, TEST_LOCATION );
  }

  // type FrameBufferImage
  map.push_back( Property::StringValuePair( "type", "FrameBufferImage" ) );
  {
    Image image = NewImage( map );
    DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
  }
  // type BitMapImage
  (map.end() - 1)->second = "BitmapImage";
  {
    Image image = NewImage( map );
    DALI_TEST_CHECK( BitmapImage::DownCast( image ) );
  }
  // type Image
  (map.end() - 1)->second = "Image";
  {
    Image image = NewImage( map );
    DALI_TEST_CHECK( Image::DownCast( image ) );
    DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
    DALI_TEST_CHECK( !BitmapImage::DownCast( image ) );
  }
  END_TEST;
}