Improved pan gesture prediction
[platform/core/uifw/dali-core.git] / automated-tests / src / dali-unmanaged / 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 #include <mesh-builder.h>
27
28
29 namespace
30 {
31
32 static Mesh NewMesh()
33 {
34   MeshData meshData;
35   MeshData::VertexContainer    vertices;
36   MeshData::FaceIndices        faces;
37   BoneContainer                bones;
38   ConstructVertices(vertices, 60);
39   ConstructFaces(vertices, faces);
40   Material customMaterial = ConstructMaterial();
41   meshData.SetData(vertices, faces, bones, customMaterial);
42   Mesh mesh = Mesh::New(meshData);
43   return mesh;
44 }
45
46 } // anon mesh
47
48
49 int UtcDaliMeshActorNew02(void)
50 {
51   TestApplication application;
52   TestPlatformAbstraction& platform = application.GetPlatform();
53
54   tet_infoline("Testing Dali::MeshActor::New()");
55
56   std::string modelName("AModel");
57   Dali::ModelData modelData = Dali::ModelData::New(modelName);
58   Dali::Entity rootEntity = Dali::Entity::New("root");
59   modelData.SetRootEntity(rootEntity);
60   rootEntity.SetType(Dali::Entity::OBJECT);
61
62   Model model = Model::New("Fake model");
63
64   // Run Core - will query using TestPlatformAbstraction::GetResources().
65   application.SendNotification();
66   application.Render();
67
68   Integration::ResourceRequest* request = platform.GetRequest();
69   if(request)
70   {
71     platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject())));
72   }
73
74   application.Render();
75   application.SendNotification();
76
77   Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded
78
79   DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded);
80   DALI_TEST_CHECK(actor);
81   DALI_TEST_CHECK(actor.GetName().compare("root") == 0);
82   END_TEST;
83 }
84
85
86 int UtcDaliMeshActorCreateNoMeshData(void)
87 {
88   TestApplication application;
89   tet_infoline("Testing Dali::Mesh::New() - Create with no mesh data");
90
91   try
92   {
93     MeshData meshData;
94     Mesh mesh = Mesh::New(meshData);
95     MeshActor actor1 = MeshActor::New(mesh);
96   }
97   catch(Dali::DaliException& e)
98   {
99     DALI_TEST_PRINT_ASSERT( e );
100     DALI_TEST_ASSERT(e, "object", TEST_LOCATION);
101   }
102   END_TEST;
103 }
104
105
106 int UtcDaliMeshActorCreateSetData01(void)
107 {
108   TestApplication application;
109   tet_infoline("Testing Dali::MeshData::SetData() - Create with no verts");
110   try
111   {
112     MeshData meshData;
113     MeshData::VertexContainer vertices;
114     MeshData::FaceIndices     faces;
115     BoneContainer             bones;
116     Material                  customMaterial;
117     meshData.SetData(vertices, faces, bones, customMaterial);
118     Mesh mesh = Mesh::New(meshData);
119     MeshActor actor1 = MeshActor::New(mesh);
120   }
121   catch(Dali::DaliException& e)
122   {
123     DALI_TEST_PRINT_ASSERT( e );
124     DALI_TEST_ASSERT(e, "!vertices.empty()", TEST_LOCATION );
125   }
126   END_TEST;
127 }
128
129 int UtcDaliMeshActorCreateSetData02(void)
130 {
131   TestApplication application;
132   tet_infoline("Testing Dali::MeshData::SetData - Create with no faces");
133   try
134   {
135     MeshData meshData;
136     MeshData::VertexContainer    vertices;
137     MeshData::FaceIndices        faces;
138     BoneContainer                bones;
139     Material                     customMaterial;
140     ConstructVertices(vertices, 60);
141     meshData.SetData(vertices, faces, bones, customMaterial);
142     Mesh mesh = Mesh::New(meshData);
143     MeshActor actor1 = MeshActor::New(mesh);
144   }
145   catch(Dali::DaliException& e)
146   {
147     DALI_TEST_PRINT_ASSERT( e );
148     DALI_TEST_ASSERT(e, "!faceIndices.empty", TEST_LOCATION );
149   }
150   END_TEST;
151 }
152
153 int UtcDaliMeshActorCreateSetData03(void)
154 {
155   TestApplication application;
156   tet_infoline("Testing Dali::MeshData::SetData - Create with no mats");
157   try
158   {
159     MeshData meshData;
160     MeshData::VertexContainer    vertices;
161     MeshData::FaceIndices        faces;
162     BoneContainer                bones;
163     Material                     customMaterial;
164     ConstructVertices(vertices, 60);
165     ConstructFaces(vertices, faces);
166     meshData.SetData(vertices, faces, bones, customMaterial);
167     Mesh mesh = Mesh::New(meshData);
168     MeshActor actor1 = MeshActor::New(mesh);
169   }
170   catch(Dali::DaliException& e)
171   {
172     DALI_TEST_PRINT_ASSERT( e );
173     DALI_TEST_ASSERT(e, "material", TEST_LOCATION );
174   }
175   END_TEST;
176 }
177
178 int UtcDaliMeshActorCreateSetData04(void)
179 {
180   TestApplication application;
181   tet_infoline("Testing Dali::MeshActor::SetData()");
182
183   MeshData meshData;
184   MeshData::VertexContainer    vertices;
185   MeshData::FaceIndices        faces;
186   BoneContainer                bones;
187   ConstructVertices(vertices, 60);
188   ConstructFaces(vertices, faces);
189   Material customMaterial = ConstructMaterial();
190   meshData.SetData(vertices, faces, bones, customMaterial);
191
192   Mesh mesh = Mesh::New(meshData);
193   MeshActor actor1 = MeshActor::New(mesh);
194   DALI_TEST_CHECK(actor1);
195   END_TEST;
196 }
197
198
199 int UtcDaliMeshActorDownCast(void)
200 {
201   TestApplication application;
202   tet_infoline("Testing Dali::MeshActor::DownCast()");
203
204   MeshData meshData;
205   MeshData::VertexContainer    vertices;
206   MeshData::FaceIndices        faces;
207   BoneContainer                bones;
208   ConstructVertices(vertices, 60);
209   ConstructFaces(vertices, faces);
210   Material customMaterial = ConstructMaterial();
211   meshData.SetData(vertices, faces, bones, customMaterial);
212   Mesh mesh = Mesh::New(meshData);
213
214   MeshActor actor1 = MeshActor::New(mesh);
215   Actor anActor = Actor::New();
216   anActor.Add(actor1);
217
218   Actor child = anActor.GetChildAt(0);
219   MeshActor meshActor = MeshActor::DownCast(child);
220
221   DALI_TEST_CHECK(meshActor);
222   END_TEST;
223 }
224
225 int UtcDaliMeshActorDownCast2(void)
226 {
227   TestApplication application;
228   tet_infoline("Testing Dali::MeshActor::DownCast()");
229
230   Actor actor1 = Actor::New();
231   Actor anActor = Actor::New();
232   anActor.Add(actor1);
233
234   Actor child = anActor.GetChildAt(0);
235   MeshActor meshActor = MeshActor::DownCast(child);
236   DALI_TEST_CHECK(!meshActor);
237
238   Actor unInitialzedActor;
239   meshActor = DownCast< MeshActor >( unInitialzedActor );
240   DALI_TEST_CHECK(!meshActor);
241   END_TEST;
242 }
243
244 int UtcDaliMeshActorSetMaterial01(void)
245 {
246   TestApplication application;
247   tet_infoline("Testing Dali::MeshActor::SetMaterial()");
248
249   Mesh mesh = NewMesh();
250
251   MeshActor actor = MeshActor::New(mesh);
252   std::string name = "AMeshActor";
253   Stage::GetCurrent().Add(actor);
254   actor.SetName(name);
255   application.SendNotification();
256   application.Render();
257   application.Render();
258   application.SendNotification();
259
260   Material customMaterial = Material::New("CustomMaterial");
261   customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
262
263   MeshActor::SetMaterial(actor, name, customMaterial);
264   application.SendNotification();
265   application.Render();
266   application.Render();
267   application.SendNotification();
268
269   DALI_TEST_CHECK( actor.GetMaterial() == customMaterial );
270   END_TEST;
271 }
272
273 int UtcDaliMeshActorSetMaterial01b(void)
274 {
275   TestApplication application;
276   tet_infoline("Testing Dali::MeshActor::SetMaterial()");
277
278   Mesh mesh = NewMesh();
279
280   Actor rootActor = Actor::New();
281   MeshActor meshActor = MeshActor::New(mesh);
282   rootActor.Add(meshActor);
283
284   std::string name = "AMeshActor";
285   meshActor.SetName(name);
286
287   Stage::GetCurrent().Add(rootActor);
288   application.SendNotification();
289   application.Render();
290   application.Render();
291   application.SendNotification();
292
293   Material customMaterial = Material::New("CustomMaterial");
294   customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
295
296   MeshActor::SetMaterial(rootActor, name, customMaterial);
297   application.SendNotification();
298   application.Render();
299   application.Render();
300   application.SendNotification();
301
302   DALI_TEST_CHECK(meshActor.GetMaterial() == customMaterial );
303   END_TEST;
304 }
305
306
307 int UtcDaliMeshActorSetMaterial02(void)
308 {
309   TestApplication application;
310   tet_infoline("Testing Dali::MeshActor::SetMaterial()");
311
312   Mesh mesh = NewMesh();
313   MeshActor actor = MeshActor::New(mesh);
314
315   std::string name = "AMeshActor";
316   actor.SetName(name);
317   Stage::GetCurrent().Add(actor);
318   application.SendNotification();
319   application.Render();
320   application.Render();
321   application.SendNotification();
322
323   Material baseMat = actor.GetMaterial();
324   Material customMaterial = Material::New("CustomMaterial");
325   customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
326
327   MeshActor::SetMaterial(actor, "NoName", customMaterial);
328   application.SendNotification();
329   application.Render();
330   application.Render();
331   application.SendNotification();
332
333   DALI_TEST_CHECK( actor.GetMaterial() == baseMat );
334   DALI_TEST_CHECK( actor.GetMaterial() != customMaterial );
335   END_TEST;
336 }
337
338 int UtcDaliMeshActorSetMaterial02b(void)
339 {
340   TestApplication application;
341   tet_infoline("Testing Dali::MeshActor::SetMaterial()");
342
343   Mesh mesh = NewMesh();
344
345   MeshActor actor = MeshActor::New(mesh);
346   Stage::GetCurrent().Add(actor);
347
348   std::string name = "AMeshActor";
349   actor.SetName(name);
350   application.SendNotification();
351   application.Render();
352   application.Render();
353   application.SendNotification();
354
355   Material baseMat = actor.GetMaterial();
356   Material customMaterial = Material::New("CustomMaterial");
357   customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
358
359   MeshActor::SetMaterial(actor, "NoName", customMaterial);
360   application.SendNotification();
361   application.Render();
362   application.Render();
363   application.SendNotification();
364
365   DALI_TEST_CHECK( actor.GetMaterial() == baseMat );
366   DALI_TEST_CHECK( actor.GetMaterial() != customMaterial );
367   END_TEST;
368 }
369
370
371 int UtcDaliMeshActorSetMaterial03(void)
372 {
373   TestApplication application;
374   tet_infoline("Testing Dali::MeshActor::SetMaterial()");
375
376   Mesh mesh = NewMesh();
377
378   MeshActor actor = MeshActor::New(mesh);
379   std::string name = "AMeshActor";
380   actor.SetName(name);
381   Stage::GetCurrent().Add(actor);
382
383   Material customMaterial = Material::New("CustomMaterial");
384   customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
385
386   actor.SetMaterial(customMaterial);
387   application.SendNotification();
388   application.Render(0);
389   application.Render(16);
390   application.SendNotification();
391
392   DALI_TEST_CHECK(actor.GetMaterial() == customMaterial );
393   END_TEST;
394 }
395
396 int UtcDaliMeshActorSetMaterial03b(void)
397 {
398   TestApplication application;
399   tet_infoline("Testing Dali::MeshActor::SetMaterial()");
400
401   Mesh mesh = NewMesh();
402
403   MeshActor actor = MeshActor::New(mesh);
404   std::string name = "AMeshActor";
405   actor.SetName(name);
406   Stage::GetCurrent().Add(actor);
407
408   Material customMaterial = Material::New("CustomMaterial");
409   customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f));
410
411   actor.SetMaterial(customMaterial);
412   application.SendNotification();
413   application.Render(0);
414   application.Render(16);
415   application.SendNotification();
416   DALI_TEST_CHECK(actor.GetMaterial() == customMaterial );
417   END_TEST;
418 }
419
420
421
422 int UtcDaliMeshActorGetMaterial01(void)
423 {
424   TestApplication application;
425   tet_infoline("Testing Dali::MeshActor::SetMaterial()");
426
427   MeshData meshData;
428   MeshData::VertexContainer vertices;
429   MeshData::FaceIndices faces;
430   BoneContainer bones;
431   ConstructVertices(vertices, 60);
432   ConstructFaces(vertices, faces);
433   Material material = ConstructMaterial();
434   meshData.SetData(vertices, faces, bones, material);
435   Mesh mesh = Mesh::New(meshData);
436
437   MeshActor actor = MeshActor::New(mesh);
438   std::string name = "AMeshActor";
439   actor.SetName(name);
440   application.SendNotification();
441   application.Render();
442   application.Render();
443   application.SendNotification();
444
445   Material gotMaterial = actor.GetMaterial();
446
447   DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION );
448   DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION );
449   DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION );
450   DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION );
451   END_TEST;
452 }
453
454
455 int UtcDaliMeshActorGetMaterial02(void)
456 {
457   TestApplication application;
458   tet_infoline("Testing Dali::MeshActor::SetMaterial()");
459
460   MeshData meshData;
461   MeshData::VertexContainer vertices;
462   MeshData::FaceIndices faces;
463   BoneContainer bones;
464   ConstructVertices(vertices, 60);
465   ConstructFaces(vertices, faces);
466   Material material = ConstructMaterial();
467   meshData.SetData(vertices, faces, bones, material);
468   Mesh mesh = Mesh::New(meshData);
469
470   MeshActor actor = MeshActor::New(mesh);
471   std::string name = "AMeshActor";
472   actor.SetName(name);
473   application.SendNotification();
474   application.Render();
475   application.Render();
476   application.SendNotification();
477
478   Material gotMaterial = actor.GetMaterial();
479
480   DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION );
481   DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION );
482   DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION );
483   DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION );
484   END_TEST;
485 }
486
487 int UtcDaliMeshActorSetLighting01(void)
488 {
489   TestApplication application;
490   tet_infoline("Testing Dali::MeshActor::GetLighting()");
491
492   Mesh mesh = NewMesh();
493
494   MeshActor actor = MeshActor::New(mesh);
495   Stage::GetCurrent().Add(actor);
496
497   // Mesh actors should be lit by default
498   DALI_TEST_EQUALS(actor.IsAffectedByLighting(), true, TEST_LOCATION);
499   END_TEST;
500 }
501
502 int UtcDaliMeshActorSetLighting02(void)
503 {
504   TestApplication application;
505   tet_infoline("Testing Dali::MeshActor::SetLighting()");
506
507   Mesh mesh = NewMesh();
508   MeshActor actor = MeshActor::New(mesh);
509   Stage::GetCurrent().Add(actor);
510
511   application.SendNotification();
512   application.Render();
513   application.Render();
514   application.SendNotification();
515
516   Light light = Light::New("KeyLight");
517   light.SetFallOff(Vector2(10000.0f, 10000.0f));
518   LightActor keyLightActor = LightActor::New();
519   keyLightActor.SetParentOrigin(ParentOrigin::CENTER);
520   keyLightActor.SetPosition(200.0f, 500.0f, 300.0f);
521   keyLightActor.SetName(light.GetName());
522
523   Stage::GetCurrent().Add(keyLightActor);
524   keyLightActor.SetLight(light);
525   keyLightActor.SetActive(true);
526
527   actor.SetAffectedByLighting(true);
528   DALI_TEST_EQUALS(actor.IsAffectedByLighting(), true, TEST_LOCATION);
529
530   // Test rendering to ensure that the correct shader setup is used in renderer
531   // (check in debugger or via coverage)
532   application.Render(1);
533   application.SendNotification();
534   application.Render(1);
535   application.SendNotification();
536   application.Render(1);
537   application.SendNotification();
538   application.Render(1);
539   application.SendNotification();
540   application.Render(1);
541
542   actor.SetAffectedByLighting(false);
543   DALI_TEST_EQUALS(actor.IsAffectedByLighting(), false, TEST_LOCATION);
544
545   // Test rendering to ensure that the correct shader setup is used in renderer
546   // (check in debugger or via coverage)
547   application.Render(1);
548   application.SendNotification();
549   application.Render(1);
550   application.SendNotification();
551   application.Render(1);
552   application.SendNotification();
553   application.Render(1);
554   application.SendNotification();
555   application.Render(1);
556   END_TEST;
557 }
558
559 namespace
560 {
561
562 Material ConstructMaterial(float opacity, float diffuseOpacity)
563 {
564   Material customMaterial = Material::New("CustomMaterial");
565   customMaterial.SetOpacity(opacity);
566   customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, diffuseOpacity));
567   customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f));
568   customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f));
569   return customMaterial;
570 }
571
572 static void TestBlending( TestApplication& application, Material material, float actorOpacity, BlendingMode::Type blendingMode, bool expectedBlend )
573 {
574   MeshData meshData;
575   MeshData::VertexContainer vertices;
576   MeshData::FaceIndices faces;
577   BoneContainer bones;
578   ConstructVertices(vertices, 60);
579   ConstructFaces(vertices, faces);
580   meshData.SetData(vertices, faces, bones, material);
581   Mesh mesh = Mesh::New(meshData);
582
583   application.SendNotification();
584   application.Render(0);
585   application.Render();
586   application.SendNotification();
587
588   MeshActor actor = MeshActor::New(mesh);
589   Stage::GetCurrent().Add(actor);
590
591   actor.SetAffectedByLighting(false);
592   actor.SetBlendMode(blendingMode);
593   actor.SetOpacity(actorOpacity);
594
595   TraceCallStack& cullFaceTrace = application.GetGlAbstraction().GetCullFaceTrace();
596   cullFaceTrace.Enable(true);
597   application.SendNotification();
598   application.Render();
599   DALI_TEST_EQUALS( BlendEnabled( cullFaceTrace ), expectedBlend, TEST_LOCATION );
600 }
601 } //anonymous namespace
602
603
604 int UtcDaliMeshActorBlend01(void)
605 {
606   // Set Material with translucent color, actor color opaque, Set Use image alpha to true
607   // Expect blending
608
609   TestApplication application;
610   tet_infoline("Testing Dali::MeshActor::Blend01()");
611
612   TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::AUTO, true );
613   END_TEST;
614 }
615
616
617 int UtcDaliMeshActorBlend02(void)
618 {
619   // Set material to translucent, set use image alpha to false, set actor opacity to 1.0f
620   // Expect no blending
621
622   TestApplication application;
623   tet_infoline("Testing Dali::MeshActor::Blend02()");
624   TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::OFF, false );
625   END_TEST;
626 }
627
628 int UtcDaliMeshActorBlend03(void)
629 {
630   // Set material to opaque, set use image alpha to true, set actor opacity to 1.0f
631   // Expect no blending
632
633   TestApplication application;
634   tet_infoline("Testing Dali::MeshActor::Blend03()");
635   TestBlending( application, ConstructMaterial(1.0f, 1.0f), 1.0f, BlendingMode::AUTO, false );
636   END_TEST;
637 }
638
639
640 int UtcDaliMeshActorBlend04(void)
641 {
642   // Set material to have image with alpha, set use image alpha to true, set actor opacity to 1.0f
643   // Expect blending
644   TestApplication application;
645   tet_infoline("Testing Dali::MeshActor::Blend04()");
646
647   Material material = ConstructMaterial(1.0f, 1.0f);
648   BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
649   material.SetDiffuseTexture( image );
650   application.SendNotification();
651   application.Render(0);
652
653   TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
654   END_TEST;
655 }
656
657 int UtcDaliMeshActorBlend05(void)
658 {
659   // Set material to have image with alpha, set use image alpha to false, set actor opacity to 1.0f
660   // Expect no blending
661
662   TestApplication application;
663   tet_infoline("Testing Dali::MeshActor::Blend05()");
664
665   Material material = ConstructMaterial(1.0f, 1.0f);
666   BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
667   material.SetDiffuseTexture( image );
668   application.SendNotification();
669   application.Render(0);
670
671   TestBlending( application, material, 1.0f, BlendingMode::ON, true );
672   END_TEST;
673 }
674
675
676 int UtcDaliMeshActorBlend06(void)
677 {
678   // Set material to have image without alpha, set use image alpha to true, set actor opacity to 1.0f
679   // Expect no blending
680
681   TestApplication application;
682   tet_infoline("Testing Dali::MeshActor::Blend()");
683
684   Material material = ConstructMaterial(1.0f, 1.0f);
685   BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 );
686   material.SetDiffuseTexture( image );
687   application.SendNotification();
688   application.Render(0);
689
690   TestBlending( application, material, 1.0f, BlendingMode::AUTO, false );
691   END_TEST;
692 }
693
694 int UtcDaliMeshActorBlend07(void)
695 {
696   // Set material to have framebuffer with alpha, set use image alpha to true, set actor opacity to 1.0f
697   // Expect blending
698   TestApplication application;
699   tet_infoline("Testing Dali::MeshActor::Blend07()");
700   application.Render(0);
701
702   Material material = ConstructMaterial(1.0f, 1.0f);
703   FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 );
704   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
705   RenderTask task = taskList.GetTask( 0u );
706   task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected
707   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
708   application.SendNotification();
709   application.Render();
710
711   material.SetDiffuseTexture( image ); // (to render from)
712   application.SendNotification();
713   application.Render();
714   application.Render();
715   application.SendNotification();
716
717   TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
718   END_TEST;
719 }
720
721 int UtcDaliMeshActorBlend08(void)
722 {
723   // Set material to have image with alpha, set use image alpha to false, set actor opacity to 0.5f
724   // Expect blending
725   TestApplication application;
726   tet_infoline("Testing Dali::MeshActor::Blend08()");
727
728   Material material = ConstructMaterial(1.0f, 1.0f);
729   BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
730   material.SetDiffuseTexture( image );
731   application.SendNotification();
732   application.Render(0);
733
734   TestBlending( application, material, 0.5f, BlendingMode::AUTO, true );
735   END_TEST;
736 }
737
738 int UtcDaliMeshActorBlend09(void)
739 {
740   // 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
741   // Expect blending
742   TestApplication application;
743   tet_infoline("Testing Dali::MeshActor::Blend08()");
744
745   Material material = ConstructMaterial(0.5f, 1.0f);
746   BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 );
747   material.SetDiffuseTexture( image );
748   application.SendNotification();
749   application.Render(0);
750
751   TestBlending( application, material, 1.0f, BlendingMode::AUTO, true );
752   END_TEST;
753 }
754
755 int UtcDaliMeshActorBoneUpdate01(void)
756 {
757   TestApplication application;
758   tet_infoline("Testing Dali::MeshActor::BoneUpdate01()");
759
760   // Set up a mesh with bones.
761   // animate bones
762   // ensure bone actor's world matrix is updated
763
764   Actor trunk = Actor::New();
765   trunk.SetName("trunk");
766   trunk.SetPosition(Vector3(100.0f, 200.0f, 300.0f));
767   trunk.SetRotation(Quaternion(M_PI*0.3f, Vector3::XAXIS));
768   Actor branch = Actor::New();
769   branch.SetName("branch");
770   branch.SetPosition(Vector3(10.0f, 100.0f, 0.0f));
771   branch.SetRotation(Quaternion(M_PI*0.2f, Vector3::YAXIS));
772
773   Actor twig = ImageActor::New(CreateBitmapImage());
774   twig.SetName("twig");
775   branch.SetPosition(Vector3(20.0f, 30.0f, 40.0f));
776
777   Actor bug = Actor::New(); // Not a bone
778   bug.SetName("bug");
779   bug.SetPosition(Vector3(10.0f, 10.0f, 10.0f));
780
781   Stage::GetCurrent().Add(trunk);
782   trunk.Add(branch);
783   branch.Add(twig);
784   twig.Add(bug);
785
786   MeshData meshData;
787   CreateMeshData(meshData); // Created with named bones (as above)
788   Mesh mesh = Mesh::New(meshData);
789   MeshActor meshActor = MeshActor::New(mesh);
790   Stage::GetCurrent().Add(meshActor);
791
792   meshActor.BindBonesToMesh(Stage::GetCurrent().GetRootLayer());
793
794   application.SendNotification();
795   application.Render(0);
796   application.Render();
797   application.SendNotification();
798
799   // How to test?
800   // Need to see what bone actor's node has set as world matrix.
801
802   Animation anim = Animation::New(1.0f);
803   anim.RotateBy(trunk, Radian(M_PI*0.5f), Vector3::ZAXIS);
804   anim.Play();
805   application.SendNotification();
806   application.Render(500);
807   application.SendNotification();
808   application.Render(500);
809   application.SendNotification();
810   application.Render(10);
811
812   // All bones have moved.
813   // Check that their world matrix has been updated: ( Isn't IDENTITY )
814   DALI_TEST_CHECK( ! application.GetGlAbstraction().CheckUniformValue("uModelMatrix", Matrix::IDENTITY ) );
815
816   Matrix worldMatrix;
817   GLuint programId, uniformId;
818   DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformIds("uModelMatrix", programId, uniformId) );
819   DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue( programId, uniformId, worldMatrix) );
820
821   // But also check that property is calculated as needed:
822   Matrix calcWorldMatrix = twig.GetCurrentWorldMatrix();
823   DALI_TEST_CHECK( Matrix::IDENTITY != calcWorldMatrix );
824   DALI_TEST_CHECK( worldMatrix == calcWorldMatrix );
825   END_TEST;
826
827 }
828
829 int UtcDaliMeshActorIndices(void)
830 {
831   TestApplication application;
832   Actor basicActor = Actor::New();
833   Mesh mesh = NewMesh();
834   MeshActor meshActor = MeshActor::New(mesh);
835
836   Property::IndexContainer indices;
837   meshActor.GetPropertyIndices( indices );
838   DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties
839   DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION );
840   END_TEST;
841 }