[dali_2.1.5] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-DebugRendering.cpp
index 12276e8..9b733f2 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 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.
@@ -26,7 +26,9 @@
 
 #include <toolkit-environment-variable.h> // for setting environment variable: DALI_DEBUG_RENDERING
 
+#if defined(ELDBUS_ENABLED)
 #include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
+#endif
 
 #include "dummy-control.h"
 
@@ -78,7 +80,9 @@ void TestDebugVisual( Integration::Scene scene,  Visual::Base& visual, Visual::T
 void dali_debug_rendering_startup(void)
 {
   test_return_value = TET_UNDEF;
+#if defined(ELDBUS_ENABLED)
   DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
+#endif
 }
 
 void dali_debug_rendering_cleanup(void)
@@ -194,7 +198,7 @@ int UtcDaliDebugRenderingGetVisual1(void)
   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, 57.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
@@ -253,6 +257,73 @@ int UtcDaliDebugRenderingGetVisual2(void)
   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<int>(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 );
@@ -277,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;
 }