Fix SVACE issue
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-scene3d / utc-Dali-Model.cpp
1 /*
2  * Copyright (c) 2022 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
26 #include <dali-scene3d/public-api/controls/model/model.h>
27
28 using namespace Dali;
29 using namespace Dali::Toolkit;
30
31 void model_startup(void)
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void model_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41 namespace
42 {
43 const bool DEFAULT_MODEL_CHILDREN_SENSITIVE = false;
44 /**
45  * For the AnimatedCube.gltf and its Assets
46  * Donated by Norbert Nopper for glTF testing.
47  * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
48  */
49 const char* TEST_GLTF_FILE_NAME                = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
50 const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf";
51 const char* TEST_DLI_FILE_NAME                 = TEST_RESOURCE_DIR "/arc.dli";
52 /**
53  * For the diffuse and specular cube map texture.
54  * These textures are based off version of Wave engine sample
55  * Take from https://github.com/WaveEngine/Samples
56  *
57  * Copyright (c) 2022 Wave Coorporation
58  *
59  * Permission is hereby granted, free of charge, to any person obtaining a copy
60  * of this software and associated documentation files (the "Software"), to
61  * deal in the Software without restriction, including without limitation the
62  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
63  * sell copies of the Software, and to permit persons to whom the Software is
64  * furnished to do so, subject to the following conditions:
65  *
66  * The above copyright notice and this permission notice shall be included in
67  * all copies or substantial portions of the Software.
68  *
69  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
72  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
75  * THE SOFTWARE.
76  */
77 const char* TEST_DIFFUSE_TEXTURE  = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
78 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
79
80 bool gTouchCallBackCalled = false;
81 bool TestTouchCallback(Actor, const TouchEvent&)
82 {
83   gTouchCallBackCalled = true;
84   return true;
85 }
86
87 } // namespace
88
89 // Negative test case for a method
90 int UtcDaliModelUninitialized(void)
91 {
92   ToolkitTestApplication application;
93   tet_infoline(" UtcDaliModelUninitialized");
94
95   Scene3D::Model model;
96
97   try
98   {
99     // New() must be called to create a Model or it wont be valid.
100     Actor a = Actor::New();
101     model.Add(a);
102     DALI_TEST_CHECK(false);
103   }
104   catch(Dali::DaliException& e)
105   {
106     // Tests that a negative test of an assertion succeeds
107     DALI_TEST_PRINT_ASSERT(e);
108     DALI_TEST_CHECK(!model);
109   }
110   END_TEST;
111 }
112
113 // Positive test case for a method
114 int UtcDaliModelNew(void)
115 {
116   ToolkitTestApplication application;
117   tet_infoline(" UtcDaliModelNew");
118
119   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
120   DALI_TEST_CHECK(model);
121   END_TEST;
122 }
123
124 // Positive test case for a method
125 int UtcDaliModelDownCast(void)
126 {
127   ToolkitTestApplication application;
128   tet_infoline(" UtcDaliModelDownCast");
129
130   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
131   BaseHandle     handle(model);
132
133   Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
134   DALI_TEST_CHECK(model);
135   DALI_TEST_CHECK(model2);
136   DALI_TEST_CHECK(model2 == model);
137   END_TEST;
138 }
139
140 int UtcDaliModelTypeRegistry(void)
141 {
142   ToolkitTestApplication application;
143
144   TypeRegistry typeRegistry = TypeRegistry::Get();
145   DALI_TEST_CHECK(typeRegistry);
146
147   TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
148   DALI_TEST_CHECK(typeInfo);
149
150   BaseHandle handle = typeInfo.CreateInstance();
151   DALI_TEST_CHECK(handle);
152
153   Scene3D::Model model = Scene3D::Model::DownCast(handle);
154   DALI_TEST_CHECK(model);
155
156   END_TEST;
157 }
158
159 // Positive test case for a method
160 int UtcDaliModelAddRemove(void)
161 {
162   ToolkitTestApplication application;
163   tet_infoline(" UtcDaliModelAddRemove");
164
165   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
166   DALI_TEST_CHECK(model);
167
168   Actor actor = Actor::New();
169   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
170
171   model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
172   model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
173   model.Add(actor);
174   application.GetScene().Add(model);
175
176   DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
177
178   model.Remove(actor);
179
180   DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
181   END_TEST;
182 }
183
184 int UtcDaliModelCopyAndAssignment(void)
185 {
186   ToolkitTestApplication application;
187
188   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
189   DALI_TEST_CHECK(model);
190
191   Scene3D::Model copy(model);
192   DALI_TEST_CHECK(model == copy);
193
194   Scene3D::Model assign;
195   DALI_TEST_CHECK(!assign);
196
197   assign = copy;
198   DALI_TEST_CHECK(assign == model);
199
200   END_TEST;
201 }
202
203 int UtcDaliModelMoveConstructor(void)
204 {
205   ToolkitTestApplication application;
206
207   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
208   DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
209   model.SetProperty(Actor::Property::SENSITIVE, false);
210   DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
211
212   Scene3D::Model moved = std::move(model);
213   DALI_TEST_CHECK(moved);
214   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
215   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
216   DALI_TEST_CHECK(!model);
217
218   END_TEST;
219 }
220
221 int UtcDaliModelMoveAssignment(void)
222 {
223   ToolkitTestApplication application;
224
225   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
226   DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
227   model.SetProperty(Actor::Property::SENSITIVE, false);
228   DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
229
230   Scene3D::Model moved;
231   moved = std::move(model);
232   DALI_TEST_CHECK(moved);
233   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
234   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
235   DALI_TEST_CHECK(!model);
236
237   END_TEST;
238 }
239
240 int UtcDaliModelOnScene01(void)
241 {
242   ToolkitTestApplication application;
243
244   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
245
246   application.GetScene().Add(model);
247
248   application.SendNotification();
249   application.Render();
250
251   uint32_t modelCount = model.GetModelRoot().GetChildCount();
252   DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
253
254   END_TEST;
255 }
256
257 int UtcDaliModelOnScene02(void)
258 {
259   ToolkitTestApplication application;
260
261   Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
262
263   application.GetScene().Add(model);
264
265   application.SendNotification();
266   application.Render();
267
268   uint32_t modelCount = model.GetModelRoot().GetChildCount();
269   DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
270
271   Actor   rootActor = model.GetModelRoot();
272   Vector3 rootSize  = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
273   DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
274
275   END_TEST;
276 }
277
278 int UtcDaliModelOnSizeSet(void)
279 {
280   ToolkitTestApplication application;
281
282   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
283
284   application.GetScene().Add(model);
285
286   application.SendNotification();
287   application.Render();
288
289   Vector2 size(200.0f, 300.0f);
290   model.SetProperty(Actor::Property::SIZE, size);
291
292   application.SendNotification();
293   application.Render();
294
295   DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
296
297   END_TEST;
298 }
299
300 int UtcDaliModelGetNaturalSize(void)
301 {
302   ToolkitTestApplication application;
303
304   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
305
306   Vector3 naturalSize = model.GetNaturalSize();
307
308   DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
309
310   Actor root = model.GetModelRoot();
311   DALI_TEST_CHECK(root);
312
313   END_TEST;
314 }
315
316 int UtcDaliModelSetImageBasedLightSource01(void)
317 {
318   ToolkitTestApplication application;
319
320   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
321
322   application.GetScene().Add(model);
323
324   application.SendNotification();
325   application.Render();
326
327   Actor meshActor = model.FindChildByName("AnimatedCube");
328   DALI_TEST_CHECK(meshActor);
329
330   Renderer renderer = meshActor.GetRendererAt(0u);
331   DALI_TEST_CHECK(renderer);
332
333   TextureSet textureSet = renderer.GetTextures();
334   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
335
336   Texture diffuseTexture  = textureSet.GetTexture(5u);
337   Texture specularTexture = textureSet.GetTexture(6u);
338
339   model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
340
341   Texture newDiffuseTexture  = textureSet.GetTexture(5u);
342   Texture newSpecularTexture = textureSet.GetTexture(6u);
343
344   DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
345   DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
346
347   END_TEST;
348 }
349
350 int UtcDaliModelSetImageBasedLightSource02(void)
351 {
352   ToolkitTestApplication application;
353
354   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
355
356   application.GetScene().Add(model);
357
358   application.SendNotification();
359   application.Render();
360
361   Actor meshActor = model.FindChildByName("AnimatedCube");
362   DALI_TEST_CHECK(meshActor);
363
364   Renderer renderer = meshActor.GetRendererAt(0u);
365   DALI_TEST_CHECK(renderer);
366
367   TextureSet textureSet = renderer.GetTextures();
368   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
369
370   Texture diffuseTexture  = textureSet.GetTexture(5u);
371   Texture specularTexture = textureSet.GetTexture(6u);
372
373   model.SetImageBasedLightSource("", "");
374
375   Texture newDiffuseTexture  = textureSet.GetTexture(5u);
376   Texture newSpecularTexture = textureSet.GetTexture(6u);
377
378   DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
379   DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
380
381   END_TEST;
382 }
383
384 int UtcDaliModelSetImageBasedLightSource03(void)
385 {
386   ToolkitTestApplication application;
387
388   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
389
390   application.GetScene().Add(model);
391
392   application.SendNotification();
393   application.Render();
394
395   Actor meshActor = model.FindChildByName("AnimatedCube");
396   DALI_TEST_CHECK(meshActor);
397
398   Renderer renderer = meshActor.GetRendererAt(0u);
399   DALI_TEST_CHECK(renderer);
400
401   TextureSet textureSet = renderer.GetTextures();
402   DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
403
404   Texture diffuseTexture  = textureSet.GetTexture(5u);
405   Texture specularTexture = textureSet.GetTexture(6u);
406
407   model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
408
409   Texture newDiffuseTexture  = textureSet.GetTexture(5u);
410   Texture newSpecularTexture = textureSet.GetTexture(6u);
411
412   DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
413   DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
414
415   END_TEST;
416 }
417
418 int UtcDaliModelImageBasedFactor(void)
419 {
420   ToolkitTestApplication application;
421
422   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
423
424   DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
425
426   model.SetImageBasedLightScaleFactor(0.5f);
427   DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
428   END_TEST;
429 }
430
431 int UtcDaliModelChildrenSensitive01(void)
432 {
433   ToolkitTestApplication application;
434
435   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
436   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
437   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
438   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
439   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
440
441   // Get default vaule.
442   DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
443
444   // Allow children actor's event before on scene.
445   view.SetChildrenSensitive(true);
446   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
447
448   application.GetScene().Add(view);
449
450   application.SendNotification();
451   application.Render();
452
453   Actor meshActor = view.FindChildByName("AnimatedCube");
454   DALI_TEST_CHECK(meshActor);
455
456   // connect hit-test signal
457   gTouchCallBackCalled = false;
458   meshActor.TouchedSignal().Connect(TestTouchCallback);
459
460   Vector2 sceneSize = application.GetScene().GetSize();
461
462   // Try to touch center of scene.
463   Dali::Integration::Point point;
464   point.SetState(PointState::DOWN);
465   point.SetScreenPosition(sceneSize * 0.5f);
466   Dali::Integration::TouchEvent event;
467   event.AddPoint(point);
468
469   // flush the queue and render once
470   application.SendNotification();
471   application.Render();
472
473   // Not touched yet.
474   DALI_TEST_CHECK(!gTouchCallBackCalled);
475   application.ProcessEvent(event);
476   // Touched.
477   DALI_TEST_CHECK(gTouchCallBackCalled);
478
479   // Clear
480   gTouchCallBackCalled = false;
481
482   // Block children actor's event
483   view.SetChildrenSensitive(false);
484   DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
485
486   // flush the queue and render once
487   application.SendNotification();
488   application.Render();
489
490   // Not touched yet.
491   DALI_TEST_CHECK(!gTouchCallBackCalled);
492   application.ProcessEvent(event);
493   // Also not touched.
494   DALI_TEST_CHECK(!gTouchCallBackCalled);
495
496   // Clear
497   gTouchCallBackCalled = false;
498
499   // Allow again
500   view.SetChildrenSensitive(true);
501   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
502
503   // flush the queue and render once
504   application.SendNotification();
505   application.Render();
506
507   // Not touched yet.
508   DALI_TEST_CHECK(!gTouchCallBackCalled);
509   application.ProcessEvent(event);
510   // Touched.
511   DALI_TEST_CHECK(gTouchCallBackCalled);
512
513   // Clear
514   gTouchCallBackCalled = false;
515
516   END_TEST;
517 }
518
519 int UtcDaliModelChildrenSensitive02(void)
520 {
521   ToolkitTestApplication application;
522
523   Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
524   view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
525   view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
526   view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
527   view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
528
529   // Get vaule.
530   DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
531
532   // Block children actor's event before on scene.
533   view.SetChildrenSensitive(false);
534   DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
535
536   application.GetScene().Add(view);
537
538   application.SendNotification();
539   application.Render();
540
541   Actor meshActor = view.FindChildByName("AnimatedCube");
542   DALI_TEST_CHECK(meshActor);
543
544   // connect hit-test signal
545   gTouchCallBackCalled = false;
546   meshActor.TouchedSignal().Connect(TestTouchCallback);
547
548   Vector2 sceneSize = application.GetScene().GetSize();
549
550   // Try to touch center of scene.
551   Dali::Integration::Point point;
552   point.SetState(PointState::DOWN);
553   point.SetScreenPosition(sceneSize * 0.5f);
554   Dali::Integration::TouchEvent event;
555   event.AddPoint(point);
556
557   // flush the queue and render once
558   application.SendNotification();
559   application.Render();
560
561   // Not touched yet.
562   DALI_TEST_CHECK(!gTouchCallBackCalled);
563   application.ProcessEvent(event);
564   // Also not touched.
565   DALI_TEST_CHECK(!gTouchCallBackCalled);
566
567   // Clear
568   gTouchCallBackCalled = false;
569
570   // Allow again
571   view.SetChildrenSensitive(true);
572   DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
573
574   // flush the queue and render once
575   application.SendNotification();
576   application.Render();
577
578   // Not touched yet.
579   DALI_TEST_CHECK(!gTouchCallBackCalled);
580   application.ProcessEvent(event);
581   // Touched.
582   DALI_TEST_CHECK(gTouchCallBackCalled);
583
584   // Clear
585   gTouchCallBackCalled = false;
586
587   END_TEST;
588 }
589
590 int UtcDaliModelAnimation01(void)
591 {
592   ToolkitTestApplication application;
593
594   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
595   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
596
597   application.GetScene().Add(model);
598
599   application.SendNotification();
600   application.Render();
601
602   uint32_t animationCount = model.GetAnimationCount();
603   DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
604
605   Animation animationByIndex = model.GetAnimation(0u);
606   DALI_TEST_CHECK(animationByIndex);
607
608   Animation animationByName = model.GetAnimation("animation_AnimatedCube");
609   DALI_TEST_CHECK(animationByName);
610   DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
611
612   END_TEST;
613 }
614
615 int UtcDaliModelAnimation02(void)
616 {
617   ToolkitTestApplication application;
618
619   Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
620   model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
621
622   application.GetScene().Add(model);
623
624   application.SendNotification();
625   application.Render();
626
627   uint32_t animationCount = model.GetAnimationCount();
628   DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
629
630   Animation animation1 = model.GetAnimation("Step Scale");
631   DALI_TEST_CHECK(animation1);
632   DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
633
634   Animation animation2 = model.GetAnimation("CubicSpline Scale");
635   DALI_TEST_CHECK(animation2);
636   DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
637
638   DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
639
640   END_TEST;
641 }
642
643 // For ResourceReady
644 namespace
645 {
646 static bool gOnRelayoutCallBackCalled = false;
647 void        OnRelayoutCallback(Actor actor)
648 {
649   gOnRelayoutCallBackCalled = true;
650 }
651
652 static bool gResourceReadyCalled = false;
653 void        OnResourceReady(Control control)
654 {
655   gResourceReadyCalled = true;
656 }
657 } // namespace
658
659 int UtcDaliModelResourceReady(void)
660 {
661   ToolkitTestApplication application;
662
663   gOnRelayoutCallBackCalled = false;
664   gResourceReadyCalled      = false;
665   Scene3D::Model model      = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
666   model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
667   model.OnRelayoutSignal().Connect(OnRelayoutCallback);
668   model.ResourceReadySignal().Connect(OnResourceReady);
669   DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
670
671   // Sanity check
672   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
673   DALI_TEST_CHECK(!gResourceReadyCalled);
674
675   application.GetScene().Add(model);
676
677   application.SendNotification();
678   application.Render();
679
680   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
681   DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
682   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
683
684   END_TEST;
685 }