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=7bc228d0cf39ba2b7e6019f78cad7b24be547f89;hp=f3667bca07c921372eba9bb379b3724bd49857d1;hb=33d3f72e60fc62db3718791f906dc843f1edeeb3;hpb=2c2f52b1e6f532312359afbf5910a44943bbb87b diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index f3667bc..7bc228d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -883,3 +883,187 @@ int UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas(void) END_TEST; } + +int UtcDaliVisualAnimateBorderVisual01(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimateBorderVisual Color" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER); + propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE); + propertyMap.Insert(BorderVisual::Property::SIZE, 5.f); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + Actor actor = Actor::New(); + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + Stage::GetCurrent().Add(actor); + borderVisual.SetOnStage( actor ); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::COLOR ); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( Property(renderer, index), Color::WHITE ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point between blue and white + + Vector4 color = renderer.GetProperty( index ); + Vector4 testColor = (Color::BLUE + Color::WHITE)*0.5f; + DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderColor", testColor ), true, TEST_LOCATION ); + + application.Render(2000u); // halfway point between blue and white + + color = renderer.GetProperty( index ); + DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderColor", Color::WHITE ), true, TEST_LOCATION ); + + END_TEST; +} + + +int UtcDaliVisualAnimateBorderVisual02(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimateBorderVisual Size" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER); + propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE); + propertyMap.Insert(BorderVisual::Property::SIZE, 5.f); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + Actor actor = Actor::New(); + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + Stage::GetCurrent().Add(actor); + borderVisual.SetOnStage( actor ); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::SIZE ); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( Property(renderer, index), 9.0f ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + + float size = renderer.GetProperty( index ); + DALI_TEST_EQUALS( size, 7.0f, 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderSize", 7.0f ), true, TEST_LOCATION ); + + application.Render(2000u); // halfway point between blue and white + + size = renderer.GetProperty( index ); + DALI_TEST_EQUALS( size, 9.0f, 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderSize", 9.0f ), true, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliVisualAnimateColorVisual(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimateColorVisual mixColor" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + Actor actor = Actor::New(); + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + Stage::GetCurrent().Add(actor); + borderVisual.SetOnStage( actor ); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Index index = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR ); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( Property(renderer, index), Color::WHITE ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + + Vector4 color = renderer.GetProperty( index ); + Vector4 testColor = (Color::BLUE + Color::WHITE)*0.5f; + DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", testColor ), true, TEST_LOCATION ); + + application.Render(2000u); // halfway point between blue and white + + color = renderer.GetProperty( index ); + DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION ); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Color::WHITE ), true, TEST_LOCATION ); + + + END_TEST; +} + + +int UtcDaliVisualAnimatePrimitiveVisual(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimatePrimitiveVisual color" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + Visual::Base borderVisual = factory.CreateVisual( propertyMap ); + + Actor actor = Actor::New(); + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + actor.SetColor(Color::BLACK); + Stage::GetCurrent().Add(actor); + borderVisual.SetOnStage( actor ); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Index index = renderer.GetPropertyIndex( PrimitiveVisual::Property::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 ); + + Animation animation = Animation::New(4.0f); + animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + + // Actor color overrides renderer color. + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Vector4(0.5f, 0.5f, 0.5f, 1.0f )), true, TEST_LOCATION ); + + application.Render(2000u); // halfway point between blue and white + + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Color::WHITE ), true, TEST_LOCATION ); + + + END_TEST; +}