/*
- * Copyright (c) 2021 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.
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 imageView = ImageView::New();
+ imageView.SetProperty(Control::Property::BACKGROUND, map);
+ imageView.SetProperty(ImageView::Property::IMAGE, map);
+
+ application.GetScene().Add(imageView);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
+
+ EnvironmentVariable::SetTestingEnvironmentVariable(false);
+ END_TEST;
+}
+
+
int UtcDaliDebugRenderingGetVisualObject01(void)
{
EnvironmentVariable::SetTestingEnvironmentVariable( true );
tet_infoline( "Compare the returned TextVisual with the visual implementation, should differ" );
DALI_TEST_CHECK( textVisual.GetObjectPtr() != &visualImpl );
+ EnvironmentVariable::SetTestingEnvironmentVariable( false );
END_TEST;
}
}
END_TEST;
-}
+}
\ No newline at end of file
/*
- * Copyright (c) 2021 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.
DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
DALI_TEST_CHECK( ! visual ); // Visual should be invalid
+ // Set a URL in property map again
+ propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
+ imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
+
+ application.SendNotification();
+ application.Render( 16 );
+
+ value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+ visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+
+ DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
+ DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
+ DALI_TEST_CHECK( visual ); // Visual should be valid
+
+ // Set an empty property map
+ propertyMap.Clear();
+ imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
+
+ application.SendNotification();
+ application.Render( 16 );
+
+ value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+ visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+
+ DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
+ DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
+ DALI_TEST_CHECK( map.Empty() ); // But PropertyMap should be empty
+ DALI_TEST_CHECK( ! visual ); // Visual should be invalid
+
END_TEST;
}
/*
- * Copyright (c) 2021 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.
map = value.GetMap();
if(map)
{
- Property::Value* shaderValue = map->Find(Toolkit::Visual::Property::SHADER, CUSTOM_SHADER);
- // set image only if property map contains image information other than custom shader
- if(map->Count() > 1u || !shaderValue)
+ // the property map is emtpy map. Unregister visual.
+ if(DALI_UNLIKELY(map->Count() == 0u))
{
- impl.SetImage(*map);
+ // Clear cached properties
+ impl.mPropertyMap.Clear();
+ impl.mUrl.clear();
+
+ // Unregister the exsiting visual
+ DevelControl::UnregisterVisual(impl, Toolkit::ImageView::Property::IMAGE);
+
+ // Trigger a size negotiation request that may be needed when unregistering a visual.
+ impl.RelayoutRequest();
}
- // the property map contains only the custom shader
- else if((map->Count() == 1u) && (shaderValue))
+ else
{
- Property::Map* shaderMap = shaderValue->GetMap();
- if(shaderMap)
+ Property::Value* shaderValue = map->Find(Toolkit::Visual::Property::SHADER, CUSTOM_SHADER);
+ // set image only if property map contains image information other than custom shader
+ if(map->Count() > 1u || !shaderValue)
{
- impl.mShaderMap = *shaderMap;
-
- if(!impl.mUrl.empty())
- {
- impl.SetImage(impl.mUrl, impl.mImageSize);
- }
- else if(!impl.mPropertyMap.Empty())
+ impl.SetImage(*map);
+ }
+ // the property map contains only the custom shader
+ else if((map->Count() == 1u) && (shaderValue))
+ {
+ Property::Map* shaderMap = shaderValue->GetMap();
+ if(shaderMap)
{
- impl.SetImage(impl.mPropertyMap);
+ impl.mShaderMap = *shaderMap;
+
+ if(!impl.mUrl.empty())
+ {
+ impl.SetImage(impl.mUrl, impl.mImageSize);
+ }
+ else if(!impl.mPropertyMap.Empty())
+ {
+ impl.SetImage(impl.mPropertyMap);
+ }
}
}
}