X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Visual.cpp;h=fae713a5eb39c129d03f069ccd4eb5bb198d365c;hb=refs%2Fchanges%2F42%2F104842%2F3;hp=04912a0ed2440ca0937cee38c9f3f309c4db0b1b;hpb=9217ec0c1d483607ed6c8f08a1d9c238657ba5d6;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 04912a0..fae713a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -924,6 +925,7 @@ int UtcDaliVisualGetPropertyMap10(void) Property::Map propertyMap; propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT ); propertyMap.Insert( "renderingBackend", static_cast( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) ); + propertyMap.Insert( "enableMarkup", false ); propertyMap.Insert( "text", "Hello world" ); propertyMap.Insert( "fontFamily", "TizenSans" ); @@ -936,7 +938,6 @@ int UtcDaliVisualGetPropertyMap10(void) propertyMap.Insert( "horizontalAlignment", "CENTER" ); propertyMap.Insert( "verticalAlignment", "CENTER" ); propertyMap.Insert( "textColor", Color::RED ); - propertyMap.Insert( "enableMarkup", false ); Visual::Base textVisual = factory.CreateVisual( propertyMap ); Property::Map resultMap; @@ -1041,7 +1042,7 @@ int UtcDaliVisualAnimateBorderVisual01(void) DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0); - Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::COLOR ); + Property::Index index = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::COLOR ); Animation animation = Animation::New(4.0f); animation.AnimateTo( Property(renderer, index), Color::WHITE ); @@ -1088,7 +1089,7 @@ int UtcDaliVisualAnimateBorderVisual02(void) DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0); - Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::SIZE ); + Property::Index index = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::SIZE ); Animation animation = Animation::New(4.0f); animation.AnimateTo( Property(renderer, index), 9.0f ); @@ -1132,7 +1133,7 @@ int UtcDaliVisualAnimateColorVisual(void) DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0); - Property::Index index = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR ); + Property::Index index = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR ); Animation animation = Animation::New(4.0f); animation.AnimateTo( Property(renderer, index), Color::WHITE ); @@ -1182,7 +1183,7 @@ int UtcDaliVisualAnimatePrimitiveVisual(void) DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0); - Property::Index index = renderer.GetPropertyIndex( PrimitiveVisual::Property::MIX_COLOR ); + Property::Index index = DevelHandle::GetPropertyIndex( renderer, PrimitiveVisual::Property::MIX_COLOR ); // The property isn't registered on the renderer, it's instead registered on the shader. DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION ); @@ -1531,6 +1532,15 @@ int UtcDaliNPatchVisualCustomShader(void) Property::Map shader; const std::string fragmentShader = "Foobar"; shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader; + + Property::Map transformMap; + transformMap["size"] = Vector2( 0.5f, 0.5f ) ; + transformMap["offset"] = Vector2( 20.0f, 0.0f ) ; + transformMap["offsetSizeMode"] = Vector4( 1.0f, 1.0f, 0.0f, 0.0f ); + transformMap["anchorPoint"] = Align::CENTER; + transformMap["origin"] = Align::CENTER; + properties[DevelVisual::Property::TRANSFORM] = transformMap; + properties[Dali::Toolkit::Visual::Property::TYPE] = Dali::Toolkit::Visual::IMAGE; properties[Dali::Toolkit::Visual::Property::SHADER]=shader; properties[Dali::Toolkit::ImageVisual::Property::URL] = TEST_NPATCH_FILE_NAME; @@ -1544,6 +1554,7 @@ int UtcDaliNPatchVisualCustomShader(void) dummy.SetSize(2000, 2000); dummy.SetParentOrigin(ParentOrigin::CENTER); Stage::GetCurrent().Add(dummy); + application.SendNotification(); Renderer renderer = dummy.GetRendererAt( 0 ); Shader shader2 = renderer.GetShader(); @@ -1551,6 +1562,9 @@ int UtcDaliNPatchVisualCustomShader(void) Property::Map* map = value.GetMap(); DALI_TEST_CHECK( map ); + Property::Index index = renderer.GetPropertyIndex("size"); + DALI_TEST_EQUALS( renderer.GetProperty( index ), Property::Value(Vector2(0.5, 0.5)), 0.001, TEST_LOCATION ); + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp // *map["vertex"]; is default here so not verifying it @@ -1654,6 +1668,7 @@ int UtcDaliVisualTextVisualRender(void) Property::Map propertyMap; propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT ); propertyMap.Insert( "renderingBackend", static_cast( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) ); + propertyMap.Insert( "enableMarkup", false ); propertyMap.Insert( "text", "Hello world" ); propertyMap.Insert( "fontFamily", "TizenSans" ); @@ -1666,7 +1681,6 @@ int UtcDaliVisualTextVisualRender(void) propertyMap.Insert( "horizontalAlignment", "CENTER" ); propertyMap.Insert( "verticalAlignment", "CENTER" ); propertyMap.Insert( "textColor", Color::RED ); - propertyMap.Insert( "enableMarkup", false ); Visual::Base textVisual = factory.CreateVisual( propertyMap ); textVisual.SetDepthIndex( 1.f ); @@ -1676,10 +1690,98 @@ int UtcDaliVisualTextVisualRender(void) DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION ); dummyControl.SetSize(200.f, 200.f); + dummyControl.SetParentOrigin( ParentOrigin::CENTER ); Stage::GetCurrent().Add( dummyControl ); application.SendNotification(); application.Render(); + + // Create a texture bigger than the maximum allowed by the image atlas. Used to increase coverage. + propertyMap.Clear(); + propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT ); + propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true ); + propertyMap.Insert( TextVisual::Property::TEXT, "Hello world" ); + propertyMap.Insert( TextVisual::Property::MULTI_LINE, true ); + + Property::Map transformMap; + transformMap.Insert( "size", Vector2( 0.5f, 0.5f ) ); + propertyMap.Insert( DevelVisual::Property::TRANSFORM, transformMap ); + + textVisual = factory.CreateVisual( propertyMap ); + textVisual.SetDepthIndex( 1.f ); + + dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, textVisual ); + dummyControl.SetSize( 720.f, 640.f ); + + application.SendNotification(); // force process events to ensure text visual + // adds renderer to the dummy control in OnRelayout + application.Render(); + + Renderer renderer = dummyControl.GetRendererAt(0u); + Property::Index index = renderer.GetPropertyIndex("size"); + + tet_infoline( "Test that the TextVisual overrides anything set by developer" ); + DALI_TEST_EQUALS( renderer.GetProperty(index), Vector2( 1.0, 1.0 ), 0.001f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliVisualPremultipliedAlpha(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualPremultipliedAlpha" ); + + VisualFactory factory = VisualFactory::Get(); + + // image visual, test default value ( false ) + { + Visual::Base imageVisual = factory.CreateVisual( + Property::Map() + .Add( Visual::Property::TYPE, Visual::IMAGE ) + .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ) ); + + Dali::Property::Map visualMap; + imageVisual.CreatePropertyMap( visualMap ); + Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA ); + + // test values + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), false, TEST_LOCATION ); + } + + // image visual, override premultiplied + { + Visual::Base imageVisual = factory.CreateVisual( + Property::Map() + .Add( Visual::Property::TYPE, Visual::IMAGE ) + .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ) + .Add( DevelVisual::Property::PREMULTIPLIED_ALPHA, true ) ); + + Dali::Property::Map visualMap; + imageVisual.CreatePropertyMap( visualMap ); + Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA ); + + // test values + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), true, TEST_LOCATION); + } + + // svg visual ( premultiplied alpha by default is true ) + { + Visual::Base imageVisual = factory.CreateVisual( + Property::Map() + .Add( Visual::Property::TYPE, Visual::IMAGE ) + .Add( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ) ); + + Dali::Property::Map visualMap; + imageVisual.CreatePropertyMap( visualMap ); + Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA ); + + // test values + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), true, TEST_LOCATION ); + } + END_TEST; }