2 * Copyright (c) 2022 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>
26 #include <dali-scene3d/public-api/controls/model/model.h>
29 using namespace Dali::Toolkit;
31 void model_startup(void)
33 test_return_value = TET_UNDEF;
36 void model_cleanup(void)
38 test_return_value = TET_PASS;
43 const bool DEFAULT_MODEL_CHILDREN_SENSITIVE = false;
44 const bool DEFAULT_MODEL_CHILDREN_FOCUSABLE = false;
46 * For the AnimatedCube.gltf and its Assets
47 * Donated by Norbert Nopper for glTF testing.
48 * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
50 const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
51 const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf";
52 const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli";
54 * For the diffuse and specular cube map texture.
55 * These textures are based off version of Wave engine sample
56 * Take from https://github.com/WaveEngine/Samples
58 * Copyright (c) 2022 Wave Coorporation
60 * Permission is hereby granted, free of charge, to any person obtaining a copy
61 * of this software and associated documentation files (the "Software"), to
62 * deal in the Software without restriction, including without limitation the
63 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
64 * sell copies of the Software, and to permit persons to whom the Software is
65 * furnished to do so, subject to the following conditions:
67 * The above copyright notice and this permission notice shall be included in
68 * all copies or substantial portions of the Software.
70 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
71 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
72 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
73 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
74 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
75 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
78 const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
79 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
81 bool gTouchCallBackCalled = false;
82 bool TestTouchCallback(Actor, const TouchEvent&)
84 gTouchCallBackCalled = true;
88 bool gFocusChangedCallBackCalled = false;
89 void TestFocusChangedCallback(Actor, Actor)
91 gFocusChangedCallBackCalled = true;
96 // Negative test case for a method
97 int UtcDaliModelUninitialized(void)
99 ToolkitTestApplication application;
100 tet_infoline(" UtcDaliModelUninitialized");
102 Scene3D::Model model;
106 // New() must be called to create a Model or it wont be valid.
107 Actor a = Actor::New();
109 DALI_TEST_CHECK(false);
111 catch(Dali::DaliException& e)
113 // Tests that a negative test of an assertion succeeds
114 DALI_TEST_PRINT_ASSERT(e);
115 DALI_TEST_CHECK(!model);
120 // Positive test case for a method
121 int UtcDaliModelNew(void)
123 ToolkitTestApplication application;
124 tet_infoline(" UtcDaliModelNew");
126 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
127 DALI_TEST_CHECK(model);
131 // Positive test case for a method
132 int UtcDaliModelDownCast(void)
134 ToolkitTestApplication application;
135 tet_infoline(" UtcDaliModelDownCast");
137 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
138 BaseHandle handle(model);
140 Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
141 DALI_TEST_CHECK(model);
142 DALI_TEST_CHECK(model2);
143 DALI_TEST_CHECK(model2 == model);
147 int UtcDaliModelTypeRegistry(void)
149 ToolkitTestApplication application;
151 TypeRegistry typeRegistry = TypeRegistry::Get();
152 DALI_TEST_CHECK(typeRegistry);
154 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
155 DALI_TEST_CHECK(typeInfo);
157 BaseHandle handle = typeInfo.CreateInstance();
158 DALI_TEST_CHECK(handle);
160 Scene3D::Model model = Scene3D::Model::DownCast(handle);
161 DALI_TEST_CHECK(model);
166 // Positive test case for a method
167 int UtcDaliModelAddRemove(void)
169 ToolkitTestApplication application;
170 tet_infoline(" UtcDaliModelAddRemove");
172 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
173 DALI_TEST_CHECK(model);
175 Actor actor = Actor::New();
176 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
178 model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
179 model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
181 application.GetScene().Add(model);
183 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
187 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
191 int UtcDaliModelCopyAndAssignment(void)
193 ToolkitTestApplication application;
195 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
196 DALI_TEST_CHECK(model);
198 Scene3D::Model copy(model);
199 DALI_TEST_CHECK(model == copy);
201 Scene3D::Model assign;
202 DALI_TEST_CHECK(!assign);
205 DALI_TEST_CHECK(assign == model);
210 int UtcDaliModelMoveConstructor(void)
212 ToolkitTestApplication application;
214 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
215 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
216 model.SetProperty(Actor::Property::SENSITIVE, false);
217 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
219 Scene3D::Model moved = std::move(model);
220 DALI_TEST_CHECK(moved);
221 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
222 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
223 DALI_TEST_CHECK(!model);
228 int UtcDaliModelMoveAssignment(void)
230 ToolkitTestApplication application;
232 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
233 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
234 model.SetProperty(Actor::Property::SENSITIVE, false);
235 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
237 Scene3D::Model moved;
238 moved = std::move(model);
239 DALI_TEST_CHECK(moved);
240 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
241 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
242 DALI_TEST_CHECK(!model);
247 int UtcDaliModelOnScene01(void)
249 ToolkitTestApplication application;
251 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
253 application.GetScene().Add(model);
255 application.SendNotification();
256 application.Render();
258 uint32_t modelCount = model.GetModelRoot().GetChildCount();
259 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
264 int UtcDaliModelOnScene02(void)
266 ToolkitTestApplication application;
268 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
270 application.GetScene().Add(model);
272 application.SendNotification();
273 application.Render();
275 uint32_t modelCount = model.GetModelRoot().GetChildCount();
276 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
278 Actor rootActor = model.GetModelRoot();
279 Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
280 DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
285 int UtcDaliModelOnSizeSet(void)
287 ToolkitTestApplication application;
289 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
291 application.GetScene().Add(model);
293 application.SendNotification();
294 application.Render();
296 Vector2 size(200.0f, 300.0f);
297 model.SetProperty(Actor::Property::SIZE, size);
299 application.SendNotification();
300 application.Render();
302 DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
307 int UtcDaliModelGetNaturalSize(void)
309 ToolkitTestApplication application;
311 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
313 Vector3 naturalSize = model.GetNaturalSize();
315 DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
317 Actor root = model.GetModelRoot();
318 DALI_TEST_CHECK(root);
323 int UtcDaliModelSetImageBasedLightSource01(void)
325 ToolkitTestApplication application;
327 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
329 application.GetScene().Add(model);
331 application.SendNotification();
332 application.Render();
334 Actor meshActor = model.FindChildByName("AnimatedCube");
335 DALI_TEST_CHECK(meshActor);
337 Renderer renderer = meshActor.GetRendererAt(0u);
338 DALI_TEST_CHECK(renderer);
340 TextureSet textureSet = renderer.GetTextures();
341 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
343 Texture diffuseTexture = textureSet.GetTexture(5u);
344 Texture specularTexture = textureSet.GetTexture(6u);
346 model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
348 Texture newDiffuseTexture = textureSet.GetTexture(5u);
349 Texture newSpecularTexture = textureSet.GetTexture(6u);
351 DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
352 DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
357 int UtcDaliModelSetImageBasedLightSource02(void)
359 ToolkitTestApplication application;
361 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
363 application.GetScene().Add(model);
365 application.SendNotification();
366 application.Render();
368 Actor meshActor = model.FindChildByName("AnimatedCube");
369 DALI_TEST_CHECK(meshActor);
371 Renderer renderer = meshActor.GetRendererAt(0u);
372 DALI_TEST_CHECK(renderer);
374 TextureSet textureSet = renderer.GetTextures();
375 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
377 Texture diffuseTexture = textureSet.GetTexture(5u);
378 Texture specularTexture = textureSet.GetTexture(6u);
380 model.SetImageBasedLightSource("", "");
382 Texture newDiffuseTexture = textureSet.GetTexture(5u);
383 Texture newSpecularTexture = textureSet.GetTexture(6u);
385 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
386 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
391 int UtcDaliModelSetImageBasedLightSource03(void)
393 ToolkitTestApplication application;
395 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
397 application.GetScene().Add(model);
399 application.SendNotification();
400 application.Render();
402 Actor meshActor = model.FindChildByName("AnimatedCube");
403 DALI_TEST_CHECK(meshActor);
405 Renderer renderer = meshActor.GetRendererAt(0u);
406 DALI_TEST_CHECK(renderer);
408 TextureSet textureSet = renderer.GetTextures();
409 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
411 Texture diffuseTexture = textureSet.GetTexture(5u);
412 Texture specularTexture = textureSet.GetTexture(6u);
414 model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
416 Texture newDiffuseTexture = textureSet.GetTexture(5u);
417 Texture newSpecularTexture = textureSet.GetTexture(6u);
419 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
420 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
425 int UtcDaliModelImageBasedFactor(void)
427 ToolkitTestApplication application;
429 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
431 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
433 model.SetImageBasedLightScaleFactor(0.5f);
434 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
438 int UtcDaliModelChildrenSensitive01(void)
440 ToolkitTestApplication application;
442 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
443 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
444 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
445 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
446 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
448 // Get default vaule.
449 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
451 // Allow children actor's event before on scene.
452 view.SetChildrenSensitive(true);
453 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
455 application.GetScene().Add(view);
457 application.SendNotification();
458 application.Render();
460 Actor meshActor = view.FindChildByName("AnimatedCube");
461 DALI_TEST_CHECK(meshActor);
463 // connect hit-test signal
464 gTouchCallBackCalled = false;
465 meshActor.TouchedSignal().Connect(TestTouchCallback);
467 Vector2 sceneSize = application.GetScene().GetSize();
469 // Try to touch center of scene.
470 Dali::Integration::Point point;
471 point.SetState(PointState::DOWN);
472 point.SetScreenPosition(sceneSize * 0.5f);
473 Dali::Integration::TouchEvent event;
474 event.AddPoint(point);
476 // flush the queue and render once
477 application.SendNotification();
478 application.Render();
481 DALI_TEST_CHECK(!gTouchCallBackCalled);
482 application.ProcessEvent(event);
484 DALI_TEST_CHECK(gTouchCallBackCalled);
487 gTouchCallBackCalled = false;
489 // Block children actor's event
490 view.SetChildrenSensitive(false);
491 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
493 // flush the queue and render once
494 application.SendNotification();
495 application.Render();
498 DALI_TEST_CHECK(!gTouchCallBackCalled);
499 application.ProcessEvent(event);
501 DALI_TEST_CHECK(!gTouchCallBackCalled);
504 gTouchCallBackCalled = false;
507 view.SetChildrenSensitive(true);
508 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
510 // flush the queue and render once
511 application.SendNotification();
512 application.Render();
515 DALI_TEST_CHECK(!gTouchCallBackCalled);
516 application.ProcessEvent(event);
518 DALI_TEST_CHECK(gTouchCallBackCalled);
521 gTouchCallBackCalled = false;
526 int UtcDaliModelChildrenSensitive02(void)
528 ToolkitTestApplication application;
530 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
531 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
532 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
533 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
534 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
537 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
539 // Block children actor's event before on scene.
540 view.SetChildrenSensitive(false);
541 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
543 application.GetScene().Add(view);
545 application.SendNotification();
546 application.Render();
548 Actor meshActor = view.FindChildByName("AnimatedCube");
549 DALI_TEST_CHECK(meshActor);
551 // connect hit-test signal
552 gTouchCallBackCalled = false;
553 meshActor.TouchedSignal().Connect(TestTouchCallback);
555 Vector2 sceneSize = application.GetScene().GetSize();
557 // Try to touch center of scene.
558 Dali::Integration::Point point;
559 point.SetState(PointState::DOWN);
560 point.SetScreenPosition(sceneSize * 0.5f);
561 Dali::Integration::TouchEvent event;
562 event.AddPoint(point);
564 // flush the queue and render once
565 application.SendNotification();
566 application.Render();
569 DALI_TEST_CHECK(!gTouchCallBackCalled);
570 application.ProcessEvent(event);
572 DALI_TEST_CHECK(!gTouchCallBackCalled);
575 gTouchCallBackCalled = false;
578 view.SetChildrenSensitive(true);
579 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
581 // flush the queue and render once
582 application.SendNotification();
583 application.Render();
586 DALI_TEST_CHECK(!gTouchCallBackCalled);
587 application.ProcessEvent(event);
589 DALI_TEST_CHECK(gTouchCallBackCalled);
592 gTouchCallBackCalled = false;
597 int UtcDaliModelChildrenFocusable01(void)
599 ToolkitTestApplication application;
601 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
602 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
603 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
604 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
605 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
607 // Get vaule. Default is false.
608 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
610 // Allow children actor's focus before on scene.
611 view.SetChildrenFocusable(true);
612 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
614 application.GetScene().Add(view);
616 application.SendNotification();
617 application.Render();
619 Actor meshActor = view.FindChildByName("AnimatedCube");
620 DALI_TEST_CHECK(meshActor);
622 // Enable the default algorithm
623 KeyboardFocusManager manager = KeyboardFocusManager::Get();
624 DALI_TEST_CHECK(manager);
625 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
627 // connect focusable signal
628 gFocusChangedCallBackCalled = false;
629 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
630 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
632 // Initialize with some left-positioned actor
633 Control focusStartActor = Control::New();
634 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
635 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
636 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
637 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
638 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
639 application.GetScene().Add(focusStartActor);
642 manager.ClearFocus();
643 manager.SetCurrentFocusActor(focusStartActor);
644 gFocusChangedCallBackCalled = false;
646 // flush the queue and render once
647 application.SendNotification();
648 application.Render();
650 // Focusable view find success
651 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
652 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
655 manager.ClearFocus();
656 manager.SetCurrentFocusActor(focusStartActor);
657 gFocusChangedCallBackCalled = false;
659 // Block children actor's focus
660 view.SetChildrenFocusable(false);
661 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
663 // flush the queue and render once
664 application.SendNotification();
665 application.Render();
667 // Focusable view find failed
668 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
669 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
672 manager.ClearFocus();
673 manager.SetCurrentFocusActor(focusStartActor);
674 gFocusChangedCallBackCalled = false;
677 view.SetChildrenFocusable(true);
678 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
680 // flush the queue and render once
681 application.SendNotification();
682 application.Render();
684 // Focusable view find success
685 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
686 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
689 manager.ClearFocus();
690 manager.SetCurrentFocusActor(focusStartActor);
691 gFocusChangedCallBackCalled = false;
696 int UtcDaliModelModelChildrenFocusable02(void)
698 ToolkitTestApplication application;
700 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
701 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
702 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
703 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
704 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
706 // Get vaule. Default is true.
707 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
709 // Block children actor's focus before on scene.
710 view.SetChildrenFocusable(false);
711 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
713 application.GetScene().Add(view);
715 application.SendNotification();
716 application.Render();
718 Actor meshActor = view.FindChildByName("AnimatedCube");
719 DALI_TEST_CHECK(meshActor);
721 // Enable the default algorithm
722 KeyboardFocusManager manager = KeyboardFocusManager::Get();
723 DALI_TEST_CHECK(manager);
724 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
726 // connect focusable signal
727 gFocusChangedCallBackCalled = false;
728 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
729 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
731 // Initialize with some left-positioned actor
732 Control focusStartActor = Control::New();
733 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
734 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
735 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
736 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
737 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
738 application.GetScene().Add(focusStartActor);
741 manager.ClearFocus();
742 manager.SetCurrentFocusActor(focusStartActor);
743 gFocusChangedCallBackCalled = false;
745 // flush the queue and render once
746 application.SendNotification();
747 application.Render();
749 // Focusable view find failed
750 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
751 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
754 manager.ClearFocus();
755 manager.SetCurrentFocusActor(focusStartActor);
756 gFocusChangedCallBackCalled = false;
759 view.SetChildrenFocusable(true);
760 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
762 // flush the queue and render once
763 application.SendNotification();
764 application.Render();
766 // Focusable view find success
767 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
768 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
771 manager.ClearFocus();
772 manager.SetCurrentFocusActor(focusStartActor);
773 gFocusChangedCallBackCalled = false;
778 int UtcDaliModelAnimation01(void)
780 ToolkitTestApplication application;
782 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
783 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
785 application.GetScene().Add(model);
787 application.SendNotification();
788 application.Render();
790 uint32_t animationCount = model.GetAnimationCount();
791 DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
793 Animation animationByIndex = model.GetAnimation(0u);
794 DALI_TEST_CHECK(animationByIndex);
796 Animation animationByName = model.GetAnimation("animation_AnimatedCube");
797 DALI_TEST_CHECK(animationByName);
798 DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
803 int UtcDaliModelAnimation02(void)
805 ToolkitTestApplication application;
807 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
808 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
810 application.GetScene().Add(model);
812 application.SendNotification();
813 application.Render();
815 uint32_t animationCount = model.GetAnimationCount();
816 DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
818 Animation animation1 = model.GetAnimation("Step Scale");
819 DALI_TEST_CHECK(animation1);
820 DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
822 Animation animation2 = model.GetAnimation("CubicSpline Scale");
823 DALI_TEST_CHECK(animation2);
824 DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
826 DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
834 static bool gOnRelayoutCallBackCalled = false;
835 void OnRelayoutCallback(Actor actor)
837 gOnRelayoutCallBackCalled = true;
840 static bool gResourceReadyCalled = false;
841 void OnResourceReady(Control control)
843 gResourceReadyCalled = true;
847 int UtcDaliModelResourceReady(void)
849 ToolkitTestApplication application;
851 gOnRelayoutCallBackCalled = false;
852 gResourceReadyCalled = false;
853 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
854 model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
855 model.OnRelayoutSignal().Connect(OnRelayoutCallback);
856 model.ResourceReadySignal().Connect(OnResourceReady);
857 DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
860 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
861 DALI_TEST_CHECK(!gResourceReadyCalled);
863 application.GetScene().Add(model);
865 application.SendNotification();
866 application.Render();
868 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
869 DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
870 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);