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