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>
23 #include <dali-toolkit/devel-api/focus-manager/keyboard-focus-manager-devel.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <toolkit-event-thread-callback.h>
27 #include <dali-scene3d/public-api/controls/model/model.h>
28 #include <dali-scene3d/public-api/model-components/model-node.h>
30 #include <dali/devel-api/actors/camera-actor-devel.h>
33 using namespace Dali::Toolkit;
35 void model_startup(void)
37 test_return_value = TET_UNDEF;
40 void model_cleanup(void)
42 test_return_value = TET_PASS;
47 const bool DEFAULT_MODEL_CHILDREN_SENSITIVE = false;
48 const bool DEFAULT_MODEL_CHILDREN_FOCUSABLE = false;
50 * For the AnimatedCube.gltf and its Assets
51 * Donated by Norbert Nopper for glTF testing.
52 * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
54 const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
55 const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf";
56 const char* TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME = TEST_RESOURCE_DIR "/simpleMultiplePrimitiveTest.gltf";
57 const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli";
58 const char* TEST_DLI_EXERCISE_FILE_NAME = TEST_RESOURCE_DIR "/exercise.dli";
61 * For the diffuse and specular cube map texture.
62 * These textures are based off version of Wave engine sample
63 * Take from https://github.com/WaveEngine/Samples
65 * Copyright (c) 2023 Wave Coorporation
67 * Permission is hereby granted, free of charge, to any person obtaining a copy
68 * of this software and associated documentation files (the "Software"), to
69 * deal in the Software without restriction, including without limitation the
70 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
71 * sell copies of the Software, and to permit persons to whom the Software is
72 * furnished to do so, subject to the following conditions:
74 * The above copyright notice and this permission notice shall be included in
75 * all copies or substantial portions of the Software.
77 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
78 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
79 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
80 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
81 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
82 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
85 const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
86 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
88 bool gTouchCallBackCalled = false;
89 bool TestTouchCallback(Actor, const TouchEvent&)
91 gTouchCallBackCalled = true;
95 bool gFocusChangedCallBackCalled = false;
96 void TestFocusChangedCallback(Actor, Actor)
98 gFocusChangedCallBackCalled = true;
102 static bool gOnRelayoutCallBackCalled = false;
103 void OnRelayoutCallback(Actor actor)
105 gOnRelayoutCallBackCalled = true;
108 static bool gResourceReadyCalled = false;
109 void OnResourceReady(Control control)
111 gResourceReadyCalled = true;
116 // Negative test case for a method
117 int UtcDaliModelUninitialized(void)
119 ToolkitTestApplication application;
120 tet_infoline(" UtcDaliModelUninitialized");
122 Scene3D::Model model;
126 // New() must be called to create a Model or it wont be valid.
127 Actor a = Actor::New();
129 DALI_TEST_CHECK(false);
131 catch(Dali::DaliException& e)
133 // Tests that a negative test of an assertion succeeds
134 DALI_TEST_PRINT_ASSERT(e);
135 DALI_TEST_CHECK(!model);
140 // Positive test case for a method
141 int UtcDaliModelNew(void)
143 ToolkitTestApplication application;
144 tet_infoline(" UtcDaliModelNew");
146 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
147 DALI_TEST_CHECK(model);
151 // Positive test case for a method
152 int UtcDaliModelNewP2(void)
154 ToolkitTestApplication application;
155 tet_infoline(" UtcDaliModelNew without url");
157 Scene3D::Model model = Scene3D::Model::New();
158 DALI_TEST_CHECK(model);
160 application.GetScene().Add(model);
162 DALI_TEST_CHECK(model.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
164 application.GetScene().Remove(model);
166 DALI_TEST_CHECK(!model.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
171 // Positive test case for a method
172 int UtcDaliModelDownCast(void)
174 ToolkitTestApplication application;
175 tet_infoline(" UtcDaliModelDownCast");
177 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
178 BaseHandle handle(model);
180 Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
181 DALI_TEST_CHECK(model);
182 DALI_TEST_CHECK(model2);
183 DALI_TEST_CHECK(model2 == model);
187 int UtcDaliModelTypeRegistry(void)
189 ToolkitTestApplication application;
191 TypeRegistry typeRegistry = TypeRegistry::Get();
192 DALI_TEST_CHECK(typeRegistry);
194 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
195 DALI_TEST_CHECK(typeInfo);
197 BaseHandle handle = typeInfo.CreateInstance();
198 DALI_TEST_CHECK(handle);
200 Scene3D::Model model = Scene3D::Model::DownCast(handle);
201 DALI_TEST_CHECK(model);
206 // Positive test case for a method
207 int UtcDaliModelAddRemove(void)
209 ToolkitTestApplication application;
210 tet_infoline(" UtcDaliModelAddRemove");
212 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
213 DALI_TEST_CHECK(model);
215 Actor actor = Actor::New();
216 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
218 model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
219 model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
221 application.GetScene().Add(model);
223 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
227 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
231 int UtcDaliModelCopyAndAssignment(void)
233 ToolkitTestApplication application;
235 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
236 DALI_TEST_CHECK(model);
238 Scene3D::Model copy(model);
239 DALI_TEST_CHECK(model == copy);
241 Scene3D::Model assign;
242 DALI_TEST_CHECK(!assign);
245 DALI_TEST_CHECK(assign == model);
250 int UtcDaliModelMoveConstructor(void)
252 ToolkitTestApplication application;
254 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
255 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
256 model.SetProperty(Actor::Property::SENSITIVE, false);
257 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
259 Scene3D::Model moved = std::move(model);
260 DALI_TEST_CHECK(moved);
261 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
262 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
263 DALI_TEST_CHECK(!model);
268 int UtcDaliModelMoveAssignment(void)
270 ToolkitTestApplication application;
272 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
273 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
274 model.SetProperty(Actor::Property::SENSITIVE, false);
275 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
277 Scene3D::Model moved;
278 moved = std::move(model);
279 DALI_TEST_CHECK(moved);
280 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
281 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
282 DALI_TEST_CHECK(!model);
287 int UtcDaliModelOnScene01(void)
289 ToolkitTestApplication application;
291 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
292 application.GetScene().Add(model);
294 gResourceReadyCalled = false;
295 model.ResourceReadySignal().Connect(&OnResourceReady);
296 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
298 application.SendNotification();
299 application.Render();
301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
302 application.SendNotification();
303 application.Render();
305 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
307 uint32_t modelCount = model.GetModelRoot().GetChildCount();
308 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
312 int UtcDaliModelOnScene02(void)
314 ToolkitTestApplication application;
316 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
317 application.GetScene().Add(model);
319 gResourceReadyCalled = false;
320 model.ResourceReadySignal().Connect(&OnResourceReady);
321 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
323 application.SendNotification();
324 application.Render();
326 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
327 application.SendNotification();
328 application.Render();
330 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
332 uint32_t modelCount = model.GetModelRoot().GetChildCount();
333 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
335 Scene3D::ModelNode rootNode = model.GetModelRoot();
336 Vector3 rootSize = rootNode.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
337 DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
342 int UtcDaliModelOnSizeSet(void)
344 ToolkitTestApplication application;
346 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
348 application.GetScene().Add(model);
350 application.SendNotification();
351 application.Render();
353 Vector2 size(200.0f, 300.0f);
354 model.SetProperty(Actor::Property::SIZE, size);
356 application.SendNotification();
357 application.Render();
359 DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
364 int UtcDaliModelGetNaturalSize(void)
366 ToolkitTestApplication application;
368 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
370 Vector3 naturalSize = model.GetNaturalSize();
371 DALI_TEST_EQUALS(Vector3::ZERO, naturalSize, TEST_LOCATION);
373 application.GetScene().Add(model);
375 gResourceReadyCalled = false;
376 model.ResourceReadySignal().Connect(&OnResourceReady);
377 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
379 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
380 application.SendNotification();
382 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
384 naturalSize = model.GetNaturalSize();
385 DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
387 Scene3D::ModelNode rootNode = model.GetModelRoot();
388 DALI_TEST_CHECK(rootNode);
393 int UtcDaliModelSetImageBasedLightSource01(void)
395 ToolkitTestApplication application;
397 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
398 application.GetScene().Add(model);
400 gResourceReadyCalled = false;
401 model.ResourceReadySignal().Connect(&OnResourceReady);
402 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
404 application.SendNotification();
405 application.Render();
407 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
408 application.SendNotification();
409 application.Render();
411 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
413 Actor meshActor = model.FindChildByName("AnimatedCube");
414 DALI_TEST_CHECK(meshActor);
416 Renderer renderer = meshActor.GetRendererAt(0u);
417 DALI_TEST_CHECK(renderer);
419 TextureSet textureSet = renderer.GetTextures();
420 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
422 Texture diffuseTexture = textureSet.GetTexture(7u);
423 Texture specularTexture = textureSet.GetTexture(8u);
425 gResourceReadyCalled = false;
426 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
427 model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
429 application.SendNotification();
430 application.Render();
432 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
433 application.SendNotification();
434 application.Render();
436 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
438 TextureSet newTextureSet = renderer.GetTextures();
439 Texture newDiffuseTexture = newTextureSet.GetTexture(7u);
440 Texture newSpecularTexture = newTextureSet.GetTexture(8u);
442 DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
443 DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
450 int UtcDaliModelSetImageBasedLightSource02(void)
452 ToolkitTestApplication application;
454 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
455 application.GetScene().Add(model);
457 gResourceReadyCalled = false;
458 model.ResourceReadySignal().Connect(&OnResourceReady);
459 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
461 application.SendNotification();
462 application.Render();
464 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
465 application.SendNotification();
466 application.Render();
468 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
470 Actor meshActor = model.FindChildByName("AnimatedCube");
471 DALI_TEST_CHECK(meshActor);
473 Renderer renderer = meshActor.GetRendererAt(0u);
474 DALI_TEST_CHECK(renderer);
476 TextureSet textureSet = renderer.GetTextures();
477 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
479 Texture diffuseTexture = textureSet.GetTexture(7u);
480 Texture specularTexture = textureSet.GetTexture(8u);
482 // if url is empty, loading is not requested.
483 model.SetImageBasedLightSource("", "");
485 Texture newDiffuseTexture = textureSet.GetTexture(7u);
486 Texture newSpecularTexture = textureSet.GetTexture(8u);
488 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
489 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
494 int UtcDaliModelSetImageBasedLightSource03(void)
496 ToolkitTestApplication application;
498 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
499 application.GetScene().Add(model);
501 gResourceReadyCalled = false;
502 model.ResourceReadySignal().Connect(&OnResourceReady);
503 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
505 application.SendNotification();
506 application.Render();
508 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
509 application.SendNotification();
510 application.Render();
512 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
514 Actor meshActor = model.FindChildByName("AnimatedCube");
515 DALI_TEST_CHECK(meshActor);
517 Renderer renderer = meshActor.GetRendererAt(0u);
518 DALI_TEST_CHECK(renderer);
520 TextureSet textureSet = renderer.GetTextures();
521 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
523 Texture diffuseTexture = textureSet.GetTexture(7u);
524 Texture specularTexture = textureSet.GetTexture(8u);
526 gResourceReadyCalled = false;
527 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
528 model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
530 application.SendNotification();
531 application.Render();
533 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
534 application.SendNotification();
535 application.Render();
537 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
539 Texture newDiffuseTexture = textureSet.GetTexture(7u);
540 Texture newSpecularTexture = textureSet.GetTexture(8u);
542 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
543 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
548 int UtcDaliModelSetImageBasedLightSource04(void)
550 ToolkitTestApplication application;
552 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
553 model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
554 application.GetScene().Add(model);
556 gResourceReadyCalled = false;
557 model.ResourceReadySignal().Connect(&OnResourceReady);
558 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
560 application.SendNotification();
561 application.Render();
563 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
564 application.SendNotification();
565 application.Render();
567 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
571 int UtcDaliModelImageBasedFactor(void)
573 ToolkitTestApplication application;
575 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
577 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
579 model.SetImageBasedLightScaleFactor(0.5f);
580 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
584 int UtcDaliModelChildrenSensitive01(void)
586 ToolkitTestApplication application;
588 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
589 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
590 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
591 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
592 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
594 // Get default vaule.
595 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
597 // Allow children actor's event before on scene.
598 view.SetChildrenSensitive(true);
599 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
600 application.GetScene().Add(view);
602 gResourceReadyCalled = false;
603 view.ResourceReadySignal().Connect(&OnResourceReady);
604 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
606 application.SendNotification();
607 application.Render();
609 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
610 application.SendNotification();
611 application.Render();
613 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
615 Actor meshActor = view.FindChildByName("AnimatedCube");
616 DALI_TEST_CHECK(meshActor);
618 // connect hit-test signal
619 gTouchCallBackCalled = false;
620 meshActor.TouchedSignal().Connect(TestTouchCallback);
622 Vector2 sceneSize = application.GetScene().GetSize();
624 // Try to touch center of scene.
625 Dali::Integration::Point point;
626 point.SetState(PointState::DOWN);
627 point.SetScreenPosition(sceneSize * 0.5f);
628 Dali::Integration::TouchEvent event;
629 event.AddPoint(point);
631 // flush the queue and render once
632 application.SendNotification();
633 application.Render();
636 DALI_TEST_CHECK(!gTouchCallBackCalled);
637 application.ProcessEvent(event);
639 DALI_TEST_CHECK(gTouchCallBackCalled);
642 gTouchCallBackCalled = false;
644 // Block children actor's event
645 view.SetChildrenSensitive(false);
646 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
648 // flush the queue and render once
649 application.SendNotification();
650 application.Render();
653 DALI_TEST_CHECK(!gTouchCallBackCalled);
654 application.ProcessEvent(event);
656 DALI_TEST_CHECK(!gTouchCallBackCalled);
659 gTouchCallBackCalled = false;
662 view.SetChildrenSensitive(true);
663 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
665 // flush the queue and render once
666 application.SendNotification();
667 application.Render();
670 DALI_TEST_CHECK(!gTouchCallBackCalled);
671 application.ProcessEvent(event);
673 DALI_TEST_CHECK(gTouchCallBackCalled);
676 gTouchCallBackCalled = false;
681 int UtcDaliModelChildrenSensitive02(void)
683 ToolkitTestApplication application;
685 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
686 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
687 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
688 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
689 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
692 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
694 // Block children actor's event before on scene.
695 view.SetChildrenSensitive(false);
696 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
697 application.GetScene().Add(view);
699 gResourceReadyCalled = false;
700 view.ResourceReadySignal().Connect(&OnResourceReady);
701 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
703 application.SendNotification();
704 application.Render();
706 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
707 application.SendNotification();
708 application.Render();
710 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
712 Actor meshActor = view.FindChildByName("AnimatedCube");
713 DALI_TEST_CHECK(meshActor);
715 // connect hit-test signal
716 gTouchCallBackCalled = false;
717 meshActor.TouchedSignal().Connect(TestTouchCallback);
719 Vector2 sceneSize = application.GetScene().GetSize();
721 // Try to touch center of scene.
722 Dali::Integration::Point point;
723 point.SetState(PointState::DOWN);
724 point.SetScreenPosition(sceneSize * 0.5f);
725 Dali::Integration::TouchEvent event;
726 event.AddPoint(point);
728 // flush the queue and render once
729 application.SendNotification();
730 application.Render();
733 DALI_TEST_CHECK(!gTouchCallBackCalled);
734 application.ProcessEvent(event);
736 DALI_TEST_CHECK(!gTouchCallBackCalled);
739 gTouchCallBackCalled = false;
742 view.SetChildrenSensitive(true);
743 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
745 // flush the queue and render once
746 application.SendNotification();
747 application.Render();
750 DALI_TEST_CHECK(!gTouchCallBackCalled);
751 application.ProcessEvent(event);
753 DALI_TEST_CHECK(gTouchCallBackCalled);
756 gTouchCallBackCalled = false;
761 int UtcDaliModelChildrenFocusable01(void)
763 ToolkitTestApplication application;
765 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
766 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
767 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
768 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
769 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
771 // Get vaule. Default is false.
772 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
774 // Allow children actor's focus before on scene.
775 view.SetChildrenFocusable(true);
776 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
777 application.GetScene().Add(view);
779 gResourceReadyCalled = false;
780 view.ResourceReadySignal().Connect(&OnResourceReady);
781 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
783 application.SendNotification();
784 application.Render();
786 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
787 application.SendNotification();
788 application.Render();
790 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
792 Actor meshActor = view.FindChildByName("AnimatedCube");
793 DALI_TEST_CHECK(meshActor);
795 // Enable the default algorithm
796 KeyboardFocusManager manager = KeyboardFocusManager::Get();
797 DALI_TEST_CHECK(manager);
798 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
800 // connect focusable signal
801 gFocusChangedCallBackCalled = false;
802 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
803 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
805 // Initialize with some left-positioned actor
806 Control focusStartActor = Control::New();
807 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
808 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
809 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
810 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
811 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
812 application.GetScene().Add(focusStartActor);
815 manager.ClearFocus();
816 manager.SetCurrentFocusActor(focusStartActor);
817 gFocusChangedCallBackCalled = false;
819 // flush the queue and render once
820 application.SendNotification();
821 application.Render();
823 // Focusable view find success
824 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
825 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
828 manager.ClearFocus();
829 manager.SetCurrentFocusActor(focusStartActor);
830 gFocusChangedCallBackCalled = false;
832 // Block children actor's focus
833 view.SetChildrenFocusable(false);
834 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
836 // flush the queue and render once
837 application.SendNotification();
838 application.Render();
840 // Focusable view find failed
841 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
842 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
845 manager.ClearFocus();
846 manager.SetCurrentFocusActor(focusStartActor);
847 gFocusChangedCallBackCalled = false;
850 view.SetChildrenFocusable(true);
851 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
853 // flush the queue and render once
854 application.SendNotification();
855 application.Render();
857 // Focusable view find success
858 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
859 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
862 manager.ClearFocus();
863 manager.SetCurrentFocusActor(focusStartActor);
864 gFocusChangedCallBackCalled = false;
869 int UtcDaliModelModelChildrenFocusable02(void)
871 ToolkitTestApplication application;
873 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
874 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
875 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
876 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
877 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
879 // Get vaule. Default is true.
880 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
882 // Block children actor's focus before on scene.
883 view.SetChildrenFocusable(false);
884 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
885 application.GetScene().Add(view);
887 gResourceReadyCalled = false;
888 view.ResourceReadySignal().Connect(&OnResourceReady);
889 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
891 application.SendNotification();
892 application.Render();
894 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
895 application.SendNotification();
896 application.Render();
898 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
900 Actor meshActor = view.FindChildByName("AnimatedCube");
901 DALI_TEST_CHECK(meshActor);
903 // Enable the default algorithm
904 KeyboardFocusManager manager = KeyboardFocusManager::Get();
905 DALI_TEST_CHECK(manager);
906 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
908 // connect focusable signal
909 gFocusChangedCallBackCalled = false;
910 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
911 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
913 // Initialize with some left-positioned actor
914 Control focusStartActor = Control::New();
915 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
916 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
917 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
918 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
919 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
920 application.GetScene().Add(focusStartActor);
923 manager.ClearFocus();
924 manager.SetCurrentFocusActor(focusStartActor);
925 gFocusChangedCallBackCalled = false;
927 // flush the queue and render once
928 application.SendNotification();
929 application.Render();
931 // Focusable view find failed
932 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
933 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
936 manager.ClearFocus();
937 manager.SetCurrentFocusActor(focusStartActor);
938 gFocusChangedCallBackCalled = false;
941 view.SetChildrenFocusable(true);
942 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
944 // flush the queue and render once
945 application.SendNotification();
946 application.Render();
948 // Focusable view find success
949 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
950 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
953 manager.ClearFocus();
954 manager.SetCurrentFocusActor(focusStartActor);
955 gFocusChangedCallBackCalled = false;
960 int UtcDaliModelAnimation01(void)
962 ToolkitTestApplication application;
964 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
965 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
966 application.GetScene().Add(model);
968 gResourceReadyCalled = false;
969 model.ResourceReadySignal().Connect(&OnResourceReady);
970 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
972 application.SendNotification();
973 application.Render();
975 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
976 application.SendNotification();
977 application.Render();
979 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
981 uint32_t animationCount = model.GetAnimationCount();
982 DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
984 Animation animationByIndex = model.GetAnimation(0u);
985 DALI_TEST_CHECK(animationByIndex);
987 Animation animationByName = model.GetAnimation("animation_AnimatedCube");
988 DALI_TEST_CHECK(animationByName);
989 DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
994 int UtcDaliModelAnimation02(void)
996 ToolkitTestApplication application;
998 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
999 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1000 application.GetScene().Add(model);
1002 gResourceReadyCalled = false;
1003 model.ResourceReadySignal().Connect(&OnResourceReady);
1004 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1006 application.SendNotification();
1007 application.Render();
1009 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1010 application.SendNotification();
1011 application.Render();
1013 uint32_t animationCount = model.GetAnimationCount();
1014 DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
1016 Animation animation1 = model.GetAnimation("Step Scale");
1017 DALI_TEST_CHECK(animation1);
1018 DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
1020 Animation animation2 = model.GetAnimation("CubicSpline Scale");
1021 DALI_TEST_CHECK(animation2);
1022 DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
1024 DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
1029 int UtcDaliModelAnimation03(void)
1031 ToolkitTestApplication application;
1033 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
1034 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1035 application.GetScene().Add(model);
1037 gResourceReadyCalled = false;
1038 model.ResourceReadySignal().Connect(&OnResourceReady);
1039 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1041 application.SendNotification();
1042 application.Render();
1044 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1045 application.SendNotification();
1046 application.Render();
1048 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1050 uint32_t animationCount = model.GetAnimationCount();
1051 DALI_TEST_EQUALS(18, animationCount, TEST_LOCATION);
1053 Animation animationByIndex = model.GetAnimation(0u);
1054 DALI_TEST_CHECK(animationByIndex);
1056 Animation animationByName = model.GetAnimation("idleClip");
1057 DALI_TEST_CHECK(animationByName);
1058 DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
1063 int UtcDaliModelCameraGenerate01(void)
1065 ToolkitTestApplication application;
1067 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
1068 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1069 application.GetScene().Add(model);
1071 gResourceReadyCalled = false;
1072 model.ResourceReadySignal().Connect(&OnResourceReady);
1073 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1075 application.SendNotification();
1076 application.Render();
1078 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1079 application.SendNotification();
1080 application.Render();
1082 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1084 uint32_t cameraCount = model.GetCameraCount();
1085 DALI_TEST_EQUALS(1, cameraCount, TEST_LOCATION);
1087 CameraActor generatedCamera = model.GenerateCamera(0u);
1088 DALI_TEST_CHECK(generatedCamera);
1090 generatedCamera = model.GenerateCamera(1u); // Fail to generate camera
1091 DALI_TEST_CHECK(!generatedCamera);
1096 int UtcDaliModelCameraGenerate02(void)
1098 ToolkitTestApplication application;
1100 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1101 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1102 application.GetScene().Add(model);
1104 gResourceReadyCalled = false;
1105 model.ResourceReadySignal().Connect(&OnResourceReady);
1106 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1108 application.SendNotification();
1109 application.Render();
1111 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1112 application.SendNotification();
1113 application.Render();
1115 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1117 uint32_t cameraCount = model.GetCameraCount();
1118 DALI_TEST_EQUALS(6, cameraCount, TEST_LOCATION);
1120 CameraActor generatedCamera0 = model.GenerateCamera(0u);
1121 DALI_TEST_CHECK(generatedCamera0);
1122 CameraActor generatedCamera1 = model.GenerateCamera(1u);
1123 DALI_TEST_CHECK(generatedCamera1);
1124 CameraActor generatedCamera2 = model.GenerateCamera(2u);
1125 DALI_TEST_CHECK(generatedCamera2);
1126 CameraActor generatedCamera3 = model.GenerateCamera(3u); // Infinity far camera
1127 DALI_TEST_CHECK(generatedCamera3);
1128 CameraActor generatedCamera4 = model.GenerateCamera(4u); // Broken camera 1
1129 DALI_TEST_CHECK(!generatedCamera4);
1130 CameraActor generatedCamera5 = model.GenerateCamera(5u); // Broken camera 2
1131 DALI_TEST_CHECK(!generatedCamera5);
1132 CameraActor generatedCamera6 = model.GenerateCamera(6u); // Out of bound
1133 DALI_TEST_CHECK(!generatedCamera6);
1135 CameraActor appliedCamera;
1136 DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), false, TEST_LOCATION); // Cannot apply into empty camera.
1138 auto CompareCameraProperties = [](CameraActor lhs, CameraActor rhs, const char* location)
1140 DALI_TEST_EQUALS(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), rhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), TEST_LOCATION);
1141 DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), TEST_LOCATION);
1143 if(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE) == static_cast<int>(Dali::Camera::ProjectionMode::PERSPECTIVE_PROJECTION))
1145 DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), rhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), TEST_LOCATION);
1146 // TODO : Open this test when infinity far projection implement.
1147 // DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
1151 DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), rhs.GetProperty<float>(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), TEST_LOCATION);
1152 DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
1156 appliedCamera = CameraActor::New();
1157 DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), true, TEST_LOCATION);
1158 CompareCameraProperties(generatedCamera0, appliedCamera, TEST_LOCATION);
1159 DALI_TEST_EQUALS(model.ApplyCamera(1u, appliedCamera), true, TEST_LOCATION);
1160 CompareCameraProperties(generatedCamera1, appliedCamera, TEST_LOCATION);
1161 DALI_TEST_EQUALS(model.ApplyCamera(2u, appliedCamera), true, TEST_LOCATION);
1162 CompareCameraProperties(generatedCamera2, appliedCamera, TEST_LOCATION);
1163 DALI_TEST_EQUALS(model.ApplyCamera(3u, appliedCamera), true, TEST_LOCATION);
1164 CompareCameraProperties(generatedCamera3, appliedCamera, TEST_LOCATION);
1165 DALI_TEST_EQUALS(model.ApplyCamera(4u, appliedCamera), false, TEST_LOCATION); // Broken camera 1
1166 DALI_TEST_EQUALS(model.ApplyCamera(5u, appliedCamera), false, TEST_LOCATION); // Broken camera 2
1167 DALI_TEST_EQUALS(model.ApplyCamera(6u, appliedCamera), false, TEST_LOCATION); // Cannot apply over the index.
1172 int UtcDaliModelMultiplePrimitives(void)
1174 ToolkitTestApplication application;
1176 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME);
1177 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1178 application.GetScene().Add(model);
1180 gResourceReadyCalled = false;
1181 model.ResourceReadySignal().Connect(&OnResourceReady);
1182 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1184 application.SendNotification();
1185 application.Render();
1187 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1188 application.SendNotification();
1189 application.Render();
1191 Actor actor = model.FindChildByName("rootNode");
1193 DALI_TEST_EQUALS(0, actor.GetChildCount(), TEST_LOCATION);
1194 DALI_TEST_EQUALS(2, actor.GetRendererCount(), TEST_LOCATION);
1199 int UtcDaliModelColorMode(void)
1201 ToolkitTestApplication application;
1203 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1204 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1205 model.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
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 Actor actor = model.FindChildByName("AnimatedCube");
1220 Vector4 childColor = actor[Dali::Actor::Property::COLOR];
1221 Vector4 childWorldColor = actor[Dali::Actor::Property::WORLD_COLOR];
1223 DALI_TEST_EQUALS(childColor, Color::WHITE, TEST_LOCATION);
1224 DALI_TEST_EQUALS(childWorldColor, Color::RED, TEST_LOCATION);
1229 int UtcDaliModelResourceReady(void)
1231 ToolkitTestApplication application;
1233 gOnRelayoutCallBackCalled = false;
1234 gResourceReadyCalled = false;
1235 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
1236 model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1237 model.OnRelayoutSignal().Connect(OnRelayoutCallback);
1238 model.ResourceReadySignal().Connect(OnResourceReady);
1239 DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
1242 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
1243 DALI_TEST_CHECK(!gResourceReadyCalled);
1245 application.GetScene().Add(model);
1247 application.SendNotification();
1248 application.Render();
1250 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1251 application.SendNotification();
1252 application.Render();
1254 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
1255 DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
1256 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1261 int UtcDaliModelResourceCacheCheck(void)
1263 ToolkitTestApplication application;
1265 // Load three instances of the same model and add them to the scene
1266 Scene3D::Model model1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1267 Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1268 Scene3D::Model model3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1270 application.GetScene().Add(model1);
1271 application.GetScene().Add(model2);
1272 application.GetScene().Add(model3);
1274 gResourceReadyCalled = false;
1275 model1.ResourceReadySignal().Connect(&OnResourceReady);
1276 model2.ResourceReadySignal().Connect(&OnResourceReady);
1277 model3.ResourceReadySignal().Connect(&OnResourceReady);
1278 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1280 application.SendNotification();
1281 application.Render();
1283 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1284 application.SendNotification();
1285 application.Render();
1287 // Check that the loading has finished for all the three instances
1288 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1290 Actor meshActor1 = model1.FindChildByName("AnimatedCube");
1291 Actor meshActor2 = model2.FindChildByName("AnimatedCube");
1292 Actor meshActor3 = model3.FindChildByName("AnimatedCube");
1293 DALI_TEST_CHECK(meshActor1);
1294 DALI_TEST_CHECK(meshActor2);
1295 DALI_TEST_CHECK(meshActor3);
1297 Renderer renderer1 = meshActor1.GetRendererAt(0u);
1298 Renderer renderer2 = meshActor2.GetRendererAt(0u);
1299 Renderer renderer3 = meshActor3.GetRendererAt(0u);
1300 DALI_TEST_CHECK(renderer1);
1301 DALI_TEST_CHECK(renderer2);
1302 DALI_TEST_CHECK(renderer3);
1304 // Check that all the three instances use the shared textures and geometries from the cache
1305 // but have their own shader objects
1306 DALI_TEST_EQUALS(renderer1.GetTextures(), renderer2.GetTextures(), TEST_LOCATION);
1307 DALI_TEST_EQUALS(renderer1.GetTextures(), renderer3.GetTextures(), TEST_LOCATION);
1308 DALI_TEST_EQUALS(renderer1.GetGeometry(), renderer2.GetGeometry(), TEST_LOCATION);
1309 DALI_TEST_EQUALS(renderer1.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1310 DALI_TEST_NOT_EQUALS(renderer1.GetShader(), renderer2.GetShader(), 0.0f, TEST_LOCATION);
1311 DALI_TEST_NOT_EQUALS(renderer1.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1312 DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1318 // Check that all the other two instances still use the shared textures and geometries from the cache
1319 // but have their own shader objects
1320 DALI_TEST_EQUALS(renderer2.GetTextures(), renderer3.GetTextures(), TEST_LOCATION);
1321 DALI_TEST_EQUALS(renderer2.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1322 DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1324 // Set new IBL textures for model2, and this should apply to model2 instance only
1325 gResourceReadyCalled = false;
1326 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
1327 model2.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
1329 application.SendNotification();
1330 application.Render();
1332 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1333 application.SendNotification();
1334 application.Render();
1336 // Check that the new IBL textures are loaded for model2
1337 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
1339 // Check that the two instances still use the shared geometries from the cache
1340 // but now have their own shader objects and different texture set
1341 DALI_TEST_NOT_EQUALS(renderer2.GetTextures(), renderer3.GetTextures(), 0.0f, TEST_LOCATION);
1342 DALI_TEST_EQUALS(renderer2.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
1343 DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
1345 // Check that the two instances now have their own diffuse texture and specular texture,
1346 // but all the other textures are still the same
1347 TextureSet textureSet2 = renderer2.GetTextures();
1348 TextureSet textureSet3 = renderer3.GetTextures();
1349 DALI_TEST_EQUALS(textureSet2.GetTextureCount(), 9u, TEST_LOCATION);
1350 DALI_TEST_EQUALS(textureSet3.GetTextureCount(), 9u, TEST_LOCATION);
1352 for(uint32_t i = 0; i < 7u; i++)
1354 DALI_TEST_EQUALS(textureSet2.GetTexture(i), textureSet3.GetTexture(i), TEST_LOCATION);
1357 DALI_TEST_NOT_EQUALS(textureSet2.GetTexture(7u), textureSet3.GetTexture(7u), 0.0f, TEST_LOCATION);
1358 DALI_TEST_NOT_EQUALS(textureSet2.GetTexture(8u), textureSet3.GetTexture(8u), 0.0f, TEST_LOCATION);
1363 int UtcDaliModelAddRemoveModelNode(void)
1365 ToolkitTestApplication application;
1367 Scene3D::Model model = Scene3D::Model::New();
1368 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
1370 Scene3D::ModelNode node1 = Scene3D::ModelNode::New();
1371 Scene3D::ModelNode node2 = Scene3D::ModelNode::New();
1372 Scene3D::ModelNode node3 = Scene3D::ModelNode::New();
1373 Scene3D::ModelNode node4 = Scene3D::ModelNode::New();
1375 model.AddModelNode(node1);
1376 model.AddModelNode(node2);
1377 model.AddModelNode(node3);
1378 model.RemoveModelNode(node1); // Remove node before scene on
1380 application.GetScene().Add(model);
1382 Dali::Scene3D::ModelNode root = model.GetModelRoot();
1383 DALI_TEST_CHECK(root);
1384 DALI_TEST_EQUALS(2, root.GetChildCount(), TEST_LOCATION);
1386 model.RemoveModelNode(node2); // Remove node after scene on
1388 DALI_TEST_EQUALS(1, root.GetChildCount(), TEST_LOCATION);
1390 model.AddModelNode(node4); // Add during scene on
1392 DALI_TEST_EQUALS(2, root.GetChildCount(), TEST_LOCATION);
1394 application.GetScene().Remove(model);
1396 model.RemoveModelNode(node3); // Remove node after scene off
1401 int UtcDaliModelFindChildModelNodeByName(void)
1403 tet_infoline(" UtcDaliModelNodeFindChildModelNodeByName.");
1405 ToolkitTestApplication application;
1407 Scene3D::Model model = Scene3D::Model::New();
1408 application.GetScene().Add(model);
1410 Scene3D::ModelNode modelNode1 = Scene3D::ModelNode::New();
1411 Scene3D::ModelNode modelNode2 = Scene3D::ModelNode::New();
1413 modelNode1.SetProperty(Dali::Actor::Property::NAME, "modelNode1");
1414 modelNode2.SetProperty(Dali::Actor::Property::NAME, "modelNode2");
1415 model.AddModelNode(modelNode1);
1416 model.AddModelNode(modelNode2);
1418 Scene3D::ModelNode child1 = model.FindChildModelNodeByName("modelNode1");
1419 DALI_TEST_CHECK(child1);
1420 DALI_TEST_EQUALS(child1, modelNode1, TEST_LOCATION);
1422 Scene3D::ModelNode child2 = model.FindChildModelNodeByName("modelNode2");
1423 DALI_TEST_CHECK(child2);
1424 DALI_TEST_EQUALS(child2, modelNode2, TEST_LOCATION);
1429 int UtcDaliModelSizeChange(void)
1431 tet_infoline(" UtcDaliModelSizeChange.");
1433 ToolkitTestApplication application;
1435 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1436 model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
1437 application.GetScene().Add(model);
1439 application.SendNotification();
1440 application.Render();
1442 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1443 application.SendNotification();
1444 application.Render();
1446 DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
1447 Vector3 scale = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1449 model.SetProperty(Dali::Actor::Property::SIZE, Vector3(600, 600, 600));
1450 Vector3 scale2 = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1452 DALI_TEST_NOT_EQUALS(scale, scale2, 0.1f, TEST_LOCATION);
1457 int UtcDaliModelSizeChange2(void)
1459 tet_infoline(" UtcDaliModelSizeChange2.");
1461 ToolkitTestApplication application;
1463 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
1464 model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
1465 application.GetScene().Add(model);
1467 application.SendNotification();
1468 application.Render();
1470 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1471 application.SendNotification();
1472 application.Render();
1474 DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
1475 Vector3 scale = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1477 Animation animation = Animation::New(0.5f);
1478 animation.AnimateTo(Dali::Property(model, Dali::Actor::Property::SIZE), Vector3(600, 600, 600));
1481 application.SendNotification();
1482 application.Render(250);
1484 application.SendNotification();
1486 Vector3 scale2 = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
1487 DALI_TEST_NOT_EQUALS(scale, scale2, 0.1f, TEST_LOCATION);