X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-DebugRendering.cpp;h=9b733f206500a3298a9e21c80db43777deb16eea;hb=e029ad17187a0cc3749982788e16e5a5bbb65301;hp=71641fbfae3668386d9ca50381cb6e2892bf5e90;hpb=072e6002280ed51a637ed54e0451bdbbe3c4ec79;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp old mode 100644 new mode 100755 index 71641fb..9b733f2 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -25,6 +25,11 @@ #include #include // for setting environment variable: DALI_DEBUG_RENDERING + +#if defined(ELDBUS_ENABLED) +#include +#endif + #include "dummy-control.h" using namespace Dali; @@ -39,7 +44,7 @@ const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif"; const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); -void TestDebugVisual( Visual::Base& visual, Visual::Type actualType, Vector2 expectedNaturalSize ) +void TestDebugVisual( Integration::Scene scene, Visual::Base& visual, Visual::Type actualType, Vector2 expectedNaturalSize ) { { auto& impl = GetImplementation( visual ); @@ -61,7 +66,7 @@ void TestDebugVisual( Visual::Base& visual, Visual::Type actualType, Vector2 exp DummyControl actor = DummyControl::New(); DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); - Stage::GetCurrent().Add( actor ); + scene.Add( actor ); DALI_TEST_EQUALS( actor.GetRendererCount(), 1, TEST_LOCATION ); if( actor.GetRendererCount() > 0 ) @@ -75,6 +80,9 @@ void TestDebugVisual( Visual::Base& visual, Visual::Type actualType, Vector2 exp void dali_debug_rendering_startup(void) { test_return_value = TET_UNDEF; +#if defined(ELDBUS_ENABLED) + DBusWrapper::Install(std::unique_ptr(new TestDBusWrapper)); +#endif } void dali_debug_rendering_cleanup(void) @@ -97,7 +105,7 @@ int UtcDaliDebugRenderingGetVisual1(void) propertyMap1.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); Visual::Base colorVisual = factory.CreateVisual(propertyMap1); DALI_TEST_CHECK( colorVisual ); - TestDebugVisual( colorVisual, Visual::COLOR, Vector2::ZERO ); + TestDebugVisual( application.GetScene(), colorVisual, Visual::COLOR, Vector2::ZERO ); // Test that border visual is replaced with debug visual Property::Map propertyMap2; @@ -106,7 +114,7 @@ int UtcDaliDebugRenderingGetVisual1(void) propertyMap2.Insert(BorderVisual::Property::SIZE, 2.f); Visual::Base borderVisual = factory.CreateVisual(propertyMap2); DALI_TEST_CHECK( borderVisual ); - TestDebugVisual( borderVisual, Visual::BORDER, Vector2::ZERO ); + TestDebugVisual( application.GetScene(), borderVisual, Visual::BORDER, Vector2::ZERO ); // Test that gradient visual is replaced with debug visual Property::Map propertyMap3; @@ -126,7 +134,7 @@ int UtcDaliDebugRenderingGetVisual1(void) propertyMap3.Insert(GradientVisual::Property::STOP_COLOR, stopColors); Visual::Base gradientVisual = factory.CreateVisual(propertyMap3); DALI_TEST_CHECK( gradientVisual ); - TestDebugVisual( gradientVisual, Visual::GRADIENT, Vector2::ZERO ); + TestDebugVisual( application.GetScene(), gradientVisual, Visual::GRADIENT, Vector2::ZERO ); // Test that image visual is replaced with debug visual Property::Map propertyMap4; @@ -136,7 +144,7 @@ int UtcDaliDebugRenderingGetVisual1(void) propertyMap4.Insert( ImageVisual::Property::DESIRED_HEIGHT, 100.f ); Visual::Base imageVisual = factory.CreateVisual( propertyMap4 ); DALI_TEST_CHECK( imageVisual ); - TestDebugVisual( imageVisual, Visual::IMAGE, Vector2( 50.f, 100.f ) ); + TestDebugVisual( application.GetScene(), imageVisual, Visual::IMAGE, Vector2( 50.f, 100.f ) ); // Test that SVG visual is replaced with debug visual // TEST_SVG_FILE: @@ -148,7 +156,7 @@ int UtcDaliDebugRenderingGetVisual1(void) propertyMap5.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ); Visual::Base svgVisual = factory.CreateVisual( propertyMap5 ); DALI_TEST_CHECK( svgVisual ); - TestDebugVisual( svgVisual, Visual::SVG, Vector2(100.f, 100.f) ); + TestDebugVisual( application.GetScene(), svgVisual, Visual::SVG, Vector2(100.f, 100.f) ); // Test that AnimatedImageVisual is replaced with debug visual // TEST_GIF_FILE: anim.gif @@ -158,7 +166,7 @@ int UtcDaliDebugRenderingGetVisual1(void) propertyMap6.Insert( ImageVisual::Property::URL, TEST_GIF_FILE_NAME ); Visual::Base animatedImageVisual = factory.CreateVisual( propertyMap6 ); DALI_TEST_CHECK( animatedImageVisual ); - TestDebugVisual( animatedImageVisual, Visual::ANIMATED_IMAGE, Vector2(50.f, 50.f) ); + TestDebugVisual( application.GetScene(), animatedImageVisual, Visual::ANIMATED_IMAGE, Vector2(50.f, 50.f) ); // Test that text visual is replaced with debug visual @@ -187,10 +195,10 @@ int UtcDaliDebugRenderingGetVisual1(void) Vector2 naturalSize; textVisual.GetNaturalSize( naturalSize ); - DALI_TEST_EQUALS( naturalSize, Vector2( 80.f, 20.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + DALI_TEST_EQUALS( naturalSize, Vector2( 82.f, 20.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION ); const float height = textVisual.GetHeightForWidth( 40.f ); - DALI_TEST_EQUALS( height, 40.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + DALI_TEST_EQUALS( height, 60.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); // Test that NPatchVisual is replaced with debug visual // TEST_NPATCH_FILE_NAME: image_01.9.jpg @@ -199,7 +207,7 @@ int UtcDaliDebugRenderingGetVisual1(void) propertyMap8.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME ); Visual::Base nPatchVisual = factory.CreateVisual( propertyMap8 ); DALI_TEST_CHECK( nPatchVisual ); - TestDebugVisual( nPatchVisual, Visual::N_PATCH, Vector2::ZERO ); + TestDebugVisual( application.GetScene(), nPatchVisual, Visual::N_PATCH, Vector2::ZERO ); EnvironmentVariable::SetTestingEnvironmentVariable(false); END_TEST; @@ -221,7 +229,7 @@ int UtcDaliDebugRenderingGetVisual2(void) Visual::Base colorVisual = factory.CreateVisual( map); DALI_TEST_CHECK( colorVisual ); - TestDebugVisual( colorVisual, Visual::COLOR, Vector2::ZERO ); + TestDebugVisual( application.GetScene(), colorVisual, Visual::COLOR, Vector2::ZERO ); // Test that border visual is replaced with debug visual map.Clear(); @@ -230,23 +238,92 @@ int UtcDaliDebugRenderingGetVisual2(void) map[ BorderVisual::Property::SIZE ] = 2.f; Visual::Base borderVisual = factory.CreateVisual( map ); DALI_TEST_CHECK( borderVisual ); - TestDebugVisual( borderVisual, Visual::BORDER, Vector2::ZERO ); + TestDebugVisual( application.GetScene(), borderVisual, Visual::BORDER, Vector2::ZERO ); // Test that image visual is replaced with debug visual - Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME); - Visual::Base imageVisual = factory.CreateVisual( image ); + map.Clear(); + map[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE; + map[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME; + Visual::Base imageVisual = factory.CreateVisual( map ); DALI_TEST_CHECK( imageVisual ); - TestDebugVisual( imageVisual, Visual::IMAGE, Vector2::ZERO); + TestDebugVisual( application.GetScene(), imageVisual, Visual::IMAGE, Vector2(64.0f, 64.0f /* Broken Image Size */ )); // Test that n patch visual is replaced with debug visual Visual::Base nPatchVisual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() ); DALI_TEST_CHECK( nPatchVisual ); - TestDebugVisual( nPatchVisual, Visual::N_PATCH, Vector2::ZERO ); + TestDebugVisual( application.GetScene(), nPatchVisual, Visual::N_PATCH, Vector2::ZERO ); EnvironmentVariable::SetTestingEnvironmentVariable(false); END_TEST; } + +int UtcDaliDebugRenderingGetVisual3(void) +{ + EnvironmentVariable::SetTestingEnvironmentVariable( true ); + ToolkitTestApplication application; + tet_infoline( "UtcDaliDebugRenderingGetVisual3: Request visual with various parameters" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + // Test that image visual is replaced with debug visual + Dali::Property::Map map; + map[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE; + map[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME; + Visual::Base imageVisual = factory.CreateVisual( map ); + DALI_TEST_CHECK( imageVisual ); + TestDebugVisual( application.GetScene(), imageVisual, Visual::IMAGE, Vector2(64.0f, 64.0f /* Broken Image Size */ )); + + // Test that image visual with null string don't make visual + map.Clear(); + map[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE; + map[ ImageVisual::Property::URL ] = ""; + Visual::Base emptyVisual = factory.CreateVisual( map ); + DALI_TEST_CHECK( emptyVisual ); + TestDebugVisual( application.GetScene(), emptyVisual, Visual::WIREFRAME, Vector2::ZERO); + + tet_infoline( "Check that GetVisualObject returns the actual WireframeVisual" ); + Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( emptyVisual ).GetVisualObject(); + DALI_TEST_CHECK( dynamic_cast< Toolkit::Internal::WireframeVisual* >( &visualImpl ) ); + + tet_infoline( "Compare the returned emptyVisual with the visual implementation, should be the same" ); + DALI_TEST_CHECK( emptyVisual.GetObjectPtr() == &visualImpl ); + + // Test that image view with empty property map don't make visual even DebugRendering is enabled. + map.Clear(); + ImageView imageView1 = ImageView::New(); + imageView1.SetProperty(Control::Property::BACKGROUND, map); + imageView1.SetProperty(ImageView::Property::IMAGE, map); + + // Test that image view with empty property value don't make visual even DebugRendering is enabled. + Property::Value emptyValue; + ImageView imageView2 = ImageView::New(); + imageView2.SetProperty(Control::Property::BACKGROUND, emptyValue); + imageView2.SetProperty(ImageView::Property::IMAGE, emptyValue); + + // Test that image view with invalid property value don't make visual even DebugRendering is enabled. + Property::Value invalidValue(static_cast(3)); + ImageView imageView3 = ImageView::New(); + imageView3.SetProperty(Control::Property::BACKGROUND, invalidValue); + imageView3.SetProperty(ImageView::Property::IMAGE, invalidValue); + + application.GetScene().Add(imageView1); + application.GetScene().Add(imageView2); + application.GetScene().Add(imageView3); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( imageView1.GetRendererCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView2.GetRendererCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView3.GetRendererCount(), 0u, TEST_LOCATION ); + + EnvironmentVariable::SetTestingEnvironmentVariable(false); + END_TEST; +} + + int UtcDaliDebugRenderingGetVisualObject01(void) { EnvironmentVariable::SetTestingEnvironmentVariable( true ); @@ -271,6 +348,7 @@ int UtcDaliDebugRenderingGetVisualObject01(void) tet_infoline( "Compare the returned TextVisual with the visual implementation, should differ" ); DALI_TEST_CHECK( textVisual.GetObjectPtr() != &visualImpl ); + EnvironmentVariable::SetTestingEnvironmentVariable( false ); END_TEST; } @@ -334,7 +412,7 @@ int UtcDaliDebugRenderingRenderText(void) try { Toolkit::TextLabel label = TextLabel::New( "Hello" ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); DALI_TEST_CHECK( true ); } catch( ... ) {