+int UtcDaliControlRendererSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetNaturalSize" );
+
+ RendererFactory factory = RendererFactory::Get();
+ Vector2 rendererSize( 20.f, 30.f );
+ Vector2 naturalSize;
+
+ // color renderer
+ ControlRenderer colorRenderer = factory.GetControlRenderer( Color::MAGENTA );
+ colorRenderer.SetSize( rendererSize );
+ DALI_TEST_EQUALS( colorRenderer.GetSize(), rendererSize, TEST_LOCATION );
+ colorRenderer.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
+
+ // image renderer
+ Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
+ ControlRenderer imageRenderer = factory.GetControlRenderer( image );
+ imageRenderer.SetSize( rendererSize );
+ DALI_TEST_EQUALS( imageRenderer.GetSize(), rendererSize, TEST_LOCATION );
+ imageRenderer.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
+
+ // n patch renderer
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ Vector2 testSize(80.f, 160.f);
+ platform.SetClosestImageSize(testSize);
+ image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
+ ControlRenderer nPatchRenderer = factory.GetControlRenderer( image );
+ nPatchRenderer.SetSize( rendererSize );
+ DALI_TEST_EQUALS( nPatchRenderer.GetSize(), rendererSize, TEST_LOCATION );
+ nPatchRenderer.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, testSize, TEST_LOCATION );
+
+ // border renderer
+ float borderSize = 5.f;
+ ControlRenderer borderRenderer = factory.GetControlRenderer( borderSize, Color::RED );
+ borderRenderer.SetSize( rendererSize );
+ DALI_TEST_EQUALS( borderRenderer.GetSize(), rendererSize, TEST_LOCATION );
+ borderRenderer.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
+
+ // gradient renderer
+ Property::Map propertyMap;
+ propertyMap.Insert("rendererType", "gradient");
+ Vector2 start(-1.f, -1.f);
+ Vector2 end(1.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("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;
+}
+