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-Control.cpp;h=df48a7de4c4d895c4102c927cbb7aca3a6b43864;hp=0a4dad2e1fff9f43b206091b011f03f3108470d7;hb=f20180dbb4cd52afb0305f2aa7889e81f55ef19e;hpb=e9e5fdaaf29bbb7204e4c2ebd5be48f541c0114d diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index 0a4dad2..df48a7d 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -75,6 +75,18 @@ static void TestKeyInputFocusCallback( Control control ) const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png"; const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg"; +Vector4 GetControlBackgroundColor( Control& control ) +{ + Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND ); + Property::Map* resultMap = propValue.GetMap(); + DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) ); + + Vector4 color; + resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get( color ); + + return color; +} + } // namespace /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -458,6 +470,80 @@ int UtcDaliControlBackgroundColor(void) END_TEST; } +int UtcDaliControlBackgroundColorRendererCount(void) +{ + tet_infoline( "Test ensures we only create renderers when non-transparent color is requested or if we our clipping-mode is set to CLIP_CHILDREN" ); + + ToolkitTestApplication application; + Control control = Control::New(); + Stage::GetCurrent().Add( control ); + + tet_infoline( "Set transparent, no renderers should be created" ); + control.SetBackgroundColor( Color::TRANSPARENT ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); + + tet_infoline( "Set transparent alpha with positive RGB values, no renderers should be created, but returned color should reflect what we set" ); + const Vector4 alphaZero( 1.0f, 0.5f, 0.25f, 0.0f ); + control.SetBackgroundColor( alphaZero ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( GetControlBackgroundColor( control ), alphaZero, TEST_LOCATION ); + + tet_infoline( "Set semi transparent alpha with positive RGB values, 1 renderer should be created, but returned color should reflect what we set" ); + const Vector4 semiTransparent( 1.0f, 0.75f, 0.5f, 0.5f ); + control.SetBackgroundColor( semiTransparent ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( GetControlBackgroundColor( control ), semiTransparent, TEST_LOCATION ); + + tet_infoline( "Set transparent, ensure no renderers are created" ); + control.SetBackgroundColor( Color::TRANSPARENT ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION ); + + tet_infoline( "Set control to clip its children, a renderer should be created which will be transparent" ); + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION ); + + tet_infoline( "Set a color, only 1 renderer should exist" ); + control.SetBackgroundColor( Color::RED ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::RED, TEST_LOCATION ); + + tet_infoline( "Clear the background, no renderers" ); + control.ClearBackground(); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); + + tet_infoline( "Set control to clip its children again, a renderer should be created which will be transparent" ); + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION ); + + tet_infoline( "Disable clipping, no renderers" ); + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliControlBackgroundImage(void) { ToolkitTestApplication application;