/*
- * Copyright (c) 2016 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;
END_TEST;
}
+int UtcDaliPropertyBufferMoveConstructor(void)
+{
+ TestApplication application;
+
+ PropertyBuffer propertyBuffer = CreatePropertyBuffer();
+ DALI_TEST_CHECK( propertyBuffer );
+ DALI_TEST_EQUALS( 1, propertyBuffer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, propertyBuffer.GetSize(), 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 UtcDaliPropertyBufferMoveAssignment(void)
+{
+ TestApplication application;
+
+ PropertyBuffer propertyBuffer = CreatePropertyBuffer();
+ DALI_TEST_CHECK( propertyBuffer );
+ DALI_TEST_EQUALS( 1, propertyBuffer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, propertyBuffer.GetSize(), 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;
+}
+
int UtcDaliPropertyBufferSetData01(void)
{
TestApplication application;
texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
texturedQuadVertexFormat["aVertexCoord"] = Property::VECTOR2;
- 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 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, 4 );
+ const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
+ application.GetGlAbstraction().GetBufferDataCalls();
- Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer( propertyBuffer );
+ DALI_TEST_EQUALS( bufferDataCalls.size(), 1u, TEST_LOCATION );
- Shader shader = CreateShader();
- Renderer renderer = Renderer::New(geometry, shader);
- 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;
}
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);
if ( bufferSubDataCalls.size() )
{
DALI_TEST_EQUALS( bufferSubDataCalls[0], sizeof(texturedQuadVertexData), TEST_LOCATION );
-
}
}
END_TEST;
}
+
+int UtcDaliPropertyBufferInvalidTypeN(void)
+{
+ TestApplication application;
+
+ Property::Map texturedQuadVertexFormat;
+ 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;
+}
+