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_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME = TEST_RESOURCE_DIR "/simpleMultiplePrimitiveTest.gltf";
53 const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli";
55 * For the diffuse and specular cube map texture.
56 * These textures are based off version of Wave engine sample
57 * Take from https://github.com/WaveEngine/Samples
59 * Copyright (c) 2022 Wave Coorporation
61 * Permission is hereby granted, free of charge, to any person obtaining a copy
62 * of this software and associated documentation files (the "Software"), to
63 * deal in the Software without restriction, including without limitation the
64 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
65 * sell copies of the Software, and to permit persons to whom the Software is
66 * furnished to do so, subject to the following conditions:
68 * The above copyright notice and this permission notice shall be included in
69 * all copies or substantial portions of the Software.
71 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
74 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
76 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
79 const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
80 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
82 bool gTouchCallBackCalled = false;
83 bool TestTouchCallback(Actor, const TouchEvent&)
85 gTouchCallBackCalled = true;
89 bool gFocusChangedCallBackCalled = false;
90 void TestFocusChangedCallback(Actor, Actor)
92 gFocusChangedCallBackCalled = true;
97 // Negative test case for a method
98 int UtcDaliModelUninitialized(void)
100 ToolkitTestApplication application;
101 tet_infoline(" UtcDaliModelUninitialized");
103 Scene3D::Model model;
107 // New() must be called to create a Model or it wont be valid.
108 Actor a = Actor::New();
110 DALI_TEST_CHECK(false);
112 catch(Dali::DaliException& e)
114 // Tests that a negative test of an assertion succeeds
115 DALI_TEST_PRINT_ASSERT(e);
116 DALI_TEST_CHECK(!model);
121 // Positive test case for a method
122 int UtcDaliModelNew(void)
124 ToolkitTestApplication application;
125 tet_infoline(" UtcDaliModelNew");
127 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
128 DALI_TEST_CHECK(model);
132 // Positive test case for a method
133 int UtcDaliModelDownCast(void)
135 ToolkitTestApplication application;
136 tet_infoline(" UtcDaliModelDownCast");
138 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
139 BaseHandle handle(model);
141 Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
142 DALI_TEST_CHECK(model);
143 DALI_TEST_CHECK(model2);
144 DALI_TEST_CHECK(model2 == model);
148 int UtcDaliModelTypeRegistry(void)
150 ToolkitTestApplication application;
152 TypeRegistry typeRegistry = TypeRegistry::Get();
153 DALI_TEST_CHECK(typeRegistry);
155 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
156 DALI_TEST_CHECK(typeInfo);
158 BaseHandle handle = typeInfo.CreateInstance();
159 DALI_TEST_CHECK(handle);
161 Scene3D::Model model = Scene3D::Model::DownCast(handle);
162 DALI_TEST_CHECK(model);
167 // Positive test case for a method
168 int UtcDaliModelAddRemove(void)
170 ToolkitTestApplication application;
171 tet_infoline(" UtcDaliModelAddRemove");
173 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
174 DALI_TEST_CHECK(model);
176 Actor actor = Actor::New();
177 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
179 model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
180 model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
182 application.GetScene().Add(model);
184 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
188 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
192 int UtcDaliModelCopyAndAssignment(void)
194 ToolkitTestApplication application;
196 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
197 DALI_TEST_CHECK(model);
199 Scene3D::Model copy(model);
200 DALI_TEST_CHECK(model == copy);
202 Scene3D::Model assign;
203 DALI_TEST_CHECK(!assign);
206 DALI_TEST_CHECK(assign == model);
211 int UtcDaliModelMoveConstructor(void)
213 ToolkitTestApplication application;
215 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
216 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
217 model.SetProperty(Actor::Property::SENSITIVE, false);
218 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
220 Scene3D::Model moved = std::move(model);
221 DALI_TEST_CHECK(moved);
222 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
223 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
224 DALI_TEST_CHECK(!model);
229 int UtcDaliModelMoveAssignment(void)
231 ToolkitTestApplication application;
233 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
234 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
235 model.SetProperty(Actor::Property::SENSITIVE, false);
236 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
238 Scene3D::Model moved;
239 moved = std::move(model);
240 DALI_TEST_CHECK(moved);
241 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
242 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
243 DALI_TEST_CHECK(!model);
248 int UtcDaliModelOnScene01(void)
250 ToolkitTestApplication application;
252 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
254 application.GetScene().Add(model);
256 application.SendNotification();
257 application.Render();
259 uint32_t modelCount = model.GetModelRoot().GetChildCount();
260 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
265 int UtcDaliModelOnScene02(void)
267 ToolkitTestApplication application;
269 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
271 application.GetScene().Add(model);
273 application.SendNotification();
274 application.Render();
276 uint32_t modelCount = model.GetModelRoot().GetChildCount();
277 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
279 Actor rootActor = model.GetModelRoot();
280 Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
281 DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
286 int UtcDaliModelOnSizeSet(void)
288 ToolkitTestApplication application;
290 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
292 application.GetScene().Add(model);
294 application.SendNotification();
295 application.Render();
297 Vector2 size(200.0f, 300.0f);
298 model.SetProperty(Actor::Property::SIZE, size);
300 application.SendNotification();
301 application.Render();
303 DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
308 int UtcDaliModelGetNaturalSize(void)
310 ToolkitTestApplication application;
312 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
314 Vector3 naturalSize = model.GetNaturalSize();
316 DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
318 Actor root = model.GetModelRoot();
319 DALI_TEST_CHECK(root);
324 int UtcDaliModelSetImageBasedLightSource01(void)
326 ToolkitTestApplication application;
328 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
330 application.GetScene().Add(model);
332 application.SendNotification();
333 application.Render();
335 Actor meshActor = model.FindChildByName("AnimatedCube");
336 DALI_TEST_CHECK(meshActor);
338 Renderer renderer = meshActor.GetRendererAt(0u);
339 DALI_TEST_CHECK(renderer);
341 TextureSet textureSet = renderer.GetTextures();
342 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
344 Texture diffuseTexture = textureSet.GetTexture(5u);
345 Texture specularTexture = textureSet.GetTexture(6u);
347 model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
349 Texture newDiffuseTexture = textureSet.GetTexture(5u);
350 Texture newSpecularTexture = textureSet.GetTexture(6u);
352 DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
353 DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
358 int UtcDaliModelSetImageBasedLightSource02(void)
360 ToolkitTestApplication application;
362 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
364 application.GetScene().Add(model);
366 application.SendNotification();
367 application.Render();
369 Actor meshActor = model.FindChildByName("AnimatedCube");
370 DALI_TEST_CHECK(meshActor);
372 Renderer renderer = meshActor.GetRendererAt(0u);
373 DALI_TEST_CHECK(renderer);
375 TextureSet textureSet = renderer.GetTextures();
376 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
378 Texture diffuseTexture = textureSet.GetTexture(5u);
379 Texture specularTexture = textureSet.GetTexture(6u);
381 model.SetImageBasedLightSource("", "");
383 Texture newDiffuseTexture = textureSet.GetTexture(5u);
384 Texture newSpecularTexture = textureSet.GetTexture(6u);
386 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
387 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
392 int UtcDaliModelSetImageBasedLightSource03(void)
394 ToolkitTestApplication application;
396 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
398 application.GetScene().Add(model);
400 application.SendNotification();
401 application.Render();
403 Actor meshActor = model.FindChildByName("AnimatedCube");
404 DALI_TEST_CHECK(meshActor);
406 Renderer renderer = meshActor.GetRendererAt(0u);
407 DALI_TEST_CHECK(renderer);
409 TextureSet textureSet = renderer.GetTextures();
410 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
412 Texture diffuseTexture = textureSet.GetTexture(5u);
413 Texture specularTexture = textureSet.GetTexture(6u);
415 model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
417 Texture newDiffuseTexture = textureSet.GetTexture(5u);
418 Texture newSpecularTexture = textureSet.GetTexture(6u);
420 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
421 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
426 int UtcDaliModelImageBasedFactor(void)
428 ToolkitTestApplication application;
430 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
432 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
434 model.SetImageBasedLightScaleFactor(0.5f);
435 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
439 int UtcDaliModelChildrenSensitive01(void)
441 ToolkitTestApplication application;
443 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
444 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
445 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
446 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
447 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
449 // Get default vaule.
450 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
452 // Allow children actor's event before on scene.
453 view.SetChildrenSensitive(true);
454 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
456 application.GetScene().Add(view);
458 application.SendNotification();
459 application.Render();
461 Actor meshActor = view.FindChildByName("AnimatedCube");
462 DALI_TEST_CHECK(meshActor);
464 // connect hit-test signal
465 gTouchCallBackCalled = false;
466 meshActor.TouchedSignal().Connect(TestTouchCallback);
468 Vector2 sceneSize = application.GetScene().GetSize();
470 // Try to touch center of scene.
471 Dali::Integration::Point point;
472 point.SetState(PointState::DOWN);
473 point.SetScreenPosition(sceneSize * 0.5f);
474 Dali::Integration::TouchEvent event;
475 event.AddPoint(point);
477 // flush the queue and render once
478 application.SendNotification();
479 application.Render();
482 DALI_TEST_CHECK(!gTouchCallBackCalled);
483 application.ProcessEvent(event);
485 DALI_TEST_CHECK(gTouchCallBackCalled);
488 gTouchCallBackCalled = false;
490 // Block children actor's event
491 view.SetChildrenSensitive(false);
492 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
494 // flush the queue and render once
495 application.SendNotification();
496 application.Render();
499 DALI_TEST_CHECK(!gTouchCallBackCalled);
500 application.ProcessEvent(event);
502 DALI_TEST_CHECK(!gTouchCallBackCalled);
505 gTouchCallBackCalled = false;
508 view.SetChildrenSensitive(true);
509 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
511 // flush the queue and render once
512 application.SendNotification();
513 application.Render();
516 DALI_TEST_CHECK(!gTouchCallBackCalled);
517 application.ProcessEvent(event);
519 DALI_TEST_CHECK(gTouchCallBackCalled);
522 gTouchCallBackCalled = false;
527 int UtcDaliModelChildrenSensitive02(void)
529 ToolkitTestApplication application;
531 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
532 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
533 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
534 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
535 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
538 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
540 // Block children actor's event before on scene.
541 view.SetChildrenSensitive(false);
542 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
544 application.GetScene().Add(view);
546 application.SendNotification();
547 application.Render();
549 Actor meshActor = view.FindChildByName("AnimatedCube");
550 DALI_TEST_CHECK(meshActor);
552 // connect hit-test signal
553 gTouchCallBackCalled = false;
554 meshActor.TouchedSignal().Connect(TestTouchCallback);
556 Vector2 sceneSize = application.GetScene().GetSize();
558 // Try to touch center of scene.
559 Dali::Integration::Point point;
560 point.SetState(PointState::DOWN);
561 point.SetScreenPosition(sceneSize * 0.5f);
562 Dali::Integration::TouchEvent event;
563 event.AddPoint(point);
565 // flush the queue and render once
566 application.SendNotification();
567 application.Render();
570 DALI_TEST_CHECK(!gTouchCallBackCalled);
571 application.ProcessEvent(event);
573 DALI_TEST_CHECK(!gTouchCallBackCalled);
576 gTouchCallBackCalled = false;
579 view.SetChildrenSensitive(true);
580 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
582 // flush the queue and render once
583 application.SendNotification();
584 application.Render();
587 DALI_TEST_CHECK(!gTouchCallBackCalled);
588 application.ProcessEvent(event);
590 DALI_TEST_CHECK(gTouchCallBackCalled);
593 gTouchCallBackCalled = false;
598 int UtcDaliModelChildrenFocusable01(void)
600 ToolkitTestApplication application;
602 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
603 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
604 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
605 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
606 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
608 // Get vaule. Default is false.
609 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
611 // Allow children actor's focus before on scene.
612 view.SetChildrenFocusable(true);
613 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
615 application.GetScene().Add(view);
617 application.SendNotification();
618 application.Render();
620 Actor meshActor = view.FindChildByName("AnimatedCube");
621 DALI_TEST_CHECK(meshActor);
623 // Enable the default algorithm
624 KeyboardFocusManager manager = KeyboardFocusManager::Get();
625 DALI_TEST_CHECK(manager);
626 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
628 // connect focusable signal
629 gFocusChangedCallBackCalled = false;
630 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
631 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
633 // Initialize with some left-positioned actor
634 Control focusStartActor = Control::New();
635 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
636 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
637 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
638 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
639 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
640 application.GetScene().Add(focusStartActor);
643 manager.ClearFocus();
644 manager.SetCurrentFocusActor(focusStartActor);
645 gFocusChangedCallBackCalled = false;
647 // flush the queue and render once
648 application.SendNotification();
649 application.Render();
651 // Focusable view find success
652 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
653 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
656 manager.ClearFocus();
657 manager.SetCurrentFocusActor(focusStartActor);
658 gFocusChangedCallBackCalled = false;
660 // Block children actor's focus
661 view.SetChildrenFocusable(false);
662 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
664 // flush the queue and render once
665 application.SendNotification();
666 application.Render();
668 // Focusable view find failed
669 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
670 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
673 manager.ClearFocus();
674 manager.SetCurrentFocusActor(focusStartActor);
675 gFocusChangedCallBackCalled = false;
678 view.SetChildrenFocusable(true);
679 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
681 // flush the queue and render once
682 application.SendNotification();
683 application.Render();
685 // Focusable view find success
686 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
687 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
690 manager.ClearFocus();
691 manager.SetCurrentFocusActor(focusStartActor);
692 gFocusChangedCallBackCalled = false;
697 int UtcDaliModelModelChildrenFocusable02(void)
699 ToolkitTestApplication application;
701 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
702 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
703 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
704 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
705 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
707 // Get vaule. Default is true.
708 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
710 // Block children actor's focus before on scene.
711 view.SetChildrenFocusable(false);
712 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
714 application.GetScene().Add(view);
716 application.SendNotification();
717 application.Render();
719 Actor meshActor = view.FindChildByName("AnimatedCube");
720 DALI_TEST_CHECK(meshActor);
722 // Enable the default algorithm
723 KeyboardFocusManager manager = KeyboardFocusManager::Get();
724 DALI_TEST_CHECK(manager);
725 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
727 // connect focusable signal
728 gFocusChangedCallBackCalled = false;
729 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
730 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
732 // Initialize with some left-positioned actor
733 Control focusStartActor = Control::New();
734 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
735 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
736 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
737 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
738 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
739 application.GetScene().Add(focusStartActor);
742 manager.ClearFocus();
743 manager.SetCurrentFocusActor(focusStartActor);
744 gFocusChangedCallBackCalled = false;
746 // flush the queue and render once
747 application.SendNotification();
748 application.Render();
750 // Focusable view find failed
751 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
752 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
755 manager.ClearFocus();
756 manager.SetCurrentFocusActor(focusStartActor);
757 gFocusChangedCallBackCalled = false;
760 view.SetChildrenFocusable(true);
761 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
763 // flush the queue and render once
764 application.SendNotification();
765 application.Render();
767 // Focusable view find success
768 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
769 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
772 manager.ClearFocus();
773 manager.SetCurrentFocusActor(focusStartActor);
774 gFocusChangedCallBackCalled = false;
779 int UtcDaliModelAnimation01(void)
781 ToolkitTestApplication application;
783 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
784 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
786 application.GetScene().Add(model);
788 application.SendNotification();
789 application.Render();
791 uint32_t animationCount = model.GetAnimationCount();
792 DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
794 Animation animationByIndex = model.GetAnimation(0u);
795 DALI_TEST_CHECK(animationByIndex);
797 Animation animationByName = model.GetAnimation("animation_AnimatedCube");
798 DALI_TEST_CHECK(animationByName);
799 DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
804 int UtcDaliModelAnimation02(void)
806 ToolkitTestApplication application;
808 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
809 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
811 application.GetScene().Add(model);
813 application.SendNotification();
814 application.Render();
816 uint32_t animationCount = model.GetAnimationCount();
817 DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
819 Animation animation1 = model.GetAnimation("Step Scale");
820 DALI_TEST_CHECK(animation1);
821 DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
823 Animation animation2 = model.GetAnimation("CubicSpline Scale");
824 DALI_TEST_CHECK(animation2);
825 DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
827 DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
832 int UtcDaliModelMultiplePrimitives(void)
834 ToolkitTestApplication application;
836 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME);
837 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
839 application.GetScene().Add(model);
841 application.SendNotification();
842 application.Render();
844 Actor actor = model.FindChildByName("rootNode");
846 DALI_TEST_EQUALS(0, actor.GetChildCount(), TEST_LOCATION);
847 DALI_TEST_EQUALS(2, actor.GetRendererCount(), TEST_LOCATION);
855 static bool gOnRelayoutCallBackCalled = false;
856 void OnRelayoutCallback(Actor actor)
858 gOnRelayoutCallBackCalled = true;
861 static bool gResourceReadyCalled = false;
862 void OnResourceReady(Control control)
864 gResourceReadyCalled = true;
868 int UtcDaliModelResourceReady(void)
870 ToolkitTestApplication application;
872 gOnRelayoutCallBackCalled = false;
873 gResourceReadyCalled = false;
874 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
875 model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
876 model.OnRelayoutSignal().Connect(OnRelayoutCallback);
877 model.ResourceReadySignal().Connect(OnResourceReady);
878 DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
881 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
882 DALI_TEST_CHECK(!gResourceReadyCalled);
884 application.GetScene().Add(model);
886 application.SendNotification();
887 application.Render();
889 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
890 DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
891 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);