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-scene3d/public-api/controls/model/model.h>
24 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
25 #include <toolkit-event-thread-callback.h>
28 using namespace Dali::Toolkit;
30 void scene_view_startup(void)
32 test_return_value = TET_UNDEF;
35 void scene_view_cleanup(void)
37 test_return_value = TET_PASS;
43 * For the AnimatedCube.gltf and its Assets
44 * Donated by Norbert Nopper for glTF testing.
45 * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
47 const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
50 * For the diffuse and specular cube map texture.
51 * These textures are based off version of Wave engine sample
52 * Take from https://github.com/WaveEngine/Samples
54 * Copyright (c) 2022 Wave Coorporation
56 * Permission is hereby granted, free of charge, to any person obtaining a copy
57 * of this software and associated documentation files (the "Software"), to
58 * deal in the Software without restriction, including without limitation the
59 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
60 * sell copies of the Software, and to permit persons to whom the Software is
61 * furnished to do so, subject to the following conditions:
63 * The above copyright notice and this permission notice shall be included in
64 * all copies or substantial portions of the Software.
66 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
67 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
68 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
69 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
70 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
71 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
74 const char* TEST_EQUIRECTANGULAR_TEXTURE = TEST_RESOURCE_DIR "/application-icon-20.png";
75 const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
76 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
77 const char* TEST_DIFFUSE_TEXTURE2 = TEST_RESOURCE_DIR "//forest_irradiance.ktx";
78 const char* TEST_SPECULAR_TEXTURE2 = TEST_RESOURCE_DIR "//forest_radiance.ktx";
80 Dali::Texture GetDiffuseTexture(Dali::Scene3D::Model model)
82 Dali::Texture texture;
84 Actor meshActor = model.FindChildByName("AnimatedCube");
87 Renderer renderer = meshActor.GetRendererAt(0u);
90 TextureSet textureSet = renderer.GetTextures();
91 if(textureSet.GetTextureCount() == 9u)
93 texture = textureSet.GetTexture(7u);
101 Dali::Texture GetSpecularTexture(Dali::Scene3D::Model model)
103 Dali::Texture texture;
105 Actor meshActor = model.FindChildByName("AnimatedCube");
108 Renderer renderer = meshActor.GetRendererAt(0u);
111 TextureSet textureSet = renderer.GetTextures();
112 if(textureSet.GetTextureCount() == 9u)
114 texture = textureSet.GetTexture(8u);
124 static bool gOnRelayoutCallBackCalled = false;
125 void OnRelayoutCallback(Actor actor)
127 gOnRelayoutCallBackCalled = true;
130 static bool gResourceReadyCalled = false;
131 void OnResourceReady(Control control)
133 gResourceReadyCalled = true;
137 // Negative test case for a method
138 int UtcDaliSceneViewUninitialized(void)
140 ToolkitTestApplication application;
141 tet_infoline("UtcDaliSceneViewUninitialized");
143 Scene3D::SceneView view;
147 // New() must be called to create a Model or it wont be valid.
148 Actor a = Actor::New();
150 DALI_TEST_CHECK(false);
152 catch(Dali::DaliException& e)
154 // Tests that a negative test of an assertion succeeds
155 DALI_TEST_PRINT_ASSERT(e);
156 DALI_TEST_CHECK(!view);
161 // Positive test case for a method
162 int UtcDaliSceneViewNew(void)
164 ToolkitTestApplication application;
165 tet_infoline("UtcDaliSceneViewNew");
167 Scene3D::SceneView view = Scene3D::SceneView::New();
168 DALI_TEST_CHECK(view);
172 // Positive test case for a method
173 int UtcDaliSceneViewDownCast(void)
175 ToolkitTestApplication application;
176 tet_infoline("UtcDaliSceneViewDownCast");
178 Scene3D::SceneView view = Scene3D::SceneView::New();
179 BaseHandle handle(view);
181 Scene3D::SceneView sceneView = Scene3D::SceneView::DownCast(handle);
182 DALI_TEST_CHECK(view);
183 DALI_TEST_CHECK(sceneView);
184 DALI_TEST_CHECK(sceneView == view);
188 int UtcDaliSceneViewTypeRegistry(void)
190 ToolkitTestApplication application;
191 tet_infoline("UtcDaliSceneViewTypeRegistry");
193 TypeRegistry typeRegistry = TypeRegistry::Get();
194 DALI_TEST_CHECK(typeRegistry);
196 TypeInfo typeInfo = typeRegistry.GetTypeInfo("SceneView");
197 DALI_TEST_CHECK(typeInfo);
199 BaseHandle handle = typeInfo.CreateInstance();
200 DALI_TEST_CHECK(handle);
202 Scene3D::SceneView model = Scene3D::SceneView::DownCast(handle);
203 DALI_TEST_CHECK(model);
208 // Positive test case for a method
209 int UtcDaliSceneViewAddRemove(void)
211 ToolkitTestApplication application;
212 tet_infoline("UtcDaliSceneViewAddRemove");
214 Scene3D::SceneView view = Scene3D::SceneView::New();
215 DALI_TEST_CHECK(view);
216 DALI_TEST_EQUALS(1u, view.GetChildCount(), TEST_LOCATION);
218 Actor actor = Actor::New();
220 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
221 view.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
224 DALI_TEST_EQUALS(1u, view.GetChildCount(), TEST_LOCATION);
225 Actor layer = view.GetChildAt(0u);
227 DALI_TEST_EQUALS(2u, layer.GetChildCount(), TEST_LOCATION);
228 DALI_TEST_EQUALS(actor, layer.GetChildAt(1u), TEST_LOCATION); // index 0u is default camera
231 DALI_TEST_EQUALS(1u, layer.GetChildCount(), TEST_LOCATION);
235 int UtcDaliSceneViewCopyAndAssignment(void)
237 ToolkitTestApplication application;
239 Scene3D::SceneView view = Scene3D::SceneView::New();
240 DALI_TEST_CHECK(view);
242 Scene3D::SceneView copy(view);
243 DALI_TEST_CHECK(view == copy);
245 Scene3D::SceneView assign;
246 DALI_TEST_CHECK(!assign);
249 DALI_TEST_CHECK(assign == view);
254 int UtcDaliSceneViewMoveConstructor(void)
256 ToolkitTestApplication application;
258 Scene3D::SceneView view = Scene3D::SceneView::New();
259 DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION);
260 view.SetProperty(Actor::Property::SENSITIVE, false);
261 DALI_TEST_CHECK(false == view.GetProperty<bool>(Actor::Property::SENSITIVE));
263 Scene3D::SceneView moved = std::move(view);
264 DALI_TEST_CHECK(moved);
265 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
266 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
267 DALI_TEST_CHECK(!view);
272 int UtcDaliSceneViewMoveAssignment(void)
274 ToolkitTestApplication application;
276 Scene3D::SceneView view = Scene3D::SceneView::New();
277 DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION);
278 view.SetProperty(Actor::Property::SENSITIVE, false);
279 DALI_TEST_CHECK(false == view.GetProperty<bool>(Actor::Property::SENSITIVE));
281 Scene3D::SceneView moved;
282 moved = std::move(view);
283 DALI_TEST_CHECK(moved);
284 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
285 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
286 DALI_TEST_CHECK(!view);
291 int UtcDaliSceneViewOnScene01(void)
293 ToolkitTestApplication application;
295 Scene3D::SceneView view = Scene3D::SceneView::New();
297 DALI_TEST_EQUALS(1u, view.GetChildCount(), TEST_LOCATION);
298 Actor layer = view.GetChildAt(0u);
300 DALI_TEST_EQUALS(1u, layer.GetChildCount(), TEST_LOCATION);
302 application.GetScene().Add(view);
304 application.SendNotification();
305 application.Render();
307 // CameraActor is added on layer when on scene
308 DALI_TEST_EQUALS(1u, layer.GetChildCount(), TEST_LOCATION);
313 int UtcDaliSceneViewOnScene02(void)
315 ToolkitTestApplication application;
317 uint32_t renderTaskCount = application.GetScene().GetRenderTaskList().GetTaskCount();
318 DALI_TEST_EQUALS(1u, renderTaskCount, TEST_LOCATION);
320 Scene3D::SceneView view = Scene3D::SceneView::New();
322 renderTaskCount = application.GetScene().GetRenderTaskList().GetTaskCount();
323 DALI_TEST_EQUALS(1u, renderTaskCount, TEST_LOCATION);
325 application.GetScene().Add(view);
327 application.SendNotification();
328 application.Render();
331 renderTaskCount = application.GetScene().GetRenderTaskList().GetTaskCount();
332 DALI_TEST_EQUALS(2u, renderTaskCount, TEST_LOCATION);
334 RenderTask renderTask = application.GetScene().GetRenderTaskList().GetTask(1u);
335 CameraActor camera = renderTask.GetCameraActor();
337 CameraActor defaultCamera = renderTask.GetCameraActor();
338 DALI_TEST_CHECK(defaultCamera);
339 DALI_TEST_EQUALS(camera, defaultCamera, TEST_LOCATION);
340 DALI_TEST_EQUALS(defaultCamera, view.GetSelectedCamera(), TEST_LOCATION);
345 int UtcDaliSceneViewUserCamera(void)
347 ToolkitTestApplication application;
349 Scene3D::SceneView view = Scene3D::SceneView::New();
350 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
352 application.GetScene().Add(view);
354 application.SendNotification();
355 application.Render();
357 CameraActor defaultCamera = view.GetSelectedCamera();
358 CameraActor camera = Dali::CameraActor::New();
359 camera.SetProperty(Dali::Actor::Property::NAME, "camera");
360 view.AddCamera(camera);
361 view.SelectCamera("camera");
363 DALI_TEST_NOT_EQUALS(defaultCamera, view.GetSelectedCamera(), 0.0f, TEST_LOCATION);
364 DALI_TEST_EQUALS(camera, view.GetSelectedCamera(), TEST_LOCATION);
366 camera.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
367 camera.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
368 camera.SetFieldOfView(0.5f);
369 camera.SetNearClippingPlane(1.0f);
370 camera.SetFarClippingPlane(5000.0f);
371 camera.SetProperty(Dali::Actor::Property::POSITION, Vector3(20, 30, 40));
373 float fov = camera[Dali::CameraActor::Property::FIELD_OF_VIEW];
374 float nearPlain = camera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE];
375 float farPlain = camera[Dali::CameraActor::Property::FAR_PLANE_DISTANCE];
376 Vector3 cameraPosition = camera[Dali::Actor::Property::POSITION];
378 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(400, 300));
380 DALI_TEST_EQUALS(fov, camera.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), TEST_LOCATION);
381 DALI_TEST_EQUALS(nearPlain, camera.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), TEST_LOCATION);
382 DALI_TEST_EQUALS(farPlain, camera.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
383 DALI_TEST_EQUALS(cameraPosition, camera.GetProperty<Vector3>(Dali::Actor::Property::POSITION), TEST_LOCATION);
388 int UtcDaliSceneViewAddRemoveCamera(void)
390 ToolkitTestApplication application;
392 Scene3D::SceneView view = Scene3D::SceneView::New();
393 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
395 application.GetScene().Add(view);
397 application.SendNotification();
398 application.Render();
400 CameraActor camera0 = view.GetSelectedCamera();
401 camera0.SetProperty(Dali::Actor::Property::NAME, "camera0");
402 CameraActor camera1 = Dali::CameraActor::New();
403 camera1.SetProperty(Dali::Actor::Property::NAME, "camera1");
405 DALI_TEST_EQUALS(1u, view.GetCameraCount(), TEST_LOCATION);
406 view.AddCamera(camera1);
407 DALI_TEST_EQUALS(2u, view.GetCameraCount(), TEST_LOCATION);
409 DALI_TEST_EQUALS(camera0, view.GetCamera(0), TEST_LOCATION);
410 DALI_TEST_EQUALS(camera0, view.GetCamera("camera0"), TEST_LOCATION);
411 DALI_TEST_EQUALS(camera1, view.GetCamera(1), TEST_LOCATION);
412 DALI_TEST_EQUALS(camera1, view.GetCamera("camera1"), TEST_LOCATION);
414 DALI_TEST_EQUALS(camera0, view.GetSelectedCamera(), TEST_LOCATION);
415 view.SelectCamera(1); // 0 -> 1
416 DALI_TEST_EQUALS(camera1, view.GetSelectedCamera(), TEST_LOCATION);
417 view.SelectCamera("camera0"); // 1 -> 0
418 DALI_TEST_EQUALS(camera0, view.GetSelectedCamera(), TEST_LOCATION);
419 view.SelectCamera("camera1"); // 0 -> 1
420 DALI_TEST_EQUALS(camera1, view.GetSelectedCamera(), TEST_LOCATION);
421 view.SelectCamera(0); // 1 -> 0
422 DALI_TEST_EQUALS(camera0, view.GetSelectedCamera(), TEST_LOCATION);
424 view.SelectCamera(1); // 0 -> 1
425 DALI_TEST_EQUALS(camera1, view.GetSelectedCamera(), TEST_LOCATION);
426 DALI_TEST_EQUALS(2u, view.GetCameraCount(), TEST_LOCATION);
427 view.RemoveCamera(camera1); // 1 -> 0
428 DALI_TEST_EQUALS(camera0, view.GetSelectedCamera(), TEST_LOCATION);
429 DALI_TEST_EQUALS(1u, view.GetCameraCount(), TEST_LOCATION);
431 CameraActor defaultCamera = view.GetSelectedCamera();
432 DALI_TEST_CHECK(defaultCamera);
433 DALI_TEST_EQUALS(camera0, defaultCamera, TEST_LOCATION);
434 DALI_TEST_NOT_EQUALS(camera1, defaultCamera, 0.0f, TEST_LOCATION);
438 int UtcDaliSceneViewImageBasedLight01(void)
440 ToolkitTestApplication application;
442 Scene3D::SceneView view = Scene3D::SceneView::New();
443 view.ResourceReadySignal().Connect(OnResourceReady);
444 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
446 application.GetScene().Add(view);
448 application.SendNotification();
449 application.Render();
451 Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
452 Scene3D::Model modelView2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
453 Scene3D::Model modelView3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
454 view.Add(modelView1);
455 view.Add(modelView2);
457 application.SendNotification();
458 application.Render();
459 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
460 application.SendNotification();
461 application.Render();
463 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView2), 0.0f, TEST_LOCATION);
464 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView2), 0.0f, TEST_LOCATION);
465 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView3), 0.0f, TEST_LOCATION);
466 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView3), 0.0f, TEST_LOCATION);
468 gResourceReadyCalled = false;
469 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
470 view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
472 application.SendNotification();
473 application.Render();
475 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
476 application.SendNotification();
477 application.Render();
479 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
481 DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView2), TEST_LOCATION);
482 DALI_TEST_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView2), TEST_LOCATION);
483 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView3), 0.0f, TEST_LOCATION);
484 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView3), 0.0f, TEST_LOCATION);
486 view.Add(modelView3);
487 application.SendNotification();
488 application.Render();
489 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
490 application.SendNotification();
491 application.Render();
493 DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView3), TEST_LOCATION);
494 DALI_TEST_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView3), TEST_LOCATION);
496 view.Remove(modelView1);
498 gResourceReadyCalled = false;
499 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
500 view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE2, TEST_SPECULAR_TEXTURE2);
502 application.SendNotification();
503 application.Render();
505 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
506 application.SendNotification();
507 application.Render();
509 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
511 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView2), 0.0f, TEST_LOCATION);
512 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView2), 0.0f, TEST_LOCATION);
513 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView3), 0.0f, TEST_LOCATION);
514 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView3), 0.0f, TEST_LOCATION);
515 DALI_TEST_EQUALS(GetDiffuseTexture(modelView2), GetDiffuseTexture(modelView3), TEST_LOCATION);
516 DALI_TEST_EQUALS(GetSpecularTexture(modelView2), GetSpecularTexture(modelView3), TEST_LOCATION);
521 int UtcDaliSceneViewImageBasedLight02(void)
523 ToolkitTestApplication application;
525 Scene3D::SceneView view = Scene3D::SceneView::New();
526 view.ResourceReadySignal().Connect(OnResourceReady);
527 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
529 application.GetScene().Add(view);
531 application.SendNotification();
532 application.Render();
534 Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
535 modelView1.ResourceReadySignal().Connect(OnResourceReady);
536 view.Add(modelView1);
537 application.SendNotification();
538 application.Render();
539 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
540 application.SendNotification();
541 application.Render();
543 gResourceReadyCalled = false;
544 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
545 view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
547 application.SendNotification();
548 application.Render();
550 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
551 application.SendNotification();
552 application.Render();
554 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
556 Dali::Texture diffuseTexture = GetDiffuseTexture(modelView1);
557 Dali::Texture specularTexture = GetSpecularTexture(modelView1);
559 gResourceReadyCalled = false;
560 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
561 modelView1.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE2, TEST_SPECULAR_TEXTURE2);
563 application.SendNotification();
564 application.Render();
566 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
567 application.SendNotification();
568 application.Render();
570 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
572 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, 0.0f, TEST_LOCATION);
573 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), specularTexture, 0.0f, TEST_LOCATION);
574 diffuseTexture = GetDiffuseTexture(modelView1);
575 specularTexture = GetSpecularTexture(modelView1);
577 // reset SceneView IBL
578 view.SetImageBasedLightSource("", "");
579 DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, TEST_LOCATION);
580 DALI_TEST_EQUALS(GetSpecularTexture(modelView1), specularTexture, TEST_LOCATION);
582 modelView1.SetImageBasedLightSource("", "");
583 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, 0.0f, TEST_LOCATION);
584 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), specularTexture, 0.0f, TEST_LOCATION);
589 int UtcDaliSceneViewImageBasedLight03(void)
591 ToolkitTestApplication application;
593 Scene3D::SceneView view = Scene3D::SceneView::New();
594 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
595 view.ResourceReadySignal().Connect(OnResourceReady);
596 application.GetScene().Add(view);
598 application.SendNotification();
599 application.Render();
601 Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
602 view.Add(modelView1);
603 modelView1.SetImageBasedLightSource(TEST_SPECULAR_TEXTURE, TEST_DIFFUSE_TEXTURE);
605 application.SendNotification();
606 application.Render();
607 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
608 application.SendNotification();
609 application.Render();
611 Dali::Texture diffuseTexture = GetDiffuseTexture(modelView1);
612 Dali::Texture specularTexture = GetSpecularTexture(modelView1);
614 gResourceReadyCalled = false;
615 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
616 view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE2, TEST_SPECULAR_TEXTURE2);
618 application.SendNotification();
619 application.Render();
620 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
621 application.SendNotification();
622 application.Render();
624 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
626 DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, TEST_LOCATION);
627 DALI_TEST_EQUALS(GetSpecularTexture(modelView1), specularTexture, TEST_LOCATION);
629 modelView1.SetImageBasedLightSource("", "");
630 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, 0.0f, TEST_LOCATION);
631 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), specularTexture, 0.0f, TEST_LOCATION);
632 diffuseTexture = GetDiffuseTexture(modelView1);
633 specularTexture = GetSpecularTexture(modelView1);
635 // reset SceneView IBL
636 view.SetImageBasedLightSource("", "");
637 DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, 0.0f, TEST_LOCATION);
638 DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), specularTexture, 0.0f, TEST_LOCATION);
643 int UtcDaliSceneViewImageBasedFactor(void)
645 ToolkitTestApplication application;
647 Scene3D::SceneView view = Scene3D::SceneView::New();
648 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
650 application.GetScene().Add(view);
652 application.SendNotification();
653 application.Render();
655 Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
656 view.Add(modelView1);
658 DALI_TEST_EQUALS(view.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
659 DALI_TEST_EQUALS(modelView1.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
661 view.SetImageBasedLightScaleFactor(0.5f);
662 DALI_TEST_EQUALS(view.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
663 DALI_TEST_EQUALS(modelView1.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
667 int UtcDaliSceneViewUseFramebuffer01(void)
669 ToolkitTestApplication application;
671 Scene3D::SceneView view = Scene3D::SceneView::New();
672 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
674 application.GetScene().Add(view);
676 application.SendNotification();
677 application.Render();
679 bool useFramebuffer = view.IsUsingFramebuffer();
680 view.UseFramebuffer(true);
681 DALI_TEST_NOT_EQUALS(useFramebuffer, view.IsUsingFramebuffer(), 0.0f, TEST_LOCATION);
686 int UtcDaliSceneViewUseFramebuffer02(void)
688 ToolkitTestApplication application;
690 Scene3D::SceneView view = Scene3D::SceneView::New();
691 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
693 application.GetScene().Add(view);
695 application.SendNotification();
696 application.Render();
698 RenderTask renderTask = application.GetScene().GetRenderTaskList().GetTask(1u);
699 DALI_TEST_CHECK(!renderTask.GetFrameBuffer());
701 view.UseFramebuffer(true);
702 DALI_TEST_CHECK(renderTask.GetFrameBuffer());
704 view.UseFramebuffer(false);
705 DALI_TEST_CHECK(!renderTask.GetFrameBuffer());
707 view.UseFramebuffer(true);
708 DALI_TEST_CHECK(renderTask.GetFrameBuffer());
713 int UtcDaliSceneViewResourceReady(void)
715 ToolkitTestApplication application;
717 gOnRelayoutCallBackCalled = false;
718 gResourceReadyCalled = false;
719 Scene3D::SceneView view = Scene3D::SceneView::New();
720 view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
721 view.OnRelayoutSignal().Connect(OnRelayoutCallback);
722 view.ResourceReadySignal().Connect(OnResourceReady);
723 // SceneView::IsResourceReady() returns true by default.
724 DALI_TEST_EQUALS(view.IsResourceReady(), true, TEST_LOCATION);
727 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
728 DALI_TEST_CHECK(!gResourceReadyCalled);
730 application.GetScene().Add(view);
732 application.SendNotification();
733 application.Render();
735 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
736 DALI_TEST_EQUALS(view.IsResourceReady(), true, TEST_LOCATION);
737 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
739 gOnRelayoutCallBackCalled = false;
740 gResourceReadyCalled = false;
742 view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
744 application.SendNotification();
745 application.Render();
746 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
747 application.SendNotification();
748 application.Render();
750 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
751 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
756 int UtcDaliSceneViewSetSkybox(void)
758 ToolkitTestApplication application;
760 gResourceReadyCalled = false;
761 Scene3D::SceneView view = Scene3D::SceneView::New();
762 view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
763 view.ResourceReadySignal().Connect(OnResourceReady);
764 application.GetScene().Add(view);
766 application.SendNotification();
767 application.Render();
769 uint32_t childCount = view.GetChildAt(0u).GetChildCount();
770 view.SetSkybox(TEST_SPECULAR_TEXTURE);
772 gResourceReadyCalled = false;
773 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
775 application.SendNotification();
776 application.Render();
777 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
778 application.SendNotification();
779 application.Render();
781 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
783 DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount + 1, TEST_LOCATION);
791 int UtcDaliSceneViewSetSkyboxEquirectangular(void)
793 ToolkitTestApplication application;
795 gResourceReadyCalled = false;
796 Scene3D::SceneView view = Scene3D::SceneView::New();
797 view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
798 view.ResourceReadySignal().Connect(OnResourceReady);
799 application.GetScene().Add(view);
801 application.SendNotification();
802 application.Render();
804 uint32_t childCount = view.GetChildAt(0u).GetChildCount();
805 view.SetSkybox(TEST_EQUIRECTANGULAR_TEXTURE, Scene3D::SceneView::SkyboxType::EQUIRECTANGULAR);
807 gResourceReadyCalled = false;
808 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
810 application.SendNotification();
811 application.Render();
812 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
813 application.SendNotification();
814 application.Render();
816 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
818 DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount + 1, TEST_LOCATION);
826 int UtcDaliSceneViewSetSkyboxEmpty(void)
828 ToolkitTestApplication application;
830 gResourceReadyCalled = false;
831 Scene3D::SceneView view = Scene3D::SceneView::New();
832 view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
833 view.ResourceReadySignal().Connect(OnResourceReady);
834 application.GetScene().Add(view);
836 application.SendNotification();
837 application.Render();
839 uint32_t childCount = view.GetChildAt(0u).GetChildCount();
841 DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount, TEST_LOCATION);
849 int UtcDaliSceneViewSetSkyboxEquirectangularEmpty(void)
851 ToolkitTestApplication application;
853 gResourceReadyCalled = false;
854 Scene3D::SceneView view = Scene3D::SceneView::New();
855 view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
856 view.ResourceReadySignal().Connect(OnResourceReady);
857 application.GetScene().Add(view);
859 application.SendNotification();
860 application.Render();
862 uint32_t childCount = view.GetChildAt(0u).GetChildCount();
863 view.SetSkybox("", Scene3D::SceneView::SkyboxType::EQUIRECTANGULAR);
864 DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount, TEST_LOCATION);
872 int UtcDaliSceneViewSetSkyboxIntensity(void)
874 ToolkitTestApplication application;
876 Scene3D::SceneView view = Scene3D::SceneView::New();
877 view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
879 float intensity = 0.5f;
880 DALI_TEST_EQUALS(view.GetSkyboxIntensity(), 1.0f, TEST_LOCATION);
882 view.SetSkyboxIntensity(intensity);
883 DALI_TEST_EQUALS(view.GetSkyboxIntensity(), intensity, TEST_LOCATION);
888 int UtcDaliSceneViewSetSkyboxOrientation(void)
890 ToolkitTestApplication application;
892 Scene3D::SceneView view = Scene3D::SceneView::New();
893 view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
895 Dali::Quaternion orientation = Dali::Quaternion(Radian(0.5f), Vector3::YAXIS);
896 view.SetSkyboxOrientation(orientation);
897 DALI_TEST_EQUALS(view.GetSkyboxOrientation(), orientation, TEST_LOCATION);
902 int UtcDaliSceneViewSetImageBasedLightAndSkybox(void)
904 ToolkitTestApplication application;
906 Scene3D::SceneView view = Scene3D::SceneView::New();
907 view.ResourceReadySignal().Connect(OnResourceReady);
908 view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
909 view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
910 view.SetSkybox(TEST_SPECULAR_TEXTURE);
911 application.GetScene().Add(view);
913 // Check SceneView needs 3 trigger to load both of image based light and skybox.
914 gResourceReadyCalled = false;
915 DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
916 application.SendNotification();
917 application.Render();
918 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
919 application.SendNotification();
920 application.Render();
921 DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
926 int UtcDaliSceneViewCreateAndRemoveRenderTask(void)
928 ToolkitTestApplication application;
929 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
931 uint32_t renderTaskCount = taskList.GetTaskCount();
933 Scene3D::SceneView view = Scene3D::SceneView::New();
934 view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
936 DALI_TEST_EQUALS(renderTaskCount, application.GetScene().GetRenderTaskList().GetTaskCount(), TEST_LOCATION);
938 application.GetScene().Add(view);
940 DALI_TEST_EQUALS(renderTaskCount + 1, application.GetScene().GetRenderTaskList().GetTaskCount(), TEST_LOCATION);
944 DALI_TEST_EQUALS(renderTaskCount, application.GetScene().GetRenderTaskList().GetTaskCount(), TEST_LOCATION);
949 int UtcDaliSceneViewColorMode(void)
951 ToolkitTestApplication application;
953 Scene3D::SceneView view = Scene3D::SceneView::New();
954 application.GetScene().Add(view);
956 DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA), TEST_LOCATION);
958 view.UseFramebuffer(true);
960 DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_COLOR), TEST_LOCATION);
962 view.UseFramebuffer(false);
964 DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA), TEST_LOCATION);