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-Visual.cpp;h=35c224edebafa6b08ff294eb2972b8f07a1ec20d;hp=b6080c3705971a0b655560845241e70a3972e2a2;hb=f4c1e7f52d49c3ce033b9ee4c3c7414b06a22d45;hpb=11ed6421771d05113ae1a6510167d8c2557ac20e diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index b6080c3..35c224e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -16,12 +16,15 @@ #include #include +#include + #include #include #include #include #include #include +#include "dummy-control.h" using namespace Dali; using namespace Dali::Toolkit; @@ -34,6 +37,8 @@ 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_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/"; + +const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); } void dali_visual_startup(void) @@ -79,6 +84,25 @@ int UtcDaliVisualCopyAndAssignment(void) END_TEST; } +int UtcDaliVisualSetName01(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualSetName" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + Visual::Base visual = factory.CreateVisual( propertyMap ); + + const char* visualName = "backgroundVisual"; + visual.SetName( visualName ); + + DALI_TEST_EQUALS( visual.GetName(), visualName, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliVisualSetGetDepthIndex(void) { ToolkitTestApplication application; @@ -177,7 +201,7 @@ int UtcDaliVisualSize(void) gradientVisual.GetNaturalSize(naturalSize); DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION ); - //svg visual + // svg visual Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() ); svgVisual.SetSize( visualSize ); DALI_TEST_EQUALS( svgVisual.GetSize(), visualSize, TEST_LOCATION ); @@ -187,6 +211,49 @@ int UtcDaliVisualSize(void) // // DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); + + // svg visual with a size + Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions(200, 200) ); + DALI_TEST_EQUALS( svgVisual2.GetSize(), Vector2( 200.f, 200.f ), TEST_LOCATION ); + svgVisual2.GetNaturalSize(naturalSize); + DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100 + + // Batch Image visual + propertyMap.Clear(); + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); + Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); + batchImageVisual.SetSize( visualSize ); + DALI_TEST_EQUALS( batchImageVisual.GetSize(), visualSize, TEST_LOCATION ); + batchImageVisual.GetNaturalSize( naturalSize ); + DALI_TEST_EQUALS( naturalSize, Vector2( 80.0f, 160.0f ), TEST_LOCATION ); + + // Text visual. + + // Load some fonts to get the same metrics on different platforms. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.SetDpi( 96u, 96u ); + + char* pathNamePtr = get_current_dir_name(); + const std::string pathName( pathNamePtr ); + free( pathNamePtr ); + + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" ); + + propertyMap.Clear(); + propertyMap.Insert( Visual::Property::TYPE, Visual::TEXT ); + propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true ); + propertyMap.Insert( TextVisual::Property::TEXT, "Hello world" ); + propertyMap.Insert( TextVisual::Property::MULTI_LINE, true ); + + Visual::Base textVisual = factory.CreateVisual( propertyMap ); + textVisual.GetNaturalSize( naturalSize ); + DALI_TEST_EQUALS( naturalSize, Size( 80.f, 20.f ), TEST_LOCATION ); + + const float height = textVisual.GetHeightForWidth( 40.f ); + DALI_TEST_EQUALS( height, 40.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + END_TEST; } @@ -296,6 +363,10 @@ int UtcDaliVisualGetPropertyMap1(void) DALI_TEST_CHECK( colorValue ); DALI_TEST_CHECK( colorValue->Get() == Color::CYAN ); + // Test the properties. TODO: to be completed. + colorVisual.SetProperty( ColorVisual::Property::MIX_COLOR, Color::RED ); + Property::Value value = colorVisual.GetProperty( ColorVisual::Property::MIX_COLOR ); + END_TEST; } @@ -346,6 +417,10 @@ int UtcDaliVisualGetPropertyMap2(void) DALI_TEST_CHECK( colorValue ); DALI_TEST_CHECK( colorValue->Get() == 10.f ); + // Test the properties. TODO: to be completed. + borderVisual.SetProperty( BorderVisual::Property::COLOR, Color::RED ); + Property::Value value = borderVisual.GetProperty( BorderVisual::Property::COLOR ); + END_TEST; } @@ -413,6 +488,10 @@ int UtcDaliVisualGetPropertyMap3(void) DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION ); DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION ); + // Test the properties. TODO: to be completed. + gradientVisual.SetProperty( GradientVisual::Property::STOP_COLOR, Color::RED ); + Property::Value gradientValue = gradientVisual.GetProperty( GradientVisual::Property::STOP_COLOR ); + END_TEST; } @@ -500,6 +579,9 @@ int UtcDaliVisualGetPropertyMap5(void) propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); propertyMap.Insert( ImageVisual::Property::FITTING_MODE, FittingMode::FIT_HEIGHT ); propertyMap.Insert( ImageVisual::Property::SAMPLING_MODE, SamplingMode::BOX_THEN_NEAREST ); + propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, Vector4( 0.25f, 0.25f, 0.5f, 0.5f ) ); + propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT ); + propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::MIRRORED_REPEAT ); propertyMap.Insert( "synchronousLoading", true ); Visual::Base imageVisual = factory.CreateVisual(propertyMap); @@ -533,6 +615,18 @@ int UtcDaliVisualGetPropertyMap5(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == 30 ); + value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), Vector4( 0.25f, 0.25f, 0.5f, 0.5f ), Math::MACHINE_EPSILON_100, TEST_LOCATION ); + + value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == WrapMode::REPEAT); + + value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == WrapMode::MIRRORED_REPEAT); + value = resultMap.Find( "synchronousLoading", Property::BOOLEAN ); DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == true ); @@ -566,10 +660,26 @@ int UtcDaliVisualGetPropertyMap5(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == 200 ); + value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), Vector4( 0.f, 0.f, 1.f, 1.f ), Math::MACHINE_EPSILON_100, TEST_LOCATION ); + + value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == WrapMode::DEFAULT); + + value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == WrapMode::DEFAULT); + value = resultMap.Find( "synchronousLoading", Property::BOOLEAN ); DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == false ); + // Test the properties. TODO: to be completed. + imageVisual.SetProperty( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + Property::Value imageValue = imageVisual.GetProperty( ImageVisual::Property::URL ); + END_TEST; } @@ -601,6 +711,10 @@ int UtcDaliVisualGetPropertyMap6(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() ); + // Test the properties. TODO: to be completed. + nPatchVisual.SetProperty( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME ); + Property::Value nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::URL ); + END_TEST; } @@ -613,7 +727,7 @@ int UtcDaliVisualGetPropertyMap7(void) VisualFactory factory = VisualFactory::Get(); Property::Map propertyMap; propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); - propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ); Visual::Base svgVisual = factory.CreateVisual( propertyMap ); Property::Map resultMap; @@ -640,6 +754,10 @@ int UtcDaliVisualGetPropertyMap7(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == TEST_SVG_FILE_NAME ); + // Test the properties. TODO: to be completed. + svgVisual.SetProperty( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ); + Property::Value svgValue = svgVisual.GetProperty( ImageVisual::Property::URL ); + END_TEST; } @@ -688,6 +806,10 @@ int UtcDaliVisualGetPropertyMap8(void) DALI_TEST_CHECK( value ); DALI_TEST_EQUALS( value->Get(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION ); + // Test the properties. TODO: to be completed. + meshVisual.SetProperty( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME ); + Property::Value meshValue = meshVisual.GetProperty( MeshVisual::Property::OBJECT_URL ); + END_TEST; } @@ -705,7 +827,7 @@ int UtcDaliVisualGetPropertyMap9(void) Property::Map propertyMap; propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE ); - propertyMap.Insert( PrimitiveVisual::Property::COLOR, color ); + propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, color ); propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 ); propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 ); propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f ); @@ -730,7 +852,7 @@ int UtcDaliVisualGetPropertyMap9(void) DALI_TEST_CHECK( value ); DALI_TEST_EQUALS( value->Get(), (int)PrimitiveVisual::Shape::CUBE, TEST_LOCATION ); - value = resultMap.Find( PrimitiveVisual::Property::COLOR, Property::VECTOR4 ); + value = resultMap.Find( PrimitiveVisual::Property::MIX_COLOR, Property::VECTOR4 ); DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == color ); DALI_TEST_EQUALS( value->Get(), color, Math::MACHINE_EPSILON_100, TEST_LOCATION ); @@ -775,5 +897,380 @@ int UtcDaliVisualGetPropertyMap9(void) DALI_TEST_CHECK( value ); DALI_TEST_EQUALS( value->Get(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION ); + // Test the properties. TODO: to be completed. + primitiveVisual.SetProperty( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE ); + Property::Value primitiveValue = primitiveVisual.GetProperty( PrimitiveVisual::Property::SHAPE ); + + END_TEST; +} + +int UtcDaliVisualGetPropertyMapBatchImageVisual(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisual:" ); + + VisualFactory factory = VisualFactory::Get(); + 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 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + + Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( batchImageVisual ); + + Property::Map resultMap; + batchImageVisual.CreatePropertyMap( resultMap ); + + // Check the property values from the returned map from visual + Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == Visual::IMAGE ); + + value = resultMap.Find( ImageVisual::Property::URL, Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == TEST_IMAGE_FILE_NAME ); + + value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == 20 ); + + value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == 30 ); + + // Test the properties. TODO: to be completed. + batchImageVisual.SetProperty( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + Property::Value primitiveValue = batchImageVisual.GetProperty( ImageVisual::Property::URL ); + + END_TEST; +} + +//Text shape visual +int UtcDaliVisualGetPropertyMap10(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualGetPropertyMap10: TextVisual" ); + + //Request PrimitiveVisual using a property map. + VisualFactory factory = VisualFactory::Get(); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::TEXT ); + propertyMap.Insert( "renderingBackend", static_cast( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) ); + propertyMap.Insert( "text", "Hello world" ); + propertyMap.Insert( "fontFamily", "TizenSans" ); + propertyMap.Insert( "fontStyle", "{\"weight\":\"bold\"}" ); + propertyMap.Insert( "pointSize", 12.f ); + propertyMap.Insert( "multiLine", true ); + propertyMap.Insert( "horizontalAlignment", "CENTER" ); + propertyMap.Insert( "verticalAlignment", "CENTER" ); + propertyMap.Insert( "textColor", Color::RED ); + propertyMap.Insert( "enableMarkup", false ); + propertyMap.Insert( "enableAutoScroll", false ); + propertyMap.Insert( "lineSpacing", 0.f ); + propertyMap.Insert( "batchingEnabled", false ); + Visual::Base textVisual = factory.CreateVisual( propertyMap ); + + Property::Map resultMap; + textVisual.CreatePropertyMap( resultMap ); + + //Check values in the result map are identical to the initial map's values. + Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), (int)Visual::TEXT, TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::RENDERING_BACKEND, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), Toolkit::Text::DEFAULT_RENDERING_BACKEND, TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::TEXT, Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), "Hello world", TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::FONT_FAMILY, Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), "TizenSans", TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::FONT_STYLE, Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), "{\"weight\":\"bold\"}", TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::POINT_SIZE, Property::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::MULTI_LINE, Property::BOOLEAN ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() ); + + value = resultMap.Find( TextVisual::Property::HORIZONTAL_ALIGNMENT, Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), "CENTER", TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::VERTICAL_ALIGNMENT, Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), "CENTER", TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::TEXT_COLOR, Property::VECTOR4 ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), Color::RED, TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::ENABLE_MARKUP, Property::BOOLEAN ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( !value->Get() ); + + value = resultMap.Find( TextVisual::Property::ENABLE_AUTO_SCROLL, Property::BOOLEAN ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( !value->Get() ); + + value = resultMap.Find( TextVisual::Property::LINE_SPACING, Property::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + value = resultMap.Find( TextVisual::Property::BATCHING_ENABLED, Property::BOOLEAN ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( !value->Get() ); + + END_TEST; +} + +int UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas:" ); + + VisualFactory factory = VisualFactory::Get(); + 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 ); + + // Set the desired size to be larger than the atlas limit of 1024x1024. + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 2048 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 2048 ); + + // Create the visual. + Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); + + DALI_TEST_CHECK( batchImageVisual ); + + Actor actor = Actor::New(); + batchImageVisual.SetOnStage( actor ); + + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + + END_TEST; +} + +int UtcDaliVisualAnimateBorderVisual01(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimateBorderVisual Color" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER); + propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE); + propertyMap.Insert(BorderVisual::Property::SIZE, 5.f); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + Actor actor = Actor::New(); + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + Stage::GetCurrent().Add(actor); + borderVisual.SetOnStage( actor ); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::COLOR ); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( Property(renderer, index), Color::WHITE ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point between blue and white + + Vector4 color = renderer.GetProperty( index ); + Vector4 testColor = (Color::BLUE + Color::WHITE)*0.5f; + DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderColor", testColor ), true, TEST_LOCATION ); + + application.Render(2000u); // halfway point between blue and white + + color = renderer.GetProperty( index ); + DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderColor", Color::WHITE ), true, TEST_LOCATION ); + + END_TEST; +} + + +int UtcDaliVisualAnimateBorderVisual02(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimateBorderVisual Size" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER); + propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE); + propertyMap.Insert(BorderVisual::Property::SIZE, 5.f); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + Actor actor = Actor::New(); + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + Stage::GetCurrent().Add(actor); + borderVisual.SetOnStage( actor ); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::SIZE ); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( Property(renderer, index), 9.0f ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + + float size = renderer.GetProperty( index ); + DALI_TEST_EQUALS( size, 7.0f, 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderSize", 7.0f ), true, TEST_LOCATION ); + + application.Render(2000u); // halfway point between blue and white + + size = renderer.GetProperty( index ); + DALI_TEST_EQUALS( size, 9.0f, 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderSize", 9.0f ), true, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliVisualAnimateColorVisual(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimateColorVisual mixColor" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + Actor actor = Actor::New(); + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + Stage::GetCurrent().Add(actor); + borderVisual.SetOnStage( actor ); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Index index = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR ); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( Property(renderer, index), Color::WHITE ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + + Vector4 color = renderer.GetProperty( index ); + Vector4 testColor = (Color::BLUE + Color::WHITE)*0.5f; + DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", testColor ), true, TEST_LOCATION ); + + application.Render(2000u); // halfway point between blue and white + + color = renderer.GetProperty( index ); + DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION ); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Color::WHITE ), true, TEST_LOCATION ); + + + END_TEST; +} + + +int UtcDaliVisualAnimatePrimitiveVisual(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimatePrimitiveVisual color" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + Actor actor = Actor::New(); + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + actor.SetColor(Color::BLACK); + Stage::GetCurrent().Add(actor); + borderVisual.SetOnStage( actor ); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Index index = renderer.GetPropertyIndex( PrimitiveVisual::Property::MIX_COLOR ); + + // The property isn't registered on the renderer, it's instead registered on the shader. + DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION ); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + + // Actor color overrides renderer color. + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Vector4(0.5f, 0.5f, 0.5f, 1.0f )), true, TEST_LOCATION ); + + application.Render(2000u); // halfway point between blue and white + + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Color::WHITE ), true, TEST_LOCATION ); + + + END_TEST; +} + +int UtcDaliVisualWireframeVisual(void) +{ + ToolkitTestApplication application; + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::WIREFRAME ); + + // Create the visual. + Visual::Base visual = factory.CreateVisual( propertyMap ); + + DALI_TEST_CHECK( visual ); + + Property::Map resultMap; + visual.CreatePropertyMap( resultMap ); + + // Check the property values from the returned map from visual + Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == Visual::WIREFRAME ); + + // Test the properties. TODO: to be completed. + Property::Value primitiveValue = visual.GetProperty( Visual::Property::TYPE ); + END_TEST; }