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=74cab9477d0824017d96659b57187cd8fb03b41c;hp=2e829f146efa82e94e66832a8d7fab38f41fb209;hb=HEAD;hpb=1a357dda85bd4ea90c9ba7a467c63a4a1a45f1c9 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 2e829f1..e2659ff 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -141,7 +141,6 @@ 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); @@ -150,6 +149,17 @@ void TestShaderCodeContainSubstrings(Control control, std::vectorFind("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); + } + Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp DALI_TEST_CHECK(fragment); std::string fragmentShader; @@ -161,6 +171,15 @@ 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* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp std::string vertexShader; @@ -168,10 +187,22 @@ void TestShaderCodeContainSubstrings(Control control, std::vectorFind("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.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); + } } } //namespace @@ -1259,7 +1290,7 @@ int UtcDaliVisualGetPropertyMap10(void) propertyMap.Insert("underline", underlineMapSet.Add("enable", true).Add("color", Color::GREEN).Add("height", 1).Add("type", Text::Underline::Type::SOLID).Add("dashWidth", 2).Add("dashGap", 1)); Property::Map outlineMapSet; - propertyMap.Insert("outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1)); + propertyMap.Insert("outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1).Add("offset", Vector2(2.0f, 2.0f)).Add("blurRadius", 3.0f)); Property::Map backgroundMapSet; propertyMap.Insert("textBackground", backgroundMapSet.Add("enable", true).Add("color", Color::CYAN)); @@ -3731,11 +3762,11 @@ int UtcDaliRegisterVisualOrder(void) dummyImpl.RegisterVisual(DummyControl::Property::FOCUS_VISUAL, focusVisual); DALI_TEST_CHECK(focusVisual.GetDepthIndex() > foregroundVisual.GetDepthIndex()); - tet_infoline("Set depth index on a new visual before registering, the depth index should not have been changed"); + tet_infoline("Set depth index on a new visual before registering, the depth index should not have been changed, and be clampled"); Visual::Base labelVisual = factory.CreateVisual(propertyMap); - labelVisual.SetDepthIndex(-2000); + labelVisual.SetDepthIndex(static_cast(Toolkit::DepthIndex::MINIMUM_DEPTH_INDEX) - 100); dummyImpl.RegisterVisual(DummyControl::Property::LABEL_VISUAL, labelVisual); - DALI_TEST_EQUALS(labelVisual.GetDepthIndex(), -2000, TEST_LOCATION); + DALI_TEST_EQUALS(labelVisual.GetDepthIndex(), static_cast(Toolkit::DepthIndex::MINIMUM_DEPTH_INDEX), TEST_LOCATION); tet_infoline("Replace visual, the depth index should be the same as what was previously set"); const int testVisual2DepthIndex = testVisual2.GetDepthIndex(); @@ -3744,11 +3775,11 @@ int UtcDaliRegisterVisualOrder(void) dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, testVisual2Replacement); DALI_TEST_EQUALS(testVisual2Replacement.GetDepthIndex(), testVisual2DepthIndex, TEST_LOCATION); - tet_infoline("Replace visual and set a depth index on the replacement, the depth index of the replacement should be honoured"); + tet_infoline("Replace visual and set a depth index on the replacement, the depth index of the replacement should be honoured, and be clampled"); Visual::Base anotherTestVisual2Replacement = factory.CreateVisual(propertyMap); - anotherTestVisual2Replacement.SetDepthIndex(2000); + anotherTestVisual2Replacement.SetDepthIndex(static_cast(Toolkit::DepthIndex::MAXIMUM_DEPTH_INDEX) + 100); dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement); - DALI_TEST_EQUALS(anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION); + DALI_TEST_EQUALS(anotherTestVisual2Replacement.GetDepthIndex(), static_cast(Toolkit::DepthIndex::MAXIMUM_DEPTH_INDEX), TEST_LOCATION); dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); application.GetScene().Add(dummyControl); @@ -3775,7 +3806,7 @@ int UtcDaliRegisterVisualOrder02(void) dummyControl.SetProperty(Control::Property::BACKGROUND, propertyMap); - const int TEST_VISUAL_1_DEPTH_INDEX = 0; + const int TEST_VISUAL_1_DEPTH_INDEX = static_cast(Toolkit::DepthIndex::CONTENT); tet_printf("Register visual, should have depth index of %d\n", TEST_VISUAL_1_DEPTH_INDEX); Visual::Base testVisual1 = factory.CreateVisual(propertyMap); dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, testVisual1); @@ -3784,7 +3815,14 @@ int UtcDaliRegisterVisualOrder02(void) tet_printf("Register another visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_1_DEPTH_INDEX); Visual::Base testVisual2 = factory.CreateVisual(propertyMap); dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, testVisual2); - DALI_TEST_CHECK(testVisual2.GetDepthIndex() > testVisual1.GetDepthIndex()); + DALI_TEST_GREATER(testVisual2.GetDepthIndex(), testVisual1.GetDepthIndex(), TEST_LOCATION); + + const int TEST_VISUAL_2_DEPTH_INDEX = testVisual2.GetDepthIndex(); + + tet_printf("Register other visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_2_DEPTH_INDEX); + Visual::Base testVisual3 = factory.CreateVisual(propertyMap); + dummyImpl.RegisterVisual(DummyControl::Property::FOREGROUND_VISUAL, testVisual3, Toolkit::DepthIndex::AUTO_INDEX); + DALI_TEST_GREATER(testVisual3.GetDepthIndex(), testVisual2.GetDepthIndex(), TEST_LOCATION); dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); application.GetScene().Add(dummyControl); @@ -6545,12 +6583,13 @@ int UtcDaliVisualUpdatePropertyChangeShader05(void) DALI_TEST_CHECK(cornerRadiusValue); DALI_TEST_EQUALS(cornerRadiusValue->Get(), targetCornerRadius, TEST_LOCATION); - TestShaderCodeContainSubstrings( + TestShaderCodeContainSubstringsForEachShader( dummyControl, { - {"#define IS_REQUIRED_BLUR", true}, - {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured - {"#define IS_REQUIRED_ROUNDED_CORNER", false}, // Note : low spec shader doesn't support rounded blur + {"#define IS_REQUIRED_BLUR", {true, true}}, + {"#define IS_REQUIRED_BORDERLINE", {false, false}}, // Note : We ignore borderline when blur radius occured + {"#define IS_REQUIRED_ROUNDED_CORNER", {true, true}}, + {"#define SL_VERSION_LOW", {false, true}}, }, TEST_LOCATION); @@ -6585,12 +6624,13 @@ int UtcDaliVisualUpdatePropertyChangeShader05(void) DALI_TEST_CHECK(cornerRadiusValue); DALI_TEST_EQUALS(cornerRadiusValue->Get(), Vector4::ZERO, TEST_LOCATION); - TestShaderCodeContainSubstrings( + TestShaderCodeContainSubstringsForEachShader( 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", false}, // Note : mAlwaysUsingCornerRadius is true. + {"#define IS_REQUIRED_BLUR", {true, true}}, // Note : mAlwaysUsingBlurRadius is true. + {"#define IS_REQUIRED_BORDERLINE", {false, false}}, // Note : We ignore borderline when blur radius occured + {"#define IS_REQUIRED_ROUNDED_CORNER", {true, true}}, // Note : mAlwaysUsingCornerRadius is true. + {"#define SL_VERSION_LOW", {false, true}}, }, TEST_LOCATION);