X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-VisualFactory.cpp;h=79b2f69fa7b37c7124e178323d9db4ed9b09359b;hp=f0bc1c8f1647e5a196c969f2afba36c261dd2977;hb=e6757fc2f8c05d6da32f329a874b0ae129abf3d4;hpb=f31a7b83577275e88914a00f37c4ff5224336553 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp index f0bc1c8..79b2f69 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp @@ -17,11 +17,13 @@ #include #include #include +#include #include #include #include #include -#include +#include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -32,13 +34,17 @@ typedef NinePatchImage::StretchRanges StretchRanges; const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg"; const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.png"; - const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg"; const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj"; const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl"; const char* TEST_SIMPLE_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube-Points-Only.obj"; const char* TEST_SIMPLE_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal-Simple.mtl"; +// resolution: 34*34, pixel format: RGBA8888 +static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png"; +// resolution: 600*600, pixel format: RGB888 +static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg"; + Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat ) { Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN ); @@ -175,7 +181,7 @@ Integration::ResourcePointer CustomizeNinePatch( TestApplication& application, void TestVisualRender( ToolkitTestApplication& application, Actor& actor, - Visual& visual, + Visual::Base& visual, std::size_t expectedSamplers = 0, ImageDimensions imageDimensions = ImageDimensions(), Integration::ResourcePointer resourcePtr = Integration::ResourcePointer()) @@ -250,7 +256,7 @@ int UtcDaliVisualFactoryGet(void) VisualFactory newFactory = VisualFactory::Get(); DALI_TEST_CHECK( newFactory ); - // Check that renderer factory is a singleton + // Check that visual factory is a singleton DALI_TEST_CHECK(factory == newFactory); END_TEST; @@ -294,10 +300,10 @@ int UtcDaliVisualFactoryGetColorVisual1(void) Property::Map propertyMap; Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f ); - propertyMap.Insert("rendererType", "COLOR"); - propertyMap.Insert("mixColor", testColor); + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, testColor); - Visual visual = factory.CreateVisual(propertyMap); + Visual::Base visual = factory.CreateVisual(propertyMap); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -321,9 +327,9 @@ int UtcDaliVisualFactoryGetColorVisual2(void) Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f ); Dali::Property::Map map; - map[ "rendererType" ] = "COLOR"; - map[ "mixColor" ] = testColor; - Visual visual = factory.CreateVisual( map ); + map[ Visual::Property::TYPE ] = Visual::COLOR; + map[ ColorVisual::Property::MIX_COLOR ] = testColor; + Visual::Base visual = factory.CreateVisual( map ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -351,11 +357,11 @@ int UtcDaliVisualFactoryGetBorderVisual1(void) Property::Map propertyMap; Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f ); float testSize = 5.f; - propertyMap.Insert("rendererType", "BORDER"); - propertyMap.Insert("borderColor", testColor); - propertyMap.Insert("borderSize", testSize); + propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER); + propertyMap.Insert(BorderVisual::Property::COLOR, testColor); + propertyMap.Insert(BorderVisual::Property::SIZE, testSize); - Visual visual = factory.CreateVisual(propertyMap); + Visual::Base visual = factory.CreateVisual(propertyMap); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -399,10 +405,10 @@ int UtcDaliVisualFactoryGetBorderVisual2(void) float testSize = 5.f; Dali::Property::Map propertyMap; - propertyMap[ "rendererType" ] = "BORDER"; - propertyMap[ "borderColor" ] = testColor; - propertyMap[ "borderSize" ] = testSize; - Visual visual = factory.CreateVisual( propertyMap ); + propertyMap[ Visual::Property::TYPE ] = Visual::BORDER; + propertyMap[ BorderVisual::Property::COLOR ] = testColor; + propertyMap[ BorderVisual::Property::SIZE ] = testSize; + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -433,10 +439,10 @@ int UtcDaliVisualFactoryGetBorderVisual2(void) // enable the anti-aliasing Dali::Property::Map map; - map[ "rendererType" ] = "BORDER"; - map[ "borderColor" ] = testColor; - map[ "borderSize" ] = testSize; - map[ "antiAliasing" ] = true; + map[ Visual::Property::TYPE ] = Visual::BORDER; + map[ BorderVisual::Property::COLOR ] = testColor; + map[ BorderVisual::Property::SIZE ] = testSize; + map[ BorderVisual::Property::ANTI_ALIASING ] = true; visual = factory.CreateVisual( map ); visual.SetOnStage( actor ); @@ -457,25 +463,25 @@ int UtcDaliVisualFactoryGetLinearGradientVisual(void) DALI_TEST_CHECK( factory ); Property::Map propertyMap; - propertyMap.Insert("rendererType", "GRADIENT"); + propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT); Vector2 start(-1.f, -1.f); Vector2 end(1.f, 1.f); - propertyMap.Insert("startPosition", start); - propertyMap.Insert("endPosition", end); - propertyMap.Insert("spreadMethod", "REPEAT"); + propertyMap.Insert(GradientVisual::Property::START_POSITION, start); + propertyMap.Insert(GradientVisual::Property::END_POSITION, end); + propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT); Property::Array stopOffsets; stopOffsets.PushBack( 0.2f ); stopOffsets.PushBack( 0.8f ); - propertyMap.Insert("stopOffset", stopOffsets); + propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets); Property::Array stopColors; stopColors.PushBack( Color::RED ); stopColors.PushBack( Color::GREEN ); - propertyMap.Insert("stopColor", stopColors); + propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors); - Visual visual = factory.CreateVisual(propertyMap); + Visual::Base visual = factory.CreateVisual(propertyMap); DALI_TEST_CHECK( visual ); // A lookup texture is generated and pass to shader as sampler @@ -497,25 +503,25 @@ int UtcDaliVisualFactoryGetRadialGradientVisual(void) DALI_TEST_CHECK( factory ); Property::Map propertyMap; - propertyMap.Insert("rendererType", "GRADIENT"); + propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT); Vector2 center(100.f, 100.f); float radius = 100.f; - propertyMap.Insert("units", "USER_SPACE"); - propertyMap.Insert("center", center); - propertyMap.Insert("radius", radius); + propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE); + propertyMap.Insert(GradientVisual::Property::CENTER, center); + propertyMap.Insert(GradientVisual::Property::RADIUS, radius); Property::Array stopOffsets; stopOffsets.PushBack( 0.0f ); stopOffsets.PushBack( 1.f ); - propertyMap.Insert("stopOffset", stopOffsets); + propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets); Property::Array stopColors; stopColors.PushBack( Color::RED ); stopColors.PushBack( Color::GREEN ); - propertyMap.Insert("stopColor", stopColors); + propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors); - Visual visual = factory.CreateVisual(propertyMap); + Visual::Base visual = factory.CreateVisual(propertyMap); DALI_TEST_CHECK( visual ); // A lookup texture is generated and pass to shader as sampler @@ -542,20 +548,20 @@ int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void) DALI_TEST_CHECK( factory ); Property::Map propertyMap; - propertyMap.Insert("rendererType", "GRADIENT"); + propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT); Vector2 start(-1.f, -1.f); Vector2 end(1.f, 1.f); - propertyMap.Insert("startPosition", start); - propertyMap.Insert("endPosition", end); - propertyMap.Insert("spreadMethod", "REPEAT"); + propertyMap.Insert(GradientVisual::Property::START_POSITION, start); + propertyMap.Insert(GradientVisual::Property::END_POSITION, end); + propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT); Property::Array stopColors; stopColors.PushBack( Color::RED ); stopColors.PushBack( Color::GREEN ); - propertyMap.Insert("stopColor", stopColors); + propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors); - Visual visual = factory.CreateVisual(propertyMap); + Visual::Base visual = factory.CreateVisual(propertyMap); DALI_TEST_CHECK( visual ); // A lookup texture is generated and pass to shader as sampler @@ -571,16 +577,16 @@ int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void) int UtcDaliVisualFactoryGetImageVisual1(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image renderer with a Property::Map" ); + tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image visual with a Property::Map" ); VisualFactory factory = VisualFactory::Get(); DALI_TEST_CHECK( factory ); Property::Map propertyMap; - propertyMap.Insert( "rendererType", "IMAGE" ); - propertyMap.Insert( "url", TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -611,13 +617,13 @@ int UtcDaliVisualFactoryGetImageVisual1(void) int UtcDaliVisualFactoryGetImageVisual2(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image renderer with an image handle" ); + tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image visual with an image handle" ); VisualFactory factory = VisualFactory::Get(); DALI_TEST_CHECK( factory ); Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME); - Visual visual = factory.CreateVisual( image ); + Visual::Base visual = factory.CreateVisual( image ); Actor actor = Actor::New(); // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied. @@ -642,10 +648,170 @@ int UtcDaliVisualFactoryGetImageVisual2(void) END_TEST; } +int UtcDaliVisualFactoryGetImageVisual3(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualFactoryGetImageVisual3: Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas. + const int width=34; + const int height=34; + const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, gImage_34_RGBA ); + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height ); + propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true ); + propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea ); + propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT ); + propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT ); + + Visual::Base visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( visual ); + + Actor actor = Actor::New(); + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + TraceCallStack& texParameterTrace = gl.GetTexParameterTrace(); + texParameterTrace.Enable( true ); + + actor.SetSize( 200.f, 200.f ); + Stage::GetCurrent().Add( actor ); + visual.SetOnStage( actor ); + + // loading started + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + BitmapLoader loader = BitmapLoader::GetLatestCreated(); + DALI_TEST_CHECK( loader ); + loader.WaitForLoading();// waiting until the image to be loaded + DALI_TEST_CHECK( loader.IsLoaded() ); + + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + + DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); + + // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called + std::stringstream out; + out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT; + DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) ); + out.str(""); + out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT; + DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) ); + + // test the uniforms which used to handle the wrap mode + Renderer renderer = actor.GetRendererAt( 0u ); + DALI_TEST_CHECK( renderer ); + + Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) ); + DALI_TEST_EQUALS( pixelAreaValue.Get(), pixelArea, TEST_LOCATION ); + Vector4 pixelAreaUniform; + DALI_TEST_CHECK( gl.GetUniformValue( "pixelArea", pixelAreaUniform ) ); + DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION ); + + Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) ); + Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 ); + DALI_TEST_EQUALS( wrapModeValue.Get(), wrapMode, TEST_LOCATION ); + Vector2 wrapModeUniform; + DALI_TEST_CHECK( gl.GetUniformValue( "wrapMode", wrapModeUniform ) ); + DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION ); + + visual.SetOffStage( actor ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + + END_TEST; +} + +int UtcDaliVisualFactoryGetImageVisual4(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualFactoryGetImageVisual4: Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas. + const int width=600; + const int height=600; + const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, gImage_600_RGB ); + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height ); + propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true ); + propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea ); + propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT ); + propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT ); + + Visual::Base visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( visual ); + + Actor actor = Actor::New(); + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + TraceCallStack& texParameterTrace = gl.GetTexParameterTrace(); + texParameterTrace.Enable( true ); + + actor.SetSize( 200.f, 200.f ); + Stage::GetCurrent().Add( actor ); + visual.SetOnStage( actor ); + + // loading started + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + BitmapLoader loader = BitmapLoader::GetLatestCreated(); + DALI_TEST_CHECK( loader ); + loader.WaitForLoading();// waiting until the image to be loaded + DALI_TEST_CHECK( loader.IsLoaded() ); + + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + + DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); + + // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters + std::stringstream out; + out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT; + DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) ); + out.str(""); + out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT; + DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) ); + + // test the uniforms which used to handle the wrap mode + Renderer renderer = actor.GetRendererAt( 0u ); + DALI_TEST_CHECK( renderer ); + + Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) ); + DALI_TEST_EQUALS( pixelAreaValue.Get(), pixelArea, TEST_LOCATION ); + Vector4 pixelAreaUniform; + DALI_TEST_CHECK( gl.GetUniformValue( "pixelArea", pixelAreaUniform ) ); + DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION ); + + Property::Index wrapModeIndex = renderer.GetPropertyIndex( "wrapMode" ); + DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX); + + visual.SetOffStage( actor ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + + END_TEST; +} + int UtcDaliVisualFactoryGetNPatchVisual1(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch renderer with a Property::Map" ); + tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map" ); VisualFactory factory = VisualFactory::Get(); DALI_TEST_CHECK( factory ); @@ -659,11 +825,11 @@ int UtcDaliVisualFactoryGetNPatchVisual1(void) Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY ); Property::Map propertyMap; - propertyMap.Insert( "rendererType", "IMAGE" ); - propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME ); + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME ); { tet_infoline( "whole grid" ); - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -679,10 +845,10 @@ int UtcDaliVisualFactoryGetNPatchVisual1(void) DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); } - propertyMap.Insert( "borderOnly", true ); + propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true ); { tet_infoline( "border only" ); - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -704,7 +870,7 @@ int UtcDaliVisualFactoryGetNPatchVisual1(void) int UtcDaliVisualFactoryGetNPatchVisual2(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch renderer with a Property::Map" ); + tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch visual with a Property::Map" ); VisualFactory factory = VisualFactory::Get(); DALI_TEST_CHECK( factory ); @@ -723,10 +889,10 @@ int UtcDaliVisualFactoryGetNPatchVisual2(void) Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY ); Property::Map propertyMap; - propertyMap.Insert( "rendererType", "IMAGE" ); - propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME ); + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME ); { - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -745,10 +911,10 @@ int UtcDaliVisualFactoryGetNPatchVisual2(void) DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); } - propertyMap.Insert( "borderOnly", true ); + propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true ); { tet_infoline( "border only" ); - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -772,7 +938,7 @@ int UtcDaliVisualFactoryGetNPatchVisual2(void) int UtcDaliVisualFactoryGetNPatchVisual3(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch renderer with an image url" ); + tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch visual with an image url" ); VisualFactory factory = VisualFactory::Get(); DALI_TEST_CHECK( factory ); @@ -785,7 +951,7 @@ int UtcDaliVisualFactoryGetNPatchVisual3(void) stretchRangesY.PushBack( Uint16Pair( 4, 5 ) ); Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY ); - Visual visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() ); + Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -824,7 +990,7 @@ int UtcDaliVisualFactoryGetNPatchVisual4(void) stretchRangesY.PushBack( Uint16Pair( 25, 27 ) ); Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY ); - Visual visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() ); + Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -852,7 +1018,7 @@ int UtcDaliVisualFactoryGetNPatchVisualN1(void) VisualFactory factory = VisualFactory::Get(); DALI_TEST_CHECK( factory ); - Visual visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() ); + Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -879,16 +1045,16 @@ int UtcDaliVisualFactoryGetNPatchVisualN2(void) //This should still load but display an error image ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid Property::Map" ); + tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" ); VisualFactory factory = VisualFactory::Get(); DALI_TEST_CHECK( factory ); Property::Map propertyMap; - propertyMap.Insert( "rendererType", 111 ); - propertyMap.Insert( "url", "ERROR.9.jpg" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" ); - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); Actor actor = Actor::New(); @@ -910,13 +1076,33 @@ int UtcDaliVisualFactoryGetNPatchVisualN2(void) END_TEST; } +int UtcDaliVisualFactoryGetNPatchVisualN3(void) +{ + // Passing in an invalid visual type so we should not get a visual + + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, 111 ); + propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" ); + + Visual::Base visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( !visual ); + + END_TEST; +} + int UtcDaliVisualFactoryGetSvgVisual(void) { ToolkitTestApplication application; tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" ); VisualFactory factory = VisualFactory::Get(); - Visual visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() ); + Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() ); DALI_TEST_CHECK( visual ); TestGlAbstraction& gl = application.GetGlAbstraction(); @@ -950,7 +1136,7 @@ int UtcDaliVisualFactoryGetSvgVisual(void) END_TEST; } -//Creates a mesh renderer from the given propertyMap and tries to load it on stage in the given application. +//Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application. //This is expected to succeed, which will then pass the test. void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application ) { @@ -958,7 +1144,7 @@ void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplic DALI_TEST_CHECK( factory ); //Create a mesh visual. - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); //Create an actor on stage to house the visual. @@ -1004,7 +1190,7 @@ void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTest DALI_TEST_CHECK( factory ); //Create a mesh visual. - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); //Create an actor on stage to house the visual. @@ -1049,8 +1235,8 @@ int UtcDaliVisualFactoryGetMeshVisual1(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); //Test to see if mesh loads correctly. MeshVisualLoadsCorrectlyTest( propertyMap, application ); @@ -1069,10 +1255,10 @@ int UtcDaliVisualFactoryGetMeshVisual2(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); - propertyMap.Insert( "materialUrl", "" ); - propertyMap.Insert( "texturesPath", "" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" ); //Test to see if mesh loads correctly. MeshVisualLoadsCorrectlyTest( propertyMap, application ); @@ -1090,10 +1276,10 @@ int UtcDaliVisualFactoryGetMeshVisual3(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); - propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME ); - propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" ); //Test to see if mesh loads correctly. MeshVisualLoadsCorrectlyTest( propertyMap, application ); @@ -1112,10 +1298,10 @@ int UtcDaliVisualFactoryGetMeshVisual4(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); - propertyMap.Insert( "materialUrl", TEST_SIMPLE_MTL_FILE_NAME ); - propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" ); //Test to see if mesh loads correctly. MeshVisualLoadsCorrectlyTest( propertyMap, application ); @@ -1134,11 +1320,11 @@ int UtcDaliVisualFactoryGetMeshVisual5(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); - propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME ); - propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" ); - propertyMap.Insert( "shaderType", "DIFFUSE_TEXTURE" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" ); + propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING ); //Test to see if mesh loads correctly. MeshVisualLoadsCorrectlyTest( propertyMap, application ); @@ -1157,11 +1343,11 @@ int UtcDaliVisualFactoryGetMeshVisual6(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); - propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME ); - propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" ); - propertyMap.Insert( "shaderType", "TEXTURELESS" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" ); + propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING ); //Test to see if mesh loads correctly. MeshVisualLoadsCorrectlyTest( propertyMap, application ); @@ -1179,11 +1365,11 @@ int UtcDaliVisualFactoryGetMeshVisual7(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); - propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME ); - propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" ); - propertyMap.Insert( "lightPosition", Vector3( 0.0, 1.0, 2.0 ) ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" ); + propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) ); //Test to see if mesh loads correctly. MeshVisualLoadsCorrectlyTest( propertyMap, application ); @@ -1202,10 +1388,10 @@ int UtcDaliVisualFactoryGetMeshVisual8(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_SIMPLE_OBJ_FILE_NAME ); - propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME ); - propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" ); //Test to see if mesh loads correctly. MeshVisualLoadsCorrectlyTest( propertyMap, application ); @@ -1223,9 +1409,9 @@ int UtcDaliVisualFactoryGetMeshVisualN1(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME ); - propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" ); //Test to see if mesh doesn't load with these properties, as expected. MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application ); @@ -1244,10 +1430,10 @@ int UtcDaliVisualFactoryGetMeshVisualN2(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); - propertyMap.Insert( "materialUrl", "invalid" ); - propertyMap.Insert( "texturesPath", "also invalid" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" ); //Test to see if mesh doesn't load with these properties, as expected. MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application ); @@ -1266,10 +1452,10 @@ int UtcDaliVisualFactoryGetMeshVisualN3(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "MESH" ); - propertyMap.Insert( "objectUrl", "invalid" ); - propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME ); - propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::MESH ); + propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" ); + propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME ); + propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" ); //Test to see if mesh doesn't load with these properties, as expected. MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application ); @@ -1284,7 +1470,7 @@ void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestA DALI_TEST_CHECK( factory ); //Create a primitive visual. - Visual visual = factory.CreateVisual( propertyMap ); + Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); //Create an actor on stage to house the visual. @@ -1324,8 +1510,8 @@ int UtcDaliVisualFactoryGetPrimitiveVisual1(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); - propertyMap.Insert( "shape", "CUBE" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); + propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE ); //Test to see if shape loads correctly. TestPrimitiveVisualWithProperties( propertyMap, application ); @@ -1343,18 +1529,18 @@ int UtcDaliVisualFactoryGetPrimitiveVisual2(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); - propertyMap.Insert( "shape", "CUBE" ); - propertyMap.Insert( "shapeColor", Vector4( 0.5, 0.5, 0.5, 1.0 ) ); - propertyMap.Insert( "slices", 10 ); - propertyMap.Insert( "stacks", 20 ); - propertyMap.Insert( "scaleTopRadius", 30.0f ); - propertyMap.Insert( "scaleBottomRadius", 40.0f ); - propertyMap.Insert( "scaleHeight", 50.0f ); - propertyMap.Insert( "scaleRadius", 60.0f ); - propertyMap.Insert( "bevelPercentage", 0.7f ); - propertyMap.Insert( "bevelSmoothness", 0.8f ); - propertyMap.Insert( "lightPosition", Vector3( 0.9, 1.0, 1.1 ) ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); + propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE ); + propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 ); + propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f ); + propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f ); + propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f ); + propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) ); //Test to see if shape loads correctly. TestPrimitiveVisualWithProperties( propertyMap, application ); @@ -1372,11 +1558,11 @@ int UtcDaliVisualFactoryGetPrimitiveVisual3(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); - propertyMap.Insert( "shape", "SPHERE" ); - propertyMap.Insert( "shapeColor", Vector4( 0.5, 0.5, 0.5, 1.0 ) ); - propertyMap.Insert( "slices", 10 ); - propertyMap.Insert( "stacks", 20 ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); + propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE ); + propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 ); + propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 ); //Test to see if shape loads correctly. TestPrimitiveVisualWithProperties( propertyMap, application ); @@ -1394,13 +1580,13 @@ int UtcDaliVisualFactoryGetPrimitiveVisual4(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); - propertyMap.Insert( "shape", "CONICAL_FRUSTRUM" ); - propertyMap.Insert( "shapeColor", Vector4( 0.5, 0.5, 0.5, 1.0 ) ); - propertyMap.Insert( "slices", 10 ); - propertyMap.Insert( "scaleTopRadius", 30.0f ); - propertyMap.Insert( "scaleBottomRadius", 40.0f ); - propertyMap.Insert( "scaleHeight", 50.0f ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); + propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM ); + propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f ); //Test to see if shape loads correctly. TestPrimitiveVisualWithProperties( propertyMap, application ); @@ -1418,10 +1604,10 @@ int UtcDaliVisualFactoryGetPrimitiveVisual5(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); - propertyMap.Insert( "shape", "BEVELLED_CUBE" ); - propertyMap.Insert( "shapeColor", Vector4( 0.5, 0.5, 0.5, 1.0 ) ); - propertyMap.Insert( "bevelPercentage", 0.7f ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); + propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE ); + propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f ); //Test to see if shape loads correctly. TestPrimitiveVisualWithProperties( propertyMap, application ); @@ -1439,9 +1625,9 @@ int UtcDaliVisualFactoryGetPrimitiveVisual6(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); - propertyMap.Insert( "shape", "OCTAHEDRON" ); - propertyMap.Insert( "shapeColor", Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); + propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON ); + propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) ); //Test to see if shape loads correctly. TestPrimitiveVisualWithProperties( propertyMap, application ); @@ -1459,12 +1645,12 @@ int UtcDaliVisualFactoryGetPrimitiveVisual7(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); - propertyMap.Insert( "shape", "CONE" ); - propertyMap.Insert( "shapeColor", Vector4( 0.5, 0.5, 0.5, 1.0 ) ); - propertyMap.Insert( "slices", 10 ); - propertyMap.Insert( "scaleTopRadius", 30.0f ); - propertyMap.Insert( "scaleHeight", 50.0f ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); + propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE ); + propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f ); + propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f ); //Test to see if shape loads correctly. TestPrimitiveVisualWithProperties( propertyMap, application ); @@ -1482,10 +1668,10 @@ int UtcDaliVisualFactoryGetPrimitiveVisual8(void) //Set up visual properties. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); - propertyMap.Insert( "shape", "SPHERE" ); - propertyMap.Insert( "shapeColor", Vector4( 0.5, 0.5, 0.5, 1.0 ) ); - propertyMap.Insert( "lightPosition", Vector3( 0.0, 1.0, 2.0 ) ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); + propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE ); + propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) ); + propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) ); //Test to see if shape loads correctly. TestPrimitiveVisualWithProperties( propertyMap, application ); @@ -1493,7 +1679,7 @@ int UtcDaliVisualFactoryGetPrimitiveVisual8(void) END_TEST; } -//Test if primitive shape renderer handles the case of not being passed a specific shape to use. +//Test if primitive shape visual handles the case of not being passed a specific shape to use. int UtcDaliVisualFactoryGetPrimitiveVisualN1(void) { //Set up test application first, so everything else can be handled. @@ -1503,10 +1689,117 @@ int UtcDaliVisualFactoryGetPrimitiveVisualN1(void) //Set up visual properties, without supplying shape. Property::Map propertyMap; - propertyMap.Insert( "rendererType", "PRIMITIVE" ); + propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); //Test to see if shape loads regardless of missing input. TestPrimitiveVisualWithProperties( propertyMap, application ); END_TEST; } + +int UtcDaliVisualFactoryGetBatchImageVisual1(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual1: Request a Batch Image visual with a Property::Map" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + + Visual::Base visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( visual ); + + Actor actor = Actor::New(); + + actor.SetSize( 200.0f, 200.0f ); + Stage::GetCurrent().Add( actor ); + visual.SetSize( Vector2( 200.0f, 200.0f ) ); + + // Test SetOnStage(). + visual.SetOnStage( actor ); + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + + application.SendNotification(); + application.Render(); + + // Test SetOffStage(). + visual.SetOffStage( actor ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + + END_TEST; +} + +int UtcDaliVisualFactoryGetBatchImageVisual2(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual2: Request Batch Image visual from an Image Visual with batchingEnabled set" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + Property::Map propertyMap; + // Create a normal Image Visual. + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + // Instruct the factory to change Image Visuals to Batch-Image Visuals. + propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); + + // Properties for the Batch-Image Visual. + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + + Visual::Base visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( visual ); + + // Check that a Batch-Image visual was created instead of an Image visual. + Property::Map resultMap; + visual.CreatePropertyMap( resultMap ); + + Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), (int)Visual::IMAGE, TEST_LOCATION ); + + Actor actor = Actor::New(); + + actor.SetSize( 200.0f, 200.0f ); + Stage::GetCurrent().Add( actor ); + visual.SetSize( Vector2( 200.0f, 200.0f ) ); + + // Test SetOnStage(). + visual.SetOnStage( actor ); + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + + application.SendNotification(); + application.Render(); + + // Test SetOffStage(). + visual.SetOffStage( actor ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + + END_TEST; +} + +int UtcDaliVisualFactoryGetBatchImageVisual3(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual3: Create an ImageView that uses a batched visual internally" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + // Create a property-map that enables batching. + Property::Map propertyMap; + propertyMap.Insert( Dali::Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); + + // Create an ImageView, passing the property-map in to instruct it to use batching. + Toolkit::ImageView imageView = Toolkit::ImageView::New(); + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap ); + + imageView.SetSize( 200.0f, 200.0f ); + Stage::GetCurrent().Add( imageView ); + + END_TEST; +}