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=fc941302d5fe6c32a623a91de1dce07f415c9076;hp=f399d4d0f268acf20304808b99f67f5129a62fab;hb=5a2a5883422f4d114902ac57d57d7d1e973fbb2e;hpb=c57e053b5795783ad92b0fd7f8fbaba6b6d9322a diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index f399d4d..fc94130 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -119,9 +119,21 @@ static void TestMixColor( Visual::Base visual, Property::Index mixColorIndex, co visual.CreatePropertyMap(map); Property::Value* value = map.Find( mixColorIndex ); DALI_TEST_CHECK( value ); - Vector4 mixColor; - DALI_TEST_CHECK( value->Get( mixColor ) ); - DALI_TEST_EQUALS( mixColor, testColor, 0.001, TEST_LOCATION ); + Vector3 mixColor1; + DALI_TEST_CHECK( value->Get( mixColor1 ) ); + DALI_TEST_EQUALS( mixColor1, Vector3(testColor), 0.001, TEST_LOCATION ); + + value = map.Find( DevelVisual::Property::MIX_COLOR ); + DALI_TEST_CHECK( value ); + Vector4 mixColor2; + DALI_TEST_CHECK( value->Get( mixColor2 ) ); + DALI_TEST_EQUALS( mixColor2, testColor, 0.001, TEST_LOCATION ); + + value = map.Find( DevelVisual::Property::OPACITY ); + DALI_TEST_CHECK( value ); + float opacity; + DALI_TEST_CHECK( value->Get( opacity ) ); + DALI_TEST_EQUALS( opacity, testColor.a, 0.001, TEST_LOCATION ); } @@ -1119,12 +1131,13 @@ int UtcDaliVisualAnimateBorderVisual01(void) DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderColor", testColor ), true, TEST_LOCATION ); - color = renderer.GetProperty( mixColorIndex ); + color = renderer.GetProperty( mixColorIndex ); testColor = Vector4( 1,1,1,0.4f ); - DALI_TEST_EQUALS( color, testColor, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", testColor ), true, TEST_LOCATION ); + 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 ); - application.Render(2000u); // halfway point between blue and white + application.Render(2000u); color = renderer.GetProperty( borderColorIndex ); DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION ); @@ -1133,7 +1146,8 @@ int UtcDaliVisualAnimateBorderVisual01(void) color = renderer.GetProperty( mixColorIndex ); testColor = Vector4(1,1,1,0); DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", testColor ), true, 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 ); END_TEST; } @@ -1205,31 +1219,31 @@ int UtcDaliVisualAnimateColorVisual(void) DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0); - Property::Index index = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR ); + Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR ); Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); Animation animation = Animation::New(4.0f); - animation.AnimateTo( Property(renderer, index), Color::WHITE ); + animation.AnimateTo( Property(renderer, mixColorIndex), Vector3(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; + Vector3 color = renderer.GetProperty( mixColorIndex ); + Vector3 testColor = Vector3(Color::BLUE + Color::WHITE)*0.5f; DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", testColor ), true, 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 ); + color = renderer.GetProperty( mixColorIndex ); + DALI_TEST_EQUALS( color, Vector3(Color::WHITE), TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Color::WHITE ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector3(Color::WHITE) ), true, TEST_LOCATION ); blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); @@ -1297,14 +1311,16 @@ int UtcDaliVisualAnimatePrimitiveVisual(void) 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("mixColor", halfwayColor ), 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("mixColor", TARGET_MIX_COLOR ), 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 ); @@ -1375,15 +1391,18 @@ int UtcDaliVisualAnimateImageVisualMixColor(void) application.SendNotification(); application.Render(0); application.Render(2000u); // halfway point + Vector4 testColor(1.0f, 0.0f, 0.5f, 0.75f ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("uColor", Vector4(0.5f, 0.5f, 0.5f, 1.0f )), true, TEST_LOCATION ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector4(1.0f, 0.0f, 0.5f, 0.75f )), true, 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 ); 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 ); - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", TARGET_MIX_COLOR), 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 ); TestMixColor( visual, DevelVisual::Property::MIX_COLOR, TARGET_MIX_COLOR ); @@ -1393,6 +1412,116 @@ int UtcDaliVisualAnimateImageVisualMixColor(void) END_TEST; } + +int UtcDaliVisualAnimateImageVisualOpacity(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliAnimateImageVisual mix color" ); + + application.GetPlatform().SetClosestImageSize( Vector2(100, 100) ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE); + propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert("opacity", 0.5f); + propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true); + 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(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + actor.SetColor(Color::BLACK); + Stage::GetCurrent().Add(actor); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + tet_infoline("Test that the renderer has the opacity property"); + Property::Index index = DevelHandle::GetPropertyIndex( renderer, DevelVisual::Property::OPACITY ); + DALI_TEST_CHECK( index != Property::INVALID_INDEX ); + + + Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON, TEST_LOCATION ); + + { + tet_infoline( "Test that the opacity can be increased to full via animation, and that the blend mode is set appropriately at the start and end of the animation." ); + + Property::Map map; + map["target"] = "testVisual"; + map["property"] = "opacity"; + map["targetValue"] = 1.0f; + map["animator"] = Property::Map() + .Add("alphaFunction", "LINEAR") + .Add("timePeriod", Property::Map() + .Add("delay", 0.0f) + .Add("duration", 4.0f)); + + Dali::Toolkit::TransitionData transition = TransitionData::New( map ); + Animation animation = dummyImpl.CreateTransition( transition ); + animation.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + application.SendNotification(); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("opacity", 0.75f), true, TEST_LOCATION ); + + application.Render(2001u); // end + application.SendNotification(); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("opacity", 1.0f), true, TEST_LOCATION ); + + blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); + } + + + { + tet_infoline( "Test that the opacity can be reduced via animation, and that the blend mode is set appropriately at the start and end of the animation." ); + + Property::Map map; + map["target"] = "testVisual"; + map["property"] = DevelVisual::Property::OPACITY; + map["targetValue"] = 0.1f; + map["animator"] = Property::Map() + .Add("alphaFunction", "LINEAR") + .Add("timePeriod", Property::Map() + .Add("delay", 0.0f) + .Add("duration", 4.0f)); + + Dali::Toolkit::TransitionData transition = TransitionData::New( map ); + Animation animation = dummyImpl.CreateTransition( transition ); + animation.Play(); + + blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + application.Render(2000u); // halfway point + application.SendNotification(); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("opacity", 0.55f), true, TEST_LOCATION ); + + application.Render(2016u); // end + application.SendNotification(); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("opacity", 0.1f), true, TEST_LOCATION ); + + blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON, TEST_LOCATION ); + } + + + END_TEST; +} + int UtcDaliVisualAnimateImageVisualPixelArea(void) { ToolkitTestApplication application;