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=93ee34e14df294b2f0e1634401f3470c0c51e8fa;hp=afb82a9f4a64301b0ed32dcb973431001065ccf7;hb=cf58f2980b99438db9784a284e126d80893e6138;hpb=ca96219e908001c5701e71c997965b11b85f05ed diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index afb82a9..93ee34e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -457,9 +457,9 @@ int UtcDaliControlBackgroundProperties(void) Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND ); Property::Map* resultMap = propValue.GetMap(); DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) ); - DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get() == Visual::IMAGE ); + DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get(),(int)Visual::IMAGE, TEST_LOCATION ); DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) ); - DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get() == "TestImage" ); + DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get(), "TestImage", TEST_LOCATION ); Property::Map rendererMap; rendererMap[Visual::Property::TYPE] = Visual::COLOR; @@ -468,17 +468,24 @@ int UtcDaliControlBackgroundProperties(void) propValue = control.GetProperty( Control::Property::BACKGROUND ); resultMap = propValue.GetMap(); DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) ); - DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get() == Visual::COLOR ); + DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get(), (int)Visual::COLOR, TEST_LOCATION ); DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) ); - DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get() == Color::CYAN ); + DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get(), Color::CYAN, TEST_LOCATION ); Property::Map emptyMap; control.SetProperty( Control::Property::BACKGROUND, emptyMap ); DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() ); + // set as URL + control.SetProperty( Control::Property::BACKGROUND, "Foobar.png" ); + propValue = control.GetProperty( Control::Property::BACKGROUND ); + resultMap = propValue.GetMap(); + DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get(), (int)Visual::IMAGE, TEST_LOCATION ); + DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get(), "Foobar.png", TEST_LOCATION ); + // Deprecated Properties control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW ); - DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW , TEST_LOCATION ); + DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW, TEST_LOCATION ); DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), control.GetBackgroundColor(), TEST_LOCATION ); control.ClearBackground(); @@ -488,7 +495,7 @@ int UtcDaliControlBackgroundProperties(void) control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap ); propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE ); resultMap = propValue.GetMap(); - DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION ); + DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION ); control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap ); DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() ); @@ -600,3 +607,117 @@ int UtcDaliControlImplGetControlExtensionP(void) END_TEST; } + +int UtcDaliControlAutoClipping(void) +{ + ToolkitTestApplication application; + Control control = Control::New(); + + tet_infoline( "Test to see if a renderer gets added when we are clipping children" ); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + + Stage::GetCurrent().Add( control ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlAutoClippingN(void) +{ + ToolkitTestApplication application; + Control control = Control::New(); + control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR ) + .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) ); + + tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals" ); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + + Stage::GetCurrent().Add( control ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Only 1, not 2 + + // Ensure the background color is still RED rather than what's set by the automatic clipping + Property::Value value = control.GetProperty( Control::Property::BACKGROUND ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR ); + DALI_TEST_CHECK( colorValue ); + DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlAutoClippingWhenAlreadyOnStage(void) +{ + ToolkitTestApplication application; + Control control = Control::New(); + + tet_infoline( "Test to see if a renderer gets added when we are clipping children and when already on stage" ); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + Stage::GetCurrent().Add( control ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void) +{ + ToolkitTestApplication application; + Control control = Control::New(); + control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR ) + .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) ); + + tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals and when already on stage" ); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + Stage::GetCurrent().Add( control ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); + + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Still should be 1 + + // Ensure the background color is still RED rather than what's set by the automatic clipping + Property::Value value = control.GetProperty( Control::Property::BACKGROUND ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR ); + DALI_TEST_CHECK( colorValue ); + DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION ); + + END_TEST; +}