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=7c13fc124409f8832ad5fd06fe9d2f33fc284d8e;hp=7d77a1bbeeec623eb42e77f1f3dcea754d5b3ebf;hb=aeddb4e028e43d5c25729f1b0e947c1138a8779d;hpb=e54ea0676d3bbe53d40309a41b1b415f8f6a64d4 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 7d77a1b..7c13fc1 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -141,6 +141,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 +357,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 +364,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 +473,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(); @@ -615,20 +635,6 @@ int UtcDaliVisualGetPropertyMap2(void) DALI_TEST_CHECK(sizeValue); DALI_TEST_CHECK(sizeValue->Get() == 10.f); - // Get default value of borderline values here - - sizeValue = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT); - DALI_TEST_CHECK(sizeValue); - DALI_TEST_CHECK(sizeValue->Get() == 0.0f); - - colorValue = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4); - DALI_TEST_CHECK(colorValue); - DALI_TEST_CHECK(colorValue->Get() == Color::BLACK); - - sizeValue = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT); - DALI_TEST_CHECK(sizeValue); - DALI_TEST_CHECK(sizeValue->Get() == 0.0f); - END_TEST; } @@ -932,7 +938,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); @@ -973,7 +979,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; } @@ -3470,7 +3476,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() @@ -3485,6 +3491,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; } @@ -3650,7 +3799,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(); @@ -3669,7 +3819,6 @@ int UtcDaliSvgVisualCustomShader(void) int UtcDaliVisualRoundedCorner(void) { - ToolkitTestApplication application; tet_infoline("UtcDaliVisualRoundedCorner"); static std::vector customUniforms = @@ -3678,11 +3827,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; @@ -3717,6 +3867,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; @@ -3743,15 +3897,17 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius)), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE), true, TEST_LOCATION); -#endif } // 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); @@ -3778,15 +3934,17 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", cornerRadius), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE), true, TEST_LOCATION); -#endif } // 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); @@ -3813,16 +3971,18 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", cornerRadius), true, TEST_LOCATION); // Default corner radius policy is absolute. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE), true, TEST_LOCATION); -#endif } // gradient visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float cornerRadius = 30.0f; @@ -3863,16 +4023,17 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius)), true, TEST_LOCATION); // Default corner radius policy is absolute. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE), true, TEST_LOCATION); -#endif } // 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); @@ -3902,15 +4063,16 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", cornerRadius), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE), true, TEST_LOCATION); -#endif } // 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); @@ -3933,21 +4095,23 @@ 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(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", cornerRadius), true, TEST_LOCATION); // Default corner radius policy is absolute. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE), true, TEST_LOCATION); -#endif } // animated vector image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float cornerRadius = 1.3f; @@ -3977,11 +4141,8 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius)), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE), true, TEST_LOCATION); -#endif } END_TEST; @@ -3989,7 +4150,6 @@ int UtcDaliVisualRoundedCorner(void) int UtcDaliVisualBorderline(void) { - ToolkitTestApplication application; tet_infoline("UtcDaliVisualBorderline"); static std::vector customUniforms = @@ -4001,11 +4161,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; @@ -4049,6 +4210,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); @@ -4080,17 +4245,18 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", cornerRadius), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineWidth", borderlineWidth), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineColor", borderlineColor), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineOffset", borderlineOffset), true, TEST_LOCATION); -#endif } // 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; @@ -4116,18 +4282,19 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineWidth", borderlineWidth), true, TEST_LOCATION); // Default borderline color is BLACK. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineColor", Color::BLACK), true, TEST_LOCATION); // Default borderline offset is 0.0f. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineOffset", 0.0f), true, TEST_LOCATION); -#endif } // 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; @@ -4157,17 +4324,18 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineWidth", borderlineWidth), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineColor", borderlineColor), true, TEST_LOCATION); // NOTE : borderlineOffset will clamp in fragment shader. not visual itself DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineOffset", borderlineOffset), true, TEST_LOCATION); -#endif } // gradient visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float borderlineWidth = 30.0f; @@ -4210,8 +4378,6 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius)), true, TEST_LOCATION); // Default corner radius policy is absolute. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE), true, TEST_LOCATION); @@ -4220,11 +4386,14 @@ int UtcDaliVisualBorderline(void) DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineColor", Color::BLACK), true, TEST_LOCATION); // Default borderline offset is 0.0f. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineOffset", 0.0f), true, TEST_LOCATION); -#endif } // animated image visual { + ToolkitTestApplication application; + TestGraphicsController& graphics = application.GetGraphicsController(); + graphics.AddCustomUniforms(customUniforms); + VisualFactory factory = VisualFactory::Get(); Property::Map properties; float borderlineWidth = 24.0f; @@ -4255,17 +4424,18 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineWidth", borderlineWidth), true, TEST_LOCATION); // Default borderline color is BLACK. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineColor", Color::BLACK), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineOffset", borderlineOffset), true, TEST_LOCATION); -#endif } // 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); @@ -4292,13 +4462,12 @@ 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(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", cornerRadius), true, TEST_LOCATION); // Default corner radius policy is absolute. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE), true, TEST_LOCATION); @@ -4306,11 +4475,14 @@ int UtcDaliVisualBorderline(void) DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineColor", borderlineColor), true, TEST_LOCATION); // Default borderline offset is 0.0. DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineOffset", 0.0f), true, TEST_LOCATION); -#endif } // 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); @@ -4345,14 +4517,11 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", cornerRadius), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineWidth", borderlineWidth), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineColor", borderlineColor), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("borderlineOffset", borderlineOffset), true, TEST_LOCATION); -#endif } END_TEST; @@ -4788,8 +4957,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); @@ -4804,7 +4972,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); @@ -4824,8 +4991,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); @@ -4883,10 +5049,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); @@ -4896,7 +5058,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); @@ -5007,15 +5168,12 @@ int UtcDaliVisualGetVisualProperty02(void) DALI_TEST_CHECK(blurRadiusValue); DALI_TEST_EQUALS(blurRadiusValue->Get(), targetBlurRadius, TEST_LOCATION); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day // 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); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("size", targetSize), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", targetCornerRadius), true, TEST_LOCATION); DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("blurRadius", targetBlurRadius), true, TEST_LOCATION); -#endif END_TEST; } @@ -5097,14 +5255,11 @@ int UtcDaliVisualGetVisualProperty03(void) DALI_TEST_CHECK(borderlineOffsetValue); DALI_TEST_EQUALS(borderlineOffsetValue->Get(), targetBorderlineOffset, TEST_LOCATION); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day // Test uniform value DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", targetCornerRadius), true, TEST_LOCATION); 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); -#endif END_TEST; } @@ -5171,11 +5326,8 @@ int UtcDaliVisualGetVisualProperty04(void) DALI_TEST_CHECK(cornerRadiusValue); DALI_TEST_EQUALS(cornerRadiusValue->Get(), targetCornerRadius, TEST_LOCATION); -#ifdef OLD_GRAPHICS_TEST - // Currently test with multiple program doesn't work well. will fix another day // Test uniform value DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", targetCornerRadius), true, TEST_LOCATION); -#endif END_TEST; } @@ -5212,8 +5364,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(); @@ -5260,14 +5412,12 @@ int UtcDaliVisualGetVisualProperty05(void) DALI_TEST_CHECK(borderlineOffsetValue); DALI_TEST_EQUALS(borderlineOffsetValue->Get(), targetBorderlineOffset, TEST_LOCATION); -#ifdef OLD_GRAPHICS_TEST // Currently test with multiple program doesn't work well. will fix another day // Test uniform value DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", targetCornerRadius), true, TEST_LOCATION); 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); -#endif END_TEST; } @@ -5352,14 +5502,12 @@ int UtcDaliVisualGetVisualProperty06(void) DALI_TEST_CHECK(borderlineOffsetValue); DALI_TEST_EQUALS(borderlineOffsetValue->Get(), targetBorderlineOffset, TEST_LOCATION); -#ifdef OLD_GRAPHICS_TEST // Currently test with multiple program doesn't work well. will fix another day // Test uniform value DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", targetCornerRadius), true, TEST_LOCATION); 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); -#endif END_TEST; } @@ -5444,14 +5592,12 @@ int UtcDaliVisualGetVisualProperty07(void) DALI_TEST_CHECK(borderlineOffsetValue); DALI_TEST_EQUALS(borderlineOffsetValue->Get(), targetBorderlineOffset, TEST_LOCATION); -#ifdef OLD_GRAPHICS_TEST // Currently test with multiple program doesn't work well. will fix another day // Test uniform value DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue("cornerRadius", targetCornerRadius), true, TEST_LOCATION); 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); -#endif END_TEST; } @@ -5557,27 +5703,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); @@ -5602,27 +5735,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(); @@ -5672,29 +5791,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(); @@ -5740,29 +5843,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(); @@ -5805,27 +5892,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); @@ -5846,29 +5919,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(); @@ -5909,29 +5966,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(); @@ -5972,29 +6013,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); @@ -6022,31 +6048,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(); @@ -6079,33 +6088,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(); @@ -6122,21 +6112,21 @@ int UtcDaliVisualUpdatePropertyChangeShader03(void) int UtcDaliVisualUpdatePropertyChangeShader04(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualUpdatePropertyChangeShader04: Test update property by DoAction during Animation. Change the shader case" ); + tet_infoline("UtcDaliVisualUpdatePropertyChangeShader04: Test update property by DoAction during Animation. 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; + propertyMap[Visual::Property::TYPE] = Visual::Type::IMAGE; + propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME; propertyMap[DevelVisual::Property::CORNER_RADIUS] = 10.0f; Visual::Base imageVisual = factory.CreateVisual(propertyMap); - DummyControl dummyControl = DummyControl::New(true); - Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + 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); @@ -6150,27 +6140,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); @@ -6184,32 +6161,17 @@ 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") ); + DALI_TEST_CHECK(!callStack.FindMethod("CreateShader")); callStack.Reset(); callStack.Enable(true); @@ -6221,7 +6183,7 @@ int UtcDaliVisualUpdatePropertyChangeShader04(void) DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Action::UPDATE_PROPERTY, targetPropertyMap); Property::Map resultMap; - imageVisual.CreatePropertyMap( resultMap ); + imageVisual.CreatePropertyMap(resultMap); // Test property values: they should be updated Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4); @@ -6236,29 +6198,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(); @@ -6266,7 +6212,7 @@ int UtcDaliVisualUpdatePropertyChangeShader04(void) callStack.Enable(false); // Shader changed - DALI_TEST_CHECK( callStack.FindMethod("CreateShader") ); + DALI_TEST_CHECK(callStack.FindMethod("CreateShader")); END_TEST; }