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