X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Visual.cpp;h=dae8540bd4af5ce71c735cbebcb9572b7f8ae9d5;hb=23446c257d6ae1977bb69e53353fb1ccd5409432;hp=79e5a349fb8f044fad85f58f0223a8f43217a3de;hpb=1d8f7098414663609c454617858bb9ea97a8a858;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 79e5a34..dae8540 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -141,6 +142,38 @@ bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map return true; } +void TestShaderCodeContainSubstrings(Control control, std::vector> substringCheckList, const char* location) +{ + Renderer renderer = control.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)); + for(const auto& checkPair : substringCheckList) + { + const auto& keyword = checkPair.first; + const auto& expect = checkPair.second; + tet_printf("check [%s] %s exist in fragment shader\n", keyword.c_str(), expect ? "is" : "is not"); + DALI_TEST_EQUALS((fragmentShader.find(keyword.c_str()) != std::string::npos), expect, location); + } + + Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp + std::string vertexShader; + DALI_TEST_CHECK(vertex->Get(vertexShader)); + for(const auto& checkPair : substringCheckList) + { + const auto& keyword = checkPair.first; + const auto& expect = checkPair.second; + tet_printf("check [%s] %s exist in vertex shader\n", keyword.c_str(), expect ? "is" : "is not"); + DALI_TEST_EQUALS((vertexShader.find(keyword.c_str()) != std::string::npos), expect, location); + } +} + } //namespace void dali_visual_startup(void) @@ -325,7 +358,6 @@ int UtcDaliVisualSize(void) DALI_TEST_EQUALS(naturalSize, Vector2::ZERO, TEST_LOCATION); // animated gradient visual - Vector2 animated_gradient_visual_size(10.f, 10.f); propertyMap.Clear(); propertyMap.Insert(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT); Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap); @@ -333,20 +365,6 @@ int UtcDaliVisualSize(void) animatedGradientVisual.SetTransformAndSize(DefaultTransform(), controlSize); DALI_TEST_EQUALS(naturalSize, Vector2::ZERO, TEST_LOCATION); - // svg visual - Visual::Base svgVisual = factory.CreateVisual(TEST_SVG_FILE_NAME, ImageDimensions()); - svgVisual.GetNaturalSize(naturalSize); - // TEST_SVG_FILE: - // - // - // - 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)); - svgVisual2.GetNaturalSize(naturalSize); - DALI_TEST_EQUALS(naturalSize, Vector2(100.f, 100.f), TEST_LOCATION); // Natural size should still be 100, 100 - // Text visual. // Load some fonts to get the same metrics on different platforms. @@ -456,7 +474,10 @@ int UtcDaliVisualSetOnOffScene2(void) application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + // Wait for loading & rasterization + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); Renderer renderer = actor.GetRendererAt(0); auto textures = renderer.GetTextures(); @@ -918,7 +939,7 @@ int UtcDaliVisualGetPropertyMap6(void) value = resultMap.Find(ImageVisual::Property::BORDER, Property::RECTANGLE); DALI_TEST_CHECK(value); - DALI_TEST_CHECK(value->Get >() == border); + DALI_TEST_CHECK(value->Get>() == border); value = resultMap.Find(DevelImageVisual::Property::AUXILIARY_IMAGE, Property::STRING); DALI_TEST_CHECK(value); @@ -959,7 +980,7 @@ int UtcDaliVisualGetPropertyMap6(void) value = resultMap.Find(ImageVisual::Property::BORDER, Property::RECTANGLE); DALI_TEST_CHECK(value); - DALI_TEST_CHECK(value->Get >() == border); + DALI_TEST_CHECK(value->Get>() == border); END_TEST; } @@ -1805,6 +1826,66 @@ int UtcDaliVisualGetPropertyMap13(void) END_TEST; } +int UtcDaliVisualAnimateArcVisual(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliVisualAnimateArcVisual color"); + + static std::vector customUniforms = + { + UniformData("startAngle", Property::Type::FLOAT), + UniformData("sweepAngle", Property::Type::FLOAT), + }; + + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, DevelVisual::ARC); + propertyMap.Insert(Visual::Property::MIX_COLOR, Color::BLUE); + propertyMap.Insert(DevelArcVisual::Property::START_ANGLE, 0.0f); + propertyMap.Insert(DevelArcVisual::Property::SWEEP_ANGLE, 90.0f); + propertyMap.Insert(DevelArcVisual::Property::CAP, DevelArcVisual::Cap::ROUND); + propertyMap.Insert(DevelArcVisual::Property::THICKNESS, 20.0f); + Visual::Base arcVisual = factory.CreateVisual(propertyMap); + + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, arcVisual); + 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::Index index = renderer.GetPropertyIndex(DevelArcVisual::Property::SWEEP_ANGLE); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo(Property(renderer, index), 50.0f); + animation.AnimateTo(DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, DevelArcVisual::Property::START_ANGLE), 40.0f); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + + float sweepAngle = renderer.GetCurrentProperty(index); + DALI_TEST_EQUALS(sweepAngle, 70.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("startAngle", 20.0f), true, TEST_LOCATION); + DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("sweepAngle", 70.0f), true, TEST_LOCATION); + + application.Render(2000u); // another halfway point + + sweepAngle = renderer.GetCurrentProperty(index); + DALI_TEST_EQUALS(sweepAngle, 50.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("startAngle", 40.0f), true, TEST_LOCATION); + DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("sweepAngle", 50.0f), true, TEST_LOCATION); + + END_TEST; +} + int UtcDaliVisualAnimateBorderVisual01(void) { ToolkitTestApplication application; @@ -3456,7 +3537,7 @@ int UtcDaliVisualPremultipliedAlpha(void) DALI_TEST_EQUALS(value->Get(), false, TEST_LOCATION); } - // svg visual ( premultiplied alpha by default is true ) + // svg visual ( premultiplied alpha by default is true, and cannot change value ) { Visual::Base imageVisual = factory.CreateVisual( Property::Map() @@ -3471,6 +3552,149 @@ int UtcDaliVisualPremultipliedAlpha(void) DALI_TEST_CHECK(value); DALI_TEST_EQUALS(value->Get(), true, TEST_LOCATION); } + { + Visual::Base imageVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::IMAGE) + .Add(ImageVisual::Property::URL, TEST_SVG_FILE_NAME) + .Add(Visual::Property::PREMULTIPLIED_ALPHA, false)); + + Dali::Property::Map visualMap; + imageVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), true, TEST_LOCATION); + } + + // animated vector visual ( premultiplied alpha by default is true, and cannot change value ) + { + Visual::Base imageVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::IMAGE) + .Add(ImageVisual::Property::URL, "something.json")); + + Dali::Property::Map visualMap; + imageVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), true, TEST_LOCATION); + } + { + Visual::Base imageVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::IMAGE) + .Add(ImageVisual::Property::URL, "something.json") + .Add(Visual::Property::PREMULTIPLIED_ALPHA, false)); + + Dali::Property::Map visualMap; + imageVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), true, TEST_LOCATION); + } + + // text visual ( premultiplied alpha by default is true, and cannot change value ) + { + Visual::Base textVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::TEXT) + .Add(TextVisual::Property::TEXT, "Text")); + + Dali::Property::Map visualMap; + textVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), true, TEST_LOCATION); + } + { + Visual::Base textVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::TEXT) + .Add(TextVisual::Property::TEXT, "Text") + .Add(Visual::Property::PREMULTIPLIED_ALPHA, false)); + + Dali::Property::Map visualMap; + textVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), true, TEST_LOCATION); + } + + // gradient visual ( premultiplied alpha by default is true, and cannot change value ) + { + Visual::Base gradientVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::GRADIENT) + .Add(GradientVisual::Property::START_POSITION, Vector2(-0.5f, -0.5f)) + .Add(GradientVisual::Property::END_POSITION, Vector2(0.5f, 0.5f)) + .Add(GradientVisual::Property::STOP_COLOR, Property::Array().Add(Color::RED).Add(Vector4(1.0f, 1.0f, 1.0f, 0.5f)))); + + Dali::Property::Map visualMap; + gradientVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), true, TEST_LOCATION); + } + { + Visual::Base gradientVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::GRADIENT) + .Add(GradientVisual::Property::START_POSITION, Vector2(-0.5f, -0.5f)) + .Add(GradientVisual::Property::END_POSITION, Vector2(0.5f, 0.5f)) + .Add(GradientVisual::Property::STOP_COLOR, Property::Array().Add(Color::RED).Add(Vector4(1.0f, 1.0f, 1.0f, 0.5f))) + .Add(Visual::Property::PREMULTIPLIED_ALPHA, false)); + + Dali::Property::Map visualMap; + gradientVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), true, TEST_LOCATION); + } + + // color visual ( premultiplied alpha by default is false, and cannot change value ) + { + Visual::Base colorVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::COLOR) + .Add(ColorVisual::Property::MIX_COLOR, Color::AQUA)); + + Dali::Property::Map visualMap; + colorVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), false, TEST_LOCATION); + } + { + Visual::Base colorVisual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Visual::COLOR) + .Add(ColorVisual::Property::MIX_COLOR, Color::AQUA) + .Add(Visual::Property::PREMULTIPLIED_ALPHA, true)); + + Dali::Property::Map visualMap; + colorVisual.CreatePropertyMap(visualMap); + Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA); + + // test values + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), false, TEST_LOCATION); + } END_TEST; } @@ -3636,7 +3860,8 @@ int UtcDaliSvgVisualCustomShader(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Wait for loading & rasterization + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); Renderer renderer = dummy.GetRendererAt(0); Shader shader2 = renderer.GetShader(); @@ -3655,7 +3880,6 @@ int UtcDaliSvgVisualCustomShader(void) int UtcDaliVisualRoundedCorner(void) { - ToolkitTestApplication application; tet_infoline("UtcDaliVisualRoundedCorner"); static std::vector customUniforms = @@ -3664,11 +3888,12 @@ int UtcDaliVisualRoundedCorner(void) UniformData("cornerRadiusPolicy", Property::Type::FLOAT), }; - TestGraphicsController& graphics = application.GetGraphicsController(); - graphics.AddCustomUniforms(customUniforms); - // image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float cornerRadius = 30.0f; @@ -3703,6 +3928,10 @@ int UtcDaliVisualRoundedCorner(void) // color visual 1 { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float cornerRadius = 30.0f; @@ -3736,6 +3965,10 @@ int UtcDaliVisualRoundedCorner(void) // color visual 2 { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; Vector4 cornerRadius(0.5f, 0.5f, 0.5f, 0.3f); @@ -3769,6 +4002,10 @@ int UtcDaliVisualRoundedCorner(void) // color visual 3 - invalid value { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; Vector4 cornerRadius(30.0f, 30.0f, 30.0f, 20.0f); @@ -3803,6 +4040,10 @@ int UtcDaliVisualRoundedCorner(void) // gradient visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float cornerRadius = 30.0f; @@ -3850,6 +4091,10 @@ int UtcDaliVisualRoundedCorner(void) // animated image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; Vector4 cornerRadius(24.0f, 23.0f, 22.0f, 21.0f); @@ -3885,6 +4130,10 @@ int UtcDaliVisualRoundedCorner(void) // vector image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; Vector4 cornerRadius(27.0f, 72.0f, 11.0f, 500.5f); @@ -3907,7 +4156,8 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Wait for loading & rasterization + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -3919,6 +4169,10 @@ int UtcDaliVisualRoundedCorner(void) // animated vector image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float cornerRadius = 1.3f; @@ -3943,7 +4197,8 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -3957,7 +4212,6 @@ int UtcDaliVisualRoundedCorner(void) int UtcDaliVisualBorderline(void) { - ToolkitTestApplication application; tet_infoline("UtcDaliVisualBorderline"); static std::vector customUniforms = @@ -3969,11 +4223,12 @@ int UtcDaliVisualBorderline(void) UniformData("borderlineOffset", Property::Type::FLOAT), }; - TestGraphicsController& graphics = application.GetGraphicsController(); - graphics.AddCustomUniforms(customUniforms); - // image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float cornerRadius = 5.0f; @@ -4017,6 +4272,10 @@ int UtcDaliVisualBorderline(void) // color visual 1 { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; Vector4 cornerRadius(23.0f, 2.0f, 3.0f, 2.3f); @@ -4056,6 +4315,10 @@ int UtcDaliVisualBorderline(void) // color visual 2, default color, default offset { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float borderlineWidth = 30.0f; @@ -4090,6 +4353,10 @@ int UtcDaliVisualBorderline(void) // color visual 3, offset not [-1.0 ~ 1.0], but uniform value is same anyway { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float borderlineWidth = 30.0f; @@ -4127,6 +4394,10 @@ int UtcDaliVisualBorderline(void) // gradient visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float borderlineWidth = 30.0f; @@ -4181,6 +4452,10 @@ int UtcDaliVisualBorderline(void) // animated image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float borderlineWidth = 24.0f; @@ -4219,6 +4494,10 @@ int UtcDaliVisualBorderline(void) // vector image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; Vector4 cornerRadius(54.0f, 43.0f, 32.0f, 21.0f); @@ -4245,7 +4524,8 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Wait for loading & rasterization + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -4261,6 +4541,10 @@ int UtcDaliVisualBorderline(void) // animated vector image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; Vector4 cornerRadius(1.3f, 0.0f, 0.4f, 0.2f); @@ -4290,7 +4574,8 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -4735,8 +5020,7 @@ int UtcDaliVisualGetVisualProperty01(void) UniformData("blurRadius", Property::Type::FLOAT), UniformData("borderlineWidth", Property::Type::FLOAT), UniformData("borderlineColor", Property::Type::VECTOR4), - UniformData("borderlineOffset", Property::Type::FLOAT), - UniformData("preMultipliedAlpha", Property::Type::FLOAT)}; + UniformData("borderlineOffset", Property::Type::FLOAT)}; TestGraphicsController& graphics = application.GetGraphicsController(); graphics.AddCustomUniforms(customUniforms); @@ -4751,7 +5035,6 @@ int UtcDaliVisualGetVisualProperty01(void) propertyMap.Insert(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f); propertyMap.Insert(DevelVisual::Property::BORDERLINE_COLOR, Color::RED); propertyMap.Insert(DevelVisual::Property::BORDERLINE_OFFSET, 1.0f); - propertyMap.Insert(Visual::Property::PREMULTIPLIED_ALPHA, true); Visual::Base colorVisual = factory.CreateVisual(propertyMap); DummyControl dummyControl = DummyControl::New(true); @@ -4771,8 +5054,7 @@ int UtcDaliVisualGetVisualProperty01(void) float targetBlurRadius = 10.0f; float targetBorderlineWidth = 25.0f; Vector4 targetBorderlineColor(1.0f, 1.0f, 1.0f, 1.0f); - float targetBorderlineOffset = -1.0f; - float targetPreMultipliedAlpha = 1.0f; + float targetBorderlineOffset = -1.0f; Animation animation = Animation::New(1.0f); animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::MIX_COLOR), targetColor); @@ -4830,10 +5112,6 @@ int UtcDaliVisualGetVisualProperty01(void) DALI_TEST_CHECK(borderlineOffsetValue); DALI_TEST_EQUALS(borderlineOffsetValue->Get(), targetBorderlineOffset, TEST_LOCATION); - Property::Value* preMultAlphaValue = resultMap.Find(Visual::Property::PREMULTIPLIED_ALPHA, Property::BOOLEAN); - DALI_TEST_CHECK(preMultAlphaValue); - DALI_TEST_EQUALS(preMultAlphaValue->Get(), bool(targetPreMultipliedAlpha), TEST_LOCATION); - // Test uniform values DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("mixColor", targetColor), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("offset", targetOffset), true, TEST_LOCATION); @@ -4843,7 +5121,6 @@ int UtcDaliVisualGetVisualProperty01(void) DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineWidth", targetBorderlineWidth), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineColor", targetBorderlineColor), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineOffset", targetBorderlineOffset), true, TEST_LOCATION); - DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("preMultipliedAlpha", targetPreMultipliedAlpha), true, TEST_LOCATION); // Test unregistered visual Property property3 = DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL2, Visual::Property::MIX_COLOR); @@ -5150,8 +5427,8 @@ int UtcDaliVisualGetVisualProperty05(void) application.SendNotification(); application.Render(); - // Wait for image loading - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Wait for loading & rasterization + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -5330,8 +5607,8 @@ int UtcDaliVisualGetVisualProperty07(void) application.SendNotification(); application.Render(); - // Wait for image loading - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -5424,6 +5701,10 @@ int UtcDaliVisualUpdateProperty(void) Vector3 targetMixColor = Vector3(1.0f, 0.4f, 0.2f); bool targetPreMultipliedAlpha = originalMap[Visual::Property::PREMULTIPLIED_ALPHA].Get() ^ true; DevelVisual::FittingMode targetVisualFittingMode = DevelVisual::CENTER; + Vector4 targetCornerRadius = Vector4(10.0f, 0.0f, 1.0f, 2.0f); + float targetBorderlineWidth = 20.0f; + Vector4 targetBorderlineColor = Color::RED; + float targetBorderlineOffset = 1.0f; Property::Map targetPropertyMap; targetPropertyMap[Visual::Property::OPACITY] = targetOpacity; @@ -5431,6 +5712,10 @@ int UtcDaliVisualUpdateProperty(void) targetPropertyMap[Visual::Property::MIX_COLOR] = targetMixColor; targetPropertyMap[Visual::Property::PREMULTIPLIED_ALPHA] = targetPreMultipliedAlpha; targetPropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = targetVisualFittingMode; + targetPropertyMap[DevelVisual::Property::CORNER_RADIUS] = targetCornerRadius; + targetPropertyMap[DevelVisual::Property::BORDERLINE_WIDTH] = targetBorderlineWidth; + targetPropertyMap[DevelVisual::Property::BORDERLINE_COLOR] = targetBorderlineColor; + targetPropertyMap[DevelVisual::Property::BORDERLINE_OFFSET] = targetBorderlineOffset; // Update Properties DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap); @@ -5456,6 +5741,104 @@ int UtcDaliVisualUpdateProperty(void) DALI_TEST_CHECK(visualFittingModeValue); DALI_TEST_EQUALS(visualFittingModeValue->Get(), "CENTER", 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); + + Property::Value* borderlineWidthValue = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT); + DALI_TEST_CHECK(borderlineWidthValue); + DALI_TEST_EQUALS(borderlineWidthValue->Get(), targetBorderlineWidth, TEST_LOCATION); + + Property::Value* borderlineColorValue = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4); + DALI_TEST_CHECK(borderlineColorValue); + DALI_TEST_EQUALS(borderlineColorValue->Get(), targetBorderlineColor, TEST_LOCATION); + + Property::Value* borderlineOffsetValue = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT); + DALI_TEST_CHECK(borderlineOffsetValue); + DALI_TEST_EQUALS(borderlineOffsetValue->Get(), targetBorderlineOffset, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliVisualUpdatePropertyInvalidType(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliVisualUpdatePropertyInvalidType: Test update property by DoAction. But some value is not invalid to update"); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap[Visual::Property::TYPE] = Visual::Type::N_PATCH; + propertyMap[ImageVisual::Property::URL] = TEST_NPATCH_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(); + + 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; + Vector4 targetCornerRadius = Vector4(10.0f, 0.0f, 1.0f, 2.0f); + float targetBorderlineWidth = 20.0f; + Vector4 targetBorderlineColor = Color::RED; + float targetBorderlineOffset = 1.0f; + + 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; + + // Properties that N_PATCH visual could not used. + targetPropertyMap[DevelVisual::Property::CORNER_RADIUS] = targetCornerRadius; + targetPropertyMap[DevelVisual::Property::BORDERLINE_WIDTH] = targetBorderlineWidth; + targetPropertyMap[DevelVisual::Property::BORDERLINE_COLOR] = targetBorderlineColor; + targetPropertyMap[DevelVisual::Property::BORDERLINE_OFFSET] = targetBorderlineOffset; + + // 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 : NPatchVisual URL must NOT changed. + DALI_TEST_EQUALS(urlValue->Get(), TEST_NPATCH_FILE_NAME, TEST_LOCATION); + + Property::Value* preMultipliedValue = resultMap.Find(Visual::Property::PREMULTIPLIED_ALPHA, Property::BOOLEAN); + DALI_TEST_CHECK(preMultipliedValue); + DALI_TEST_EQUALS(preMultipliedValue->Get(), targetPreMultipliedAlpha, TEST_LOCATION); + + Property::Value* visualFittingModeValue = resultMap.Find(DevelVisual::Property::VISUAL_FITTING_MODE, Property::STRING); + DALI_TEST_CHECK(visualFittingModeValue); + DALI_TEST_EQUALS(visualFittingModeValue->Get(), "CENTER", TEST_LOCATION); + + // We don't check properties value that N_PATCH visual could not used. + // It is undefined. + END_TEST; } @@ -5489,27 +5872,14 @@ int UtcDaliVisualUpdatePropertyChangeShader01(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", false}, + {"#define IS_REQUIRED_ROUNDED_CORNER", false}, + }, + TEST_LOCATION); + callStack.Reset(); callStack.Enable(true); @@ -5534,27 +5904,13 @@ int UtcDaliVisualUpdatePropertyChangeShader01(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", false}, + {"#define IS_REQUIRED_ROUNDED_CORNER", true}, + }, + TEST_LOCATION); // Send shader compile signal application.SendNotification(); @@ -5604,29 +5960,13 @@ int UtcDaliVisualUpdatePropertyChangeShader01(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", true}, + {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true. + }, + TEST_LOCATION); // Send shader compile signal application.SendNotification(); @@ -5672,29 +6012,13 @@ int UtcDaliVisualUpdatePropertyChangeShader01(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", true}, // Note : mAlwaysUsingBorderline is true. + {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true. + }, + TEST_LOCATION); // Send shader compile signal application.SendNotification(); @@ -5737,27 +6061,13 @@ int UtcDaliVisualUpdatePropertyChangeShader02(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", false}, + {"#define IS_REQUIRED_ROUNDED_CORNER", false}, + }, + TEST_LOCATION); Vector4 targetCornerRadius = Vector4(0.0f, 0.0f, 0.0f, 0.0f); @@ -5778,29 +6088,13 @@ int UtcDaliVisualUpdatePropertyChangeShader02(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", false}, + {"#define IS_REQUIRED_ROUNDED_CORNER", false}, // Note : corner radius is zero. so we don't change shader! + }, + TEST_LOCATION); // Send shader compile signal application.SendNotification(); @@ -5841,29 +6135,13 @@ int UtcDaliVisualUpdatePropertyChangeShader02(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", false}, // Note : borderline width is zero. so we don't change shader! + {"#define IS_REQUIRED_ROUNDED_CORNER", false}, + }, + TEST_LOCATION); // Send shader compile signal application.SendNotification(); @@ -5904,29 +6182,14 @@ int UtcDaliVisualUpdatePropertyChangeShader03(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BLUR", false}, + {"#define IS_REQUIRED_BORDERLINE", false}, + {"#define IS_REQUIRED_ROUNDED_CORNER", false}, + }, + TEST_LOCATION); float targetBlurRadius = 15.0f; Vector4 targetCornerRadius = Vector4(1.0f, 0.1f, 1.1f, 0.0f); @@ -5954,31 +6217,14 @@ int UtcDaliVisualUpdatePropertyChangeShader03(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BLUR", true}, + {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured + {"#define IS_REQUIRED_ROUNDED_CORNER", true}, + }, + TEST_LOCATION); // Send shader compile signal application.SendNotification(); @@ -6011,33 +6257,14 @@ int UtcDaliVisualUpdatePropertyChangeShader03(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BLUR", true}, // Note : mAlwaysUsingBlurRadius is true. + {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured + {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true. + }, + TEST_LOCATION); // Send shader compile signal application.SendNotification(); @@ -6082,27 +6309,14 @@ int UtcDaliVisualUpdatePropertyChangeShader04(void) 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", false}, + {"#define IS_REQUIRED_ROUNDED_CORNER", true}, + }, + TEST_LOCATION); + callStack.Reset(); callStack.Enable(true); @@ -6116,29 +6330,14 @@ int UtcDaliVisualUpdatePropertyChangeShader04(void) application.Render(); application.Render(1001u); // End of animation - // 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", false}, + {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true. + }, + TEST_LOCATION); + callStack.Enable(false); // Shader not changed DALI_TEST_CHECK(!callStack.FindMethod("CreateShader")); @@ -6168,29 +6367,13 @@ int UtcDaliVisualUpdatePropertyChangeShader04(void) DALI_TEST_CHECK(borderlineWidthValue); DALI_TEST_EQUALS(borderlineWidthValue->Get(), targetBorderlineWidth, 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); - } + TestShaderCodeContainSubstrings( + dummyControl, + { + {"#define IS_REQUIRED_BORDERLINE", true}, + {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true. + }, + TEST_LOCATION); // Send shader compile signal application.SendNotification();