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";
54 const char* TEST_DLI_EXERCISE_FILE_NAME = TEST_RESOURCE_DIR "/exercise.dli";
56 * For the diffuse and specular cube map texture.
57 * These textures are based off version of Wave engine sample
58 * Take from https://github.com/WaveEngine/Samples
60 * Copyright (c) 2022 Wave Coorporation
62 * Permission is hereby granted, free of charge, to any person obtaining a copy
63 * of this software and associated documentation files (the "Software"), to
64 * deal in the Software without restriction, including without limitation the
65 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
66 * sell copies of the Software, and to permit persons to whom the Software is
67 * furnished to do so, subject to the following conditions:
69 * The above copyright notice and this permission notice shall be included in
70 * all copies or substantial portions of the Software.
72 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
80 const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
81 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
83 bool gTouchCallBackCalled = false;
84 bool TestTouchCallback(Actor, const TouchEvent&)
86 gTouchCallBackCalled = true;
90 bool gFocusChangedCallBackCalled = false;
91 void TestFocusChangedCallback(Actor, Actor)
93 gFocusChangedCallBackCalled = true;
98 // Negative test case for a method
99 int UtcDaliModelUninitialized(void)
101 ToolkitTestApplication application;
102 tet_infoline(" UtcDaliModelUninitialized");
104 Scene3D::Model model;
108 // New() must be called to create a Model or it wont be valid.
109 Actor a = Actor::New();
111 DALI_TEST_CHECK(false);
113 catch(Dali::DaliException& e)
115 // Tests that a negative test of an assertion succeeds
116 DALI_TEST_PRINT_ASSERT(e);
117 DALI_TEST_CHECK(!model);
122 // Positive test case for a method
123 int UtcDaliModelNew(void)
125 ToolkitTestApplication application;
126 tet_infoline(" UtcDaliModelNew");
128 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
129 DALI_TEST_CHECK(model);
133 // Positive test case for a method
134 int UtcDaliModelDownCast(void)
136 ToolkitTestApplication application;
137 tet_infoline(" UtcDaliModelDownCast");
139 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
140 BaseHandle handle(model);
142 Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
143 DALI_TEST_CHECK(model);
144 DALI_TEST_CHECK(model2);
145 DALI_TEST_CHECK(model2 == model);
149 int UtcDaliModelTypeRegistry(void)
151 ToolkitTestApplication application;
153 TypeRegistry typeRegistry = TypeRegistry::Get();
154 DALI_TEST_CHECK(typeRegistry);
156 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
157 DALI_TEST_CHECK(typeInfo);
159 BaseHandle handle = typeInfo.CreateInstance();
160 DALI_TEST_CHECK(handle);
162 Scene3D::Model model = Scene3D::Model::DownCast(handle);
163 DALI_TEST_CHECK(model);
168 // Positive test case for a method
169 int UtcDaliModelAddRemove(void)
171 ToolkitTestApplication application;
172 tet_infoline(" UtcDaliModelAddRemove");
174 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
175 DALI_TEST_CHECK(model);
177 Actor actor = Actor::New();
178 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
180 model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
181 model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
183 application.GetScene().Add(model);
185 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
189 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
193 int UtcDaliModelCopyAndAssignment(void)
195 ToolkitTestApplication application;
197 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
198 DALI_TEST_CHECK(model);
200 Scene3D::Model copy(model);
201 DALI_TEST_CHECK(model == copy);
203 Scene3D::Model assign;
204 DALI_TEST_CHECK(!assign);
207 DALI_TEST_CHECK(assign == model);
212 int UtcDaliModelMoveConstructor(void)
214 ToolkitTestApplication application;
216 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
217 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
218 model.SetProperty(Actor::Property::SENSITIVE, false);
219 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
221 Scene3D::Model moved = std::move(model);
222 DALI_TEST_CHECK(moved);
223 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
224 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
225 DALI_TEST_CHECK(!model);
230 int UtcDaliModelMoveAssignment(void)
232 ToolkitTestApplication application;
234 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
235 DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
236 model.SetProperty(Actor::Property::SENSITIVE, false);
237 DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
239 Scene3D::Model moved;
240 moved = std::move(model);
241 DALI_TEST_CHECK(moved);
242 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
243 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
244 DALI_TEST_CHECK(!model);
249 int UtcDaliModelOnScene01(void)
251 ToolkitTestApplication application;
253 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
255 application.GetScene().Add(model);
257 application.SendNotification();
258 application.Render();
260 uint32_t modelCount = model.GetModelRoot().GetChildCount();
261 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
266 int UtcDaliModelOnScene02(void)
268 ToolkitTestApplication application;
270 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
272 application.GetScene().Add(model);
274 application.SendNotification();
275 application.Render();
277 uint32_t modelCount = model.GetModelRoot().GetChildCount();
278 DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
280 Actor rootActor = model.GetModelRoot();
281 Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
282 DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
287 int UtcDaliModelOnSizeSet(void)
289 ToolkitTestApplication application;
291 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
293 application.GetScene().Add(model);
295 application.SendNotification();
296 application.Render();
298 Vector2 size(200.0f, 300.0f);
299 model.SetProperty(Actor::Property::SIZE, size);
301 application.SendNotification();
302 application.Render();
304 DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
309 int UtcDaliModelGetNaturalSize(void)
311 ToolkitTestApplication application;
313 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
315 Vector3 naturalSize = model.GetNaturalSize();
317 DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
319 Actor root = model.GetModelRoot();
320 DALI_TEST_CHECK(root);
325 int UtcDaliModelSetImageBasedLightSource01(void)
327 ToolkitTestApplication application;
329 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
331 application.GetScene().Add(model);
333 application.SendNotification();
334 application.Render();
336 Actor meshActor = model.FindChildByName("AnimatedCube");
337 DALI_TEST_CHECK(meshActor);
339 Renderer renderer = meshActor.GetRendererAt(0u);
340 DALI_TEST_CHECK(renderer);
342 TextureSet textureSet = renderer.GetTextures();
343 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
345 Texture diffuseTexture = textureSet.GetTexture(7u);
346 Texture specularTexture = textureSet.GetTexture(8u);
348 model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
350 Texture newDiffuseTexture = textureSet.GetTexture(7u);
351 Texture newSpecularTexture = textureSet.GetTexture(8u);
353 DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
354 DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
359 int UtcDaliModelSetImageBasedLightSource02(void)
361 ToolkitTestApplication application;
363 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
365 application.GetScene().Add(model);
367 application.SendNotification();
368 application.Render();
370 Actor meshActor = model.FindChildByName("AnimatedCube");
371 DALI_TEST_CHECK(meshActor);
373 Renderer renderer = meshActor.GetRendererAt(0u);
374 DALI_TEST_CHECK(renderer);
376 TextureSet textureSet = renderer.GetTextures();
377 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
379 Texture diffuseTexture = textureSet.GetTexture(7u);
380 Texture specularTexture = textureSet.GetTexture(8u);
382 model.SetImageBasedLightSource("", "");
384 Texture newDiffuseTexture = textureSet.GetTexture(7u);
385 Texture newSpecularTexture = textureSet.GetTexture(8u);
387 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
388 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
393 int UtcDaliModelSetImageBasedLightSource03(void)
395 ToolkitTestApplication application;
397 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
399 application.GetScene().Add(model);
401 application.SendNotification();
402 application.Render();
404 Actor meshActor = model.FindChildByName("AnimatedCube");
405 DALI_TEST_CHECK(meshActor);
407 Renderer renderer = meshActor.GetRendererAt(0u);
408 DALI_TEST_CHECK(renderer);
410 TextureSet textureSet = renderer.GetTextures();
411 DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION);
413 Texture diffuseTexture = textureSet.GetTexture(7u);
414 Texture specularTexture = textureSet.GetTexture(8u);
416 model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
418 Texture newDiffuseTexture = textureSet.GetTexture(7u);
419 Texture newSpecularTexture = textureSet.GetTexture(8u);
421 DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
422 DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
427 int UtcDaliModelImageBasedFactor(void)
429 ToolkitTestApplication application;
431 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
433 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
435 model.SetImageBasedLightScaleFactor(0.5f);
436 DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
440 int UtcDaliModelChildrenSensitive01(void)
442 ToolkitTestApplication application;
444 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
445 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
446 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
447 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
448 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
450 // Get default vaule.
451 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
453 // Allow children actor's event before on scene.
454 view.SetChildrenSensitive(true);
455 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
457 application.GetScene().Add(view);
459 application.SendNotification();
460 application.Render();
462 Actor meshActor = view.FindChildByName("AnimatedCube");
463 DALI_TEST_CHECK(meshActor);
465 // connect hit-test signal
466 gTouchCallBackCalled = false;
467 meshActor.TouchedSignal().Connect(TestTouchCallback);
469 Vector2 sceneSize = application.GetScene().GetSize();
471 // Try to touch center of scene.
472 Dali::Integration::Point point;
473 point.SetState(PointState::DOWN);
474 point.SetScreenPosition(sceneSize * 0.5f);
475 Dali::Integration::TouchEvent event;
476 event.AddPoint(point);
478 // flush the queue and render once
479 application.SendNotification();
480 application.Render();
483 DALI_TEST_CHECK(!gTouchCallBackCalled);
484 application.ProcessEvent(event);
486 DALI_TEST_CHECK(gTouchCallBackCalled);
489 gTouchCallBackCalled = false;
491 // Block children actor's event
492 view.SetChildrenSensitive(false);
493 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
495 // flush the queue and render once
496 application.SendNotification();
497 application.Render();
500 DALI_TEST_CHECK(!gTouchCallBackCalled);
501 application.ProcessEvent(event);
503 DALI_TEST_CHECK(!gTouchCallBackCalled);
506 gTouchCallBackCalled = false;
509 view.SetChildrenSensitive(true);
510 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
512 // flush the queue and render once
513 application.SendNotification();
514 application.Render();
517 DALI_TEST_CHECK(!gTouchCallBackCalled);
518 application.ProcessEvent(event);
520 DALI_TEST_CHECK(gTouchCallBackCalled);
523 gTouchCallBackCalled = false;
528 int UtcDaliModelChildrenSensitive02(void)
530 ToolkitTestApplication application;
532 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
533 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
534 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
535 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
536 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
539 DALI_TEST_EQUALS(view.GetChildrenSensitive(), DEFAULT_MODEL_CHILDREN_SENSITIVE, TEST_LOCATION);
541 // Block children actor's event before on scene.
542 view.SetChildrenSensitive(false);
543 DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION);
545 application.GetScene().Add(view);
547 application.SendNotification();
548 application.Render();
550 Actor meshActor = view.FindChildByName("AnimatedCube");
551 DALI_TEST_CHECK(meshActor);
553 // connect hit-test signal
554 gTouchCallBackCalled = false;
555 meshActor.TouchedSignal().Connect(TestTouchCallback);
557 Vector2 sceneSize = application.GetScene().GetSize();
559 // Try to touch center of scene.
560 Dali::Integration::Point point;
561 point.SetState(PointState::DOWN);
562 point.SetScreenPosition(sceneSize * 0.5f);
563 Dali::Integration::TouchEvent event;
564 event.AddPoint(point);
566 // flush the queue and render once
567 application.SendNotification();
568 application.Render();
571 DALI_TEST_CHECK(!gTouchCallBackCalled);
572 application.ProcessEvent(event);
574 DALI_TEST_CHECK(!gTouchCallBackCalled);
577 gTouchCallBackCalled = false;
580 view.SetChildrenSensitive(true);
581 DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION);
583 // flush the queue and render once
584 application.SendNotification();
585 application.Render();
588 DALI_TEST_CHECK(!gTouchCallBackCalled);
589 application.ProcessEvent(event);
591 DALI_TEST_CHECK(gTouchCallBackCalled);
594 gTouchCallBackCalled = false;
599 int UtcDaliModelChildrenFocusable01(void)
601 ToolkitTestApplication application;
603 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
604 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
605 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
606 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
607 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
609 // Get vaule. Default is false.
610 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
612 // Allow children actor's focus before on scene.
613 view.SetChildrenFocusable(true);
614 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
616 application.GetScene().Add(view);
618 application.SendNotification();
619 application.Render();
621 Actor meshActor = view.FindChildByName("AnimatedCube");
622 DALI_TEST_CHECK(meshActor);
624 // Enable the default algorithm
625 KeyboardFocusManager manager = KeyboardFocusManager::Get();
626 DALI_TEST_CHECK(manager);
627 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
629 // connect focusable signal
630 gFocusChangedCallBackCalled = false;
631 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
632 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
634 // Initialize with some left-positioned actor
635 Control focusStartActor = Control::New();
636 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
637 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
638 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
639 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
640 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
641 application.GetScene().Add(focusStartActor);
644 manager.ClearFocus();
645 manager.SetCurrentFocusActor(focusStartActor);
646 gFocusChangedCallBackCalled = false;
648 // flush the queue and render once
649 application.SendNotification();
650 application.Render();
652 // Focusable view find success
653 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
654 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
657 manager.ClearFocus();
658 manager.SetCurrentFocusActor(focusStartActor);
659 gFocusChangedCallBackCalled = false;
661 // Block children actor's focus
662 view.SetChildrenFocusable(false);
663 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
665 // flush the queue and render once
666 application.SendNotification();
667 application.Render();
669 // Focusable view find failed
670 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
671 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
674 manager.ClearFocus();
675 manager.SetCurrentFocusActor(focusStartActor);
676 gFocusChangedCallBackCalled = false;
679 view.SetChildrenFocusable(true);
680 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
682 // flush the queue and render once
683 application.SendNotification();
684 application.Render();
686 // Focusable view find success
687 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
688 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
691 manager.ClearFocus();
692 manager.SetCurrentFocusActor(focusStartActor);
693 gFocusChangedCallBackCalled = false;
698 int UtcDaliModelModelChildrenFocusable02(void)
700 ToolkitTestApplication application;
702 Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
703 view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
704 view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0));
705 view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
706 view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
708 // Get vaule. Default is true.
709 DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION);
711 // Block children actor's focus before on scene.
712 view.SetChildrenFocusable(false);
713 DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION);
715 application.GetScene().Add(view);
717 application.SendNotification();
718 application.Render();
720 Actor meshActor = view.FindChildByName("AnimatedCube");
721 DALI_TEST_CHECK(meshActor);
723 // Enable the default algorithm
724 KeyboardFocusManager manager = KeyboardFocusManager::Get();
725 DALI_TEST_CHECK(manager);
726 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
728 // connect focusable signal
729 gFocusChangedCallBackCalled = false;
730 meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
731 manager.FocusChangedSignal().Connect(TestFocusChangedCallback);
733 // Initialize with some left-positioned actor
734 Control focusStartActor = Control::New();
735 focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100));
736 focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0));
737 focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
738 focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
739 focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true);
740 application.GetScene().Add(focusStartActor);
743 manager.ClearFocus();
744 manager.SetCurrentFocusActor(focusStartActor);
745 gFocusChangedCallBackCalled = false;
747 // flush the queue and render once
748 application.SendNotification();
749 application.Render();
751 // Focusable view find failed
752 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
753 DALI_TEST_CHECK(!gFocusChangedCallBackCalled);
756 manager.ClearFocus();
757 manager.SetCurrentFocusActor(focusStartActor);
758 gFocusChangedCallBackCalled = false;
761 view.SetChildrenFocusable(true);
762 DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION);
764 // flush the queue and render once
765 application.SendNotification();
766 application.Render();
768 // Focusable view find success
769 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
770 DALI_TEST_CHECK(gFocusChangedCallBackCalled);
773 manager.ClearFocus();
774 manager.SetCurrentFocusActor(focusStartActor);
775 gFocusChangedCallBackCalled = false;
780 int UtcDaliModelAnimation01(void)
782 ToolkitTestApplication application;
784 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
785 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
787 application.GetScene().Add(model);
789 application.SendNotification();
790 application.Render();
792 uint32_t animationCount = model.GetAnimationCount();
793 DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
795 Animation animationByIndex = model.GetAnimation(0u);
796 DALI_TEST_CHECK(animationByIndex);
798 Animation animationByName = model.GetAnimation("animation_AnimatedCube");
799 DALI_TEST_CHECK(animationByName);
800 DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
805 int UtcDaliModelAnimation02(void)
807 ToolkitTestApplication application;
809 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
810 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
812 application.GetScene().Add(model);
814 application.SendNotification();
815 application.Render();
817 uint32_t animationCount = model.GetAnimationCount();
818 DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
820 Animation animation1 = model.GetAnimation("Step Scale");
821 DALI_TEST_CHECK(animation1);
822 DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
824 Animation animation2 = model.GetAnimation("CubicSpline Scale");
825 DALI_TEST_CHECK(animation2);
826 DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
828 DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
833 int UtcDaliModelAnimation03(void)
835 ToolkitTestApplication application;
837 Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
838 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
840 application.GetScene().Add(model);
842 application.SendNotification();
843 application.Render();
845 uint32_t animationCount = model.GetAnimationCount();
846 DALI_TEST_EQUALS(18, animationCount, TEST_LOCATION);
848 Animation animationByIndex = model.GetAnimation(0u);
849 DALI_TEST_CHECK(animationByIndex);
851 Animation animationByName = model.GetAnimation("idleClip");
852 DALI_TEST_CHECK(animationByName);
853 DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
858 int UtcDaliModelMultiplePrimitives(void)
860 ToolkitTestApplication application;
862 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME);
863 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
865 application.GetScene().Add(model);
867 application.SendNotification();
868 application.Render();
870 Actor actor = model.FindChildByName("rootNode");
872 DALI_TEST_EQUALS(0, actor.GetChildCount(), TEST_LOCATION);
873 DALI_TEST_EQUALS(2, actor.GetRendererCount(), TEST_LOCATION);
878 int UtcDaliModelColorMode(void)
880 ToolkitTestApplication application;
882 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
883 model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
884 model.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
886 application.GetScene().Add(model);
888 application.SendNotification();
889 application.Render();
891 Actor actor = model.FindChildByName("AnimatedCube");
892 Vector4 childColor = actor[Dali::Actor::Property::COLOR];
893 Vector4 childWorldColor = actor[Dali::Actor::Property::WORLD_COLOR];
895 DALI_TEST_EQUALS(childColor, Color::WHITE, TEST_LOCATION);
896 DALI_TEST_EQUALS(childWorldColor, Color::RED, TEST_LOCATION);
904 static bool gOnRelayoutCallBackCalled = false;
905 void OnRelayoutCallback(Actor actor)
907 gOnRelayoutCallBackCalled = true;
910 static bool gResourceReadyCalled = false;
911 void OnResourceReady(Control control)
913 gResourceReadyCalled = true;
917 int UtcDaliModelResourceReady(void)
919 ToolkitTestApplication application;
921 gOnRelayoutCallBackCalled = false;
922 gResourceReadyCalled = false;
923 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
924 model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
925 model.OnRelayoutSignal().Connect(OnRelayoutCallback);
926 model.ResourceReadySignal().Connect(OnResourceReady);
927 DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
930 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
931 DALI_TEST_CHECK(!gResourceReadyCalled);
933 application.GetScene().Add(model);
935 application.SendNotification();
936 application.Render();
938 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
939 DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
940 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);