[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-scene3d / utc-Dali-Model.cpp
1 /*
2  * Copyright (c) 2024 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 <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali/devel-api/common/map-wrapper.h>
21 #include <dali/public-api/common/vector-wrapper.h>
22 #include <stdlib.h>
23 #include <iostream>
24
25 #include <dali-toolkit/devel-api/focus-manager/keyboard-focus-manager-devel.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <toolkit-environment-variable.h>
28 #include <toolkit-event-thread-callback.h>
29
30 #include <dali-scene3d/public-api/controls/model/model.h>
31 #include <dali-scene3d/public-api/model-components/model-node.h>
32
33 #include <dali-scene3d/public-api/model-motion/motion-data.h>
34 #include <dali-scene3d/public-api/model-motion/motion-index/blend-shape-index.h>
35 #include <dali-scene3d/public-api/model-motion/motion-index/motion-transform-index.h>
36
37 #include <dali-scene3d/public-api/loader/node-definition.h>
38
39 #include <dali/devel-api/actors/camera-actor-devel.h>
40
41 using namespace Dali;
42 using namespace Dali::Toolkit;
43
44 void model_startup(void)
45 {
46   test_return_value = TET_UNDEF;
47 }
48
49 void model_cleanup(void)
50 {
51   test_return_value = TET_PASS;
52 }
53
54 namespace
55 {
56 const bool DEFAULT_MODEL_CHILDREN_SENSITIVE = false;
57 const bool DEFAULT_MODEL_CHILDREN_FOCUSABLE = false;
58 /**
59  * For the AnimatedCube.gltf and its Assets
60  * Donated by Norbert Nopper for glTF testing.
61  * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
62  */
63 const char* TEST_GLTF_FILE_NAME                    = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
64 const char* TEST_GLTF_FILE_NAME_SAME_FILE          = TEST_RESOURCE_DIR "/AnimatedCube2.gltf";
65 const char* TEST_GLTF_FILE_NAME_DIFF_META_FILE     = TEST_RESOURCE_DIR "/AnimatedCube3.gltf";
66 const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME     = TEST_RESOURCE_DIR "/animationTest.gltf";
67 const char* TEST_GLTF_EXTRAS_FILE_NAME             = TEST_RESOURCE_DIR "/AnimatedMorphCubeAnimateNonZeroFrame.gltf";
68 const char* TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME = TEST_RESOURCE_DIR "/simpleMultiplePrimitiveTest.gltf";
69 const char* TEST_GLTF_MORPH_FILE_NAME              = TEST_RESOURCE_DIR "/AnimatedMorphCube.gltf";
70 const char* TEST_DLI_FILE_NAME                     = TEST_RESOURCE_DIR "/arc.dli";
71 const char* TEST_DLI_EXERCISE_FILE_NAME            = TEST_RESOURCE_DIR "/exercise.dli";
72
73 /**
74  * For the diffuse and specular cube map texture.
75  * These textures are based off version of Wave engine sample
76  * Take from https://github.com/WaveEngine/Samples
77  *
78  * Copyright (c) 2024 Wave Coorporation
79  *
80  * Permission is hereby granted, free of charge, to any person obtaining a copy
81  * of this software and associated documentation files (the "Software"), to
82  * deal in the Software without restriction, including without limitation the
83  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
84  * sell copies of the Software, and to permit persons to whom the Software is
85  * furnished to do so, subject to the following conditions:
86  *
87  * The above copyright notice and this permission notice shall be included in
88  * all copies or substantial portions of the Software.
89  *
90  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
91  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
92  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
93  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
94  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
95  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
96  * THE SOFTWARE.
97  */
98 const char* TEST_DIFFUSE_TEXTURE  = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
99 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
100
101 bool gTouchCallBackCalled = false;
102 bool TestTouchCallback(Actor, const TouchEvent&)
103 {
104   gTouchCallBackCalled = true;
105   return true;
106 }
107
108 bool gFocusChangedCallBackCalled = false;
109 void TestFocusChangedCallback(Actor, Actor)
110 {
111   gFocusChangedCallBackCalled = true;
112 }
113
114 // For ResourceReady
115 static bool gOnRelayoutCallBackCalled = false;
116 void        OnRelayoutCallback(Actor actor)
117 {
118   gOnRelayoutCallBackCalled = true;
119 }
120
121 static bool gResourceReadyCalled = false;
122 void        OnResourceReady(Control control)
123 {
124   gResourceReadyCalled = true;
125 }
126
127 void ApplyAllMaterialPropertyRecursively(Scene3D::ModelNode modelNode, const std::vector<KeyValuePair>& materialPropertyValues)
128 {
129   if(!modelNode)
130   {
131     return;
132   }
133
134   for(uint32_t primitiveIndex = 0u; primitiveIndex < modelNode.GetModelPrimitiveCount(); ++primitiveIndex)
135   {
136     Scene3D::ModelPrimitive primitive = modelNode.GetModelPrimitive(primitiveIndex);
137     if(primitive)
138     {
139       Scene3D::Material material = primitive.GetMaterial();
140       if(material)
141       {
142         for(const auto& keyValuePair : materialPropertyValues)
143         {
144           if(keyValuePair.first.type == Property::Key::Type::INDEX)
145           {
146             material.SetProperty(keyValuePair.first.indexKey, keyValuePair.second);
147           }
148         }
149       }
150     }
151   }
152
153   for(uint32_t childIndex = 0u; childIndex < modelNode.GetChildCount(); ++childIndex)
154   {
155     Scene3D::ModelNode childNode = Scene3D::ModelNode::DownCast(modelNode.GetChildAt(childIndex));
156     ApplyAllMaterialPropertyRecursively(childNode, materialPropertyValues);
157   }
158 }
159
160 } // namespace
161
162 // Negative test case for a method
163 int UtcDaliModelUninitialized(void)
164 {
165   ToolkitTestApplication application;
166   tet_infoline(" UtcDaliModelUninitialized");
167
168   Scene3D::Model model;
169
170   try
171   {
172     // New() must be called to create a Model or it wont be valid.
173     Actor a = Actor::New();
174     model.Add(a);
175     DALI_TEST_CHECK(false);
176   }
177   catch(Dali::DaliException& e)
178   {
179     // Tests that a negative test of an assertion succeeds
180     DALI_TEST_PRINT_ASSERT(e);
181     DALI_TEST_CHECK(!model);
182   }
183   END_TEST;
184 }
185
186 // Positive test case for a method
187 int UtcDaliModelNew(void)
188 {
189   ToolkitTestApplication application;
190   tet_infoline(" UtcDaliModelNew");
191
192   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
193   DALI_TEST_CHECK(model);
194   END_TEST;
195 }
196
197 // Positive test case for a method
198 int UtcDaliModelNewP2(void)
199 {
200   ToolkitTestApplication application;
201   tet_infoline(" UtcDaliModelNew without url");
202
203   Scene3D::Model model = Scene3D::Model::New();
204   DALI_TEST_CHECK(model);
205
206   application.GetScene().Add(model);
207
208   DALI_TEST_CHECK(model.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
209
210   application.GetScene().Remove(model);
211
212   DALI_TEST_CHECK(!model.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
213
214   END_TEST;
215 }
216
217 int UtcDaliModelNewSameModelUrlCached(void)
218 {
219   ToolkitTestApplication application;
220   tet_infoline(" UtcDaliModelNew with same model");
221
222   // Set up trace debug
223   TestGlAbstraction& gl           = application.GetGlAbstraction();
224   TraceCallStack&    textureTrace = gl.GetTextureTrace();
225   textureTrace.Enable(true);
226
227   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
228   DALI_TEST_CHECK(model);
229   Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
230   DALI_TEST_CHECK(model2);
231
232   application.GetScene().Add(model);
233
234   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
235
236   application.SendNotification();
237   application.Render();
238
239   tet_printf("Test if there is at least 1 texture.\n");
240   int expectTextureCount = textureTrace.CountMethod("GenTextures");
241   DALI_TEST_GREATER(expectTextureCount, 0, TEST_LOCATION);
242
243   application.GetScene().Add(model2);
244
245   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
246
247   application.SendNotification();
248   application.Render();
249
250   tet_printf("Test if we reuse cached texture or not.\n");
251   int currentTextureCount = textureTrace.CountMethod("GenTextures");
252   DALI_TEST_EQUALS(currentTextureCount, expectTextureCount, TEST_LOCATION);
253
254   application.SendNotification();
255   application.Render();
256
257   END_TEST;
258 }
259
260 int UtcDaliModelNewSameResourceUrlCached01(void)
261 {
262   ToolkitTestApplication application;
263   tet_infoline(" UtcDaliModelNew with difference url but same model");
264
265   // Set up trace debug
266   TestGlAbstraction& gl           = application.GetGlAbstraction();
267   TraceCallStack&    textureTrace = gl.GetTextureTrace();
268   textureTrace.Enable(true);
269   textureTrace.EnableLogging(true);
270
271   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
272   DALI_TEST_CHECK(model);
273   Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME_SAME_FILE); // Difference model that use same Images.
274   DALI_TEST_CHECK(model2);
275   Scene3D::Model model3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME_DIFF_META_FILE); // Difference model that use same Images, but difference metadata.
276   DALI_TEST_CHECK(model3);
277
278   application.GetScene().Add(model);
279
280   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
281
282   application.SendNotification();
283   application.Render();
284
285   tet_printf("Test if there is at least 1 texture.\n");
286   int expectTextureCount = textureTrace.CountMethod("GenTextures");
287   DALI_TEST_GREATER(expectTextureCount, 0, TEST_LOCATION);
288
289   application.GetScene().Add(model2);
290
291   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
292
293   application.SendNotification();
294   application.Render();
295
296   tet_printf("Test if we reuse cached texture or not.\n");
297   int currentTextureCount = textureTrace.CountMethod("GenTextures");
298   DALI_TEST_EQUALS(currentTextureCount, expectTextureCount, TEST_LOCATION);
299
300   application.GetScene().Add(model3);
301
302   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
303
304   application.SendNotification();
305   application.Render();
306
307   tet_printf("Test if we don't reuse cached texture, due to the metadata difference.\n");
308   currentTextureCount = textureTrace.CountMethod("GenTextures");
309   DALI_TEST_GREATER(currentTextureCount, expectTextureCount, TEST_LOCATION);
310
311   application.SendNotification();
312   application.Render();
313
314   END_TEST;
315 }
316
317 int UtcDaliModelNewSameResourceUrlCached02(void)
318 {
319   /// Make we don't use mutiple thread loading for this UTC.
320   EnvironmentVariable::SetTestEnvironmentVariable("DALI_ASYNC_MANAGER_THREAD_POOL_SIZE", "1");
321   EnvironmentVariable::SetTestEnvironmentVariable("DALI_ASYNC_MANAGER_LOW_PRIORITY_THREAD_POOL_SIZE", "1");
322
323   ToolkitTestApplication application;
324   tet_infoline(" UtcDaliModelNew with difference url but same model");
325
326   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
327   DALI_TEST_CHECK(model);
328   Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME_SAME_FILE);
329   DALI_TEST_CHECK(model2);
330
331   application.GetScene().Add(model);
332   application.GetScene().Add(model2);
333
334   application.SendNotification();
335   application.Render();
336
337   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
338   application.SendNotification();
339   application.Render();
340
341   END_TEST;
342 }
343
344 // Positive test case for a method
345 int UtcDaliModelDownCast(void)
346 {
347   ToolkitTestApplication application;
348   tet_infoline(" UtcDaliModelDownCast");
349
350   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
351   BaseHandle     handle(model);
352
353   Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
354   DALI_TEST_CHECK(model);
355   DALI_TEST_CHECK(model2);
356   DALI_TEST_CHECK(model2 == model);
357   END_TEST;
358 }
359
360 int UtcDaliModelTypeRegistry(void)
361 {
362   ToolkitTestApplication application;
363
364   TypeRegistry typeRegistry = TypeRegistry::Get();
365   DALI_TEST_CHECK(typeRegistry);
366
367   TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
368   DALI_TEST_CHECK(typeInfo);
369
370   BaseHandle handle = typeInfo.CreateInstance();
371   DALI_TEST_CHECK(handle);
372
373   Scene3D::Model model = Scene3D::Model::DownCast(handle);
374   DALI_TEST_CHECK(model);
375
376   END_TEST;
377 }
378
379 // Positive test case for a method
380 int UtcDaliModelAddRemove(void)
381 {
382   ToolkitTestApplication application;
383   tet_infoline(" UtcDaliModelAddRemove");
384
385   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
386   DALI_TEST_CHECK(model);
387
388   Actor actor = Actor::New();
389   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
390
391   model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
392   model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
393   model.Add(actor);
394   application.GetScene().Add(model);
395
396   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
397
398   model.Remove(actor);
399
400   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
401   END_TEST;
402 }
403
404 int UtcDaliModelCopyAndAssignment(void)
405 {
406   ToolkitTestApplication application;
407
408   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
409   DALI_TEST_CHECK(model);
410
411   Scene3D::Model copy(model);
412   DALI_TEST_CHECK(model == copy);
413
414   Scene3D::Model assign;
415   DALI_TEST_CHECK(!assign);
416
417   assign = copy;
418   DALI_TEST_CHECK(assign == model);
419
420   END_TEST;
421 }
422
423 int UtcDaliModelMoveConstructor(void)
424 {
425   ToolkitTestApplication application;
426
427   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
428   DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
429   model.SetProperty(Actor::Property::SENSITIVE, false);
430   DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
431
432   Scene3D::Model moved = std::move(model);
433   DALI_TEST_CHECK(moved);
434   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
435   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
436   DALI_TEST_CHECK(!model);
437
438   END_TEST;
439 }
440
441 int UtcDaliModelMoveAssignment(void)
442 {
443   ToolkitTestApplication application;
444
445   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
446   DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
447   model.SetProperty(Actor::Property::SENSITIVE, false);
448   DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
449
450   Scene3D::Model moved;
451   moved = std::move(model);
452   DALI_TEST_CHECK(moved);
453   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
454   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
455   DALI_TEST_CHECK(!model);
456
457   END_TEST;
458 }
459
460 int UtcDaliModelOnScene01(void)
461 {
462   ToolkitTestApplication application;
463
464   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
465   application.GetScene().Add(model);
466
467   gResourceReadyCalled = false;
468   model.ResourceReadySignal().Connect(&OnResourceReady);
469   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
470
471   application.SendNotification();
472   application.Render();
473
474   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
475   application.SendNotification();
476   application.Render();
477
478   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
479
480   uint32_t modelCount = model.GetModelRoot().GetChildCount();
481   DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
482   END_TEST;
483 }
484
485 int UtcDaliModelOnScene02(void)
486 {
487   ToolkitTestApplication application;
488
489   Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
490   application.GetScene().Add(model);
491
492   gResourceReadyCalled = false;
493   model.ResourceReadySignal().Connect(&OnResourceReady);
494   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
495
496   application.SendNotification();
497   application.Render();
498
499   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
500   application.SendNotification();
501   application.Render();
502
503   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
504
505   uint32_t modelCount = model.GetModelRoot().GetChildCount();
506   DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
507
508   Scene3D::ModelNode rootNode = model.GetModelRoot();
509   Vector3            rootSize = rootNode.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
510   DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
511
512   END_TEST;
513 }
514
515 int UtcDaliModelOnSizeSet(void)
516 {
517   ToolkitTestApplication application;
518
519   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
520
521   application.GetScene().Add(model);
522
523   application.SendNotification();
524   application.Render();
525
526   Vector2 size(200.0f, 300.0f);
527   model.SetProperty(Actor::Property::SIZE, size);
528
529   application.SendNotification();
530   application.Render();
531
532   DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
533
534   END_TEST;
535 }
536
537 int UtcDaliModelGetNaturalSize(void)
538 {
539   ToolkitTestApplication application;
540
541   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
542
543   Vector3 naturalSize = model.GetNaturalSize();
544   DALI_TEST_EQUALS(Vector3::ZERO, naturalSize, TEST_LOCATION);
545
546   application.GetScene().Add(model);
547
548   gResourceReadyCalled = false;
549   model.ResourceReadySignal().Connect(&OnResourceReady);
550   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
551
552   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
553   application.SendNotification();
554
555   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
556
557   naturalSize = model.GetNaturalSize();
558   DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
559
560   Scene3D::ModelNode rootNode = model.GetModelRoot();
561   DALI_TEST_CHECK(rootNode);
562
563   END_TEST;
564 }
565
566 int UtcDaliModelSetImageBasedLightSource01(void)
567 {
568   ToolkitTestApplication application;
569
570   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
571   application.GetScene().Add(model);
572
573   gResourceReadyCalled = false;
574   model.ResourceReadySignal().Connect(&OnResourceReady);
575   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
576
577   application.SendNotification();
578   application.Render();
579
580   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
581   application.SendNotification();
582   application.Render();
583
584   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
585
586   Actor meshActor = model.FindChildByName("AnimatedCube");
587   DALI_TEST_CHECK(meshActor);
588
589   Renderer renderer = meshActor.GetRendererAt(0u);
590   DALI_TEST_CHECK(renderer);
591
592   TextureSet textureSet = renderer.GetTextures();
593   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 10u, TEST_LOCATION);
594
595   Texture diffuseTexture  = textureSet.GetTexture(8u);
596   Texture specularTexture = textureSet.GetTexture(9u);
597
598   gResourceReadyCalled = false;
599   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
600   model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
601
602   application.SendNotification();
603   application.Render();
604
605   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
606   application.SendNotification();
607   application.Render();
608
609   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
610
611   TextureSet newTextureSet      = renderer.GetTextures();
612   Texture    newDiffuseTexture  = newTextureSet.GetTexture(8u);
613   Texture    newSpecularTexture = newTextureSet.GetTexture(9u);
614
615   DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
616   DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
617
618   model.Unparent();
619   model.Reset();
620   END_TEST;
621 }
622
623 int UtcDaliModelSetImageBasedLightSource02(void)
624 {
625   ToolkitTestApplication application;
626
627   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
628   application.GetScene().Add(model);
629
630   gResourceReadyCalled = false;
631   model.ResourceReadySignal().Connect(&OnResourceReady);
632   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
633
634   application.SendNotification();
635   application.Render();
636
637   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
638   application.SendNotification();
639   application.Render();
640
641   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
642
643   Actor meshActor = model.FindChildByName("AnimatedCube");
644   DALI_TEST_CHECK(meshActor);
645
646   Renderer renderer = meshActor.GetRendererAt(0u);
647   DALI_TEST_CHECK(renderer);
648
649   TextureSet textureSet = renderer.GetTextures();
650   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 10u, TEST_LOCATION);
651
652   Texture diffuseTexture  = textureSet.GetTexture(8u);
653   Texture specularTexture = textureSet.GetTexture(9u);
654
655   // if url is empty, loading is not requested.
656   model.SetImageBasedLightSource("", "");
657
658   Texture newDiffuseTexture  = textureSet.GetTexture(8u);
659   Texture newSpecularTexture = textureSet.GetTexture(9u);
660
661   DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
662   DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
663
664   END_TEST;
665 }
666
667 int UtcDaliModelSetImageBasedLightSource03(void)
668 {
669   ToolkitTestApplication application;
670
671   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
672   application.GetScene().Add(model);
673
674   gResourceReadyCalled = false;
675   model.ResourceReadySignal().Connect(&OnResourceReady);
676   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
677
678   application.SendNotification();
679   application.Render();
680
681   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
682   application.SendNotification();
683   application.Render();
684
685   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
686
687   Actor meshActor = model.FindChildByName("AnimatedCube");
688   DALI_TEST_CHECK(meshActor);
689
690   Renderer renderer = meshActor.GetRendererAt(0u);
691   DALI_TEST_CHECK(renderer);
692
693   TextureSet textureSet = renderer.GetTextures();
694   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 10u, TEST_LOCATION);
695
696   Texture diffuseTexture  = textureSet.GetTexture(8u);
697   Texture specularTexture = textureSet.GetTexture(9u);
698
699   gResourceReadyCalled = false;
700   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
701   model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
702
703   application.SendNotification();
704   application.Render();
705
706   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
707   application.SendNotification();
708   application.Render();
709
710   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
711
712   Texture newDiffuseTexture  = textureSet.GetTexture(8u);
713   Texture newSpecularTexture = textureSet.GetTexture(9u);
714
715   DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
716   DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
717
718   END_TEST;
719 }
720
721 int UtcDaliModelSetImageBasedLightSource04(void)
722 {
723   ToolkitTestApplication application;
724
725   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
726   model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
727   application.GetScene().Add(model);
728
729   gResourceReadyCalled = false;
730   model.ResourceReadySignal().Connect(&OnResourceReady);
731   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
732
733   application.SendNotification();
734   application.Render();
735
736   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
737   application.SendNotification();
738   application.Render();
739
740   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
741   END_TEST;
742 }
743
744 int UtcDaliModelImageBasedFactor(void)
745 {
746   ToolkitTestApplication application;
747
748   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
749
750   DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
751
752   model.SetImageBasedLightScaleFactor(0.5f);
753   DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
754   END_TEST;
755 }
756
757 int UtcDaliModelChildrenSensitive01(void)
758 {
759   ToolkitTestApplication application;
760
761   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
762   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
763   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
764   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
765   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
766
767   // Get default vaule.
768   DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
769
770   // Allow children actor's event before on scene.
771   view.SetChildrenSensitive(true);
772   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
773   application.GetScene().Add(view);
774
775   gResourceReadyCalled = false;
776   view.ResourceReadySignal().Connect(&OnResourceReady);
777   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
778
779   application.SendNotification();
780   application.Render();
781
782   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
783   application.SendNotification();
784   application.Render();
785
786   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
787
788   Actor meshActor = view.FindChildByName("AnimatedCube");
789   DALI_TEST_CHECK(meshActor);
790
791   // connect hit-test signal
792   gTouchCallBackCalled = false;
793   meshActor.TouchedSignal().Connect(TestTouchCallback);
794
795   Vector2 sceneSize = application.GetScene().GetSize();
796
797   // Try to touch center of scene.
798   Dali::Integration::Point point;
799   point.SetState(PointState::DOWN);
800   point.SetScreenPosition(sceneSize * 0.5f);
801   Dali::Integration::TouchEvent event;
802   event.AddPoint(point);
803
804   // flush the queue and render once
805   application.SendNotification();
806   application.Render();
807
808   // Not touched yet.
809   DALI_TEST_CHECK(!gTouchCallBackCalled);
810   application.ProcessEvent(event);
811   // Touched.
812   DALI_TEST_CHECK(gTouchCallBackCalled);
813
814   // Clear
815   gTouchCallBackCalled = false;
816
817   // Block children actor's event
818   view.SetChildrenSensitive(false);
819   DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
820
821   // flush the queue and render once
822   application.SendNotification();
823   application.Render();
824
825   // Not touched yet.
826   DALI_TEST_CHECK(!gTouchCallBackCalled);
827   application.ProcessEvent(event);
828   // Also not touched.
829   DALI_TEST_CHECK(!gTouchCallBackCalled);
830
831   // Clear
832   gTouchCallBackCalled = false;
833
834   // Allow again
835   view.SetChildrenSensitive(true);
836   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
837
838   // flush the queue and render once
839   application.SendNotification();
840   application.Render();
841
842   // Not touched yet.
843   DALI_TEST_CHECK(!gTouchCallBackCalled);
844   application.ProcessEvent(event);
845   // Touched.
846   DALI_TEST_CHECK(gTouchCallBackCalled);
847
848   // Clear
849   gTouchCallBackCalled = false;
850
851   END_TEST;
852 }
853
854 int UtcDaliModelChildrenSensitive02(void)
855 {
856   ToolkitTestApplication application;
857
858   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
859   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
860   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
861   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
862   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
863
864   // Get vaule.
865   DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
866
867   // Block children actor's event before on scene.
868   view.SetChildrenSensitive(false);
869   DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
870   application.GetScene().Add(view);
871
872   gResourceReadyCalled = false;
873   view.ResourceReadySignal().Connect(&OnResourceReady);
874   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
875
876   application.SendNotification();
877   application.Render();
878
879   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
880   application.SendNotification();
881   application.Render();
882
883   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
884
885   Actor meshActor = view.FindChildByName("AnimatedCube");
886   DALI_TEST_CHECK(meshActor);
887
888   // connect hit-test signal
889   gTouchCallBackCalled = false;
890   meshActor.TouchedSignal().Connect(TestTouchCallback);
891
892   Vector2 sceneSize = application.GetScene().GetSize();
893
894   // Try to touch center of scene.
895   Dali::Integration::Point point;
896   point.SetState(PointState::DOWN);
897   point.SetScreenPosition(sceneSize * 0.5f);
898   Dali::Integration::TouchEvent event;
899   event.AddPoint(point);
900
901   // flush the queue and render once
902   application.SendNotification();
903   application.Render();
904
905   // Not touched yet.
906   DALI_TEST_CHECK(!gTouchCallBackCalled);
907   application.ProcessEvent(event);
908   // Also not touched.
909   DALI_TEST_CHECK(!gTouchCallBackCalled);
910
911   // Clear
912   gTouchCallBackCalled = false;
913
914   // Allow again
915   view.SetChildrenSensitive(true);
916   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
917
918   // flush the queue and render once
919   application.SendNotification();
920   application.Render();
921
922   // Not touched yet.
923   DALI_TEST_CHECK(!gTouchCallBackCalled);
924   application.ProcessEvent(event);
925   // Touched.
926   DALI_TEST_CHECK(gTouchCallBackCalled);
927
928   // Clear
929   gTouchCallBackCalled = false;
930
931   END_TEST;
932 }
933
934 int UtcDaliModelChildrenFocusable01(void)
935 {
936   ToolkitTestApplication application;
937
938   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
939   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
940   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
941   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
942   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
943
944   // Get vaule. Default is false.
945   DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
946
947   // Allow children actor's focus before on scene.
948   view.SetChildrenFocusable(true);
949   DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
950   application.GetScene().Add(view);
951
952   gResourceReadyCalled = false;
953   view.ResourceReadySignal().Connect(&OnResourceReady);
954   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
955
956   application.SendNotification();
957   application.Render();
958
959   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
960   application.SendNotification();
961   application.Render();
962
963   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
964
965   Actor meshActor = view.FindChildByName("AnimatedCube");
966   DALI_TEST_CHECK(meshActor);
967
968   // Enable the default algorithm
969   KeyboardFocusManager manager = KeyboardFocusManager::Get();
970   DALI_TEST_CHECK(manager);
971   Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
972
973   // connect focusable signal
974   gFocusChangedCallBackCalled = false;
975   meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
976   manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
977
978   // Initialize with some left-positioned actor
979   Control focusStartActor = Control::New();
980   focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
981   focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
982   focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
983   focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
984   focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
985   application.GetScene().Add(focusStartActor);
986
987   // Clear
988   manager.ClearFocus();
989   manager.SetCurrentFocusActor(focusStartActor);
990   gFocusChangedCallBackCalled = false;
991
992   // flush the queue and render once
993   application.SendNotification();
994   application.Render();
995
996   // Focusable view find success
997   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
998   DALI_TEST_CHECK(gFocusChangedCallBackCalled);
999
1000   // Clear
1001   manager.ClearFocus();
1002   manager.SetCurrentFocusActor(focusStartActor);
1003   gFocusChangedCallBackCalled = false;
1004
1005   // Block children actor's focus
1006   view.SetChildrenFocusable(false);
1007   DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
1008
1009   // flush the queue and render once
1010   application.SendNotification();
1011   application.Render();
1012
1013   // Focusable view find failed
1014   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
1015   DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
1016
1017   // Clear
1018   manager.ClearFocus();
1019   manager.SetCurrentFocusActor(focusStartActor);
1020   gFocusChangedCallBackCalled = false;
1021
1022   // Allow again
1023   view.SetChildrenFocusable(true);
1024   DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
1025
1026   // flush the queue and render once
1027   application.SendNotification();
1028   application.Render();
1029
1030   // Focusable view find success
1031   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
1032   DALI_TEST_CHECK(gFocusChangedCallBackCalled);
1033
1034   // Clear
1035   manager.ClearFocus();
1036   manager.SetCurrentFocusActor(focusStartActor);
1037   gFocusChangedCallBackCalled = false;
1038
1039   END_TEST;
1040 }
1041
1042 int UtcDaliModelModelChildrenFocusable02(void)
1043 {
1044   ToolkitTestApplication application;
1045
1046   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1047   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
1048   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
1049   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1050   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1051
1052   // Get vaule. Default is true.
1053   DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
1054
1055   // Block children actor's focus before on scene.
1056   view.SetChildrenFocusable(false);
1057   DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
1058   application.GetScene().Add(view);
1059
1060   gResourceReadyCalled = false;
1061   view.ResourceReadySignal().Connect(&OnResourceReady);
1062   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1063
1064   application.SendNotification();
1065   application.Render();
1066
1067   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1068   application.SendNotification();
1069   application.Render();
1070
1071   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1072
1073   Actor meshActor = view.FindChildByName("AnimatedCube");
1074   DALI_TEST_CHECK(meshActor);
1075
1076   // Enable the default algorithm
1077   KeyboardFocusManager manager = KeyboardFocusManager::Get();
1078   DALI_TEST_CHECK(manager);
1079   Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
1080
1081   // connect focusable signal
1082   gFocusChangedCallBackCalled = false;
1083   meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
1084   manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
1085
1086   // Initialize with some left-positioned actor
1087   Control focusStartActor = Control::New();
1088   focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
1089   focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
1090   focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1091   focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1092   focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
1093   application.GetScene().Add(focusStartActor);
1094
1095   // Clear
1096   manager.ClearFocus();
1097   manager.SetCurrentFocusActor(focusStartActor);
1098   gFocusChangedCallBackCalled = false;
1099
1100   // flush the queue and render once
1101   application.SendNotification();
1102   application.Render();
1103
1104   // Focusable view find failed
1105   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
1106   DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
1107
1108   // Clear
1109   manager.ClearFocus();
1110   manager.SetCurrentFocusActor(focusStartActor);
1111   gFocusChangedCallBackCalled = false;
1112
1113   // Allow again
1114   view.SetChildrenFocusable(true);
1115   DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
1116
1117   // flush the queue and render once
1118   application.SendNotification();
1119   application.Render();
1120
1121   // Focusable view find success
1122   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
1123   DALI_TEST_CHECK(gFocusChangedCallBackCalled);
1124
1125   // Clear
1126   manager.ClearFocus();
1127   manager.SetCurrentFocusActor(focusStartActor);
1128   gFocusChangedCallBackCalled = false;
1129
1130   END_TEST;
1131 }
1132
1133 int UtcDaliModelAnimation01(void)
1134 {
1135   ToolkitTestApplication application;
1136
1137   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1138   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1139   application.GetScene().Add(model);
1140
1141   gResourceReadyCalled = false;
1142   model.ResourceReadySignal().Connect(&OnResourceReady);
1143   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1144
1145   application.SendNotification();
1146   application.Render();
1147
1148   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1149   application.SendNotification();
1150   application.Render();
1151
1152   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1153
1154   uint32_t animationCount = model.GetAnimationCount();
1155   DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
1156
1157   Animation animationByIndex = model.GetAnimation(0u);
1158   DALI_TEST_CHECK(animationByIndex);
1159
1160   Animation animationByName = model.GetAnimation("animation_AnimatedCube");
1161   DALI_TEST_CHECK(animationByName);
1162   DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
1163
1164   END_TEST;
1165 }
1166
1167 int UtcDaliModelAnimation02(void)
1168 {
1169   ToolkitTestApplication application;
1170
1171   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
1172   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1173   application.GetScene().Add(model);
1174
1175   gResourceReadyCalled = false;
1176   model.ResourceReadySignal().Connect(&OnResourceReady);
1177   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1178
1179   application.SendNotification();
1180   application.Render();
1181
1182   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1183   application.SendNotification();
1184   application.Render();
1185
1186   uint32_t animationCount = model.GetAnimationCount();
1187   DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
1188
1189   Animation animation1 = model.GetAnimation("Step Scale");
1190   DALI_TEST_CHECK(animation1);
1191   DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
1192
1193   Animation animation2 = model.GetAnimation("CubicSpline Scale");
1194   DALI_TEST_CHECK(animation2);
1195   DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
1196
1197   DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
1198
1199   END_TEST;
1200 }
1201
1202 int UtcDaliModelAnimation03(void)
1203 {
1204   ToolkitTestApplication application;
1205
1206   Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
1207   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1208   application.GetScene().Add(model);
1209
1210   gResourceReadyCalled = false;
1211   model.ResourceReadySignal().Connect(&OnResourceReady);
1212   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1213
1214   application.SendNotification();
1215   application.Render();
1216
1217   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1218   application.SendNotification();
1219   application.Render();
1220
1221   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1222
1223   uint32_t animationCount = model.GetAnimationCount();
1224   DALI_TEST_EQUALS(18, animationCount, TEST_LOCATION);
1225
1226   Animation animationByIndex = model.GetAnimation(0u);
1227   DALI_TEST_CHECK(animationByIndex);
1228
1229   Animation animationByName = model.GetAnimation("idleClip");
1230   DALI_TEST_CHECK(animationByName);
1231   DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
1232
1233   END_TEST;
1234 }
1235
1236 int UtcDaliModelCameraGenerate01(void)
1237 {
1238   ToolkitTestApplication application;
1239
1240   Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
1241   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1242   application.GetScene().Add(model);
1243
1244   gResourceReadyCalled = false;
1245   model.ResourceReadySignal().Connect(&OnResourceReady);
1246   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1247
1248   application.SendNotification();
1249   application.Render();
1250
1251   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1252   application.SendNotification();
1253   application.Render();
1254
1255   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1256
1257   uint32_t cameraCount = model.GetCameraCount();
1258   DALI_TEST_EQUALS(1, cameraCount, TEST_LOCATION);
1259
1260   CameraActor generatedCamera = model.GenerateCamera(0u);
1261   DALI_TEST_CHECK(generatedCamera);
1262
1263   generatedCamera = model.GenerateCamera(1u); // Fail to generate camera
1264   DALI_TEST_CHECK(!generatedCamera);
1265
1266   END_TEST;
1267 }
1268
1269 int UtcDaliModelCameraGenerate02(void)
1270 {
1271   ToolkitTestApplication application;
1272
1273   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1274   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1275   application.GetScene().Add(model);
1276
1277   gResourceReadyCalled = false;
1278   model.ResourceReadySignal().Connect(&OnResourceReady);
1279   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1280
1281   application.SendNotification();
1282   application.Render();
1283
1284   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1285   application.SendNotification();
1286   application.Render();
1287
1288   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1289
1290   uint32_t cameraCount = model.GetCameraCount();
1291   DALI_TEST_EQUALS(6, cameraCount, TEST_LOCATION);
1292
1293   CameraActor generatedCamera0 = model.GenerateCamera(0u);
1294   DALI_TEST_CHECK(generatedCamera0);
1295   CameraActor generatedCamera1 = model.GenerateCamera(1u);
1296   DALI_TEST_CHECK(generatedCamera1);
1297   CameraActor generatedCamera2 = model.GenerateCamera(2u);
1298   DALI_TEST_CHECK(generatedCamera2);
1299   CameraActor generatedCamera3 = model.GenerateCamera(3u); // Infinity far camera
1300   DALI_TEST_CHECK(generatedCamera3);
1301   CameraActor generatedCamera4 = model.GenerateCamera(4u); // Broken camera 1
1302   DALI_TEST_CHECK(!generatedCamera4);
1303   CameraActor generatedCamera5 = model.GenerateCamera(5u); // Broken camera 2
1304   DALI_TEST_CHECK(!generatedCamera5);
1305   CameraActor generatedCamera6 = model.GenerateCamera(6u); // Out of bound
1306   DALI_TEST_CHECK(!generatedCamera6);
1307
1308   CameraActor appliedCamera;
1309   DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), false, TEST_LOCATION); // Cannot apply into empty camera.
1310
1311   auto CompareCameraProperties = [](CameraActor lhs, CameraActor rhs, const char* location) {
1312     DALI_TEST_EQUALS(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), rhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), TEST_LOCATION);
1313     DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), TEST_LOCATION);
1314
1315     if(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE) == static_cast<int>(Dali::Camera::ProjectionMode::PERSPECTIVE_PROJECTION))
1316     {
1317       DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), rhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), TEST_LOCATION);
1318       // TODO : Open this test when infinity far projection implement.
1319       // DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
1320     }
1321     else
1322     {
1323       DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), rhs.GetProperty<float>(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), TEST_LOCATION);
1324       DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
1325     }
1326   };
1327
1328   appliedCamera = CameraActor::New();
1329   DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), true, TEST_LOCATION);
1330   CompareCameraProperties(generatedCamera0, appliedCamera, TEST_LOCATION);
1331   DALI_TEST_EQUALS(model.ApplyCamera(1u, appliedCamera), true, TEST_LOCATION);
1332   CompareCameraProperties(generatedCamera1, appliedCamera, TEST_LOCATION);
1333   DALI_TEST_EQUALS(model.ApplyCamera(2u, appliedCamera), true, TEST_LOCATION);
1334   CompareCameraProperties(generatedCamera2, appliedCamera, TEST_LOCATION);
1335   DALI_TEST_EQUALS(model.ApplyCamera(3u, appliedCamera), true, TEST_LOCATION);
1336   CompareCameraProperties(generatedCamera3, appliedCamera, TEST_LOCATION);
1337   DALI_TEST_EQUALS(model.ApplyCamera(4u, appliedCamera), false, TEST_LOCATION); // Broken camera 1
1338   DALI_TEST_EQUALS(model.ApplyCamera(5u, appliedCamera), false, TEST_LOCATION); // Broken camera 2
1339   DALI_TEST_EQUALS(model.ApplyCamera(6u, appliedCamera), false, TEST_LOCATION); // Cannot apply over the index.
1340
1341   END_TEST;
1342 }
1343
1344 int UtcDaliModelMultiplePrimitives(void)
1345 {
1346   ToolkitTestApplication application;
1347
1348   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME);
1349   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1350   application.GetScene().Add(model);
1351
1352   gResourceReadyCalled = false;
1353   model.ResourceReadySignal().Connect(&OnResourceReady);
1354   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1355
1356   application.SendNotification();
1357   application.Render();
1358
1359   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1360   application.SendNotification();
1361   application.Render();
1362
1363   Actor actor = model.FindChildByName("rootNode");
1364
1365   DALI_TEST_EQUALS(0, actor.GetChildCount(), TEST_LOCATION);
1366   DALI_TEST_EQUALS(2, actor.GetRendererCount(), TEST_LOCATION);
1367
1368   END_TEST;
1369 }
1370
1371 int UtcDaliModelColorMode(void)
1372 {
1373   ToolkitTestApplication application;
1374
1375   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1376   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1377   model.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
1378   application.GetScene().Add(model);
1379
1380   gResourceReadyCalled = false;
1381   model.ResourceReadySignal().Connect(&OnResourceReady);
1382   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1383
1384   application.SendNotification();
1385   application.Render();
1386
1387   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1388   application.SendNotification();
1389   application.Render();
1390
1391   Actor   actor           = model.FindChildByName("AnimatedCube");
1392   Vector4 childColor      = actor[Dali::Actor::Property::COLOR];
1393   Vector4 childWorldColor = actor[Dali::Actor::Property::WORLD_COLOR];
1394
1395   DALI_TEST_EQUALS(childColor, Color::WHITE, TEST_LOCATION);
1396   DALI_TEST_EQUALS(childWorldColor, Color::RED, TEST_LOCATION);
1397
1398   END_TEST;
1399 }
1400
1401 int UtcDaliModelResourceReady(void)
1402 {
1403   ToolkitTestApplication application;
1404
1405   gOnRelayoutCallBackCalled = false;
1406   gResourceReadyCalled      = false;
1407   Scene3D::Model model      = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
1408   model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1409   model.OnRelayoutSignal().Connect(OnRelayoutCallback);
1410   model.ResourceReadySignal().Connect(OnResourceReady);
1411   DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
1412
1413   // Sanity check
1414   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
1415   DALI_TEST_CHECK(!gResourceReadyCalled);
1416
1417   application.GetScene().Add(model);
1418
1419   application.SendNotification();
1420   application.Render();
1421
1422   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1423   application.SendNotification();
1424   application.Render();
1425
1426   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
1427   DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
1428   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1429
1430   END_TEST;
1431 }
1432
1433 int UtcDaliModelResourceReady02(void)
1434 {
1435   tet_infoline("Test model load successfully even if shader language version is low\n");
1436   ToolkitTestApplication application;
1437
1438   auto originalShaderVersion = application.GetGlAbstraction().GetShaderLanguageVersion();
1439
1440   // Change the shader language version forcely!
1441   application.GetGlAbstraction().mShaderLanguageVersion = 200;
1442
1443   try
1444   {
1445     gOnRelayoutCallBackCalled = false;
1446     gResourceReadyCalled      = false;
1447     Scene3D::Model model      = Scene3D::Model::New(TEST_GLTF_MORPH_FILE_NAME);
1448     model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1449     model.OnRelayoutSignal().Connect(OnRelayoutCallback);
1450     model.ResourceReadySignal().Connect(OnResourceReady);
1451     DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
1452
1453     // Sanity check
1454     DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
1455     DALI_TEST_CHECK(!gResourceReadyCalled);
1456
1457     application.GetScene().Add(model);
1458
1459     application.SendNotification();
1460     application.Render();
1461
1462     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1463     application.SendNotification();
1464     application.Render();
1465
1466     DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
1467     DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
1468     DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1469
1470     // Change material information, for line coverage.
1471     auto modelNode = model.FindChildModelNodeByName("AnimatedMorphCube");
1472     DALI_TEST_CHECK(modelNode);
1473     DALI_TEST_GREATER(modelNode.GetModelPrimitiveCount(), 0u, TEST_LOCATION);
1474     auto modelPrimitive = modelNode.GetModelPrimitive(0u);
1475     DALI_TEST_CHECK(modelPrimitive);
1476     auto material = modelPrimitive.GetMaterial();
1477     DALI_TEST_CHECK(material);
1478
1479     auto originBaseColorFactor = material.GetProperty<Dali::Vector4>(Dali::Scene3D::Material::Property::BASE_COLOR_FACTOR);
1480     auto expectBaseColorFactor = Vector4(originBaseColorFactor.r + 0.05f, originBaseColorFactor.g - 0.05f, originBaseColorFactor.b, originBaseColorFactor.a);
1481     material.SetProperty(Dali::Scene3D::Material::Property::BASE_COLOR_FACTOR, expectBaseColorFactor);
1482
1483     application.SendNotification();
1484     application.Render();
1485
1486     DALI_TEST_EQUALS(material.GetProperty<Dali::Vector4>(Dali::Scene3D::Material::Property::BASE_COLOR_FACTOR), expectBaseColorFactor, TEST_LOCATION);
1487   }
1488   catch(...)
1489   {
1490     DALI_TEST_CHECK(false);
1491   }
1492
1493   // Revert shader version. We should revert it even if UTC failed.
1494   application.GetGlAbstraction().mShaderLanguageVersion = originalShaderVersion;
1495
1496   END_TEST;
1497 }
1498
1499 int UtcDaliModelResourceCacheCheck(void)
1500 {
1501   ToolkitTestApplication application;
1502
1503   // Load three instances of the same model and add them to the scene
1504   Scene3D::Model model1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1505   Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1506   Scene3D::Model model3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1507
1508   application.GetScene().Add(model1);
1509   application.GetScene().Add(model2);
1510   application.GetScene().Add(model3);
1511
1512   gResourceReadyCalled = false;
1513   model1.ResourceReadySignal().Connect(&OnResourceReady);
1514   model2.ResourceReadySignal().Connect(&OnResourceReady);
1515   model3.ResourceReadySignal().Connect(&OnResourceReady);
1516   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1517
1518   application.SendNotification();
1519   application.Render();
1520
1521   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1522   application.SendNotification();
1523   application.Render();
1524
1525   // Check that the loading has finished for all the three instances
1526   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1527
1528   Actor meshActor1 = model1.FindChildByName("AnimatedCube");
1529   Actor meshActor2 = model2.FindChildByName("AnimatedCube");
1530   Actor meshActor3 = model3.FindChildByName("AnimatedCube");
1531   DALI_TEST_CHECK(meshActor1);
1532   DALI_TEST_CHECK(meshActor2);
1533   DALI_TEST_CHECK(meshActor3);
1534
1535   Renderer renderer1 = meshActor1.GetRendererAt(0u);
1536   Renderer renderer2 = meshActor2.GetRendererAt(0u);
1537   Renderer renderer3 = meshActor3.GetRendererAt(0u);
1538   DALI_TEST_CHECK(renderer1);
1539   DALI_TEST_CHECK(renderer2);
1540   DALI_TEST_CHECK(renderer3);
1541
1542   // Check that all the three instances use the shared textures and geometries from the cache
1543   // but have their own shader objects
1544   DALI_TEST_EQUALS(renderer1.GetTextures(), renderer2.GetTextures(), TEST_LOCATION);
1545   DALI_TEST_EQUALS(renderer1.GetTextures(), renderer3.GetTextures(), TEST_LOCATION);
1546   DALI_TEST_EQUALS(renderer1.GetGeometry(), renderer2.GetGeometry(), TEST_LOCATION);
1547   DALI_TEST_EQUALS(renderer1.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1548   DALI_TEST_NOT_EQUALS(renderer1.GetShader(), renderer2.GetShader(), 0.0f, TEST_LOCATION);
1549   DALI_TEST_NOT_EQUALS(renderer1.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1550   DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1551
1552   // Destroy model1
1553   model1.Unparent();
1554   model1.Reset();
1555
1556   // Check that all the other two instances still use the shared textures and geometries from the cache
1557   // but have their own shader objects
1558   DALI_TEST_EQUALS(renderer2.GetTextures(), renderer3.GetTextures(), TEST_LOCATION);
1559   DALI_TEST_EQUALS(renderer2.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1560   DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1561
1562   // Set new IBL textures for model2, and this should apply to model2 instance only
1563   gResourceReadyCalled = false;
1564   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1565   model2.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
1566
1567   application.SendNotification();
1568   application.Render();
1569
1570   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1571   application.SendNotification();
1572   application.Render();
1573
1574   // Check that the new IBL textures are loaded for model2
1575   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1576
1577   // Check that the two instances still use the shared geometries from the cache
1578   // but now have their own shader objects and different texture set
1579   DALI_TEST_NOT_EQUALS(renderer2.GetTextures(), renderer3.GetTextures(), 0.0f, TEST_LOCATION);
1580   DALI_TEST_EQUALS(renderer2.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1581   DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1582
1583   // Check that the two instances now have their own diffuse texture and specular texture,
1584   // but all the other textures are still the same
1585   TextureSet textureSet2 = renderer2.GetTextures();
1586   TextureSet textureSet3 = renderer3.GetTextures();
1587   DALI_TEST_EQUALS(textureSet2.GetTextureCount(), 10u, TEST_LOCATION);
1588   DALI_TEST_EQUALS(textureSet3.GetTextureCount(), 10u, TEST_LOCATION);
1589
1590   for(uint32_t i = 0; i < 7u; i++)
1591   {
1592     DALI_TEST_EQUALS(textureSet2.GetTexture(i), textureSet3.GetTexture(i), TEST_LOCATION);
1593   }
1594
1595   DALI_TEST_NOT_EQUALS(textureSet2.GetTexture(8u), textureSet3.GetTexture(7u), 0.0f, TEST_LOCATION);
1596   DALI_TEST_NOT_EQUALS(textureSet2.GetTexture(9u), textureSet3.GetTexture(8u), 0.0f, TEST_LOCATION);
1597
1598   END_TEST;
1599 }
1600
1601 int UtcDaliModelAddRemoveModelNode(void)
1602 {
1603   ToolkitTestApplication application;
1604
1605   Scene3D::Model model = Scene3D::Model::New();
1606   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1607
1608   Scene3D::ModelNode node1 = Scene3D::ModelNode::New();
1609   Scene3D::ModelNode node2 = Scene3D::ModelNode::New();
1610   Scene3D::ModelNode node3 = Scene3D::ModelNode::New();
1611   Scene3D::ModelNode node4 = Scene3D::ModelNode::New();
1612
1613   model.AddModelNode(node1);
1614   model.AddModelNode(node2);
1615   model.AddModelNode(node3);
1616   model.RemoveModelNode(node1); // Remove node before scene on
1617
1618   application.GetScene().Add(model);
1619
1620   Dali::Scene3D::ModelNode root = model.GetModelRoot();
1621   DALI_TEST_CHECK(root);
1622   DALI_TEST_EQUALS(2, root.GetChildCount(), TEST_LOCATION);
1623
1624   model.RemoveModelNode(node2); // Remove node after scene on
1625
1626   DALI_TEST_EQUALS(1, root.GetChildCount(), TEST_LOCATION);
1627
1628   model.AddModelNode(node4); // Add during scene on
1629
1630   DALI_TEST_EQUALS(2, root.GetChildCount(), TEST_LOCATION);
1631
1632   application.GetScene().Remove(model);
1633
1634   model.RemoveModelNode(node3); // Remove node after scene off
1635
1636   END_TEST;
1637 }
1638
1639 int UtcDaliModelFindChildModelNodeByName(void)
1640 {
1641   tet_infoline(" UtcDaliModelNodeFindChildModelNodeByName.");
1642
1643   ToolkitTestApplication application;
1644
1645   Scene3D::Model model = Scene3D::Model::New();
1646   application.GetScene().Add(model);
1647
1648   Scene3D::ModelNode modelNode1 = Scene3D::ModelNode::New();
1649   Scene3D::ModelNode modelNode2 = Scene3D::ModelNode::New();
1650
1651   modelNode1.SetProperty(Dali::Actor::Property::NAME, "modelNode1");
1652   modelNode2.SetProperty(Dali::Actor::Property::NAME, "modelNode2");
1653   model.AddModelNode(modelNode1);
1654   model.AddModelNode(modelNode2);
1655
1656   Scene3D::ModelNode child1 = model.FindChildModelNodeByName("modelNode1");
1657   DALI_TEST_CHECK(child1);
1658   DALI_TEST_EQUALS(child1, modelNode1, TEST_LOCATION);
1659
1660   Scene3D::ModelNode child2 = model.FindChildModelNodeByName("modelNode2");
1661   DALI_TEST_CHECK(child2);
1662   DALI_TEST_EQUALS(child2, modelNode2, TEST_LOCATION);
1663
1664   END_TEST;
1665 }
1666
1667 int UtcDaliModelSizeChange(void)
1668 {
1669   tet_infoline(" UtcDaliModelSizeChange.");
1670
1671   ToolkitTestApplication application;
1672
1673   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1674   model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
1675   application.GetScene().Add(model);
1676
1677   application.SendNotification();
1678   application.Render();
1679
1680   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1681   application.SendNotification();
1682   application.Render();
1683
1684   DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
1685   Vector3 scale = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1686
1687   model.SetProperty(Dali::Actor::Property::SIZE, Vector3(600, 600, 600));
1688   Vector3 scale2 = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1689
1690   DALI_TEST_NOT_EQUALS(scale, scale2, 0.1f, TEST_LOCATION);
1691
1692   END_TEST;
1693 }
1694
1695 int UtcDaliModelSizeChange2(void)
1696 {
1697   tet_infoline(" UtcDaliModelSizeChange2.");
1698
1699   ToolkitTestApplication application;
1700
1701   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1702   model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
1703   application.GetScene().Add(model);
1704
1705   application.SendNotification();
1706   application.Render();
1707
1708   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1709   application.SendNotification();
1710   application.Render();
1711
1712   DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
1713   Vector3 scale = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1714
1715   Animation animation = Animation::New(0.5f);
1716   animation.AnimateTo(Dali::Property(model, Dali::Actor::Property::SIZE), Vector3(600, 600, 600));
1717   animation.Play();
1718
1719   application.SendNotification();
1720   application.Render(250);
1721
1722   application.SendNotification();
1723
1724   Vector3 scale2 = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1725   DALI_TEST_NOT_EQUALS(scale, scale2, 0.1f, TEST_LOCATION);
1726
1727   END_TEST;
1728 }
1729
1730 int UtcDaliModelRetrieveBlendShapeNames(void)
1731 {
1732   tet_infoline(" UtcDaliModelRetrieveBlendShapeByName.");
1733
1734   ToolkitTestApplication application;
1735
1736   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_EXTRAS_FILE_NAME);
1737   model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
1738   application.GetScene().Add(model);
1739
1740   application.SendNotification();
1741   application.Render();
1742
1743   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1744   application.SendNotification();
1745   application.Render();
1746
1747   DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
1748
1749   // Get target ModelNode that has extras
1750   Scene3D::ModelNode expectNode = model.FindChildModelNodeByName("AnimatedMorphCube");
1751
1752   // Pair of expected blend shape index from expectNode.
1753   std::map<std::string, Scene3D::Loader::BlendShapes::Index> expectBlendShapeNames = {
1754     {"Target_0", 0u},
1755     {"Target_1", 1u},
1756   };
1757
1758   std::vector<std::string> blendShapeNameList;
1759   model.RetrieveBlendShapeNames(blendShapeNameList);
1760
1761   DALI_TEST_EQUALS(blendShapeNameList.size(), expectBlendShapeNames.size(), TEST_LOCATION);
1762   for(auto i = 0u; i < blendShapeNameList.size(); ++i)
1763   {
1764     const auto& name = blendShapeNameList[i];
1765     tet_printf("Check retrieved blendshape name : %s\n", name.c_str());
1766
1767     const auto& iter = expectBlendShapeNames.find(name);
1768     DALI_TEST_CHECK(iter != expectBlendShapeNames.end());
1769
1770     std::vector<Scene3D::ModelNode> nodeList;
1771     model.RetrieveModelNodesByBlendShapeName(name, nodeList);
1772     DALI_TEST_EQUALS(nodeList.size(), 1u, TEST_LOCATION);
1773     DALI_TEST_EQUALS(nodeList[0], expectNode, TEST_LOCATION);
1774     DALI_TEST_EQUALS(nodeList[0].GetBlendShapeIndexByName(name), iter->second, TEST_LOCATION);
1775   }
1776
1777   END_TEST;
1778 }
1779
1780 int UtcDaliModelGenerateMotionDataAnimation01(void)
1781 {
1782   ToolkitTestApplication application;
1783
1784   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MORPH_FILE_NAME);
1785   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1786   application.GetScene().Add(model);
1787
1788   gResourceReadyCalled = false;
1789   model.ResourceReadySignal().Connect(&OnResourceReady);
1790   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1791
1792   application.SendNotification();
1793   application.Render();
1794
1795   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1796   application.SendNotification();
1797   application.Render();
1798
1799   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1800
1801   KeyFrames floatKeyFrames = KeyFrames::New();
1802   floatKeyFrames.Add(0.0f, 1.0f);
1803   floatKeyFrames.Add(1.0f, 0.5f);
1804
1805   float               duration   = 3.0f;
1806   Scene3D::MotionData motionData = Scene3D::MotionData::New(duration);
1807   motionData.Add(Scene3D::MotionTransformIndex::New("AnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Y), Scene3D::MotionValue::New(2.0f));
1808   motionData.Add(Scene3D::MotionTransformIndex::New("AnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Z), Scene3D::MotionValue::New(floatKeyFrames));
1809   motionData.Add(Scene3D::BlendShapeIndex::New("AnimatedMorphCube", 0), Scene3D::MotionValue::New(0.5f));
1810   motionData.Add(Scene3D::BlendShapeIndex::New("AnimatedMorphCube", 1), Scene3D::MotionValue::New(floatKeyFrames));
1811
1812   Animation generatedAnimation = model.GenerateMotionDataAnimation(motionData);
1813   DALI_TEST_CHECK(generatedAnimation);
1814   DALI_TEST_EQUALS(generatedAnimation.GetDuration(), duration, TEST_LOCATION);
1815
1816   Scene3D::MotionData invalidMotionData = Scene3D::MotionData::New(duration);
1817   invalidMotionData.Add(Scene3D::MotionTransformIndex::New("NotAnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Y), Scene3D::MotionValue::New(2.0f));
1818   invalidMotionData.Add(Scene3D::MotionTransformIndex::New("NotAnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Z), Scene3D::MotionValue::New(floatKeyFrames));
1819   invalidMotionData.Add(Scene3D::BlendShapeIndex::New("NotAnimatedMorphCube", 0), Scene3D::MotionValue::New(0.5f));
1820   invalidMotionData.Add(Scene3D::BlendShapeIndex::New("NotAnimatedMorphCube", 1), Scene3D::MotionValue::New(floatKeyFrames));
1821
1822   generatedAnimation = model.GenerateMotionDataAnimation(invalidMotionData);
1823   DALI_TEST_CHECK(!generatedAnimation); // Animation should be empty if motion data have invalid index.
1824
1825   END_TEST;
1826 }
1827
1828 int UtcDaliModelSetMotionData(void)
1829 {
1830   ToolkitTestApplication application;
1831
1832   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MORPH_FILE_NAME);
1833   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1834   application.GetScene().Add(model);
1835
1836   gResourceReadyCalled = false;
1837   model.ResourceReadySignal().Connect(&OnResourceReady);
1838   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1839
1840   application.SendNotification();
1841   application.Render();
1842
1843   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1844   application.SendNotification();
1845   application.Render();
1846
1847   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1848
1849   KeyFrames floatKeyFrames = KeyFrames::New();
1850   floatKeyFrames.Add(0.0f, 1.0f);
1851   floatKeyFrames.Add(1.0f, 0.5f);
1852
1853   float               duration   = 3.0f;
1854   Scene3D::MotionData motionData = Scene3D::MotionData::New(duration);
1855   motionData.Add(Scene3D::MotionTransformIndex::New("AnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Y), Scene3D::MotionValue::New(2.0f));
1856   motionData.Add(Scene3D::MotionTransformIndex::New("AnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Z), Scene3D::MotionValue::New(floatKeyFrames));
1857   motionData.Add(Scene3D::BlendShapeIndex::New("AnimatedMorphCube", 0), Scene3D::MotionValue::New(0.5f));
1858   motionData.Add(Scene3D::BlendShapeIndex::New("AnimatedMorphCube", 1), Scene3D::MotionValue::New(floatKeyFrames));
1859
1860   auto cubeModelNode = model.FindChildModelNodeByName("AnimatedMorphCube");
1861
1862   float expectScaleX = cubeModelNode.GetProperty<float>(Actor::Property::SCALE_X);
1863
1864   model.SetMotionData(motionData);
1865
1866   DALI_TEST_EQUALS(cubeModelNode.GetProperty<float>(Actor::Property::SCALE_X), expectScaleX, TEST_LOCATION);
1867   DALI_TEST_EQUALS(cubeModelNode.GetProperty<float>(Actor::Property::SCALE_Y), 2.0f, TEST_LOCATION);
1868   DALI_TEST_EQUALS(cubeModelNode.GetProperty<float>(Actor::Property::SCALE_Z), 0.5f, TEST_LOCATION); ///< Last value of keyframes
1869
1870   END_TEST;
1871 }
1872
1873 int UtcDaliModelBlendShapeMotionDataByName(void)
1874 {
1875   ToolkitTestApplication application;
1876
1877   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_EXTRAS_FILE_NAME);
1878   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1879   application.GetScene().Add(model);
1880
1881   gResourceReadyCalled = false;
1882   model.ResourceReadySignal().Connect(&OnResourceReady);
1883   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1884
1885   application.SendNotification();
1886   application.Render();
1887
1888   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1889   application.SendNotification();
1890   application.Render();
1891
1892   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1893
1894   KeyFrames floatKeyFrames = KeyFrames::New();
1895   floatKeyFrames.Add(0.0f, 0.5f);
1896   floatKeyFrames.Add(1.0f, 1.0f);
1897
1898   float               duration   = 3.0f;
1899   Scene3D::MotionData motionData = Scene3D::MotionData::New(duration);
1900   motionData.Add(Scene3D::BlendShapeIndex::New("Target_0"), Scene3D::MotionValue::New(0.5f));
1901   motionData.Add(Scene3D::BlendShapeIndex::New("Target_1"), Scene3D::MotionValue::New(floatKeyFrames));
1902
1903   Animation generatedAnimation = model.GenerateMotionDataAnimation(motionData);
1904   DALI_TEST_CHECK(generatedAnimation);
1905   DALI_TEST_EQUALS(generatedAnimation.GetDuration(), duration, TEST_LOCATION);
1906
1907   model.SetMotionData(motionData);
1908
1909   // Get target ModelNode that has extras
1910   Scene3D::ModelNode expectNode    = model.FindChildModelNodeByName("AnimatedMorphCube");
1911   auto               propertyIndex = expectNode.GetPropertyIndex(motionData.GetIndex(0u).GetPropertyName(expectNode));
1912
1913   DALI_TEST_CHECK(propertyIndex != Property::INVALID_INDEX);
1914   DALI_TEST_EQUALS(expectNode.GetProperty<float>(propertyIndex), 0.5f, TEST_LOCATION);
1915
1916   propertyIndex = expectNode.GetPropertyIndex(motionData.GetIndex(1u).GetPropertyName(expectNode));
1917   DALI_TEST_CHECK(propertyIndex != Property::INVALID_INDEX);
1918   DALI_TEST_EQUALS(expectNode.GetProperty<float>(propertyIndex), 1.0f, TEST_LOCATION);
1919
1920   END_TEST;
1921 }
1922
1923 int UtcDaliModelMaterialUniformChange(void)
1924 {
1925   ToolkitTestApplication application;
1926
1927   static std::vector<UniformData> customUniforms =
1928     {
1929       UniformData("uColorFactor", Property::Type::VECTOR4),
1930       UniformData("uBaseColorTextureTransformAvailable", Property::Type::FLOAT),
1931       UniformData(Scene3D::Loader::NodeDefinition::GetIblMaxLodUniformName().data(), Property::Type::FLOAT),
1932       UniformData(Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), Property::Type::FLOAT),
1933     };
1934
1935   TestGraphicsController& graphics = application.GetGraphicsController();
1936   graphics.AddCustomUniforms(customUniforms);
1937
1938   auto& gl = application.GetGlAbstraction();
1939
1940   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1941
1942   gResourceReadyCalled = false;
1943   model.ResourceReadySignal().Connect(&OnResourceReady);
1944
1945   float expectIblFactor = 0.5f;
1946   model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE, expectIblFactor);
1947   DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), expectIblFactor, TEST_LOCATION);
1948
1949   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1950   application.GetScene().Add(model);
1951
1952   application.SendNotification();
1953   application.Render();
1954
1955   // Wait 3 task. (Load 1 model + Load 2 IBL)
1956   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1957   application.SendNotification();
1958   application.Render();
1959
1960   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1961   DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), expectIblFactor, TEST_LOCATION);
1962
1963   // Check uniform values before change material value
1964   Vector4 expectBaseColorFactor = Vector4(1.000f, 0.766f, 0.336f, 1.0f); // Defined at AnimatedCube.gltf
1965   float   expectTransformValid  = 0.0f;                                  ///< Note : This value will be true when gltf have BaseColorTexture, and use KHR_texture_transform extension.
1966   float   expectMaxLOD          = 5.0f;                                  ///< Note : The number of LOD what TEST_SPECULAR_TEXTURE file has is 5.
1967
1968   tet_printf("Check uniform value result\n");
1969   DALI_TEST_EQUALS(gl.CheckUniformValue<Vector4>("uColorFactor", expectBaseColorFactor), true, TEST_LOCATION);
1970   DALI_TEST_EQUALS(gl.CheckUniformValue<float>("uBaseColorTextureTransformAvailable", expectTransformValid), true, TEST_LOCATION);
1971   DALI_TEST_EQUALS(gl.CheckUniformValue<float>(Scene3D::Loader::NodeDefinition::GetIblMaxLodUniformName().data(), expectMaxLOD), true, TEST_LOCATION);
1972   DALI_TEST_EQUALS(gl.CheckUniformValue<float>(Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), expectIblFactor), true, TEST_LOCATION);
1973
1974   // Change all materials in Model.
1975   expectBaseColorFactor = Color::BLUE;
1976
1977   Scene3D::ModelNode rootModelNode = model.GetModelRoot();
1978   DALI_TEST_CHECK(rootModelNode);
1979   ApplyAllMaterialPropertyRecursively(rootModelNode, {{Dali::Scene3D::Material::Property::BASE_COLOR_FACTOR, expectBaseColorFactor}});
1980
1981   application.SendNotification();
1982   application.Render();
1983
1984   tet_printf("Check whether uniform values are not changed instead what we change now\n");
1985   DALI_TEST_EQUALS(gl.CheckUniformValue<Vector4>("uColorFactor", expectBaseColorFactor), true, TEST_LOCATION);
1986   DALI_TEST_EQUALS(gl.CheckUniformValue<float>("uBaseColorTextureTransformAvailable", expectTransformValid), true, TEST_LOCATION);
1987   DALI_TEST_EQUALS(gl.CheckUniformValue<float>(Scene3D::Loader::NodeDefinition::GetIblMaxLodUniformName().data(), expectMaxLOD), true, TEST_LOCATION);
1988   DALI_TEST_EQUALS(gl.CheckUniformValue<float>(Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), expectIblFactor), true, TEST_LOCATION);
1989
1990   END_TEST;
1991 }
1992
1993 int UtcDaliModelCastShadow(void)
1994 {
1995   ToolkitTestApplication application;
1996
1997   Scene3D::Model model = Scene3D::Model::New();
1998   application.GetScene().Add(model);
1999
2000   Scene3D::ModelNode modelNode = Scene3D::ModelNode::New();
2001   model.AddModelNode(modelNode);
2002
2003   DALI_TEST_EQUALS(model.IsShadowCasting(), true, TEST_LOCATION);
2004
2005   DALI_TEST_EQUALS(modelNode.IsShadowCasting(), true, TEST_LOCATION);
2006
2007   auto shadowCastingIndex = modelNode.GetPropertyIndex("uIsShadowCasting");
2008   DALI_TEST_EQUALS(modelNode.GetProperty<int>(shadowCastingIndex), 1, TEST_LOCATION);
2009
2010   model.CastShadow(false);
2011
2012   DALI_TEST_EQUALS(model.IsShadowCasting(), false, TEST_LOCATION);
2013
2014   DALI_TEST_EQUALS(modelNode.IsShadowCasting(), false, TEST_LOCATION);
2015
2016   DALI_TEST_EQUALS(modelNode.GetProperty<int>(shadowCastingIndex), 0, TEST_LOCATION);
2017
2018   Scene3D::ModelNode modelNode2 = Scene3D::ModelNode::New();
2019   model.AddModelNode(modelNode2);
2020
2021   DALI_TEST_EQUALS(modelNode2.IsShadowCasting(), true, TEST_LOCATION);
2022
2023   auto shadowCastingIndex2 = modelNode2.GetPropertyIndex("uIsShadowCasting");
2024   DALI_TEST_EQUALS(modelNode2.GetProperty<int>(shadowCastingIndex2), 1, TEST_LOCATION);
2025
2026   modelNode.CastShadow(true);
2027
2028   DALI_TEST_EQUALS(modelNode.IsShadowCasting(), true, TEST_LOCATION);
2029
2030   DALI_TEST_EQUALS(model.IsShadowCasting(), false, TEST_LOCATION);
2031
2032   model.CastShadow(false);
2033
2034   DALI_TEST_EQUALS(model.IsShadowCasting(), false, TEST_LOCATION);
2035
2036   DALI_TEST_EQUALS(modelNode.IsShadowCasting(), false, TEST_LOCATION);
2037
2038   DALI_TEST_EQUALS(modelNode.GetProperty<int>(shadowCastingIndex), 0, TEST_LOCATION);
2039
2040   DALI_TEST_EQUALS(modelNode2.GetProperty<int>(shadowCastingIndex2), 0, TEST_LOCATION);
2041   END_TEST;
2042 }
2043
2044 int UtcDaliModelReceiveShadow(void)
2045 {
2046   ToolkitTestApplication application;
2047
2048   Scene3D::Model model = Scene3D::Model::New();
2049   application.GetScene().Add(model);
2050
2051   Scene3D::ModelNode modelNode = Scene3D::ModelNode::New();
2052   model.AddModelNode(modelNode);
2053
2054   DALI_TEST_EQUALS(model.IsShadowReceiving(), true, TEST_LOCATION);
2055
2056   DALI_TEST_EQUALS(modelNode.IsShadowReceiving(), true, TEST_LOCATION);
2057
2058   auto shadowReceivingIndex = modelNode.GetPropertyIndex("uIsShadowReceiving");
2059   DALI_TEST_EQUALS(modelNode.GetProperty<int>(shadowReceivingIndex), 1, TEST_LOCATION);
2060
2061   model.ReceiveShadow(false);
2062
2063   DALI_TEST_EQUALS(model.IsShadowReceiving(), false, TEST_LOCATION);
2064
2065   DALI_TEST_EQUALS(modelNode.IsShadowReceiving(), false, TEST_LOCATION);
2066
2067   DALI_TEST_EQUALS(modelNode.GetProperty<int>(shadowReceivingIndex), 0, TEST_LOCATION);
2068
2069   Scene3D::ModelNode modelNode2 = Scene3D::ModelNode::New();
2070   model.AddModelNode(modelNode2);
2071
2072   DALI_TEST_EQUALS(modelNode2.IsShadowReceiving(), true, TEST_LOCATION);
2073
2074   auto shadowReceivingIndex2 = modelNode2.GetPropertyIndex("uIsShadowReceiving");
2075   DALI_TEST_EQUALS(modelNode2.GetProperty<int>(shadowReceivingIndex2), 1, TEST_LOCATION);
2076
2077   modelNode.ReceiveShadow(true);
2078
2079   DALI_TEST_EQUALS(modelNode.IsShadowReceiving(), true, TEST_LOCATION);
2080
2081   DALI_TEST_EQUALS(model.IsShadowReceiving(), false, TEST_LOCATION);
2082
2083   model.ReceiveShadow(false);
2084
2085   DALI_TEST_EQUALS(model.IsShadowReceiving(), false, TEST_LOCATION);
2086
2087   DALI_TEST_EQUALS(modelNode.IsShadowReceiving(), false, TEST_LOCATION);
2088
2089   DALI_TEST_EQUALS(modelNode.GetProperty<int>(shadowReceivingIndex), 0, TEST_LOCATION);
2090
2091   DALI_TEST_EQUALS(modelNode2.GetProperty<int>(shadowReceivingIndex2), 0, TEST_LOCATION);
2092   END_TEST;
2093 }