X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Actor.cpp;h=e233b1b2cf4b395f6b4dd824092a0600a0d007fe;hb=ec1bd81a4e903f1c96350a35e918715a2e1278ef;hp=e3f106102aa7afbba419b28bf70be1f260d1f94b;hpb=23757de09d484bd019f758bc3a20e60e26a79456;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index e3f1061..e233b1b 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -721,11 +721,44 @@ int UtcDaliActorSetSize01(void) actor.SetSize(vector.x, vector.y); - // flush the queue and render once + // Immediately retrieve the size after setting + Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + // Flush the queue and render once application.SendNotification(); application.Render(); + // Check the size in the new frame DALI_TEST_CHECK(vector == actor.GetCurrentSize()); + + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + // Change the resize policy and check whether the size stays the same + actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + // Set a new size after resize policy is changed and check the new size + actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) ); + + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + // Change the resize policy again and check whether the new size stays the same + actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); + + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + // Set another new size after resize policy is changed and check the new size + actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) ); + + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; } @@ -741,11 +774,20 @@ int UtcDaliActorSetSize02(void) actor.SetSize(vector.x, vector.y, vector.z); + // Immediately check the size after setting + Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + // flush the queue and render once application.SendNotification(); application.Render(); + // Check the size in the new frame DALI_TEST_CHECK(vector == actor.GetCurrentSize()); + + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; } @@ -761,11 +803,20 @@ int UtcDaliActorSetSize03(void) actor.SetSize(Vector2(vector.x, vector.y)); + // Immediately check the size after setting + Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + // flush the queue and render once application.SendNotification(); application.Render(); + // Check the size in the new frame DALI_TEST_CHECK(vector == actor.GetCurrentSize()); + + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; } @@ -781,20 +832,34 @@ int UtcDaliActorSetSize04(void) actor.SetSize(vector); + // Immediately check the size after setting + Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + // flush the queue and render once application.SendNotification(); application.Render(); + // Check the size in the new frame DALI_TEST_CHECK(vector == actor.GetCurrentSize()); Stage::GetCurrent().Add( actor ); actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) ); + // Immediately check the size after setting + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + // flush the queue and render once application.SendNotification(); application.Render(); + // Check the size in the new frame DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION ); + + currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(); + DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + Stage::GetCurrent().Remove( actor ); END_TEST; } @@ -810,28 +875,76 @@ int UtcDaliActorSetSizeIndividual(void) actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width ); + // Immediately check the width after setting + float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(); + DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + // flush the queue and render once application.SendNotification(); application.Render(); + // Check the width in the new frame DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION ); + sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(); + DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height ); + // Immediately check the height after setting + float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(); + DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + // flush the queue and render once application.SendNotification(); application.Render(); + // Check the height in the new frame DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION ); + sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(); + DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth ); + // Immediately check the depth after setting + float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(); + DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + // flush the queue and render once application.SendNotification(); application.Render(); + // Check the depth in the new frame DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION ); + sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(); + DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + // Change the resize policy and check whether the size stays the same + actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + + sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(); + DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(); + DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(); + DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + // Change the resize policy again and check whether the size stays the same + actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); + + sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(); + DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(); + DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(); + DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; } @@ -2494,6 +2607,12 @@ int UtcDaliActorSetDrawModeOverlayRender(void) Actor b = CreateRenderableActor( imageB ); Actor c = CreateRenderableActor( imageC ); + app.SendNotification(); + app.Render(1); + + //Textures are bound when first created. Clear bound textures vector + app.GetGlAbstraction().ClearBoundTextures(); + // Render a,b,c as regular non-overlays. so order will be: // a (8) // b (9) @@ -2815,7 +2934,6 @@ const PropertyStringIndex PROPERTY_TABLE[] = { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 }, { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 }, { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN }, - { "batchParent", DevelActor::Property::BATCH_PARENT, Property::BOOLEAN }, { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING }, }; const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] ); @@ -2864,6 +2982,16 @@ int UtcDaliRelayoutProperties_ResizePolicies(void) DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION ); DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION ); + // Set individual dimensions using enums + ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE; + ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT; + + actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum ); + actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum ); + + DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION ); + END_TEST; } @@ -3359,6 +3487,66 @@ int UtcDaliActorDrawModePropertyAsString(void) END_TEST; } +int UtcDaliActorColorModePropertyAsEnum(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR ); + DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR ); + DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR ); + DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA ); + DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliActorPositionInheritancePropertyAsEnum(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION ); + DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION ); + DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); + DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION ); + DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliActorDrawModePropertyAsEnum(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL ); + DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D ); + DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL ); + DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliActorAddRendererP(void) { tet_infoline("Testing Actor::AddRenderer"); @@ -3659,6 +3847,56 @@ int UtcDaliActorPropertyClippingActor(void) END_TEST; } +int UtcDaliActorPropertyClippingActorEnableThenDisable(void) +{ + // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled + tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" ); + TestApplication application; + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace(); + TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace(); + size_t startIndex = 0u; + + // Create a clipping actor. + Actor actorDepth1Clip = CreateActorWithContent(); + actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + Stage::GetCurrent().Add( actorDepth1Clip ); + + // Gather the call trace. + GenerateTrace( application, enabledDisableTrace, stencilTrace ); + + // Check we are writing to the color buffer. + CheckColorMask( glAbstraction, true ); + + // Check the stencil buffer was enabled. + DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST + + // Check the stencil buffer was cleared. + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) ); + + // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer. + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node. + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE + + // Now disable the clipping + actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED ); + + // Gather the call trace. + GenerateTrace( application, enabledDisableTrace, stencilTrace ); + + // Check the stencil buffer was disabled. + DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST + + // Ensure all values in stencil-mask are set to 1. + startIndex = 0u; + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) ); + + END_TEST; +} + + int UtcDaliActorPropertyClippingNestedChildren(void) { // This test checks that a hierarchy of actors are clipped correctly by @@ -3771,3 +4009,15 @@ int UtcDaliActorPropertyClippingActorWithRendererOverride(void) END_TEST; } + +int UtcDaliGetPropertyN(void) +{ + tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" ); + TestApplication app; + + Actor actor = Actor::New(); + + unsigned int propertyCount = actor.GetPropertyCount(); + DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION ); + END_TEST; +}