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=87701b2965586b9613d6d0bccd52c5edde7fde3f;hp=bd389ad0f9da3d7a71bac0026586fd7c1b2c61e8;hb=b7108fc5f28fd650a1ea08a8692c822a63baf5bd;hpb=bd04df1ac18ac7446e95192724272d6a95f8e0eb diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index bd389ad..87701b2 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -889,7 +890,7 @@ int UtcDaliVisualGetPropertyMap5(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == WrapMode::MIRRORED_REPEAT); - value = resultMap.Find( "synchronousLoading", Property::BOOLEAN ); + value = resultMap.Find( ImageVisual::Property::SYNCHRONOUS_LOADING, Property::BOOLEAN ); DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == true ); @@ -1218,7 +1219,7 @@ int UtcDaliVisualGetPropertyMap10(void) propertyMap.Insert( "shadow", shadowMapSet.Add("color", Color::RED).Add("offset", Vector2(2.0f, 2.0f)).Add("blurRadius", 3.0f) ); Property::Map underlineMapSet; - propertyMap.Insert( "underline", underlineMapSet.Add("enable", true).Add("color", Color::GREEN).Add("height", 1) ); + propertyMap.Insert( "underline", underlineMapSet.Add("enable", true).Add("color", Color::GREEN).Add("height", 1).Add("type", Text::Underline::Type::SOLID).Add("dashWidth", 2).Add("dashGap", 1) ); Property::Map outlineMapSet; propertyMap.Insert( "outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1) ); @@ -4352,6 +4353,242 @@ int UtcDaliVisualBorderline(void) END_TEST; } +int UtcDaliVisualBorderlineBlendModeTest(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualBorderlineBlendModeTest" ); + VisualFactory factory = VisualFactory::Get(); + + // Case 1 : Test which doesn't support borderline feature. + { + tet_printf("Test Unsupported visual type\n"); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER); + propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE); + propertyMap.Insert(DevelVisual::Property::BORDERLINE_WIDTH, 1.0f); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) ); + actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + application.GetScene().Add(actor); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + + Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + // Visual::BORDER doesn't support BORDERLINE. BlendMode is AUTO. + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); + + application.GetScene().Remove(actor); + } + + // Case 2 : Test which support borderline feature. + { + tet_printf("Test normal case\n"); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + propertyMap.Insert(DevelVisual::Property::BORDERLINE_WIDTH, 1.0f); + Visual::Base colorVisual = factory.CreateVisual( propertyMap ); + + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, colorVisual ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) ); + actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + application.GetScene().Add(actor); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + + Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + // Visual::COLOR support BORDERLINE. BlendMode is ON_WITHOUT_CULL. + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON_WITHOUT_CULL, TEST_LOCATION ); + + application.GetScene().Remove(actor); + } + + // Case 3 : Test which animated borderline. + { + tet_printf("Test borderline animate case\n"); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + Visual::Base colorVisual = factory.CreateVisual( propertyMap ); + + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, colorVisual ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) ); + actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + application.GetScene().Add(actor); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + + Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + // BlendMode is AUTO. + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); + + Animation animation = Animation::New(0.1f); + animation.AnimateTo( DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::BORDERLINE_WIDTH), 1.0f ); + animation.Play(); + + application.SendNotification(); + application.Render(); + application.Render(101u); // End of animation + + blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + // BlendMode is ON_WITHOUT_CULL. + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON_WITHOUT_CULL, TEST_LOCATION ); + + Animation revanimation = Animation::New(0.1f); + revanimation.AnimateTo( DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::BORDERLINE_WIDTH), 0.0f ); + revanimation.Play(); + + application.SendNotification(); + application.Render(); + application.Render(101u); // End of animation + + blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + // BlendMode is still ON_WITHOUT_CULL. + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON_WITHOUT_CULL, TEST_LOCATION ); + + application.GetScene().Remove(actor); + } + + // Case 4 : Test which animated corner radius occur. + { + tet_printf("Test borderline animate case\n"); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + propertyMap.Insert(DevelVisual::Property::BORDERLINE_WIDTH, 1.0f); + Visual::Base colorVisual = factory.CreateVisual( propertyMap ); + + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, colorVisual ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) ); + actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + application.GetScene().Add(actor); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + + Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + // BlendMode is ON_WITHOUT_CULL. + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON_WITHOUT_CULL, TEST_LOCATION ); + + Animation animation = Animation::New(0.1f); + animation.AnimateTo( DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), Vector4(1.0f, 1.0f, 1.0f, 1.0f) ); + animation.Play(); + + application.SendNotification(); + application.Render(); + application.Render(101u); // End of animation + + blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + // BlendMode is ON_WITHOUT_CULL. + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON_WITHOUT_CULL, TEST_LOCATION ); + + application.GetScene().Remove(actor); + } + + END_TEST; +} + +int UtcDaliVisualBorderlineColorAnimateTest(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualBorderlineColorAnimateTest color" ); + + TestGraphicsController& graphics = application.GetGraphicsController(); + static std::vector customUniforms = + { + UniformData("mixColor", Property::Type::VECTOR3), + UniformData("cornerRadius", Property::Type::VECTOR4), + UniformData("cornerRadiusPolicy", Property::Type::FLOAT), + UniformData("borderlineWidth", Property::Type::FLOAT), + UniformData("borderlineColor", Property::Type::VECTOR4), + UniformData("borderlineOffset", Property::Type::FLOAT), + }; + graphics.AddCustomUniforms(customUniforms); + + { + const Vector3 INITIAL_MIX_COLOR( 1.0f,0.0f,1.0f ); + const float INITIAL_MIX_OPACITY( 0.5f ); + const Vector4 INITIAL_BORDERLINE_COLOR( 0.0f,1.0f,0.0f,1.0f ); + const float INITIAL_ACTOR_OPACITY( 1.0f ); + const Vector3 TARGET_MIX_COLOR( 1.0f, 0.0f, 0.0f ); + const float TARGET_MIX_OPACITY( 0.8f ); + const Vector4 TARGET_BORDERLINE_COLOR( 1.0f, 0.0f, 1.0f, 0.2f); + const float TARGET_ACTOR_OPACITY( 0.5f ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(Visual::Property::MIX_COLOR, INITIAL_MIX_COLOR); + propertyMap.Insert(Visual::Property::OPACITY, INITIAL_MIX_OPACITY); + propertyMap.Insert(DevelVisual::Property::BORDERLINE_WIDTH, 1.0f); + propertyMap.Insert(DevelVisual::Property::BORDERLINE_COLOR, INITIAL_BORDERLINE_COLOR); + Visual::Base visual = factory.CreateVisual( propertyMap ); + + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) ); + actor.SetProperty( Actor::Property::OPACITY, INITIAL_ACTOR_OPACITY ); + actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + application.GetScene().Add(actor); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, Visual::Property::MIX_COLOR), TARGET_MIX_COLOR ); + animation.AnimateTo( DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), TARGET_MIX_OPACITY); + animation.AnimateTo( DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::BORDERLINE_COLOR), TARGET_BORDERLINE_COLOR ); + animation.AnimateTo( Property(actor, Actor::Property::OPACITY), TARGET_ACTOR_OPACITY); + animation.Play(); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + application.SendNotification(); + + Vector3 halfwayMixColor = (INITIAL_MIX_COLOR + TARGET_MIX_COLOR ) * 0.5f; + float halfwayMixOpacity = (INITIAL_MIX_OPACITY + TARGET_MIX_OPACITY ) * 0.5f; + Vector4 halfwayBorderlineColor = (INITIAL_BORDERLINE_COLOR + TARGET_BORDERLINE_COLOR) * 0.5f; + float halfwayActorOpacity = (INITIAL_ACTOR_OPACITY + TARGET_ACTOR_OPACITY ) * 0.5f; + halfwayMixOpacity *= halfwayActorOpacity; + DALI_TEST_EQUALS( glAbstraction.CheckUniformValue("mixColor", halfwayMixColor), true, TEST_LOCATION ); + DALI_TEST_EQUALS( glAbstraction.CheckUniformValue("uColor", Vector4(1.0f, 1.0f, 1.0f, halfwayMixOpacity)), true, TEST_LOCATION ); + DALI_TEST_EQUALS( glAbstraction.CheckUniformValue("uActorColor", Vector4(1.0f, 1.0f, 1.0f, halfwayActorOpacity)), true, TEST_LOCATION ); + DALI_TEST_EQUALS( glAbstraction.CheckUniformValue("borderlineColor", halfwayBorderlineColor), true, TEST_LOCATION ); + + application.Render(2001u); // go past end + application.SendNotification(); // Trigger signals + + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Vector4(1.0f, 1.0f, 1.0f, TARGET_ACTOR_OPACITY), TEST_LOCATION ); + DALI_TEST_EQUALS( glAbstraction.CheckUniformValue("mixColor", TARGET_MIX_COLOR), true, TEST_LOCATION ); + DALI_TEST_EQUALS( glAbstraction.CheckUniformValue("uColor", Vector4(1.0f, 1.0f, 1.0f, TARGET_MIX_OPACITY * TARGET_ACTOR_OPACITY) ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( glAbstraction.CheckUniformValue("uActorColor", Vector4(1.0f, 1.0f, 1.0f, TARGET_ACTOR_OPACITY)), true, TEST_LOCATION ); + DALI_TEST_EQUALS( glAbstraction.CheckUniformValue("borderlineColor", TARGET_BORDERLINE_COLOR ), true, TEST_LOCATION ); + + actor.Unparent(); + } + + END_TEST; +} int UtcDaliColorVisualBlurRadius(void) { @@ -5210,4 +5447,667 @@ int UtcDaliVisualGetVisualProperty07(void) #endif END_TEST; +} + +int UtcDaliVisualUpdateProperty(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualUpdateProperty: Test update property by DoAction. Standard case" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap[Visual::Property::TYPE] = Visual::Type::IMAGE; + propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME; + propertyMap[Visual::Property::MIX_COLOR] = Color::BLUE; + propertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = DevelVisual::FIT_WIDTH; + + Visual::Base imageVisual = factory.CreateVisual(propertyMap); + + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual); + dummyControl[Actor::Property::SIZE] = Vector2(200.f, 200.f); + application.GetScene().Add(dummyControl); + + application.SendNotification(); + application.Render(); + + // Wait for image loading + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + Property::Map originalMap; + imageVisual.CreatePropertyMap( originalMap ); + + float targetOpacity = 0.5f; + Vector3 targetMixColor = Vector3(1.0f, 0.4f, 0.2f); + bool targetPreMultipliedAlpha = originalMap[Visual::Property::PREMULTIPLIED_ALPHA].Get() ^ true; + DevelVisual::FittingMode targetVisualFittingMode = DevelVisual::CENTER; + + Property::Map targetPropertyMap; + targetPropertyMap[Visual::Property::OPACITY] = targetOpacity; + targetPropertyMap[ImageVisual::Property::URL] = "foobar"; + targetPropertyMap[Visual::Property::MIX_COLOR] = targetMixColor; + targetPropertyMap[Visual::Property::PREMULTIPLIED_ALPHA] = targetPreMultipliedAlpha; + targetPropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = targetVisualFittingMode; + + // Update Properties + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap); + + Property::Map resultMap; + imageVisual.CreatePropertyMap( resultMap ); + + // Test property values: they should be updated + Property::Value* colorValue = resultMap.Find(Visual::Property::MIX_COLOR, Property::VECTOR4); + DALI_TEST_CHECK(colorValue); + DALI_TEST_EQUALS(colorValue->Get(), Vector4(targetMixColor.r, targetMixColor.g, targetMixColor.b, targetOpacity), TEST_LOCATION); + + Property::Value* urlValue = resultMap.Find(ImageVisual::Property::URL, Property::STRING); + DALI_TEST_CHECK(urlValue); + // NOTE : ImageVisual URL must NOT changed. + DALI_TEST_EQUALS(urlValue->Get< std::string >(), TEST_IMAGE_FILE_NAME, TEST_LOCATION); + + Property::Value* preMultipliedValue = resultMap.Find(Visual::Property::PREMULTIPLIED_ALPHA, Property::BOOLEAN); + DALI_TEST_CHECK(preMultipliedValue); + DALI_TEST_EQUALS(preMultipliedValue->Get< bool >(), targetPreMultipliedAlpha, TEST_LOCATION); + + Property::Value* visualFittingModeValue = resultMap.Find(DevelVisual::Property::VISUAL_FITTING_MODE, Property::STRING); + DALI_TEST_CHECK(visualFittingModeValue); + DALI_TEST_EQUALS(visualFittingModeValue->Get< std::string >(), "CENTER", TEST_LOCATION); + + END_TEST; +} + +int UtcDaliVisualUpdatePropertyChangeShader01(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualUpdatePropertyChangeShader01: Test update property by DoAction. Change the shader case" ); + + TraceCallStack& callStack = application.GetGraphicsController().mCallStack; + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + // Case ImageVisual + propertyMap[Visual::Property::TYPE] = Visual::Type::IMAGE; + propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME; + + Visual::Base imageVisual = factory.CreateVisual(propertyMap); + + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual); + dummyControl[Actor::Property::SIZE] = Vector2(200.f, 200.f); + application.GetScene().Add(dummyControl); + + application.SendNotification(); + application.Render(); + + // Wait for image loading + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + } + callStack.Reset(); + callStack.Enable(true); + + Vector4 targetCornerRadius = Vector4(1.0f, 12.0f, 2.0f, 21.0f); + + Property::Map targetPropertyMap; + targetPropertyMap[DevelVisual::Property::CORNER_RADIUS] = targetCornerRadius; + targetPropertyMap[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::RELATIVE; + + // Update Properties with CornerRadius + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap); + + Property::Map resultMap; + imageVisual.CreatePropertyMap( resultMap ); + + // Test property values: they should be updated + Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4); + DALI_TEST_CHECK(cornerRadiusValue); + DALI_TEST_EQUALS(cornerRadiusValue->Get(), targetCornerRadius, TEST_LOCATION); + + Property::Value* cornerRadiusPolicyValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER); + DALI_TEST_CHECK(cornerRadiusPolicyValue); + DALI_TEST_EQUALS(cornerRadiusPolicyValue->Get(), static_cast(Toolkit::Visual::Transform::Policy::RELATIVE), TEST_LOCATION); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + } + + // Send shader compile signal + application.SendNotification(); + application.Render(); + + callStack.Enable(false); + // Shader changed + DALI_TEST_CHECK( callStack.FindMethod("CreateShader") ); + callStack.Reset(); + callStack.Enable(true); + + float targetBorderlineWidth = 10.0f; + Vector4 targetBorderlineColor = Vector4(1.0f, 0.2f, 0.1f, 0.5f); + float targetBorderlineOffset = -0.3f; + + Property::Map targetPropertyMap2; + targetPropertyMap2[DevelVisual::Property::CORNER_RADIUS] = Vector4::ZERO; + targetPropertyMap2[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::ABSOLUTE; + targetPropertyMap2[DevelVisual::Property::BORDERLINE_WIDTH] = targetBorderlineWidth; + targetPropertyMap2[DevelVisual::Property::BORDERLINE_COLOR] = targetBorderlineColor; + targetPropertyMap2[DevelVisual::Property::BORDERLINE_OFFSET] = targetBorderlineOffset; + + // Update Properties with Borderline + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap2); + + Property::Map resultMap2; + imageVisual.CreatePropertyMap( resultMap2 ); + + // Test property values: they should be updated + cornerRadiusValue = resultMap2.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4); + DALI_TEST_CHECK(cornerRadiusValue); + DALI_TEST_EQUALS(cornerRadiusValue->Get(), Vector4::ZERO, TEST_LOCATION); + + cornerRadiusPolicyValue = resultMap2.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER); + DALI_TEST_CHECK(cornerRadiusPolicyValue); + DALI_TEST_EQUALS(cornerRadiusPolicyValue->Get(), static_cast(Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION); + + Property::Value* borderlineWidthValue = resultMap2.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT); + DALI_TEST_CHECK(borderlineWidthValue); + DALI_TEST_EQUALS(borderlineWidthValue->Get(), targetBorderlineWidth, TEST_LOCATION); + + Property::Value* borderlineColorValue = resultMap2.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4); + DALI_TEST_CHECK(borderlineColorValue); + DALI_TEST_EQUALS(borderlineColorValue->Get(), targetBorderlineColor, TEST_LOCATION); + + Property::Value* borderlineOffsetValue = resultMap2.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT); + DALI_TEST_CHECK(borderlineOffsetValue); + DALI_TEST_EQUALS(borderlineOffsetValue->Get(), targetBorderlineOffset, TEST_LOCATION); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos ); + // Note : mAlwaysUsingCornerRadius is true. + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos ); + // Note : mAlwaysUsingCornerRadius is true. + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + } + + // Send shader compile signal + application.SendNotification(); + application.Render(); + + callStack.Enable(false); + // Shader changed + DALI_TEST_CHECK( callStack.FindMethod("CreateShader") ); + callStack.Reset(); + callStack.Enable(true); + + Property::Map targetPropertyMap3; + targetPropertyMap3[DevelVisual::Property::CORNER_RADIUS] = Vector4::ZERO; + targetPropertyMap3[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::ABSOLUTE; + targetPropertyMap3[DevelVisual::Property::BORDERLINE_WIDTH] = 0.0f; + targetPropertyMap3[DevelVisual::Property::BORDERLINE_COLOR] = Vector4::ZERO; + targetPropertyMap3[DevelVisual::Property::BORDERLINE_OFFSET] = 0.0f; + + // Update Properties into zero + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap3); + + Property::Map resultMap3; + imageVisual.CreatePropertyMap( resultMap3 ); + + // Test property values: they should be updated + cornerRadiusValue = resultMap3.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4); + DALI_TEST_CHECK(cornerRadiusValue); + DALI_TEST_EQUALS(cornerRadiusValue->Get(), Vector4::ZERO, TEST_LOCATION); + + cornerRadiusPolicyValue = resultMap3.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER); + DALI_TEST_CHECK(cornerRadiusPolicyValue); + DALI_TEST_EQUALS(cornerRadiusPolicyValue->Get(), static_cast(Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION); + + borderlineWidthValue = resultMap3.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT); + DALI_TEST_CHECK(borderlineWidthValue); + DALI_TEST_EQUALS(borderlineWidthValue->Get(), 0.0f, TEST_LOCATION); + + borderlineColorValue = resultMap3.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4); + DALI_TEST_CHECK(borderlineColorValue); + DALI_TEST_EQUALS(borderlineColorValue->Get(), Vector4::ZERO, TEST_LOCATION); + + borderlineOffsetValue = resultMap3.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT); + DALI_TEST_CHECK(borderlineOffsetValue); + DALI_TEST_EQUALS(borderlineOffsetValue->Get(), 0.0f, TEST_LOCATION); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + // Note : mAlwaysUsingBorderline and mAlwaysUsingCornerRadius is true. + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + // Note : mAlwaysUsingBorderline and mAlwaysUsingCornerRadius is true. + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + } + + // Send shader compile signal + application.SendNotification(); + application.Render(); + + callStack.Enable(false); + // Shader not changed + DALI_TEST_CHECK( !callStack.FindMethod("CreateShader") ); + + END_TEST; +} + +int UtcDaliVisualUpdatePropertyChangeShader02(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualUpdatePropertyChangeShader02: Test update property by DoAction. Fake update" ); + + TraceCallStack& callStack = application.GetGraphicsController().mCallStack; + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + // Case ImageVisual + propertyMap[Visual::Property::TYPE] = Visual::Type::IMAGE; + propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME; + + Visual::Base imageVisual = factory.CreateVisual(propertyMap); + + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual); + dummyControl[Actor::Property::SIZE] = Vector2(200.f, 200.f); + application.GetScene().Add(dummyControl); + + application.SendNotification(); + application.Render(); + + // Wait for image loading + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + } + + Vector4 targetCornerRadius = Vector4(0.0f, 0.0f, 0.0f, 0.0f); + + Property::Map targetPropertyMap; + targetPropertyMap[DevelVisual::Property::CORNER_RADIUS] = targetCornerRadius; + + callStack.Reset(); + callStack.Enable(true); + + // Update Properties with CornerRadius + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap); + + Property::Map resultMap; + imageVisual.CreatePropertyMap( resultMap ); + + // Test property values: they should be updated + Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4); + DALI_TEST_CHECK(cornerRadiusValue); + DALI_TEST_EQUALS(cornerRadiusValue->Get(), targetCornerRadius, TEST_LOCATION); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + // Note : corner radius is zero. so we don't change shader! + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + // Note : corner radius is zero. so we don't change shader! + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + } + + // Send shader compile signal + application.SendNotification(); + application.Render(); + + callStack.Enable(false); + + // Shader doesn't changed + DALI_TEST_CHECK( !(callStack.FindMethod("CreateShader")) ); + callStack.Reset(); + callStack.Enable(true); + + float targetBorderlineWidth = 0.0f; + Vector4 targetBorderlineColor = Vector4(1.0f, 1.0f, 0.0f, 0.0f); + float targetBorderlineOffset = -1.0f; + + Property::Map targetPropertyMap2; + targetPropertyMap2[DevelVisual::Property::BORDERLINE_WIDTH] = targetBorderlineWidth; + targetPropertyMap2[DevelVisual::Property::BORDERLINE_COLOR] = targetBorderlineColor; + targetPropertyMap2[DevelVisual::Property::BORDERLINE_OFFSET] = targetBorderlineOffset; + + // Update Properties with Borderline + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap2); + + Property::Map resultMap2; + imageVisual.CreatePropertyMap( resultMap2 ); + + // Test property values: they should be updated + Property::Value* borderlineWidthValue = resultMap2.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT); + DALI_TEST_CHECK(borderlineWidthValue); + DALI_TEST_EQUALS(borderlineWidthValue->Get(), targetBorderlineWidth, TEST_LOCATION); + + Property::Value* borderlineColorValue = resultMap2.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4); + DALI_TEST_CHECK(borderlineColorValue); + DALI_TEST_EQUALS(borderlineColorValue->Get(), targetBorderlineColor, TEST_LOCATION); + + Property::Value* borderlineOffsetValue = resultMap2.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT); + DALI_TEST_CHECK(borderlineOffsetValue); + DALI_TEST_EQUALS(borderlineOffsetValue->Get(), targetBorderlineOffset, TEST_LOCATION); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + // Note : borderline width is zero. so we don't change shader! + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + // Note : borderline width is zero. so we don't change shader! + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + } + + // Send shader compile signal + application.SendNotification(); + application.Render(); + + callStack.Enable(false); + + // Shader doesn't changed + DALI_TEST_CHECK( !(callStack.FindMethod("CreateShader")) ); + + END_TEST; +} + +int UtcDaliVisualUpdatePropertyChangeShader03(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualUpdatePropertyChangeShader03: Test update property by DoAction. Blur Radius" ); + + TraceCallStack& callStack = application.GetGraphicsController().mCallStack; + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + // Case ImageVisual + propertyMap[Visual::Property::TYPE] = Visual::Type::COLOR; + propertyMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE; + + Visual::Base imageVisual = factory.CreateVisual(propertyMap); + + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual); + dummyControl[Actor::Property::SIZE] = Vector2(200.f, 200.f); + application.GetScene().Add(dummyControl); + + application.SendNotification(); + application.Render(); + + application.SendNotification(); + application.Render(); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BLUR 1") == std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BLUR 1") == std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos ); + } + + float targetBlurRadius = 15.0f; + Vector4 targetCornerRadius = Vector4(1.0f, 0.1f, 1.1f, 0.0f); + + Property::Map targetPropertyMap; + targetPropertyMap[DevelColorVisual::Property::BLUR_RADIUS] = targetBlurRadius; + targetPropertyMap[DevelVisual::Property::CORNER_RADIUS] = targetCornerRadius; + targetPropertyMap[DevelVisual::Property::BORDERLINE_WIDTH] = 10.0f; // Don't care. just dummy + + callStack.Reset(); + callStack.Enable(true); + + // Update Properties with CornerRadius + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap); + + Property::Map resultMap; + imageVisual.CreatePropertyMap( resultMap ); + + // Test property values: they should be updated + Property::Value* blurRadiusValue = resultMap.Find(DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT); + DALI_TEST_CHECK(blurRadiusValue); + DALI_TEST_EQUALS(blurRadiusValue->Get(), targetBlurRadius, TEST_LOCATION); + + Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4); + DALI_TEST_CHECK(cornerRadiusValue); + DALI_TEST_EQUALS(cornerRadiusValue->Get(), targetCornerRadius, TEST_LOCATION); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos ); + // Note : We ignore borderline when blur radius occured + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos ); + // Note : We ignore borderline when blur radius occured + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + } + + // Send shader compile signal + application.SendNotification(); + application.Render(); + + callStack.Enable(false); + + // Shader changed + DALI_TEST_CHECK( (callStack.FindMethod("CreateShader")) ); + callStack.Reset(); + callStack.Enable(true); + + Property::Map targetPropertyMap2; + targetPropertyMap2[DevelColorVisual::Property::BLUR_RADIUS] = 0.0f; + targetPropertyMap2[DevelVisual::Property::CORNER_RADIUS] = Vector4::ZERO; + targetPropertyMap2[DevelVisual::Property::BORDERLINE_WIDTH] = 15.0f; // Don't care. just dummy + + // Update Properties with CornerRadius + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap2); + + Property::Map resultMap2; + imageVisual.CreatePropertyMap( resultMap2 ); + + // Test property values: they should be updated + blurRadiusValue = resultMap2.Find(DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT); + DALI_TEST_CHECK(blurRadiusValue); + DALI_TEST_EQUALS(blurRadiusValue->Get(), 0.0f, TEST_LOCATION); + + cornerRadiusValue = resultMap2.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4); + DALI_TEST_CHECK(cornerRadiusValue); + DALI_TEST_EQUALS(cornerRadiusValue->Get(), Vector4::ZERO, TEST_LOCATION); + + // Get shader + { + Renderer renderer = dummyControl.GetRendererAt( 0 ); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + DALI_TEST_CHECK( fragment ); + std::string fragmentShader; + DALI_TEST_CHECK( fragment->Get(fragmentShader) ); + // Note : mAlwaysUsingBlurRadius and mAlwaysUsingCornerRadius is true. + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos ); + // Note : We ignore borderline when blur radius occured + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK( vertex->Get(vertexShader) ); + // Note : mAlwaysUsingBlurRadius and mAlwaysUsingCornerRadius is true. + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos ); + // Note : We ignore borderline when blur radius occured + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos ); + DALI_TEST_CHECK( vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos ); + } + + // Send shader compile signal + application.SendNotification(); + application.Render(); + + callStack.Enable(false); + + // Shader not changed + DALI_TEST_CHECK( !(callStack.FindMethod("CreateShader")) ); + + END_TEST; } \ No newline at end of file