X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Visual.cpp;h=3c774c7e2a323734f7e0f70a361121ddf2c72fec;hb=af0625200898f1861270555be616d7848a1d0b6c;hp=9e39e3645fa8cfbfc2540872fbbd22a50661d6b8;hpb=7f0a28e0f0da67178997e5a647bdc471e8dcb652;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 9e39e36..3c774c7 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -37,10 +39,10 @@ using namespace Dali::Toolkit; namespace { +const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif"; const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg"; const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg"; const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg"; -const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif"; const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj"; const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl"; const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/"; @@ -53,8 +55,8 @@ Property::Map DefaultTransform() transformMap .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) ) .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) ) - .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER ) - .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER ) + .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) + .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN ) .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) ) .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) ); return transformMap; @@ -202,7 +204,7 @@ int UtcDaliVisualSetGetDepthIndex(void) propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); Visual::Base visual = factory.CreateVisual( propertyMap ); - visual.SetDepthIndex( 1.f ); + visual.SetDepthIndex( 1 ); DummyControl dummyControl = DummyControl::New(true); Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); @@ -214,12 +216,12 @@ int UtcDaliVisualSetGetDepthIndex(void) int depthIndex = dummyControl.GetRendererAt(0u).GetProperty( Renderer::Property::DEPTH_INDEX ); DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION ); - DALI_TEST_EQUALS( visual.GetDepthIndex(), 1.f, TEST_LOCATION ); + DALI_TEST_EQUALS( visual.GetDepthIndex(), 1, TEST_LOCATION ); - visual.SetDepthIndex( -1.f ); + visual.SetDepthIndex( -1 ); depthIndex = dummyControl.GetRendererAt(0u).GetProperty( Renderer::Property::DEPTH_INDEX ); DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION ); - DALI_TEST_EQUALS( visual.GetDepthIndex(), -1.f, TEST_LOCATION ); + DALI_TEST_EQUALS( visual.GetDepthIndex(), -1, TEST_LOCATION ); END_TEST; } @@ -1079,44 +1081,6 @@ int UtcDaliVisualGetPropertyMap10(void) END_TEST; } -int UtcDaliVisualGetPropertyMap11(void) -{ - ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualGetPropertyMap11: AnimatedImageVisual" ); - - // request AnimatedImageVisual with a property map - VisualFactory factory = VisualFactory::Get(); - Visual::Base animatedImageVisual = factory.CreateVisual( Property::Map() - .Add( Visual::Property::TYPE, DevelVisual::ANIMATED_IMAGE ) - .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME ) ); - - Property::Map resultMap; - animatedImageVisual.CreatePropertyMap( resultMap ); - // check the property values from the returned map from a visual - Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == DevelVisual::ANIMATED_IMAGE ); - - value = resultMap.Find( ImageVisual::Property::URL, Property::STRING ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == TEST_GIF_FILE_NAME ); - - // request AnimatedImageVisual with an URL - Visual::Base animatedImageVisual2 = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() ); - resultMap.Clear(); - animatedImageVisual2.CreatePropertyMap( resultMap ); - // check the property values from the returned map from a visual - value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == DevelVisual::ANIMATED_IMAGE ); - - value = resultMap.Find( ImageVisual::Property::URL, Property::STRING ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == TEST_GIF_FILE_NAME ); - - END_TEST; -} - int UtcDaliVisualAnimateBorderVisual01(void) { ToolkitTestApplication application; @@ -1166,12 +1130,12 @@ int UtcDaliVisualAnimateBorderVisual01(void) application.Render(0); application.Render(2000u); // halfway point between blue and white - Vector4 color = renderer.GetProperty( borderColorIndex ); + Vector4 color = renderer.GetCurrentProperty< Vector4 >( borderColorIndex ); 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 ); - color = renderer.GetProperty( mixColorIndex ); + color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex ); testColor = Vector4( 1,1,1,0.4f ); DALI_TEST_EQUALS( Vector3(color), Vector3(testColor), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector3(testColor) ), true, TEST_LOCATION ); @@ -1179,11 +1143,11 @@ int UtcDaliVisualAnimateBorderVisual01(void) application.Render(2000u); - color = renderer.GetProperty( borderColorIndex ); + color = renderer.GetCurrentProperty< Vector4 >( borderColorIndex ); DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderColor", Color::WHITE ), true, TEST_LOCATION ); - color = renderer.GetProperty( mixColorIndex ); + color = renderer.GetCurrentProperty< Vector4 >( mixColorIndex ); testColor = Vector4(1,1,1,0); DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector3(testColor) ), true, TEST_LOCATION ); @@ -1225,13 +1189,13 @@ int UtcDaliVisualAnimateBorderVisual02(void) application.Render(0); application.Render(2000u); // halfway point - float size = renderer.GetProperty( index ); + float size = renderer.GetCurrentProperty< float >( 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 ); + size = renderer.GetCurrentProperty< float >( index ); DALI_TEST_EQUALS( size, 9.0f, 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("borderSize", 9.0f ), true, TEST_LOCATION ); @@ -1272,7 +1236,7 @@ int UtcDaliVisualAnimateColorVisual(void) application.Render(0); application.Render(2000u); // halfway point - Vector3 color = renderer.GetProperty( mixColorIndex ); + Vector3 color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex ); Vector3 testColor = Vector3(Color::BLUE + Color::WHITE)*0.5f; DALI_TEST_EQUALS( color, testColor, TEST_LOCATION ); @@ -1280,12 +1244,12 @@ int UtcDaliVisualAnimateColorVisual(void) application.Render(2000u); // halfway point between blue and white - color = renderer.GetProperty( mixColorIndex ); + color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex ); DALI_TEST_EQUALS( color, Vector3(Color::WHITE), TEST_LOCATION ); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("mixColor", Vector3(Color::WHITE) ), true, TEST_LOCATION ); - blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + blendModeValue = renderer.GetCurrentProperty( Renderer::Property::BLEND_MODE ); DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); END_TEST; @@ -1371,260 +1335,6 @@ int UtcDaliVisualAnimatePrimitiveVisual(void) END_TEST; } -int UtcDaliVisualAnimateImageVisualMixColor(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("mixColor", Color::BLUE); - 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); - Property::Index index = DevelHandle::GetPropertyIndex( renderer, DevelVisual::Property::MIX_COLOR ); - Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); - DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); - - tet_infoline("Test that the renderer has the mixColor property"); - DALI_TEST_CHECK( index != Property::INVALID_INDEX ); - - const Vector4 TARGET_MIX_COLOR( 1.0f, 0.0f, 0.0f, 0.5f ); - - Property::Map map; - map["target"] = "testVisual"; - map["property"] = "mixColor"; - map["initialValue"] = Color::MAGENTA; - map["targetValue"] = TARGET_MIX_COLOR; - 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 ); - - blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); - DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON, TEST_LOCATION ); - - animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE ); - animation.Play(); - - 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", 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", 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 ); - - blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); - DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON, TEST_LOCATION ); - - 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; - tet_infoline( "UtcDaliAnimateImageVisual pixel area" ); - - 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("mixColor", Color::BLUE); - 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); - Property::Index index = DevelHandle::GetPropertyIndex( renderer, DevelVisual::Property::MIX_COLOR ); - - tet_infoline("Test that the renderer has the mixColor property"); - DALI_TEST_CHECK( index != Property::INVALID_INDEX ); - - // TransitionData only takes string keys - Property::Map map; - map["target"] = "testVisual"; - map["property"] = "pixelArea"; - map["initialValue"] = Vector4( 0,0,0,1 ); - map["targetValue"] = Vector4( 0,0,1,1 ); // Animate width from zero to full - 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.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE ); - animation.Play(); - - application.SendNotification(); - application.Render(0); - application.Render(2000u); // halfway point - - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("pixelArea", Vector4(0.0f, 0.0f, 0.5f, 1.0f )), true, TEST_LOCATION ); - - application.Render(2000u); - - DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue("pixelArea", Vector4( 0.0f, 0.0f, 1.0f, 1.0f )), true, TEST_LOCATION ); - - END_TEST; -} - int UtcDaliVisualWireframeVisual(void) { @@ -1691,12 +1401,12 @@ int UtcDaliVisualGetTransform(void) { Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ORIGIN ); DALI_TEST_CHECK( typeValue ); - DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get() == Toolkit::Align::CENTER ); + DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get() == Toolkit::Align::TOP_BEGIN ); } { Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT ); DALI_TEST_CHECK( typeValue ); - DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get() == Toolkit::Align::CENTER ); + DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get() == Toolkit::Align::TOP_BEGIN ); } END_TEST; @@ -1708,7 +1418,7 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(10.0f, 10.0f) ); transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(0.2f, 0.2f) ); transform.Insert( DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::ABSOLUTE, Toolkit::DevelVisual::Transform::Policy::ABSOLUTE ) ); - transform.Insert( DevelVisual::Transform::Property::ORIGIN, "TOP_BEGIN" ); + transform.Insert( DevelVisual::Transform::Property::ORIGIN, "CENTER" ); transform.Insert( DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::BOTTOM_END ); visual.SetTransformAndSize( transform, Vector2(100, 100) ); @@ -1742,7 +1452,7 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis { Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ORIGIN ); DALI_TEST_CHECK( typeValue ); - DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get(), Toolkit::Align::TOP_BEGIN, TEST_LOCATION ); + DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get(), Toolkit::Align::CENTER, TEST_LOCATION ); } { Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT ); @@ -1783,7 +1493,7 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis index = renderer.GetPropertyIndex( "origin" ); DALI_TEST_CHECK( index != Property::INVALID_INDEX ); Vector2 parentOrigin = renderer.GetProperty( index ); - DALI_TEST_EQUALS( parentOrigin, Vector2(-0.5f,-0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( parentOrigin, Vector2(0.0f,0.0f), TEST_LOCATION ); index = renderer.GetPropertyIndex( "anchorPoint" ); DALI_TEST_CHECK( index != Property::INVALID_INDEX ); @@ -1810,12 +1520,12 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis offsetSizeMode = renderer.GetProperty( renderer.GetPropertyIndex( "offsetSizeMode" ) ); DALI_TEST_EQUALS( offsetSizeMode, Vector4(0.0f,0.0f,1.0f,1.0f), TEST_LOCATION ); - //Parent origin and anchor point should have default values + //Parent origin and anchor point should have the default values parentOrigin = renderer.GetProperty( renderer.GetPropertyIndex( "origin" ) ); - DALI_TEST_EQUALS( parentOrigin, Vector2(0.0f,0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( parentOrigin, Vector2(-0.5f,-0.5f), TEST_LOCATION ); anchorPoint = renderer.GetProperty( renderer.GetPropertyIndex( "anchorPoint" ) ); - DALI_TEST_EQUALS( anchorPoint, Vector2(0.0f,0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( anchorPoint, Vector2(0.5f,0.5f), TEST_LOCATION ); } int UtcDaliVisualSetTransform0(void) @@ -2023,8 +1733,10 @@ int UtcDaliNPatchVisualCustomShader(void) VisualFactory factory = VisualFactory::Get(); Property::Map properties; Property::Map shader; + const std::string vertexShader = "Foobar"; const std::string fragmentShader = "Foobar"; shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader; + shader[Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER] = vertexShader; Property::Map transformMap; transformMap["size"] = Vector2( 0.5f, 0.5f ) ; @@ -2062,10 +1774,11 @@ int UtcDaliNPatchVisualCustomShader(void) 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 - DALI_TEST_EQUALS( fragmentShader, fragment->Get(), TEST_LOCATION ); + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + DALI_TEST_EQUALS( vertexShader, vertex->Get(), TEST_LOCATION ); + END_TEST; } @@ -2118,7 +1831,7 @@ int UtcDaliVisualRendererRemovalAndReAddition(void) propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); Visual::Base visual = factory.CreateVisual( propertyMap ); - visual.SetDepthIndex( 1.f ); + visual.SetDepthIndex( 1 ); DummyControl dummyControl = DummyControl::New(true); Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); @@ -2180,7 +1893,7 @@ int UtcDaliVisualTextVisualRender(void) propertyMap.Insert( "verticalAlignment", "CENTER" ); propertyMap.Insert( "textColor", Color::RED ); Visual::Base textVisual = factory.CreateVisual( propertyMap ); - textVisual.SetDepthIndex( 1.f ); + textVisual.SetDepthIndex( 1 ); DummyControl dummyControl = DummyControl::New(true); Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); @@ -2207,7 +1920,7 @@ int UtcDaliVisualTextVisualRender(void) propertyMap.Insert( DevelVisual::Property::TRANSFORM, transformMap ); textVisual = factory.CreateVisual( propertyMap ); - textVisual.SetDepthIndex( 1.f ); + textVisual.SetDepthIndex( 1 ); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual ); dummyControl.SetSize( 720.f, 640.f ); @@ -2249,7 +1962,7 @@ int UtcDaliVisualTextVisualDisableEnable(void) propertyMap.Insert( "verticalAlignment", "CENTER" ); propertyMap.Insert( "textColor", Color::RED ); Visual::Base textVisual = factory.CreateVisual( propertyMap ); - textVisual.SetDepthIndex( 1.f ); + textVisual.SetDepthIndex( 1 ); DummyControl dummyControl = DummyControl::New(true); Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); @@ -2334,3 +2047,133 @@ int UtcDaliVisualPremultipliedAlpha(void) END_TEST; } + +int UtcDaliRegisterVisualOrder(void) +{ + ToolkitTestApplication application; + tet_infoline( "Register Visual Order" ); + + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + + tet_infoline( "Register visual, should have depth index of 0.0f" ); + Visual::Base testVisual = factory.CreateVisual( propertyMap ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, testVisual ); + DALI_TEST_EQUALS( testVisual.GetDepthIndex(), 0, TEST_LOCATION ); + + tet_infoline( "Register more visuals, each added one should have a depth index greater than previous" ); + + Visual::Base testVisual2 = factory.CreateVisual( propertyMap ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 ); + DALI_TEST_CHECK( testVisual2.GetDepthIndex() > testVisual.GetDepthIndex() ); + + Visual::Base foregroundVisual = factory.CreateVisual( propertyMap ); + dummyImpl.RegisterVisual( DummyControl::Property::FOREGROUND_VISUAL, foregroundVisual ); + DALI_TEST_CHECK( foregroundVisual.GetDepthIndex() > testVisual2.GetDepthIndex() ); + + Visual::Base focusVisual = factory.CreateVisual( propertyMap ); + dummyImpl.RegisterVisual( DummyControl::Property::FOCUS_VISUAL, focusVisual ); + DALI_TEST_CHECK( focusVisual.GetDepthIndex() > foregroundVisual.GetDepthIndex() ); + + tet_infoline( "Set depth index on a new visual before registering, the depth index should not have been changed" ); + Visual::Base labelVisual = factory.CreateVisual( propertyMap ); + labelVisual.SetDepthIndex( -2000 ); + dummyImpl.RegisterVisual( DummyControl::Property::LABEL_VISUAL, labelVisual ); + DALI_TEST_EQUALS( labelVisual.GetDepthIndex(), -2000, TEST_LOCATION ); + + tet_infoline( "Replace visual, the depth index should be the same as what was previously set" ); + const int testVisual2DepthIndex = testVisual2.GetDepthIndex(); + Visual::Base testVisual2Replacement = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( testVisual2Replacement.GetDepthIndex() != testVisual2DepthIndex ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2Replacement ); + DALI_TEST_EQUALS( testVisual2Replacement.GetDepthIndex(), testVisual2DepthIndex, TEST_LOCATION ); + + tet_infoline( "Replace visual and set a depth index on the replacement, the depth index of the replacement should be honoured" ); + Visual::Base anotherTestVisual2Replacement = factory.CreateVisual( propertyMap ); + anotherTestVisual2Replacement.SetDepthIndex( 2000 ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement ); + DALI_TEST_EQUALS( anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION ); + + dummyControl.SetSize(200.f, 200.f); + Stage::GetCurrent().Add( dummyControl ); + + END_TEST; +} + +int UtcDaliRegisterVisualOrder02(void) +{ + ToolkitTestApplication application; + tet_infoline( "Register Visual Order with Background Set" ); + + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + + const int backgroundDepthIndex = Toolkit::DepthIndex::BACKGROUND; + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + + tet_printf( "Register a control background visual, should have depth index of %d\n", backgroundDepthIndex ); + + dummyControl.SetProperty( Control::Property::BACKGROUND, propertyMap ); + + const int TEST_VISUAL_1_DEPTH_INDEX = 0; + tet_printf( "Register visual, should have depth index of %d\n", TEST_VISUAL_1_DEPTH_INDEX ); + Visual::Base testVisual1 = factory.CreateVisual( propertyMap ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, testVisual1 ); + DALI_TEST_EQUALS( testVisual1.GetDepthIndex(), TEST_VISUAL_1_DEPTH_INDEX , TEST_LOCATION ); + + tet_printf( "Register another visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_1_DEPTH_INDEX ); + Visual::Base testVisual2 = factory.CreateVisual( propertyMap ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 ); + DALI_TEST_CHECK( testVisual2.GetDepthIndex() > testVisual1.GetDepthIndex() ); + + dummyControl.SetSize(200.f, 200.f); + Stage::GetCurrent().Add( dummyControl ); + + END_TEST; +} + +int UtcDaliRegisterVisualWithDepthIndex(void) +{ + ToolkitTestApplication application; + tet_infoline( "Register a Visual With Depth Index" ); + + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + + tet_infoline( "Register a visual with a depth index, it should be enabled by default too" ); + Visual::Base testVisual = factory.CreateVisual( propertyMap ); + DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL, testVisual, 203 ); + DALI_TEST_EQUALS( testVisual.GetDepthIndex(), 203, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL ), true, TEST_LOCATION ); + + tet_infoline( "Register another visual with a depth index and it disabled" ); + Visual::Base testVisual2 = factory.CreateVisual( propertyMap ); + DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL2, testVisual2, false, 450 ); + DALI_TEST_EQUALS( testVisual2.GetDepthIndex(), 450, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), false, TEST_LOCATION ); + + tet_infoline( "Register another visual with a depth index and it enabled using the enabled API" ); + Visual::Base testVisual3 = factory.CreateVisual( propertyMap ); + DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL2, testVisual3, true, 300 ); + DALI_TEST_EQUALS( testVisual3.GetDepthIndex(), 300, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), true, TEST_LOCATION ); + + dummyControl.SetSize(200.f, 200.f); + Stage::GetCurrent().Add( dummyControl ); + + END_TEST; +}