X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Visual.cpp;h=6de8e238424bcb72db40f18bf551007c5352f52e;hb=a3ab994876ea86236784101dd85370815c336e8b;hp=f3667bca07c921372eba9bb379b3724bd49857d1;hpb=190217c8f02a9a1703dedfe38eb1974b6830e5ac;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 f3667bc..6de8e23 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -744,7 +744,7 @@ int UtcDaliVisualGetPropertyMap9(void) Property::Map propertyMap; propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE ); propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE ); - propertyMap.Insert( PrimitiveVisual::Property::COLOR, color ); + propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, color ); propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 ); propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 ); propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f ); @@ -769,7 +769,7 @@ int UtcDaliVisualGetPropertyMap9(void) DALI_TEST_CHECK( value ); DALI_TEST_EQUALS( value->Get(), (int)PrimitiveVisual::Shape::CUBE, TEST_LOCATION ); - value = resultMap.Find( PrimitiveVisual::Property::COLOR, Property::VECTOR4 ); + value = resultMap.Find( PrimitiveVisual::Property::MIX_COLOR, Property::VECTOR4 ); DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == color ); DALI_TEST_EQUALS( value->Get(), color, Math::MACHINE_EPSILON_100, TEST_LOCATION ); @@ -883,3 +883,210 @@ 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::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 ); + + 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; +} + +int UtcDaliVisualWireframeVisual(void) +{ + ToolkitTestApplication application; + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::WIREFRAME ); + + // Create the visual. + Visual::Base visual = factory.CreateVisual( propertyMap ); + + DALI_TEST_CHECK( visual ); + + Property::Map resultMap; + visual.CreatePropertyMap( resultMap ); + + // Check the property values from the returned map from visual + Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == Visual::WIREFRAME ); + END_TEST; +}