utc-Dali-Text-Layout.cpp
utc-Dali-Text-Controller.cpp
utc-Dali-VisualFactoryResolveUrl.cpp
+ utc-Dali-Visuals.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/wireframe/wireframe-visual.h>
+
+using namespace Dali::Toolkit::Internal;
+
+namespace
+{
+
+class DummyWireframeVisual : public WireframeVisual
+{
+public:
+
+ DummyWireframeVisual( VisualFactoryCache& factoryCache )
+ : WireframeVisual( factoryCache )
+ {}
+
+ virtual ~DummyWireframeVisual()
+ {}
+
+ void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+ {
+ WireframeVisual::DoSetProperty( index, propertyValue );
+ }
+
+ Dali::Property::Value DoGetProperty( Dali::Property::Index index )
+ {
+ return WireframeVisual::DoGetProperty( index );
+ }
+};
+
+} // namespace
+
+int UtcDaliWireframeVisual(void)
+{
+ // The goal of this test case is to cover the WireframeVisual::DoSetProperty() and
+ // WireframeVisual::DoGetProperty() which are unreachable from the public API.
+
+ tet_infoline( " UtcDaliWireframeVisual" );
+
+ VisualFactoryCache* visualFactoryCache = new VisualFactoryCache();
+
+ DummyWireframeVisual visual( *visualFactoryCache );
+
+ visual.DoSetProperty( Dali::Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::WIREFRAME );
+ Dali::Property::Value value = visual.DoGetProperty( Dali::Toolkit::Visual::Property::TYPE );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
+ // Test the properties. TODO: to be completed.
+ colorVisual.SetProperty( ColorVisual::Property::MIX_COLOR, Color::RED );
+ Property::Value value = colorVisual.GetProperty( ColorVisual::Property::MIX_COLOR );
+
END_TEST;
}
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<float>() == 10.f );
+ // Test the properties. TODO: to be completed.
+ borderVisual.SetProperty( BorderVisual::Property::COLOR, Color::RED );
+ Property::Value value = borderVisual.GetProperty( BorderVisual::Property::COLOR );
+
END_TEST;
}
DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ // Test the properties. TODO: to be completed.
+ gradientVisual.SetProperty( GradientVisual::Property::STOP_COLOR, Color::RED );
+ Property::Value gradientValue = gradientVisual.GetProperty( GradientVisual::Property::STOP_COLOR );
+
END_TEST;
}
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<bool>() == false );
+ // Test the properties. TODO: to be completed.
+ imageVisual.SetProperty( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ Property::Value imageValue = imageVisual.GetProperty( ImageVisual::Property::URL );
+
END_TEST;
}
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<bool>() );
+ // Test the properties. TODO: to be completed.
+ nPatchVisual.SetProperty( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
+ Property::Value nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::URL );
+
END_TEST;
}
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
Visual::Base svgVisual = factory.CreateVisual( propertyMap );
Property::Map resultMap;
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
+ // Test the properties. TODO: to be completed.
+ svgVisual.SetProperty( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
+ Property::Value svgValue = svgVisual.GetProperty( ImageVisual::Property::URL );
+
END_TEST;
}
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ // Test the properties. TODO: to be completed.
+ meshVisual.SetProperty( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ Property::Value meshValue = meshVisual.GetProperty( MeshVisual::Property::OBJECT_URL );
+
END_TEST;
}
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ // Test the properties. TODO: to be completed.
+ primitiveVisual.SetProperty( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
+ Property::Value primitiveValue = primitiveVisual.GetProperty( PrimitiveVisual::Property::SHAPE );
+
END_TEST;
}
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == 30 );
+ // Test the properties. TODO: to be completed.
+ batchImageVisual.SetProperty( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ Property::Value primitiveValue = batchImageVisual.GetProperty( ImageVisual::Property::URL );
+
END_TEST;
}
Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == Visual::WIREFRAME );
+
+ // Test the properties. TODO: to be completed.
+ Property::Value primitiveValue = visual.GetProperty( Visual::Property::TYPE );
+
END_TEST;
}
GetImplementation( *this ).CreatePropertyMap( map );
}
+void Visual::Base::SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ GetImplementation( *this ).SetProperty( index, propertyValue );
+}
+
+Dali::Property::Value Visual::Base::GetProperty( Dali::Property::Index index )
+{
+ return GetImplementation( *this ).GetProperty( index );
+}
+
} // namespace Toolkit
} // namespace Dali
*/
void CreatePropertyMap( Dali::Property::Map& map ) const;
+ /**
+ * @brief Sets the value of an existing property.
+ *
+ * @param [in] index The index of the property.
+ * @param [in] propertyValue The new value of the property.
+ */
+ void SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @brief Retrieves a property value.
+ *
+ * @param [in] index The index of the property.
+ *
+ * @return The property value.
+ */
+ Dali::Property::Value GetProperty( Dali::Property::Index index );
+
public: // Not intended for application developers
explicit DALI_INTERNAL Base(Internal::Visual::Base *impl);
map.Insert( Toolkit::BorderVisual::Property::ANTI_ALIASING, mAntiAliasing );
}
+void BorderVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value BorderVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
void BorderVisual::InitializeRenderer()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::BORDER_GEOMETRY );
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
public:
/**
map.Insert( Toolkit::ColorVisual::Property::MIX_COLOR, mMixColor );
}
+void ColorVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+ /* David Steele comented :
+
+ Some things to bear in mind:
+
+ We currently keep a copy of the mix color in the ColorVisual object, which is then used to instantiate the registered property on the renderer.
+
+ The user can get the renderer and animate the mixColor property (it's registered, so is automatically a scene-graph property).
+
+ The GetProperty method will have to read from the renderer, or from the cached value in the Visual, and the SetProperty will have to write to cache and to the renderer if present.
+ */
+}
+
+Dali::Property::Value ColorVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
void ColorVisual::InitializeRenderer()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
protected:
/**
}
}
+void GradientVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value GradientVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
void GradientVisual::InitializeRenderer()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
protected:
/**
* @copydoc Visual::Base::DoInitialize
}
}
+void BatchImageVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value BatchImageVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
Shader BatchImageVisual::GetBatchShader( VisualFactoryCache& factoryCache )
{
Shader shader = factoryCache.GetShader( VisualFactoryCache::BATCH_IMAGE_SHADER );
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
protected:
/**
map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV );
}
+void ImageVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value ImageVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
Shader ImageVisual::GetImageShader( VisualFactoryCache& factoryCache, bool atlasing, bool defaultTextureWrapping )
{
Shader shader;
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
protected:
/**
* @copydoc Visual::Base::DoInitialize
map.Insert( Toolkit::MeshVisual::Property::LIGHT_POSITION, mLightPosition );
}
+void MeshVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value MeshVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
void MeshVisual::InitializeRenderer()
{
//Try to load the geometry from the file.
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
protected:
/**
map.Insert( Toolkit::ImageVisual::Property::BORDER_ONLY, mBorderOnly );
}
+void NPatchVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value NPatchVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
void NPatchVisual::ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t oldGridY )
{
//check to see if the border style has changed
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
protected:
/**
map.Insert( Toolkit::PrimitiveVisual::Property::LIGHT_POSITION, mLightPosition );
}
+void PrimitiveVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value PrimitiveVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
void PrimitiveVisual::InitializeRenderer()
{
if( !mGeometry )
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
protected:
/**
}
}
+void SvgVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value SvgVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
void SvgVisual::SetImage( const std::string& imageUrl, ImageDimensions size )
{
if( mImageUrl != imageUrl )
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
+
protected:
/**
return mImpl->mFlags & Impl::IS_FROM_CACHE;
}
+void Visual::Base::SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ DALI_ASSERT_ALWAYS( ( index > Property::INVALID_INDEX ) &&
+ ( index > VISUAL_PROPERTY_BASE_START_INDEX ) && // Change the type of visual is not allowed.
+ "Property index is out of bounds" );
+
+ if( index < VISUAL_PROPERTY_START_INDEX )
+ {
+ // TODO set the properties of the visual base.
+ }
+ else
+ {
+ DoSetProperty( index, propertyValue );
+ }
+}
+
+Dali::Property::Value Visual::Base::GetProperty( Dali::Property::Index index )
+{
+ DALI_ASSERT_ALWAYS( ( index > Property::INVALID_INDEX ) &&
+ ( index >= VISUAL_PROPERTY_BASE_START_INDEX ) &&
+ "Property index is out of bounds" );
+
+ Dali::Property::Value value;
+
+ if( index < VISUAL_PROPERTY_START_INDEX )
+ {
+ // TODO retrieve the properties of the visual base.
+ }
+ else
+ {
+ value = DoGetProperty( index );
+ }
+
+ return value;
+}
+
} // namespace Internal
} // namespace Toolkit
*/
void SetCustomShader( const Property::Map& propertyMap );
+ /**
+ * @copydoc Toolkit::Visual::Base::SetProperty
+ */
+ void SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Toolkit::Visual::Base::GetProperty
+ */
+ Dali::Property::Value GetProperty( Dali::Property::Index index );
+
protected:
/**
*/
bool GetIsFromCache() const;
+protected:
+ /**
+ * @brief Called by SetProperty(). To be overriden by derived clases in order to set properties.
+ *
+ * @param [in] index The index of the property.
+ * @param [in] propertyValue The new value of the property.
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue ) = 0;
+
+ /**
+ * @brief Called by GetProperty(). To be overriden by derived classes in order to retrieve properties.
+ *
+ * @param [in] index The index of the property.
+ *
+ * @return The property value.
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index ) = 0;
+
private:
// Undefined
map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::WIREFRAME );
}
+void WireframeVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value WireframeVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
void WireframeVisual::InitializeRenderer()
{
mImpl->mRenderer = mFactoryCache.GetWireframeRenderer();
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
+ /**
+ * @copydoc Visual::Base::DoSetProperty
+ */
+ virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
+
+ /**
+ * @copydoc Visual::Base::DoGetProperty
+ */
+ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
private:
/**