/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
#include <mesh-builder.h>
-namespace
-{
-void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
-{
- current.b = 0.0f;
-}
-}
-
void propertyBuffer_test_startup(void)
{
test_return_value = TET_UNDEF;
texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
texturedQuadVertexFormat["aVertexCoord"] = Property::VECTOR2;
- PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
+ PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat );
DALI_TEST_EQUALS( (bool)propertyBuffer, true, TEST_LOCATION );
END_TEST;
texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
texturedQuadVertexFormat["aVertexCoord"] = Property::VECTOR2;
- PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
+ PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat );
BaseHandle handle(propertyBuffer);
PropertyBuffer propertyBuffer2 = PropertyBuffer::DownCast(handle);
END_TEST;
}
-
-int UtcDaliPropertyBufferConstraint01(void)
+int UtcDaliPropertyBufferCopyConstructor(void)
{
TestApplication application;
- tet_infoline("Test that a non-uniform propertyBuffer property can be constrained");
-
- Shader shader = Shader::New("VertexSource", "FragmentSource");
- Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
-
PropertyBuffer propertyBuffer = CreatePropertyBuffer();
- Geometry geometry = CreateQuadGeometryFromBuffer(propertyBuffer);
- Renderer renderer = Renderer::New( geometry, material );
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
+ PropertyBuffer propertyBufferCopy(propertyBuffer);
- Vector4 initialColor = Color::WHITE;
- Property::Index colorIndex = propertyBuffer.RegisterProperty( "fade-color", initialColor );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
-
- // Apply constraint
- Constraint constraint = Constraint::New<Vector4>( propertyBuffer, colorIndex, TestConstraintNoBlue );
- constraint.Apply();
- application.SendNotification();
- application.Render(0);
-
- // Expect no blue component in either buffer - yellow
- DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
-
- propertyBuffer.RemoveConstraints();
- propertyBuffer.SetProperty(colorIndex, Color::WHITE );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
+ DALI_TEST_EQUALS( (bool)propertyBufferCopy, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( propertyBufferCopy.GetSize(), 0u, TEST_LOCATION );
END_TEST;
}
-int UtcDaliPropertyBufferConstraint02(void)
+int UtcDaliPropertyBufferAssignmentOperator(void)
{
TestApplication application;
- tet_infoline("Test that a uniform map propertyBuffer property can be constrained");
-
- Shader shader = Shader::New( "VertexSource", "FragmentSource" );
- Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
-
PropertyBuffer propertyBuffer = CreatePropertyBuffer();
- Geometry geometry = CreateQuadGeometryFromBuffer(propertyBuffer);
- Renderer renderer = Renderer::New( geometry, material );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- Vector4 initialColor = Color::WHITE;
- Property::Index colorIndex = propertyBuffer.RegisterProperty( "fade-color", initialColor );
- propertyBuffer.AddUniformMapping( colorIndex, std::string("uFadeColor") );
- TestGlAbstraction& gl = application.GetGlAbstraction();
+ PropertyBuffer propertyBuffer2;
+ DALI_TEST_EQUALS( (bool)propertyBuffer2, false, TEST_LOCATION );
- application.SendNotification();
- application.Render(0);
-
- Vector4 actualValue(Vector4::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
-
- // Apply constraint
- Constraint constraint = Constraint::New<Vector4>( propertyBuffer, colorIndex, TestConstraintNoBlue );
- constraint.Apply();
- application.SendNotification();
- application.Render(0);
-
- // Expect no blue component in either buffer - yellow
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
-
- application.Render(0);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
-
- propertyBuffer.RemoveConstraints();
- propertyBuffer.SetProperty(colorIndex, Color::WHITE );
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
+ propertyBuffer2 = propertyBuffer;
+ DALI_TEST_EQUALS( (bool)propertyBuffer2, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( propertyBuffer2.GetSize(), 0u, TEST_LOCATION );
END_TEST;
}
-
-
-int UtcDaliPropertyBufferAnimatedProperty01(void)
+int UtcDaliPropertyBufferMoveConstructor(void)
{
TestApplication application;
- tet_infoline("Test that a non-uniform propertyBuffer property can be animated");
-
- Shader shader = Shader::New("VertexSource", "FragmentSource");
- Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
-
PropertyBuffer propertyBuffer = CreatePropertyBuffer();
- Geometry geometry = CreateQuadGeometryFromBuffer(propertyBuffer);
- Renderer renderer = Renderer::New( geometry, material );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
-
- Vector4 initialColor = Color::WHITE;
- Property::Index colorIndex = propertyBuffer.RegisterProperty( "fade-color", initialColor );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
-
- Animation animation = Animation::New(1.0f);
- KeyFrames keyFrames = KeyFrames::New();
- keyFrames.Add(0.0f, initialColor);
- keyFrames.Add(1.0f, Color::TRANSPARENT);
- animation.AnimateBetween( Property( propertyBuffer, colorIndex ), keyFrames );
- animation.Play();
-
- application.SendNotification();
- application.Render(500);
+ DALI_TEST_CHECK( propertyBuffer );
+ DALI_TEST_EQUALS( 1, propertyBuffer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, propertyBuffer.GetSize(), TEST_LOCATION );
- DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
-
- application.Render(500);
-
- DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
+ PropertyBuffer move = std::move( propertyBuffer );
+ DALI_TEST_CHECK( move );
+ DALI_TEST_EQUALS( 1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, move.GetSize(), TEST_LOCATION );
+ DALI_TEST_CHECK( !propertyBuffer );
END_TEST;
}
-int UtcDaliPropertyBufferAnimatedProperty02(void)
+int UtcDaliPropertyBufferMoveAssignment(void)
{
TestApplication application;
- tet_infoline("Test that a uniform map propertyBuffer property can be animated");
-
- Shader shader = Shader::New("VertexSource", "FragmentSource");
- Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
-
PropertyBuffer propertyBuffer = CreatePropertyBuffer();
- Geometry geometry = CreateQuadGeometryFromBuffer(propertyBuffer);
- Renderer renderer = Renderer::New( geometry, material );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- Vector4 initialColor = Color::WHITE;
- Property::Index colorIndex = propertyBuffer.RegisterProperty( "fade-color", initialColor );
- propertyBuffer.AddUniformMapping( colorIndex, std::string("uFadeColor") );
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
-
- application.SendNotification();
- application.Render(0);
+ DALI_TEST_CHECK( propertyBuffer );
+ DALI_TEST_EQUALS( 1, propertyBuffer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, propertyBuffer.GetSize(), TEST_LOCATION );
- Vector4 actualValue(Vector4::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
-
- Animation animation = Animation::New(1.0f);
- KeyFrames keyFrames = KeyFrames::New();
- keyFrames.Add(0.0f, initialColor);
- keyFrames.Add(1.0f, Color::TRANSPARENT);
- animation.AnimateBetween( Property( propertyBuffer, colorIndex ), keyFrames );
- animation.Play();
-
- application.SendNotification();
- application.Render(500);
-
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
-
- application.Render(500);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+ PropertyBuffer move;
+ move = std::move( propertyBuffer );
+ DALI_TEST_CHECK( move );
+ DALI_TEST_EQUALS( 1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, move.GetSize(), TEST_LOCATION );
+ DALI_TEST_CHECK( !propertyBuffer );
END_TEST;
}
texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
texturedQuadVertexFormat["aVertexCoord"] = Property::VECTOR2;
- PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
- DALI_TEST_EQUALS( (bool)propertyBuffer, true, TEST_LOCATION );
-
- const float halfQuadSize = .5f;
- struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
- TexturedQuadVertex texturedQuadVertexData[4] = {
- { Vector2(-halfQuadSize, -halfQuadSize), Vector2(0.f, 0.f) },
- { Vector2( halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f) },
- { Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f) },
- { Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
+ {
+ PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat );
+ DALI_TEST_EQUALS( (bool)propertyBuffer, true, TEST_LOCATION );
+
+ const float halfQuadSize = .5f;
+ struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
+ TexturedQuadVertex texturedQuadVertexData[4] = {
+ { Vector2(-halfQuadSize, -halfQuadSize), Vector2(0.f, 0.f) },
+ { Vector2( halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f) },
+ { Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f) },
+ { Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
+
+ propertyBuffer.SetData( texturedQuadVertexData, 4 );
+
+ Geometry geometry = Geometry::New();
+ geometry.AddVertexBuffer( propertyBuffer );
+
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
+ Actor actor = Actor::New();
+ actor.SetProperty( Actor::Property::SIZE,Vector3::ONE * 100.f);
+ actor.AddRenderer(renderer);
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render(0);
+ application.Render();
+ application.SendNotification();
- propertyBuffer.SetData( texturedQuadVertexData );
+ const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
+ application.GetGlAbstraction().GetBufferDataCalls();
- Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer( propertyBuffer );
+ DALI_TEST_EQUALS( bufferDataCalls.size(), 1u, TEST_LOCATION );
- Material material = CreateMaterial(1.f);
- Renderer renderer = Renderer::New(geometry, material);
- Actor actor = Actor::New();
- actor.SetSize(Vector3::ONE * 100.f);
- actor.AddRenderer(renderer);
- Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( bufferDataCalls[0], sizeof(texturedQuadVertexData), TEST_LOCATION );
+ }
+ // end of scope to let the buffer and geometry die; do another notification and render to get the deletion processed
application.SendNotification();
application.Render(0);
- application.Render();
- application.SendNotification();
-
- const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
- application.GetGlAbstraction().GetBufferDataCalls();
-
- DALI_TEST_EQUALS( bufferDataCalls.size(), 1u, TEST_LOCATION );
-
- DALI_TEST_EQUALS( bufferDataCalls[0], sizeof(texturedQuadVertexData), TEST_LOCATION );
END_TEST;
}
texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
texturedQuadVertexFormat["aVertexCoord"] = Property::VECTOR2;
- PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
+ PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat );
DALI_TEST_EQUALS( (bool)propertyBuffer, true, TEST_LOCATION );
const float halfQuadSize = .5f;
{ Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f) },
{ Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
- propertyBuffer.SetData( texturedQuadVertexData );
+ propertyBuffer.SetData( texturedQuadVertexData, 4 );
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( propertyBuffer );
- Material material = CreateMaterial(1.f);
- Renderer renderer = Renderer::New(geometry, material);
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
Actor actor = Actor::New();
- actor.SetSize(Vector3::ONE * 100.f);
+ actor.SetProperty( Actor::Property::SIZE,Vector3::ONE * 100.f);
actor.AddRenderer(renderer);
- Stage::GetCurrent().Add(actor);
+ application.GetScene().Add(actor);
application.SendNotification();
application.Render(0);
}
// Re-upload the data on the propertyBuffer
- propertyBuffer.SetData( texturedQuadVertexData );
+ propertyBuffer.SetData( texturedQuadVertexData, 4 );
application.SendNotification();
application.Render(0);
const TestGlAbstraction::BufferSubDataCalls& bufferSubDataCalls =
application.GetGlAbstraction().GetBufferSubDataCalls();
+ const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
+ application.GetGlAbstraction().GetBufferDataCalls();
+
DALI_TEST_EQUALS( bufferSubDataCalls.size(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( bufferDataCalls.size(), 1u, TEST_LOCATION );
if ( bufferSubDataCalls.size() )
{
END_TEST;
}
-int UtcDaliPropertyBufferSetSize01(void)
+int UtcDaliPropertyBufferInvalidTypeN(void)
{
TestApplication application;
Property::Map texturedQuadVertexFormat;
- texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
- texturedQuadVertexFormat["aVertexCoord"] = Property::VECTOR2;
-
- PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat, 4u );
- DALI_TEST_EQUALS( (bool)propertyBuffer, true, TEST_LOCATION );
-
- size_t size = propertyBuffer.GetSize();
- DALI_TEST_EQUALS( size, 4u, TEST_LOCATION );
-
- propertyBuffer.SetSize( 10u );
- size = propertyBuffer.GetSize();
- DALI_TEST_EQUALS( size, 10u, TEST_LOCATION );
+ texturedQuadVertexFormat["aPosition"] = Property::MAP;
+ texturedQuadVertexFormat["aVertexCoord"] = Property::STRING;
+ try
+ {
+ PropertyBuffer propertyBuffer = PropertyBuffer::New( texturedQuadVertexFormat );
+ tet_result(TET_FAIL);
+ }
+ catch ( Dali::DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "Property::Type not supported in PropertyBuffer", TEST_LOCATION );
+ }
END_TEST;
}