Merge "Generate Camera from loaded model" 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 <stdlib.h>
21 #include <iostream>
22
23 #include <dali-toolkit/devel-api/focus-manager/keyboard-focus-manager-devel.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <toolkit-event-thread-callback.h>
26
27 #include <dali-scene3d/public-api/controls/model/model.h>
28
29 #include <dali/devel-api/actors/camera-actor-devel.h>
30
31 using namespace Dali;
32 using namespace Dali::Toolkit;
33
34 void model_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void model_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 namespace
45 {
46 const bool DEFAULT_MODEL_CHILDREN_SENSITIVE = false;
47 const bool DEFAULT_MODEL_CHILDREN_FOCUSABLE = false;
48 /**
49  * For the AnimatedCube.gltf and its Assets
50  * Donated by Norbert Nopper for glTF testing.
51  * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
52  */
53 const char* TEST_GLTF_FILE_NAME                    = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
54 const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME     = TEST_RESOURCE_DIR "/animationTest.gltf";
55 const char* TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME = TEST_RESOURCE_DIR "/simpleMultiplePrimitiveTest.gltf";
56 const char* TEST_DLI_FILE_NAME                     = TEST_RESOURCE_DIR "/arc.dli";
57 const char* TEST_DLI_EXERCISE_FILE_NAME            = TEST_RESOURCE_DIR "/exercise.dli";
58 /**
59  * For the diffuse and specular cube map texture.
60  * These textures are based off version of Wave engine sample
61  * Take from https://github.com/WaveEngine/Samples
62  *
63  * Copyright (c) 2023 Wave Coorporation
64  *
65  * Permission is hereby granted, free of charge, to any person obtaining a copy
66  * of this software and associated documentation files (the "Software"), to
67  * deal in the Software without restriction, including without limitation the
68  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
69  * sell copies of the Software, and to permit persons to whom the Software is
70  * furnished to do so, subject to the following conditions:
71  *
72  * The above copyright notice and this permission notice shall be included in
73  * all copies or substantial portions of the Software.
74  *
75  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
78  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
79  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
80  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
81  * THE SOFTWARE.
82  */
83 const char* TEST_DIFFUSE_TEXTURE  = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
84 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
85
86 bool gTouchCallBackCalled = false;
87 bool TestTouchCallback(Actor, const TouchEvent&)
88 {
89   gTouchCallBackCalled = true;
90   return true;
91 }
92
93 bool gFocusChangedCallBackCalled = false;
94 void TestFocusChangedCallback(Actor, Actor)
95 {
96   gFocusChangedCallBackCalled = true;
97 }
98
99 // For ResourceReady
100 static bool gOnRelayoutCallBackCalled = false;
101 void        OnRelayoutCallback(Actor actor)
102 {
103   gOnRelayoutCallBackCalled = true;
104 }
105
106 static bool gResourceReadyCalled = false;
107 void        OnResourceReady(Control control)
108 {
109   gResourceReadyCalled = true;
110 }
111
112 } // namespace
113
114 // Negative test case for a method
115 int UtcDaliModelUninitialized(void)
116 {
117   ToolkitTestApplication application;
118   tet_infoline(" UtcDaliModelUninitialized");
119
120   Scene3D::Model model;
121
122   try
123   {
124     // New() must be called to create a Model or it wont be valid.
125     Actor a = Actor::New();
126     model.Add(a);
127     DALI_TEST_CHECK(false);
128   }
129   catch(Dali::DaliException& e)
130   {
131     // Tests that a negative test of an assertion succeeds
132     DALI_TEST_PRINT_ASSERT(e);
133     DALI_TEST_CHECK(!model);
134   }
135   END_TEST;
136 }
137
138 // Positive test case for a method
139 int UtcDaliModelNew(void)
140 {
141   ToolkitTestApplication application;
142   tet_infoline(" UtcDaliModelNew");
143
144   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
145   DALI_TEST_CHECK(model);
146   END_TEST;
147 }
148
149 // Positive test case for a method
150 int UtcDaliModelDownCast(void)
151 {
152   ToolkitTestApplication application;
153   tet_infoline(" UtcDaliModelDownCast");
154
155   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
156   BaseHandle     handle(model);
157
158   Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
159   DALI_TEST_CHECK(model);
160   DALI_TEST_CHECK(model2);
161   DALI_TEST_CHECK(model2 == model);
162   END_TEST;
163 }
164
165 int UtcDaliModelTypeRegistry(void)
166 {
167   ToolkitTestApplication application;
168
169   TypeRegistry typeRegistry = TypeRegistry::Get();
170   DALI_TEST_CHECK(typeRegistry);
171
172   TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
173   DALI_TEST_CHECK(typeInfo);
174
175   BaseHandle handle = typeInfo.CreateInstance();
176   DALI_TEST_CHECK(handle);
177
178   Scene3D::Model model = Scene3D::Model::DownCast(handle);
179   DALI_TEST_CHECK(model);
180
181   END_TEST;
182 }
183
184 // Positive test case for a method
185 int UtcDaliModelAddRemove(void)
186 {
187   ToolkitTestApplication application;
188   tet_infoline(" UtcDaliModelAddRemove");
189
190   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
191   DALI_TEST_CHECK(model);
192
193   Actor actor = Actor::New();
194   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
195
196   model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
197   model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
198   model.Add(actor);
199   application.GetScene().Add(model);
200
201   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
202
203   model.Remove(actor);
204
205   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
206   END_TEST;
207 }
208
209 int UtcDaliModelCopyAndAssignment(void)
210 {
211   ToolkitTestApplication application;
212
213   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
214   DALI_TEST_CHECK(model);
215
216   Scene3D::Model copy(model);
217   DALI_TEST_CHECK(model == copy);
218
219   Scene3D::Model assign;
220   DALI_TEST_CHECK(!assign);
221
222   assign = copy;
223   DALI_TEST_CHECK(assign == model);
224
225   END_TEST;
226 }
227
228 int UtcDaliModelMoveConstructor(void)
229 {
230   ToolkitTestApplication application;
231
232   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
233   DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
234   model.SetProperty(Actor::Property::SENSITIVE, false);
235   DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
236
237   Scene3D::Model moved = std::move(model);
238   DALI_TEST_CHECK(moved);
239   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
240   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
241   DALI_TEST_CHECK(!model);
242
243   END_TEST;
244 }
245
246 int UtcDaliModelMoveAssignment(void)
247 {
248   ToolkitTestApplication application;
249
250   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
251   DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
252   model.SetProperty(Actor::Property::SENSITIVE, false);
253   DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
254
255   Scene3D::Model moved;
256   moved = std::move(model);
257   DALI_TEST_CHECK(moved);
258   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
259   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
260   DALI_TEST_CHECK(!model);
261
262   END_TEST;
263 }
264
265 int UtcDaliModelOnScene01(void)
266 {
267   ToolkitTestApplication application;
268
269   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
270   application.GetScene().Add(model);
271
272   gResourceReadyCalled = false;
273   model.ResourceReadySignal().Connect(&OnResourceReady);
274   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
275
276   application.SendNotification();
277   application.Render();
278
279   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
280   application.SendNotification();
281   application.Render();
282
283   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
284
285   uint32_t modelCount = model.GetModelRoot().GetChildCount();
286   DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
287   END_TEST;
288 }
289
290 int UtcDaliModelOnScene02(void)
291 {
292   ToolkitTestApplication application;
293
294   Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
295   application.GetScene().Add(model);
296
297   gResourceReadyCalled = false;
298   model.ResourceReadySignal().Connect(&OnResourceReady);
299   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
300
301   application.SendNotification();
302   application.Render();
303
304   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
305   application.SendNotification();
306   application.Render();
307
308   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
309
310   uint32_t modelCount = model.GetModelRoot().GetChildCount();
311   DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
312
313   Actor   rootActor = model.GetModelRoot();
314   Vector3 rootSize  = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
315   DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
316
317   END_TEST;
318 }
319
320 int UtcDaliModelOnSizeSet(void)
321 {
322   ToolkitTestApplication application;
323
324   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
325
326   application.GetScene().Add(model);
327
328   application.SendNotification();
329   application.Render();
330
331   Vector2 size(200.0f, 300.0f);
332   model.SetProperty(Actor::Property::SIZE, size);
333
334   application.SendNotification();
335   application.Render();
336
337   DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
338
339   END_TEST;
340 }
341
342 int UtcDaliModelGetNaturalSize(void)
343 {
344   ToolkitTestApplication application;
345
346   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
347
348   Vector3 naturalSize = model.GetNaturalSize();
349   DALI_TEST_EQUALS(Vector3::ZERO, naturalSize, TEST_LOCATION);
350
351   application.GetScene().Add(model);
352
353   gResourceReadyCalled = false;
354   model.ResourceReadySignal().Connect(&OnResourceReady);
355   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
356
357   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
358   application.SendNotification();
359
360   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
361
362   naturalSize = model.GetNaturalSize();
363   DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
364
365   Actor root = model.GetModelRoot();
366   DALI_TEST_CHECK(root);
367
368   END_TEST;
369 }
370
371 int UtcDaliModelSetImageBasedLightSource01(void)
372 {
373   ToolkitTestApplication application;
374
375   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
376   application.GetScene().Add(model);
377
378   gResourceReadyCalled = false;
379   model.ResourceReadySignal().Connect(&OnResourceReady);
380   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
381
382   application.SendNotification();
383   application.Render();
384
385   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
386   application.SendNotification();
387   application.Render();
388
389   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
390
391   Actor meshActor = model.FindChildByName("AnimatedCube");
392   DALI_TEST_CHECK(meshActor);
393
394   Renderer renderer = meshActor.GetRendererAt(0u);
395   DALI_TEST_CHECK(renderer);
396
397   TextureSet textureSet = renderer.GetTextures();
398   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
399
400   Texture diffuseTexture  = textureSet.GetTexture(7u);
401   Texture specularTexture = textureSet.GetTexture(8u);
402
403   gResourceReadyCalled = false;
404   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
405   model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
406
407   application.SendNotification();
408   application.Render();
409
410   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
411   application.SendNotification();
412   application.Render();
413
414   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
415
416   Texture newDiffuseTexture  = textureSet.GetTexture(7u);
417   Texture newSpecularTexture = textureSet.GetTexture(8u);
418
419   DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
420   DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
421
422   model.Unparent();
423   model.Reset();
424   END_TEST;
425 }
426
427 int UtcDaliModelSetImageBasedLightSource02(void)
428 {
429   ToolkitTestApplication application;
430
431   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
432   application.GetScene().Add(model);
433
434   gResourceReadyCalled = false;
435   model.ResourceReadySignal().Connect(&OnResourceReady);
436   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
437
438   application.SendNotification();
439   application.Render();
440
441   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
442   application.SendNotification();
443   application.Render();
444
445   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
446
447   Actor meshActor = model.FindChildByName("AnimatedCube");
448   DALI_TEST_CHECK(meshActor);
449
450   Renderer renderer = meshActor.GetRendererAt(0u);
451   DALI_TEST_CHECK(renderer);
452
453   TextureSet textureSet = renderer.GetTextures();
454   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
455
456   Texture diffuseTexture  = textureSet.GetTexture(7u);
457   Texture specularTexture = textureSet.GetTexture(8u);
458
459   // if url is empty, loading is not requested.
460   model.SetImageBasedLightSource("", "");
461
462   Texture newDiffuseTexture  = textureSet.GetTexture(7u);
463   Texture newSpecularTexture = textureSet.GetTexture(8u);
464
465   DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
466   DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
467
468   END_TEST;
469 }
470
471 int UtcDaliModelSetImageBasedLightSource03(void)
472 {
473   ToolkitTestApplication application;
474
475   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
476   application.GetScene().Add(model);
477
478   gResourceReadyCalled = false;
479   model.ResourceReadySignal().Connect(&OnResourceReady);
480   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
481
482   application.SendNotification();
483   application.Render();
484
485   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
486   application.SendNotification();
487   application.Render();
488
489   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
490
491   Actor meshActor = model.FindChildByName("AnimatedCube");
492   DALI_TEST_CHECK(meshActor);
493
494   Renderer renderer = meshActor.GetRendererAt(0u);
495   DALI_TEST_CHECK(renderer);
496
497   TextureSet textureSet = renderer.GetTextures();
498   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
499
500   Texture diffuseTexture  = textureSet.GetTexture(7u);
501   Texture specularTexture = textureSet.GetTexture(8u);
502
503   gResourceReadyCalled = false;
504   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
505   model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
506
507   application.SendNotification();
508   application.Render();
509
510   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
511   application.SendNotification();
512   application.Render();
513
514   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
515
516   Texture newDiffuseTexture  = textureSet.GetTexture(7u);
517   Texture newSpecularTexture = textureSet.GetTexture(8u);
518
519   DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
520   DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
521
522   END_TEST;
523 }
524
525 int UtcDaliModelSetImageBasedLightSource04(void)
526 {
527   ToolkitTestApplication application;
528
529   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
530   model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
531   application.GetScene().Add(model);
532
533   gResourceReadyCalled = false;
534   model.ResourceReadySignal().Connect(&OnResourceReady);
535   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
536
537   application.SendNotification();
538   application.Render();
539
540   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
541   application.SendNotification();
542   application.Render();
543
544   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
545   END_TEST;
546 }
547
548 int UtcDaliModelImageBasedFactor(void)
549 {
550   ToolkitTestApplication application;
551
552   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
553
554   DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
555
556   model.SetImageBasedLightScaleFactor(0.5f);
557   DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
558   END_TEST;
559 }
560
561 int UtcDaliModelChildrenSensitive01(void)
562 {
563   ToolkitTestApplication application;
564
565   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
566   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
567   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
568   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
569   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
570
571   // Get default vaule.
572   DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
573
574   // Allow children actor's event before on scene.
575   view.SetChildrenSensitive(true);
576   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
577   application.GetScene().Add(view);
578
579   gResourceReadyCalled = false;
580   view.ResourceReadySignal().Connect(&OnResourceReady);
581   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
582
583   application.SendNotification();
584   application.Render();
585
586   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
587   application.SendNotification();
588   application.Render();
589
590   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
591
592   Actor meshActor = view.FindChildByName("AnimatedCube");
593   DALI_TEST_CHECK(meshActor);
594
595   // connect hit-test signal
596   gTouchCallBackCalled = false;
597   meshActor.TouchedSignal().Connect(TestTouchCallback);
598
599   Vector2 sceneSize = application.GetScene().GetSize();
600
601   // Try to touch center of scene.
602   Dali::Integration::Point point;
603   point.SetState(PointState::DOWN);
604   point.SetScreenPosition(sceneSize * 0.5f);
605   Dali::Integration::TouchEvent event;
606   event.AddPoint(point);
607
608   // flush the queue and render once
609   application.SendNotification();
610   application.Render();
611
612   // Not touched yet.
613   DALI_TEST_CHECK(!gTouchCallBackCalled);
614   application.ProcessEvent(event);
615   // Touched.
616   DALI_TEST_CHECK(gTouchCallBackCalled);
617
618   // Clear
619   gTouchCallBackCalled = false;
620
621   // Block children actor's event
622   view.SetChildrenSensitive(false);
623   DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
624
625   // flush the queue and render once
626   application.SendNotification();
627   application.Render();
628
629   // Not touched yet.
630   DALI_TEST_CHECK(!gTouchCallBackCalled);
631   application.ProcessEvent(event);
632   // Also not touched.
633   DALI_TEST_CHECK(!gTouchCallBackCalled);
634
635   // Clear
636   gTouchCallBackCalled = false;
637
638   // Allow again
639   view.SetChildrenSensitive(true);
640   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
641
642   // flush the queue and render once
643   application.SendNotification();
644   application.Render();
645
646   // Not touched yet.
647   DALI_TEST_CHECK(!gTouchCallBackCalled);
648   application.ProcessEvent(event);
649   // Touched.
650   DALI_TEST_CHECK(gTouchCallBackCalled);
651
652   // Clear
653   gTouchCallBackCalled = false;
654
655   END_TEST;
656 }
657
658 int UtcDaliModelChildrenSensitive02(void)
659 {
660   ToolkitTestApplication application;
661
662   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
663   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
664   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
665   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
666   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
667
668   // Get vaule.
669   DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
670
671   // Block children actor's event before on scene.
672   view.SetChildrenSensitive(false);
673   DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
674   application.GetScene().Add(view);
675
676   gResourceReadyCalled = false;
677   view.ResourceReadySignal().Connect(&OnResourceReady);
678   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
679
680   application.SendNotification();
681   application.Render();
682
683   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
684   application.SendNotification();
685   application.Render();
686
687   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
688
689   Actor meshActor = view.FindChildByName("AnimatedCube");
690   DALI_TEST_CHECK(meshActor);
691
692   // connect hit-test signal
693   gTouchCallBackCalled = false;
694   meshActor.TouchedSignal().Connect(TestTouchCallback);
695
696   Vector2 sceneSize = application.GetScene().GetSize();
697
698   // Try to touch center of scene.
699   Dali::Integration::Point point;
700   point.SetState(PointState::DOWN);
701   point.SetScreenPosition(sceneSize * 0.5f);
702   Dali::Integration::TouchEvent event;
703   event.AddPoint(point);
704
705   // flush the queue and render once
706   application.SendNotification();
707   application.Render();
708
709   // Not touched yet.
710   DALI_TEST_CHECK(!gTouchCallBackCalled);
711   application.ProcessEvent(event);
712   // Also not touched.
713   DALI_TEST_CHECK(!gTouchCallBackCalled);
714
715   // Clear
716   gTouchCallBackCalled = false;
717
718   // Allow again
719   view.SetChildrenSensitive(true);
720   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
721
722   // flush the queue and render once
723   application.SendNotification();
724   application.Render();
725
726   // Not touched yet.
727   DALI_TEST_CHECK(!gTouchCallBackCalled);
728   application.ProcessEvent(event);
729   // Touched.
730   DALI_TEST_CHECK(gTouchCallBackCalled);
731
732   // Clear
733   gTouchCallBackCalled = false;
734
735   END_TEST;
736 }
737
738 int UtcDaliModelChildrenFocusable01(void)
739 {
740   ToolkitTestApplication application;
741
742   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
743   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
744   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
745   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
746   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
747
748   // Get vaule. Default is false.
749   DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
750
751   // Allow children actor's focus before on scene.
752   view.SetChildrenFocusable(true);
753   DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
754   application.GetScene().Add(view);
755
756   gResourceReadyCalled = false;
757   view.ResourceReadySignal().Connect(&OnResourceReady);
758   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
759
760   application.SendNotification();
761   application.Render();
762
763   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
764   application.SendNotification();
765   application.Render();
766
767   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
768
769   Actor meshActor = view.FindChildByName("AnimatedCube");
770   DALI_TEST_CHECK(meshActor);
771
772   // Enable the default algorithm
773   KeyboardFocusManager manager = KeyboardFocusManager::Get();
774   DALI_TEST_CHECK(manager);
775   Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
776
777   // connect focusable signal
778   gFocusChangedCallBackCalled = false;
779   meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
780   manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
781
782   // Initialize with some left-positioned actor
783   Control focusStartActor = Control::New();
784   focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
785   focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
786   focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
787   focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
788   focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
789   application.GetScene().Add(focusStartActor);
790
791   // Clear
792   manager.ClearFocus();
793   manager.SetCurrentFocusActor(focusStartActor);
794   gFocusChangedCallBackCalled = false;
795
796   // flush the queue and render once
797   application.SendNotification();
798   application.Render();
799
800   // Focusable view find success
801   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
802   DALI_TEST_CHECK(gFocusChangedCallBackCalled);
803
804   // Clear
805   manager.ClearFocus();
806   manager.SetCurrentFocusActor(focusStartActor);
807   gFocusChangedCallBackCalled = false;
808
809   // Block children actor's focus
810   view.SetChildrenFocusable(false);
811   DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
812
813   // flush the queue and render once
814   application.SendNotification();
815   application.Render();
816
817   // Focusable view find failed
818   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
819   DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
820
821   // Clear
822   manager.ClearFocus();
823   manager.SetCurrentFocusActor(focusStartActor);
824   gFocusChangedCallBackCalled = false;
825
826   // Allow again
827   view.SetChildrenFocusable(true);
828   DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
829
830   // flush the queue and render once
831   application.SendNotification();
832   application.Render();
833
834   // Focusable view find success
835   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
836   DALI_TEST_CHECK(gFocusChangedCallBackCalled);
837
838   // Clear
839   manager.ClearFocus();
840   manager.SetCurrentFocusActor(focusStartActor);
841   gFocusChangedCallBackCalled = false;
842
843   END_TEST;
844 }
845
846 int UtcDaliModelModelChildrenFocusable02(void)
847 {
848   ToolkitTestApplication application;
849
850   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
851   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
852   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
853   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
854   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
855
856   // Get vaule. Default is true.
857   DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
858
859   // Block children actor's focus before on scene.
860   view.SetChildrenFocusable(false);
861   DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
862   application.GetScene().Add(view);
863
864   gResourceReadyCalled = false;
865   view.ResourceReadySignal().Connect(&OnResourceReady);
866   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
867
868   application.SendNotification();
869   application.Render();
870
871   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
872   application.SendNotification();
873   application.Render();
874
875   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
876
877   Actor meshActor = view.FindChildByName("AnimatedCube");
878   DALI_TEST_CHECK(meshActor);
879
880   // Enable the default algorithm
881   KeyboardFocusManager manager = KeyboardFocusManager::Get();
882   DALI_TEST_CHECK(manager);
883   Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
884
885   // connect focusable signal
886   gFocusChangedCallBackCalled = false;
887   meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
888   manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
889
890   // Initialize with some left-positioned actor
891   Control focusStartActor = Control::New();
892   focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
893   focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
894   focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
895   focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
896   focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
897   application.GetScene().Add(focusStartActor);
898
899   // Clear
900   manager.ClearFocus();
901   manager.SetCurrentFocusActor(focusStartActor);
902   gFocusChangedCallBackCalled = false;
903
904   // flush the queue and render once
905   application.SendNotification();
906   application.Render();
907
908   // Focusable view find failed
909   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
910   DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
911
912   // Clear
913   manager.ClearFocus();
914   manager.SetCurrentFocusActor(focusStartActor);
915   gFocusChangedCallBackCalled = false;
916
917   // Allow again
918   view.SetChildrenFocusable(true);
919   DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
920
921   // flush the queue and render once
922   application.SendNotification();
923   application.Render();
924
925   // Focusable view find success
926   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
927   DALI_TEST_CHECK(gFocusChangedCallBackCalled);
928
929   // Clear
930   manager.ClearFocus();
931   manager.SetCurrentFocusActor(focusStartActor);
932   gFocusChangedCallBackCalled = false;
933
934   END_TEST;
935 }
936
937 int UtcDaliModelAnimation01(void)
938 {
939   ToolkitTestApplication application;
940
941   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
942   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
943   application.GetScene().Add(model);
944
945   gResourceReadyCalled = false;
946   model.ResourceReadySignal().Connect(&OnResourceReady);
947   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
948
949   application.SendNotification();
950   application.Render();
951
952   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
953   application.SendNotification();
954   application.Render();
955
956   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
957
958   uint32_t animationCount = model.GetAnimationCount();
959   DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
960
961   Animation animationByIndex = model.GetAnimation(0u);
962   DALI_TEST_CHECK(animationByIndex);
963
964   Animation animationByName = model.GetAnimation("animation_AnimatedCube");
965   DALI_TEST_CHECK(animationByName);
966   DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
967
968   END_TEST;
969 }
970
971 int UtcDaliModelAnimation02(void)
972 {
973   ToolkitTestApplication application;
974
975   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
976   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
977   application.GetScene().Add(model);
978
979   gResourceReadyCalled = false;
980   model.ResourceReadySignal().Connect(&OnResourceReady);
981   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
982
983   application.SendNotification();
984   application.Render();
985
986   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
987   application.SendNotification();
988   application.Render();
989
990   uint32_t animationCount = model.GetAnimationCount();
991   DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
992
993   Animation animation1 = model.GetAnimation("Step Scale");
994   DALI_TEST_CHECK(animation1);
995   DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
996
997   Animation animation2 = model.GetAnimation("CubicSpline Scale");
998   DALI_TEST_CHECK(animation2);
999   DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
1000
1001   DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
1002
1003   END_TEST;
1004 }
1005
1006 int UtcDaliModelAnimation03(void)
1007 {
1008   ToolkitTestApplication application;
1009
1010   Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
1011   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1012   application.GetScene().Add(model);
1013
1014   gResourceReadyCalled = false;
1015   model.ResourceReadySignal().Connect(&OnResourceReady);
1016   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1017
1018   application.SendNotification();
1019   application.Render();
1020
1021   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1022   application.SendNotification();
1023   application.Render();
1024
1025   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1026
1027   uint32_t animationCount = model.GetAnimationCount();
1028   DALI_TEST_EQUALS(18, animationCount, TEST_LOCATION);
1029
1030   Animation animationByIndex = model.GetAnimation(0u);
1031   DALI_TEST_CHECK(animationByIndex);
1032
1033   Animation animationByName = model.GetAnimation("idleClip");
1034   DALI_TEST_CHECK(animationByName);
1035   DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
1036
1037   END_TEST;
1038 }
1039
1040 int UtcDaliModelCameraGenerate01(void)
1041 {
1042   ToolkitTestApplication application;
1043
1044   Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
1045   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1046   application.GetScene().Add(model);
1047
1048   gResourceReadyCalled = false;
1049   model.ResourceReadySignal().Connect(&OnResourceReady);
1050   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1051
1052   application.SendNotification();
1053   application.Render();
1054
1055   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1056   application.SendNotification();
1057   application.Render();
1058
1059   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1060
1061   uint32_t cameraCount = model.GetCameraCount();
1062   DALI_TEST_EQUALS(1, cameraCount, TEST_LOCATION);
1063
1064   CameraActor generatedCamera = model.GenerateCamera(0u);
1065   DALI_TEST_CHECK(generatedCamera);
1066
1067   generatedCamera = model.GenerateCamera(1u); // Fail to generate camera
1068   DALI_TEST_CHECK(!generatedCamera);
1069
1070   END_TEST;
1071 }
1072
1073 int UtcDaliModelCameraGenerate02(void)
1074 {
1075   ToolkitTestApplication application;
1076
1077   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1078   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1079   application.GetScene().Add(model);
1080
1081   gResourceReadyCalled = false;
1082   model.ResourceReadySignal().Connect(&OnResourceReady);
1083   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1084
1085   application.SendNotification();
1086   application.Render();
1087
1088   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1089   application.SendNotification();
1090   application.Render();
1091
1092   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1093
1094   uint32_t cameraCount = model.GetCameraCount();
1095   DALI_TEST_EQUALS(6, cameraCount, TEST_LOCATION);
1096
1097   CameraActor generatedCamera0 = model.GenerateCamera(0u);
1098   DALI_TEST_CHECK(generatedCamera0);
1099   CameraActor generatedCamera1 = model.GenerateCamera(1u);
1100   DALI_TEST_CHECK(generatedCamera1);
1101   CameraActor generatedCamera2 = model.GenerateCamera(2u);
1102   DALI_TEST_CHECK(generatedCamera2);
1103   CameraActor generatedCamera3 = model.GenerateCamera(3u); // Infinity far camera
1104   DALI_TEST_CHECK(generatedCamera3);
1105   CameraActor generatedCamera4 = model.GenerateCamera(4u); // Broken camera 1
1106   DALI_TEST_CHECK(!generatedCamera4);
1107   CameraActor generatedCamera5 = model.GenerateCamera(5u); // Broken camera 2
1108   DALI_TEST_CHECK(!generatedCamera5);
1109   CameraActor generatedCamera6 = model.GenerateCamera(6u); // Out of bound
1110   DALI_TEST_CHECK(!generatedCamera6);
1111
1112   CameraActor appliedCamera;
1113   DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), false, TEST_LOCATION); // Cannot apply into empty camera.
1114
1115   auto CompareCameraProperties = [](CameraActor lhs, CameraActor rhs, const char* location) {
1116     DALI_TEST_EQUALS(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), rhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), TEST_LOCATION);
1117     DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), TEST_LOCATION);
1118
1119     if(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE) == static_cast<int>(Dali::Camera::ProjectionMode::PERSPECTIVE_PROJECTION))
1120     {
1121       DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), rhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), TEST_LOCATION);
1122       // TODO : Open this test when infinity far projection implement.
1123       //DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
1124     }
1125     else
1126     {
1127       DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), rhs.GetProperty<float>(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), TEST_LOCATION);
1128       DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
1129     }
1130   };
1131
1132   appliedCamera = CameraActor::New();
1133   DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), true, TEST_LOCATION);
1134   CompareCameraProperties(generatedCamera0, appliedCamera, TEST_LOCATION);
1135   DALI_TEST_EQUALS(model.ApplyCamera(1u, appliedCamera), true, TEST_LOCATION);
1136   CompareCameraProperties(generatedCamera1, appliedCamera, TEST_LOCATION);
1137   DALI_TEST_EQUALS(model.ApplyCamera(2u, appliedCamera), true, TEST_LOCATION);
1138   CompareCameraProperties(generatedCamera2, appliedCamera, TEST_LOCATION);
1139   DALI_TEST_EQUALS(model.ApplyCamera(3u, appliedCamera), true, TEST_LOCATION);
1140   CompareCameraProperties(generatedCamera3, appliedCamera, TEST_LOCATION);
1141   DALI_TEST_EQUALS(model.ApplyCamera(4u, appliedCamera), false, TEST_LOCATION); // Broken camera 1
1142   DALI_TEST_EQUALS(model.ApplyCamera(5u, appliedCamera), false, TEST_LOCATION); // Broken camera 2
1143   DALI_TEST_EQUALS(model.ApplyCamera(6u, appliedCamera), false, TEST_LOCATION); // Cannot apply over the index.
1144
1145   END_TEST;
1146 }
1147
1148 int UtcDaliModelMultiplePrimitives(void)
1149 {
1150   ToolkitTestApplication application;
1151
1152   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME);
1153   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1154   application.GetScene().Add(model);
1155
1156   gResourceReadyCalled = false;
1157   model.ResourceReadySignal().Connect(&OnResourceReady);
1158   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1159
1160   application.SendNotification();
1161   application.Render();
1162
1163   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1164   application.SendNotification();
1165   application.Render();
1166
1167   Actor actor = model.FindChildByName("rootNode");
1168
1169   DALI_TEST_EQUALS(0, actor.GetChildCount(), TEST_LOCATION);
1170   DALI_TEST_EQUALS(2, actor.GetRendererCount(), TEST_LOCATION);
1171
1172   END_TEST;
1173 }
1174
1175 int UtcDaliModelColorMode(void)
1176 {
1177   ToolkitTestApplication application;
1178
1179   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1180   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1181   model.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
1182   application.GetScene().Add(model);
1183
1184   gResourceReadyCalled = false;
1185   model.ResourceReadySignal().Connect(&OnResourceReady);
1186   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1187
1188   application.SendNotification();
1189   application.Render();
1190
1191   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1192   application.SendNotification();
1193   application.Render();
1194
1195   Actor   actor           = model.FindChildByName("AnimatedCube");
1196   Vector4 childColor      = actor[Dali::Actor::Property::COLOR];
1197   Vector4 childWorldColor = actor[Dali::Actor::Property::WORLD_COLOR];
1198
1199   DALI_TEST_EQUALS(childColor, Color::WHITE, TEST_LOCATION);
1200   DALI_TEST_EQUALS(childWorldColor, Color::RED, TEST_LOCATION);
1201
1202   END_TEST;
1203 }
1204 int UtcDaliModelResourceReady(void)
1205 {
1206   ToolkitTestApplication application;
1207
1208   gOnRelayoutCallBackCalled = false;
1209   gResourceReadyCalled      = false;
1210   Scene3D::Model model      = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
1211   model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1212   model.OnRelayoutSignal().Connect(OnRelayoutCallback);
1213   model.ResourceReadySignal().Connect(OnResourceReady);
1214   DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
1215
1216   // Sanity check
1217   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
1218   DALI_TEST_CHECK(!gResourceReadyCalled);
1219
1220   application.GetScene().Add(model);
1221
1222   application.SendNotification();
1223   application.Render();
1224
1225   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1226   application.SendNotification();
1227   application.Render();
1228
1229   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
1230   DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
1231   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1232
1233   END_TEST;
1234 }