X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Visual.cpp;h=07c8564b2cdb78c71a8efa3ee5df55413341b260;hb=3638fc255ad784cecea605d0e942391b9051ccd4;hp=ab45fc08574aa0ae71cd763efc6508c67b097a53;hpb=05e6b5073a18b6ebe1f536a3693300b3ee35b199;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 ab45fc0..07c8564 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -395,7 +397,7 @@ int UtcDaliVisualSize(void) int UtcDaliVisualSetOnOffStage(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualSetDepthIndex" ); + tet_infoline( "UtcDaliVisualSetOnOffStage" ); VisualFactory factory = VisualFactory::Get(); Property::Map propertyMap; @@ -428,6 +430,64 @@ int UtcDaliVisualSetOnOffStage(void) END_TEST; } +int UtcDaliVisualSetOnOffStage2(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualSetOnOffStage2" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::SVG ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ); + Visual::Base visual = factory.CreateVisual( propertyMap ); + + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); + + actor.SetSize(200.f, 200.f); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + + // First on/off + Stage::GetCurrent().Add( actor ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + Renderer renderer = actor.GetRendererAt( 0 ); + auto textures = renderer.GetTextures(); + DALI_TEST_CHECK( textures.GetTextureCount() != 0u ); + + Stage::GetCurrent().Remove( actor ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + + // Second on/off + Stage::GetCurrent().Add( actor ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + renderer = actor.GetRendererAt( 0 ); + textures = renderer.GetTextures(); + DALI_TEST_CHECK( textures.GetTextureCount() != 0u ); + + Stage::GetCurrent().Remove( actor ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + + END_TEST; +} + int UtcDaliVisualGetPropertyMap1(void) { ToolkitTestApplication application; @@ -1127,6 +1187,9 @@ int UtcDaliVisualGetPropertyMap10(void) Property::Map outlineMapSet; propertyMap.Insert( "outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1) ); + Property::Map backgroundMapSet; + propertyMap.Insert( "textBackground", backgroundMapSet.Add("enable", true).Add("color", Color::CYAN) ); + Visual::Base textVisual = factory.CreateVisual( propertyMap ); Property::Map resultMap; @@ -1201,6 +1264,13 @@ int UtcDaliVisualGetPropertyMap10(void) DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION ); DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION ); + value = resultMap.Find( DevelTextVisual::Property::BACKGROUND, Property::MAP ); + DALI_TEST_CHECK( value ); + + Property::Map backgroundMapGet = value->Get(); + DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION ); + END_TEST; } @@ -1704,7 +1774,7 @@ int UtcDaliVisualAnimateBorderVisual01(void) Property::Map map; map["target"] = "testVisual"; map["property"] = "mixColor"; - map["targetValue"] = Vector4(1,1,1,0); + map["targetValue"] = Vector4(1,1,1,0.1); map["animator"] = Property::Map() .Add("alphaFunction", "LINEAR") .Add("timePeriod", Property::Map() @@ -1743,10 +1813,13 @@ int UtcDaliVisualAnimateBorderVisual01(void) DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderColor", testColor ), true, TEST_LOCATION ); color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex ); - testColor = Vector4( 1,1,1,0.4f ); + testColor = Vector4( 1,1,1,0.45f ); DALI_TEST_EQUALS( Vector3(color), Vector3(testColor), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector3(testColor) ), true, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("opacity", testColor.a ) , true, TEST_LOCATION ); + + Vector4 uColor; + DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", uColor ) ); + DALI_TEST_EQUALS( uColor.a, testColor.a, TEST_LOCATION ); application.Render(2000u); @@ -1754,11 +1827,13 @@ int UtcDaliVisualAnimateBorderVisual01(void) DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderColor", Color::WHITE ), true, TEST_LOCATION ); - color = renderer.GetCurrentProperty< Vector4 >( mixColorIndex ); - testColor = Vector4(1,1,1,0); - DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); + color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex ); + testColor = Vector4(1,1,1,0.1); + DALI_TEST_EQUALS( Vector3(color), Vector3(testColor), TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector3(testColor) ), true, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("opacity", testColor.a ), true, TEST_LOCATION ); + + DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", uColor ) ); + DALI_TEST_EQUALS( uColor.a, testColor.a, TEST_LOCATION ); END_TEST; } @@ -1919,19 +1994,16 @@ int UtcDaliVisualAnimatePrimitiveVisual(void) application.Render(2000u); // halfway point application.SendNotification(); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Vector4(0.5f, 0.5f, 0.5f, 1.0f )), true, TEST_LOCATION ); - Vector4 halfwayColor = (INITIAL_MIX_COLOR + TARGET_MIX_COLOR)*0.5; + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Vector4(0.5f, 0.5f, 0.5f, halfwayColor.a )), true, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector3(halfwayColor) ), true, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("opacity", halfwayColor.a ), true, TEST_LOCATION ); application.Render(2001u); // go past end application.SendNotification(); // Trigger signals DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Color::WHITE ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Vector4( 1.0f, 1.0f, 1.0f, TARGET_MIX_COLOR.a ) ), true, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector3(TARGET_MIX_COLOR) ), true, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("opacity", TARGET_MIX_COLOR.a ), true, TEST_LOCATION ); blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); @@ -3392,3 +3464,53 @@ int UtcDaliRegisterVisualWithDepthIndex(void) END_TEST; } + +int UtcDaliColorVisualRenderIfTransparentProperty(void) +{ + ToolkitTestApplication application; + tet_infoline( "Test the renderIfTransparent property of ColorVisual" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::COLOR ); + propertyMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLUE ); + + tet_infoline( "Check default value" ); + { + Visual::Base testVisual = factory.CreateVisual( propertyMap ); + Property::Map returnedMap; + testVisual.CreatePropertyMap( returnedMap ); + + Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT ); + DALI_TEST_CHECK( renderIfTransparentProperty ); + DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION ); + } + + propertyMap.Insert( DevelColorVisual::Property::RENDER_IF_TRANSPARENT, true ); + + tet_infoline( "Ensure set to value required" ); + { + Visual::Base testVisual = factory.CreateVisual( propertyMap ); + Property::Map returnedMap; + testVisual.CreatePropertyMap( returnedMap ); + + Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT ); + DALI_TEST_CHECK( renderIfTransparentProperty ); + DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), true, TEST_LOCATION ); + } + + propertyMap[ DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = Color::BLUE; + + tet_infoline( "Ensure it returns default value if set to wrong type" ); + { + Visual::Base testVisual = factory.CreateVisual( propertyMap ); + Property::Map returnedMap; + testVisual.CreatePropertyMap( returnedMap ); + + Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT ); + DALI_TEST_CHECK( renderIfTransparentProperty ); + DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION ); + } + + END_TEST; +}