SET(CAPI_LIB "dali-internal")
SET(TC_SOURCES
+ utc-Dali-Atlas.cpp
+ utc-Dali-AnimatableMesh.cpp
+ utc-Dali-Context.cpp
+ utc-Dali-Constrainer.cpp
+ utc-Dali-DistanceField.cpp
+ utc-Dali-DynamicsBodyConfig.cpp
+ utc-Dali-DynamicsShape.cpp
+ utc-Dali-DynamicsWorld.cpp
+ utc-Dali-DynamicsWorldConfig.cpp
+ utc-Dali-Hash.cpp
+ utc-Dali-HitTestAlgorithm.cpp
+ utc-Dali-Material.cpp
+ utc-Dali-MeshActor.cpp
+ utc-Dali-MeshData.cpp
+ utc-Dali-Mutex.cpp
+ utc-Dali-Scripting.cpp
utc-Dali-Internal-Handles.cpp
utc-Dali-Internal-ImageFactory.cpp
utc-Dali-Internal-Mesh.cpp
)
LIST(APPEND TC_SOURCES
- ../dali/dali-test-suite-utils/mesh-builder.cpp
+ mesh-builder.cpp
../dali/dali-test-suite-utils/test-harness.cpp
../dali/dali-test-suite-utils/dali-test-suite-utils.cpp
../dali/dali-test-suite-utils/test-application.cpp
INCLUDE_DIRECTORIES(
../../..
+ .
${${CAPI_LIB}_INCLUDE_DIRS}
../dali/dali-test-suite-utils
)
ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
TARGET_LINK_LIBRARIES(${EXEC_NAME}
${${CAPI_LIB}_LIBRARIES}
+ -lpthread
)
INSTALL(PROGRAMS ${EXEC_NAME}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 "mesh-builder.h"
+
+namespace Dali
+{
+
+void AddVertex( MeshData::VertexContainer& verts, Vector3 V, Vector2 UV )
+{
+ MeshData::Vertex meshVertex;
+ meshVertex.x = V.x;
+ meshVertex.y = V.y;
+ meshVertex.z = V.z;
+ meshVertex.u = UV.x;
+ meshVertex.v = UV.y;
+ verts.push_back(meshVertex);
+}
+
+void SetNormal( MeshData::VertexContainer& verts, size_t vertIdx, Vector3 normal )
+{
+ verts[vertIdx].nX = normal.x;
+ verts[vertIdx].nY = normal.y;
+ verts[vertIdx].nZ = normal.z;
+}
+
+void SetBone( MeshData::VertexContainer& verts, size_t vertIdx, size_t index, size_t boneIndex, float weight)
+{
+ verts[vertIdx].boneIndices[index] = boneIndex;
+ verts[vertIdx].boneWeights[index] = weight;
+}
+
+void SetBones(MeshData::VertexContainer& verts)
+{
+ // Set all verts in one corner to be affected fully by bone 0
+ SetBone(verts, 0, 0, 0, 1.0f);
+ SetBone(verts, 1, 0, 0, 1.0f);
+ SetBone(verts, 2, 0, 0, 1.0f);
+
+ // Set all verts in next corner to be affected by bone 1 and bone 2 equally
+ SetBone(verts, 3, 0, 1, 0.5f);
+ SetBone(verts, 4, 0, 1, 0.5f);
+ SetBone(verts, 5, 0, 1, 0.5f);
+
+ SetBone(verts, 3, 1, 2, 0.5f);
+ SetBone(verts, 4, 1, 2, 0.5f);
+ SetBone(verts, 5, 1, 2, 0.5f);
+}
+
+void ConstructBones(BoneContainer& bones)
+{
+ bones.push_back(Bone("Bone1", Matrix::IDENTITY));
+ bones.push_back(Bone("Bone2", Matrix::IDENTITY));
+ bones.push_back(Bone("Bone3", Matrix::IDENTITY));
+}
+
+void CopyVertex( MeshData::Vertex& vert, Vector3& vector )
+{
+ vector.x = vert.x;
+ vector.y = vert.y;
+ vector.z = vert.z;
+}
+
+void AddTriangle( MeshData::VertexContainer& verts,
+ MeshData::FaceIndices& faces,
+ size_t v0, size_t v1, size_t v2 )
+{
+ faces.push_back(v0);
+ faces.push_back(v1);
+ faces.push_back(v2);
+
+ // Calculate normal...
+ Vector3 vert0, vert1, vert2;
+ CopyVertex(verts[v0], vert0);
+ CopyVertex(verts[v1], vert1);
+ CopyVertex(verts[v2], vert2);
+ Vector3 e0 = vert1 - vert0;
+ Vector3 e1 = vert2 - vert1;
+ Vector3 normal = e0.Cross(e1);
+ normal.Normalize();
+ SetNormal(verts, v0, normal);
+ SetNormal(verts, v1, normal);
+ SetNormal(verts, v2, normal);
+}
+
+void ConstructVertices( MeshData::VertexContainer& vertices, float sz )
+{
+ // back
+ AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0a 0
+ AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0b 1
+ AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0c 2
+
+ // left
+ AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1a 3
+ AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1b 4
+ AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1c 5
+
+ // right
+ AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2a 6
+ AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2b 7
+ AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2c 8
+
+ // top
+ AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3a 9
+ AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3b 10
+ AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3c 11
+}
+
+void ConstructFaces(MeshData::VertexContainer& vertices, MeshData::FaceIndices& faces)
+{
+ AddTriangle(vertices, faces, 0, 6, 3); // 0, 2, 1 back, right, left (ac)
+ AddTriangle(vertices, faces, 1, 9, 7); // 0, 3, 2 back, top , right (ac)
+ AddTriangle(vertices, faces, 2, 4, 10); // 0, 1, 3 back, left, top (ac)
+ AddTriangle(vertices, faces, 11, 5, 8); // 3, 1, 2 top, left, right (ac)
+}
+
+Material ConstructMaterial()
+{
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetOpacity(.76f);
+ customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, 1.0f));
+ customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
+ customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
+ return customMaterial;
+}
+
+
+Mesh ConstructMesh( float sz )
+{
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ ConstructVertices( vertices, sz );
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+
+ MeshData meshData;
+ BoneContainer bones;
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ meshData.SetHasNormals(true);
+ meshData.SetHasTextureCoords(true);
+
+ Mesh mesh = Mesh::New(meshData);
+ return mesh;
+}
+
+
+void AddBone(Dali::BoneContainer& bones, const std::string& name, const Dali::Matrix& offsetMatrix)
+{
+ bones.push_back(Bone(name, offsetMatrix));
+}
+
+void CreateMeshData(MeshData& meshData)
+{
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ Dali::BoneContainer bones;
+ AddBone(bones, "trunk", Matrix::IDENTITY);
+ AddBone(bones, "branch", Matrix::IDENTITY);
+ AddBone(bones, "twig", Matrix::IDENTITY);
+ ConstructVertices( vertices, 50 );
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ meshData.SetHasNormals(true);
+ meshData.SetHasTextureCoords(true);
+}
+
+
+} // namespace Dali
--- /dev/null
+#ifndef MESH_BUILDER_H
+#define MESH_BUILDER_H
+/*
+ * Copyright (c) 2014 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 <dali/public-api/dali-core.h>
+#include <dali/devel-api/geometry/mesh.h>
+
+namespace Dali
+{
+
+void AddVertex( MeshData::VertexContainer& verts, Vector3 V, Vector2 UV );
+void SetNormal( MeshData::VertexContainer& verts, size_t vertIdx, Vector3 normal );
+void SetBone( MeshData::VertexContainer& verts, size_t vertIdx, size_t index, size_t boneIndex, float weight);
+void SetBones(MeshData::VertexContainer& verts);
+void ConstructBones(BoneContainer& bones);
+void CopyVertex( MeshData::Vertex& vert, Vector3& vector );
+void AddTriangle( MeshData::VertexContainer& verts,
+ MeshData::FaceIndices& faces,
+ size_t v0, size_t v1, size_t v2 );
+void ConstructVertices( MeshData::VertexContainer& vertices, float sz );
+void ConstructFaces(MeshData::VertexContainer& vertices, MeshData::FaceIndices& faces);
+Material ConstructMaterial();
+Mesh ConstructMesh( float sz );
+void AddBone(Dali::BoneContainer& bones, const std::string& name, const Dali::Matrix& offsetMatrix);
+void CreateMeshData(MeshData& meshData);
+
+}
+
+#endif // MESH_BUILDER_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali/devel-api/geometry/animatable-mesh.h>
+#include <dali/devel-api/actors/mesh-actor.h>
+#include <dali-test-suite-utils.h>
+#include <mesh-builder.h>
+
+using namespace Dali;
+
+
+void utc_dali_animatable_mesh_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_animatable_mesh_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+void CreateFaces(Dali::AnimatableMesh::Faces& faces, int numVerts)
+{
+ for(int i=0; i<numVerts-3; i++)
+ {
+ faces.push_back(i);
+ faces.push_back(i+1);
+ faces.push_back(i+2);
+ }
+}
+
+void CreateOutOfRangeFaces(Dali::AnimatableMesh::Faces& faces, int numVerts)
+{
+ for(int i=numVerts; i<numVerts*2-3; i++)
+ {
+ faces.push_back(i);
+ faces.push_back(i+1);
+ faces.push_back(i+2);
+ }
+}
+
+AnimatableMesh CreateMesh()
+{
+ AnimatableMesh::Faces faces;
+ CreateFaces(faces, 10);
+ AnimatableMesh mesh = AnimatableMesh::New(10, faces);
+ return mesh;
+}
+
+} // anon namespace
+
+// Negative test case for a method
+int UtcDaliAnimatableMeshConstructor01(void)
+{
+ TestApplication application;
+
+ AnimatableMesh mesh;
+
+ DALI_TEST_CHECK( ! mesh );
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshConstructor02(void)
+{
+ TestApplication application;
+
+ Dali::AnimatableMesh::Faces faces;
+ CreateFaces(faces, 10);
+
+ AnimatableMesh mesh = AnimatableMesh::New(10, faces);
+ DALI_TEST_CHECK( mesh );
+
+ AnimatableMesh mesh2 = mesh;
+ DALI_TEST_CHECK( mesh2 );
+
+ AnimatableMesh mesh3 ( mesh2 );
+ DALI_TEST_CHECK( mesh3 );
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshConstructor03(void)
+{
+ TestApplication application;
+
+ // Heap allocate a handle. Don't do this in real code!
+ AnimatableMesh* mesh = new AnimatableMesh();
+ DALI_TEST_CHECK( ! *mesh );
+ delete mesh;
+ END_TEST;
+}
+
+
+// Positive test case for a method
+int UtcDaliAnimatableMeshNew01(void)
+{
+ TestApplication application;
+
+ Dali::AnimatableMesh::Faces faces;
+ CreateFaces(faces, 10);
+
+ AnimatableMesh mesh = AnimatableMesh::New(10, faces);
+ DALI_TEST_CHECK( mesh );
+ END_TEST;
+}
+
+// Positive test case for a method
+int UtcDaliAnimatableMeshNew02(void)
+{
+ TestApplication application;
+
+ Dali::AnimatableMesh::Faces faces;
+ CreateFaces(faces, 10);
+
+ Dali::Material mat = Dali::Material::New("dummy mat");
+ AnimatableMesh mesh = AnimatableMesh::New(10, faces, mat);
+ DALI_TEST_CHECK( mesh );
+ END_TEST;
+}
+
+
+// Negative test case for a method
+int UtcDaliAnimatableMeshNew03(void)
+{
+ TestApplication application;
+ Dali::AnimatableMesh::Faces faces;
+ try
+ {
+ AnimatableMesh mesh = AnimatableMesh::New(0, faces);
+ DALI_TEST_CHECK( !mesh );
+ }
+ catch (Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "numVertices > 0", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+// Negative test case for a method
+int UtcDaliAnimatableMeshNew04(void)
+{
+ TestApplication application;
+
+ Dali::AnimatableMesh::Faces faces;
+
+ try
+ {
+ AnimatableMesh mesh = AnimatableMesh::New(10, faces);
+ DALI_TEST_CHECK( !mesh );
+ }
+ catch (Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "faceIndices.size() > 0", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+// Negative test case for a method
+int UtcDaliAnimatableMeshNew05(void)
+{
+ TestApplication application;
+
+ Dali::AnimatableMesh::Faces faces;
+ CreateOutOfRangeFaces(faces, 10);
+
+ try
+ {
+ AnimatableMesh mesh = AnimatableMesh::New(10, faces);
+ DALI_TEST_CHECK( !mesh );
+ }
+ catch (Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "faceIndex < numVertices", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+// Negative test case for a method
+int UtcDaliAnimatableMeshNew06(void)
+{
+ TestApplication application;
+
+ Dali::AnimatableMesh::Faces faces;
+ CreateFaces(faces, 10);
+
+ try
+ {
+ AnimatableMesh mesh = AnimatableMesh::New(10, faces, Dali::Material() );
+ DALI_TEST_CHECK( !mesh );
+ }
+ catch (Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "material", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshDownCast01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh::DownCast()");
+
+ Dali::AnimatableMesh::Faces faces;
+ CreateFaces(faces, 10);
+
+ AnimatableMesh mesh = AnimatableMesh::New(10, faces);
+ BaseHandle* bh = &mesh;
+
+ AnimatableMesh mesh2 = AnimatableMesh::DownCast(*bh);
+ DALI_TEST_CHECK( mesh2 );
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshDownCast02(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh::DownCast()");
+
+ MeshData meshData;
+ CreateMeshData(meshData);
+ Mesh mesh = Mesh::New(meshData);
+ BaseHandle* bh = &mesh;
+
+ AnimatableMesh mesh2 = AnimatableMesh::DownCast(*bh);
+ DALI_TEST_CHECK( ! mesh2 );
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshGetPropertyIndex01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh::operator[]");
+ AnimatableMesh mesh = CreateMesh();
+
+ Property::Index i = mesh.GetPropertyIndex(0, AnimatableVertex::Property::POSITION );
+ DALI_TEST_EQUALS( i, 0*3+0, TEST_LOCATION );
+
+ i = mesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION );
+ DALI_TEST_EQUALS( i, 5*3+0, TEST_LOCATION );
+
+ i = mesh.GetPropertyIndex(7, AnimatableVertex::Property::COLOR );
+ DALI_TEST_EQUALS( i, 7*3+1, TEST_LOCATION );
+
+ i = mesh.GetPropertyIndex(9, AnimatableVertex::Property::TEXTURE_COORDS );
+ DALI_TEST_EQUALS( i, 9*3+2, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshGetPropertyIndex02(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndex");
+
+ AnimatableMesh mesh = CreateMesh();
+ try
+ {
+ Property::Index i = mesh.GetPropertyIndex(12, AnimatableVertex::Property::POSITION );
+ DALI_TEST_CHECK( i==0 );
+ }
+ catch (Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshGetPropertyIndex03(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndex");
+
+ AnimatableMesh mesh = CreateMesh();
+ try
+ {
+ Property::Index i = mesh.GetPropertyIndex(12, AnimatableVertex::Property::COLOR );
+ DALI_TEST_CHECK( i==0 );
+ }
+ catch (Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshGetPropertyIndex04(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndexa");
+
+ AnimatableMesh mesh = CreateMesh();
+ try
+ {
+ Property::Index i = mesh.GetPropertyIndex(12342343, AnimatableVertex::Property::TEXTURE_COORDS );
+ DALI_TEST_CHECK( i==0 );
+ }
+ catch (Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshOperatorArray01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh::operator[]");
+
+ AnimatableMesh mesh = CreateMesh();
+ {
+ Vector3 initialPos1(0.0f, 200.0f, 0.0f);
+ Vector3 initialPos2(100.0f, 300.0f, 0.0f);
+
+ mesh[1].SetPosition(initialPos1);
+ mesh[3].SetPosition(initialPos2);
+
+ application.Render(0);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), initialPos1, TEST_LOCATION );
+
+ Vector3 pos = mesh[3].GetCurrentPosition();
+ DALI_TEST_EQUALS( pos, initialPos2, TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshOperatorArray02(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh::operator[]");
+
+ AnimatableMesh mesh = CreateMesh();
+ try
+ {
+ mesh[20].SetPosition(Vector3(0.0f, 0.0f, 0.0f));
+ }
+ catch (Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshAnimateVertex01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableMesh Animating properties");
+
+ AnimatableMesh mesh = CreateMesh();
+ MeshActor meshActor = MeshActor::New(mesh);
+ Stage::GetCurrent().Add(meshActor);
+ {
+ mesh[0].SetPosition(Vector3(0.0f, 200.0f, 0.0f));
+ mesh[1].SetPosition(Vector3(100.0f, 300.0f, 0.0f));
+
+ Animation anim = Animation::New(1);
+ anim.AnimateBy(mesh.GetVertexProperty(0, AnimatableVertex::Property::POSITION), Vector3( 0.0f, 100.0f, 0.0f));
+ anim.AnimateTo(mesh.GetVertexProperty(1, AnimatableVertex::Property::POSITION), Vector3(100.0f, 0.0f, 0.0f));
+ anim.Play();
+
+ application.SendNotification();
+ application.Render(0);
+ application.Render(500);
+ application.SendNotification();
+
+ // 50% progress
+ DALI_TEST_EQUALS( mesh[0].GetCurrentPosition(), Vector3( 0.0f, 250.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), Vector3(100.0f, 150.0f, 0.0f), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(501);
+ application.SendNotification();
+
+ DALI_TEST_EQUALS( mesh[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), Vector3(100.0f, 0.0f, 0.0f), TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliAnimatableVertexSettersAndGetters(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::AnimatableVertex constructors");
+ AnimatableMesh mesh = CreateMesh();
+ Vector3 v1Pos(0.0f, 200.0f, 0.0f);
+ Vector3 v2Pos(100.0f, 300.0f, 0.0f);
+ Vector2 uvs(0.1f, 0.2f);
+ mesh[0].SetPosition(v1Pos);
+ mesh[1].SetPosition(v2Pos);
+ mesh[2].SetColor(Color::BLACK);
+ mesh[3].SetTextureCoords(uvs);
+
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_EQUALS(mesh[0].GetCurrentPosition(), v1Pos, TEST_LOCATION);
+ DALI_TEST_EQUALS(mesh[1].GetCurrentPosition(), v2Pos, TEST_LOCATION);
+ DALI_TEST_EQUALS(mesh[2].GetCurrentColor(), Color::BLACK, TEST_LOCATION);
+ DALI_TEST_EQUALS(mesh[3].GetCurrentTextureCoords(), uvs, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshProperties(void)
+{
+ TestApplication application;
+ AnimatableMesh mesh = CreateMesh();
+
+ Property::IndexContainer indices;
+ mesh.GetPropertyIndices( indices );
+ DALI_TEST_CHECK( ! indices.empty() );
+ DALI_TEST_EQUALS( indices.size(), mesh.GetPropertyCount(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshExceedVertices(void)
+{
+ TestApplication application;
+
+ AnimatableMesh::Faces faces;
+ CreateFaces(faces, 10);
+
+ try
+ {
+ AnimatableMesh mesh = AnimatableMesh::New(3333334, faces);
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "( numVertices * 3 ) < DEFAULT_PROPERTY_MAX_COUNT", TEST_LOCATION );
+ }
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 <algorithm>
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/bitmap.h>
+#include <dali/devel-api/images/atlas.h>
+#include <dali-test-suite-utils.h>
+#include <test-native-image.h>
+
+using namespace Dali;
+
+namespace
+{
+static const char* gTestImageFilename = "icon_wrt.png";
+
+void PrepareResourceImage( TestApplication& application, unsigned int imageHeight, unsigned int imageWidth, Pixel::Format pixelFormat )
+{
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetClosestImageSize(Vector2( 16, 16));
+
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
+ unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
+ unsigned int initialColor = 0xFF;
+ memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel);
+
+ Integration::ResourcePointer resourcePtr(bitmap);
+ platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
+}
+
+}
+
+void utc_dali_atlas_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_atlas_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+// 1.1
+int UtcDaliAtlasNew01(void)
+{
+ TestApplication application;
+
+ // invoke default handle constructor
+ Atlas atlas;
+
+ DALI_TEST_CHECK( !atlas );
+
+ // initialise handle
+ atlas = Atlas::New( 16, 16 );
+
+ DALI_TEST_CHECK( atlas );
+ END_TEST;
+}
+
+
+// 1.2
+int UtcDaliAtlasUpload01(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ // Using correct pixel format
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
+
+ PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 0 ) );
+
+ END_TEST;
+}
+
+// 1.3
+int UtcDaliAtlasUpload02(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 10, 10, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ // Using INCORRECT pixel format
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::A8 );
+ DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
+
+ PrepareResourceImage( application, 16, 16, Pixel::A8 );
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 0, 0 ) );
+
+ END_TEST;
+}
+
+// 1.4
+int UtcDaliAtlasUpload03(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 10, 10, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ // Using image too big for atlas
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
+
+ PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 0, 0 ) );
+
+ END_TEST;
+}
+
+// 1.5
+int UtcDaliAtlasUpload04(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 32, 32, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ // Using valid offsets
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+
+ DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
+ DALI_TEST_CHECK( atlas.Upload( image, 16, 0 ) );
+ DALI_TEST_CHECK( atlas.Upload( image, 0, 16 ) );
+ DALI_TEST_CHECK( atlas.Upload( image, 16, 16 ) );
+
+ PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 0 ) );
+ DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 16, 0 ) );
+ DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 16 ) );
+ DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 16, 16 ) );
+
+ END_TEST;
+}
+
+// 1.6
+int UtcDaliAtlasUpload05(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 32, 32, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ // Using invalid offsets
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+
+ DALI_TEST_CHECK( !atlas.Upload( image, 0, 17 ) );
+ DALI_TEST_CHECK( !atlas.Upload( image, 17, 0 ) );
+ DALI_TEST_CHECK( !atlas.Upload( image, 17, 17 ) );
+ DALI_TEST_CHECK( !atlas.Upload( image, 99, 0 ) );
+ DALI_TEST_CHECK( !atlas.Upload( image, 0, 99 ) );
+ DALI_TEST_CHECK( !atlas.Upload( image, 99, 99 ) );
+
+ PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
+
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 0, 17 ) );
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 17, 0 ) );
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 17, 17 ) );
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 99, 0 ) );
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 0, 99 ) );
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 99, 99 ) );
+
+ END_TEST;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali/devel-api/animation/path-constrainer.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+using namespace Dali::Internal;
+
+namespace
+{
+
+static void SetupPath( Dali::Path& path)
+{
+ path.AddPoint(Vector3( 30.0, 80.0, 0.0));
+ path.AddPoint(Vector3( 70.0, 120.0, 0.0));
+ path.AddPoint(Vector3(100.0, 100.0, 0.0));
+
+ //Control points for first segment
+ path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
+ path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
+
+ //Control points for second segment
+ path.AddControlPoint(Vector3( 78.0, 120.0, 0.0) );
+ path.AddControlPoint(Vector3( 93.0, 104.0, 0.0) );
+}
+
+static void SetupPathConstrainer( Dali::PathConstrainer& PathConstrainer)
+{
+ PathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3(1.0f,0.0f,0.0f) );
+
+ Dali::Property::Array points;
+ points.Resize(3);
+ points[0] = Vector3( 30.0, 80.0, 0.0);
+ points[1] = Vector3( 70.0, 120.0, 0.0);
+ points[2] = Vector3(100.0, 100.0, 0.0);
+ PathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points );
+
+ points.Resize(4);
+ points[0] = Vector3( 39.0, 90.0, 0.0);
+ points[1] = Vector3( 56.0, 119.0, 0.0);
+ points[2] = Vector3( 78.0, 120.0, 0.0);
+ points[3] = Vector3( 93.0, 104.0, 0.0);
+ PathConstrainer.SetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS, points );
+}
+
+static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer)
+{
+ Dali::Property::Array points;
+ points.Resize(3);
+ points[0] = 0.0f;
+ points[1] = 1.0f;
+ points[2] = 0.0f;
+ linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
+}
+
+static void SetupLinearConstrainerNonUniformProgress( Dali::LinearConstrainer& linearConstrainer)
+{
+ Dali::Property::Array points;
+ points.Resize(3);
+ points[0] = 0.0f;
+ points[1] = 1.0f;
+ points[2] = 0.0f;
+ linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
+
+ points[0] = 0.0f;
+ points[1] = 0.25f;
+ points[2] = 1.0f;
+ linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::PROGRESS, points );
+}
+
+} // anonymous namespace
+
+//PathConstrainer test cases
+int UtcPathConstrainerApply(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a Path
+ Dali::Path path = Dali::Path::New();
+ SetupPath(path);
+
+ //Create a PathConstrainer
+ Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
+ SetupPathConstrainer( pathConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
+
+ //Create an animation to animate the custom property
+ float durationSeconds(1.0f);
+ Dali::Animation animation = Dali::Animation::New(durationSeconds);
+ animation.AnimateTo(Dali::Property(actor,index),1.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+
+ Vector3 position, tangent;
+ path.Sample(0.2f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+ path.Sample(0.4f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+ path.Sample(0.6f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+ path.Sample(0.8f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
+ path.Sample(1.0f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* beyond the animation duration*/);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcPathConstrainerApplyRange(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a Path
+ Dali::Path path = Dali::Path::New();
+ SetupPath(path);
+
+ //Create a PathConstrainer
+ Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
+ SetupPathConstrainer( pathConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 100.0f, 300.0f );
+ pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
+
+
+ //Create an animation to animate the custom property
+ float durationSeconds(1.0f);
+ Dali::Animation animation = Dali::Animation::New(durationSeconds);
+ animation.AnimateTo(Dali::Property(actor,index),400.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+
+ Vector3 position, tangent;
+ float tValue;
+ actor.GetProperty(index).Get(tValue);
+ float currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ actor.GetProperty(index).Get(tValue);
+ currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ path.Sample(0.5, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ actor.GetProperty(index).Get(tValue);
+ currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
+ actor.GetProperty(index).Get(tValue);
+ currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
+ actor.GetProperty(index).Get(tValue);
+ currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcPathConstrainerDestroy(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ {
+ //Create a Path
+ Dali::Path path = Dali::Path::New();
+ SetupPath(path);
+
+ //Create a PathConstrainer
+ Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
+ SetupPathConstrainer( pathConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
+
+ //Test that the constraint is correctly applied
+ actor.SetProperty(index,0.5f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ Vector3 position, tangent;
+ path.Sample(0.5f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ }
+
+ //PathConstrainer has been destroyed. Constraint in the actor should have been removed
+ actor.SetProperty(index,0.75f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcPathConstrainerRemove(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a Path
+ Dali::Path path = Dali::Path::New();
+ SetupPath(path);
+
+ //Create a PathConstrainer
+ Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
+ SetupPathConstrainer( pathConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
+
+ //Test that the constraint is correctly applied
+ actor.SetProperty(index,0.5f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ Vector3 position, tangent;
+ path.Sample(0.5f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ //Remove constraint
+ pathConstrainer.Remove( actor );
+ actor.SetProperty(index,0.75f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+
+ END_TEST;
+}
+
+//LinearConstrainer test cases
+int UtcLinearConstrainerDownCast(void)
+{
+ TestApplication application;
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+
+ BaseHandle handle( linearConstrainer );
+ Dali::LinearConstrainer linearConstrainer2 = Dali::LinearConstrainer::DownCast( handle );
+ DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
+
+ BaseHandle handle2;
+ Dali:: LinearConstrainer linearConstrainer3 = Dali::LinearConstrainer::DownCast( handle2 );
+ DALI_TEST_EQUALS( (bool)linearConstrainer3, false, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcLinearConstrainerCopyConstructor(void)
+{
+ TestApplication application;
+ Dali::LinearConstrainer linearConstrainer;
+ DALI_TEST_EQUALS( (bool)linearConstrainer, false, TEST_LOCATION );
+
+ linearConstrainer = Dali::LinearConstrainer::New();
+ DALI_TEST_EQUALS( (bool)linearConstrainer, true, TEST_LOCATION );
+
+ // call the copy constructor
+ Dali::LinearConstrainer linearConstrainer2( linearConstrainer );
+ DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcLinearConstrainerApply(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+
+ Dali::Stage::GetCurrent().Add(actor);
+
+
+ //Create a LinearConstrainer without specifying progress for values
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+ SetupLinearConstrainerUniformProgress( linearConstrainer );
+
+ //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+ //Create an animation to animate the custom property
+ float durationSeconds(1.0f);
+ Dali::Animation animation = Dali::Animation::New(durationSeconds);
+ animation.AnimateTo(Dali::Property(actor,index),1.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ //Setup a LinearConstrainer specifying the progress for each value
+ linearConstrainer.Remove(actor);
+ SetupLinearConstrainerNonUniformProgress( linearConstrainer );
+ linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+ actor.SetProperty(index,0.0f);
+ animation.Play();
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 2.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcLinearConstrainerApplyRange(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 100.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a LinearConstrainer
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+ SetupLinearConstrainerUniformProgress( linearConstrainer );
+
+ //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 100.0f, 300.0f );
+ linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+
+ //Create an animation to animate the custom property
+ float durationSeconds(1.0f);
+ Dali::Animation animation = Dali::Animation::New(durationSeconds);
+ animation.AnimateTo(Dali::Property(actor,index),300.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcLinearConstrainerDestroy(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ {
+ //Create a LinearConstrainer
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+ SetupLinearConstrainerUniformProgress( linearConstrainer );
+
+ //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+ //Test that the constraint is correctly applied
+ actor.SetProperty(index,0.5f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+ }
+
+ //LinearConstrainer has been destroyed. Constraint in the actor should have been removed
+ actor.SetProperty(index,0.75f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcLinearConstrainerRemove(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a LinearConstrainer
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+ SetupLinearConstrainerUniformProgress( linearConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+ //Test that the constraint is correctly applied
+ actor.SetProperty(index,0.5f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+ //Remove constraint
+ linearConstrainer.Remove( actor );
+ actor.SetProperty(index,0.75f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali/devel-api/actors/mesh-actor.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+#include "mesh-builder.h"
+
+
+namespace
+{
+// Size of the VertexAttributeArray enables
+// GLES specification states that there's minimum of
+const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8;
+
+enum TestAttribType
+{
+ ATTRIB_UNKNOWN = -1,
+ ATTRIB_POSITION,
+ ATTRIB_NORMAL,
+ ATTRIB_TEXCOORD,
+ ATTRIB_COLOR,
+ ATTRIB_BONE_WEIGHTS,
+ ATTRIB_BONE_INDICES,
+ ATTRIB_TYPE_LAST
+};
+
+// Create bitmap image
+static BufferImage CreateBufferImage()
+{
+ BufferImage image = BufferImage::New(4,4,Pixel::RGBA8888);
+
+ return image;
+}
+
+static MeshActor CreateMeshActor()
+{
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ meshData.SetHasNormals(true);
+ meshData.SetHasTextureCoords(true);
+
+ Mesh mesh = Mesh::New(meshData);
+ MeshActor actor = MeshActor::New(mesh);
+
+ actor.SetName("Test MeshActor");
+
+ return actor;
+}
+
+
+static ImageActor CreateImageActor()
+{
+ BufferImage image = CreateBufferImage();
+ ImageActor actor = ImageActor::New( image );
+ actor.SetSize( 100.0f, 100.0f );
+ actor.SetName("Test ImageActor");
+ return actor;
+}
+
+} // anonymous namespace
+
+
+// Positive test case for a method
+int UtcDaliContextVertexAttribStartup(void)
+{
+ tet_infoline("Testing vertex attrib initial state in context");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // context class should initially set the vertex attrib locations to disable
+ // Make sure it has been modified
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
+
+ // check the locations
+ for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
+ {
+ DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(i) == false);
+ }
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+// Tests to make the attribs only get set once when continually rendering an image actor
+int UtcDaliContextVertexAttribImageRendering(void)
+{
+ tet_infoline("Testing vertex attrib rendering state in context with images");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // the vertex attribs get modified on startup to set them to disabled
+ // clear the flag to say they've changed
+ application.GetGlAbstraction().ClearVertexAttribArrayChanged();
+
+
+ // create a test image actor
+ ImageActor imageActor(CreateImageActor());
+ Stage::GetCurrent().Add(imageActor);
+
+
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // check to make sure the state has changed (the image renderer will enable some
+ // locations).
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
+
+ // Now check to make sure the state is cached, and isn't being set each frame.
+ application.GetGlAbstraction().ClearVertexAttribArrayChanged();
+
+ application.Render();
+ application.Render();
+ application.Render();
+
+ // if it has changed then the caching has failed
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false);
+
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+// test to make sure the attribs change when rendering both image and mode actors
+int UtcDaliContextVertexAttribImageAndModelRendering(void)
+{
+ tet_infoline("Testing vertex attrib rendering state in context with images and models");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // the vertex attribs get modified on startup to set them to disabled
+ // clear the flag to say they've changed
+ application.GetGlAbstraction().ClearVertexAttribArrayChanged();
+
+ // create a test image and mesh actor.
+
+ MeshActor meshActor(CreateMeshActor());
+ Stage::GetCurrent().Add(meshActor);
+
+ ImageActor imageActor(CreateImageActor());
+ Stage::GetCurrent().Add(imageActor);
+
+
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // check to make sure the state changes during the rendering of a frame
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
+
+ // Now check to make sure the state is changing each frame.
+ application.GetGlAbstraction().ClearVertexAttribArrayChanged();
+
+ application.Render();
+ application.Render();
+ application.Render();
+
+ // make sure the state has changed
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
+
+ // depending on the order of drawing, one of the attrib locations should be disabled
+ // Image uses locations 0 & 2 (position, texture)
+ // Model uses locations 0 & 1 (position, normals) -no textures
+ // so either location 1 or location 2 should be disabled after drawing.
+
+ // see if mesh was last to draw
+ if (application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_NORMAL))
+ {
+ // texture should be disabled
+ DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_TEXCOORD) == false)
+ }
+ else
+ {
+ // image was to draw so, normals should be disabled
+ DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_NORMAL) == false)
+ }
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 <algorithm>
+
+#include <stdlib.h>
+
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/images/distance-field.h>
+#include <dali-test-suite-utils.h>
+
+using std::max;
+using namespace Dali;
+
+namespace
+{
+
+static const float ROTATION_EPSILON = 0.0001f;
+
+static unsigned char sourceImage[] =
+{
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+};
+
+} // anonymous namespace
+
+
+
+int UtcDaliGenerateDistanceField(void)
+{
+ unsigned char distanceField[4*4];
+
+ GenerateDistanceFieldMap(sourceImage, Size(8.0f, 8.0f), distanceField, Size(4.0f, 4.0f), 0, Size(4.0f, 4.0f));
+
+ if(distanceField[0] <= distanceField[5] &&
+ distanceField[5] <= distanceField[10] &&
+ distanceField[10] <= distanceField[15])
+ {
+ tet_result(TET_PASS);
+ }
+ else
+ {
+ tet_result(TET_FAIL);
+ }
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <dali/devel-api/dynamics/dynamics.h>
+
+int UtcDaliDynamicsBodyConstructor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConstructor - DynamicsBody::DynamicsBody()");
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // Default constructor - create an uninitialized handle
+ DynamicsBody body;
+ DALI_TEST_CHECK( !body );
+
+ // create world and actor
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ // initialize handle
+ body = actor.GetDynamicsBody();
+
+ DALI_TEST_CHECK( body );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyGetMass(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testMass = 1.23f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ bodyConfig.SetMass(testMass);
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ tet_infoline("UtcDaliDynamicsBodyGetMass - DynamicsBody::GetMass");
+ DALI_TEST_EQUALS( testMass, actor.GetDynamicsBody().GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyGetElasticity(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testElasticity = 1.23f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ bodyConfig.SetElasticity(testElasticity);
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ tet_infoline("UtcDaliDynamicsBodyGetMass - DynamicsBody::GetElasticity");
+ DALI_TEST_EQUALS( testElasticity, actor.GetDynamicsBody().GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodySetLinearVelocity(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodySetLinearVelocity - DynamicsBody::SetLinearVelocity");
+
+ TestApplication application;
+ TraceCallStack& trace( application.GetPlatform().GetTrace() );
+ trace.Enable( true );
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+ body.SetLinearVelocity(Vector3::ONE);
+
+ DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetLinearVelocity" ) );
+
+ // update
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetLinearVelocity" ) );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodySetAngularVelocity(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodySetAngularVelocity - DynamicsBody::SetAngularVelocity");
+
+ TestApplication application;
+ TraceCallStack& trace( application.GetPlatform().GetTrace() );
+ trace.Enable( true );
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+ body.SetAngularVelocity(Vector3::ONE);
+
+ DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetAngularVelocity" ) );
+
+ // update
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetAngularVelocity" ) );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodySetKinematic(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testMass = 1.0f;
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ bodyConfig.SetMass(testMass);
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+
+ DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::SetKinematic(true)");
+ body.SetKinematic(true);
+
+ DALI_TEST_CHECK( body.IsKinematic() );
+ DALI_TEST_EQUALS( 0.0f, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::SetKinematic(false)");
+ body.SetKinematic(false);
+ DALI_TEST_CHECK( !body.IsKinematic() );
+ DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyIsKinematic(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testMass = 1.0f;
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ bodyConfig.SetMass(testMass);
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+
+ DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::IsSetKinematic");
+ body.SetKinematic(true);
+
+ DALI_TEST_CHECK( body.IsKinematic() );
+ body.SetKinematic(false);
+ DALI_TEST_CHECK( !body.IsKinematic() );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodySetSleepEnabled(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodySetSleepEnabled");
+
+ TestApplication application;
+ TraceCallStack& trace( application.GetPlatform().GetTrace() );
+ trace.Enable( true );
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+
+ // SleepEnabled true by default
+ DALI_TEST_CHECK( body.GetSleepEnabled() );
+ body.SetSleepEnabled(false);
+
+ DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetSleepEnabled" ) );
+
+ // update
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetSleepEnabled" ) );
+
+ DALI_TEST_CHECK( ! body.GetSleepEnabled() );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyGetSleepEnabled(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyGetSleepEnabled");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+
+ // SleepEnabled true by default
+ DALI_TEST_CHECK( body.GetSleepEnabled() );
+ body.SetSleepEnabled(false);
+ DALI_TEST_CHECK( !body.GetSleepEnabled() );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyWakeUp(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyWakeUp");
+
+ TestApplication application;
+ TraceCallStack& trace( application.GetPlatform().GetTrace() );
+ trace.Enable( true );
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+
+ body.WakeUp();
+
+ DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::WakeUp" ) );
+
+ // update
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::WakeUp" ) );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyAddAnchor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyAddAnchor - DynamicsBody::AddAnchor()");
+
+ TestApplication application;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ worldConfig.SetType(DynamicsWorldConfig::SOFT);
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ Actor rootActor(Actor::New());
+ world.SetRootActor(rootActor);
+ Stage::GetCurrent().Add(rootActor);
+
+ DynamicsBodyConfig softConfig( DynamicsBodyConfig::New() );
+ softConfig.SetType(DynamicsBodyConfig::SOFT);
+ Cloth mesh(Cloth::New(10.0f, 10.0f, 10, 10));
+ DynamicsShape meshShape(DynamicsShape::NewMesh(mesh));
+ softConfig.SetShape( meshShape );
+ softConfig.SetMass(1.0f);
+ MeshActor softActor(MeshActor::New(mesh));
+
+ rootActor.Add(softActor);
+ softActor.EnableDynamics(softConfig);
+ DynamicsBody softBody(softActor.GetDynamicsBody());
+
+ DynamicsBodyConfig anchorConfig(DynamicsBodyConfig::New());
+ anchorConfig.SetMass(0.0f);
+ Actor anchor(Actor::New());
+ rootActor.Add(anchor);
+ anchor.EnableDynamics(anchorConfig);
+ DynamicsBody anchorBody(anchor.GetDynamicsBody());
+ anchorBody.SetKinematic(true);
+ try
+ {
+ softBody.AddAnchor(0, anchorBody, false);
+
+ DALI_TEST_CHECK(true)
+ }
+ catch(Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_CHECK( false );
+ }
+
+ rootActor.Remove(softActor);
+ rootActor.Remove(anchor);
+ Stage::GetCurrent().Remove(rootActor);
+ softActor.DisableDynamics();
+ anchor.DisableDynamics();
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConserveVolume(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConserveVolume");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+
+ body.ConserveVolume(false);
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConserveShape(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConserveShape");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor(Actor::New());
+
+ // enable dynamics on the actor to create the Dynamicsbody
+ actor.EnableDynamics(bodyConfig);
+
+ DynamicsBody body(actor.GetDynamicsBody());
+
+ body.ConserveShape(false);
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <dali/devel-api/dynamics/dynamics.h>
+
+using namespace Dali;
+
+
+int UtcDaliDynamicsBodyConfigNew(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+
+ tet_infoline("UtcDaliDynamicsBodyConfigNew - DynamicsBodyConfig::New()");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+
+ DALI_TEST_CHECK( config );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigConstructor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConfigConstructor - DynamicsBodyConfig::DynamicsBodyConfig()");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // Default constructor - create an uninitialized handle
+ DynamicsBodyConfig config;
+
+ DALI_TEST_CHECK( !config );
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ // initialize handle
+ config = DynamicsBodyConfig::New();
+
+ DALI_TEST_CHECK( config );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigType(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+
+ tet_infoline("UtcDaliDynamicsBodyConfigType - DynamicsBodyConfig::GetType");
+ DALI_TEST_CHECK( DynamicsBodyConfig::RIGID == config.GetType() );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigType - DynamicsBodyConfig::SetType(const BodyType)");
+ config.SetType( DynamicsBodyConfig::SOFT );
+ DALI_TEST_CHECK( DynamicsBodyConfig::SOFT == config.GetType() );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigSetShape01(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConfigSetShape01 - DynamicsBodyConfig::SetShape(const DynamicsShape::ShapeType,const Vector3&)");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+
+ DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
+
+ const float radius(1.5f);
+ config.SetShape(DynamicsShape::SPHERE, Vector3(radius, 0.0f, 0.0f));
+
+ DALI_TEST_CHECK( DynamicsShape::SPHERE == config.GetShape().GetType() );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigSetShape02(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConfigSetShape02 - DynamicsBodyConfig::SetShape(DynamicsShape)");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+
+ DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
+
+ const float radius(1.5f);
+ DynamicsShape shape(DynamicsShape::NewSphere(radius));
+ config.SetShape(shape);
+
+ DALI_TEST_CHECK( DynamicsShape::SPHERE == config.GetShape().GetType() );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigGetShape(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConfigGetShape - DynamicsBodyConfig::GetShape");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+
+ DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigMass(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testMass = 1.23f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetMass(testMass);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigMass - DynamicsBodyConfig::GetMass");
+ DALI_TEST_EQUALS( testMass, config.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigMass - DynamicsBodyConfig::SetMass");
+ const float mass = config.GetMass() + 0.1f;
+ config.SetMass(mass);
+ DALI_TEST_EQUALS( mass, config.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigElasticity(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testElasticity = 0.87f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetElasticity(testElasticity);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigElasticity- DynamicsBodyConfig::GetElasticity");
+ DALI_TEST_EQUALS( testElasticity, config.GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigElasticity - DynamicsBodyConfig::SetElasticity");
+ const float elasticity = config.GetElasticity() + 0.1f;
+ config.SetElasticity(elasticity);
+ DALI_TEST_EQUALS( elasticity, config.GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigFriction(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testFriction= 0.87f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetFriction(testFriction);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigFriction - DynamicsBodyConfig::GetFriction");
+ DALI_TEST_EQUALS( testFriction, config.GetFriction(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigFriction - DynamicsBodyConfig::SetFriction");
+ const float friction = config.GetFriction() + 0.1f;
+ config.SetFriction(friction);
+ DALI_TEST_EQUALS( friction, config.GetFriction(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigLinearDamping(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testDamping = 0.123f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetLinearDamping(testDamping);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigLinearDamping- DynamicsBodyConfig::GetLinearDamping");
+ DALI_TEST_EQUALS( testDamping, config.GetLinearDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigLinearDamping - DynamicsBodyConfig::SetLinearDamping");
+ const float damping = config.GetLinearDamping() + 0.1f;
+ config.SetLinearDamping(damping);
+ DALI_TEST_EQUALS( damping, config.GetLinearDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigAngularDamping(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testDamping = 0.123f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetAngularDamping(testDamping);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigAngularDamping- DynamicsBodyConfig::GetAngularDamping");
+ DALI_TEST_EQUALS( testDamping, config.GetAngularDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigAngularDamping - DynamicsBodyConfig::SetAngularDamping");
+ const float damping = config.GetAngularDamping() + 0.1f;
+ config.SetAngularDamping(damping);
+ DALI_TEST_EQUALS( damping, config.GetAngularDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigLinearSleepVelocity(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testSleepVelocity = 0.123f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetLinearSleepVelocity(testSleepVelocity);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigLinearSleepVelocity - DynamicsBodyConfig::GetLinearSleepVelocity");
+ DALI_TEST_EQUALS( testSleepVelocity, config.GetLinearSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigLinearSleepVelocity - DynamicsBodyConfig::SetLinearSleepVelocity");
+ const float sleepVelocity = config.GetLinearSleepVelocity() + 0.1f;
+ config.SetLinearSleepVelocity(sleepVelocity);
+ DALI_TEST_EQUALS( sleepVelocity, config.GetLinearSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigAngularSleepVelocity(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testSleepVelocity = 0.123f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetAngularSleepVelocity(testSleepVelocity);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigAngularSleepVelocity - DynamicsBodyConfig::GetAngularSleepVelocity");
+ DALI_TEST_EQUALS( testSleepVelocity, config.GetAngularSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigAngularSleepVelocity - DynamicsBodyConfig::SetAngularSleepVelocity");
+ const float sleepVelocity = config.GetAngularSleepVelocity() + 0.1f;
+ config.SetAngularSleepVelocity(sleepVelocity);
+ DALI_TEST_EQUALS( sleepVelocity, config.GetAngularSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigCollisionGroup(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const short int testGroup = 0x1234;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetCollisionGroup(testGroup);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup- DynamicsBodyConfig::GetCollisionGroup");
+ DALI_TEST_EQUALS( testGroup, config.GetCollisionGroup(), TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup - DynamicsBodyConfig::SetCollisionGroup");
+ const short int group = config.GetCollisionGroup() + 1;
+ config.SetCollisionGroup(group);
+ DALI_TEST_EQUALS( group, config.GetCollisionGroup(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigCollisionMask(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const short int testMask = 0x7ffe;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetCollisionMask(testMask);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask- DynamicsBodyConfig::GetCollisionMask");
+ DALI_TEST_EQUALS( testMask, config.GetCollisionMask(), TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask - DynamicsBodyConfig::SetCollisionMask");
+ const short int mask = config.GetCollisionMask() + 1;
+ config.SetCollisionMask(mask);
+ DALI_TEST_EQUALS( mask, config.GetCollisionMask(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigAnchorHardness(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const float testHardness = 0.87f;
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+ config.SetAnchorHardness(testHardness);
+
+ tet_infoline("UtcDaliDynamicsBodyConfigAnchorHardness - DynamicsBodyConfig::GetAnchorHardness");
+ DALI_TEST_EQUALS( testHardness, config.GetAnchorHardness(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+ tet_infoline("UtcDaliDynamicsBodyConfigAnchorHardness - DynamicsBodyConfig::SetAnchorHardness");
+ const float hardness = config.GetAnchorHardness() + 0.1f;
+ config.SetAnchorHardness(hardness);
+ DALI_TEST_EQUALS( hardness, config.GetAnchorHardness(), Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigVolumeConservation(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConfigVolumeConservation");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+
+ const float conservation = config.GetVolumeConservation() + 0.1f;
+ config.SetVolumeConservation(conservation);
+ DALI_TEST_EQUALS( conservation, config.GetVolumeConservation(), Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliDynamicsBodyConfigShapeConservation(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsBodyConfigShapeConservation");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig config(DynamicsBodyConfig::New());
+
+ const float conservation = config.GetShapeConservation() + 0.1f;
+ config.SetShapeConservation(conservation);
+ DALI_TEST_EQUALS( conservation, config.GetShapeConservation(), Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <dali/devel-api/dynamics/dynamics.h>
+
+using namespace Dali;
+
+
+int UtcDaliDynamicsJointConstructor(void)
+{
+ tet_infoline("UtcDaliDynamicsJointConstructor - DynamicsJoint::DynamicsJoint");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsJoint joint;
+
+ DALI_TEST_CHECK( !joint );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointLinearLimit(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ if( joint )
+ {
+ tet_infoline("UtcDaliDynamicsJointLinearLimit - DynamicsJoint::SetLinearLimit()");
+ joint.SetLinearLimit(DynamicsJoint::LINEAR_X, 0.0f, 1.0f);
+ }
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointAngularLimit(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ tet_infoline("UtcDaliDynamicsJointAngularLimit - DynamicsJoint::SetAngularLimit()");
+ joint.SetAngularLimit(DynamicsJoint::ANGULAR_X, Degree(0.0f), Degree(1.0f) );
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointEnableSpring(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ tet_infoline("UtcDaliDynamicsJointEnableSpring");
+ joint.EnableSpring(DynamicsJoint::LINEAR_X, true );
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointSetSpringStiffness(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ tet_infoline("UtcDaliDynamicsJointSetSpringStiffness");
+ joint.SetSpringStiffness(DynamicsJoint::LINEAR_X, 1.0f );
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointSetSpringCenterPoint(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ tet_infoline("UtcDaliDynamicsJointSetSpringCenterPoint");
+ joint.SetSpringCenterPoint(DynamicsJoint::LINEAR_X, 0.5f );
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointEnableMotor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ tet_infoline("UtcDaliDynamicsJointEnableMotor");
+ joint.EnableMotor(DynamicsJoint::LINEAR_X, true );
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointSetMotorVelocity(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ tet_infoline("UtcDaliDynamicsJointSetMotorVelocity");
+ joint.SetMotorVelocity(DynamicsJoint::LINEAR_X, 1.0f );
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointSetMotorForce(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ tet_infoline("UtcDaliDynamicsJointSetMotorForce");
+ joint.SetMotorForce(DynamicsJoint::LINEAR_X, 0.5f );
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliDynamicsJointGetActor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
+ Actor actor1(Actor::New());
+ actor1.EnableDynamics(bodyConfig);
+ Actor actor2(Actor::New());
+ actor2.EnableDynamics(bodyConfig);
+
+ DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
+
+ tet_infoline("UtcDaliDynamicsJointGetActor");
+ DALI_TEST_CHECK( joint.GetActor(true) == actor1 && joint.GetActor(false) == actor2 );
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <dali/devel-api/dynamics/dynamics.h>
+
+using namespace Dali;
+
+
+int UtcDaliDynamicsShapeConstructor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsShapeConstructor - DynamicsShape::DynamicsShape");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( world )
+ {
+
+ // Default constructor - create an uninitialized handle
+ DynamicsShape shape;
+ DALI_TEST_CHECK( !shape );
+
+ // initialize handle
+ shape = DynamicsShape::NewCube(Vector3::ONE);
+
+ DALI_TEST_CHECK( shape );
+ }
+ else
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliDynamicsShapeNewCapsule(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsShapeNewCapsule - DynamicsShape::NewCapsule");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( world )
+ {
+
+ DynamicsShape shape( DynamicsShape::NewCapsule( 1.0f, 2.0f ) );
+
+ DALI_TEST_CHECK( shape );
+ DALI_TEST_CHECK( DynamicsShape::CAPSULE == shape.GetType() );
+ }
+ else
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliDynamicsShapeNewCone(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsShapeNewCone - DynamicsShape::NewCone");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( world )
+ {
+ DynamicsShape shape( DynamicsShape::NewCone( 1.0f, 2.0f ) );
+
+ DALI_TEST_CHECK( shape );
+ DALI_TEST_CHECK( DynamicsShape::CONE == shape.GetType() );
+ }
+ else
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliDynamicsShapeNewCube(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsShapeNewCube - DynamicsShape::NewCube");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( world )
+ {
+ DynamicsShape shape( DynamicsShape::NewCube( Vector3::ONE ) );
+
+ DALI_TEST_CHECK( shape );
+ DALI_TEST_CHECK( DynamicsShape::CUBE == shape.GetType() );
+ }
+ else
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ }
+ END_TEST;
+}
+
+int UtcDaliDynamicsShapeNewCylinder(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsShapeNewCylinder - DynamicsShape::NewCylinder");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( world )
+ {
+ DynamicsShape shape( DynamicsShape::NewCylinder( 1.0f, 2.0f ) );
+
+ DALI_TEST_CHECK( shape );
+ DALI_TEST_CHECK( DynamicsShape::CYLINDER == shape.GetType() );
+ }
+ else
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ }
+ END_TEST;
+}
+
+int UtcDaliDynamicsShapeNewMesh(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsShapeNewMesh - DynamicsShape::NewMesh");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( world )
+ {
+ DynamicsShape shape( DynamicsShape::NewMesh( Cloth::New(10.0f, 10.0f, 10, 10)) );
+
+ DALI_TEST_CHECK( shape );
+ DALI_TEST_CHECK( DynamicsShape::MESH == shape.GetType() );
+ }
+ else
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ }
+ END_TEST;
+}
+
+int UtcDaliDynamicsShapeNewSphere(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsShapeNewSphere - DynamicsShape::NewSphere");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( world )
+ {
+ DynamicsShape shape( DynamicsShape::NewSphere( 1.0f ) );
+
+ DALI_TEST_CHECK( shape );
+ DALI_TEST_CHECK( DynamicsShape::SPHERE == shape.GetType() );
+ }
+ else
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ }
+ END_TEST;
+}
+
+int UtcDaliDynamicsShapeGetType(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsShapeGetType - DynamicsShape::GetType");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( world )
+ {
+ DynamicsShape shape( DynamicsShape::NewSphere( 1.0f ) );
+
+ DALI_TEST_CHECK( shape );
+ DALI_TEST_CHECK( DynamicsShape::SPHERE == shape.GetType() );
+ }
+ else
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ }
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <test-dynamics.h>
+#include <dali/devel-api/dynamics/dynamics.h>
+
+using namespace Dali;
+
+int UtcDaliStageInitializeDynamics(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ Stage stage = Stage::GetCurrent();
+ TraceCallStack& trace = application.GetPlatform().GetTrace();
+ trace.Enable(true);
+ DALI_TEST_CHECK( stage.InitializeDynamics( DynamicsWorldConfig::New() ) );
+ DALI_TEST_CHECK( trace.FindMethod( "GetDynamicsFactory" ) );
+ DALI_TEST_CHECK( trace.FindMethod( "DynamicsFactory::InitializeDynamics" ) );
+ END_TEST;
+}
+
+int UtcDaliStageGetDynamicsWorld(void)
+{
+ TestApplication application;
+
+ Stage stage = Stage::GetCurrent();
+
+ DALI_TEST_CHECK( !stage.GetDynamicsWorld() );
+ END_TEST;
+}
+
+int UtcDaliStageTerminateDynamics(void)
+{
+ TestApplication application;
+
+ Stage stage = Stage::GetCurrent();
+
+ stage.TerminateDynamics();
+
+ DALI_TEST_CHECK( !stage.GetDynamicsWorld() );
+ END_TEST;
+}
+
+int UtcDaliDynamicsWorldConstructor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsWorldConstructor - DynamicsWorld::DynamicsWorld");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // Default constructor - create an uninitialized handle
+ DynamicsWorld world;
+ DALI_TEST_CHECK( !world );
+
+ // initialize handle
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ world = Stage::GetCurrent().InitializeDynamics(worldConfig);
+
+ DALI_TEST_CHECK( world );
+ END_TEST;
+}
+
+int UtcDaliDynamicsWorldGravity(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+ TraceCallStack& trace( application.GetPlatform().GetTrace() );
+ trace.Enable( true );
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const Vector3 gravity(1.0f, 2.0f, 3.0f);
+
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ tet_infoline("UtcDaliDynamicsWorldGravity - DynamicsWorld::SetGravity");
+ world.SetGravity(gravity);
+
+ // update
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DALI_TEST_CHECK( trace.FindMethod( "DynamicsWorld::SetGravity" ) );
+
+ tet_infoline("UtcDaliDynamicsWorldGravity - DynamicsWorld::GetGravity");
+ DALI_TEST_EQUALS(gravity, world.GetGravity(), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliDynamicsWorldDebugDrawMode(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+ TraceCallStack& trace( application.GetPlatform().GetTrace() );
+ trace.Enable( true );
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const Vector3 gravity(1.0f, 2.0f, 3.0f);
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ const int mode(DynamicsWorld::DEBUG_MODE_WIREFRAME | DynamicsWorld::DEBUG_MODE_AABB);
+
+ tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::SetDebugDrawMode");
+ world.SetDebugDrawMode(mode);
+
+ // update
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ DALI_TEST_CHECK( trace.FindMethod( "DynamicsWorld::SetDebugDrawMode" ) );
+
+ tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::GetDebugDrawMode");
+ DALI_TEST_CHECK(mode == world.GetDebugDrawMode());
+ END_TEST;
+}
+
+int UtcDaliDynamicsWorldRootActor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ const Vector3 gravity(1.0f, 2.0f, 3.0f);
+ DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
+ DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+
+ if( !world )
+ {
+ // cannot create dynamics world, log failure and exit
+ DALI_TEST_CHECK( false );
+ END_TEST;
+ }
+
+ Actor rootActor(Actor::New());
+
+ tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::GetRootActor");
+ Actor actor(world.GetRootActor());
+ DALI_TEST_CHECK( !actor );
+
+ tet_infoline("UtcDaliDynamicsWorldSetRootActor - DynamicsWorld::SetRootActor");
+ world.SetRootActor(rootActor);
+ DALI_TEST_CHECK(rootActor == world.GetRootActor());
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <dali/devel-api/dynamics/dynamics.h>
+
+using namespace Dali;
+
+
+int UtcDaliDynamicsWorldConfigConstructor(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsWorldConfigConstructor - DynamicsWorldConfig::DynamicsWorldConfig");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // Default constructor - create an uninitialized handle
+ DynamicsWorldConfig worldConfig;
+ DALI_TEST_CHECK( !worldConfig );
+
+ // initialize handle
+ worldConfig = DynamicsWorldConfig::New();
+
+ DALI_TEST_CHECK( worldConfig );
+ END_TEST;
+}
+
+int UtcDaliDynamicsWorldConfigNew(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::New");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // Default constructor - create an uninitialized handle
+ DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+
+ DALI_TEST_CHECK( worldConfig );
+ END_TEST;
+}
+
+int UtcDaliDynamicsWorldConfigType(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+ tet_infoline("No dynamics support compiled\n");
+ return 0;
+#endif
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // Default constructor - create an uninitialized handle
+ DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+
+ tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::GetType");
+ DALI_TEST_CHECK(DynamicsWorldConfig::RIGID == worldConfig.GetType());
+
+ tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::SetType");
+ worldConfig.SetType(DynamicsWorldConfig::SOFT);
+ DALI_TEST_CHECK(DynamicsWorldConfig::SOFT == worldConfig.GetType());
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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 <string>
+#include <stdlib.h>
+#include <dali/devel-api/common/hash.h>
+#include <dali-test-suite-utils.h>
+
+void utc_dali_hash_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_hash_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+
+int UtcDaliHash(void)
+{
+ // To fully test the Hash distribution we need to use a tool like http://code.google.com/p/smhasher/
+ // DALi currently uses the hash for variable length strings which come from:
+ // shader vert+frag source, font family + style, image filename.
+ TestApplication application;
+
+ tet_infoline("UtcDaliHash");
+
+ const std::string testString1( "highp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
+ const std::string testString2( "lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
+
+ DALI_TEST_CHECK( Dali::CalculateHash( testString1 ) != Dali::CalculateHash( testString2 ) );
+ DALI_TEST_CHECK( Dali::CalculateHash( testString1, testString2 ) != Dali::CalculateHash( testString2, testString1 ) );
+
+ END_TEST;
+}
+
+int UtcDaliHashNegative(void)
+{
+ // negative test, check hash value == initial value
+ const std::string emptyString;
+
+ DALI_TEST_CHECK( Dali::CalculateHash( emptyString ) != 0 );
+ DALI_TEST_CHECK( Dali::CalculateHash( emptyString, emptyString ) != 0 );
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali/devel-api/events/hit-test-algorithm.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+namespace
+{
+
+/**
+ * The functor to be used in the hit-test algorithm to check whether the actor is hittable.
+ */
+bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
+{
+ bool hittable = false;
+
+ switch (type)
+ {
+ case Dali::HitTestAlgorithm::CHECK_ACTOR:
+ {
+ // Check whether the actor is visible and not fully transparent.
+ if( actor.IsVisible()
+ && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
+ {
+ // Check whether the actor has the specific name "HittableActor"
+ if(actor.GetName() == "HittableActor")
+ {
+ hittable = true;
+ }
+ }
+ break;
+ }
+ case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
+ {
+ if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
+ {
+ hittable = true;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return hittable;
+};
+
+
+bool DefaultIsActorTouchableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::TraverseType type)
+{
+ bool hittable = false;
+
+ switch (type)
+ {
+ case Dali::HitTestAlgorithm::CHECK_ACTOR:
+ {
+ if( actor.IsVisible() &&
+ actor.IsSensitive() &&
+ actor.GetCurrentWorldColor().a > 0.01f)
+ {
+ hittable = true;
+ }
+ break;
+ }
+ case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
+ {
+ if( actor.IsVisible() && // Actor is visible, if not visible then none of its children are visible.
+ actor.IsSensitive()) // Actor is sensitive, if insensitive none of its children should be hittable either.
+ {
+ hittable = true;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return hittable;
+};
+
+} // anonymous namespace
+
+
+// Positive test case for a method
+int UtcDaliHitTestAlgorithmWithFunctor(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm functor");
+
+ Stage stage = Stage::GetCurrent();
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor.SetName("NonHittableActor");
+ stage.Add(actor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector2 screenCoordinates( 10.0f, 10.0f );
+ Vector2 localCoordinates;
+ actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
+
+ // Perform a hit-test at the given screen coordinates
+ Dali::HitTestAlgorithm::Results results;
+ Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor != actor );
+
+ actor.SetName("HittableActor");
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+
+ // Perform a hit-test at the given screen coordinates
+ Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor );
+ DALI_TEST_EQUALS( localCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliHitTestAlgorithmWithFunctorOnRenderTask(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm functor, specific to a given render task");
+
+ Stage stage = Stage::GetCurrent();
+ Size stageSize = stage.GetSize();
+ RenderTaskList taskList = stage.GetRenderTaskList();
+
+ Actor actor[2];
+
+ for( int i=0; i<2; i++ )
+ {
+ actor[i] = Actor::New();
+ actor[i].SetSize(100.f, 100.f);
+ actor[i].SetParentOrigin(ParentOrigin::TOP_LEFT);
+ actor[i].SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor[i].SetName("HittableActor");
+ stage.Add(actor[i]);
+ }
+ Vector2 position( 50.f, 40.f );
+ actor[1].SetPosition( position.x, position.y );
+
+ RenderTask renderTask[2];
+ renderTask[0] = taskList.GetTask( 0u );
+
+ FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width, stageSize.height, Pixel::A8, Image::NEVER);
+ renderTask[1] = taskList.CreateTask();
+ renderTask[1].SetSourceActor( actor[1] );
+ renderTask[1].SetExclusive( true );
+ renderTask[1].SetInputEnabled( true );
+ renderTask[1].SetTargetFrameBuffer( frameBufferImage );
+ renderTask[1].SetRefreshRate( RenderTask::REFRESH_ONCE );
+ renderTask[1].SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ // Perform a hit-test at the given screen coordinates with different render tasks
+
+ Dali::HitTestAlgorithm::Results results;
+ Vector2 screenCoordinates( 25.f, 25.f );
+
+ Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[0] );
+ DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( !results.actor );
+ DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ screenCoordinates.x = 80.f;
+ screenCoordinates.y = 70.f;
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[0] );
+ DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[1]);
+ DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+
+ screenCoordinates.x = 120.f;
+ screenCoordinates.y = 130.f;
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[1] );
+ DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[1]);
+ DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
+ END_TEST;
+}
+
+
+int UtcDaliHitTestAlgorithmOrtho01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm with parallel Ortho camera()");
+
+ Stage stage = Stage::GetCurrent();
+ RenderTaskList renderTaskList = stage.GetRenderTaskList();
+ RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
+ Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
+
+ Vector2 stageSize ( stage.GetSize() );
+ cameraActor.SetOrthographicProjection( stageSize );
+ cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
+
+ Vector2 actorSize( stageSize * 0.5f );
+ // Create two actors with half the size of the stage and set them to be partially overlapping
+ Actor blue = Actor::New();
+ blue.SetName( "Blue" );
+ blue.SetAnchorPoint( AnchorPoint::CENTER );
+ blue.SetParentOrigin( Vector3(1.0f/3.0f, 1.0f/3.0f, 0.5f) );
+ blue.SetSize( actorSize );
+ blue.SetZ(30.0f);
+
+ Actor green = Actor::New( );
+ green.SetName( "Green" );
+ green.SetAnchorPoint( AnchorPoint::CENTER );
+ green.SetParentOrigin( Vector3(2.0f/3.0f, 2.0f/3.0f, 0.5f) );
+ green.SetSize( actorSize );
+
+ // Add the actors to the view
+ stage.Add( blue );
+ stage.Add( green );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(0);
+ application.Render(10);
+
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == blue );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 5.0f/6.0f, TEST_LOCATION );
+
+ HitTest(stage, stageSize / 3.0f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == blue );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
+
+ HitTest(stage, stageSize * 2.0f / 3.0f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == green );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
+ END_TEST;
+}
+
+
+int UtcDaliHitTestAlgorithmOrtho02(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm with offset Ortho camera()");
+
+ Stage stage = Stage::GetCurrent();
+ RenderTaskList renderTaskList = stage.GetRenderTaskList();
+ RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
+ Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
+
+ Vector2 stageSize ( stage.GetSize() );
+ cameraActor.SetOrthographicProjection(-stageSize.x * 0.3f, stageSize.x * 0.7f,
+ stageSize.y * 0.3f, -stageSize.y * 0.7f,
+ 800.0f, 4895.0f);
+ cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
+
+ Vector2 actorSize( stageSize * 0.5f );
+ // Create two actors with half the size of the stage and set them to be partially overlapping
+ Actor blue = Actor::New();
+ blue.SetName( "Blue" );
+ blue.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ blue.SetParentOrigin( Vector3(0.2f, 0.2f, 0.5f) );
+ blue.SetSize( actorSize );
+ blue.SetZ(30.0f);
+
+ Actor green = Actor::New( );
+ green.SetName( "Green" );
+ green.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ green.SetParentOrigin( Vector3(0.4f, 0.4f, 0.5f) );
+ green.SetSize( actorSize );
+
+ // Add the actors to the view
+ stage.Add( blue );
+ stage.Add( green );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(0);
+ application.Render(10);
+
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == green );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.6f, 0.01f, TEST_LOCATION );
+ }
+
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 0.001f, 0.001f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == blue );
+ DALI_TEST_EQUALS( results.actorCoordinates, Vector2( 0.001f, 0.001f ), 0.001f, TEST_LOCATION );
+ }
+
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, stageSize, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( ! results.actor );
+ DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION );
+ }
+
+ // Just inside green
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, stageSize*0.69f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == green );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.98f, 0.01f, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliHitTestAlgorithmStencil(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm with a stencil");
+
+ Stage stage = Stage::GetCurrent();
+ Actor rootLayer = stage.GetRootLayer();
+ rootLayer.SetName( "RootLayer" );
+
+ // Create a layer
+ Layer layer = Layer::New();
+ layer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ layer.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ layer.SetName( "layer" );
+ stage.Add( layer );
+
+ // Create a stencil and add that to the layer
+ Actor stencil = ImageActor::New(Dali::BufferImage::WHITE() );
+ stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ stencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ stencil.SetSize( 50.0f, 50.0f );
+ stencil.SetDrawMode( DrawMode::STENCIL );
+ stencil.SetName( "stencil" );
+ layer.Add( stencil );
+
+ // Create a renderable actor and add that to the layer
+ Actor layerHitActor = ImageActor::New();
+ layerHitActor.SetSize( 100.0f, 100.0f );
+ layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ layerHitActor.SetName( "layerHitActor" );
+ layer.Add( layerHitActor );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Hit within stencil and actor
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 10.0f, 10.0f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == layerHitActor );
+ tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
+ }
+
+ // Hit within actor but outside of stencil, should hit the root-layer
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 60.0f, 60.0f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == rootLayer );
+ tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
+ }
+ END_TEST;
+}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-
-#include <dali-test-suite-utils.h>
-#include <dali/internal/update/animation/scene-graph-constraint-base.h>
-
-using namespace Dali;
-
-using Dali::Internal::SceneGraph::ConstraintBase;
-
-int UtcDaliConstraintNewInput1OffStage(void)
-{
- /**
- * Test that the Constraint is correctly added/removed when an object
- * providing the input property is added/removed from the stage
- */
- TestApplication application;
-
- Actor parent = Actor::New();
- Stage::GetCurrent().Add( parent );
-
- Actor actor = Actor::New();
- parent.Add( actor );
-
- Actor sibling1 = Actor::New();
- sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) );
- parent.Add( sibling1 );
-
- Vector3 startValue( 0.0f, 0.0f, 0.0f );
- DALI_TEST_EQUALS( 0u, ConstraintBase::GetCurrentInstanceCount(), TEST_LOCATION );
- DALI_TEST_EQUALS( 0u, ConstraintBase::GetTotalInstanceCount(), TEST_LOCATION );
-
- /**
- * Test that the Constraint is correctly applied on a clean Node
- */
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
-
- // Apply constraint with a parent input property
-
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source( sibling1, Actor::Property::POSITION ),
- EqualToConstraint() );
-
- actor.ApplyConstraint( constraint );
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), startValue, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(1.0f, 2.0f, 3.0f)/*from sibling1*/, TEST_LOCATION );
- DALI_TEST_EQUALS( 1u, ConstraintBase::GetCurrentInstanceCount(), TEST_LOCATION );
- DALI_TEST_EQUALS( 1u, ConstraintBase::GetTotalInstanceCount(), TEST_LOCATION );
-
- // Remove sibling1 providing the input property
-
- parent.Remove( sibling1 );
- actor.SetPosition( Vector3(2.0f, 2.0f, 2.0f) ); // This should be effective
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(2.0f, 2.0f, 2.0f)/*from SetPosition*/, TEST_LOCATION );
- DALI_TEST_EQUALS( 0u/*should have been removed*/, ConstraintBase::GetCurrentInstanceCount(), TEST_LOCATION );
- DALI_TEST_EQUALS( 1u, ConstraintBase::GetTotalInstanceCount(), TEST_LOCATION );
-
- // Add sibling1 back again (re-enables constraint)
-
- parent.Add( sibling1 );
- actor.SetPosition( Vector3(3.0f, 3.0f, 3.0f) ); // This should NOT be effective
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(1.0f, 2.0f, 3.0f)/*from sibling1*/, TEST_LOCATION );
- DALI_TEST_EQUALS( 1u, ConstraintBase::GetCurrentInstanceCount(), TEST_LOCATION );
- DALI_TEST_EQUALS( 2u/*recreated once*/, ConstraintBase::GetTotalInstanceCount(), TEST_LOCATION );
-
- END_TEST;
-}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali/devel-api/actors/mesh-actor.h>
+#include <dali/devel-api/geometry/mesh.h>
+#include <dali/devel-api/geometry/animatable-mesh.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+
+void utc_dali_material_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_material_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+static AnimatableMesh CreateMeshData(Material material)
+{
+ AnimatableMesh::Faces faces;
+ for(int i=0; i<10-3; i++)
+ {
+ faces.push_back(i);
+ faces.push_back(i+1);
+ faces.push_back(i+2);
+ }
+ return AnimatableMesh::New(10, faces, material);
+}
+
+}// anonymous namespace
+
+
+// Positive test case for a method
+int UtcDaliMaterialNew01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing constructors, New and destructors");
+
+ Material material;
+ DALI_TEST_CHECK( ! material );
+
+ material = Material::New("material");
+ DALI_TEST_CHECK( material );
+
+ Material* material2 = new Material();
+ DALI_TEST_CHECK( ! *material2 );
+ delete material2;
+
+ Material material3 = material;
+ Material material4;
+ material4 = material;
+ Material material5 = material;
+ END_TEST;
+}
+
+
+int UtcDaliMaterialDownCast(void)
+{
+ TestApplication application;
+
+ Material material = Material::New("material");
+ BaseHandle handle(material);
+
+ Material mat2 = Material::DownCast( handle );
+ DALI_TEST_CHECK( mat2 );
+ END_TEST;
+}
+
+int UtcDaliMaterialSettersAndGetters(void)
+{
+ TestApplication application;
+ Material material = Material::New("material");
+ DALI_TEST_EQUALS( material.GetName(), "material", TEST_LOCATION );
+ material.SetName( "AnotherMaterial" );
+ DALI_TEST_EQUALS( material.GetName(), "AnotherMaterial", TEST_LOCATION );
+
+ DALI_TEST_EQUALS( material.GetOpacity(), Material::DEFAULT_OPACITY, 0.001, TEST_LOCATION);
+ material.SetOpacity(0.38f);
+ DALI_TEST_EQUALS( material.GetOpacity(), 0.38f, 0.001, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( material.GetShininess(), Material::DEFAULT_SHININESS, 0.001, TEST_LOCATION);
+ material.SetShininess(0.47f);
+ DALI_TEST_EQUALS( material.GetShininess(), 0.47f, 0.001, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( material.GetAmbientColor(), Material::DEFAULT_AMBIENT_COLOR, 0.001, TEST_LOCATION);
+ material.SetAmbientColor(Color::BLACK);
+ DALI_TEST_EQUALS( material.GetAmbientColor(), Color::BLACK, 0.001, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( material.GetDiffuseColor(), Material::DEFAULT_DIFFUSE_COLOR, 0.001, TEST_LOCATION);
+ material.SetDiffuseColor(Color::BLUE);
+ DALI_TEST_EQUALS( material.GetDiffuseColor(), Color::BLUE, 0.001, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( material.GetSpecularColor(), Material::DEFAULT_SPECULAR_COLOR, 0.001, TEST_LOCATION);
+ material.SetSpecularColor(Color::GREEN);
+ DALI_TEST_EQUALS( material.GetSpecularColor(), Color::GREEN, 0.001, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( material.GetEmissiveColor(), Material::DEFAULT_EMISSIVE_COLOR, 0.001, TEST_LOCATION);
+ material.SetEmissiveColor(Color::MAGENTA);
+ DALI_TEST_EQUALS( material.GetEmissiveColor(), Color::MAGENTA, 0.001, TEST_LOCATION);
+
+ material.SetDiffuseTextureFileName("diffuse-texture.png");
+ DALI_TEST_EQUALS( material.GetDiffuseFileName(), "diffuse-texture.png", TEST_LOCATION);
+
+ material.SetOpacityTextureFileName("opacity-texture.png");
+ DALI_TEST_EQUALS( material.GetOpacityTextureFileName(), "opacity-texture.png", TEST_LOCATION);
+
+ material.SetNormalMapFileName("normal-map.png");
+ DALI_TEST_EQUALS( material.GetNormalMapFileName(), "normal-map.png", TEST_LOCATION);
+
+ Image diffuseTexture = ResourceImage::New("diffuse-texture.png");
+ material.SetDiffuseTexture(diffuseTexture);
+ DALI_TEST_EQUALS( material.GetDiffuseTexture(), diffuseTexture, TEST_LOCATION );
+
+ Image opacityTexture = ResourceImage::New("opacity-texture.png");
+ material.SetOpacityTexture(opacityTexture);
+ DALI_TEST_EQUALS( material.GetOpacityTexture(), opacityTexture, TEST_LOCATION);
+
+ Image normalMap = ResourceImage::New("normal-map.png");
+ material.SetNormalMap(normalMap);
+ DALI_TEST_EQUALS( material.GetNormalMap(), normalMap, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( material.GetMapU(), (unsigned int)Material::DEFAULT_MAPPING_MODE, TEST_LOCATION );
+ DALI_TEST_EQUALS( material.GetMapV(), (unsigned int)Material::DEFAULT_MAPPING_MODE, TEST_LOCATION );
+ material.SetMapU( Material::MAPPING_MODE_WRAP );
+ material.SetMapV( Material::MAPPING_MODE_MIRROR );
+ DALI_TEST_EQUALS( material.GetMapU(), (unsigned int)Material::MAPPING_MODE_WRAP, TEST_LOCATION );
+ DALI_TEST_EQUALS( material.GetMapV(), (unsigned int)Material::MAPPING_MODE_MIRROR, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( material.GetDiffuseUVIndex(), Material::DEFAULT_DIFFUSE_UV_INDEX, TEST_LOCATION );
+ material.SetDiffuseUVIndex( 1u );
+ DALI_TEST_EQUALS( material.GetDiffuseUVIndex(), 1u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( material.GetOpacityUVIndex(), Material::DEFAULT_OPACITY_UV_INDEX, TEST_LOCATION );
+ material.SetOpacityUVIndex( 1u );
+ DALI_TEST_EQUALS( material.GetOpacityUVIndex(), 1u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( material.GetNormalUVIndex(), Material::DEFAULT_NORMAL_UV_INDEX, TEST_LOCATION );
+ material.SetNormalUVIndex( 1u );
+ DALI_TEST_EQUALS( material.GetNormalUVIndex(), 1u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( material.GetHasHeightMap(), Material::DEFAULT_HAS_HEIGHT_MAP, TEST_LOCATION );
+ material.SetHasHeightMap(true);
+ DALI_TEST_EQUALS( material.GetHasHeightMap(), true, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliMaterialStage01(void)
+{
+ TestApplication application;
+ TraceCallStack& textureTrace = application.GetGlAbstraction().GetTextureTrace();
+ textureTrace.Enable(true);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+
+ {
+ Material material = Material::New("material");
+ Image image = ResourceImage::New( "image.png", ResourceImage::IMMEDIATE, Image::NEVER );
+ DALI_TEST_CHECK(image);
+ application.SendNotification();
+ application.Render(16);
+
+ std::vector<GLuint> ids;
+ ids.push_back( 23 );
+ application.GetGlAbstraction().SetNextTextureIds( ids );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::ResourcePointer resource(bitmap);
+ bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
+ DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ DALI_TEST_CHECK( request != NULL );
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
+ }
+
+ material.SetDiffuseTexture(image);
+ application.SendNotification();
+ application.Render();
+
+ AnimatableMesh mesh = CreateMeshData(material);
+
+ application.SendNotification();
+ application.Render();
+ {
+ MeshActor meshActor = MeshActor::New(mesh);
+ meshActor.SetSize(100, 100);
+ Stage::GetCurrent().Add(meshActor);
+ application.SendNotification();
+ application.Render();
+
+ material.SetOpacity(0.5f);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove(meshActor);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( glAbstraction.CheckNoTexturesDeleted() );
+ DALI_TEST_CHECK( ! textureTrace.FindMethod( "DeleteTextures" ) );
+ }
+ application.SendNotification();
+ application.Render();
+
+ // Mesh should be destroyed, reducing connection count on material to zero.
+ // This should also reduce connection count on image to zero
+ DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION );
+ }
+ // SceneGraph::Material & SceneGraph::RenderMaterial should be destroyed
+ // Image should be destroyed
+ application.SendNotification();
+ application.Render();
+
+ application.Render();
+ DALI_TEST_CHECK( textureTrace.FindMethod( "DeleteTextures" ) );
+ DALI_TEST_CHECK( glAbstraction.CheckTextureDeleted( 23 ) );
+ END_TEST;
+}
+
+
+int UtcDaliMaterialStage01MemCheck(void)
+{
+ TestApplication application;
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliMaterialStage02(void)
+{
+ TestApplication application;
+ TraceCallStack& textureTrace = application.GetGlAbstraction().GetTextureTrace();
+ textureTrace.Enable(true);
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+
+ {
+ Material material = Material::New("material");
+
+ Image image = ResourceImage::New( "image.png", ResourceImage::ON_DEMAND, Image::UNUSED );
+ DALI_TEST_CHECK(image);
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+ DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL );
+
+ std::vector<GLuint> ids;
+ ids.push_back( 23 );
+ application.GetGlAbstraction().SetNextTextureIds( ids );
+
+ material.SetDiffuseTexture(image);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+ DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL );
+
+ AnimatableMesh mesh = CreateMeshData(material);
+
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+ DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL );
+
+ {
+ MeshActor meshActor = MeshActor::New(mesh);
+ meshActor.SetSize(100, 100);
+ Stage::GetCurrent().Add(meshActor);
+ application.SendNotification();
+ application.Render();
+
+ // Image connection count should go to one - image should get loaded
+ DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ DALI_TEST_CHECK( request != NULL );
+
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::ResourcePointer resource(bitmap);
+ bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
+ }
+ application.Render();
+
+ material.SetOpacity(0.5f);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove(meshActor);
+ application.SendNotification();
+ application.Render();
+
+ // This should reduce connection count on material to zero, freeing the texture:
+ DALI_TEST_CHECK( textureTrace.FindMethod( "DeleteTextures" ) );
+ DALI_TEST_CHECK( glAbstraction.CheckTextureDeleted( 23 ) );
+ }
+ application.SendNotification();
+ application.Render();
+
+ // Mesh should be destroyed, reducing connection count on material to zero.
+ // This should also reduce connection count on image to zero, freeing it
+ DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION );
+ }
+ application.SendNotification();
+ application.Render();
+
+ // SceneGraph::Material & SceneGraph::RenderMaterial should be destroyed
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali/devel-api/actors/mesh-actor.h>
+#include <dali/devel-api/geometry/mesh.h>
+#include <dali/devel-api/geometry/animatable-mesh.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+#include <mesh-builder.h>
+
+void mesh_actor_test_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void mesh_actor_test_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+static Mesh NewMesh()
+{
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ Mesh mesh = Mesh::New(meshData);
+ return mesh;
+}
+
+static AnimatableMesh NewAnimatableMesh()
+{
+ AnimatableMesh::Faces faces;
+ faces.push_back(0);
+ faces.push_back(1);
+ faces.push_back(2);
+
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetOpacity(.76f);
+ customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, 1.0f));
+ customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
+ customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
+
+ AnimatableMesh mesh = AnimatableMesh::New( 10u, faces, customMaterial );
+ return mesh;
+}
+} // anonymous namespace
+
+int UtcDaliMeshActorConstructorVoid(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::MeshActor()");
+
+ MeshActor actor;
+ DALI_TEST_CHECK(!actor);
+ END_TEST;
+}
+
+int UtcDaliMeshActorNew01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::New()");
+
+ AnimatableMesh mesh = NewAnimatableMesh();
+ MeshActor actor = MeshActor::New(mesh);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK(actor);
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorNew03(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::Mesh::New() - Create with no mesh");
+
+ try
+ {
+ MeshActor actor = MeshActor::New(); // Shouldn't assert
+ tet_result(TET_PASS);
+ }
+ catch (Dali::DaliException& e)
+ {
+ tet_result(TET_FAIL);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliMeshActorCreateNoMeshData(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::Mesh::New() - Create with no mesh data");
+
+ try
+ {
+ MeshData meshData;
+ Mesh mesh = Mesh::New(meshData);
+ MeshActor actor1 = MeshActor::New(mesh);
+ }
+ catch(Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "object", TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorCreateSetData01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshData::SetData() - Create with no verts");
+ try
+ {
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ Material customMaterial;
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ Mesh mesh = Mesh::New(meshData);
+ MeshActor actor1 = MeshActor::New(mesh);
+ }
+ catch(Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "!vertices.empty()", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliMeshActorCreateSetData02(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshData::SetData - Create with no faces");
+ try
+ {
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ Material customMaterial;
+ ConstructVertices(vertices, 60);
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ Mesh mesh = Mesh::New(meshData);
+ MeshActor actor1 = MeshActor::New(mesh);
+ }
+ catch(Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "!faceIndices.empty", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliMeshActorCreateSetData03(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshData::SetData - Create with no mats");
+ try
+ {
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ Material customMaterial;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ Mesh mesh = Mesh::New(meshData);
+ MeshActor actor1 = MeshActor::New(mesh);
+ }
+ catch(Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "material", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliMeshActorCreateSetData04(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetData()");
+
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ Mesh mesh = Mesh::New(meshData);
+ MeshActor actor1 = MeshActor::New(mesh);
+ DALI_TEST_CHECK(actor1);
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorDownCast(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::DownCast()");
+
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ Mesh mesh = Mesh::New(meshData);
+
+ MeshActor actor1 = MeshActor::New(mesh);
+ Actor anActor = Actor::New();
+ anActor.Add(actor1);
+
+ Actor child = anActor.GetChildAt(0);
+ MeshActor meshActor = MeshActor::DownCast(child);
+
+ DALI_TEST_CHECK(meshActor);
+ END_TEST;
+}
+
+int UtcDaliMeshActorDownCast2(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::DownCast()");
+
+ Actor actor1 = Actor::New();
+ Actor anActor = Actor::New();
+ anActor.Add(actor1);
+
+ Actor child = anActor.GetChildAt(0);
+ MeshActor meshActor = MeshActor::DownCast(child);
+ DALI_TEST_CHECK(!meshActor);
+
+ Actor unInitialzedActor;
+ meshActor = DownCast< MeshActor >( unInitialzedActor );
+ DALI_TEST_CHECK(!meshActor);
+ END_TEST;
+}
+
+int UtcDaliMeshActorSetMaterial01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetMaterial()");
+
+ Mesh mesh = NewMesh();
+
+ MeshActor actor = MeshActor::New(mesh);
+ std::string name = "AMeshActor";
+ Stage::GetCurrent().Add(actor);
+ actor.SetName(name);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+
+ MeshActor::SetMaterial(actor, name, customMaterial);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK( actor.GetMaterial() == customMaterial );
+ END_TEST;
+}
+
+int UtcDaliMeshActorSetMaterial01b(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetMaterial()");
+
+ Mesh mesh = NewMesh();
+
+ Actor rootActor = Actor::New();
+ MeshActor meshActor = MeshActor::New(mesh);
+ rootActor.Add(meshActor);
+
+ std::string name = "AMeshActor";
+ meshActor.SetName(name);
+
+ Stage::GetCurrent().Add(rootActor);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+
+ MeshActor::SetMaterial(rootActor, name, customMaterial);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK(meshActor.GetMaterial() == customMaterial );
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorSetMaterial02(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetMaterial()");
+
+ Mesh mesh = NewMesh();
+ MeshActor actor = MeshActor::New(mesh);
+
+ std::string name = "AMeshActor";
+ actor.SetName(name);
+ Stage::GetCurrent().Add(actor);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ Material baseMat = actor.GetMaterial();
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+
+ MeshActor::SetMaterial(actor, "NoName", customMaterial);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK( actor.GetMaterial() == baseMat );
+ DALI_TEST_CHECK( actor.GetMaterial() != customMaterial );
+ END_TEST;
+}
+
+int UtcDaliMeshActorSetMaterial02b(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetMaterial()");
+
+ Mesh mesh = NewMesh();
+
+ MeshActor actor = MeshActor::New(mesh);
+ Stage::GetCurrent().Add(actor);
+
+ std::string name = "AMeshActor";
+ actor.SetName(name);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ Material baseMat = actor.GetMaterial();
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+
+ MeshActor::SetMaterial(actor, "NoName", customMaterial);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK( actor.GetMaterial() == baseMat );
+ DALI_TEST_CHECK( actor.GetMaterial() != customMaterial );
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorSetMaterial03(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetMaterial()");
+
+ Mesh mesh = NewMesh();
+
+ MeshActor actor = MeshActor::New(mesh);
+ std::string name = "AMeshActor";
+ actor.SetName(name);
+ Stage::GetCurrent().Add(actor);
+
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+
+ actor.SetMaterial(customMaterial);
+ application.SendNotification();
+ application.Render(0);
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK(actor.GetMaterial() == customMaterial );
+ END_TEST;
+}
+
+int UtcDaliMeshActorSetMaterial03b(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetMaterial()");
+
+ Mesh mesh = NewMesh();
+
+ MeshActor actor = MeshActor::New(mesh);
+ std::string name = "AMeshActor";
+ actor.SetName(name);
+ Stage::GetCurrent().Add(actor);
+
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+
+ actor.SetMaterial(customMaterial);
+ application.SendNotification();
+ application.Render(0);
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK(actor.GetMaterial() == customMaterial );
+ END_TEST;
+}
+
+
+
+int UtcDaliMeshActorGetMaterial01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetMaterial()");
+
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ Material material = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, material);
+ Mesh mesh = Mesh::New(meshData);
+
+ MeshActor actor = MeshActor::New(mesh);
+ std::string name = "AMeshActor";
+ actor.SetName(name);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ Material gotMaterial = actor.GetMaterial();
+
+ DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION );
+ DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION );
+ DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION );
+ DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION );
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorGetMaterial02(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::SetMaterial()");
+
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ Material material = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, material);
+ Mesh mesh = Mesh::New(meshData);
+
+ MeshActor actor = MeshActor::New(mesh);
+ std::string name = "AMeshActor";
+ actor.SetName(name);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ Material gotMaterial = actor.GetMaterial();
+
+ DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION );
+ DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION );
+ DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION );
+ DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION );
+ END_TEST;
+}
+
+
+namespace
+{
+
+Material ConstructMaterial(float opacity, float diffuseOpacity)
+{
+ Material customMaterial = Material::New("CustomMaterial");
+ customMaterial.SetOpacity(opacity);
+ customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, diffuseOpacity));
+ customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
+ customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
+ return customMaterial;
+}
+
+static void TestBlending( TestApplication& application, Material material, float actorOpacity, BlendingMode::Type blendingMode, bool expectedBlend )
+{
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ meshData.SetData(vertices, faces, bones, material);
+ Mesh mesh = Mesh::New(meshData);
+
+ application.SendNotification();
+ application.Render(0);
+ application.Render();
+ application.SendNotification();
+
+ MeshActor actor = MeshActor::New(mesh);
+ Stage::GetCurrent().Add(actor);
+
+ actor.SetBlendMode(blendingMode);
+ actor.SetOpacity(actorOpacity);
+
+ TraceCallStack& cullFaceTrace = application.GetGlAbstraction().GetCullFaceTrace();
+ cullFaceTrace.Enable(true);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( BlendEnabled( cullFaceTrace ), expectedBlend, TEST_LOCATION );
+}
+} //anonymous namespace
+
+
+int UtcDaliMeshActorBlend01(void)
+{
+ // Set Material with translucent color, actor color opaque, Set Use image alpha to true
+ // Expect blending
+
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend01()");
+
+ TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::AUTO, true );
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorBlend02(void)
+{
+ // Set material to translucent, set use image alpha to false, set actor opacity to 1.0f
+ // Expect no blending
+
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend02()");
+ TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::OFF, false );
+ END_TEST;
+}
+
+int UtcDaliMeshActorBlend03(void)
+{
+ // Set material to opaque, set use image alpha to true, set actor opacity to 1.0f
+ // Expect no blending
+
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend03()");
+ TestBlending( application, ConstructMaterial(1.0f, 1.0f), 1.0f, BlendingMode::AUTO, false );
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorBlend04(void)
+{
+ // Set material to have image with alpha, set use image alpha to true, set actor opacity to 1.0f
+ // Expect blending
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend04()");
+
+ Material material = ConstructMaterial(1.0f, 1.0f);
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
+ material.SetDiffuseTexture( image );
+ application.SendNotification();
+ application.Render(0);
+
+ TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
+ END_TEST;
+}
+
+int UtcDaliMeshActorBlend05(void)
+{
+ // Set material to have image with alpha, set use image alpha to false, set actor opacity to 1.0f
+ // Expect no blending
+
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend05()");
+
+ Material material = ConstructMaterial(1.0f, 1.0f);
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
+ material.SetDiffuseTexture( image );
+ application.SendNotification();
+ application.Render(0);
+
+ TestBlending( application, material, 1.0f, BlendingMode::ON, true );
+ END_TEST;
+}
+
+
+int UtcDaliMeshActorBlend06(void)
+{
+ // Set material to have image without alpha, set use image alpha to true, set actor opacity to 1.0f
+ // Expect no blending
+
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend()");
+
+ Material material = ConstructMaterial(1.0f, 1.0f);
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGB888 );
+ material.SetDiffuseTexture( image );
+ application.SendNotification();
+ application.Render(0);
+
+ TestBlending( application, material, 1.0f, BlendingMode::AUTO, false );
+ END_TEST;
+}
+
+int UtcDaliMeshActorBlend07(void)
+{
+ // Set material to have framebuffer with alpha, set use image alpha to true, set actor opacity to 1.0f
+ // Expect blending
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend07()");
+ application.Render(0);
+
+ Material material = ConstructMaterial(1.0f, 1.0f);
+ FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 );
+ RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
+ RenderTask task = taskList.GetTask( 0u );
+ task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+ application.SendNotification();
+ application.Render();
+
+ material.SetDiffuseTexture( image ); // (to render from)
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
+ END_TEST;
+}
+
+int UtcDaliMeshActorBlend08(void)
+{
+ // Set material to have image with alpha, set use image alpha to false, set actor opacity to 0.5f
+ // Expect blending
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend08()");
+
+ Material material = ConstructMaterial(1.0f, 1.0f);
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
+ material.SetDiffuseTexture( image );
+ application.SendNotification();
+ application.Render(0);
+
+ TestBlending( application, material, 0.5f, BlendingMode::AUTO, true );
+ END_TEST;
+}
+
+int UtcDaliMeshActorBlend09(void)
+{
+ // Set material to have image with no alpha, set material opacity to 0.5, set use image alpha to true, set actor opacity to 1.0f
+ // Expect blending
+ TestApplication application;
+ tet_infoline("Testing Dali::MeshActor::Blend08()");
+
+ Material material = ConstructMaterial(0.5f, 1.0f);
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGB888 );
+ material.SetDiffuseTexture( image );
+ application.SendNotification();
+ application.Render(0);
+
+ TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
+ END_TEST;
+}
+
+// Test that bones update the mesh's bone transform uniforms
+// (Removed old test - wasn't checking the above information, but instead the property
+// info, which is tested elsewhere)
+
+int UtcDaliMeshActorIndices(void)
+{
+ TestApplication application;
+ Actor basicActor = Actor::New();
+ Mesh mesh = NewMesh();
+ MeshActor meshActor = MeshActor::New(mesh);
+
+ Property::IndexContainer indices;
+ meshActor.GetPropertyIndices( indices );
+ DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties
+ DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimatableMeshActorIndices(void)
+{
+ TestApplication application;
+ Actor basicActor = Actor::New();
+ AnimatableMesh mesh = NewAnimatableMesh();
+ MeshActor meshActor = MeshActor::New(mesh);
+
+ Property::IndexContainer indices;
+ meshActor.GetPropertyIndices( indices );
+ DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties
+ DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION );
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+#include "mesh-builder.h"
+
+
+
+int UtcDaliMeshDataNew(void)
+{
+ TestApplication application;
+ MeshData meshData;
+
+ DALI_TEST_EQUALS(meshData.HasNormals(), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(meshData.HasTextureCoords(), false, TEST_LOCATION);
+ END_TEST;
+}
+
+
+int UtcDaliMeshDataSetData(void)
+{
+ TestApplication application;
+
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 60);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ DALI_TEST_GREATER(meshData.GetVertexCount(), size_t(0), TEST_LOCATION);
+ DALI_TEST_GREATER(meshData.GetFaceCount(), size_t(0), TEST_LOCATION);
+
+ const MeshData::FaceIndices& faces2 = meshData.GetFaces();
+ const MeshData::VertexContainer& verts2 = meshData.GetVertices();
+ DALI_TEST_EQUALS(faces.at(0), faces2.at(0), TEST_LOCATION);
+ DALI_TEST_EQUALS(vertices.at(1).y, verts2.at(1).y, TEST_LOCATION);
+ DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast<size_t>(0), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMeshDataAddToBoundingVolume(void)
+{
+ TestApplication application;
+
+ float sz=40.0f;
+
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, sz);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ Vector4 upper(-1e10f, -1e10f, -1e10f, 0.0f);
+ Vector4 lower(1e10f, 1e10f, 1e10f, 0.0f);
+ Matrix f(false);
+ f.SetIdentityAndScale(Vector3(2.0f, 2.0f, 2.0f));
+ meshData.AddToBoundingVolume(lower, upper, f);
+
+ Vector4 min(-sz*0.5f, -sz, -sz*0.7f, 0.0f);
+ Vector4 max( sz*0.5f, sz*0.3f, sz*0.5f, 0.0f);
+
+ // Test that upper and lower bounds are set and transformed
+ DALI_TEST_EQUALS(lower, min*2.0f, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(upper, max*2.0f, 0.001, TEST_LOCATION);
+
+ // Test that mesh's upper and lower bounds are set and not transformed
+ DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMeshDataBoundingBox(void)
+{
+ TestApplication application;
+
+ float sz=40.0f;
+ MeshData meshData;
+ Vector4 min(-1.0f, -2.0f, -3.0f, 0.0f);
+ Vector4 max(1.0f, 2.0f, 3.0f, 0.0f);
+ meshData.SetBoundingBoxMin(min);
+ meshData.SetBoundingBoxMax(max);
+ DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION);
+
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, sz);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ // Check bounding box hasn't changed
+ DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION);
+
+ Vector4 upper(-1e10f, -1e10f, -1e10f, 0.0f);
+ Vector4 lower(1e10f, 1e10f, 1e10f, 0.0f);
+ meshData.AddToBoundingVolume(lower, upper, Matrix::IDENTITY);
+
+ // Bounding box should have been update
+ Vector4 bbMin(-sz*0.5f, -sz, -sz*0.7f, 0.0f);
+ Vector4 bbMax( sz*0.5f, sz*0.3f, sz*0.5f, 0.0f);
+
+ // Test that upper and lower bounds are set and transformed
+ DALI_TEST_EQUALS(lower, bbMin, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(upper, bbMax, 0.001, TEST_LOCATION);
+
+ // Test that mesh's upper and lower bounds are set and not transformed
+ DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), bbMin, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), bbMax, 0.001, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMeshDataGetVertexCount(void)
+{
+ TestApplication application;
+
+ MeshData meshData;
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 30);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+
+ DALI_TEST_EQUALS(meshData.GetVertexCount(), static_cast<size_t>(0), TEST_LOCATION);
+
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ DALI_TEST_EQUALS(meshData.GetVertexCount(), vertices.size(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliMeshDataGetVertices(void)
+{
+ TestApplication application;
+ MeshData meshData;
+ const Dali::MeshData::VertexContainer& verts1 = meshData.GetVertices();
+ DALI_TEST_CHECK(verts1.size() == 0);
+
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 30);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ const Dali::MeshData::VertexContainer& verts2 = meshData.GetVertices();
+ DALI_TEST_CHECK(verts2.size() != 0);
+ DALI_TEST_CHECK(verts2.size() == meshData.GetVertexCount());
+ END_TEST;
+}
+
+int UtcDaliMeshDataGetFaceCount(void)
+{
+ TestApplication application;
+ MeshData meshData;
+ DALI_TEST_EQUALS(meshData.GetFaceCount(), static_cast<size_t>(0), TEST_LOCATION);
+
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 30);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ DALI_TEST_EQUALS(meshData.GetFaceCount(), faces.size() / 3, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMeshDataGetFaces(void)
+{
+ TestApplication application;
+ MeshData meshData;
+ const Dali::MeshData::FaceIndices& faces1 = meshData.GetFaces();
+ DALI_TEST_CHECK(faces1.size() == 0);
+
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 30);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ const Dali::MeshData::FaceIndices& faces2 = meshData.GetFaces();
+ DALI_TEST_CHECK(faces2.size() != 0);
+ END_TEST;
+}
+
+int UtcDaliMeshDataTextureCoords(void)
+{
+ TestApplication application;
+ MeshData meshData;
+ DALI_TEST_EQUALS(meshData.HasTextureCoords(), false, TEST_LOCATION);
+ meshData.SetHasTextureCoords(true);
+ DALI_TEST_EQUALS(meshData.HasTextureCoords(), true, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMeshDataNormals(void)
+{
+ TestApplication application;
+ MeshData meshData;
+ DALI_TEST_EQUALS(meshData.HasNormals(), false, TEST_LOCATION);
+ meshData.SetHasNormals(true);
+ DALI_TEST_EQUALS(meshData.HasNormals(), true, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMeshDataGetMaterial(void)
+{
+ TestApplication application;
+ MeshData meshData;
+ Material aMat = meshData.GetMaterial();
+ DALI_TEST_CHECK(!aMat);
+
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 30);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ aMat = meshData.GetMaterial();
+ DALI_TEST_CHECK(aMat);
+ END_TEST;
+}
+
+int UtcDaliMeshDataSetMaterial(void)
+{
+ TestApplication application;
+ MeshData meshData;
+
+ Material aMat = meshData.GetMaterial();
+ DALI_TEST_CHECK(!aMat);
+
+ Material mat1 = ConstructMaterial();
+ meshData.SetMaterial(mat1);
+ aMat = meshData.GetMaterial();
+ DALI_TEST_CHECK(mat1 == aMat);
+
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 30);
+ ConstructFaces(vertices, faces);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ aMat = meshData.GetMaterial();
+
+ DALI_TEST_CHECK(aMat == customMaterial);
+ DALI_TEST_CHECK(aMat != mat1);
+
+ END_TEST;
+}
+
+int UtcDaliMeshDataGetBoneCount(void)
+{
+ TestApplication application;
+ MeshData meshData;
+ DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast<size_t>(0), TEST_LOCATION);
+ DALI_TEST_EQUALS(meshData.HasBones(), false, TEST_LOCATION);
+
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 30);
+ ConstructFaces(vertices, faces);
+ ConstructBones(bones);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+
+ DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast<size_t>(3), TEST_LOCATION);
+ DALI_TEST_EQUALS(meshData.HasBones(), true, TEST_LOCATION);
+ END_TEST;
+}
+
+
+int UtcDaliMeshDataGetBones(void)
+{
+ TestApplication application;
+ MeshData meshData;
+ DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast<size_t>(0), TEST_LOCATION);
+ const BoneContainer& bones1 = meshData.GetBones();
+ DALI_TEST_CHECK(bones1.empty());
+
+ MeshData::VertexContainer vertices;
+ MeshData::FaceIndices faces;
+ BoneContainer bones;
+ ConstructVertices(vertices, 30);
+ ConstructFaces(vertices, faces);
+ ConstructBones(bones);
+ Material customMaterial = ConstructMaterial();
+ meshData.SetData(vertices, faces, bones, customMaterial);
+ const BoneContainer& bones3 = meshData.GetBones();
+ DALI_TEST_CHECK( ! bones3.empty() );
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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 <unistd.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/common/mutex.h>
+#include <dali-test-suite-utils.h>
+
+using Dali::Mutex;
+
+int UtcDaliMutexSingleThread(void)
+{
+ tet_infoline("Testing Dali::Mutex in a single thread");
+
+ {
+ Mutex mutex1;
+ DALI_TEST_EQUALS( false, mutex1.IsLocked(), TEST_LOCATION );
+ }
+
+ {
+ Mutex mutex2;
+ Mutex::ScopedLock lock( mutex2 );
+ DALI_TEST_EQUALS( true, mutex2.IsLocked(), TEST_LOCATION );
+ }
+
+ Mutex mutex3;
+ {
+ Mutex::ScopedLock lock( mutex3 );
+ }
+ DALI_TEST_EQUALS( false, mutex3.IsLocked(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+namespace // for local variables to avoid name clashes
+{
+int gGlobalValue = 0;
+Mutex* gGlobalValueMutex;
+bool gWorkerThreadWait = true;
+enum ThreadState { INIT, RUN, LOCKING, TERMINATE } gWorkerThreadState = INIT;
+}
+void* WorkerThread1( void* ptr )
+{
+ gWorkerThreadState = RUN;
+ {
+ Mutex::ScopedLock lock( *gGlobalValueMutex );
+ gWorkerThreadState = LOCKING;
+ gGlobalValue = -1;
+ while( gWorkerThreadWait ) // wait till we can exit
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ }
+ gWorkerThreadState = TERMINATE;
+ return NULL;
+}
+
+int UtcDaliMutexMultiThread(void)
+{
+ tet_infoline("Testing Dali::Mutex multithreaded");
+
+ gGlobalValueMutex = new Dali::Mutex;
+
+ pthread_t thread1;
+ // initialize values
+ gGlobalValue = 0;
+ gWorkerThreadWait = true;
+ DALI_TEST_EQUALS( INIT, gWorkerThreadState, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( false, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+
+ // lock the mutex
+ {
+ Mutex::ScopedLock lock( *gGlobalValueMutex );
+ DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+ pthread_create( &thread1, NULL, &WorkerThread1, NULL );
+ // wait till the thread is in run state
+ while( RUN != gWorkerThreadState )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ // now the thread is running and mutex is still locked by this thread so value is not changed
+ DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
+ // drop out of scope, releases our lock
+ }
+ // now child thread is allowed to change the value
+ // wait till the thread is in locking state
+ while( LOCKING != gWorkerThreadState )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ // mutex is locked, but not by us, by the child thread
+ DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+ // value is changed
+ DALI_TEST_EQUALS( -1, gGlobalValue, TEST_LOCATION );
+ // let worker finish
+ gWorkerThreadWait = false;
+ // wait till the thread is terminated state
+ while( TERMINATE != gWorkerThreadState )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ DALI_TEST_EQUALS( false, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+ void* exitValue;
+ pthread_join( thread1, &exitValue );
+
+ END_TEST;
+}
+
+int UtcDaliMutexNonCopyable(void)
+{
+ // we want to make sure that mutex is not copyable (its copy constructor is not defined)
+ // this test will stop compiling if Mutex has compiler generated copy constructor
+ DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Mutex ) );
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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/public-api/dali-core.h>
+#include <dali/devel-api/scripting/scripting.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+using namespace Dali::Scripting;
+
+namespace
+{
+
+const StringEnum< int > COLOR_MODE_VALUES[] =
+{
+ { "USE_OWN_COLOR", USE_OWN_COLOR },
+ { "USE_PARENT_COLOR", USE_PARENT_COLOR },
+ { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR },
+ { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
+};
+const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
+
+const StringEnum< int > POSITION_INHERITANCE_MODE_VALUES[] =
+{
+ { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
+ { "USE_PARENT_POSITION", USE_PARENT_POSITION },
+ { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION },
+ { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
+};
+const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] );
+
+const StringEnum< int > DRAW_MODE_VALUES[] =
+{
+ { "NORMAL", DrawMode::NORMAL },
+ { "OVERLAY", DrawMode::OVERLAY },
+ { "STENCIL", DrawMode::STENCIL },
+};
+const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Helpers for string to enum comparisons for Image and Image loading parameters
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Template to check enumerations of type T, with a class of type X
+ */
+template< typename T, typename X >
+void TestEnumStrings(
+ Property::Map& map, // The map used to create instance of type X
+ const StringEnum< int >* values, // An array of string values
+ unsigned int num, // Number of items in the array
+ T ( X::*method )() const, // The member method of X to call to get the enum
+ X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X
+)
+{
+ const unsigned int lastIndex( map.Count() - 1 );
+ const std::string& key = map.GetKey( lastIndex );
+ Property::Value& value = map.GetValue( lastIndex );
+
+ for ( unsigned int i = 0; i < num; ++i )
+ {
+ value = values[i].string;
+ tet_printf("Checking: %s: %s\n", key.c_str(), values[i].string );
+ X instance = creator( map );
+ DALI_TEST_EQUALS( values[i].value, ( instance.*method )(), TEST_LOCATION );
+ }
+}
+
+/// Helper method to create ResourceImage using property
+ResourceImage NewResourceImage( const Property::Value& map )
+{
+ ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
+ return image;
+}
+
+/// Helper method to create ResourceImage using property
+BufferImage NewBufferImage( const Property::Value& map )
+{
+ BufferImage image = BufferImage::DownCast( NewImage( map ) );
+ return image;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Helpers for string to enum comparisons for Actor to Property::Map
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Template to check enumerations of type T
+ */
+template< typename T >
+void TestEnumStrings(
+ const char * const keyName, // The name of the key to check
+ TestApplication& application, // Reference to the application class
+ const StringEnum< int >* values, // An array of string values
+ unsigned int num, // Number of items in the array
+ void ( Actor::*method )( T ) // The Actor member method to set the enumeration
+)
+{
+ for ( unsigned int i = 0; i < num; ++i )
+ {
+ tet_printf("Checking: %s: %s\n", keyName, values[i].string );
+
+ Actor actor = Actor::New();
+ (actor.*method)( ( T ) values[i].value );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+
+ DALI_TEST_CHECK( map.Count() );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( keyName ) );
+ DALI_TEST_EQUALS( value.GetValue( keyName ).Get< std::string >(), values[i].string, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+
+} // anon namespace
+
+
+
+int UtcDaliScriptingGetColorMode(void)
+{
+ TestApplication application;
+
+ for ( unsigned int i = 0; i < COLOR_MODE_VALUES_COUNT; ++i )
+ {
+ tet_printf( "Checking %s == %d\n", COLOR_MODE_VALUES[i].string, COLOR_MODE_VALUES[i].value );
+ DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].value, GetColorMode( COLOR_MODE_VALUES[i].string ), TEST_LOCATION );
+ DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].string, GetColorMode( (ColorMode) COLOR_MODE_VALUES[i].value ), TEST_LOCATION );
+ }
+
+ try
+ {
+ (void)GetColorMode("INVALID_ARG");
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingGetPositionInheritanceMode(void)
+{
+ TestApplication application;
+
+ for ( unsigned int i = 0; i < POSITION_INHERITANCE_MODE_VALUES_COUNT; ++i )
+ {
+ tet_printf( "Checking %s == %d\n", POSITION_INHERITANCE_MODE_VALUES[i].string, POSITION_INHERITANCE_MODE_VALUES[i].value );
+ DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].value, GetPositionInheritanceMode( POSITION_INHERITANCE_MODE_VALUES[i].string ), TEST_LOCATION );
+ DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].string, GetPositionInheritanceMode( (PositionInheritanceMode) POSITION_INHERITANCE_MODE_VALUES[i].value ), TEST_LOCATION );
+ }
+
+ try
+ {
+ (void)GetPositionInheritanceMode("INVALID_ARG");
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+
+int UtcDaliScriptingGetDrawMode(void)
+{
+ TestApplication application;
+
+ for ( unsigned int i = 0; i < DRAW_MODE_VALUES_COUNT; ++i )
+ {
+ tet_printf( "Checking %s == %d\n", DRAW_MODE_VALUES[i].string, DRAW_MODE_VALUES[i].value );
+ DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].value, GetDrawMode( DRAW_MODE_VALUES[i].string ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].string, GetDrawMode( (DrawMode::Type) DRAW_MODE_VALUES[i].value ), TEST_LOCATION );
+ }
+
+ try
+ {
+ (void)GetDrawMode("INVALID_ARG");
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingGetAnchorConstant(void)
+{
+ TestApplication application;
+
+ DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_LEFT, GetAnchorConstant( "TOP_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_CENTER, GetAnchorConstant( "TOP_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_RIGHT, GetAnchorConstant( "TOP_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_LEFT, GetAnchorConstant( "CENTER_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER, GetAnchorConstant( "CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_RIGHT, GetAnchorConstant( "CENTER_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_LEFT, GetAnchorConstant( "BOTTOM_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_CENTER, GetAnchorConstant( "BOTTOM_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_RIGHT, GetAnchorConstant( "BOTTOM_RIGHT" ), TEST_LOCATION );
+
+ try
+ {
+ (void)GetAnchorConstant("INVALID_ARG");
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative(void)
+{
+ TestApplication application;
+
+ // Invalid filename
+ try
+ {
+ Property::Map map;
+ map[ "filename" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+ }
+
+ // Invalid load-policy
+ try
+ {
+ Property::Map map;
+ map[ "load-policy" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map[ "load-policy" ] = "INVALID";
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid release-policy
+ try
+ {
+ Property::Map map;
+ map[ "release-policy" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map[ "release-policy" ] = "INVALID";
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid width
+ try
+ {
+ Property::Map map;
+ map[ "width" ] = "Invalid";
+ map[ "height" ] = "Invalid";
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
+ }
+
+ // Invalid height
+ try
+ {
+ Property::Map map;
+ map[ "width" ] = 10;
+ map[ "height" ] = "Invalid";
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
+ }
+
+ // Invalid fitting-mode
+ try
+ {
+ Property::Map map;
+ map[ "fitting-mode" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "value.GetType() == Property::STRING", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map[ "fitting-mode" ] = "INVALID";
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid scaling-mode
+ try
+ {
+ Property::Map map;
+ map[ "sampling-mode" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "value.GetType() == Property::STRING", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map[ "sampling-mode" ] = "INVALID";
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid orientation-correction
+ try
+ {
+ Property::Map map;
+ map[ "orientation" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "value.GetType() == Property::BOOLEAN", TEST_LOCATION );
+ }
+
+ // Invalid type
+ try
+ {
+ Property::Map map;
+ map[ "type" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(\"type\").GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map[ "type" ] = "INVALID";
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid pixel-format
+ try
+ {
+ Property::Map map;
+ map[ "pixel-format" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map[ "pixel-format" ] = "INVALID";
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ END_TEST;
+}
+
+
+int UtcDaliScriptingNewImage(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+
+ // Filename only
+ {
+ ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
+ DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION );
+ }
+
+ // load-policy
+ map[ "load-policy" ] = "";
+ {
+ const StringEnum< int > values[] =
+ {
+ { "IMMEDIATE", ResourceImage::IMMEDIATE },
+ { "ON_DEMAND", ResourceImage::ON_DEMAND }
+ };
+ TestEnumStrings< ResourceImage::LoadPolicy, ResourceImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ResourceImage::GetLoadPolicy, &NewResourceImage );
+ }
+
+ // release-policy
+ map[ "release-policy" ] = "";
+ {
+ const StringEnum< int > values[] =
+ {
+ { "UNUSED", Image::UNUSED },
+ { "NEVER", Image::NEVER }
+ };
+ TestEnumStrings< Image::ReleasePolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
+ }
+
+ // float width and height
+ map[ "width" ] = (float) 10.0f;
+ map[ "height" ] = (float) 20.0f;
+ {
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( image.GetWidth(), 10.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( image.GetHeight(), 20.0f, TEST_LOCATION );
+ }
+
+ // int width and height
+ map[ "width"] = (int) 50;
+ map[ "height" ] = (int) 70;
+ {
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
+ DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
+ }
+
+ //map.erase( map.end() - 2, map.end() );
+
+ // type FrameBufferImage
+ map[ "type" ] = "FrameBufferImage";
+ {
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
+ }
+ // type BufferImage
+ map[ "type" ] = "BufferImage";
+ {
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( BufferImage::DownCast( image ) );
+ DALI_TEST_CHECK((BufferImage::DownCast( image )).GetPixelFormat()== Pixel::RGBA8888);
+ }
+
+ // pixel-format
+ map[ "pixel-format" ] = "";
+ {
+ const StringEnum< int > values[] =
+ {
+ { "A8", Pixel::A8 },
+ { "L8", Pixel::L8 },
+ { "LA88", Pixel::LA88 },
+ { "RGB565", Pixel::RGB565 },
+ { "BGR565", Pixel::BGR565 },
+ { "RGBA4444", Pixel::RGBA4444 },
+ { "BGRA4444", Pixel::BGRA4444 },
+ { "RGBA5551", Pixel::RGBA5551 },
+ { "BGRA5551", Pixel::BGRA5551 },
+ { "RGB888", Pixel::RGB888 },
+ { "RGB8888", Pixel::RGB8888 },
+ { "BGR8888", Pixel::BGR8888 },
+ { "RGBA8888", Pixel::RGBA8888 },
+ { "BGRA8888", Pixel::BGRA8888 },
+ /*{ "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
+ { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
+ { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
+ { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
+ { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
+ { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
+ { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
+ { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
+ { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
+ { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
+ { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
+ { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },*/
+ // BufferImage does not support compressed formats
+ };
+
+ TestEnumStrings< Pixel::Format, BufferImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
+ }
+
+ // type Image
+ map[ "type" ] = "ResourceImage";
+ {
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
+ DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
+ DALI_TEST_CHECK( !BufferImage::DownCast( image ) );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingNewShaderEffect(void)
+{
+ TestApplication application;
+
+ Property::Map programMap;
+ programMap[ "vertex-filename" ] = "bump.vert";
+ programMap[ "fragment-filename" ] = "bump.frag";
+
+ Property::Map imageMap;
+ imageMap[ "filename" ] = "image.png";
+
+ Property::Map map;
+ map[ "image" ] = imageMap;
+ map[ "program" ] = programMap;
+ map[ "uLightPosition" ] = Vector3( 0.0, 0.0, -1.5);
+ map[ "uAmbientLight" ] = (int)10;
+
+ ShaderEffect shader = NewShaderEffect( map );
+
+ DALI_TEST_CHECK( shader );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewActorNegative(void)
+{
+ TestApplication application;
+
+ // Empty map
+ {
+ Actor handle = NewActor( Property::Map() );
+ DALI_TEST_CHECK( !handle );
+ }
+
+ // Map with only properties
+ {
+ Property::Map map;
+ map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
+ map[ "anchor-point" ] = AnchorPoint::TOP_CENTER;
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( !handle );
+ }
+
+ // Add some signals to the map, we should have no signal connections as its not yet supported
+ {
+ Property::Map map;
+ map[ "type" ] = "Actor";
+ map[ "signals" ] = Property::MAP;
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+ DALI_TEST_CHECK( !handle.MouseWheelEventSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingNewActorProperties(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "type" ] = "Actor";
+ map[ "size" ] = Vector3::ONE;
+ map[ "position" ] = Vector3::XAXIS;
+ map[ "scale" ] = Vector3::ONE;
+ map[ "visible" ] = false;
+ map[ "color" ] = Color::MAGENTA;
+ map[ "name" ] = "MyActor";
+ map[ "color-mode" ] = "USE_PARENT_COLOR";
+ map[ "inherit-shader-effect" ] = false;
+ map[ "sensitive" ] = false;
+ map[ "leave-required" ] = true;
+ map[ "position-inheritance" ] = "DONT_INHERIT_POSITION";
+ map[ "draw-mode" ] = "STENCIL";
+ map[ "inherit-orientation" ] = false;
+ map[ "inherit-scale" ] = false;
+
+ // Default properties
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsSensitive(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetLeaveRequired(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsOrientationInherited(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+
+ // Check Anchor point and parent origin vector3s
+ map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
+ map[ "anchor-point" ] = AnchorPoint::TOP_LEFT;
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+
+ // Check Anchor point and parent origin STRINGS
+ map[ "parent-origin" ] = "TOP_LEFT";
+ map[ "anchor-point" ] = "CENTER_LEFT";
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingNewActorChildren(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "type" ] = "Actor";
+ map[ "position" ] = Vector3::XAXIS;
+
+ Property::Map child1Map;
+ child1Map[ "type" ] = "ImageActor";
+ child1Map[ "position" ] = Vector3::YAXIS;
+
+ Property::Array childArray;
+ childArray.PushBack( child1Map );
+ map[ "actors" ] = childArray;
+
+ // Create
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetChildCount(), 1u, TEST_LOCATION );
+
+ Actor child1 = handle.GetChildAt(0);
+ DALI_TEST_CHECK( child1 );
+ DALI_TEST_CHECK( ImageActor::DownCast( child1 ) );
+ DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ END_TEST;
+}
+
+
+int UtcDaliScriptingCreatePropertyMapActor(void)
+{
+ TestApplication application;
+
+ // Actor Type
+ {
+ Actor actor = Actor::New();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.Empty() );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "Actor", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // ImageActor Type
+ {
+ Actor actor = ImageActor::New();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.Empty() );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "ImageActor", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // Default properties
+ {
+ Actor actor = Actor::New();
+ actor.SetSize( Vector3::ONE );
+ actor.SetPosition( Vector3::XAXIS );
+ actor.SetScale( Vector3::ZAXIS );
+ actor.SetVisible( false );
+ actor.SetColor( Color::MAGENTA );
+ actor.SetName( "MyActor" );
+ actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ actor.SetParentOrigin( ParentOrigin::TOP_RIGHT );
+ actor.SetSensitive( false );
+ actor.SetLeaveRequired( true );
+ actor.SetInheritOrientation( false );
+ actor.SetInheritScale( false );
+ actor.SetSizeModeFactor( Vector3::ONE );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+
+ DALI_TEST_CHECK( !map.Empty() );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "size" ) );
+ DALI_TEST_EQUALS( value.GetValue( "size" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "position" ) );
+ DALI_TEST_EQUALS( value.GetValue( "position" ).Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "scale" ) );
+ DALI_TEST_EQUALS( value.GetValue( "scale" ).Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "visible" ) );
+ DALI_TEST_EQUALS( value.GetValue( "visible" ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "color" ) );
+ DALI_TEST_EQUALS( value.GetValue( "color" ).Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "name" ) );
+ DALI_TEST_EQUALS( value.GetValue( "name").Get< std::string >(), "MyActor", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "anchor-point" ) );
+ DALI_TEST_EQUALS( value.GetValue( "anchor-point" ).Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "parent-origin" ) );
+ DALI_TEST_EQUALS( value.GetValue( "parent-origin" ).Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "sensitive" ) );
+ DALI_TEST_EQUALS( value.GetValue( "sensitive" ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "leave-required" ) );
+ DALI_TEST_EQUALS( value.GetValue( "leave-required" ).Get< bool >(), true, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "inherit-orientation" ) );
+ DALI_TEST_EQUALS( value.GetValue( "inherit-orientation" ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "inherit-scale" ) );
+ DALI_TEST_EQUALS( value.GetValue( "inherit-scale" ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "size-mode-factor" ) );
+ DALI_TEST_EQUALS( value.GetValue( "size-mode-factor" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // ColorMode
+ TestEnumStrings< ColorMode >( "color-mode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
+
+ // PositionInheritanceMode
+ TestEnumStrings< PositionInheritanceMode >( "position-inheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
+
+ // DrawMode
+ TestEnumStrings< DrawMode::Type >( "draw-mode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
+
+ // Children
+ {
+ Actor actor = Actor::New();
+ Actor child = ImageActor::New();
+ actor.Add( child );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.Empty() );
+
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Actor", TEST_LOCATION );
+
+ DALI_TEST_CHECK( value.HasKey( "actors" ) );
+ Property::Array children( value.GetValue( "actors").Get< Property::Array >() );
+ DALI_TEST_CHECK( !children.Empty() );
+ Property::Map childMap( children[0].Get< Property::Map >() );
+ DALI_TEST_CHECK( !childMap.Empty() );
+ Property::Value childValue( childMap );
+ DALI_TEST_CHECK( childValue.HasKey( "type" ) );
+ DALI_TEST_EQUALS( childValue.GetValue( "type" ).Get< std::string >(), "ImageActor", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingCreatePropertyMapImage(void)
+{
+ TestApplication application;
+
+ // Empty
+ {
+ Image image;
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( map.Empty() );
+ }
+
+ // Default
+ {
+ Image image = ResourceImage::New( "MY_PATH" );
+
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( !map.Empty() );
+
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "ResourceImage", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "filename" ) );
+ DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "load-policy") );
+ DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "release-policy") );
+ DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "NEVER", TEST_LOCATION );
+ DALI_TEST_CHECK( !value.HasKey( "width" ) );
+ DALI_TEST_CHECK( !value.HasKey( "height" ) );
+ }
+
+ // Change values
+ {
+ ResourceImage image = ResourceImage::New( "MY_PATH", ResourceImage::ON_DEMAND, Image::UNUSED, ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
+
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( !map.Empty() );
+
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "ResourceImage", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "filename" ) );
+ DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "load-policy") );
+ DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "release-policy") );
+ DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "UNUSED", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "width" ) );
+ DALI_TEST_EQUALS( value.GetValue( "width" ).Get< int >(), 300, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "height" ) );
+ DALI_TEST_EQUALS( value.GetValue( "height" ).Get< int >(), 400, TEST_LOCATION );
+ }
+
+ // BufferImage
+ {
+ Image image = BufferImage::New( 200, 300, Pixel::A8 );
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BufferImage", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "pixel-format") );
+ DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION );
+ }
+
+ // FrameBufferImage
+ {
+ Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingGetEnumerationTemplates(void)
+{
+ TestApplication application;
+
+ const Scripting::StringEnum< int > myTable[] =
+ {
+ { "ONE", 1 },
+ { "TWO", 2 },
+ { "THREE", 3 },
+ { "FOUR", 4 },
+ { "FIVE", 5 },
+ };
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+
+ for ( unsigned int i = 0; i < myTableCount; ++i )
+ {
+ tet_printf("Checking: %s\n", myTable[ i ].string );
+ DALI_TEST_EQUALS( myTable[ i ].value, GetEnumeration( myTable[ i ].string, myTable, myTableCount ), TEST_LOCATION );
+ }
+
+ for ( unsigned int i = 0; i < myTableCount; ++i )
+ {
+ tet_printf("Checking: %d\n", myTable[ i ].value );
+ DALI_TEST_EQUALS( myTable[ i ].string, GetEnumerationName( myTable[ i ].value, myTable, myTableCount ), TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliScriptingCompareEnums(void)
+{
+ // EQUAL
+ DALI_TEST_CHECK( CompareEnums( "", "" ) );
+ DALI_TEST_CHECK( CompareEnums( "HELLO", "HELLO" ) );
+ DALI_TEST_CHECK( CompareEnums( "HELLO", "hello" ) );
+ DALI_TEST_CHECK( CompareEnums( "hello", "HELLO" ) );
+ DALI_TEST_CHECK( CompareEnums( "hello-world", "HELLO_WORLD" ) );
+ DALI_TEST_CHECK( CompareEnums( "hello_WORLD", "HELLO-world" ) );
+ DALI_TEST_CHECK( CompareEnums( "hello_WORLD-", "HELLO-world_" ) );
+ DALI_TEST_CHECK( CompareEnums( "_hello_WORLD-", "-HELLO-world_" ) );
+ DALI_TEST_CHECK( CompareEnums( "-hello_WORLD-", "_HELLO-world_" ) );
+ DALI_TEST_CHECK( CompareEnums( "hello123", "HELLO123" ) );
+
+ // NOT EQUAL
+ DALI_TEST_CHECK( ! CompareEnums( "hello", "HELLOWORLD" ) );
+
+ END_TEST;
+}
utc-Dali-Actor.cpp
utc-Dali-AlphaFunction.cpp
utc-Dali-AngleAxis.cpp
- utc-Dali-AnimatableMesh.cpp
utc-Dali-Animation.cpp
utc-Dali-Any.cpp
- utc-Dali-Atlas.cpp
utc-Dali-BaseHandle.cpp
utc-Dali-BufferImage.cpp
utc-Dali-CameraActor.cpp
- utc-Dali-Constrainer.cpp
utc-Dali-Constraint.cpp
utc-Dali-ConstraintFunction.cpp
utc-Dali-Constraints.cpp
utc-Dali-ConstraintSource.cpp
- utc-Dali-Context.cpp
utc-Dali-ConnectionTracker.cpp
utc-Dali-CustomActor.cpp
utc-Dali-Degree.cpp
- utc-Dali-DistanceField.cpp
- utc-Dali-DynamicsBodyConfig.cpp
- utc-Dali-DynamicsShape.cpp
- utc-Dali-DynamicsWorld.cpp
- utc-Dali-DynamicsWorldConfig.cpp
utc-Dali-EncodedBufferImage.cpp
utc-Dali-FrameBufferImage.cpp
utc-Dali-Gesture.cpp
utc-Dali-GestureDetector.cpp
utc-Dali-Handle.cpp
- utc-Dali-Hash.cpp
- utc-Dali-HitTestAlgorithm.cpp
utc-Dali-HoverProcessing.cpp
utc-Dali-Image.cpp
utc-Dali-ImageActor.cpp
utc-Dali-LocklessBuffer.cpp
utc-Dali-LongPressGesture.cpp
utc-Dali-LongPressGestureDetector.cpp
- utc-Dali-Material.cpp
utc-Dali-MathUtils.cpp
utc-Dali-Matrix.cpp
utc-Dali-Matrix3.cpp
- utc-Dali-MeshActor.cpp
- utc-Dali-MeshData.cpp
utc-Dali-MouseWheelEvent.cpp
- utc-Dali-Mutex.cpp
utc-Dali-NativeImage.cpp
utc-Dali-NinePatchImages.cpp
utc-Dali-ObjectRegistry.cpp
utc-Dali-RenderableActor.cpp
utc-Dali-ResourceImage.cpp
utc-Dali-ShaderEffect.cpp
- utc-Dali-Scripting.cpp
utc-Dali-SignalTemplatesFunctors.cpp
utc-Dali-SignalTemplates.cpp
utc-Dali-Stage.cpp
)
LIST(APPEND TC_SOURCES
- dali-test-suite-utils/mesh-builder.cpp
dali-test-suite-utils/test-harness.cpp
dali-test-suite-utils/dali-test-suite-utils.cpp
dali-test-suite-utils/test-application.cpp
ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
TARGET_LINK_LIBRARIES(${EXEC_NAME}
${${CAPI_LIB}_LIBRARIES}
- -lpthread
)
INSTALL(PROGRAMS ${EXEC_NAME}
+++ /dev/null
-/*
- * Copyright (c) 2014 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 "mesh-builder.h"
-
-namespace Dali
-{
-
-void AddVertex( MeshData::VertexContainer& verts, Vector3 V, Vector2 UV )
-{
- MeshData::Vertex meshVertex;
- meshVertex.x = V.x;
- meshVertex.y = V.y;
- meshVertex.z = V.z;
- meshVertex.u = UV.x;
- meshVertex.v = UV.y;
- verts.push_back(meshVertex);
-}
-
-void SetNormal( MeshData::VertexContainer& verts, size_t vertIdx, Vector3 normal )
-{
- verts[vertIdx].nX = normal.x;
- verts[vertIdx].nY = normal.y;
- verts[vertIdx].nZ = normal.z;
-}
-
-void SetBone( MeshData::VertexContainer& verts, size_t vertIdx, size_t index, size_t boneIndex, float weight)
-{
- verts[vertIdx].boneIndices[index] = boneIndex;
- verts[vertIdx].boneWeights[index] = weight;
-}
-
-void SetBones(MeshData::VertexContainer& verts)
-{
- // Set all verts in one corner to be affected fully by bone 0
- SetBone(verts, 0, 0, 0, 1.0f);
- SetBone(verts, 1, 0, 0, 1.0f);
- SetBone(verts, 2, 0, 0, 1.0f);
-
- // Set all verts in next corner to be affected by bone 1 and bone 2 equally
- SetBone(verts, 3, 0, 1, 0.5f);
- SetBone(verts, 4, 0, 1, 0.5f);
- SetBone(verts, 5, 0, 1, 0.5f);
-
- SetBone(verts, 3, 1, 2, 0.5f);
- SetBone(verts, 4, 1, 2, 0.5f);
- SetBone(verts, 5, 1, 2, 0.5f);
-}
-
-void ConstructBones(BoneContainer& bones)
-{
- bones.push_back(Bone("Bone1", Matrix::IDENTITY));
- bones.push_back(Bone("Bone2", Matrix::IDENTITY));
- bones.push_back(Bone("Bone3", Matrix::IDENTITY));
-}
-
-void CopyVertex( MeshData::Vertex& vert, Vector3& vector )
-{
- vector.x = vert.x;
- vector.y = vert.y;
- vector.z = vert.z;
-}
-
-void AddTriangle( MeshData::VertexContainer& verts,
- MeshData::FaceIndices& faces,
- size_t v0, size_t v1, size_t v2 )
-{
- faces.push_back(v0);
- faces.push_back(v1);
- faces.push_back(v2);
-
- // Calculate normal...
- Vector3 vert0, vert1, vert2;
- CopyVertex(verts[v0], vert0);
- CopyVertex(verts[v1], vert1);
- CopyVertex(verts[v2], vert2);
- Vector3 e0 = vert1 - vert0;
- Vector3 e1 = vert2 - vert1;
- Vector3 normal = e0.Cross(e1);
- normal.Normalize();
- SetNormal(verts, v0, normal);
- SetNormal(verts, v1, normal);
- SetNormal(verts, v2, normal);
-}
-
-void ConstructVertices( MeshData::VertexContainer& vertices, float sz )
-{
- // back
- AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0a 0
- AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0b 1
- AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0c 2
-
- // left
- AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1a 3
- AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1b 4
- AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1c 5
-
- // right
- AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2a 6
- AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2b 7
- AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2c 8
-
- // top
- AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3a 9
- AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3b 10
- AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3c 11
-}
-
-void ConstructFaces(MeshData::VertexContainer& vertices, MeshData::FaceIndices& faces)
-{
- AddTriangle(vertices, faces, 0, 6, 3); // 0, 2, 1 back, right, left (ac)
- AddTriangle(vertices, faces, 1, 9, 7); // 0, 3, 2 back, top , right (ac)
- AddTriangle(vertices, faces, 2, 4, 10); // 0, 1, 3 back, left, top (ac)
- AddTriangle(vertices, faces, 11, 5, 8); // 3, 1, 2 top, left, right (ac)
-}
-
-Material ConstructMaterial()
-{
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetOpacity(.76f);
- customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, 1.0f));
- customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
- customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
- return customMaterial;
-}
-
-
-Mesh ConstructMesh( float sz )
-{
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- ConstructVertices( vertices, sz );
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
-
- MeshData meshData;
- BoneContainer bones;
- meshData.SetData(vertices, faces, bones, customMaterial);
- meshData.SetHasNormals(true);
- meshData.SetHasTextureCoords(true);
-
- Mesh mesh = Mesh::New(meshData);
- return mesh;
-}
-
-
-void AddBone(Dali::BoneContainer& bones, const std::string& name, const Dali::Matrix& offsetMatrix)
-{
- bones.push_back(Bone(name, offsetMatrix));
-}
-
-void CreateMeshData(MeshData& meshData)
-{
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- Dali::BoneContainer bones;
- AddBone(bones, "trunk", Matrix::IDENTITY);
- AddBone(bones, "branch", Matrix::IDENTITY);
- AddBone(bones, "twig", Matrix::IDENTITY);
- ConstructVertices( vertices, 50 );
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
- meshData.SetHasNormals(true);
- meshData.SetHasTextureCoords(true);
-}
-
-
-} // namespace Dali
+++ /dev/null
-#ifndef MESH_BUILDER_H
-#define MESH_BUILDER_H
-/*
- * Copyright (c) 2014 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 <dali/public-api/dali-core.h>
-#include <dali/devel-api/geometry/mesh.h>
-
-namespace Dali
-{
-
-void AddVertex( MeshData::VertexContainer& verts, Vector3 V, Vector2 UV );
-void SetNormal( MeshData::VertexContainer& verts, size_t vertIdx, Vector3 normal );
-void SetBone( MeshData::VertexContainer& verts, size_t vertIdx, size_t index, size_t boneIndex, float weight);
-void SetBones(MeshData::VertexContainer& verts);
-void ConstructBones(BoneContainer& bones);
-void CopyVertex( MeshData::Vertex& vert, Vector3& vector );
-void AddTriangle( MeshData::VertexContainer& verts,
- MeshData::FaceIndices& faces,
- size_t v0, size_t v1, size_t v2 );
-void ConstructVertices( MeshData::VertexContainer& vertices, float sz );
-void ConstructFaces(MeshData::VertexContainer& vertices, MeshData::FaceIndices& faces);
-Material ConstructMaterial();
-Mesh ConstructMesh( float sz );
-void AddBone(Dali::BoneContainer& bones, const std::string& name, const Dali::Matrix& offsetMatrix);
-void CreateMeshData(MeshData& meshData);
-
-}
-
-#endif // MESH_BUILDER_H
#include <string>
// INTERNAL INCLUDES
-#include <dali/devel-api/common/set-wrapper.h>
#include <dali/integration-api/platform-abstraction.h>
#include "test-trace-call-stack.h"
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali/devel-api/geometry/animatable-mesh.h>
-#include <dali/devel-api/actors/mesh-actor.h>
-#include <dali-test-suite-utils.h>
-#include <mesh-builder.h>
-
-using namespace Dali;
-
-
-void utc_dali_animatable_mesh_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_animatable_mesh_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-
-void CreateFaces(Dali::AnimatableMesh::Faces& faces, int numVerts)
-{
- for(int i=0; i<numVerts-3; i++)
- {
- faces.push_back(i);
- faces.push_back(i+1);
- faces.push_back(i+2);
- }
-}
-
-void CreateOutOfRangeFaces(Dali::AnimatableMesh::Faces& faces, int numVerts)
-{
- for(int i=numVerts; i<numVerts*2-3; i++)
- {
- faces.push_back(i);
- faces.push_back(i+1);
- faces.push_back(i+2);
- }
-}
-
-AnimatableMesh CreateMesh()
-{
- AnimatableMesh::Faces faces;
- CreateFaces(faces, 10);
- AnimatableMesh mesh = AnimatableMesh::New(10, faces);
- return mesh;
-}
-
-} // anon namespace
-
-// Negative test case for a method
-int UtcDaliAnimatableMeshConstructor01(void)
-{
- TestApplication application;
-
- AnimatableMesh mesh;
-
- DALI_TEST_CHECK( ! mesh );
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshConstructor02(void)
-{
- TestApplication application;
-
- Dali::AnimatableMesh::Faces faces;
- CreateFaces(faces, 10);
-
- AnimatableMesh mesh = AnimatableMesh::New(10, faces);
- DALI_TEST_CHECK( mesh );
-
- AnimatableMesh mesh2 = mesh;
- DALI_TEST_CHECK( mesh2 );
-
- AnimatableMesh mesh3 ( mesh2 );
- DALI_TEST_CHECK( mesh3 );
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshConstructor03(void)
-{
- TestApplication application;
-
- // Heap allocate a handle. Don't do this in real code!
- AnimatableMesh* mesh = new AnimatableMesh();
- DALI_TEST_CHECK( ! *mesh );
- delete mesh;
- END_TEST;
-}
-
-
-// Positive test case for a method
-int UtcDaliAnimatableMeshNew01(void)
-{
- TestApplication application;
-
- Dali::AnimatableMesh::Faces faces;
- CreateFaces(faces, 10);
-
- AnimatableMesh mesh = AnimatableMesh::New(10, faces);
- DALI_TEST_CHECK( mesh );
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliAnimatableMeshNew02(void)
-{
- TestApplication application;
-
- Dali::AnimatableMesh::Faces faces;
- CreateFaces(faces, 10);
-
- Dali::Material mat = Dali::Material::New("dummy mat");
- AnimatableMesh mesh = AnimatableMesh::New(10, faces, mat);
- DALI_TEST_CHECK( mesh );
- END_TEST;
-}
-
-
-// Negative test case for a method
-int UtcDaliAnimatableMeshNew03(void)
-{
- TestApplication application;
- Dali::AnimatableMesh::Faces faces;
- try
- {
- AnimatableMesh mesh = AnimatableMesh::New(0, faces);
- DALI_TEST_CHECK( !mesh );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "numVertices > 0", TEST_LOCATION);
- }
- END_TEST;
-}
-
-// Negative test case for a method
-int UtcDaliAnimatableMeshNew04(void)
-{
- TestApplication application;
-
- Dali::AnimatableMesh::Faces faces;
-
- try
- {
- AnimatableMesh mesh = AnimatableMesh::New(10, faces);
- DALI_TEST_CHECK( !mesh );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "faceIndices.size() > 0", TEST_LOCATION);
- }
- END_TEST;
-}
-
-// Negative test case for a method
-int UtcDaliAnimatableMeshNew05(void)
-{
- TestApplication application;
-
- Dali::AnimatableMesh::Faces faces;
- CreateOutOfRangeFaces(faces, 10);
-
- try
- {
- AnimatableMesh mesh = AnimatableMesh::New(10, faces);
- DALI_TEST_CHECK( !mesh );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "faceIndex < numVertices", TEST_LOCATION);
- }
- END_TEST;
-}
-
-// Negative test case for a method
-int UtcDaliAnimatableMeshNew06(void)
-{
- TestApplication application;
-
- Dali::AnimatableMesh::Faces faces;
- CreateFaces(faces, 10);
-
- try
- {
- AnimatableMesh mesh = AnimatableMesh::New(10, faces, Dali::Material() );
- DALI_TEST_CHECK( !mesh );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "material", TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshDownCast01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh::DownCast()");
-
- Dali::AnimatableMesh::Faces faces;
- CreateFaces(faces, 10);
-
- AnimatableMesh mesh = AnimatableMesh::New(10, faces);
- BaseHandle* bh = &mesh;
-
- AnimatableMesh mesh2 = AnimatableMesh::DownCast(*bh);
- DALI_TEST_CHECK( mesh2 );
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshDownCast02(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh::DownCast()");
-
- MeshData meshData;
- CreateMeshData(meshData);
- Mesh mesh = Mesh::New(meshData);
- BaseHandle* bh = &mesh;
-
- AnimatableMesh mesh2 = AnimatableMesh::DownCast(*bh);
- DALI_TEST_CHECK( ! mesh2 );
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshGetPropertyIndex01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh::operator[]");
- AnimatableMesh mesh = CreateMesh();
-
- Property::Index i = mesh.GetPropertyIndex(0, AnimatableVertex::Property::POSITION );
- DALI_TEST_EQUALS( i, 0*3+0, TEST_LOCATION );
-
- i = mesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION );
- DALI_TEST_EQUALS( i, 5*3+0, TEST_LOCATION );
-
- i = mesh.GetPropertyIndex(7, AnimatableVertex::Property::COLOR );
- DALI_TEST_EQUALS( i, 7*3+1, TEST_LOCATION );
-
- i = mesh.GetPropertyIndex(9, AnimatableVertex::Property::TEXTURE_COORDS );
- DALI_TEST_EQUALS( i, 9*3+2, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshGetPropertyIndex02(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndex");
-
- AnimatableMesh mesh = CreateMesh();
- try
- {
- Property::Index i = mesh.GetPropertyIndex(12, AnimatableVertex::Property::POSITION );
- DALI_TEST_CHECK( i==0 );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshGetPropertyIndex03(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndex");
-
- AnimatableMesh mesh = CreateMesh();
- try
- {
- Property::Index i = mesh.GetPropertyIndex(12, AnimatableVertex::Property::COLOR );
- DALI_TEST_CHECK( i==0 );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshGetPropertyIndex04(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndexa");
-
- AnimatableMesh mesh = CreateMesh();
- try
- {
- Property::Index i = mesh.GetPropertyIndex(12342343, AnimatableVertex::Property::TEXTURE_COORDS );
- DALI_TEST_CHECK( i==0 );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshOperatorArray01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh::operator[]");
-
- AnimatableMesh mesh = CreateMesh();
- {
- Vector3 initialPos1(0.0f, 200.0f, 0.0f);
- Vector3 initialPos2(100.0f, 300.0f, 0.0f);
-
- mesh[1].SetPosition(initialPos1);
- mesh[3].SetPosition(initialPos2);
-
- application.Render(0);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), initialPos1, TEST_LOCATION );
-
- Vector3 pos = mesh[3].GetCurrentPosition();
- DALI_TEST_EQUALS( pos, initialPos2, TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshOperatorArray02(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh::operator[]");
-
- AnimatableMesh mesh = CreateMesh();
- try
- {
- mesh[20].SetPosition(Vector3(0.0f, 0.0f, 0.0f));
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION);
- }
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshAnimateVertex01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableMesh Animating properties");
-
- AnimatableMesh mesh = CreateMesh();
- MeshActor meshActor = MeshActor::New(mesh);
- Stage::GetCurrent().Add(meshActor);
- {
- mesh[0].SetPosition(Vector3(0.0f, 200.0f, 0.0f));
- mesh[1].SetPosition(Vector3(100.0f, 300.0f, 0.0f));
-
- Animation anim = Animation::New(1);
- anim.AnimateBy(mesh.GetVertexProperty(0, AnimatableVertex::Property::POSITION), Vector3( 0.0f, 100.0f, 0.0f));
- anim.AnimateTo(mesh.GetVertexProperty(1, AnimatableVertex::Property::POSITION), Vector3(100.0f, 0.0f, 0.0f));
- anim.Play();
-
- application.SendNotification();
- application.Render(0);
- application.Render(500);
- application.SendNotification();
-
- // 50% progress
- DALI_TEST_EQUALS( mesh[0].GetCurrentPosition(), Vector3( 0.0f, 250.0f, 0.0f), TEST_LOCATION );
- DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), Vector3(100.0f, 150.0f, 0.0f), TEST_LOCATION );
-
- application.SendNotification();
- application.Render(501);
- application.SendNotification();
-
- DALI_TEST_EQUALS( mesh[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f), TEST_LOCATION );
- DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), Vector3(100.0f, 0.0f, 0.0f), TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliAnimatableVertexSettersAndGetters(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::AnimatableVertex constructors");
- AnimatableMesh mesh = CreateMesh();
- Vector3 v1Pos(0.0f, 200.0f, 0.0f);
- Vector3 v2Pos(100.0f, 300.0f, 0.0f);
- Vector2 uvs(0.1f, 0.2f);
- mesh[0].SetPosition(v1Pos);
- mesh[1].SetPosition(v2Pos);
- mesh[2].SetColor(Color::BLACK);
- mesh[3].SetTextureCoords(uvs);
-
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_EQUALS(mesh[0].GetCurrentPosition(), v1Pos, TEST_LOCATION);
- DALI_TEST_EQUALS(mesh[1].GetCurrentPosition(), v2Pos, TEST_LOCATION);
- DALI_TEST_EQUALS(mesh[2].GetCurrentColor(), Color::BLACK, TEST_LOCATION);
- DALI_TEST_EQUALS(mesh[3].GetCurrentTextureCoords(), uvs, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshProperties(void)
-{
- TestApplication application;
- AnimatableMesh mesh = CreateMesh();
-
- Property::IndexContainer indices;
- mesh.GetPropertyIndices( indices );
- DALI_TEST_CHECK( ! indices.empty() );
- DALI_TEST_EQUALS( indices.size(), mesh.GetPropertyCount(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshExceedVertices(void)
-{
- TestApplication application;
-
- AnimatableMesh::Faces faces;
- CreateFaces(faces, 10);
-
- try
- {
- AnimatableMesh mesh = AnimatableMesh::New(3333334, faces);
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "( numVertices * 3 ) < DEFAULT_PROPERTY_MAX_COUNT", TEST_LOCATION );
- }
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <algorithm>
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/devel-api/images/atlas.h>
-#include <dali-test-suite-utils.h>
-#include <test-native-image.h>
-
-using namespace Dali;
-
-namespace
-{
-static const char* gTestImageFilename = "icon_wrt.png";
-
-void PrepareResourceImage( TestApplication& application, unsigned int imageHeight, unsigned int imageWidth, Pixel::Format pixelFormat )
-{
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetClosestImageSize(Vector2( 16, 16));
-
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
- Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
- unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
- unsigned int initialColor = 0xFF;
- memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel);
-
- Integration::ResourcePointer resourcePtr(bitmap);
- platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
-}
-
-}
-
-void utc_dali_atlas_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_atlas_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-// 1.1
-int UtcDaliAtlasNew01(void)
-{
- TestApplication application;
-
- // invoke default handle constructor
- Atlas atlas;
-
- DALI_TEST_CHECK( !atlas );
-
- // initialise handle
- atlas = Atlas::New( 16, 16 );
-
- DALI_TEST_CHECK( atlas );
- END_TEST;
-}
-
-
-// 1.2
-int UtcDaliAtlasUpload01(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using correct pixel format
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 0 ) );
-
- END_TEST;
-}
-
-// 1.3
-int UtcDaliAtlasUpload02(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 10, 10, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using INCORRECT pixel format
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::A8 );
- DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::A8 );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 0, 0 ) );
-
- END_TEST;
-}
-
-// 1.4
-int UtcDaliAtlasUpload03(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 10, 10, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using image too big for atlas
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 0, 0 ) );
-
- END_TEST;
-}
-
-// 1.5
-int UtcDaliAtlasUpload04(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 32, 32, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using valid offsets
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
-
- DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
- DALI_TEST_CHECK( atlas.Upload( image, 16, 0 ) );
- DALI_TEST_CHECK( atlas.Upload( image, 0, 16 ) );
- DALI_TEST_CHECK( atlas.Upload( image, 16, 16 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 0 ) );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 16, 0 ) );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 16 ) );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 16, 16 ) );
-
- END_TEST;
-}
-
-// 1.6
-int UtcDaliAtlasUpload05(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 32, 32, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using invalid offsets
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
-
- DALI_TEST_CHECK( !atlas.Upload( image, 0, 17 ) );
- DALI_TEST_CHECK( !atlas.Upload( image, 17, 0 ) );
- DALI_TEST_CHECK( !atlas.Upload( image, 17, 17 ) );
- DALI_TEST_CHECK( !atlas.Upload( image, 99, 0 ) );
- DALI_TEST_CHECK( !atlas.Upload( image, 0, 99 ) );
- DALI_TEST_CHECK( !atlas.Upload( image, 99, 99 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
-
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 0, 17 ) );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 17, 0 ) );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 17, 17 ) );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 99, 0 ) );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 0, 99 ) );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 99, 99 ) );
-
- END_TEST;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali/devel-api/animation/path-constrainer.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-using namespace Dali::Internal;
-
-namespace
-{
-
-static void SetupPath( Dali::Path& path)
-{
- path.AddPoint(Vector3( 30.0, 80.0, 0.0));
- path.AddPoint(Vector3( 70.0, 120.0, 0.0));
- path.AddPoint(Vector3(100.0, 100.0, 0.0));
-
- //Control points for first segment
- path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
- path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
-
- //Control points for second segment
- path.AddControlPoint(Vector3( 78.0, 120.0, 0.0) );
- path.AddControlPoint(Vector3( 93.0, 104.0, 0.0) );
-}
-
-static void SetupPathConstrainer( Dali::PathConstrainer& PathConstrainer)
-{
- PathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3(1.0f,0.0f,0.0f) );
-
- Dali::Property::Array points;
- points.Resize(3);
- points[0] = Vector3( 30.0, 80.0, 0.0);
- points[1] = Vector3( 70.0, 120.0, 0.0);
- points[2] = Vector3(100.0, 100.0, 0.0);
- PathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points );
-
- points.Resize(4);
- points[0] = Vector3( 39.0, 90.0, 0.0);
- points[1] = Vector3( 56.0, 119.0, 0.0);
- points[2] = Vector3( 78.0, 120.0, 0.0);
- points[3] = Vector3( 93.0, 104.0, 0.0);
- PathConstrainer.SetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS, points );
-}
-
-static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer)
-{
- Dali::Property::Array points;
- points.Resize(3);
- points[0] = 0.0f;
- points[1] = 1.0f;
- points[2] = 0.0f;
- linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
-}
-
-static void SetupLinearConstrainerNonUniformProgress( Dali::LinearConstrainer& linearConstrainer)
-{
- Dali::Property::Array points;
- points.Resize(3);
- points[0] = 0.0f;
- points[1] = 1.0f;
- points[2] = 0.0f;
- linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
-
- points[0] = 0.0f;
- points[1] = 0.25f;
- points[2] = 1.0f;
- linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::PROGRESS, points );
-}
-
-} // anonymous namespace
-
-//PathConstrainer test cases
-int UtcPathConstrainerApply(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
-
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a Path
- Dali::Path path = Dali::Path::New();
- SetupPath(path);
-
- //Create a PathConstrainer
- Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
- SetupPathConstrainer( pathConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
-
- //Create an animation to animate the custom property
- float durationSeconds(1.0f);
- Dali::Animation animation = Dali::Animation::New(durationSeconds);
- animation.AnimateTo(Dali::Property(actor,index),1.0f);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
-
- Vector3 position, tangent;
- path.Sample(0.2f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
- path.Sample(0.4f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
- path.Sample(0.6f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
- path.Sample(0.8f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
- path.Sample(1.0f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* beyond the animation duration*/);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcPathConstrainerApplyRange(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a Path
- Dali::Path path = Dali::Path::New();
- SetupPath(path);
-
- //Create a PathConstrainer
- Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
- SetupPathConstrainer( pathConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 100.0f, 300.0f );
- pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
-
-
- //Create an animation to animate the custom property
- float durationSeconds(1.0f);
- Dali::Animation animation = Dali::Animation::New(durationSeconds);
- animation.AnimateTo(Dali::Property(actor,index),400.0f);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
-
- Vector3 position, tangent;
- float tValue;
- actor.GetProperty(index).Get(tValue);
- float currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- actor.GetProperty(index).Get(tValue);
- currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- path.Sample(0.5, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- actor.GetProperty(index).Get(tValue);
- currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- actor.GetProperty(index).Get(tValue);
- currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
- actor.GetProperty(index).Get(tValue);
- currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcPathConstrainerDestroy(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- {
- //Create a Path
- Dali::Path path = Dali::Path::New();
- SetupPath(path);
-
- //Create a PathConstrainer
- Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
- SetupPathConstrainer( pathConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
-
- //Test that the constraint is correctly applied
- actor.SetProperty(index,0.5f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- Vector3 position, tangent;
- path.Sample(0.5f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- }
-
- //PathConstrainer has been destroyed. Constraint in the actor should have been removed
- actor.SetProperty(index,0.75f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcPathConstrainerRemove(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a Path
- Dali::Path path = Dali::Path::New();
- SetupPath(path);
-
- //Create a PathConstrainer
- Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
- SetupPathConstrainer( pathConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
-
- //Test that the constraint is correctly applied
- actor.SetProperty(index,0.5f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- Vector3 position, tangent;
- path.Sample(0.5f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- //Remove constraint
- pathConstrainer.Remove( actor );
- actor.SetProperty(index,0.75f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
-
- END_TEST;
-}
-
-//LinearConstrainer test cases
-int UtcLinearConstrainerDownCast(void)
-{
- TestApplication application;
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
-
- BaseHandle handle( linearConstrainer );
- Dali::LinearConstrainer linearConstrainer2 = Dali::LinearConstrainer::DownCast( handle );
- DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
-
- BaseHandle handle2;
- Dali:: LinearConstrainer linearConstrainer3 = Dali::LinearConstrainer::DownCast( handle2 );
- DALI_TEST_EQUALS( (bool)linearConstrainer3, false, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerCopyConstructor(void)
-{
- TestApplication application;
- Dali::LinearConstrainer linearConstrainer;
- DALI_TEST_EQUALS( (bool)linearConstrainer, false, TEST_LOCATION );
-
- linearConstrainer = Dali::LinearConstrainer::New();
- DALI_TEST_EQUALS( (bool)linearConstrainer, true, TEST_LOCATION );
-
- // call the copy constructor
- Dali::LinearConstrainer linearConstrainer2( linearConstrainer );
- DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerApply(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
-
- Dali::Stage::GetCurrent().Add(actor);
-
-
- //Create a LinearConstrainer without specifying progress for values
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
- SetupLinearConstrainerUniformProgress( linearConstrainer );
-
- //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
- //Create an animation to animate the custom property
- float durationSeconds(1.0f);
- Dali::Animation animation = Dali::Animation::New(durationSeconds);
- animation.AnimateTo(Dali::Property(actor,index),1.0f);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- //Setup a LinearConstrainer specifying the progress for each value
- linearConstrainer.Remove(actor);
- SetupLinearConstrainerNonUniformProgress( linearConstrainer );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
- actor.SetProperty(index,0.0f);
- animation.Play();
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 2.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerApplyRange(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 100.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a LinearConstrainer
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
- SetupLinearConstrainerUniformProgress( linearConstrainer );
-
- //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 100.0f, 300.0f );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
-
- //Create an animation to animate the custom property
- float durationSeconds(1.0f);
- Dali::Animation animation = Dali::Animation::New(durationSeconds);
- animation.AnimateTo(Dali::Property(actor,index),300.0f);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerDestroy(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- {
- //Create a LinearConstrainer
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
- SetupLinearConstrainerUniformProgress( linearConstrainer );
-
- //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
- //Test that the constraint is correctly applied
- actor.SetProperty(index,0.5f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- }
-
- //LinearConstrainer has been destroyed. Constraint in the actor should have been removed
- actor.SetProperty(index,0.75f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerRemove(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a LinearConstrainer
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
- SetupLinearConstrainerUniformProgress( linearConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
- //Test that the constraint is correctly applied
- actor.SetProperty(index,0.5f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- //Remove constraint
- linearConstrainer.Remove( actor );
- actor.SetProperty(index,0.75f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali/devel-api/actors/mesh-actor.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-#include "mesh-builder.h"
-
-
-namespace
-{
-// Size of the VertexAttributeArray enables
-// GLES specification states that there's minimum of
-const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8;
-
-enum TestAttribType
-{
- ATTRIB_UNKNOWN = -1,
- ATTRIB_POSITION,
- ATTRIB_NORMAL,
- ATTRIB_TEXCOORD,
- ATTRIB_COLOR,
- ATTRIB_BONE_WEIGHTS,
- ATTRIB_BONE_INDICES,
- ATTRIB_TYPE_LAST
-};
-
-// Create bitmap image
-static BufferImage CreateBufferImage()
-{
- BufferImage image = BufferImage::New(4,4,Pixel::RGBA8888);
-
- return image;
-}
-
-static MeshActor CreateMeshActor()
-{
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
- meshData.SetHasNormals(true);
- meshData.SetHasTextureCoords(true);
-
- Mesh mesh = Mesh::New(meshData);
- MeshActor actor = MeshActor::New(mesh);
-
- actor.SetName("Test MeshActor");
-
- return actor;
-}
-
-
-static ImageActor CreateImageActor()
-{
- BufferImage image = CreateBufferImage();
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetName("Test ImageActor");
- return actor;
-}
-
-} // anonymous namespace
-
-
-// Positive test case for a method
-int UtcDaliContextVertexAttribStartup(void)
-{
- tet_infoline("Testing vertex attrib initial state in context");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // context class should initially set the vertex attrib locations to disable
- // Make sure it has been modified
- DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
-
- // check the locations
- for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
- {
- DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(i) == false);
- }
-
- tet_result(TET_PASS);
- END_TEST;
-}
-
-// Tests to make the attribs only get set once when continually rendering an image actor
-int UtcDaliContextVertexAttribImageRendering(void)
-{
- tet_infoline("Testing vertex attrib rendering state in context with images");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // the vertex attribs get modified on startup to set them to disabled
- // clear the flag to say they've changed
- application.GetGlAbstraction().ClearVertexAttribArrayChanged();
-
-
- // create a test image actor
- ImageActor imageActor(CreateImageActor());
- Stage::GetCurrent().Add(imageActor);
-
-
- application.SendNotification();
- application.Render();
- application.Render();
-
- // check to make sure the state has changed (the image renderer will enable some
- // locations).
- DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
-
- // Now check to make sure the state is cached, and isn't being set each frame.
- application.GetGlAbstraction().ClearVertexAttribArrayChanged();
-
- application.Render();
- application.Render();
- application.Render();
-
- // if it has changed then the caching has failed
- DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false);
-
-
- tet_result(TET_PASS);
- END_TEST;
-}
-
-// test to make sure the attribs change when rendering both image and mode actors
-int UtcDaliContextVertexAttribImageAndModelRendering(void)
-{
- tet_infoline("Testing vertex attrib rendering state in context with images and models");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // the vertex attribs get modified on startup to set them to disabled
- // clear the flag to say they've changed
- application.GetGlAbstraction().ClearVertexAttribArrayChanged();
-
- // create a test image and mesh actor.
-
- MeshActor meshActor(CreateMeshActor());
- Stage::GetCurrent().Add(meshActor);
-
- ImageActor imageActor(CreateImageActor());
- Stage::GetCurrent().Add(imageActor);
-
-
- application.SendNotification();
- application.Render();
- application.Render();
-
- // check to make sure the state changes during the rendering of a frame
- DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
-
- // Now check to make sure the state is changing each frame.
- application.GetGlAbstraction().ClearVertexAttribArrayChanged();
-
- application.Render();
- application.Render();
- application.Render();
-
- // make sure the state has changed
- DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
-
- // depending on the order of drawing, one of the attrib locations should be disabled
- // Image uses locations 0 & 2 (position, texture)
- // Model uses locations 0 & 1 (position, normals) -no textures
- // so either location 1 or location 2 should be disabled after drawing.
-
- // see if mesh was last to draw
- if (application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_NORMAL))
- {
- // texture should be disabled
- DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_TEXCOORD) == false)
- }
- else
- {
- // image was to draw so, normals should be disabled
- DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_NORMAL) == false)
- }
-
- tet_result(TET_PASS);
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <algorithm>
-
-#include <stdlib.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/images/distance-field.h>
-#include <dali-test-suite-utils.h>
-
-using std::max;
-using namespace Dali;
-
-namespace
-{
-
-static const float ROTATION_EPSILON = 0.0001f;
-
-static unsigned char sourceImage[] =
-{
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-} // anonymous namespace
-
-
-
-int UtcDaliGenerateDistanceField(void)
-{
- unsigned char distanceField[4*4];
-
- GenerateDistanceFieldMap(sourceImage, Size(8.0f, 8.0f), distanceField, Size(4.0f, 4.0f), 0, Size(4.0f, 4.0f));
-
- if(distanceField[0] <= distanceField[5] &&
- distanceField[5] <= distanceField[10] &&
- distanceField[10] <= distanceField[15])
- {
- tet_result(TET_PASS);
- }
- else
- {
- tet_result(TET_FAIL);
- }
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-#include <dali/devel-api/dynamics/dynamics.h>
-
-int UtcDaliDynamicsBodyConstructor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConstructor - DynamicsBody::DynamicsBody()");
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // Default constructor - create an uninitialized handle
- DynamicsBody body;
- DALI_TEST_CHECK( !body );
-
- // create world and actor
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- // initialize handle
- body = actor.GetDynamicsBody();
-
- DALI_TEST_CHECK( body );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyGetMass(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testMass = 1.23f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- bodyConfig.SetMass(testMass);
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- tet_infoline("UtcDaliDynamicsBodyGetMass - DynamicsBody::GetMass");
- DALI_TEST_EQUALS( testMass, actor.GetDynamicsBody().GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyGetElasticity(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testElasticity = 1.23f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- bodyConfig.SetElasticity(testElasticity);
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- tet_infoline("UtcDaliDynamicsBodyGetMass - DynamicsBody::GetElasticity");
- DALI_TEST_EQUALS( testElasticity, actor.GetDynamicsBody().GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodySetLinearVelocity(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodySetLinearVelocity - DynamicsBody::SetLinearVelocity");
-
- TestApplication application;
- TraceCallStack& trace( application.GetPlatform().GetTrace() );
- trace.Enable( true );
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
- body.SetLinearVelocity(Vector3::ONE);
-
- DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetLinearVelocity" ) );
-
- // update
- application.SendNotification();
- application.Render();
- application.Render();
-
- DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetLinearVelocity" ) );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodySetAngularVelocity(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodySetAngularVelocity - DynamicsBody::SetAngularVelocity");
-
- TestApplication application;
- TraceCallStack& trace( application.GetPlatform().GetTrace() );
- trace.Enable( true );
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
- body.SetAngularVelocity(Vector3::ONE);
-
- DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetAngularVelocity" ) );
-
- // update
- application.SendNotification();
- application.Render();
- application.Render();
-
- DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetAngularVelocity" ) );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodySetKinematic(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testMass = 1.0f;
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- bodyConfig.SetMass(testMass);
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
-
- DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::SetKinematic(true)");
- body.SetKinematic(true);
-
- DALI_TEST_CHECK( body.IsKinematic() );
- DALI_TEST_EQUALS( 0.0f, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::SetKinematic(false)");
- body.SetKinematic(false);
- DALI_TEST_CHECK( !body.IsKinematic() );
- DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyIsKinematic(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testMass = 1.0f;
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- bodyConfig.SetMass(testMass);
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
-
- DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::IsSetKinematic");
- body.SetKinematic(true);
-
- DALI_TEST_CHECK( body.IsKinematic() );
- body.SetKinematic(false);
- DALI_TEST_CHECK( !body.IsKinematic() );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodySetSleepEnabled(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodySetSleepEnabled");
-
- TestApplication application;
- TraceCallStack& trace( application.GetPlatform().GetTrace() );
- trace.Enable( true );
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
-
- // SleepEnabled true by default
- DALI_TEST_CHECK( body.GetSleepEnabled() );
- body.SetSleepEnabled(false);
-
- DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetSleepEnabled" ) );
-
- // update
- application.SendNotification();
- application.Render();
- application.Render();
-
- DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetSleepEnabled" ) );
-
- DALI_TEST_CHECK( ! body.GetSleepEnabled() );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyGetSleepEnabled(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyGetSleepEnabled");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
-
- // SleepEnabled true by default
- DALI_TEST_CHECK( body.GetSleepEnabled() );
- body.SetSleepEnabled(false);
- DALI_TEST_CHECK( !body.GetSleepEnabled() );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyWakeUp(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyWakeUp");
-
- TestApplication application;
- TraceCallStack& trace( application.GetPlatform().GetTrace() );
- trace.Enable( true );
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
-
- body.WakeUp();
-
- DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::WakeUp" ) );
-
- // update
- application.SendNotification();
- application.Render();
- application.Render();
-
- DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::WakeUp" ) );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyAddAnchor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyAddAnchor - DynamicsBody::AddAnchor()");
-
- TestApplication application;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- worldConfig.SetType(DynamicsWorldConfig::SOFT);
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- Actor rootActor(Actor::New());
- world.SetRootActor(rootActor);
- Stage::GetCurrent().Add(rootActor);
-
- DynamicsBodyConfig softConfig( DynamicsBodyConfig::New() );
- softConfig.SetType(DynamicsBodyConfig::SOFT);
- Cloth mesh(Cloth::New(10.0f, 10.0f, 10, 10));
- DynamicsShape meshShape(DynamicsShape::NewMesh(mesh));
- softConfig.SetShape( meshShape );
- softConfig.SetMass(1.0f);
- MeshActor softActor(MeshActor::New(mesh));
-
- rootActor.Add(softActor);
- softActor.EnableDynamics(softConfig);
- DynamicsBody softBody(softActor.GetDynamicsBody());
-
- DynamicsBodyConfig anchorConfig(DynamicsBodyConfig::New());
- anchorConfig.SetMass(0.0f);
- Actor anchor(Actor::New());
- rootActor.Add(anchor);
- anchor.EnableDynamics(anchorConfig);
- DynamicsBody anchorBody(anchor.GetDynamicsBody());
- anchorBody.SetKinematic(true);
- try
- {
- softBody.AddAnchor(0, anchorBody, false);
-
- DALI_TEST_CHECK(true)
- }
- catch(Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK( false );
- }
-
- rootActor.Remove(softActor);
- rootActor.Remove(anchor);
- Stage::GetCurrent().Remove(rootActor);
- softActor.DisableDynamics();
- anchor.DisableDynamics();
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConserveVolume(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConserveVolume");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
-
- body.ConserveVolume(false);
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConserveShape(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConserveShape");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor(Actor::New());
-
- // enable dynamics on the actor to create the Dynamicsbody
- actor.EnableDynamics(bodyConfig);
-
- DynamicsBody body(actor.GetDynamicsBody());
-
- body.ConserveShape(false);
- DALI_TEST_CHECK( true );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-#include <dali/devel-api/dynamics/dynamics.h>
-
-using namespace Dali;
-
-
-int UtcDaliDynamicsBodyConfigNew(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
-
- tet_infoline("UtcDaliDynamicsBodyConfigNew - DynamicsBodyConfig::New()");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
-
- DALI_TEST_CHECK( config );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigConstructor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConfigConstructor - DynamicsBodyConfig::DynamicsBodyConfig()");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // Default constructor - create an uninitialized handle
- DynamicsBodyConfig config;
-
- DALI_TEST_CHECK( !config );
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- // initialize handle
- config = DynamicsBodyConfig::New();
-
- DALI_TEST_CHECK( config );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigType(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
-
- tet_infoline("UtcDaliDynamicsBodyConfigType - DynamicsBodyConfig::GetType");
- DALI_TEST_CHECK( DynamicsBodyConfig::RIGID == config.GetType() );
-
- tet_infoline("UtcDaliDynamicsBodyConfigType - DynamicsBodyConfig::SetType(const BodyType)");
- config.SetType( DynamicsBodyConfig::SOFT );
- DALI_TEST_CHECK( DynamicsBodyConfig::SOFT == config.GetType() );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigSetShape01(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConfigSetShape01 - DynamicsBodyConfig::SetShape(const DynamicsShape::ShapeType,const Vector3&)");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
-
- DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
-
- const float radius(1.5f);
- config.SetShape(DynamicsShape::SPHERE, Vector3(radius, 0.0f, 0.0f));
-
- DALI_TEST_CHECK( DynamicsShape::SPHERE == config.GetShape().GetType() );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigSetShape02(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConfigSetShape02 - DynamicsBodyConfig::SetShape(DynamicsShape)");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
-
- DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
-
- const float radius(1.5f);
- DynamicsShape shape(DynamicsShape::NewSphere(radius));
- config.SetShape(shape);
-
- DALI_TEST_CHECK( DynamicsShape::SPHERE == config.GetShape().GetType() );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigGetShape(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConfigGetShape - DynamicsBodyConfig::GetShape");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
-
- DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigMass(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testMass = 1.23f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetMass(testMass);
-
- tet_infoline("UtcDaliDynamicsBodyConfigMass - DynamicsBodyConfig::GetMass");
- DALI_TEST_EQUALS( testMass, config.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigMass - DynamicsBodyConfig::SetMass");
- const float mass = config.GetMass() + 0.1f;
- config.SetMass(mass);
- DALI_TEST_EQUALS( mass, config.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigElasticity(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testElasticity = 0.87f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetElasticity(testElasticity);
-
- tet_infoline("UtcDaliDynamicsBodyConfigElasticity- DynamicsBodyConfig::GetElasticity");
- DALI_TEST_EQUALS( testElasticity, config.GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigElasticity - DynamicsBodyConfig::SetElasticity");
- const float elasticity = config.GetElasticity() + 0.1f;
- config.SetElasticity(elasticity);
- DALI_TEST_EQUALS( elasticity, config.GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigFriction(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testFriction= 0.87f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetFriction(testFriction);
-
- tet_infoline("UtcDaliDynamicsBodyConfigFriction - DynamicsBodyConfig::GetFriction");
- DALI_TEST_EQUALS( testFriction, config.GetFriction(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigFriction - DynamicsBodyConfig::SetFriction");
- const float friction = config.GetFriction() + 0.1f;
- config.SetFriction(friction);
- DALI_TEST_EQUALS( friction, config.GetFriction(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigLinearDamping(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testDamping = 0.123f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetLinearDamping(testDamping);
-
- tet_infoline("UtcDaliDynamicsBodyConfigLinearDamping- DynamicsBodyConfig::GetLinearDamping");
- DALI_TEST_EQUALS( testDamping, config.GetLinearDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigLinearDamping - DynamicsBodyConfig::SetLinearDamping");
- const float damping = config.GetLinearDamping() + 0.1f;
- config.SetLinearDamping(damping);
- DALI_TEST_EQUALS( damping, config.GetLinearDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigAngularDamping(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testDamping = 0.123f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetAngularDamping(testDamping);
-
- tet_infoline("UtcDaliDynamicsBodyConfigAngularDamping- DynamicsBodyConfig::GetAngularDamping");
- DALI_TEST_EQUALS( testDamping, config.GetAngularDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigAngularDamping - DynamicsBodyConfig::SetAngularDamping");
- const float damping = config.GetAngularDamping() + 0.1f;
- config.SetAngularDamping(damping);
- DALI_TEST_EQUALS( damping, config.GetAngularDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigLinearSleepVelocity(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testSleepVelocity = 0.123f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetLinearSleepVelocity(testSleepVelocity);
-
- tet_infoline("UtcDaliDynamicsBodyConfigLinearSleepVelocity - DynamicsBodyConfig::GetLinearSleepVelocity");
- DALI_TEST_EQUALS( testSleepVelocity, config.GetLinearSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigLinearSleepVelocity - DynamicsBodyConfig::SetLinearSleepVelocity");
- const float sleepVelocity = config.GetLinearSleepVelocity() + 0.1f;
- config.SetLinearSleepVelocity(sleepVelocity);
- DALI_TEST_EQUALS( sleepVelocity, config.GetLinearSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigAngularSleepVelocity(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testSleepVelocity = 0.123f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetAngularSleepVelocity(testSleepVelocity);
-
- tet_infoline("UtcDaliDynamicsBodyConfigAngularSleepVelocity - DynamicsBodyConfig::GetAngularSleepVelocity");
- DALI_TEST_EQUALS( testSleepVelocity, config.GetAngularSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigAngularSleepVelocity - DynamicsBodyConfig::SetAngularSleepVelocity");
- const float sleepVelocity = config.GetAngularSleepVelocity() + 0.1f;
- config.SetAngularSleepVelocity(sleepVelocity);
- DALI_TEST_EQUALS( sleepVelocity, config.GetAngularSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigCollisionGroup(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const short int testGroup = 0x1234;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetCollisionGroup(testGroup);
-
- tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup- DynamicsBodyConfig::GetCollisionGroup");
- DALI_TEST_EQUALS( testGroup, config.GetCollisionGroup(), TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup - DynamicsBodyConfig::SetCollisionGroup");
- const short int group = config.GetCollisionGroup() + 1;
- config.SetCollisionGroup(group);
- DALI_TEST_EQUALS( group, config.GetCollisionGroup(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigCollisionMask(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const short int testMask = 0x7ffe;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetCollisionMask(testMask);
-
- tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask- DynamicsBodyConfig::GetCollisionMask");
- DALI_TEST_EQUALS( testMask, config.GetCollisionMask(), TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask - DynamicsBodyConfig::SetCollisionMask");
- const short int mask = config.GetCollisionMask() + 1;
- config.SetCollisionMask(mask);
- DALI_TEST_EQUALS( mask, config.GetCollisionMask(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigAnchorHardness(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const float testHardness = 0.87f;
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
- config.SetAnchorHardness(testHardness);
-
- tet_infoline("UtcDaliDynamicsBodyConfigAnchorHardness - DynamicsBodyConfig::GetAnchorHardness");
- DALI_TEST_EQUALS( testHardness, config.GetAnchorHardness(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
-
- tet_infoline("UtcDaliDynamicsBodyConfigAnchorHardness - DynamicsBodyConfig::SetAnchorHardness");
- const float hardness = config.GetAnchorHardness() + 0.1f;
- config.SetAnchorHardness(hardness);
- DALI_TEST_EQUALS( hardness, config.GetAnchorHardness(), Math::MACHINE_EPSILON_1, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigVolumeConservation(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConfigVolumeConservation");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
-
- const float conservation = config.GetVolumeConservation() + 0.1f;
- config.SetVolumeConservation(conservation);
- DALI_TEST_EQUALS( conservation, config.GetVolumeConservation(), Math::MACHINE_EPSILON_1, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDynamicsBodyConfigShapeConservation(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsBodyConfigShapeConservation");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig config(DynamicsBodyConfig::New());
-
- const float conservation = config.GetShapeConservation() + 0.1f;
- config.SetShapeConservation(conservation);
- DALI_TEST_EQUALS( conservation, config.GetShapeConservation(), Math::MACHINE_EPSILON_1, TEST_LOCATION );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-#include <dali/devel-api/dynamics/dynamics.h>
-
-using namespace Dali;
-
-
-int UtcDaliDynamicsJointConstructor(void)
-{
- tet_infoline("UtcDaliDynamicsJointConstructor - DynamicsJoint::DynamicsJoint");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsJoint joint;
-
- DALI_TEST_CHECK( !joint );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointLinearLimit(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- if( joint )
- {
- tet_infoline("UtcDaliDynamicsJointLinearLimit - DynamicsJoint::SetLinearLimit()");
- joint.SetLinearLimit(DynamicsJoint::LINEAR_X, 0.0f, 1.0f);
- }
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointAngularLimit(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- tet_infoline("UtcDaliDynamicsJointAngularLimit - DynamicsJoint::SetAngularLimit()");
- joint.SetAngularLimit(DynamicsJoint::ANGULAR_X, Degree(0.0f), Degree(1.0f) );
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointEnableSpring(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- tet_infoline("UtcDaliDynamicsJointEnableSpring");
- joint.EnableSpring(DynamicsJoint::LINEAR_X, true );
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointSetSpringStiffness(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- tet_infoline("UtcDaliDynamicsJointSetSpringStiffness");
- joint.SetSpringStiffness(DynamicsJoint::LINEAR_X, 1.0f );
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointSetSpringCenterPoint(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- tet_infoline("UtcDaliDynamicsJointSetSpringCenterPoint");
- joint.SetSpringCenterPoint(DynamicsJoint::LINEAR_X, 0.5f );
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointEnableMotor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- tet_infoline("UtcDaliDynamicsJointEnableMotor");
- joint.EnableMotor(DynamicsJoint::LINEAR_X, true );
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointSetMotorVelocity(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- tet_infoline("UtcDaliDynamicsJointSetMotorVelocity");
- joint.SetMotorVelocity(DynamicsJoint::LINEAR_X, 1.0f );
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointSetMotorForce(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- tet_infoline("UtcDaliDynamicsJointSetMotorForce");
- joint.SetMotorForce(DynamicsJoint::LINEAR_X, 0.5f );
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-int UtcDaliDynamicsJointGetActor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
- Actor actor1(Actor::New());
- actor1.EnableDynamics(bodyConfig);
- Actor actor2(Actor::New());
- actor2.EnableDynamics(bodyConfig);
-
- DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
-
- tet_infoline("UtcDaliDynamicsJointGetActor");
- DALI_TEST_CHECK( joint.GetActor(true) == actor1 && joint.GetActor(false) == actor2 );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-#include <dali/devel-api/dynamics/dynamics.h>
-
-using namespace Dali;
-
-
-int UtcDaliDynamicsShapeConstructor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsShapeConstructor - DynamicsShape::DynamicsShape");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( world )
- {
-
- // Default constructor - create an uninitialized handle
- DynamicsShape shape;
- DALI_TEST_CHECK( !shape );
-
- // initialize handle
- shape = DynamicsShape::NewCube(Vector3::ONE);
-
- DALI_TEST_CHECK( shape );
- }
- else
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- }
-
- END_TEST;
-}
-
-int UtcDaliDynamicsShapeNewCapsule(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsShapeNewCapsule - DynamicsShape::NewCapsule");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( world )
- {
-
- DynamicsShape shape( DynamicsShape::NewCapsule( 1.0f, 2.0f ) );
-
- DALI_TEST_CHECK( shape );
- DALI_TEST_CHECK( DynamicsShape::CAPSULE == shape.GetType() );
- }
- else
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- }
-
- END_TEST;
-}
-
-int UtcDaliDynamicsShapeNewCone(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsShapeNewCone - DynamicsShape::NewCone");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( world )
- {
- DynamicsShape shape( DynamicsShape::NewCone( 1.0f, 2.0f ) );
-
- DALI_TEST_CHECK( shape );
- DALI_TEST_CHECK( DynamicsShape::CONE == shape.GetType() );
- }
- else
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- }
-
- END_TEST;
-}
-
-int UtcDaliDynamicsShapeNewCube(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsShapeNewCube - DynamicsShape::NewCube");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( world )
- {
- DynamicsShape shape( DynamicsShape::NewCube( Vector3::ONE ) );
-
- DALI_TEST_CHECK( shape );
- DALI_TEST_CHECK( DynamicsShape::CUBE == shape.GetType() );
- }
- else
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- }
- END_TEST;
-}
-
-int UtcDaliDynamicsShapeNewCylinder(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsShapeNewCylinder - DynamicsShape::NewCylinder");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( world )
- {
- DynamicsShape shape( DynamicsShape::NewCylinder( 1.0f, 2.0f ) );
-
- DALI_TEST_CHECK( shape );
- DALI_TEST_CHECK( DynamicsShape::CYLINDER == shape.GetType() );
- }
- else
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- }
- END_TEST;
-}
-
-int UtcDaliDynamicsShapeNewMesh(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsShapeNewMesh - DynamicsShape::NewMesh");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( world )
- {
- DynamicsShape shape( DynamicsShape::NewMesh( Cloth::New(10.0f, 10.0f, 10, 10)) );
-
- DALI_TEST_CHECK( shape );
- DALI_TEST_CHECK( DynamicsShape::MESH == shape.GetType() );
- }
- else
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- }
- END_TEST;
-}
-
-int UtcDaliDynamicsShapeNewSphere(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsShapeNewSphere - DynamicsShape::NewSphere");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( world )
- {
- DynamicsShape shape( DynamicsShape::NewSphere( 1.0f ) );
-
- DALI_TEST_CHECK( shape );
- DALI_TEST_CHECK( DynamicsShape::SPHERE == shape.GetType() );
- }
- else
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- }
- END_TEST;
-}
-
-int UtcDaliDynamicsShapeGetType(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsShapeGetType - DynamicsShape::GetType");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( world )
- {
- DynamicsShape shape( DynamicsShape::NewSphere( 1.0f ) );
-
- DALI_TEST_CHECK( shape );
- DALI_TEST_CHECK( DynamicsShape::SPHERE == shape.GetType() );
- }
- else
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- }
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-#include <test-dynamics.h>
-#include <dali/devel-api/dynamics/dynamics.h>
-
-using namespace Dali;
-
-int UtcDaliStageInitializeDynamics(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- Stage stage = Stage::GetCurrent();
- TraceCallStack& trace = application.GetPlatform().GetTrace();
- trace.Enable(true);
- DALI_TEST_CHECK( stage.InitializeDynamics( DynamicsWorldConfig::New() ) );
- DALI_TEST_CHECK( trace.FindMethod( "GetDynamicsFactory" ) );
- DALI_TEST_CHECK( trace.FindMethod( "DynamicsFactory::InitializeDynamics" ) );
- END_TEST;
-}
-
-int UtcDaliStageGetDynamicsWorld(void)
-{
- TestApplication application;
-
- Stage stage = Stage::GetCurrent();
-
- DALI_TEST_CHECK( !stage.GetDynamicsWorld() );
- END_TEST;
-}
-
-int UtcDaliStageTerminateDynamics(void)
-{
- TestApplication application;
-
- Stage stage = Stage::GetCurrent();
-
- stage.TerminateDynamics();
-
- DALI_TEST_CHECK( !stage.GetDynamicsWorld() );
- END_TEST;
-}
-
-int UtcDaliDynamicsWorldConstructor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsWorldConstructor - DynamicsWorld::DynamicsWorld");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // Default constructor - create an uninitialized handle
- DynamicsWorld world;
- DALI_TEST_CHECK( !world );
-
- // initialize handle
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- world = Stage::GetCurrent().InitializeDynamics(worldConfig);
-
- DALI_TEST_CHECK( world );
- END_TEST;
-}
-
-int UtcDaliDynamicsWorldGravity(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
- TraceCallStack& trace( application.GetPlatform().GetTrace() );
- trace.Enable( true );
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const Vector3 gravity(1.0f, 2.0f, 3.0f);
-
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- tet_infoline("UtcDaliDynamicsWorldGravity - DynamicsWorld::SetGravity");
- world.SetGravity(gravity);
-
- // update
- application.SendNotification();
- application.Render();
- application.Render();
-
- DALI_TEST_CHECK( trace.FindMethod( "DynamicsWorld::SetGravity" ) );
-
- tet_infoline("UtcDaliDynamicsWorldGravity - DynamicsWorld::GetGravity");
- DALI_TEST_EQUALS(gravity, world.GetGravity(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliDynamicsWorldDebugDrawMode(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
- TraceCallStack& trace( application.GetPlatform().GetTrace() );
- trace.Enable( true );
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const Vector3 gravity(1.0f, 2.0f, 3.0f);
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- const int mode(DynamicsWorld::DEBUG_MODE_WIREFRAME | DynamicsWorld::DEBUG_MODE_AABB);
-
- tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::SetDebugDrawMode");
- world.SetDebugDrawMode(mode);
-
- // update
- application.SendNotification();
- application.Render();
- application.Render();
-
- DALI_TEST_CHECK( trace.FindMethod( "DynamicsWorld::SetDebugDrawMode" ) );
-
- tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::GetDebugDrawMode");
- DALI_TEST_CHECK(mode == world.GetDebugDrawMode());
- END_TEST;
-}
-
-int UtcDaliDynamicsWorldRootActor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- const Vector3 gravity(1.0f, 2.0f, 3.0f);
- DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
- DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
-
- if( !world )
- {
- // cannot create dynamics world, log failure and exit
- DALI_TEST_CHECK( false );
- END_TEST;
- }
-
- Actor rootActor(Actor::New());
-
- tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::GetRootActor");
- Actor actor(world.GetRootActor());
- DALI_TEST_CHECK( !actor );
-
- tet_infoline("UtcDaliDynamicsWorldSetRootActor - DynamicsWorld::SetRootActor");
- world.SetRootActor(rootActor);
- DALI_TEST_CHECK(rootActor == world.GetRootActor());
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-#include <dali/devel-api/dynamics/dynamics.h>
-
-using namespace Dali;
-
-
-int UtcDaliDynamicsWorldConfigConstructor(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsWorldConfigConstructor - DynamicsWorldConfig::DynamicsWorldConfig");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // Default constructor - create an uninitialized handle
- DynamicsWorldConfig worldConfig;
- DALI_TEST_CHECK( !worldConfig );
-
- // initialize handle
- worldConfig = DynamicsWorldConfig::New();
-
- DALI_TEST_CHECK( worldConfig );
- END_TEST;
-}
-
-int UtcDaliDynamicsWorldConfigNew(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::New");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // Default constructor - create an uninitialized handle
- DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
-
- DALI_TEST_CHECK( worldConfig );
- END_TEST;
-}
-
-int UtcDaliDynamicsWorldConfigType(void)
-{
-#if !defined(DYNAMICS_SUPPORT)
- tet_infoline("No dynamics support compiled\n");
- return 0;
-#endif
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // Default constructor - create an uninitialized handle
- DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
-
- tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::GetType");
- DALI_TEST_CHECK(DynamicsWorldConfig::RIGID == worldConfig.GetType());
-
- tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::SetType");
- worldConfig.SetType(DynamicsWorldConfig::SOFT);
- DALI_TEST_CHECK(DynamicsWorldConfig::SOFT == worldConfig.GetType());
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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 <string>
-#include <stdlib.h>
-#include <dali/devel-api/common/hash.h>
-#include <dali-test-suite-utils.h>
-
-void utc_dali_hash_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_hash_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliHash(void)
-{
- // To fully test the Hash distribution we need to use a tool like http://code.google.com/p/smhasher/
- // DALi currently uses the hash for variable length strings which come from:
- // shader vert+frag source, font family + style, image filename.
- TestApplication application;
-
- tet_infoline("UtcDaliHash");
-
- const std::string testString1( "highp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
- const std::string testString2( "lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
-
- DALI_TEST_CHECK( Dali::CalculateHash( testString1 ) != Dali::CalculateHash( testString2 ) );
- DALI_TEST_CHECK( Dali::CalculateHash( testString1, testString2 ) != Dali::CalculateHash( testString2, testString1 ) );
-
- END_TEST;
-}
-
-int UtcDaliHashNegative(void)
-{
- // negative test, check hash value == initial value
- const std::string emptyString;
-
- DALI_TEST_CHECK( Dali::CalculateHash( emptyString ) != 0 );
- DALI_TEST_CHECK( Dali::CalculateHash( emptyString, emptyString ) != 0 );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali/devel-api/events/hit-test-algorithm.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-namespace
-{
-
-/**
- * The functor to be used in the hit-test algorithm to check whether the actor is hittable.
- */
-bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
-{
- bool hittable = false;
-
- switch (type)
- {
- case Dali::HitTestAlgorithm::CHECK_ACTOR:
- {
- // Check whether the actor is visible and not fully transparent.
- if( actor.IsVisible()
- && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
- {
- // Check whether the actor has the specific name "HittableActor"
- if(actor.GetName() == "HittableActor")
- {
- hittable = true;
- }
- }
- break;
- }
- case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
- {
- if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
- {
- hittable = true;
- }
- break;
- }
- default:
- {
- break;
- }
- }
-
- return hittable;
-};
-
-
-bool DefaultIsActorTouchableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::TraverseType type)
-{
- bool hittable = false;
-
- switch (type)
- {
- case Dali::HitTestAlgorithm::CHECK_ACTOR:
- {
- if( actor.IsVisible() &&
- actor.IsSensitive() &&
- actor.GetCurrentWorldColor().a > 0.01f)
- {
- hittable = true;
- }
- break;
- }
- case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
- {
- if( actor.IsVisible() && // Actor is visible, if not visible then none of its children are visible.
- actor.IsSensitive()) // Actor is sensitive, if insensitive none of its children should be hittable either.
- {
- hittable = true;
- }
- break;
- }
- default:
- {
- break;
- }
- }
-
- return hittable;
-};
-
-} // anonymous namespace
-
-
-// Positive test case for a method
-int UtcDaliHitTestAlgorithmWithFunctor(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm functor");
-
- Stage stage = Stage::GetCurrent();
-
- Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- actor.SetName("NonHittableActor");
- stage.Add(actor);
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- Vector2 screenCoordinates( 10.0f, 10.0f );
- Vector2 localCoordinates;
- actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
-
- // Perform a hit-test at the given screen coordinates
- Dali::HitTestAlgorithm::Results results;
- Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor != actor );
-
- actor.SetName("HittableActor");
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
-
- // Perform a hit-test at the given screen coordinates
- Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor );
- DALI_TEST_EQUALS( localCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliHitTestAlgorithmWithFunctorOnRenderTask(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm functor, specific to a given render task");
-
- Stage stage = Stage::GetCurrent();
- Size stageSize = stage.GetSize();
- RenderTaskList taskList = stage.GetRenderTaskList();
-
- Actor actor[2];
-
- for( int i=0; i<2; i++ )
- {
- actor[i] = Actor::New();
- actor[i].SetSize(100.f, 100.f);
- actor[i].SetParentOrigin(ParentOrigin::TOP_LEFT);
- actor[i].SetAnchorPoint(AnchorPoint::TOP_LEFT);
- actor[i].SetName("HittableActor");
- stage.Add(actor[i]);
- }
- Vector2 position( 50.f, 40.f );
- actor[1].SetPosition( position.x, position.y );
-
- RenderTask renderTask[2];
- renderTask[0] = taskList.GetTask( 0u );
-
- FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width, stageSize.height, Pixel::A8, Image::NEVER);
- renderTask[1] = taskList.CreateTask();
- renderTask[1].SetSourceActor( actor[1] );
- renderTask[1].SetExclusive( true );
- renderTask[1].SetInputEnabled( true );
- renderTask[1].SetTargetFrameBuffer( frameBufferImage );
- renderTask[1].SetRefreshRate( RenderTask::REFRESH_ONCE );
- renderTask[1].SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
-
- // Render and notify
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- // Perform a hit-test at the given screen coordinates with different render tasks
-
- Dali::HitTestAlgorithm::Results results;
- Vector2 screenCoordinates( 25.f, 25.f );
-
- Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[0] );
- DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( !results.actor );
- DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- screenCoordinates.x = 80.f;
- screenCoordinates.y = 70.f;
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[0] );
- DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[1]);
- DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
-
- screenCoordinates.x = 120.f;
- screenCoordinates.y = 130.f;
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[1] );
- DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[1]);
- DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
- END_TEST;
-}
-
-
-int UtcDaliHitTestAlgorithmOrtho01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm with parallel Ortho camera()");
-
- Stage stage = Stage::GetCurrent();
- RenderTaskList renderTaskList = stage.GetRenderTaskList();
- RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
- Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
-
- Vector2 stageSize ( stage.GetSize() );
- cameraActor.SetOrthographicProjection( stageSize );
- cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
-
- Vector2 actorSize( stageSize * 0.5f );
- // Create two actors with half the size of the stage and set them to be partially overlapping
- Actor blue = Actor::New();
- blue.SetName( "Blue" );
- blue.SetAnchorPoint( AnchorPoint::CENTER );
- blue.SetParentOrigin( Vector3(1.0f/3.0f, 1.0f/3.0f, 0.5f) );
- blue.SetSize( actorSize );
- blue.SetZ(30.0f);
-
- Actor green = Actor::New( );
- green.SetName( "Green" );
- green.SetAnchorPoint( AnchorPoint::CENTER );
- green.SetParentOrigin( Vector3(2.0f/3.0f, 2.0f/3.0f, 0.5f) );
- green.SetSize( actorSize );
-
- // Add the actors to the view
- stage.Add( blue );
- stage.Add( green );
-
- // Render and notify
- application.SendNotification();
- application.Render(0);
- application.Render(10);
-
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == blue );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 5.0f/6.0f, TEST_LOCATION );
-
- HitTest(stage, stageSize / 3.0f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == blue );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
-
- HitTest(stage, stageSize * 2.0f / 3.0f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == green );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
- END_TEST;
-}
-
-
-int UtcDaliHitTestAlgorithmOrtho02(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm with offset Ortho camera()");
-
- Stage stage = Stage::GetCurrent();
- RenderTaskList renderTaskList = stage.GetRenderTaskList();
- RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
- Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
-
- Vector2 stageSize ( stage.GetSize() );
- cameraActor.SetOrthographicProjection(-stageSize.x * 0.3f, stageSize.x * 0.7f,
- stageSize.y * 0.3f, -stageSize.y * 0.7f,
- 800.0f, 4895.0f);
- cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
-
- Vector2 actorSize( stageSize * 0.5f );
- // Create two actors with half the size of the stage and set them to be partially overlapping
- Actor blue = Actor::New();
- blue.SetName( "Blue" );
- blue.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- blue.SetParentOrigin( Vector3(0.2f, 0.2f, 0.5f) );
- blue.SetSize( actorSize );
- blue.SetZ(30.0f);
-
- Actor green = Actor::New( );
- green.SetName( "Green" );
- green.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- green.SetParentOrigin( Vector3(0.4f, 0.4f, 0.5f) );
- green.SetSize( actorSize );
-
- // Add the actors to the view
- stage.Add( blue );
- stage.Add( green );
-
- // Render and notify
- application.SendNotification();
- application.Render(0);
- application.Render(10);
-
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == green );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.6f, 0.01f, TEST_LOCATION );
- }
-
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 0.001f, 0.001f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == blue );
- DALI_TEST_EQUALS( results.actorCoordinates, Vector2( 0.001f, 0.001f ), 0.001f, TEST_LOCATION );
- }
-
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, stageSize, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( ! results.actor );
- DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION );
- }
-
- // Just inside green
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, stageSize*0.69f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == green );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.98f, 0.01f, TEST_LOCATION );
- }
-
- END_TEST;
-}
-
-int UtcDaliHitTestAlgorithmStencil(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm with a stencil");
-
- Stage stage = Stage::GetCurrent();
- Actor rootLayer = stage.GetRootLayer();
- rootLayer.SetName( "RootLayer" );
-
- // Create a layer
- Layer layer = Layer::New();
- layer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- layer.SetParentOrigin( ParentOrigin::TOP_LEFT );
- layer.SetName( "layer" );
- stage.Add( layer );
-
- // Create a stencil and add that to the layer
- Actor stencil = ImageActor::New(Dali::BufferImage::WHITE() );
- stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- stencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
- stencil.SetSize( 50.0f, 50.0f );
- stencil.SetDrawMode( DrawMode::STENCIL );
- stencil.SetName( "stencil" );
- layer.Add( stencil );
-
- // Create a renderable actor and add that to the layer
- Actor layerHitActor = ImageActor::New();
- layerHitActor.SetSize( 100.0f, 100.0f );
- layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- layerHitActor.SetName( "layerHitActor" );
- layer.Add( layerHitActor );
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- // Hit within stencil and actor
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 10.0f, 10.0f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == layerHitActor );
- tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
- }
-
- // Hit within actor but outside of stencil, should hit the root-layer
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 60.0f, 60.0f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == rootLayer );
- tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
- }
- END_TEST;
-}
#include <stdlib.h>
#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
-#include <test-native-image.h>
using namespace Dali;
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali/devel-api/actors/mesh-actor.h>
-#include <dali/devel-api/geometry/mesh.h>
-#include <dali/devel-api/geometry/animatable-mesh.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-
-void utc_dali_material_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_material_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-
-static AnimatableMesh CreateMeshData(Material material)
-{
- AnimatableMesh::Faces faces;
- for(int i=0; i<10-3; i++)
- {
- faces.push_back(i);
- faces.push_back(i+1);
- faces.push_back(i+2);
- }
- return AnimatableMesh::New(10, faces, material);
-}
-
-}// anonymous namespace
-
-
-// Positive test case for a method
-int UtcDaliMaterialNew01(void)
-{
- TestApplication application;
- tet_infoline("Testing constructors, New and destructors");
-
- Material material;
- DALI_TEST_CHECK( ! material );
-
- material = Material::New("material");
- DALI_TEST_CHECK( material );
-
- Material* material2 = new Material();
- DALI_TEST_CHECK( ! *material2 );
- delete material2;
-
- Material material3 = material;
- Material material4;
- material4 = material;
- Material material5 = material;
- END_TEST;
-}
-
-
-int UtcDaliMaterialDownCast(void)
-{
- TestApplication application;
-
- Material material = Material::New("material");
- BaseHandle handle(material);
-
- Material mat2 = Material::DownCast( handle );
- DALI_TEST_CHECK( mat2 );
- END_TEST;
-}
-
-int UtcDaliMaterialSettersAndGetters(void)
-{
- TestApplication application;
- Material material = Material::New("material");
- DALI_TEST_EQUALS( material.GetName(), "material", TEST_LOCATION );
- material.SetName( "AnotherMaterial" );
- DALI_TEST_EQUALS( material.GetName(), "AnotherMaterial", TEST_LOCATION );
-
- DALI_TEST_EQUALS( material.GetOpacity(), Material::DEFAULT_OPACITY, 0.001, TEST_LOCATION);
- material.SetOpacity(0.38f);
- DALI_TEST_EQUALS( material.GetOpacity(), 0.38f, 0.001, TEST_LOCATION);
-
- DALI_TEST_EQUALS( material.GetShininess(), Material::DEFAULT_SHININESS, 0.001, TEST_LOCATION);
- material.SetShininess(0.47f);
- DALI_TEST_EQUALS( material.GetShininess(), 0.47f, 0.001, TEST_LOCATION);
-
- DALI_TEST_EQUALS( material.GetAmbientColor(), Material::DEFAULT_AMBIENT_COLOR, 0.001, TEST_LOCATION);
- material.SetAmbientColor(Color::BLACK);
- DALI_TEST_EQUALS( material.GetAmbientColor(), Color::BLACK, 0.001, TEST_LOCATION);
-
- DALI_TEST_EQUALS( material.GetDiffuseColor(), Material::DEFAULT_DIFFUSE_COLOR, 0.001, TEST_LOCATION);
- material.SetDiffuseColor(Color::BLUE);
- DALI_TEST_EQUALS( material.GetDiffuseColor(), Color::BLUE, 0.001, TEST_LOCATION);
-
- DALI_TEST_EQUALS( material.GetSpecularColor(), Material::DEFAULT_SPECULAR_COLOR, 0.001, TEST_LOCATION);
- material.SetSpecularColor(Color::GREEN);
- DALI_TEST_EQUALS( material.GetSpecularColor(), Color::GREEN, 0.001, TEST_LOCATION);
-
- DALI_TEST_EQUALS( material.GetEmissiveColor(), Material::DEFAULT_EMISSIVE_COLOR, 0.001, TEST_LOCATION);
- material.SetEmissiveColor(Color::MAGENTA);
- DALI_TEST_EQUALS( material.GetEmissiveColor(), Color::MAGENTA, 0.001, TEST_LOCATION);
-
- material.SetDiffuseTextureFileName("diffuse-texture.png");
- DALI_TEST_EQUALS( material.GetDiffuseFileName(), "diffuse-texture.png", TEST_LOCATION);
-
- material.SetOpacityTextureFileName("opacity-texture.png");
- DALI_TEST_EQUALS( material.GetOpacityTextureFileName(), "opacity-texture.png", TEST_LOCATION);
-
- material.SetNormalMapFileName("normal-map.png");
- DALI_TEST_EQUALS( material.GetNormalMapFileName(), "normal-map.png", TEST_LOCATION);
-
- Image diffuseTexture = ResourceImage::New("diffuse-texture.png");
- material.SetDiffuseTexture(diffuseTexture);
- DALI_TEST_EQUALS( material.GetDiffuseTexture(), diffuseTexture, TEST_LOCATION );
-
- Image opacityTexture = ResourceImage::New("opacity-texture.png");
- material.SetOpacityTexture(opacityTexture);
- DALI_TEST_EQUALS( material.GetOpacityTexture(), opacityTexture, TEST_LOCATION);
-
- Image normalMap = ResourceImage::New("normal-map.png");
- material.SetNormalMap(normalMap);
- DALI_TEST_EQUALS( material.GetNormalMap(), normalMap, TEST_LOCATION);
-
- DALI_TEST_EQUALS( material.GetMapU(), (unsigned int)Material::DEFAULT_MAPPING_MODE, TEST_LOCATION );
- DALI_TEST_EQUALS( material.GetMapV(), (unsigned int)Material::DEFAULT_MAPPING_MODE, TEST_LOCATION );
- material.SetMapU( Material::MAPPING_MODE_WRAP );
- material.SetMapV( Material::MAPPING_MODE_MIRROR );
- DALI_TEST_EQUALS( material.GetMapU(), (unsigned int)Material::MAPPING_MODE_WRAP, TEST_LOCATION );
- DALI_TEST_EQUALS( material.GetMapV(), (unsigned int)Material::MAPPING_MODE_MIRROR, TEST_LOCATION );
-
- DALI_TEST_EQUALS( material.GetDiffuseUVIndex(), Material::DEFAULT_DIFFUSE_UV_INDEX, TEST_LOCATION );
- material.SetDiffuseUVIndex( 1u );
- DALI_TEST_EQUALS( material.GetDiffuseUVIndex(), 1u, TEST_LOCATION );
-
- DALI_TEST_EQUALS( material.GetOpacityUVIndex(), Material::DEFAULT_OPACITY_UV_INDEX, TEST_LOCATION );
- material.SetOpacityUVIndex( 1u );
- DALI_TEST_EQUALS( material.GetOpacityUVIndex(), 1u, TEST_LOCATION );
-
- DALI_TEST_EQUALS( material.GetNormalUVIndex(), Material::DEFAULT_NORMAL_UV_INDEX, TEST_LOCATION );
- material.SetNormalUVIndex( 1u );
- DALI_TEST_EQUALS( material.GetNormalUVIndex(), 1u, TEST_LOCATION );
-
- DALI_TEST_EQUALS( material.GetHasHeightMap(), Material::DEFAULT_HAS_HEIGHT_MAP, TEST_LOCATION );
- material.SetHasHeightMap(true);
- DALI_TEST_EQUALS( material.GetHasHeightMap(), true, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliMaterialStage01(void)
-{
- TestApplication application;
- TraceCallStack& textureTrace = application.GetGlAbstraction().GetTextureTrace();
- textureTrace.Enable(true);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-
- {
- Material material = Material::New("material");
- Image image = ResourceImage::New( "image.png", ResourceImage::IMMEDIATE, Image::NEVER );
- DALI_TEST_CHECK(image);
- application.SendNotification();
- application.Render(16);
-
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- DALI_TEST_CHECK( request != NULL );
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
-
- material.SetDiffuseTexture(image);
- application.SendNotification();
- application.Render();
-
- AnimatableMesh mesh = CreateMeshData(material);
-
- application.SendNotification();
- application.Render();
- {
- MeshActor meshActor = MeshActor::New(mesh);
- meshActor.SetSize(100, 100);
- Stage::GetCurrent().Add(meshActor);
- application.SendNotification();
- application.Render();
-
- material.SetOpacity(0.5f);
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION );
-
- Stage::GetCurrent().Remove(meshActor);
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( glAbstraction.CheckNoTexturesDeleted() );
- DALI_TEST_CHECK( ! textureTrace.FindMethod( "DeleteTextures" ) );
- }
- application.SendNotification();
- application.Render();
-
- // Mesh should be destroyed, reducing connection count on material to zero.
- // This should also reduce connection count on image to zero
- DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION );
- }
- // SceneGraph::Material & SceneGraph::RenderMaterial should be destroyed
- // Image should be destroyed
- application.SendNotification();
- application.Render();
-
- application.Render();
- DALI_TEST_CHECK( textureTrace.FindMethod( "DeleteTextures" ) );
- DALI_TEST_CHECK( glAbstraction.CheckTextureDeleted( 23 ) );
- END_TEST;
-}
-
-
-int UtcDaliMaterialStage01MemCheck(void)
-{
- TestApplication application;
- tet_result(TET_PASS);
- END_TEST;
-}
-
-int UtcDaliMaterialStage02(void)
-{
- TestApplication application;
- TraceCallStack& textureTrace = application.GetGlAbstraction().GetTextureTrace();
- textureTrace.Enable(true);
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-
- {
- Material material = Material::New("material");
-
- Image image = ResourceImage::New( "image.png", ResourceImage::ON_DEMAND, Image::UNUSED );
- DALI_TEST_CHECK(image);
- application.SendNotification();
- application.Render(16);
- DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL );
-
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
- material.SetDiffuseTexture(image);
- application.SendNotification();
- application.Render();
- DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL );
-
- AnimatableMesh mesh = CreateMeshData(material);
-
- application.SendNotification();
- application.Render();
- DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL );
-
- {
- MeshActor meshActor = MeshActor::New(mesh);
- meshActor.SetSize(100, 100);
- Stage::GetCurrent().Add(meshActor);
- application.SendNotification();
- application.Render();
-
- // Image connection count should go to one - image should get loaded
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- DALI_TEST_CHECK( request != NULL );
-
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
- application.Render();
-
- material.SetOpacity(0.5f);
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION );
-
- Stage::GetCurrent().Remove(meshActor);
- application.SendNotification();
- application.Render();
-
- // This should reduce connection count on material to zero, freeing the texture:
- DALI_TEST_CHECK( textureTrace.FindMethod( "DeleteTextures" ) );
- DALI_TEST_CHECK( glAbstraction.CheckTextureDeleted( 23 ) );
- }
- application.SendNotification();
- application.Render();
-
- // Mesh should be destroyed, reducing connection count on material to zero.
- // This should also reduce connection count on image to zero, freeing it
- DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION );
- }
- application.SendNotification();
- application.Render();
-
- // SceneGraph::Material & SceneGraph::RenderMaterial should be destroyed
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali/devel-api/actors/mesh-actor.h>
-#include <dali/devel-api/geometry/mesh.h>
-#include <dali/devel-api/geometry/animatable-mesh.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-#include <mesh-builder.h>
-
-void mesh_actor_test_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void mesh_actor_test_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-
-static Mesh NewMesh()
-{
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
- Mesh mesh = Mesh::New(meshData);
- return mesh;
-}
-
-static AnimatableMesh NewAnimatableMesh()
-{
- AnimatableMesh::Faces faces;
- faces.push_back(0);
- faces.push_back(1);
- faces.push_back(2);
-
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetOpacity(.76f);
- customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, 1.0f));
- customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
- customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
-
- AnimatableMesh mesh = AnimatableMesh::New( 10u, faces, customMaterial );
- return mesh;
-}
-} // anonymous namespace
-
-int UtcDaliMeshActorConstructorVoid(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::MeshActor()");
-
- MeshActor actor;
- DALI_TEST_CHECK(!actor);
- END_TEST;
-}
-
-int UtcDaliMeshActorNew01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::New()");
-
- AnimatableMesh mesh = NewAnimatableMesh();
- MeshActor actor = MeshActor::New(mesh);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- DALI_TEST_CHECK(actor);
- END_TEST;
-}
-
-
-int UtcDaliMeshActorNew03(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::Mesh::New() - Create with no mesh");
-
- try
- {
- MeshActor actor = MeshActor::New(); // Shouldn't assert
- tet_result(TET_PASS);
- }
- catch (Dali::DaliException& e)
- {
- tet_result(TET_FAIL);
- }
-
- END_TEST;
-}
-
-int UtcDaliMeshActorCreateNoMeshData(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::Mesh::New() - Create with no mesh data");
-
- try
- {
- MeshData meshData;
- Mesh mesh = Mesh::New(meshData);
- MeshActor actor1 = MeshActor::New(mesh);
- }
- catch(Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "object", TEST_LOCATION);
- }
- END_TEST;
-}
-
-
-int UtcDaliMeshActorCreateSetData01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshData::SetData() - Create with no verts");
- try
- {
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- Material customMaterial;
- meshData.SetData(vertices, faces, bones, customMaterial);
- Mesh mesh = Mesh::New(meshData);
- MeshActor actor1 = MeshActor::New(mesh);
- }
- catch(Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "!vertices.empty()", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliMeshActorCreateSetData02(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshData::SetData - Create with no faces");
- try
- {
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- Material customMaterial;
- ConstructVertices(vertices, 60);
- meshData.SetData(vertices, faces, bones, customMaterial);
- Mesh mesh = Mesh::New(meshData);
- MeshActor actor1 = MeshActor::New(mesh);
- }
- catch(Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "!faceIndices.empty", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliMeshActorCreateSetData03(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshData::SetData - Create with no mats");
- try
- {
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- Material customMaterial;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- meshData.SetData(vertices, faces, bones, customMaterial);
- Mesh mesh = Mesh::New(meshData);
- MeshActor actor1 = MeshActor::New(mesh);
- }
- catch(Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "material", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliMeshActorCreateSetData04(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetData()");
-
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- Mesh mesh = Mesh::New(meshData);
- MeshActor actor1 = MeshActor::New(mesh);
- DALI_TEST_CHECK(actor1);
- END_TEST;
-}
-
-
-int UtcDaliMeshActorDownCast(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::DownCast()");
-
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
- Mesh mesh = Mesh::New(meshData);
-
- MeshActor actor1 = MeshActor::New(mesh);
- Actor anActor = Actor::New();
- anActor.Add(actor1);
-
- Actor child = anActor.GetChildAt(0);
- MeshActor meshActor = MeshActor::DownCast(child);
-
- DALI_TEST_CHECK(meshActor);
- END_TEST;
-}
-
-int UtcDaliMeshActorDownCast2(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::DownCast()");
-
- Actor actor1 = Actor::New();
- Actor anActor = Actor::New();
- anActor.Add(actor1);
-
- Actor child = anActor.GetChildAt(0);
- MeshActor meshActor = MeshActor::DownCast(child);
- DALI_TEST_CHECK(!meshActor);
-
- Actor unInitialzedActor;
- meshActor = DownCast< MeshActor >( unInitialzedActor );
- DALI_TEST_CHECK(!meshActor);
- END_TEST;
-}
-
-int UtcDaliMeshActorSetMaterial01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetMaterial()");
-
- Mesh mesh = NewMesh();
-
- MeshActor actor = MeshActor::New(mesh);
- std::string name = "AMeshActor";
- Stage::GetCurrent().Add(actor);
- actor.SetName(name);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
-
- MeshActor::SetMaterial(actor, name, customMaterial);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- DALI_TEST_CHECK( actor.GetMaterial() == customMaterial );
- END_TEST;
-}
-
-int UtcDaliMeshActorSetMaterial01b(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetMaterial()");
-
- Mesh mesh = NewMesh();
-
- Actor rootActor = Actor::New();
- MeshActor meshActor = MeshActor::New(mesh);
- rootActor.Add(meshActor);
-
- std::string name = "AMeshActor";
- meshActor.SetName(name);
-
- Stage::GetCurrent().Add(rootActor);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
-
- MeshActor::SetMaterial(rootActor, name, customMaterial);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- DALI_TEST_CHECK(meshActor.GetMaterial() == customMaterial );
- END_TEST;
-}
-
-
-int UtcDaliMeshActorSetMaterial02(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetMaterial()");
-
- Mesh mesh = NewMesh();
- MeshActor actor = MeshActor::New(mesh);
-
- std::string name = "AMeshActor";
- actor.SetName(name);
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- Material baseMat = actor.GetMaterial();
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
-
- MeshActor::SetMaterial(actor, "NoName", customMaterial);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- DALI_TEST_CHECK( actor.GetMaterial() == baseMat );
- DALI_TEST_CHECK( actor.GetMaterial() != customMaterial );
- END_TEST;
-}
-
-int UtcDaliMeshActorSetMaterial02b(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetMaterial()");
-
- Mesh mesh = NewMesh();
-
- MeshActor actor = MeshActor::New(mesh);
- Stage::GetCurrent().Add(actor);
-
- std::string name = "AMeshActor";
- actor.SetName(name);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- Material baseMat = actor.GetMaterial();
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
-
- MeshActor::SetMaterial(actor, "NoName", customMaterial);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- DALI_TEST_CHECK( actor.GetMaterial() == baseMat );
- DALI_TEST_CHECK( actor.GetMaterial() != customMaterial );
- END_TEST;
-}
-
-
-int UtcDaliMeshActorSetMaterial03(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetMaterial()");
-
- Mesh mesh = NewMesh();
-
- MeshActor actor = MeshActor::New(mesh);
- std::string name = "AMeshActor";
- actor.SetName(name);
- Stage::GetCurrent().Add(actor);
-
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
-
- actor.SetMaterial(customMaterial);
- application.SendNotification();
- application.Render(0);
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK(actor.GetMaterial() == customMaterial );
- END_TEST;
-}
-
-int UtcDaliMeshActorSetMaterial03b(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetMaterial()");
-
- Mesh mesh = NewMesh();
-
- MeshActor actor = MeshActor::New(mesh);
- std::string name = "AMeshActor";
- actor.SetName(name);
- Stage::GetCurrent().Add(actor);
-
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
-
- actor.SetMaterial(customMaterial);
- application.SendNotification();
- application.Render(0);
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK(actor.GetMaterial() == customMaterial );
- END_TEST;
-}
-
-
-
-int UtcDaliMeshActorGetMaterial01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetMaterial()");
-
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- Material material = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, material);
- Mesh mesh = Mesh::New(meshData);
-
- MeshActor actor = MeshActor::New(mesh);
- std::string name = "AMeshActor";
- actor.SetName(name);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- Material gotMaterial = actor.GetMaterial();
-
- DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION );
- DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION );
- DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION );
- DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION );
- END_TEST;
-}
-
-
-int UtcDaliMeshActorGetMaterial02(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::SetMaterial()");
-
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- Material material = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, material);
- Mesh mesh = Mesh::New(meshData);
-
- MeshActor actor = MeshActor::New(mesh);
- std::string name = "AMeshActor";
- actor.SetName(name);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- Material gotMaterial = actor.GetMaterial();
-
- DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION );
- DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION );
- DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION );
- DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION );
- END_TEST;
-}
-
-
-namespace
-{
-
-Material ConstructMaterial(float opacity, float diffuseOpacity)
-{
- Material customMaterial = Material::New("CustomMaterial");
- customMaterial.SetOpacity(opacity);
- customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, diffuseOpacity));
- customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
- customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
- return customMaterial;
-}
-
-static void TestBlending( TestApplication& application, Material material, float actorOpacity, BlendingMode::Type blendingMode, bool expectedBlend )
-{
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- meshData.SetData(vertices, faces, bones, material);
- Mesh mesh = Mesh::New(meshData);
-
- application.SendNotification();
- application.Render(0);
- application.Render();
- application.SendNotification();
-
- MeshActor actor = MeshActor::New(mesh);
- Stage::GetCurrent().Add(actor);
-
- actor.SetBlendMode(blendingMode);
- actor.SetOpacity(actorOpacity);
-
- TraceCallStack& cullFaceTrace = application.GetGlAbstraction().GetCullFaceTrace();
- cullFaceTrace.Enable(true);
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( BlendEnabled( cullFaceTrace ), expectedBlend, TEST_LOCATION );
-}
-} //anonymous namespace
-
-
-int UtcDaliMeshActorBlend01(void)
-{
- // Set Material with translucent color, actor color opaque, Set Use image alpha to true
- // Expect blending
-
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend01()");
-
- TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::AUTO, true );
- END_TEST;
-}
-
-
-int UtcDaliMeshActorBlend02(void)
-{
- // Set material to translucent, set use image alpha to false, set actor opacity to 1.0f
- // Expect no blending
-
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend02()");
- TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::OFF, false );
- END_TEST;
-}
-
-int UtcDaliMeshActorBlend03(void)
-{
- // Set material to opaque, set use image alpha to true, set actor opacity to 1.0f
- // Expect no blending
-
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend03()");
- TestBlending( application, ConstructMaterial(1.0f, 1.0f), 1.0f, BlendingMode::AUTO, false );
- END_TEST;
-}
-
-
-int UtcDaliMeshActorBlend04(void)
-{
- // Set material to have image with alpha, set use image alpha to true, set actor opacity to 1.0f
- // Expect blending
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend04()");
-
- Material material = ConstructMaterial(1.0f, 1.0f);
- BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
- material.SetDiffuseTexture( image );
- application.SendNotification();
- application.Render(0);
-
- TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
- END_TEST;
-}
-
-int UtcDaliMeshActorBlend05(void)
-{
- // Set material to have image with alpha, set use image alpha to false, set actor opacity to 1.0f
- // Expect no blending
-
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend05()");
-
- Material material = ConstructMaterial(1.0f, 1.0f);
- BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
- material.SetDiffuseTexture( image );
- application.SendNotification();
- application.Render(0);
-
- TestBlending( application, material, 1.0f, BlendingMode::ON, true );
- END_TEST;
-}
-
-
-int UtcDaliMeshActorBlend06(void)
-{
- // Set material to have image without alpha, set use image alpha to true, set actor opacity to 1.0f
- // Expect no blending
-
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend()");
-
- Material material = ConstructMaterial(1.0f, 1.0f);
- BufferImage image = BufferImage::New( 100, 50, Pixel::RGB888 );
- material.SetDiffuseTexture( image );
- application.SendNotification();
- application.Render(0);
-
- TestBlending( application, material, 1.0f, BlendingMode::AUTO, false );
- END_TEST;
-}
-
-int UtcDaliMeshActorBlend07(void)
-{
- // Set material to have framebuffer with alpha, set use image alpha to true, set actor opacity to 1.0f
- // Expect blending
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend07()");
- application.Render(0);
-
- Material material = ConstructMaterial(1.0f, 1.0f);
- FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 );
- RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
- RenderTask task = taskList.GetTask( 0u );
- task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
- application.SendNotification();
- application.Render();
-
- material.SetDiffuseTexture( image ); // (to render from)
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
- END_TEST;
-}
-
-int UtcDaliMeshActorBlend08(void)
-{
- // Set material to have image with alpha, set use image alpha to false, set actor opacity to 0.5f
- // Expect blending
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend08()");
-
- Material material = ConstructMaterial(1.0f, 1.0f);
- BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
- material.SetDiffuseTexture( image );
- application.SendNotification();
- application.Render(0);
-
- TestBlending( application, material, 0.5f, BlendingMode::AUTO, true );
- END_TEST;
-}
-
-int UtcDaliMeshActorBlend09(void)
-{
- // Set material to have image with no alpha, set material opacity to 0.5, set use image alpha to true, set actor opacity to 1.0f
- // Expect blending
- TestApplication application;
- tet_infoline("Testing Dali::MeshActor::Blend08()");
-
- Material material = ConstructMaterial(0.5f, 1.0f);
- BufferImage image = BufferImage::New( 100, 50, Pixel::RGB888 );
- material.SetDiffuseTexture( image );
- application.SendNotification();
- application.Render(0);
-
- TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
- END_TEST;
-}
-
-// Test that bones update the mesh's bone transform uniforms
-// (Removed old test - wasn't checking the above information, but instead the property
-// info, which is tested elsewhere)
-
-int UtcDaliMeshActorIndices(void)
-{
- TestApplication application;
- Actor basicActor = Actor::New();
- Mesh mesh = NewMesh();
- MeshActor meshActor = MeshActor::New(mesh);
-
- Property::IndexContainer indices;
- meshActor.GetPropertyIndices( indices );
- DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties
- DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimatableMeshActorIndices(void)
-{
- TestApplication application;
- Actor basicActor = Actor::New();
- AnimatableMesh mesh = NewAnimatableMesh();
- MeshActor meshActor = MeshActor::New(mesh);
-
- Property::IndexContainer indices;
- meshActor.GetPropertyIndices( indices );
- DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties
- DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-#include "mesh-builder.h"
-
-
-
-int UtcDaliMeshDataNew(void)
-{
- TestApplication application;
- MeshData meshData;
-
- DALI_TEST_EQUALS(meshData.HasNormals(), false, TEST_LOCATION);
- DALI_TEST_EQUALS(meshData.HasTextureCoords(), false, TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliMeshDataSetData(void)
-{
- TestApplication application;
-
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- DALI_TEST_GREATER(meshData.GetVertexCount(), size_t(0), TEST_LOCATION);
- DALI_TEST_GREATER(meshData.GetFaceCount(), size_t(0), TEST_LOCATION);
-
- const MeshData::FaceIndices& faces2 = meshData.GetFaces();
- const MeshData::VertexContainer& verts2 = meshData.GetVertices();
- DALI_TEST_EQUALS(faces.at(0), faces2.at(0), TEST_LOCATION);
- DALI_TEST_EQUALS(vertices.at(1).y, verts2.at(1).y, TEST_LOCATION);
- DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast<size_t>(0), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliMeshDataAddToBoundingVolume(void)
-{
- TestApplication application;
-
- float sz=40.0f;
-
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, sz);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- Vector4 upper(-1e10f, -1e10f, -1e10f, 0.0f);
- Vector4 lower(1e10f, 1e10f, 1e10f, 0.0f);
- Matrix f(false);
- f.SetIdentityAndScale(Vector3(2.0f, 2.0f, 2.0f));
- meshData.AddToBoundingVolume(lower, upper, f);
-
- Vector4 min(-sz*0.5f, -sz, -sz*0.7f, 0.0f);
- Vector4 max( sz*0.5f, sz*0.3f, sz*0.5f, 0.0f);
-
- // Test that upper and lower bounds are set and transformed
- DALI_TEST_EQUALS(lower, min*2.0f, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(upper, max*2.0f, 0.001, TEST_LOCATION);
-
- // Test that mesh's upper and lower bounds are set and not transformed
- DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliMeshDataBoundingBox(void)
-{
- TestApplication application;
-
- float sz=40.0f;
- MeshData meshData;
- Vector4 min(-1.0f, -2.0f, -3.0f, 0.0f);
- Vector4 max(1.0f, 2.0f, 3.0f, 0.0f);
- meshData.SetBoundingBoxMin(min);
- meshData.SetBoundingBoxMax(max);
- DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION);
-
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, sz);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- // Check bounding box hasn't changed
- DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION);
-
- Vector4 upper(-1e10f, -1e10f, -1e10f, 0.0f);
- Vector4 lower(1e10f, 1e10f, 1e10f, 0.0f);
- meshData.AddToBoundingVolume(lower, upper, Matrix::IDENTITY);
-
- // Bounding box should have been update
- Vector4 bbMin(-sz*0.5f, -sz, -sz*0.7f, 0.0f);
- Vector4 bbMax( sz*0.5f, sz*0.3f, sz*0.5f, 0.0f);
-
- // Test that upper and lower bounds are set and transformed
- DALI_TEST_EQUALS(lower, bbMin, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(upper, bbMax, 0.001, TEST_LOCATION);
-
- // Test that mesh's upper and lower bounds are set and not transformed
- DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), bbMin, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), bbMax, 0.001, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliMeshDataGetVertexCount(void)
-{
- TestApplication application;
-
- MeshData meshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 30);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
-
- DALI_TEST_EQUALS(meshData.GetVertexCount(), static_cast<size_t>(0), TEST_LOCATION);
-
- meshData.SetData(vertices, faces, bones, customMaterial);
- DALI_TEST_EQUALS(meshData.GetVertexCount(), vertices.size(), TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliMeshDataGetVertices(void)
-{
- TestApplication application;
- MeshData meshData;
- const Dali::MeshData::VertexContainer& verts1 = meshData.GetVertices();
- DALI_TEST_CHECK(verts1.size() == 0);
-
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 30);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- const Dali::MeshData::VertexContainer& verts2 = meshData.GetVertices();
- DALI_TEST_CHECK(verts2.size() != 0);
- DALI_TEST_CHECK(verts2.size() == meshData.GetVertexCount());
- END_TEST;
-}
-
-int UtcDaliMeshDataGetFaceCount(void)
-{
- TestApplication application;
- MeshData meshData;
- DALI_TEST_EQUALS(meshData.GetFaceCount(), static_cast<size_t>(0), TEST_LOCATION);
-
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 30);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- DALI_TEST_EQUALS(meshData.GetFaceCount(), faces.size() / 3, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliMeshDataGetFaces(void)
-{
- TestApplication application;
- MeshData meshData;
- const Dali::MeshData::FaceIndices& faces1 = meshData.GetFaces();
- DALI_TEST_CHECK(faces1.size() == 0);
-
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 30);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- const Dali::MeshData::FaceIndices& faces2 = meshData.GetFaces();
- DALI_TEST_CHECK(faces2.size() != 0);
- END_TEST;
-}
-
-int UtcDaliMeshDataTextureCoords(void)
-{
- TestApplication application;
- MeshData meshData;
- DALI_TEST_EQUALS(meshData.HasTextureCoords(), false, TEST_LOCATION);
- meshData.SetHasTextureCoords(true);
- DALI_TEST_EQUALS(meshData.HasTextureCoords(), true, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliMeshDataNormals(void)
-{
- TestApplication application;
- MeshData meshData;
- DALI_TEST_EQUALS(meshData.HasNormals(), false, TEST_LOCATION);
- meshData.SetHasNormals(true);
- DALI_TEST_EQUALS(meshData.HasNormals(), true, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliMeshDataGetMaterial(void)
-{
- TestApplication application;
- MeshData meshData;
- Material aMat = meshData.GetMaterial();
- DALI_TEST_CHECK(!aMat);
-
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 30);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- aMat = meshData.GetMaterial();
- DALI_TEST_CHECK(aMat);
- END_TEST;
-}
-
-int UtcDaliMeshDataSetMaterial(void)
-{
- TestApplication application;
- MeshData meshData;
-
- Material aMat = meshData.GetMaterial();
- DALI_TEST_CHECK(!aMat);
-
- Material mat1 = ConstructMaterial();
- meshData.SetMaterial(mat1);
- aMat = meshData.GetMaterial();
- DALI_TEST_CHECK(mat1 == aMat);
-
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 30);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- aMat = meshData.GetMaterial();
-
- DALI_TEST_CHECK(aMat == customMaterial);
- DALI_TEST_CHECK(aMat != mat1);
-
- END_TEST;
-}
-
-int UtcDaliMeshDataGetBoneCount(void)
-{
- TestApplication application;
- MeshData meshData;
- DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast<size_t>(0), TEST_LOCATION);
- DALI_TEST_EQUALS(meshData.HasBones(), false, TEST_LOCATION);
-
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 30);
- ConstructFaces(vertices, faces);
- ConstructBones(bones);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
-
- DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast<size_t>(3), TEST_LOCATION);
- DALI_TEST_EQUALS(meshData.HasBones(), true, TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliMeshDataGetBones(void)
-{
- TestApplication application;
- MeshData meshData;
- DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast<size_t>(0), TEST_LOCATION);
- const BoneContainer& bones1 = meshData.GetBones();
- DALI_TEST_CHECK(bones1.empty());
-
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 30);
- ConstructFaces(vertices, faces);
- ConstructBones(bones);
- Material customMaterial = ConstructMaterial();
- meshData.SetData(vertices, faces, bones, customMaterial);
- const BoneContainer& bones3 = meshData.GetBones();
- DALI_TEST_CHECK( ! bones3.empty() );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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 <unistd.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/common/mutex.h>
-#include <dali-test-suite-utils.h>
-
-using Dali::Mutex;
-
-int UtcDaliMutexSingleThread(void)
-{
- tet_infoline("Testing Dali::Mutex in a single thread");
-
- {
- Mutex mutex1;
- DALI_TEST_EQUALS( false, mutex1.IsLocked(), TEST_LOCATION );
- }
-
- {
- Mutex mutex2;
- Mutex::ScopedLock lock( mutex2 );
- DALI_TEST_EQUALS( true, mutex2.IsLocked(), TEST_LOCATION );
- }
-
- Mutex mutex3;
- {
- Mutex::ScopedLock lock( mutex3 );
- }
- DALI_TEST_EQUALS( false, mutex3.IsLocked(), TEST_LOCATION );
-
- END_TEST;
-}
-
-namespace // for local variables to avoid name clashes
-{
-int gGlobalValue = 0;
-Mutex* gGlobalValueMutex;
-bool gWorkerThreadWait = true;
-enum ThreadState { INIT, RUN, LOCKING, TERMINATE } gWorkerThreadState = INIT;
-}
-void* WorkerThread1( void* ptr )
-{
- gWorkerThreadState = RUN;
- {
- Mutex::ScopedLock lock( *gGlobalValueMutex );
- gWorkerThreadState = LOCKING;
- gGlobalValue = -1;
- while( gWorkerThreadWait ) // wait till we can exit
- {
- usleep( 1 ); // 1 microsecond
- }
- }
- gWorkerThreadState = TERMINATE;
- return NULL;
-}
-
-int UtcDaliMutexMultiThread(void)
-{
- tet_infoline("Testing Dali::Mutex multithreaded");
-
- gGlobalValueMutex = new Dali::Mutex;
-
- pthread_t thread1;
- // initialize values
- gGlobalValue = 0;
- gWorkerThreadWait = true;
- DALI_TEST_EQUALS( INIT, gWorkerThreadState, TEST_LOCATION );
- DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
- DALI_TEST_EQUALS( false, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
-
- // lock the mutex
- {
- Mutex::ScopedLock lock( *gGlobalValueMutex );
- DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
- pthread_create( &thread1, NULL, &WorkerThread1, NULL );
- // wait till the thread is in run state
- while( RUN != gWorkerThreadState )
- {
- usleep( 1 ); // 1 microsecond
- }
- // now the thread is running and mutex is still locked by this thread so value is not changed
- DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
- DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
- // drop out of scope, releases our lock
- }
- // now child thread is allowed to change the value
- // wait till the thread is in locking state
- while( LOCKING != gWorkerThreadState )
- {
- usleep( 1 ); // 1 microsecond
- }
- // mutex is locked, but not by us, by the child thread
- DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
- // value is changed
- DALI_TEST_EQUALS( -1, gGlobalValue, TEST_LOCATION );
- // let worker finish
- gWorkerThreadWait = false;
- // wait till the thread is terminated state
- while( TERMINATE != gWorkerThreadState )
- {
- usleep( 1 ); // 1 microsecond
- }
- DALI_TEST_EQUALS( false, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
- void* exitValue;
- pthread_join( thread1, &exitValue );
-
- END_TEST;
-}
-
-int UtcDaliMutexNonCopyable(void)
-{
- // we want to make sure that mutex is not copyable (its copy constructor is not defined)
- // this test will stop compiling if Mutex has compiler generated copy constructor
- DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Mutex ) );
-
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-
#include <stdlib.h>
#include <dali-test-suite-utils.h>
#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/actors/mesh-actor.h>
-#include <dali/devel-api/geometry/mesh.h>
using namespace Dali;
-#include "mesh-builder.h"
-
namespace
{
bool& mSignalVerified;
};
-
-struct TestMeshActorCallback
-{
- TestMeshActorCallback(bool& signalReceived)
- : mSignalVerified(signalReceived)
- {
- }
- void operator()(BaseHandle object)
- {
- tet_infoline("Verifying TestMeshActorCallback()");
- MeshActor actor = MeshActor::DownCast(object);
- if(actor)
- {
- mSignalVerified = true;
- }
- }
- bool& mSignalVerified;
-};
-
struct TestAnimationCallback
{
TestAnimationCallback(bool& signalReceived)
END_TEST;
}
-
-int UtcDaliObjectRegistrySignalMeshActorCreated(void)
-{
- TestApplication application;
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
-
- bool verified = false;
- TestMeshActorCallback test(verified);
-
- Dali::RefObject* objectPointer = NULL;
- TestObjectDestroyedCallback test2(verified, objectPointer);
-
- registry.ObjectCreatedSignal().Connect(&application, test);
- registry.ObjectDestroyedSignal().Connect(&application, test2);
-
- Mesh mesh = ConstructMesh(60);
-
- {
- MeshActor actor = MeshActor::New(mesh);
-
- DALI_TEST_CHECK(actor);
- DALI_TEST_CHECK( test.mSignalVerified );
-
- verified = false;
- objectPointer = actor.GetObjectPtr();
- }
- DALI_TEST_CHECK( test.mSignalVerified );
- END_TEST;
-}
-
-
int UtcDaliObjectRegistrySignalAnimationCreated(void)
{
TestApplication application;
#include <stdlib.h>
#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/actors/mesh-actor.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali-test-suite-utils.h>
DALI_TEST_CHECK( CullNone == imageActor.GetCullFace() );
- MeshActor meshActor = MeshActor::New();
+ imageActor.SetCullFace( CullBack );
+
+ DALI_TEST_CHECK( CullBack == imageActor.GetCullFace() );
- DALI_TEST_CHECK( CullBack == meshActor.GetCullFace() );
END_TEST;
}
+++ /dev/null
-/*
- * Copyright (c) 2014 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/public-api/dali-core.h>
-#include <dali/devel-api/scripting/scripting.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-using namespace Dali::Scripting;
-
-namespace
-{
-
-const StringEnum< int > COLOR_MODE_VALUES[] =
-{
- { "USE_OWN_COLOR", USE_OWN_COLOR },
- { "USE_PARENT_COLOR", USE_PARENT_COLOR },
- { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR },
- { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
-};
-const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
-
-const StringEnum< int > POSITION_INHERITANCE_MODE_VALUES[] =
-{
- { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
- { "USE_PARENT_POSITION", USE_PARENT_POSITION },
- { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION },
- { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
-};
-const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] );
-
-const StringEnum< int > DRAW_MODE_VALUES[] =
-{
- { "NORMAL", DrawMode::NORMAL },
- { "OVERLAY", DrawMode::OVERLAY },
- { "STENCIL", DrawMode::STENCIL },
-};
-const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Helpers for string to enum comparisons for Image and Image loading parameters
-////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Template to check enumerations of type T, with a class of type X
- */
-template< typename T, typename X >
-void TestEnumStrings(
- Property::Map& map, // The map used to create instance of type X
- const StringEnum< int >* values, // An array of string values
- unsigned int num, // Number of items in the array
- T ( X::*method )() const, // The member method of X to call to get the enum
- X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X
-)
-{
- const unsigned int lastIndex( map.Count() - 1 );
- const std::string& key = map.GetKey( lastIndex );
- Property::Value& value = map.GetValue( lastIndex );
-
- for ( unsigned int i = 0; i < num; ++i )
- {
- value = values[i].string;
- tet_printf("Checking: %s: %s\n", key.c_str(), values[i].string );
- X instance = creator( map );
- DALI_TEST_EQUALS( values[i].value, ( instance.*method )(), TEST_LOCATION );
- }
-}
-
-/// Helper method to create ResourceImage using property
-ResourceImage NewResourceImage( const Property::Value& map )
-{
- ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
- return image;
-}
-
-/// Helper method to create ResourceImage using property
-BufferImage NewBufferImage( const Property::Value& map )
-{
- BufferImage image = BufferImage::DownCast( NewImage( map ) );
- return image;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Helpers for string to enum comparisons for Actor to Property::Map
-//////////////////////////////////////////////////////////////////////////////
-
-/**
- * Template to check enumerations of type T
- */
-template< typename T >
-void TestEnumStrings(
- const char * const keyName, // The name of the key to check
- TestApplication& application, // Reference to the application class
- const StringEnum< int >* values, // An array of string values
- unsigned int num, // Number of items in the array
- void ( Actor::*method )( T ) // The Actor member method to set the enumeration
-)
-{
- for ( unsigned int i = 0; i < num; ++i )
- {
- tet_printf("Checking: %s: %s\n", keyName, values[i].string );
-
- Actor actor = Actor::New();
- (actor.*method)( ( T ) values[i].value );
-
- Stage::GetCurrent().Add( actor );
- application.SendNotification();
- application.Render();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
-
- DALI_TEST_CHECK( map.Count() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( keyName ) );
- DALI_TEST_EQUALS( value.GetValue( keyName ).Get< std::string >(), values[i].string, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-
-} // anon namespace
-
-
-
-int UtcDaliScriptingGetColorMode(void)
-{
- TestApplication application;
-
- for ( unsigned int i = 0; i < COLOR_MODE_VALUES_COUNT; ++i )
- {
- tet_printf( "Checking %s == %d\n", COLOR_MODE_VALUES[i].string, COLOR_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].value, GetColorMode( COLOR_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].string, GetColorMode( (ColorMode) COLOR_MODE_VALUES[i].value ), TEST_LOCATION );
- }
-
- try
- {
- (void)GetColorMode("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingGetPositionInheritanceMode(void)
-{
- TestApplication application;
-
- for ( unsigned int i = 0; i < POSITION_INHERITANCE_MODE_VALUES_COUNT; ++i )
- {
- tet_printf( "Checking %s == %d\n", POSITION_INHERITANCE_MODE_VALUES[i].string, POSITION_INHERITANCE_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].value, GetPositionInheritanceMode( POSITION_INHERITANCE_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].string, GetPositionInheritanceMode( (PositionInheritanceMode) POSITION_INHERITANCE_MODE_VALUES[i].value ), TEST_LOCATION );
- }
-
- try
- {
- (void)GetPositionInheritanceMode("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- END_TEST;
-}
-
-
-int UtcDaliScriptingGetDrawMode(void)
-{
- TestApplication application;
-
- for ( unsigned int i = 0; i < DRAW_MODE_VALUES_COUNT; ++i )
- {
- tet_printf( "Checking %s == %d\n", DRAW_MODE_VALUES[i].string, DRAW_MODE_VALUES[i].value );
- DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].value, GetDrawMode( DRAW_MODE_VALUES[i].string ), TEST_LOCATION );
- DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].string, GetDrawMode( (DrawMode::Type) DRAW_MODE_VALUES[i].value ), TEST_LOCATION );
- }
-
- try
- {
- (void)GetDrawMode("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingGetAnchorConstant(void)
-{
- TestApplication application;
-
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_LEFT, GetAnchorConstant( "TOP_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_CENTER, GetAnchorConstant( "TOP_CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_RIGHT, GetAnchorConstant( "TOP_RIGHT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_LEFT, GetAnchorConstant( "CENTER_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER, GetAnchorConstant( "CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_RIGHT, GetAnchorConstant( "CENTER_RIGHT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_LEFT, GetAnchorConstant( "BOTTOM_LEFT" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_CENTER, GetAnchorConstant( "BOTTOM_CENTER" ), TEST_LOCATION );
- DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_RIGHT, GetAnchorConstant( "BOTTOM_RIGHT" ), TEST_LOCATION );
-
- try
- {
- (void)GetAnchorConstant("INVALID_ARG");
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative(void)
-{
- TestApplication application;
-
- // Invalid filename
- try
- {
- Property::Map map;
- map[ "filename" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
- }
-
- // Invalid load-policy
- try
- {
- Property::Map map;
- map[ "load-policy" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "load-policy" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
-
- // Invalid release-policy
- try
- {
- Property::Map map;
- map[ "release-policy" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "release-policy" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
-
- // Invalid width
- try
- {
- Property::Map map;
- map[ "width" ] = "Invalid";
- map[ "height" ] = "Invalid";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
- }
-
- // Invalid height
- try
- {
- Property::Map map;
- map[ "width" ] = 10;
- map[ "height" ] = "Invalid";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
- }
-
- // Invalid fitting-mode
- try
- {
- Property::Map map;
- map[ "fitting-mode" ] = Vector3::ZERO;
- Image image = NewImage( map );
- DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "value.GetType() == Property::STRING", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "fitting-mode" ] = "INVALID";
- Image image = NewImage( map );
- DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
-
- // Invalid scaling-mode
- try
- {
- Property::Map map;
- map[ "sampling-mode" ] = Vector3::ZERO;
- Image image = NewImage( map );
- DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "value.GetType() == Property::STRING", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "sampling-mode" ] = "INVALID";
- Image image = NewImage( map );
- DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
-
- // Invalid orientation-correction
- try
- {
- Property::Map map;
- map[ "orientation" ] = Vector3::ZERO;
- Image image = NewImage( map );
- DALI_TEST_EQUALS( "Expected exception to be thrown", "But exception was not thrown", TEST_LOCATION );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "value.GetType() == Property::BOOLEAN", TEST_LOCATION );
- }
-
- // Invalid type
- try
- {
- Property::Map map;
- map[ "type" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(\"type\").GetType()", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "type" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
-
- // Invalid pixel-format
- try
- {
- Property::Map map;
- map[ "pixel-format" ] = Vector3::ZERO;
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
-
- // Invalid value
- try
- {
- Property::Map map;
- map[ "pixel-format" ] = "INVALID";
- Image image = NewImage( map );
- tet_result( TET_FAIL );
- }
- catch ( DaliException& e )
- {
- DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
- }
- }
-
- END_TEST;
-}
-
-
-int UtcDaliScriptingNewImage(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // Filename only
- {
- ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
- DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION );
- }
-
- // load-policy
- map[ "load-policy" ] = "";
- {
- const StringEnum< int > values[] =
- {
- { "IMMEDIATE", ResourceImage::IMMEDIATE },
- { "ON_DEMAND", ResourceImage::ON_DEMAND }
- };
- TestEnumStrings< ResourceImage::LoadPolicy, ResourceImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ResourceImage::GetLoadPolicy, &NewResourceImage );
- }
-
- // release-policy
- map[ "release-policy" ] = "";
- {
- const StringEnum< int > values[] =
- {
- { "UNUSED", Image::UNUSED },
- { "NEVER", Image::NEVER }
- };
- TestEnumStrings< Image::ReleasePolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
- }
-
- // float width and height
- map[ "width" ] = (float) 10.0f;
- map[ "height" ] = (float) 20.0f;
- {
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 10.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 20.0f, TEST_LOCATION );
- }
-
- // int width and height
- map[ "width"] = (int) 50;
- map[ "height" ] = (int) 70;
- {
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
- }
-
- //map.erase( map.end() - 2, map.end() );
-
- // type FrameBufferImage
- map[ "type" ] = "FrameBufferImage";
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
- }
- // type BufferImage
- map[ "type" ] = "BufferImage";
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( BufferImage::DownCast( image ) );
- DALI_TEST_CHECK((BufferImage::DownCast( image )).GetPixelFormat()== Pixel::RGBA8888);
- }
-
- // pixel-format
- map[ "pixel-format" ] = "";
- {
- const StringEnum< int > values[] =
- {
- { "A8", Pixel::A8 },
- { "L8", Pixel::L8 },
- { "LA88", Pixel::LA88 },
- { "RGB565", Pixel::RGB565 },
- { "BGR565", Pixel::BGR565 },
- { "RGBA4444", Pixel::RGBA4444 },
- { "BGRA4444", Pixel::BGRA4444 },
- { "RGBA5551", Pixel::RGBA5551 },
- { "BGRA5551", Pixel::BGRA5551 },
- { "RGB888", Pixel::RGB888 },
- { "RGB8888", Pixel::RGB8888 },
- { "BGR8888", Pixel::BGR8888 },
- { "RGBA8888", Pixel::RGBA8888 },
- { "BGRA8888", Pixel::BGRA8888 },
- /*{ "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
- { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
- { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
- { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
- { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
- { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
- { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
- { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
- { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
- { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },*/
- // BufferImage does not support compressed formats
- };
-
- TestEnumStrings< Pixel::Format, BufferImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
- }
-
- // type Image
- map[ "type" ] = "ResourceImage";
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
- DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
- DALI_TEST_CHECK( !BufferImage::DownCast( image ) );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingNewShaderEffect(void)
-{
- TestApplication application;
-
- Property::Map programMap;
- programMap[ "vertex-filename" ] = "bump.vert";
- programMap[ "fragment-filename" ] = "bump.frag";
-
- Property::Map imageMap;
- imageMap[ "filename" ] = "image.png";
-
- Property::Map map;
- map[ "image" ] = imageMap;
- map[ "program" ] = programMap;
- map[ "uLightPosition" ] = Vector3( 0.0, 0.0, -1.5);
- map[ "uAmbientLight" ] = (int)10;
-
- ShaderEffect shader = NewShaderEffect( map );
-
- DALI_TEST_CHECK( shader );
- END_TEST;
-}
-
-int UtcDaliScriptingNewActorNegative(void)
-{
- TestApplication application;
-
- // Empty map
- {
- Actor handle = NewActor( Property::Map() );
- DALI_TEST_CHECK( !handle );
- }
-
- // Map with only properties
- {
- Property::Map map;
- map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
- map[ "anchor-point" ] = AnchorPoint::TOP_CENTER;
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( !handle );
- }
-
- // Add some signals to the map, we should have no signal connections as its not yet supported
- {
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "signals" ] = Property::MAP;
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
- DALI_TEST_CHECK( !handle.MouseWheelEventSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingNewActorProperties(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "size" ] = Vector3::ONE;
- map[ "position" ] = Vector3::XAXIS;
- map[ "scale" ] = Vector3::ONE;
- map[ "visible" ] = false;
- map[ "color" ] = Color::MAGENTA;
- map[ "name" ] = "MyActor";
- map[ "color-mode" ] = "USE_PARENT_COLOR";
- map[ "inherit-shader-effect" ] = false;
- map[ "sensitive" ] = false;
- map[ "leave-required" ] = true;
- map[ "position-inheritance" ] = "DONT_INHERIT_POSITION";
- map[ "draw-mode" ] = "STENCIL";
- map[ "inherit-orientation" ] = false;
- map[ "inherit-scale" ] = false;
-
- // Default properties
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
-
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsSensitive(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetLeaveRequired(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsOrientationInherited(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- }
-
- // Check Anchor point and parent origin vector3s
- map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
- map[ "anchor-point" ] = AnchorPoint::TOP_LEFT;
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
-
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- }
-
- // Check Anchor point and parent origin STRINGS
- map[ "parent-origin" ] = "TOP_LEFT";
- map[ "anchor-point" ] = "CENTER_LEFT";
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
-
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingNewActorChildren(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "position" ] = Vector3::XAXIS;
-
- Property::Map child1Map;
- child1Map[ "type" ] = "ImageActor";
- child1Map[ "position" ] = Vector3::YAXIS;
-
- Property::Array childArray;
- childArray.PushBack( child1Map );
- map[ "actors" ] = childArray;
-
- // Create
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
-
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetChildCount(), 1u, TEST_LOCATION );
-
- Actor child1 = handle.GetChildAt(0);
- DALI_TEST_CHECK( child1 );
- DALI_TEST_CHECK( ImageActor::DownCast( child1 ) );
- DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- END_TEST;
-}
-
-
-int UtcDaliScriptingCreatePropertyMapActor(void)
-{
- TestApplication application;
-
- // Actor Type
- {
- Actor actor = Actor::New();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "Actor", TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
-
- // ImageActor Type
- {
- Actor actor = ImageActor::New();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "ImageActor", TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
-
- // Default properties
- {
- Actor actor = Actor::New();
- actor.SetSize( Vector3::ONE );
- actor.SetPosition( Vector3::XAXIS );
- actor.SetScale( Vector3::ZAXIS );
- actor.SetVisible( false );
- actor.SetColor( Color::MAGENTA );
- actor.SetName( "MyActor" );
- actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- actor.SetParentOrigin( ParentOrigin::TOP_RIGHT );
- actor.SetSensitive( false );
- actor.SetLeaveRequired( true );
- actor.SetInheritOrientation( false );
- actor.SetInheritScale( false );
- actor.SetSizeModeFactor( Vector3::ONE );
-
- Stage::GetCurrent().Add( actor );
- application.SendNotification();
- application.Render();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
-
- DALI_TEST_CHECK( !map.Empty() );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "size" ) );
- DALI_TEST_EQUALS( value.GetValue( "size" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "position" ) );
- DALI_TEST_EQUALS( value.GetValue( "position" ).Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "scale" ) );
- DALI_TEST_EQUALS( value.GetValue( "scale" ).Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "visible" ) );
- DALI_TEST_EQUALS( value.GetValue( "visible" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "color" ) );
- DALI_TEST_EQUALS( value.GetValue( "color" ).Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "name" ) );
- DALI_TEST_EQUALS( value.GetValue( "name").Get< std::string >(), "MyActor", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "anchor-point" ) );
- DALI_TEST_EQUALS( value.GetValue( "anchor-point" ).Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "parent-origin" ) );
- DALI_TEST_EQUALS( value.GetValue( "parent-origin" ).Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "sensitive" ) );
- DALI_TEST_EQUALS( value.GetValue( "sensitive" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "leave-required" ) );
- DALI_TEST_EQUALS( value.GetValue( "leave-required" ).Get< bool >(), true, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "inherit-orientation" ) );
- DALI_TEST_EQUALS( value.GetValue( "inherit-orientation" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "inherit-scale" ) );
- DALI_TEST_EQUALS( value.GetValue( "inherit-scale" ).Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "size-mode-factor" ) );
- DALI_TEST_EQUALS( value.GetValue( "size-mode-factor" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
-
- // ColorMode
- TestEnumStrings< ColorMode >( "color-mode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
-
- // PositionInheritanceMode
- TestEnumStrings< PositionInheritanceMode >( "position-inheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
-
- // DrawMode
- TestEnumStrings< DrawMode::Type >( "draw-mode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
-
- // Children
- {
- Actor actor = Actor::New();
- Actor child = ImageActor::New();
- actor.Add( child );
-
- Stage::GetCurrent().Add( actor );
- application.SendNotification();
- application.Render();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Actor", TEST_LOCATION );
-
- DALI_TEST_CHECK( value.HasKey( "actors" ) );
- Property::Array children( value.GetValue( "actors").Get< Property::Array >() );
- DALI_TEST_CHECK( !children.Empty() );
- Property::Map childMap( children[0].Get< Property::Map >() );
- DALI_TEST_CHECK( !childMap.Empty() );
- Property::Value childValue( childMap );
- DALI_TEST_CHECK( childValue.HasKey( "type" ) );
- DALI_TEST_EQUALS( childValue.GetValue( "type" ).Get< std::string >(), "ImageActor", TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingCreatePropertyMapImage(void)
-{
- TestApplication application;
-
- // Empty
- {
- Image image;
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( map.Empty() );
- }
-
- // Default
- {
- Image image = ResourceImage::New( "MY_PATH" );
-
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "filename" ) );
- DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "load-policy") );
- DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "release-policy") );
- DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "NEVER", TEST_LOCATION );
- DALI_TEST_CHECK( !value.HasKey( "width" ) );
- DALI_TEST_CHECK( !value.HasKey( "height" ) );
- }
-
- // Change values
- {
- ResourceImage image = ResourceImage::New( "MY_PATH", ResourceImage::ON_DEMAND, Image::UNUSED, ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
-
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "filename" ) );
- DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "load-policy") );
- DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "release-policy") );
- DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "UNUSED", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "width" ) );
- DALI_TEST_EQUALS( value.GetValue( "width" ).Get< int >(), 300, TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "height" ) );
- DALI_TEST_EQUALS( value.GetValue( "height" ).Get< int >(), 400, TEST_LOCATION );
- }
-
- // BufferImage
- {
- Image image = BufferImage::New( 200, 300, Pixel::A8 );
- Property::Map map;
- CreatePropertyMap( image, map );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BufferImage", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "pixel-format") );
- DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION );
- }
-
- // FrameBufferImage
- {
- Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
- Property::Map map;
- CreatePropertyMap( image, map );
- Property::Value value( map );
- DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingGetEnumerationTemplates(void)
-{
- TestApplication application;
-
- const Scripting::StringEnum< int > myTable[] =
- {
- { "ONE", 1 },
- { "TWO", 2 },
- { "THREE", 3 },
- { "FOUR", 4 },
- { "FIVE", 5 },
- };
- const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
-
- for ( unsigned int i = 0; i < myTableCount; ++i )
- {
- tet_printf("Checking: %s\n", myTable[ i ].string );
- DALI_TEST_EQUALS( myTable[ i ].value, GetEnumeration( myTable[ i ].string, myTable, myTableCount ), TEST_LOCATION );
- }
-
- for ( unsigned int i = 0; i < myTableCount; ++i )
- {
- tet_printf("Checking: %d\n", myTable[ i ].value );
- DALI_TEST_EQUALS( myTable[ i ].string, GetEnumerationName( myTable[ i ].value, myTable, myTableCount ), TEST_LOCATION );
- }
-
- END_TEST;
-}
-
-int UtcDaliScriptingCompareEnums(void)
-{
- // EQUAL
- DALI_TEST_CHECK( CompareEnums( "", "" ) );
- DALI_TEST_CHECK( CompareEnums( "HELLO", "HELLO" ) );
- DALI_TEST_CHECK( CompareEnums( "HELLO", "hello" ) );
- DALI_TEST_CHECK( CompareEnums( "hello", "HELLO" ) );
- DALI_TEST_CHECK( CompareEnums( "hello-world", "HELLO_WORLD" ) );
- DALI_TEST_CHECK( CompareEnums( "hello_WORLD", "HELLO-world" ) );
- DALI_TEST_CHECK( CompareEnums( "hello_WORLD-", "HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "_hello_WORLD-", "-HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "-hello_WORLD-", "_HELLO-world_" ) );
- DALI_TEST_CHECK( CompareEnums( "hello123", "HELLO123" ) );
-
- // NOT EQUAL
- DALI_TEST_CHECK( ! CompareEnums( "hello", "HELLOWORLD" ) );
-
- END_TEST;
-}