5c5a99601da754dc01fbea2ae600602e0934f28f
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-MeshActor.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23
24 using namespace Dali;
25
26
27 void mesh_actor_test_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void mesh_actor_test_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37 namespace
38 {
39
40 static AnimatableMesh NewMesh()
41 {
42   AnimatableMesh::Faces faces;
43   faces.push_back(0);
44   faces.push_back(1);
45   faces.push_back(2);
46
47   Material customMaterial = Material::New("CustomMaterial");
48   customMaterial.SetOpacity(.76f);
49   customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, 1.0f));
50   customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
51   customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
52
53   AnimatableMesh mesh = AnimatableMesh::New( 10u, faces, customMaterial );
54   return mesh;
55 }
56 } // anonymous namespace
57
58 int UtcDaliMeshActorConstructorVoid(void)
59 {
60   TestApplication application;
61   tet_infoline("Testing Dali::MeshActor::MeshActor()");
62
63   MeshActor actor;
64   DALI_TEST_CHECK(!actor);
65   END_TEST;
66 }
67
68 int UtcDaliMeshActorNew01(void)
69 {
70   TestApplication application;
71   tet_infoline("Testing Dali::MeshActor::New()");
72
73   AnimatableMesh mesh = NewMesh();
74   MeshActor actor = MeshActor::New(mesh);
75   application.SendNotification();
76   application.Render();
77   application.Render();
78   application.SendNotification();
79
80   DALI_TEST_CHECK(actor);
81   END_TEST;
82 }
83
84 int UtcDaliMeshActorNew03(void)
85 {
86   TestApplication application;
87   tet_infoline("Testing Dali::Mesh::New() - Create with no mesh");
88
89   try
90   {
91     MeshActor actor = MeshActor::New(); // Shouldn't assert
92     tet_result(TET_PASS);
93   }
94   catch (Dali::DaliException& e)
95   {
96     tet_result(TET_FAIL);
97   }
98
99   END_TEST;
100 }
101
102 int UtcDaliMeshActorIndices(void)
103 {
104   TestApplication application;
105   Actor basicActor = Actor::New();
106   AnimatableMesh mesh = NewMesh();
107   MeshActor meshActor = MeshActor::New(mesh);
108
109   Property::IndexContainer indices;
110   meshActor.GetPropertyIndices( indices );
111   DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties
112   DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION );
113   END_TEST;
114 }