2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali/devel-api/common/map-wrapper.h>
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-environment-variable.h>
27 #include <toolkit-event-thread-callback.h>
29 #include <dali-scene3d/public-api/controls/model/model.h>
30 #include <dali-scene3d/public-api/model-components/model-node.h>
32 #include <dali-scene3d/public-api/model-motion/motion-data.h>
33 #include <dali-scene3d/public-api/model-motion/motion-index/blend-shape-index.h>
34 #include <dali-scene3d/public-api/model-motion/motion-index/motion-transform-index.h>
36 #include <dali/devel-api/actors/camera-actor-devel.h>
39 using namespace Dali::Toolkit;
41 void model_startup(void)
43 test_return_value = TET_UNDEF;
46 void model_cleanup(void)
48 test_return_value = TET_PASS;
53 const bool DEFAULT_MODEL_CHILDREN_SENSITIVE = false;
54 const bool DEFAULT_MODEL_CHILDREN_FOCUSABLE = false;
56 * For the AnimatedCube.gltf and its Assets
57 * Donated by Norbert Nopper for glTF testing.
58 * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
60 const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
61 const char* TEST_GLTF_FILE_NAME_SAME_FILE = TEST_RESOURCE_DIR "/AnimatedCube2.gltf";
62 const char* TEST_GLTF_FILE_NAME_DIFF_META_FILE = TEST_RESOURCE_DIR "/AnimatedCube3.gltf";
63 const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf";
64 const char* TEST_GLTF_EXTRAS_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedMorphCubeAnimateNonZeroFrame.gltf";
65 const char* TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME = TEST_RESOURCE_DIR "/simpleMultiplePrimitiveTest.gltf";
66 const char* TEST_GLTF_MORPH_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedMorphCube.gltf";
67 const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli";
68 const char* TEST_DLI_EXERCISE_FILE_NAME = TEST_RESOURCE_DIR "/exercise.dli";
71 * For the diffuse and specular cube map texture.
72 * These textures are based off version of Wave engine sample
73 * Take from https://github.com/WaveEngine/Samples
75 * Copyright (c) 2023 Wave Coorporation
77 * Permission is hereby granted, free of charge, to any person obtaining a copy
78 * of this software and associated documentation files (the "Software"), to
79 * deal in the Software without restriction, including without limitation the
80 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
81 * sell copies of the Software, and to permit persons to whom the Software is
82 * furnished to do so, subject to the following conditions:
84 * The above copyright notice and this permission notice shall be included in
85 * all copies or substantial portions of the Software.
87 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
95 const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
96 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
98 bool gTouchCallBackCalled = false;
99 bool TestTouchCallback(Actor, const TouchEvent&)
101 gTouchCallBackCalled = true;
105 bool gFocusChangedCallBackCalled = false;
106 void TestFocusChangedCallback(Actor, Actor)
108 gFocusChangedCallBackCalled = true;
112 static bool gOnRelayoutCallBackCalled = false;
113 void OnRelayoutCallback(Actor actor)
115 gOnRelayoutCallBackCalled = true;
118 static bool gResourceReadyCalled = false;
119 void OnResourceReady(Control control)
121 gResourceReadyCalled = true;
126 // Negative test case for a method
127 int UtcDaliModelUninitialized(void)
129 ToolkitTestApplication application;
130 tet_infoline(" UtcDaliModelUninitialized");
132 Scene3D::Model model;
136 // New() must be called to create a Model or it wont be valid.
137 Actor a = Actor::New();
139 DALI_TEST_CHECK(false);
141 catch(Dali::DaliException& e)
143 // Tests that a negative test of an assertion succeeds
144 DALI_TEST_PRINT_ASSERT(e);
145 DALI_TEST_CHECK(!model);
150 // Positive test case for a method
151 int UtcDaliModelNew(void)
153 ToolkitTestApplication application;
154 tet_infoline(" UtcDaliModelNew");
156 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
157 DALI_TEST_CHECK(model);
161 // Positive test case for a method
162 int UtcDaliModelNewP2(void)
164 ToolkitTestApplication application;
165 tet_infoline(" UtcDaliModelNew without url");
167 Scene3D::Model model = Scene3D::Model::New();
168 DALI_TEST_CHECK(model);
170 application.GetScene().Add(model);
172 DALI_TEST_CHECK(model.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
174 application.GetScene().Remove(model);
176 DALI_TEST_CHECK(!model.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
181 int UtcDaliModelNewSameModelUrlCached(void)
183 ToolkitTestApplication application;
184 tet_infoline(" UtcDaliModelNew with same model");
186 // Set up trace debug
187 TestGlAbstraction& gl = application.GetGlAbstraction();
188 TraceCallStack& textureTrace = gl.GetTextureTrace();
189 textureTrace.Enable(true);
191 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
192 DALI_TEST_CHECK(model);
193 Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
194 DALI_TEST_CHECK(model2);
196 application.GetScene().Add(model);
198 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
200 application.SendNotification();
201 application.Render();
203 tet_printf("Test if there is at least 1 texture.\n");
204 int expectTextureCount = textureTrace.CountMethod("GenTextures");
205 DALI_TEST_GREATER(expectTextureCount, 0, TEST_LOCATION);
207 application.GetScene().Add(model2);
209 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
211 application.SendNotification();
212 application.Render();
214 tet_printf("Test if we reuse cached texture or not.\n");
215 int currentTextureCount = textureTrace.CountMethod("GenTextures");
216 DALI_TEST_EQUALS(currentTextureCount, expectTextureCount, TEST_LOCATION);
218 application.SendNotification();
219 application.Render();
224 int UtcDaliModelNewSameResourceUrlCached01(void)
226 ToolkitTestApplication application;
227 tet_infoline(" UtcDaliModelNew with difference url but same model");
229 // Set up trace debug
230 TestGlAbstraction& gl = application.GetGlAbstraction();
231 TraceCallStack& textureTrace = gl.GetTextureTrace();
232 textureTrace.Enable(true);
233 textureTrace.EnableLogging(true);
235 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
236 DALI_TEST_CHECK(model);
237 Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME_SAME_FILE); // Difference model that use same Images.
238 DALI_TEST_CHECK(model2);
239 Scene3D::Model model3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME_DIFF_META_FILE); // Difference model that use same Images, but difference metadata.
240 DALI_TEST_CHECK(model3);
242 application.GetScene().Add(model);
244 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
246 application.SendNotification();
247 application.Render();
249 tet_printf("Test if there is at least 1 texture.\n");
250 int expectTextureCount = textureTrace.CountMethod("GenTextures");
251 DALI_TEST_GREATER(expectTextureCount, 0, TEST_LOCATION);
253 application.GetScene().Add(model2);
255 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
257 application.SendNotification();
258 application.Render();
260 tet_printf("Test if we reuse cached texture or not.\n");
261 int currentTextureCount = textureTrace.CountMethod("GenTextures");
262 DALI_TEST_EQUALS(currentTextureCount, expectTextureCount, TEST_LOCATION);
264 application.GetScene().Add(model3);
266 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
268 application.SendNotification();
269 application.Render();
271 tet_printf("Test if we don't reuse cached texture, due to the metadata difference.\n");
272 currentTextureCount = textureTrace.CountMethod("GenTextures");
273 DALI_TEST_GREATER(currentTextureCount, expectTextureCount, TEST_LOCATION);
275 application.SendNotification();
276 application.Render();
281 int UtcDaliModelNewSameResourceUrlCached02(void)
283 /// Make we don't use mutiple thread loading for this UTC.
284 EnvironmentVariable::SetTestEnvironmentVariable("DALI_ASYNC_MANAGER_THREAD_POOL_SIZE", "1");
285 EnvironmentVariable::SetTestEnvironmentVariable("DALI_ASYNC_MANAGER_LOW_PRIORITY_THREAD_POOL_SIZE", "1");
287 ToolkitTestApplication application;
288 tet_infoline(" UtcDaliModelNew with difference url but same model");
290 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
291 DALI_TEST_CHECK(model);
292 Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME_SAME_FILE);
293 DALI_TEST_CHECK(model2);
295 application.GetScene().Add(model);
296 application.GetScene().Add(model2);
298 application.SendNotification();
299 application.Render();
301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
302 application.SendNotification();
303 application.Render();
308 // Positive test case for a method
309 int UtcDaliModelDownCast(void)
311 ToolkitTestApplication application;
312 tet_infoline(" UtcDaliModelDownCast");
314 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
315 BaseHandle handle(model);
317 Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
318 DALI_TEST_CHECK(model);
319 DALI_TEST_CHECK(model2);
320 DALI_TEST_CHECK(model2 == model);
324 int UtcDaliModelTypeRegistry(void)
326 ToolkitTestApplication application;
328 TypeRegistry typeRegistry = TypeRegistry::Get();
329 DALI_TEST_CHECK(typeRegistry);
331 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
332 DALI_TEST_CHECK(typeInfo);
334 BaseHandle handle = typeInfo.CreateInstance();
335 DALI_TEST_CHECK(handle);
337 Scene3D::Model model = Scene3D::Model::DownCast(handle);
338 DALI_TEST_CHECK(model);
343 // Positive test case for a method
344 int UtcDaliModelAddRemove(void)
346 ToolkitTestApplication application;
347 tet_infoline(" UtcDaliModelAddRemove");
349 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
350 DALI_TEST_CHECK(model);
352 Actor actor = Actor::New();
353 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
355 model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
356 model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
358 application.GetScene().Add(model);
360 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
364 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
368 int UtcDaliModelCopyAndAssignment(void)
370 ToolkitTestApplication application;
372 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
373 DALI_TEST_CHECK(model);
375 Scene3D::Model copy(model);
376 DALI_TEST_CHECK(model == copy);
378 Scene3D::Model assign;
379 DALI_TEST_CHECK(!assign);
382 DALI_TEST_CHECK(assign == model);
387 int UtcDaliModelMoveConstructor(void)
389 ToolkitTestApplication application;
391 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
392 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
393 model.SetProperty(Actor::Property::SENSITIVE, false);
394 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
396 Scene3D::Model moved = std::move(model);
397 DALI_TEST_CHECK(moved);
398 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
399 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
400 DALI_TEST_CHECK(!model);
405 int UtcDaliModelMoveAssignment(void)
407 ToolkitTestApplication application;
409 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
410 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
411 model.SetProperty(Actor::Property::SENSITIVE, false);
412 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
414 Scene3D::Model moved;
415 moved = std::move(model);
416 DALI_TEST_CHECK(moved);
417 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
418 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
419 DALI_TEST_CHECK(!model);
424 int UtcDaliModelOnScene01(void)
426 ToolkitTestApplication application;
428 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
429 application.GetScene().Add(model);
431 gResourceReadyCalled = false;
432 model.ResourceReadySignal().Connect(&OnResourceReady);
433 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
435 application.SendNotification();
436 application.Render();
438 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
439 application.SendNotification();
440 application.Render();
442 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
444 uint32_t modelCount = model.GetModelRoot().GetChildCount();
445 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
449 int UtcDaliModelOnScene02(void)
451 ToolkitTestApplication application;
453 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
454 application.GetScene().Add(model);
456 gResourceReadyCalled = false;
457 model.ResourceReadySignal().Connect(&OnResourceReady);
458 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
460 application.SendNotification();
461 application.Render();
463 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
464 application.SendNotification();
465 application.Render();
467 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
469 uint32_t modelCount = model.GetModelRoot().GetChildCount();
470 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
472 Scene3D::ModelNode rootNode = model.GetModelRoot();
473 Vector3 rootSize = rootNode.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
474 DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
479 int UtcDaliModelOnSizeSet(void)
481 ToolkitTestApplication application;
483 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
485 application.GetScene().Add(model);
487 application.SendNotification();
488 application.Render();
490 Vector2 size(200.0f, 300.0f);
491 model.SetProperty(Actor::Property::SIZE, size);
493 application.SendNotification();
494 application.Render();
496 DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
501 int UtcDaliModelGetNaturalSize(void)
503 ToolkitTestApplication application;
505 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
507 Vector3 naturalSize = model.GetNaturalSize();
508 DALI_TEST_EQUALS(Vector3::ZERO, naturalSize, TEST_LOCATION);
510 application.GetScene().Add(model);
512 gResourceReadyCalled = false;
513 model.ResourceReadySignal().Connect(&OnResourceReady);
514 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
516 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
517 application.SendNotification();
519 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
521 naturalSize = model.GetNaturalSize();
522 DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
524 Scene3D::ModelNode rootNode = model.GetModelRoot();
525 DALI_TEST_CHECK(rootNode);
530 int UtcDaliModelSetImageBasedLightSource01(void)
532 ToolkitTestApplication application;
534 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
535 application.GetScene().Add(model);
537 gResourceReadyCalled = false;
538 model.ResourceReadySignal().Connect(&OnResourceReady);
539 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
541 application.SendNotification();
542 application.Render();
544 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
545 application.SendNotification();
546 application.Render();
548 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
550 Actor meshActor = model.FindChildByName("AnimatedCube");
551 DALI_TEST_CHECK(meshActor);
553 Renderer renderer = meshActor.GetRendererAt(0u);
554 DALI_TEST_CHECK(renderer);
556 TextureSet textureSet = renderer.GetTextures();
557 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 10u, TEST_LOCATION);
559 Texture diffuseTexture = textureSet.GetTexture(8u);
560 Texture specularTexture = textureSet.GetTexture(9u);
562 gResourceReadyCalled = false;
563 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
564 model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
566 application.SendNotification();
567 application.Render();
569 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
570 application.SendNotification();
571 application.Render();
573 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
575 TextureSet newTextureSet = renderer.GetTextures();
576 Texture newDiffuseTexture = newTextureSet.GetTexture(8u);
577 Texture newSpecularTexture = newTextureSet.GetTexture(9u);
579 DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
580 DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
587 int UtcDaliModelSetImageBasedLightSource02(void)
589 ToolkitTestApplication application;
591 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
592 application.GetScene().Add(model);
594 gResourceReadyCalled = false;
595 model.ResourceReadySignal().Connect(&OnResourceReady);
596 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
598 application.SendNotification();
599 application.Render();
601 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
602 application.SendNotification();
603 application.Render();
605 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
607 Actor meshActor = model.FindChildByName("AnimatedCube");
608 DALI_TEST_CHECK(meshActor);
610 Renderer renderer = meshActor.GetRendererAt(0u);
611 DALI_TEST_CHECK(renderer);
613 TextureSet textureSet = renderer.GetTextures();
614 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 10u, TEST_LOCATION);
616 Texture diffuseTexture = textureSet.GetTexture(8u);
617 Texture specularTexture = textureSet.GetTexture(9u);
619 // if url is empty, loading is not requested.
620 model.SetImageBasedLightSource("", "");
622 Texture newDiffuseTexture = textureSet.GetTexture(8u);
623 Texture newSpecularTexture = textureSet.GetTexture(9u);
625 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
626 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
631 int UtcDaliModelSetImageBasedLightSource03(void)
633 ToolkitTestApplication application;
635 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
636 application.GetScene().Add(model);
638 gResourceReadyCalled = false;
639 model.ResourceReadySignal().Connect(&OnResourceReady);
640 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
642 application.SendNotification();
643 application.Render();
645 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
646 application.SendNotification();
647 application.Render();
649 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
651 Actor meshActor = model.FindChildByName("AnimatedCube");
652 DALI_TEST_CHECK(meshActor);
654 Renderer renderer = meshActor.GetRendererAt(0u);
655 DALI_TEST_CHECK(renderer);
657 TextureSet textureSet = renderer.GetTextures();
658 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 10u, TEST_LOCATION);
660 Texture diffuseTexture = textureSet.GetTexture(8u);
661 Texture specularTexture = textureSet.GetTexture(9u);
663 gResourceReadyCalled = false;
664 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
665 model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
667 application.SendNotification();
668 application.Render();
670 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
671 application.SendNotification();
672 application.Render();
674 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
676 Texture newDiffuseTexture = textureSet.GetTexture(8u);
677 Texture newSpecularTexture = textureSet.GetTexture(9u);
679 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
680 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
685 int UtcDaliModelSetImageBasedLightSource04(void)
687 ToolkitTestApplication application;
689 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
690 model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
691 application.GetScene().Add(model);
693 gResourceReadyCalled = false;
694 model.ResourceReadySignal().Connect(&OnResourceReady);
695 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
697 application.SendNotification();
698 application.Render();
700 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
701 application.SendNotification();
702 application.Render();
704 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
708 int UtcDaliModelImageBasedFactor(void)
710 ToolkitTestApplication application;
712 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
714 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
716 model.SetImageBasedLightScaleFactor(0.5f);
717 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
721 int UtcDaliModelChildrenSensitive01(void)
723 ToolkitTestApplication application;
725 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
726 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
727 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
728 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
729 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
731 // Get default vaule.
732 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
734 // Allow children actor's event before on scene.
735 view.SetChildrenSensitive(true);
736 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
737 application.GetScene().Add(view);
739 gResourceReadyCalled = false;
740 view.ResourceReadySignal().Connect(&OnResourceReady);
741 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
743 application.SendNotification();
744 application.Render();
746 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
747 application.SendNotification();
748 application.Render();
750 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
752 Actor meshActor = view.FindChildByName("AnimatedCube");
753 DALI_TEST_CHECK(meshActor);
755 // connect hit-test signal
756 gTouchCallBackCalled = false;
757 meshActor.TouchedSignal().Connect(TestTouchCallback);
759 Vector2 sceneSize = application.GetScene().GetSize();
761 // Try to touch center of scene.
762 Dali::Integration::Point point;
763 point.SetState(PointState::DOWN);
764 point.SetScreenPosition(sceneSize * 0.5f);
765 Dali::Integration::TouchEvent event;
766 event.AddPoint(point);
768 // flush the queue and render once
769 application.SendNotification();
770 application.Render();
773 DALI_TEST_CHECK(!gTouchCallBackCalled);
774 application.ProcessEvent(event);
776 DALI_TEST_CHECK(gTouchCallBackCalled);
779 gTouchCallBackCalled = false;
781 // Block children actor's event
782 view.SetChildrenSensitive(false);
783 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
785 // flush the queue and render once
786 application.SendNotification();
787 application.Render();
790 DALI_TEST_CHECK(!gTouchCallBackCalled);
791 application.ProcessEvent(event);
793 DALI_TEST_CHECK(!gTouchCallBackCalled);
796 gTouchCallBackCalled = false;
799 view.SetChildrenSensitive(true);
800 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
802 // flush the queue and render once
803 application.SendNotification();
804 application.Render();
807 DALI_TEST_CHECK(!gTouchCallBackCalled);
808 application.ProcessEvent(event);
810 DALI_TEST_CHECK(gTouchCallBackCalled);
813 gTouchCallBackCalled = false;
818 int UtcDaliModelChildrenSensitive02(void)
820 ToolkitTestApplication application;
822 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
823 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
824 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
825 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
826 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
829 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
831 // Block children actor's event before on scene.
832 view.SetChildrenSensitive(false);
833 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
834 application.GetScene().Add(view);
836 gResourceReadyCalled = false;
837 view.ResourceReadySignal().Connect(&OnResourceReady);
838 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
840 application.SendNotification();
841 application.Render();
843 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
844 application.SendNotification();
845 application.Render();
847 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
849 Actor meshActor = view.FindChildByName("AnimatedCube");
850 DALI_TEST_CHECK(meshActor);
852 // connect hit-test signal
853 gTouchCallBackCalled = false;
854 meshActor.TouchedSignal().Connect(TestTouchCallback);
856 Vector2 sceneSize = application.GetScene().GetSize();
858 // Try to touch center of scene.
859 Dali::Integration::Point point;
860 point.SetState(PointState::DOWN);
861 point.SetScreenPosition(sceneSize * 0.5f);
862 Dali::Integration::TouchEvent event;
863 event.AddPoint(point);
865 // flush the queue and render once
866 application.SendNotification();
867 application.Render();
870 DALI_TEST_CHECK(!gTouchCallBackCalled);
871 application.ProcessEvent(event);
873 DALI_TEST_CHECK(!gTouchCallBackCalled);
876 gTouchCallBackCalled = false;
879 view.SetChildrenSensitive(true);
880 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
882 // flush the queue and render once
883 application.SendNotification();
884 application.Render();
887 DALI_TEST_CHECK(!gTouchCallBackCalled);
888 application.ProcessEvent(event);
890 DALI_TEST_CHECK(gTouchCallBackCalled);
893 gTouchCallBackCalled = false;
898 int UtcDaliModelChildrenFocusable01(void)
900 ToolkitTestApplication application;
902 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
903 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
904 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
905 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
906 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
908 // Get vaule. Default is false.
909 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
911 // Allow children actor's focus before on scene.
912 view.SetChildrenFocusable(true);
913 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
914 application.GetScene().Add(view);
916 gResourceReadyCalled = false;
917 view.ResourceReadySignal().Connect(&OnResourceReady);
918 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
920 application.SendNotification();
921 application.Render();
923 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
924 application.SendNotification();
925 application.Render();
927 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
929 Actor meshActor = view.FindChildByName("AnimatedCube");
930 DALI_TEST_CHECK(meshActor);
932 // Enable the default algorithm
933 KeyboardFocusManager manager = KeyboardFocusManager::Get();
934 DALI_TEST_CHECK(manager);
935 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
937 // connect focusable signal
938 gFocusChangedCallBackCalled = false;
939 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
940 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
942 // Initialize with some left-positioned actor
943 Control focusStartActor = Control::New();
944 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
945 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
946 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
947 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
948 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
949 application.GetScene().Add(focusStartActor);
952 manager.ClearFocus();
953 manager.SetCurrentFocusActor(focusStartActor);
954 gFocusChangedCallBackCalled = false;
956 // flush the queue and render once
957 application.SendNotification();
958 application.Render();
960 // Focusable view find success
961 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
962 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
965 manager.ClearFocus();
966 manager.SetCurrentFocusActor(focusStartActor);
967 gFocusChangedCallBackCalled = false;
969 // Block children actor's focus
970 view.SetChildrenFocusable(false);
971 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
973 // flush the queue and render once
974 application.SendNotification();
975 application.Render();
977 // Focusable view find failed
978 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
979 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
982 manager.ClearFocus();
983 manager.SetCurrentFocusActor(focusStartActor);
984 gFocusChangedCallBackCalled = false;
987 view.SetChildrenFocusable(true);
988 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
990 // flush the queue and render once
991 application.SendNotification();
992 application.Render();
994 // Focusable view find success
995 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
996 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
999 manager.ClearFocus();
1000 manager.SetCurrentFocusActor(focusStartActor);
1001 gFocusChangedCallBackCalled = false;
1006 int UtcDaliModelModelChildrenFocusable02(void)
1008 ToolkitTestApplication application;
1010 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1011 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
1012 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
1013 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1014 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1016 // Get vaule. Default is true.
1017 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
1019 // Block children actor's focus before on scene.
1020 view.SetChildrenFocusable(false);
1021 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
1022 application.GetScene().Add(view);
1024 gResourceReadyCalled = false;
1025 view.ResourceReadySignal().Connect(&OnResourceReady);
1026 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1028 application.SendNotification();
1029 application.Render();
1031 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1032 application.SendNotification();
1033 application.Render();
1035 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1037 Actor meshActor = view.FindChildByName("AnimatedCube");
1038 DALI_TEST_CHECK(meshActor);
1040 // Enable the default algorithm
1041 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1042 DALI_TEST_CHECK(manager);
1043 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
1045 // connect focusable signal
1046 gFocusChangedCallBackCalled = false;
1047 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
1048 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
1050 // Initialize with some left-positioned actor
1051 Control focusStartActor = Control::New();
1052 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
1053 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
1054 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1055 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1056 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
1057 application.GetScene().Add(focusStartActor);
1060 manager.ClearFocus();
1061 manager.SetCurrentFocusActor(focusStartActor);
1062 gFocusChangedCallBackCalled = false;
1064 // flush the queue and render once
1065 application.SendNotification();
1066 application.Render();
1068 // Focusable view find failed
1069 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
1070 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
1073 manager.ClearFocus();
1074 manager.SetCurrentFocusActor(focusStartActor);
1075 gFocusChangedCallBackCalled = false;
1078 view.SetChildrenFocusable(true);
1079 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
1081 // flush the queue and render once
1082 application.SendNotification();
1083 application.Render();
1085 // Focusable view find success
1086 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
1087 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
1090 manager.ClearFocus();
1091 manager.SetCurrentFocusActor(focusStartActor);
1092 gFocusChangedCallBackCalled = false;
1097 int UtcDaliModelAnimation01(void)
1099 ToolkitTestApplication application;
1101 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1102 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1103 application.GetScene().Add(model);
1105 gResourceReadyCalled = false;
1106 model.ResourceReadySignal().Connect(&OnResourceReady);
1107 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1109 application.SendNotification();
1110 application.Render();
1112 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1113 application.SendNotification();
1114 application.Render();
1116 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1118 uint32_t animationCount = model.GetAnimationCount();
1119 DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
1121 Animation animationByIndex = model.GetAnimation(0u);
1122 DALI_TEST_CHECK(animationByIndex);
1124 Animation animationByName = model.GetAnimation("animation_AnimatedCube");
1125 DALI_TEST_CHECK(animationByName);
1126 DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
1131 int UtcDaliModelAnimation02(void)
1133 ToolkitTestApplication application;
1135 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
1136 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1137 application.GetScene().Add(model);
1139 gResourceReadyCalled = false;
1140 model.ResourceReadySignal().Connect(&OnResourceReady);
1141 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1143 application.SendNotification();
1144 application.Render();
1146 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1147 application.SendNotification();
1148 application.Render();
1150 uint32_t animationCount = model.GetAnimationCount();
1151 DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
1153 Animation animation1 = model.GetAnimation("Step Scale");
1154 DALI_TEST_CHECK(animation1);
1155 DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
1157 Animation animation2 = model.GetAnimation("CubicSpline Scale");
1158 DALI_TEST_CHECK(animation2);
1159 DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
1161 DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
1166 int UtcDaliModelAnimation03(void)
1168 ToolkitTestApplication application;
1170 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
1171 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1172 application.GetScene().Add(model);
1174 gResourceReadyCalled = false;
1175 model.ResourceReadySignal().Connect(&OnResourceReady);
1176 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1178 application.SendNotification();
1179 application.Render();
1181 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1182 application.SendNotification();
1183 application.Render();
1185 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1187 uint32_t animationCount = model.GetAnimationCount();
1188 DALI_TEST_EQUALS(18, animationCount, TEST_LOCATION);
1190 Animation animationByIndex = model.GetAnimation(0u);
1191 DALI_TEST_CHECK(animationByIndex);
1193 Animation animationByName = model.GetAnimation("idleClip");
1194 DALI_TEST_CHECK(animationByName);
1195 DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
1200 int UtcDaliModelCameraGenerate01(void)
1202 ToolkitTestApplication application;
1204 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
1205 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1206 application.GetScene().Add(model);
1208 gResourceReadyCalled = false;
1209 model.ResourceReadySignal().Connect(&OnResourceReady);
1210 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1212 application.SendNotification();
1213 application.Render();
1215 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1216 application.SendNotification();
1217 application.Render();
1219 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1221 uint32_t cameraCount = model.GetCameraCount();
1222 DALI_TEST_EQUALS(1, cameraCount, TEST_LOCATION);
1224 CameraActor generatedCamera = model.GenerateCamera(0u);
1225 DALI_TEST_CHECK(generatedCamera);
1227 generatedCamera = model.GenerateCamera(1u); // Fail to generate camera
1228 DALI_TEST_CHECK(!generatedCamera);
1233 int UtcDaliModelCameraGenerate02(void)
1235 ToolkitTestApplication application;
1237 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1238 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1239 application.GetScene().Add(model);
1241 gResourceReadyCalled = false;
1242 model.ResourceReadySignal().Connect(&OnResourceReady);
1243 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1245 application.SendNotification();
1246 application.Render();
1248 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1249 application.SendNotification();
1250 application.Render();
1252 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1254 uint32_t cameraCount = model.GetCameraCount();
1255 DALI_TEST_EQUALS(6, cameraCount, TEST_LOCATION);
1257 CameraActor generatedCamera0 = model.GenerateCamera(0u);
1258 DALI_TEST_CHECK(generatedCamera0);
1259 CameraActor generatedCamera1 = model.GenerateCamera(1u);
1260 DALI_TEST_CHECK(generatedCamera1);
1261 CameraActor generatedCamera2 = model.GenerateCamera(2u);
1262 DALI_TEST_CHECK(generatedCamera2);
1263 CameraActor generatedCamera3 = model.GenerateCamera(3u); // Infinity far camera
1264 DALI_TEST_CHECK(generatedCamera3);
1265 CameraActor generatedCamera4 = model.GenerateCamera(4u); // Broken camera 1
1266 DALI_TEST_CHECK(!generatedCamera4);
1267 CameraActor generatedCamera5 = model.GenerateCamera(5u); // Broken camera 2
1268 DALI_TEST_CHECK(!generatedCamera5);
1269 CameraActor generatedCamera6 = model.GenerateCamera(6u); // Out of bound
1270 DALI_TEST_CHECK(!generatedCamera6);
1272 CameraActor appliedCamera;
1273 DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), false, TEST_LOCATION); // Cannot apply into empty camera.
1275 auto CompareCameraProperties = [](CameraActor lhs, CameraActor rhs, const char* location) {
1276 DALI_TEST_EQUALS(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), rhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), TEST_LOCATION);
1277 DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), TEST_LOCATION);
1279 if(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE) == static_cast<int>(Dali::Camera::ProjectionMode::PERSPECTIVE_PROJECTION))
1281 DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), rhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), TEST_LOCATION);
1282 // TODO : Open this test when infinity far projection implement.
1283 // DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
1287 DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), rhs.GetProperty<float>(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), TEST_LOCATION);
1288 DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
1292 appliedCamera = CameraActor::New();
1293 DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), true, TEST_LOCATION);
1294 CompareCameraProperties(generatedCamera0, appliedCamera, TEST_LOCATION);
1295 DALI_TEST_EQUALS(model.ApplyCamera(1u, appliedCamera), true, TEST_LOCATION);
1296 CompareCameraProperties(generatedCamera1, appliedCamera, TEST_LOCATION);
1297 DALI_TEST_EQUALS(model.ApplyCamera(2u, appliedCamera), true, TEST_LOCATION);
1298 CompareCameraProperties(generatedCamera2, appliedCamera, TEST_LOCATION);
1299 DALI_TEST_EQUALS(model.ApplyCamera(3u, appliedCamera), true, TEST_LOCATION);
1300 CompareCameraProperties(generatedCamera3, appliedCamera, TEST_LOCATION);
1301 DALI_TEST_EQUALS(model.ApplyCamera(4u, appliedCamera), false, TEST_LOCATION); // Broken camera 1
1302 DALI_TEST_EQUALS(model.ApplyCamera(5u, appliedCamera), false, TEST_LOCATION); // Broken camera 2
1303 DALI_TEST_EQUALS(model.ApplyCamera(6u, appliedCamera), false, TEST_LOCATION); // Cannot apply over the index.
1308 int UtcDaliModelMultiplePrimitives(void)
1310 ToolkitTestApplication application;
1312 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME);
1313 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1314 application.GetScene().Add(model);
1316 gResourceReadyCalled = false;
1317 model.ResourceReadySignal().Connect(&OnResourceReady);
1318 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1324 application.SendNotification();
1325 application.Render();
1327 Actor actor = model.FindChildByName("rootNode");
1329 DALI_TEST_EQUALS(0, actor.GetChildCount(), TEST_LOCATION);
1330 DALI_TEST_EQUALS(2, actor.GetRendererCount(), TEST_LOCATION);
1335 int UtcDaliModelColorMode(void)
1337 ToolkitTestApplication application;
1339 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1340 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1341 model.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
1342 application.GetScene().Add(model);
1344 gResourceReadyCalled = false;
1345 model.ResourceReadySignal().Connect(&OnResourceReady);
1346 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1348 application.SendNotification();
1349 application.Render();
1351 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1352 application.SendNotification();
1353 application.Render();
1355 Actor actor = model.FindChildByName("AnimatedCube");
1356 Vector4 childColor = actor[Dali::Actor::Property::COLOR];
1357 Vector4 childWorldColor = actor[Dali::Actor::Property::WORLD_COLOR];
1359 DALI_TEST_EQUALS(childColor, Color::WHITE, TEST_LOCATION);
1360 DALI_TEST_EQUALS(childWorldColor, Color::RED, TEST_LOCATION);
1365 int UtcDaliModelResourceReady(void)
1367 ToolkitTestApplication application;
1369 gOnRelayoutCallBackCalled = false;
1370 gResourceReadyCalled = false;
1371 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
1372 model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1373 model.OnRelayoutSignal().Connect(OnRelayoutCallback);
1374 model.ResourceReadySignal().Connect(OnResourceReady);
1375 DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
1378 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
1379 DALI_TEST_CHECK(!gResourceReadyCalled);
1381 application.GetScene().Add(model);
1383 application.SendNotification();
1384 application.Render();
1386 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1387 application.SendNotification();
1388 application.Render();
1390 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
1391 DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
1392 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1397 int UtcDaliModelResourceCacheCheck(void)
1399 ToolkitTestApplication application;
1401 // Load three instances of the same model and add them to the scene
1402 Scene3D::Model model1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1403 Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1404 Scene3D::Model model3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1406 application.GetScene().Add(model1);
1407 application.GetScene().Add(model2);
1408 application.GetScene().Add(model3);
1410 gResourceReadyCalled = false;
1411 model1.ResourceReadySignal().Connect(&OnResourceReady);
1412 model2.ResourceReadySignal().Connect(&OnResourceReady);
1413 model3.ResourceReadySignal().Connect(&OnResourceReady);
1414 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1416 application.SendNotification();
1417 application.Render();
1419 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1420 application.SendNotification();
1421 application.Render();
1423 // Check that the loading has finished for all the three instances
1424 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1426 Actor meshActor1 = model1.FindChildByName("AnimatedCube");
1427 Actor meshActor2 = model2.FindChildByName("AnimatedCube");
1428 Actor meshActor3 = model3.FindChildByName("AnimatedCube");
1429 DALI_TEST_CHECK(meshActor1);
1430 DALI_TEST_CHECK(meshActor2);
1431 DALI_TEST_CHECK(meshActor3);
1433 Renderer renderer1 = meshActor1.GetRendererAt(0u);
1434 Renderer renderer2 = meshActor2.GetRendererAt(0u);
1435 Renderer renderer3 = meshActor3.GetRendererAt(0u);
1436 DALI_TEST_CHECK(renderer1);
1437 DALI_TEST_CHECK(renderer2);
1438 DALI_TEST_CHECK(renderer3);
1440 // Check that all the three instances use the shared textures and geometries from the cache
1441 // but have their own shader objects
1442 DALI_TEST_EQUALS(renderer1.GetTextures(), renderer2.GetTextures(), TEST_LOCATION);
1443 DALI_TEST_EQUALS(renderer1.GetTextures(), renderer3.GetTextures(), TEST_LOCATION);
1444 DALI_TEST_EQUALS(renderer1.GetGeometry(), renderer2.GetGeometry(), TEST_LOCATION);
1445 DALI_TEST_EQUALS(renderer1.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1446 DALI_TEST_NOT_EQUALS(renderer1.GetShader(), renderer2.GetShader(), 0.0f, TEST_LOCATION);
1447 DALI_TEST_NOT_EQUALS(renderer1.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1448 DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1454 // Check that all the other two instances still use the shared textures and geometries from the cache
1455 // but have their own shader objects
1456 DALI_TEST_EQUALS(renderer2.GetTextures(), renderer3.GetTextures(), TEST_LOCATION);
1457 DALI_TEST_EQUALS(renderer2.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1458 DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1460 // Set new IBL textures for model2, and this should apply to model2 instance only
1461 gResourceReadyCalled = false;
1462 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1463 model2.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
1465 application.SendNotification();
1466 application.Render();
1468 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1469 application.SendNotification();
1470 application.Render();
1472 // Check that the new IBL textures are loaded for model2
1473 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1475 // Check that the two instances still use the shared geometries from the cache
1476 // but now have their own shader objects and different texture set
1477 DALI_TEST_NOT_EQUALS(renderer2.GetTextures(), renderer3.GetTextures(), 0.0f, TEST_LOCATION);
1478 DALI_TEST_EQUALS(renderer2.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1479 DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1481 // Check that the two instances now have their own diffuse texture and specular texture,
1482 // but all the other textures are still the same
1483 TextureSet textureSet2 = renderer2.GetTextures();
1484 TextureSet textureSet3 = renderer3.GetTextures();
1485 DALI_TEST_EQUALS(textureSet2.GetTextureCount(), 10u, TEST_LOCATION);
1486 DALI_TEST_EQUALS(textureSet3.GetTextureCount(), 10u, TEST_LOCATION);
1488 for(uint32_t i = 0; i < 7u; i++)
1490 DALI_TEST_EQUALS(textureSet2.GetTexture(i), textureSet3.GetTexture(i), TEST_LOCATION);
1493 DALI_TEST_NOT_EQUALS(textureSet2.GetTexture(8u), textureSet3.GetTexture(7u), 0.0f, TEST_LOCATION);
1494 DALI_TEST_NOT_EQUALS(textureSet2.GetTexture(9u), textureSet3.GetTexture(8u), 0.0f, TEST_LOCATION);
1499 int UtcDaliModelAddRemoveModelNode(void)
1501 ToolkitTestApplication application;
1503 Scene3D::Model model = Scene3D::Model::New();
1504 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1506 Scene3D::ModelNode node1 = Scene3D::ModelNode::New();
1507 Scene3D::ModelNode node2 = Scene3D::ModelNode::New();
1508 Scene3D::ModelNode node3 = Scene3D::ModelNode::New();
1509 Scene3D::ModelNode node4 = Scene3D::ModelNode::New();
1511 model.AddModelNode(node1);
1512 model.AddModelNode(node2);
1513 model.AddModelNode(node3);
1514 model.RemoveModelNode(node1); // Remove node before scene on
1516 application.GetScene().Add(model);
1518 Dali::Scene3D::ModelNode root = model.GetModelRoot();
1519 DALI_TEST_CHECK(root);
1520 DALI_TEST_EQUALS(2, root.GetChildCount(), TEST_LOCATION);
1522 model.RemoveModelNode(node2); // Remove node after scene on
1524 DALI_TEST_EQUALS(1, root.GetChildCount(), TEST_LOCATION);
1526 model.AddModelNode(node4); // Add during scene on
1528 DALI_TEST_EQUALS(2, root.GetChildCount(), TEST_LOCATION);
1530 application.GetScene().Remove(model);
1532 model.RemoveModelNode(node3); // Remove node after scene off
1537 int UtcDaliModelFindChildModelNodeByName(void)
1539 tet_infoline(" UtcDaliModelNodeFindChildModelNodeByName.");
1541 ToolkitTestApplication application;
1543 Scene3D::Model model = Scene3D::Model::New();
1544 application.GetScene().Add(model);
1546 Scene3D::ModelNode modelNode1 = Scene3D::ModelNode::New();
1547 Scene3D::ModelNode modelNode2 = Scene3D::ModelNode::New();
1549 modelNode1.SetProperty(Dali::Actor::Property::NAME, "modelNode1");
1550 modelNode2.SetProperty(Dali::Actor::Property::NAME, "modelNode2");
1551 model.AddModelNode(modelNode1);
1552 model.AddModelNode(modelNode2);
1554 Scene3D::ModelNode child1 = model.FindChildModelNodeByName("modelNode1");
1555 DALI_TEST_CHECK(child1);
1556 DALI_TEST_EQUALS(child1, modelNode1, TEST_LOCATION);
1558 Scene3D::ModelNode child2 = model.FindChildModelNodeByName("modelNode2");
1559 DALI_TEST_CHECK(child2);
1560 DALI_TEST_EQUALS(child2, modelNode2, TEST_LOCATION);
1565 int UtcDaliModelSizeChange(void)
1567 tet_infoline(" UtcDaliModelSizeChange.");
1569 ToolkitTestApplication application;
1571 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1572 model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
1573 application.GetScene().Add(model);
1575 application.SendNotification();
1576 application.Render();
1578 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1579 application.SendNotification();
1580 application.Render();
1582 DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
1583 Vector3 scale = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1585 model.SetProperty(Dali::Actor::Property::SIZE, Vector3(600, 600, 600));
1586 Vector3 scale2 = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1588 DALI_TEST_NOT_EQUALS(scale, scale2, 0.1f, TEST_LOCATION);
1593 int UtcDaliModelSizeChange2(void)
1595 tet_infoline(" UtcDaliModelSizeChange2.");
1597 ToolkitTestApplication application;
1599 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1600 model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
1601 application.GetScene().Add(model);
1603 application.SendNotification();
1604 application.Render();
1606 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1607 application.SendNotification();
1608 application.Render();
1610 DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
1611 Vector3 scale = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1613 Animation animation = Animation::New(0.5f);
1614 animation.AnimateTo(Dali::Property(model, Dali::Actor::Property::SIZE), Vector3(600, 600, 600));
1617 application.SendNotification();
1618 application.Render(250);
1620 application.SendNotification();
1622 Vector3 scale2 = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1623 DALI_TEST_NOT_EQUALS(scale, scale2, 0.1f, TEST_LOCATION);
1628 int UtcDaliModelRetrieveBlendShapeNames(void)
1630 tet_infoline(" UtcDaliModelRetrieveBlendShapeByName.");
1632 ToolkitTestApplication application;
1634 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_EXTRAS_FILE_NAME);
1635 model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
1636 application.GetScene().Add(model);
1638 application.SendNotification();
1639 application.Render();
1641 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1642 application.SendNotification();
1643 application.Render();
1645 DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
1647 // Get target ModelNode that has extras
1648 Scene3D::ModelNode expectNode = model.FindChildModelNodeByName("AnimatedMorphCube");
1650 // Pair of expected blend shape index from expectNode.
1651 std::map<std::string, Scene3D::Loader::BlendShapes::Index> expectBlendShapeNames = {
1656 std::vector<std::string> blendShapeNameList;
1657 model.RetrieveBlendShapeNames(blendShapeNameList);
1659 DALI_TEST_EQUALS(blendShapeNameList.size(), expectBlendShapeNames.size(), TEST_LOCATION);
1660 for(auto i = 0u; i < blendShapeNameList.size(); ++i)
1662 const auto& name = blendShapeNameList[i];
1663 tet_printf("Check retrieved blendshape name : %s\n", name.c_str());
1665 const auto& iter = expectBlendShapeNames.find(name);
1666 DALI_TEST_CHECK(iter != expectBlendShapeNames.end());
1668 std::vector<Scene3D::ModelNode> nodeList;
1669 model.RetrieveModelNodesByBlendShapeName(name, nodeList);
1670 DALI_TEST_EQUALS(nodeList.size(), 1u, TEST_LOCATION);
1671 DALI_TEST_EQUALS(nodeList[0], expectNode, TEST_LOCATION);
1672 DALI_TEST_EQUALS(nodeList[0].GetBlendShapeIndexByName(name), iter->second, TEST_LOCATION);
1678 int UtcDaliModelGenerateMotionDataAnimation01(void)
1680 ToolkitTestApplication application;
1682 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MORPH_FILE_NAME);
1683 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1684 application.GetScene().Add(model);
1686 gResourceReadyCalled = false;
1687 model.ResourceReadySignal().Connect(&OnResourceReady);
1688 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1690 application.SendNotification();
1691 application.Render();
1693 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1694 application.SendNotification();
1695 application.Render();
1697 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1699 KeyFrames floatKeyFrames = KeyFrames::New();
1700 floatKeyFrames.Add(0.0f, 1.0f);
1701 floatKeyFrames.Add(1.0f, 0.5f);
1703 float duration = 3.0f;
1704 Scene3D::MotionData motionData = Scene3D::MotionData::New(duration);
1705 motionData.Add(Scene3D::MotionTransformIndex::New("AnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Y), Scene3D::MotionValue::New(2.0f));
1706 motionData.Add(Scene3D::MotionTransformIndex::New("AnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Z), Scene3D::MotionValue::New(floatKeyFrames));
1707 motionData.Add(Scene3D::BlendShapeIndex::New("AnimatedMorphCube", 0), Scene3D::MotionValue::New(0.5f));
1708 motionData.Add(Scene3D::BlendShapeIndex::New("AnimatedMorphCube", 1), Scene3D::MotionValue::New(floatKeyFrames));
1710 Animation generatedAnimation = model.GenerateMotionDataAnimation(motionData);
1711 DALI_TEST_CHECK(generatedAnimation);
1712 DALI_TEST_EQUALS(generatedAnimation.GetDuration(), duration, TEST_LOCATION);
1714 Scene3D::MotionData invalidMotionData = Scene3D::MotionData::New(duration);
1715 invalidMotionData.Add(Scene3D::MotionTransformIndex::New("NotAnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Y), Scene3D::MotionValue::New(2.0f));
1716 invalidMotionData.Add(Scene3D::MotionTransformIndex::New("NotAnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Z), Scene3D::MotionValue::New(floatKeyFrames));
1717 invalidMotionData.Add(Scene3D::BlendShapeIndex::New("NotAnimatedMorphCube", 0), Scene3D::MotionValue::New(0.5f));
1718 invalidMotionData.Add(Scene3D::BlendShapeIndex::New("NotAnimatedMorphCube", 1), Scene3D::MotionValue::New(floatKeyFrames));
1720 generatedAnimation = model.GenerateMotionDataAnimation(invalidMotionData);
1721 DALI_TEST_CHECK(!generatedAnimation); // Animation should be empty if motion data have invalid index.
1726 int UtcDaliModelSetMotionData(void)
1728 ToolkitTestApplication application;
1730 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MORPH_FILE_NAME);
1731 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1732 application.GetScene().Add(model);
1734 gResourceReadyCalled = false;
1735 model.ResourceReadySignal().Connect(&OnResourceReady);
1736 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1738 application.SendNotification();
1739 application.Render();
1741 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1742 application.SendNotification();
1743 application.Render();
1745 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1747 KeyFrames floatKeyFrames = KeyFrames::New();
1748 floatKeyFrames.Add(0.0f, 1.0f);
1749 floatKeyFrames.Add(1.0f, 0.5f);
1751 float duration = 3.0f;
1752 Scene3D::MotionData motionData = Scene3D::MotionData::New(duration);
1753 motionData.Add(Scene3D::MotionTransformIndex::New("AnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Y), Scene3D::MotionValue::New(2.0f));
1754 motionData.Add(Scene3D::MotionTransformIndex::New("AnimatedMorphCube", Scene3D::MotionTransformIndex::TransformType::SCALE_Z), Scene3D::MotionValue::New(floatKeyFrames));
1755 motionData.Add(Scene3D::BlendShapeIndex::New("AnimatedMorphCube", 0), Scene3D::MotionValue::New(0.5f));
1756 motionData.Add(Scene3D::BlendShapeIndex::New("AnimatedMorphCube", 1), Scene3D::MotionValue::New(floatKeyFrames));
1758 auto cubeModelNode = model.FindChildModelNodeByName("AnimatedMorphCube");
1760 float expectScaleX = cubeModelNode.GetProperty<float>(Actor::Property::SCALE_X);
1762 model.SetMotionData(motionData);
1764 DALI_TEST_EQUALS(cubeModelNode.GetProperty<float>(Actor::Property::SCALE_X), expectScaleX, TEST_LOCATION);
1765 DALI_TEST_EQUALS(cubeModelNode.GetProperty<float>(Actor::Property::SCALE_Y), 2.0f, TEST_LOCATION);
1766 DALI_TEST_EQUALS(cubeModelNode.GetProperty<float>(Actor::Property::SCALE_Z), 0.5f, TEST_LOCATION); ///< Last value of keyframes
1771 int UtcDaliModelBlendShapeMotionDataByName(void)
1773 ToolkitTestApplication application;
1775 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_EXTRAS_FILE_NAME);
1776 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1777 application.GetScene().Add(model);
1779 gResourceReadyCalled = false;
1780 model.ResourceReadySignal().Connect(&OnResourceReady);
1781 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1783 application.SendNotification();
1784 application.Render();
1786 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1787 application.SendNotification();
1788 application.Render();
1790 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1792 KeyFrames floatKeyFrames = KeyFrames::New();
1793 floatKeyFrames.Add(0.0f, 0.5f);
1794 floatKeyFrames.Add(1.0f, 1.0f);
1796 float duration = 3.0f;
1797 Scene3D::MotionData motionData = Scene3D::MotionData::New(duration);
1798 motionData.Add(Scene3D::BlendShapeIndex::New("Target_0"), Scene3D::MotionValue::New(0.5f));
1799 motionData.Add(Scene3D::BlendShapeIndex::New("Target_1"), Scene3D::MotionValue::New(floatKeyFrames));
1801 Animation generatedAnimation = model.GenerateMotionDataAnimation(motionData);
1802 DALI_TEST_CHECK(generatedAnimation);
1803 DALI_TEST_EQUALS(generatedAnimation.GetDuration(), duration, TEST_LOCATION);
1805 model.SetMotionData(motionData);
1807 // Get target ModelNode that has extras
1808 Scene3D::ModelNode expectNode = model.FindChildModelNodeByName("AnimatedMorphCube");
1809 auto propertyIndex = expectNode.GetPropertyIndex(motionData.GetIndex(0u).GetPropertyName(expectNode));
1811 DALI_TEST_CHECK(propertyIndex != Property::INVALID_INDEX);
1812 DALI_TEST_EQUALS(expectNode.GetProperty<float>(propertyIndex), 0.5f, TEST_LOCATION);
1814 propertyIndex = expectNode.GetPropertyIndex(motionData.GetIndex(1u).GetPropertyName(expectNode));
1815 DALI_TEST_CHECK(propertyIndex != Property::INVALID_INDEX);
1816 DALI_TEST_EQUALS(expectNode.GetProperty<float>(propertyIndex), 1.0f, TEST_LOCATION);