#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali/devel-api/rendering/renderer.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/texture-set.h>
#include <dali/devel-api/rendering/shader.h>
#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
{
const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg";
+const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
}
void dali_control_renderer_startup(void)
RendererFactory factory = RendererFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "colorRenderer");
- propertyMap.Insert("blendColor", Color::BLUE);
+ propertyMap.Insert("rendererType", "color");
+ propertyMap.Insert("mixColor", Color::BLUE);
ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
ControlRenderer controlRendererCopy( controlRenderer );
RendererFactory factory = RendererFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "colorRenderer");
- propertyMap.Insert("blendColor", Color::BLUE);
+ propertyMap.Insert("rendererType", "color");
+ propertyMap.Insert("mixColor", Color::BLUE);
ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
controlRenderer.SetDepthIndex( 1.f );
Stage::GetCurrent().Add( actor );
controlRenderer.SetOnStage( actor );
- DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), 1.f, TEST_LOCATION );
+ int depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
+ DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION );
DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), 1.f, TEST_LOCATION );
controlRenderer.SetDepthIndex( -1.f );
- DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), -1.f, TEST_LOCATION );
+ depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
+ DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION );
DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), -1.f, TEST_LOCATION );
END_TEST;
// gradient renderer
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "gradientRenderer");
+ propertyMap.Insert("rendererType", "gradient");
Vector2 start(-1.f, -1.f);
Vector2 end(1.f, 1.f);
- propertyMap.Insert("gradientStartPosition", start);
- propertyMap.Insert("gradientEndPosition", end);
- propertyMap.Insert("gradientStopOffset", Vector2(0.f, 1.f));
+ propertyMap.Insert("startPosition", start);
+ propertyMap.Insert("endPosition", end);
+ propertyMap.Insert("stopOffset", Vector2(0.f, 1.f));
Property::Array stopColors;
stopColors.PushBack( Color::RED );
stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("gradientStopColor", stopColors);
+ propertyMap.Insert("stopColor", stopColors);
ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
gradientRenderer.SetSize( rendererSize );
DALI_TEST_EQUALS( gradientRenderer.GetSize(), rendererSize, TEST_LOCATION );
gradientRenderer.GetNaturalSize(naturalSize);
DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
+ //svg renderer
+ ControlRenderer svgRenderer = factory.GetControlRenderer( TEST_SVG_FILE_NAME );
+ svgRenderer.SetSize( rendererSize );
+ DALI_TEST_EQUALS( svgRenderer.GetSize(), rendererSize, TEST_LOCATION );
+ svgRenderer.GetNaturalSize(naturalSize);
+ // TEST_SVG_FILE:
+ // <svg width="100" height="100">
+ // <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
+ // </svg>
+ DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION );
END_TEST;
}
RendererFactory factory = RendererFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "colorRenderer");
- propertyMap.Insert("blendColor", Color::BLUE);
+ propertyMap.Insert("rendererType", "color");
+ propertyMap.Insert("mixColor", Color::BLUE);
ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
Actor actor = Actor::New();
RendererFactory factory = RendererFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "colorRenderer");
- propertyMap.Insert("blendColor", Color::BLUE);
+ propertyMap.Insert("rendererType", "color");
+ propertyMap.Insert("mixColor", Color::BLUE);
ControlRenderer colorRenderer = factory.GetControlRenderer( propertyMap );
Property::Map resultMap;
Property::Value* typeValue = resultMap.Find( "rendererType", Property::STRING );
DALI_TEST_CHECK( typeValue );
- DALI_TEST_CHECK( typeValue->Get<std::string>() == "colorRenderer" );
+ DALI_TEST_CHECK( typeValue->Get<std::string>() == "color" );
- Property::Value* colorValue = resultMap.Find( "blendColor", Property::VECTOR4 );
+ Property::Value* colorValue = resultMap.Find( "mixColor", Property::VECTOR4 );
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
factory.ResetRenderer( colorRenderer, actor, Color::CYAN );
colorRenderer.CreatePropertyMap( resultMap );
- colorValue = resultMap.Find( "blendColor", Property::VECTOR4 );
+ colorValue = resultMap.Find( "mixColor", Property::VECTOR4 );
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
RendererFactory factory = RendererFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "borderRenderer");
+ propertyMap.Insert("rendererType", "border");
propertyMap.Insert("borderColor", Color::BLUE);
propertyMap.Insert("borderSize", 5.f);
ControlRenderer borderRenderer = factory.GetControlRenderer( propertyMap );
// check the property values from the returned map from control renderer
Property::Value* typeValue = resultMap.Find( "rendererType", Property::STRING );
DALI_TEST_CHECK( typeValue );
- DALI_TEST_CHECK( typeValue->Get<std::string>() == "borderRenderer" );
+ DALI_TEST_CHECK( typeValue->Get<std::string>() == "border" );
Property::Value* colorValue = resultMap.Find( "borderColor", Property::VECTOR4 );
DALI_TEST_CHECK( colorValue );
typeValue = resultMap.Find( "rendererType", Property::STRING );
DALI_TEST_CHECK( typeValue );
- DALI_TEST_CHECK( typeValue->Get<std::string>() == "borderRenderer" );
+ DALI_TEST_CHECK( typeValue->Get<std::string>() == "border" );
- colorValue = resultMap.Find( "borderColor", Property::VECTOR4 );
+ colorValue = resultMap.Find( "borderColor", Property::VECTOR4 );
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "gradientRenderer");
+ propertyMap.Insert("rendererType", "gradient");
Vector2 start(-1.f, -1.f);
Vector2 end(1.f, 1.f);
- propertyMap.Insert("gradientStartPosition", start);
- propertyMap.Insert("gradientEndPosition", end);
- propertyMap.Insert("gradientSpreadMethod", "repeat");
+ propertyMap.Insert("startPosition", start);
+ propertyMap.Insert("endPosition", end);
+ propertyMap.Insert("spreadMethod", "repeat");
- propertyMap.Insert("gradientStopOffset", Vector2(0.2f, 0.8f));
+ propertyMap.Insert("stopOffset", Vector2(0.2f, 0.8f));
Property::Array stopColors;
stopColors.PushBack( Color::RED );
stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("gradientStopColor", stopColors);
+ propertyMap.Insert("stopColor", stopColors);
ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
// check the property values from the returned map from control renderer
Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "gradientRenderer" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "gradient" );
- value = resultMap.Find( "gradientUnits", Property::STRING );
+ value = resultMap.Find( "units", Property::STRING );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == "objectBoundingBox" );
- value = resultMap.Find( "gradientSpreadMethod", Property::STRING );
+ value = resultMap.Find( "spreadMethod", Property::STRING );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == "repeat" );
- value = resultMap.Find( "gradientStartPosition", Property::VECTOR2 );
+ value = resultMap.Find( "startPosition", Property::VECTOR2 );
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- value = resultMap.Find( "gradientEndPosition", Property::VECTOR2 );
+ value = resultMap.Find( "endPosition", Property::VECTOR2 );
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- value = resultMap.Find( "gradientStopOffset", Property::ARRAY );
+ value = resultMap.Find( "stopOffset", Property::ARRAY );
DALI_TEST_CHECK( value );
Property::Array* offsetArray = value->GetArray();
DALI_TEST_CHECK( offsetArray->Count() == 2 );
DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.2f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.8f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- value = resultMap.Find( "gradientStopColor", Property::ARRAY );
+ value = resultMap.Find( "stopColor", Property::ARRAY );
DALI_TEST_CHECK( value );
Property::Array* colorArray = value->GetArray();
DALI_TEST_CHECK( colorArray->Count() == 2 );
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "gradientRenderer");
+ propertyMap.Insert("rendererType", "gradient");
Vector2 center(100.f, 100.f);
float radius = 100.f;
- propertyMap.Insert("gradientUnits", "userSpace");
- propertyMap.Insert("gradientCenter", center);
- propertyMap.Insert("gradientRadius", radius);
- propertyMap.Insert("gradientStopOffset", Vector3(0.1f, 0.3f, 1.1f));
+ propertyMap.Insert("units", "userSpace");
+ propertyMap.Insert("center", center);
+ propertyMap.Insert("radius", radius);
+ propertyMap.Insert("stopOffset", Vector3(0.1f, 0.3f, 1.1f));
Property::Array stopColors;
stopColors.PushBack( Color::RED );
stopColors.PushBack( Color::BLACK );
stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("gradientStopColor", stopColors);
+ propertyMap.Insert("stopColor", stopColors);
ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
DALI_TEST_CHECK( gradientRenderer );
// check the property values from the returned map from control renderer
Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "gradientRenderer" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "gradient" );
- value = resultMap.Find( "gradientUnits", Property::STRING );
+ value = resultMap.Find( "units", Property::STRING );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == "userSpace" );
- value = resultMap.Find( "gradientSpreadMethod", Property::STRING );
+ value = resultMap.Find( "spreadMethod", Property::STRING );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == "pad" );
- value = resultMap.Find( "gradientCenter", Property::VECTOR2 );
+ value = resultMap.Find( "center", Property::VECTOR2 );
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( value->Get<Vector2>(), center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- value = resultMap.Find( "gradientRadius", Property::FLOAT );
+ value = resultMap.Find( "radius", Property::FLOAT );
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( value->Get<float>(), radius , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- value = resultMap.Find( "gradientStopOffset", Property::ARRAY );
+ value = resultMap.Find( "stopOffset", Property::ARRAY );
DALI_TEST_CHECK( value );
Property::Array* offsetArray = value->GetArray();
DALI_TEST_CHECK( offsetArray->Count() == 3 );
// any stop value will be clamped to [0.0, 1.0];
DALI_TEST_EQUALS( offsetArray->GetElementAt(2).Get<float>(), 1.0f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- value = resultMap.Find( "gradientStopColor", Property::ARRAY );
+ value = resultMap.Find( "stopColor", Property::ARRAY );
DALI_TEST_CHECK( value );
Property::Array* colorArray = value->GetArray();
DALI_TEST_CHECK( colorArray->Count() == 3 );
RendererFactory factory = RendererFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "imageRenderer" );
- propertyMap.Insert( "imageUrl", TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( "imageDesiredWidth", 20 );
- propertyMap.Insert( "imageDesiredHeight", 30 );
- propertyMap.Insert( "imageFittingMode", "fitHeight" );
- propertyMap.Insert( "imageSamplingMode", "boxThenNearest" );
+ propertyMap.Insert( "rendererType", "image" );
+ propertyMap.Insert( "url", TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( "desiredWidth", 20 );
+ propertyMap.Insert( "desiredHeight", 30 );
+ propertyMap.Insert( "fittingMode", "FIT_HEIGHT" );
+ propertyMap.Insert( "samplingMode", "BOX_THEN_NEAREST" );
ControlRenderer imageRenderer = factory.GetControlRenderer(propertyMap);
DALI_TEST_CHECK( imageRenderer );
// check the property values from the returned map from control renderer
Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "imageRenderer" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "image" );
- value = resultMap.Find( "imageUrl", Property::STRING );
+ value = resultMap.Find( "url", Property::STRING );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
- value = resultMap.Find( "imageFittingMode", Property::STRING );
+ value = resultMap.Find( "fittingMode", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "fitHeight" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "FIT_HEIGHT" );
- value = resultMap.Find( "imageSamplingMode", Property::STRING );
+ value = resultMap.Find( "samplingMode", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "boxThenNearest" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "BOX_THEN_NEAREST" );
- value = resultMap.Find( "imageDesiredWidth", Property::INTEGER );
+ value = resultMap.Find( "desiredWidth", Property::INTEGER );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == 20 );
- value = resultMap.Find( "imageDesiredHeight", Property::INTEGER );
+ value = resultMap.Find( "desiredHeight", Property::INTEGER );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == 30 );
value = resultMap.Find( "rendererType", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "imageRenderer" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "image" );
- value = resultMap.Find( "imageUrl", Property::STRING );
+ value = resultMap.Find( "url", Property::STRING );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
- value = resultMap.Find( "imageFittingMode", Property::STRING );
+ value = resultMap.Find( "fittingMode", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "shrinkToFit" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "SHRINK_TO_FIT" );
- value = resultMap.Find( "imageSamplingMode", Property::STRING );
+ value = resultMap.Find( "samplingMode", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "box" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "BOX" );
- value = resultMap.Find( "imageDesiredWidth", Property::INTEGER );
+ value = resultMap.Find( "desiredWidth", Property::INTEGER );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == 100 );
- value = resultMap.Find( "imageDesiredHeight", Property::INTEGER );
+ value = resultMap.Find( "desiredHeight", Property::INTEGER );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == 200 );
RendererFactory factory = RendererFactory::Get();
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "nPatchRenderer" );
- propertyMap.Insert( "imageUrl", TEST_NPATCH_FILE_NAME );
+ propertyMap.Insert( "rendererType", "image" );
+ propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME );
propertyMap.Insert( "borderOnly", true );
ControlRenderer nPatchRenderer = factory.GetControlRenderer( propertyMap );
// check the property values from the returned map from control renderer
Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "nPatchRenderer" );
+ DALI_TEST_CHECK( value->Get<std::string>() == "image" );
- value = resultMap.Find( "imageUrl", Property::STRING );
+ value = resultMap.Find( "url", Property::STRING );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
END_TEST;
}
+
+int UtcDaliControlRendererGetPropertyMap7(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetPropertyMap7: SvgRenderer" );
+
+ // request SvgRenderer with a property map
+ RendererFactory factory = RendererFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "image" );
+ propertyMap.Insert( "url", TEST_SVG_FILE_NAME );
+ ControlRenderer svgRenderer = factory.GetControlRenderer( propertyMap );
+
+ Property::Map resultMap;
+ svgRenderer.CreatePropertyMap( resultMap );
+ // check the property values from the returned map from control renderer
+ Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "image" );
+
+ value = resultMap.Find( "url", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
+
+ // request SvgRenderer with an URL
+ ControlRenderer svgRenderer2 = factory.GetControlRenderer( TEST_SVG_FILE_NAME );
+ resultMap.Clear();
+ svgRenderer2.CreatePropertyMap( resultMap );
+ // check the property values from the returned map from control renderer
+ value = resultMap.Find( "rendererType", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "image" );
+
+ value = resultMap.Find( "url", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
+
+ END_TEST;
+}