[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-scene3d / utc-Dali-SceneView.cpp
1 /*
2  * Copyright (c) 2024 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <stdlib.h>
21 #include <iostream>
22
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>
26
27 using namespace Dali;
28 using namespace Dali::Toolkit;
29
30 void scene_view_startup(void)
31 {
32   test_return_value = TET_UNDEF;
33 }
34
35 void scene_view_cleanup(void)
36 {
37   test_return_value = TET_PASS;
38 }
39
40 namespace
41 {
42 /**
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
46  */
47 const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
48
49 /**
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
53  *
54  * Copyright (c) 2024 Wave Coorporation
55  *
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:
62  *
63  * The above copyright notice and this permission notice shall be included in
64  * all copies or substantial portions of the Software.
65  *
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
72  * THE SOFTWARE.
73  */
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";
79
80 Dali::Texture GetDiffuseTexture(Dali::Scene3D::Model model)
81 {
82   Dali::Texture texture;
83
84   Actor meshActor = model.FindChildByName("AnimatedCube");
85   if(meshActor)
86   {
87     Renderer renderer = meshActor.GetRendererAt(0u);
88     if(renderer)
89     {
90       TextureSet textureSet = renderer.GetTextures();
91       if(textureSet.GetTextureCount() == 10u)
92       {
93         texture = textureSet.GetTexture(8u);
94       }
95     }
96   }
97
98   return texture;
99 }
100
101 Dali::Texture GetSpecularTexture(Dali::Scene3D::Model model)
102 {
103   Dali::Texture texture;
104
105   Actor meshActor = model.FindChildByName("AnimatedCube");
106   if(meshActor)
107   {
108     Renderer renderer = meshActor.GetRendererAt(0u);
109     if(renderer)
110     {
111       TextureSet textureSet = renderer.GetTextures();
112       if(textureSet.GetTextureCount() == 10u)
113       {
114         texture = textureSet.GetTexture(9u);
115       }
116     }
117   }
118
119   return texture;
120 }
121
122 // For ResourceReady
123 static bool gOnRelayoutCallBackCalled = false;
124 void        OnRelayoutCallback(Actor actor)
125 {
126   gOnRelayoutCallBackCalled = true;
127 }
128
129 static bool gResourceReadyCalled = false;
130 void        OnResourceReady(Control control)
131 {
132   gResourceReadyCalled = true;
133 }
134 } // namespace
135
136 // Negative test case for a method
137 int UtcDaliSceneViewUninitialized(void)
138 {
139   ToolkitTestApplication application;
140   tet_infoline("UtcDaliSceneViewUninitialized");
141
142   Scene3D::SceneView view;
143
144   try
145   {
146     // New() must be called to create a Model or it wont be valid.
147     Actor a = Actor::New();
148     view.Add(a);
149     DALI_TEST_CHECK(false);
150   }
151   catch(Dali::DaliException& e)
152   {
153     // Tests that a negative test of an assertion succeeds
154     DALI_TEST_PRINT_ASSERT(e);
155     DALI_TEST_CHECK(!view);
156   }
157   END_TEST;
158 }
159
160 // Positive test case for a method
161 int UtcDaliSceneViewNew(void)
162 {
163   ToolkitTestApplication application;
164   tet_infoline("UtcDaliSceneViewNew");
165
166   Scene3D::SceneView view = Scene3D::SceneView::New();
167   DALI_TEST_CHECK(view);
168   END_TEST;
169 }
170
171 // Positive test case for a method
172 int UtcDaliSceneViewDownCast(void)
173 {
174   ToolkitTestApplication application;
175   tet_infoline("UtcDaliSceneViewDownCast");
176
177   Scene3D::SceneView view = Scene3D::SceneView::New();
178   BaseHandle         handle(view);
179
180   Scene3D::SceneView sceneView = Scene3D::SceneView::DownCast(handle);
181   DALI_TEST_CHECK(view);
182   DALI_TEST_CHECK(sceneView);
183   DALI_TEST_CHECK(sceneView == view);
184   END_TEST;
185 }
186
187 int UtcDaliSceneViewTypeRegistry(void)
188 {
189   ToolkitTestApplication application;
190   tet_infoline("UtcDaliSceneViewTypeRegistry");
191
192   TypeRegistry typeRegistry = TypeRegistry::Get();
193   DALI_TEST_CHECK(typeRegistry);
194
195   TypeInfo typeInfo = typeRegistry.GetTypeInfo("SceneView");
196   DALI_TEST_CHECK(typeInfo);
197
198   BaseHandle handle = typeInfo.CreateInstance();
199   DALI_TEST_CHECK(handle);
200
201   Scene3D::SceneView model = Scene3D::SceneView::DownCast(handle);
202   DALI_TEST_CHECK(model);
203
204   END_TEST;
205 }
206
207 // Positive test case for a method
208 int UtcDaliSceneViewAddRemove(void)
209 {
210   ToolkitTestApplication application;
211   tet_infoline("UtcDaliSceneViewAddRemove");
212
213   Scene3D::SceneView view = Scene3D::SceneView::New();
214   DALI_TEST_CHECK(view);
215   DALI_TEST_EQUALS(1u, view.GetChildCount(), TEST_LOCATION);
216
217   Actor actor = Actor::New();
218
219   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
220   view.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
221   view.Add(actor);
222
223   DALI_TEST_EQUALS(1u, view.GetChildCount(), TEST_LOCATION);
224   Actor layer = view.GetChildAt(0u);
225
226   DALI_TEST_EQUALS(2u, layer.GetChildCount(), TEST_LOCATION);
227   DALI_TEST_EQUALS(actor, layer.GetChildAt(1u), TEST_LOCATION); // index 0u is default camera
228
229   view.Remove(actor);
230   DALI_TEST_EQUALS(1u, layer.GetChildCount(), TEST_LOCATION);
231   END_TEST;
232 }
233
234 int UtcDaliSceneViewCopyAndAssignment(void)
235 {
236   ToolkitTestApplication application;
237
238   Scene3D::SceneView view = Scene3D::SceneView::New();
239   DALI_TEST_CHECK(view);
240
241   Scene3D::SceneView copy(view);
242   DALI_TEST_CHECK(view == copy);
243
244   Scene3D::SceneView assign;
245   DALI_TEST_CHECK(!assign);
246
247   assign = copy;
248   DALI_TEST_CHECK(assign == view);
249
250   END_TEST;
251 }
252
253 int UtcDaliSceneViewMoveConstructor(void)
254 {
255   ToolkitTestApplication application;
256
257   Scene3D::SceneView view = Scene3D::SceneView::New();
258   DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION);
259   view.SetProperty(Actor::Property::SENSITIVE, false);
260   DALI_TEST_CHECK(false == view.GetProperty<bool>(Actor::Property::SENSITIVE));
261
262   Scene3D::SceneView moved = std::move(view);
263   DALI_TEST_CHECK(moved);
264   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
265   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
266   DALI_TEST_CHECK(!view);
267
268   END_TEST;
269 }
270
271 int UtcDaliSceneViewMoveAssignment(void)
272 {
273   ToolkitTestApplication application;
274
275   Scene3D::SceneView view = Scene3D::SceneView::New();
276   DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION);
277   view.SetProperty(Actor::Property::SENSITIVE, false);
278   DALI_TEST_CHECK(false == view.GetProperty<bool>(Actor::Property::SENSITIVE));
279
280   Scene3D::SceneView moved;
281   moved = std::move(view);
282   DALI_TEST_CHECK(moved);
283   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
284   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
285   DALI_TEST_CHECK(!view);
286
287   END_TEST;
288 }
289
290 int UtcDaliSceneViewOnScene01(void)
291 {
292   ToolkitTestApplication application;
293
294   Scene3D::SceneView view = Scene3D::SceneView::New();
295
296   DALI_TEST_EQUALS(1u, view.GetChildCount(), TEST_LOCATION);
297   Actor layer = view.GetChildAt(0u);
298
299   DALI_TEST_EQUALS(1u, layer.GetChildCount(), TEST_LOCATION);
300
301   application.GetScene().Add(view);
302
303   application.SendNotification();
304   application.Render();
305
306   // CameraActor is added on layer when on scene
307   DALI_TEST_EQUALS(1u, layer.GetChildCount(), TEST_LOCATION);
308
309   END_TEST;
310 }
311
312 int UtcDaliSceneViewOnScene02(void)
313 {
314   ToolkitTestApplication application;
315
316   uint32_t baseRenderTaskCount = application.GetScene().GetRenderTaskList().GetTaskCount();
317
318   Scene3D::SceneView view = Scene3D::SceneView::New();
319
320   uint32_t renderTaskCount = application.GetScene().GetRenderTaskList().GetTaskCount();
321   DALI_TEST_EQUALS(baseRenderTaskCount, renderTaskCount, TEST_LOCATION);
322
323   application.GetScene().Add(view);
324
325   application.SendNotification();
326   application.Render();
327
328   renderTaskCount = application.GetScene().GetRenderTaskList().GetTaskCount();
329   DALI_TEST_EQUALS(baseRenderTaskCount + 1u, renderTaskCount, TEST_LOCATION);
330
331   RenderTask  renderTask = application.GetScene().GetRenderTaskList().GetTask(baseRenderTaskCount);
332   CameraActor camera     = renderTask.GetCameraActor();
333
334   CameraActor defaultCamera = renderTask.GetCameraActor();
335   DALI_TEST_CHECK(defaultCamera);
336   DALI_TEST_EQUALS(camera, defaultCamera, TEST_LOCATION);
337   DALI_TEST_EQUALS(defaultCamera, view.GetSelectedCamera(), TEST_LOCATION);
338
339   END_TEST;
340 }
341
342 int UtcDaliSceneViewUserCamera(void)
343 {
344   ToolkitTestApplication application;
345
346   Scene3D::SceneView view = Scene3D::SceneView::New();
347   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
348
349   application.GetScene().Add(view);
350
351   application.SendNotification();
352   application.Render();
353
354   CameraActor defaultCamera = view.GetSelectedCamera();
355   CameraActor camera        = Dali::CameraActor::New();
356   camera.SetProperty(Dali::Actor::Property::NAME, "camera");
357   view.AddCamera(camera);
358   view.SelectCamera("camera");
359
360   DALI_TEST_NOT_EQUALS(defaultCamera, view.GetSelectedCamera(), 0.0f, TEST_LOCATION);
361   DALI_TEST_EQUALS(camera, view.GetSelectedCamera(), TEST_LOCATION);
362
363   camera.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
364   camera.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
365   camera.SetFieldOfView(0.5f);
366   camera.SetNearClippingPlane(1.0f);
367   camera.SetFarClippingPlane(5000.0f);
368   camera.SetProperty(Dali::Actor::Property::POSITION, Vector3(20, 30, 40));
369
370   float   fov            = camera[Dali::CameraActor::Property::FIELD_OF_VIEW];
371   float   nearPlain      = camera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE];
372   float   farPlain       = camera[Dali::CameraActor::Property::FAR_PLANE_DISTANCE];
373   Vector3 cameraPosition = camera[Dali::Actor::Property::POSITION];
374
375   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(400, 300));
376
377   DALI_TEST_EQUALS(fov, camera.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), TEST_LOCATION);
378   DALI_TEST_EQUALS(nearPlain, camera.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), TEST_LOCATION);
379   DALI_TEST_EQUALS(farPlain, camera.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
380   DALI_TEST_EQUALS(cameraPosition, camera.GetProperty<Vector3>(Dali::Actor::Property::POSITION), TEST_LOCATION);
381
382   END_TEST;
383 }
384
385 int UtcDaliSceneViewAddRemoveCamera(void)
386 {
387   ToolkitTestApplication application;
388
389   Scene3D::SceneView view = Scene3D::SceneView::New();
390   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
391
392   application.GetScene().Add(view);
393
394   application.SendNotification();
395   application.Render();
396
397   CameraActor camera0 = view.GetSelectedCamera();
398   camera0.SetProperty(Dali::Actor::Property::NAME, "camera0");
399   CameraActor camera1 = Dali::CameraActor::New();
400   camera1.SetProperty(Dali::Actor::Property::NAME, "camera1");
401
402   DALI_TEST_EQUALS(1u, view.GetCameraCount(), TEST_LOCATION);
403   view.AddCamera(camera1);
404   DALI_TEST_EQUALS(2u, view.GetCameraCount(), TEST_LOCATION);
405
406   DALI_TEST_EQUALS(camera0, view.GetCamera(0), TEST_LOCATION);
407   DALI_TEST_EQUALS(camera0, view.GetCamera("camera0"), TEST_LOCATION);
408   DALI_TEST_EQUALS(camera1, view.GetCamera(1), TEST_LOCATION);
409   DALI_TEST_EQUALS(camera1, view.GetCamera("camera1"), TEST_LOCATION);
410
411   DALI_TEST_EQUALS(camera0, view.GetSelectedCamera(), TEST_LOCATION);
412   view.SelectCamera(1); // 0 -> 1
413   DALI_TEST_EQUALS(camera1, view.GetSelectedCamera(), TEST_LOCATION);
414   view.SelectCamera("camera0"); // 1 -> 0
415   DALI_TEST_EQUALS(camera0, view.GetSelectedCamera(), TEST_LOCATION);
416   view.SelectCamera("camera1"); // 0 -> 1
417   DALI_TEST_EQUALS(camera1, view.GetSelectedCamera(), TEST_LOCATION);
418   view.SelectCamera(0); // 1 -> 0
419   DALI_TEST_EQUALS(camera0, view.GetSelectedCamera(), TEST_LOCATION);
420
421   view.SelectCamera(1); // 0 -> 1
422   DALI_TEST_EQUALS(camera1, view.GetSelectedCamera(), TEST_LOCATION);
423   DALI_TEST_EQUALS(2u, view.GetCameraCount(), TEST_LOCATION);
424   view.RemoveCamera(camera1); // 1 -> 0
425   DALI_TEST_EQUALS(camera0, view.GetSelectedCamera(), TEST_LOCATION);
426   DALI_TEST_EQUALS(1u, view.GetCameraCount(), TEST_LOCATION);
427
428   CameraActor defaultCamera = view.GetSelectedCamera();
429   DALI_TEST_CHECK(defaultCamera);
430   DALI_TEST_EQUALS(camera0, defaultCamera, TEST_LOCATION);
431   DALI_TEST_NOT_EQUALS(camera1, defaultCamera, 0.0f, TEST_LOCATION);
432   END_TEST;
433 }
434
435 int UtcDaliSceneViewImageBasedLight01(void)
436 {
437   ToolkitTestApplication application;
438
439   Scene3D::SceneView view = Scene3D::SceneView::New();
440   view.ResourceReadySignal().Connect(OnResourceReady);
441   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
442
443   application.GetScene().Add(view);
444
445   application.SendNotification();
446   application.Render();
447
448   Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
449   Scene3D::Model modelView2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
450   Scene3D::Model modelView3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
451   view.Add(modelView1);
452   view.Add(modelView2);
453
454   application.SendNotification();
455   application.Render();
456   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
457   application.SendNotification();
458   application.Render();
459
460   DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView2), TEST_LOCATION);
461   DALI_TEST_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView2), TEST_LOCATION);
462   DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView3), 0.0f, TEST_LOCATION);
463   DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView3), 0.0f, TEST_LOCATION);
464
465   gResourceReadyCalled = false;
466   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
467   view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
468
469   application.SendNotification();
470   application.Render();
471
472   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
473   application.SendNotification();
474   application.Render();
475
476   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
477
478   DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView2), TEST_LOCATION);
479   DALI_TEST_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView2), TEST_LOCATION);
480   DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView3), 0.0f, TEST_LOCATION);
481   DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView3), 0.0f, TEST_LOCATION);
482
483   view.Add(modelView3);
484   application.SendNotification();
485   application.Render();
486   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
487   application.SendNotification();
488   application.Render();
489
490   DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView3), TEST_LOCATION);
491   DALI_TEST_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView3), TEST_LOCATION);
492
493   view.Remove(modelView1);
494
495   gResourceReadyCalled = false;
496   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
497   view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE2, TEST_SPECULAR_TEXTURE2);
498
499   application.SendNotification();
500   application.Render();
501
502   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
503   application.SendNotification();
504   application.Render();
505
506   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
507
508   DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView2), 0.0f, TEST_LOCATION);
509   DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView2), 0.0f, TEST_LOCATION);
510   DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), GetDiffuseTexture(modelView3), 0.0f, TEST_LOCATION);
511   DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), GetSpecularTexture(modelView3), 0.0f, TEST_LOCATION);
512   DALI_TEST_EQUALS(GetDiffuseTexture(modelView2), GetDiffuseTexture(modelView3), TEST_LOCATION);
513   DALI_TEST_EQUALS(GetSpecularTexture(modelView2), GetSpecularTexture(modelView3), TEST_LOCATION);
514
515   END_TEST;
516 }
517
518 int UtcDaliSceneViewImageBasedLight02(void)
519 {
520   ToolkitTestApplication application;
521
522   Scene3D::SceneView view = Scene3D::SceneView::New();
523   view.ResourceReadySignal().Connect(OnResourceReady);
524   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
525
526   application.GetScene().Add(view);
527
528   application.SendNotification();
529   application.Render();
530
531   Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
532   modelView1.ResourceReadySignal().Connect(OnResourceReady);
533   view.Add(modelView1);
534   application.SendNotification();
535   application.Render();
536   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
537   application.SendNotification();
538   application.Render();
539
540   gResourceReadyCalled = false;
541   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
542   view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
543
544   application.SendNotification();
545   application.Render();
546
547   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
548   application.SendNotification();
549   application.Render();
550
551   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
552
553   Dali::Texture diffuseTexture  = GetDiffuseTexture(modelView1);
554   Dali::Texture specularTexture = GetSpecularTexture(modelView1);
555
556   gResourceReadyCalled = false;
557   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
558   modelView1.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE2, TEST_SPECULAR_TEXTURE2);
559
560   application.SendNotification();
561   application.Render();
562
563   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
564   application.SendNotification();
565   application.Render();
566
567   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
568
569   DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, 0.0f, TEST_LOCATION);
570   DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), specularTexture, 0.0f, TEST_LOCATION);
571   diffuseTexture  = GetDiffuseTexture(modelView1);
572   specularTexture = GetSpecularTexture(modelView1);
573
574   // reset SceneView IBL
575   view.SetImageBasedLightSource("", "");
576   DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, TEST_LOCATION);
577   DALI_TEST_EQUALS(GetSpecularTexture(modelView1), specularTexture, TEST_LOCATION);
578
579   modelView1.SetImageBasedLightSource("", "");
580   DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, 0.0f, TEST_LOCATION);
581   DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), specularTexture, 0.0f, TEST_LOCATION);
582
583   END_TEST;
584 }
585
586 int UtcDaliSceneViewImageBasedLight03(void)
587 {
588   ToolkitTestApplication application;
589
590   Scene3D::SceneView view = Scene3D::SceneView::New();
591   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
592   view.ResourceReadySignal().Connect(OnResourceReady);
593   application.GetScene().Add(view);
594
595   application.SendNotification();
596   application.Render();
597
598   Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
599   view.Add(modelView1);
600   modelView1.SetImageBasedLightSource(TEST_SPECULAR_TEXTURE, TEST_DIFFUSE_TEXTURE);
601
602   application.SendNotification();
603   application.Render();
604   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
605   application.SendNotification();
606   application.Render();
607
608   Dali::Texture diffuseTexture  = GetDiffuseTexture(modelView1);
609   Dali::Texture specularTexture = GetSpecularTexture(modelView1);
610
611   gResourceReadyCalled = false;
612   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
613   view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE2, TEST_SPECULAR_TEXTURE2);
614
615   application.SendNotification();
616   application.Render();
617   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
618   application.SendNotification();
619   application.Render();
620
621   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
622
623   DALI_TEST_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, TEST_LOCATION);
624   DALI_TEST_EQUALS(GetSpecularTexture(modelView1), specularTexture, TEST_LOCATION);
625
626   modelView1.SetImageBasedLightSource("", "");
627   DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, 0.0f, TEST_LOCATION);
628   DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), specularTexture, 0.0f, TEST_LOCATION);
629   diffuseTexture  = GetDiffuseTexture(modelView1);
630   specularTexture = GetSpecularTexture(modelView1);
631
632   // reset SceneView IBL
633   view.SetImageBasedLightSource("", "");
634   DALI_TEST_NOT_EQUALS(GetDiffuseTexture(modelView1), diffuseTexture, 0.0f, TEST_LOCATION);
635   DALI_TEST_NOT_EQUALS(GetSpecularTexture(modelView1), specularTexture, 0.0f, TEST_LOCATION);
636
637   END_TEST;
638 }
639
640 int UtcDaliSceneViewImageBasedFactor(void)
641 {
642   ToolkitTestApplication application;
643
644   Scene3D::SceneView view = Scene3D::SceneView::New();
645   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
646
647   application.GetScene().Add(view);
648
649   application.SendNotification();
650   application.Render();
651
652   Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
653   view.Add(modelView1);
654
655   DALI_TEST_EQUALS(view.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
656   DALI_TEST_EQUALS(modelView1.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
657
658   view.SetImageBasedLightScaleFactor(0.5f);
659   DALI_TEST_EQUALS(view.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
660   DALI_TEST_EQUALS(modelView1.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
661   END_TEST;
662 }
663
664 int UtcDaliSceneViewUseFramebuffer01(void)
665 {
666   ToolkitTestApplication application;
667
668   Scene3D::SceneView view = Scene3D::SceneView::New();
669   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
670
671   application.GetScene().Add(view);
672
673   application.SendNotification();
674   application.Render();
675
676   bool useFramebuffer = view.IsUsingFramebuffer();
677   view.UseFramebuffer(true);
678   DALI_TEST_NOT_EQUALS(useFramebuffer, view.IsUsingFramebuffer(), 0.0f, TEST_LOCATION);
679
680   END_TEST;
681 }
682
683 int UtcDaliSceneViewUseFramebuffer02(void)
684 {
685   ToolkitTestApplication application;
686
687   uint32_t baseRenderTaskCount = application.GetScene().GetRenderTaskList().GetTaskCount();
688
689   Scene3D::SceneView view = Scene3D::SceneView::New();
690   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
691
692   application.GetScene().Add(view);
693
694   application.SendNotification();
695   application.Render();
696
697   RenderTask renderTask = application.GetScene().GetRenderTaskList().GetTask(baseRenderTaskCount);
698   DALI_TEST_CHECK(!renderTask.GetFrameBuffer());
699
700   view.UseFramebuffer(true);
701   DALI_TEST_CHECK(renderTask.GetFrameBuffer());
702
703   view.UseFramebuffer(false);
704   DALI_TEST_CHECK(!renderTask.GetFrameBuffer());
705
706   view.UseFramebuffer(true);
707   DALI_TEST_CHECK(renderTask.GetFrameBuffer());
708
709   END_TEST;
710 }
711
712 int UtcDaliSceneViewFramebufferMultiSamplingLevel(void)
713 {
714   ToolkitTestApplication application;
715
716   Scene3D::SceneView view = Scene3D::SceneView::New();
717   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
718
719   application.GetScene().Add(view);
720
721   application.SendNotification();
722   application.Render();
723
724   uint8_t expectValue        = 0u; // Default MultiSamplingLevel is 0.
725   uint8_t multiSamplingLevel = view.GetFramebufferMultiSamplingLevel();
726   DALI_TEST_EQUALS(multiSamplingLevel, expectValue, TEST_LOCATION);
727
728   expectValue = 4u; // Change value.
729   view.UseFramebuffer(true);
730   view.SetFramebufferMultiSamplingLevel(expectValue);
731
732   multiSamplingLevel = view.GetFramebufferMultiSamplingLevel();
733   DALI_TEST_EQUALS(multiSamplingLevel, expectValue, TEST_LOCATION);
734
735   // Note : we don't check multi sampling level is applied to framebuffer, or not.
736   view.UseFramebuffer(false);
737   expectValue = 2u; // Change value.
738   view.SetFramebufferMultiSamplingLevel(expectValue);
739
740   application.SendNotification();
741   application.Render();
742
743   multiSamplingLevel = view.GetFramebufferMultiSamplingLevel();
744   DALI_TEST_EQUALS(multiSamplingLevel, expectValue, TEST_LOCATION);
745
746   END_TEST;
747 }
748
749 int UtcDaliSceneViewResourceReady(void)
750 {
751   ToolkitTestApplication application;
752
753   gOnRelayoutCallBackCalled = false;
754   gResourceReadyCalled      = false;
755   Scene3D::SceneView view   = Scene3D::SceneView::New();
756   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
757   view.OnRelayoutSignal().Connect(OnRelayoutCallback);
758   view.ResourceReadySignal().Connect(OnResourceReady);
759   // SceneView::IsResourceReady() returns true by default.
760   DALI_TEST_EQUALS(view.IsResourceReady(), true, TEST_LOCATION);
761
762   // Sanity check
763   DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
764   DALI_TEST_CHECK(!gResourceReadyCalled);
765
766   application.GetScene().Add(view);
767
768   application.SendNotification();
769   application.Render();
770
771   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
772   DALI_TEST_EQUALS(view.IsResourceReady(), true, TEST_LOCATION);
773   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
774
775   gOnRelayoutCallBackCalled = false;
776   gResourceReadyCalled      = false;
777
778   view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
779
780   application.SendNotification();
781   application.Render();
782   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
783   application.SendNotification();
784   application.Render();
785
786   DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
787   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
788
789   END_TEST;
790 }
791
792 int UtcDaliSceneViewSetSkybox(void)
793 {
794   ToolkitTestApplication application;
795
796   gResourceReadyCalled    = false;
797   Scene3D::SceneView view = Scene3D::SceneView::New();
798   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
799   view.ResourceReadySignal().Connect(OnResourceReady);
800   application.GetScene().Add(view);
801
802   application.SendNotification();
803   application.Render();
804
805   uint32_t childCount = view.GetChildAt(0u).GetChildCount();
806   view.SetSkybox(TEST_SPECULAR_TEXTURE);
807
808   gResourceReadyCalled = false;
809   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
810
811   application.SendNotification();
812   application.Render();
813   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
814   application.SendNotification();
815   application.Render();
816
817   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
818
819   DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount + 1, TEST_LOCATION);
820
821   view.Unparent();
822   view.Reset();
823
824   END_TEST;
825 }
826
827 int UtcDaliSceneViewSetSkyboxEquirectangular(void)
828 {
829   ToolkitTestApplication application;
830
831   gResourceReadyCalled    = false;
832   Scene3D::SceneView view = Scene3D::SceneView::New();
833   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
834   view.ResourceReadySignal().Connect(OnResourceReady);
835   application.GetScene().Add(view);
836
837   application.SendNotification();
838   application.Render();
839
840   uint32_t childCount = view.GetChildAt(0u).GetChildCount();
841   view.SetSkyboxEnvironmentMapType(Scene3D::EnvironmentMapType::EQUIRECTANGULAR);
842   view.SetSkybox(TEST_EQUIRECTANGULAR_TEXTURE);
843
844   gResourceReadyCalled = false;
845   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
846
847   application.SendNotification();
848   application.Render();
849   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
850   application.SendNotification();
851   application.Render();
852
853   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
854
855   DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount + 1, TEST_LOCATION);
856
857   view.Unparent();
858   view.Reset();
859
860   END_TEST;
861 }
862
863 int UtcDaliSceneViewSetSkyboxEmpty(void)
864 {
865   ToolkitTestApplication application;
866
867   gResourceReadyCalled    = false;
868   Scene3D::SceneView view = Scene3D::SceneView::New();
869   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
870   view.ResourceReadySignal().Connect(OnResourceReady);
871   application.GetScene().Add(view);
872
873   application.SendNotification();
874   application.Render();
875
876   uint32_t childCount = view.GetChildAt(0u).GetChildCount();
877   view.SetSkybox("");
878   DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount, TEST_LOCATION);
879
880   view.Unparent();
881   view.Reset();
882
883   END_TEST;
884 }
885
886 int UtcDaliSceneViewSetSkyboxEmpty2(void)
887 {
888   ToolkitTestApplication application;
889
890   gResourceReadyCalled    = false;
891   Scene3D::SceneView view = Scene3D::SceneView::New();
892   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
893   view.ResourceReadySignal().Connect(OnResourceReady);
894   application.GetScene().Add(view);
895
896   application.SendNotification();
897   application.Render();
898
899   view.SetSkybox(TEST_EQUIRECTANGULAR_TEXTURE);
900
901   application.SendNotification();
902   application.Render();
903   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
904   application.SendNotification();
905   application.Render();
906
907   uint32_t childCount = view.GetChildAt(0u).GetChildCount();
908
909   view.SetSkybox("");
910   DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount - 1, TEST_LOCATION);
911
912   view.Unparent();
913   view.Reset();
914
915   END_TEST;
916 }
917
918 int UtcDaliSceneViewSetSkyboxEquirectangularEmpty(void)
919 {
920   ToolkitTestApplication application;
921
922   gResourceReadyCalled    = false;
923   Scene3D::SceneView view = Scene3D::SceneView::New();
924   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
925   view.ResourceReadySignal().Connect(OnResourceReady);
926   application.GetScene().Add(view);
927
928   application.SendNotification();
929   application.Render();
930
931   uint32_t childCount = view.GetChildAt(0u).GetChildCount();
932   view.SetSkybox("");
933   DALI_TEST_EQUALS(view.GetChildAt(0u).GetChildCount(), childCount, TEST_LOCATION);
934
935   view.Unparent();
936   view.Reset();
937
938   END_TEST;
939 }
940
941 int UtcDaliSceneViewSetSkyboxIntensity(void)
942 {
943   ToolkitTestApplication application;
944
945   Scene3D::SceneView view = Scene3D::SceneView::New();
946   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
947
948   float intensity = 0.5f;
949   DALI_TEST_EQUALS(view.GetSkyboxIntensity(), 1.0f, TEST_LOCATION);
950
951   view.SetSkyboxIntensity(intensity);
952   DALI_TEST_EQUALS(view.GetSkyboxIntensity(), intensity, TEST_LOCATION);
953
954   END_TEST;
955 }
956
957 int UtcDaliSceneViewSetSkyboxOrientation(void)
958 {
959   ToolkitTestApplication application;
960
961   Scene3D::SceneView view = Scene3D::SceneView::New();
962   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
963
964   Dali::Quaternion orientation = Dali::Quaternion(Radian(0.5f), Vector3::YAXIS);
965   view.SetSkyboxOrientation(orientation);
966   DALI_TEST_EQUALS(view.GetSkyboxOrientation(), orientation, TEST_LOCATION);
967
968   END_TEST;
969 }
970
971 int UtcDaliSceneViewSetImageBasedLightAndSkybox(void)
972 {
973   ToolkitTestApplication application;
974
975   Scene3D::SceneView view = Scene3D::SceneView::New();
976   view.ResourceReadySignal().Connect(OnResourceReady);
977   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
978   view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
979   view.SetSkybox(TEST_SPECULAR_TEXTURE);
980   application.GetScene().Add(view);
981
982   // Check SceneView needs 3 trigger to load both of image based light and skybox.
983   gResourceReadyCalled = false;
984   DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
985   application.SendNotification();
986   application.Render();
987   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
988   application.SendNotification();
989   application.Render();
990   DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
991
992   END_TEST;
993 }
994
995 int UtcDaliSceneViewCreateAndRemoveRenderTask(void)
996 {
997   ToolkitTestApplication application;
998   RenderTaskList         taskList = application.GetScene().GetRenderTaskList();
999
1000   uint32_t baseRenderTaskCount = taskList.GetTaskCount();
1001
1002   Scene3D::SceneView view = Scene3D::SceneView::New();
1003   view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1004
1005   DALI_TEST_EQUALS(baseRenderTaskCount, application.GetScene().GetRenderTaskList().GetTaskCount(), TEST_LOCATION);
1006
1007   application.GetScene().Add(view);
1008
1009   DALI_TEST_EQUALS(baseRenderTaskCount + 1, application.GetScene().GetRenderTaskList().GetTaskCount(), TEST_LOCATION);
1010
1011   view.Unparent();
1012
1013   DALI_TEST_EQUALS(baseRenderTaskCount, application.GetScene().GetRenderTaskList().GetTaskCount(), TEST_LOCATION);
1014
1015   END_TEST;
1016 }
1017
1018 int UtcDaliSceneViewColorMode(void)
1019 {
1020   ToolkitTestApplication application;
1021
1022   Scene3D::SceneView view = Scene3D::SceneView::New();
1023   application.GetScene().Add(view);
1024
1025   DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA), TEST_LOCATION);
1026
1027   view.UseFramebuffer(true);
1028
1029   DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_COLOR), TEST_LOCATION);
1030
1031   view.UseFramebuffer(false);
1032
1033   DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA), TEST_LOCATION);
1034
1035   END_TEST;
1036 }
1037
1038 int UtcDaliSceneViewSetResolution(void)
1039 {
1040   ToolkitTestApplication application;
1041
1042   Scene3D::SceneView view = Scene3D::SceneView::New();
1043   application.GetScene().Add(view);
1044   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
1045
1046   DALI_TEST_EQUALS(view.GetResolutionWidth(), 100u, TEST_LOCATION);
1047   DALI_TEST_EQUALS(view.GetResolutionHeight(), 100u, TEST_LOCATION);
1048
1049   view.SetResolution(200u, 200u);
1050
1051   DALI_TEST_EQUALS(view.GetResolutionWidth(), 100u, TEST_LOCATION);
1052   DALI_TEST_EQUALS(view.GetResolutionHeight(), 100u, TEST_LOCATION);
1053
1054   view.UseFramebuffer(true);
1055
1056   DALI_TEST_EQUALS(view.GetResolutionWidth(), 200u, TEST_LOCATION);
1057   DALI_TEST_EQUALS(view.GetResolutionHeight(), 200u, TEST_LOCATION);
1058
1059   view.SetResolution(300u, 0u);
1060
1061   DALI_TEST_EQUALS(view.GetResolutionWidth(), 100u, TEST_LOCATION);
1062   DALI_TEST_EQUALS(view.GetResolutionHeight(), 100u, TEST_LOCATION);
1063
1064   view.SetResolution(300u, 400u);
1065
1066   DALI_TEST_EQUALS(view.GetResolutionWidth(), 300u, TEST_LOCATION);
1067   DALI_TEST_EQUALS(view.GetResolutionHeight(), 400u, TEST_LOCATION);
1068
1069   view.ResetResolution();
1070
1071   DALI_TEST_EQUALS(view.GetResolutionWidth(), 100u, TEST_LOCATION);
1072   DALI_TEST_EQUALS(view.GetResolutionHeight(), 100u, TEST_LOCATION);
1073
1074   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(400, 400));
1075
1076   DALI_TEST_EQUALS(view.GetResolutionWidth(), 400u, TEST_LOCATION);
1077   DALI_TEST_EQUALS(view.GetResolutionHeight(), 400u, TEST_LOCATION);
1078
1079   END_TEST;
1080 }
1081
1082 int UtcDaliSceneViewSetResolution02(void)
1083 {
1084   tet_infoline("Test whether framebuffer created well base on inputed resolution");
1085   ToolkitTestApplication application;
1086   RenderTaskList         renderTaskList = application.GetScene().GetRenderTaskList();
1087
1088   uint32_t baseRenderTaskCount = renderTaskList.GetTaskCount();
1089
1090   Scene3D::SceneView view = Scene3D::SceneView::New();
1091   application.GetScene().Add(view);
1092   view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
1093
1094   DALI_TEST_EQUALS(view.GetResolutionWidth(), 100u, TEST_LOCATION);
1095   DALI_TEST_EQUALS(view.GetResolutionHeight(), 100u, TEST_LOCATION);
1096
1097   uint32_t expectWidth  = 83u;
1098   uint32_t expectHeight = 207u;
1099
1100   view.SetResolution(expectWidth, expectHeight);
1101
1102   DALI_TEST_EQUALS(view.GetResolutionWidth(), 100u, TEST_LOCATION);
1103   DALI_TEST_EQUALS(view.GetResolutionHeight(), 100u, TEST_LOCATION);
1104
1105   tet_printf("Test Framebuffer result target created well\n");
1106   view.UseFramebuffer(true);
1107
1108   RenderTask renderTask = renderTaskList.GetTask(baseRenderTaskCount);
1109   DALI_TEST_CHECK(renderTask);
1110
1111   FrameBuffer frameBuffer = renderTask.GetFrameBuffer();
1112   DALI_TEST_CHECK(frameBuffer);
1113
1114   DALI_TEST_EQUALS(view.GetResolutionWidth(), expectWidth, TEST_LOCATION);
1115   DALI_TEST_EQUALS(view.GetResolutionHeight(), expectHeight, TEST_LOCATION);
1116
1117   Texture renderTargetTexture = frameBuffer.GetColorTexture();
1118   DALI_TEST_CHECK(renderTargetTexture);
1119   DALI_TEST_EQUALS(renderTargetTexture.GetWidth(), expectWidth, TEST_LOCATION);
1120   DALI_TEST_EQUALS(renderTargetTexture.GetHeight(), expectHeight, TEST_LOCATION);
1121
1122   tet_printf("Test Framebuffer result target created well after create new FBO, by set multisampling level\n");
1123   view.SetFramebufferMultiSamplingLevel(2u);
1124
1125   renderTask = renderTaskList.GetTask(baseRenderTaskCount);
1126   DALI_TEST_CHECK(renderTask);
1127
1128   frameBuffer = renderTask.GetFrameBuffer();
1129   DALI_TEST_CHECK(frameBuffer);
1130
1131   DALI_TEST_EQUALS(view.GetResolutionWidth(), expectWidth, TEST_LOCATION);
1132   DALI_TEST_EQUALS(view.GetResolutionHeight(), expectHeight, TEST_LOCATION);
1133
1134   renderTargetTexture = frameBuffer.GetColorTexture();
1135   DALI_TEST_CHECK(renderTargetTexture);
1136
1137   DALI_TEST_EQUALS(renderTargetTexture.GetWidth(), expectWidth, TEST_LOCATION);
1138   DALI_TEST_EQUALS(renderTargetTexture.GetHeight(), expectHeight, TEST_LOCATION);
1139
1140   tet_printf("Test Framebuffer result target created well after change resolution\n");
1141   expectWidth  = 421u;
1142   expectHeight = 103u;
1143   view.SetResolution(expectWidth, expectHeight);
1144
1145   renderTask = renderTaskList.GetTask(baseRenderTaskCount);
1146   DALI_TEST_CHECK(renderTask);
1147
1148   frameBuffer = renderTask.GetFrameBuffer();
1149   DALI_TEST_CHECK(frameBuffer);
1150
1151   DALI_TEST_EQUALS(view.GetResolutionWidth(), expectWidth, TEST_LOCATION);
1152   DALI_TEST_EQUALS(view.GetResolutionHeight(), expectHeight, TEST_LOCATION);
1153
1154   renderTargetTexture = frameBuffer.GetColorTexture();
1155   DALI_TEST_CHECK(renderTargetTexture);
1156
1157   DALI_TEST_EQUALS(renderTargetTexture.GetWidth(), expectWidth, TEST_LOCATION);
1158   DALI_TEST_EQUALS(renderTargetTexture.GetHeight(), expectHeight, TEST_LOCATION);
1159
1160   END_TEST;
1161 }
1162
1163 namespace
1164 {
1165 const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
1166
1167 static constexpr std::string_view Y_FLIP_MASK_TEXTURE = "uYFlipMaskTexture";
1168 } // namespace
1169
1170 int UtcDaliSceneViewMasking(void)
1171 {
1172   ToolkitTestApplication application;
1173
1174   Scene3D::SceneView view = Scene3D::SceneView::New();
1175   application.GetScene().Add(view);
1176
1177   DALI_TEST_EQUALS(view.GetProperty<std::string>(Dali::Scene3D::SceneView::Property::ALPHA_MASK_URL), "", TEST_LOCATION);
1178   DALI_TEST_EQUALS(view.GetProperty<bool>(Dali::Scene3D::SceneView::Property::CROP_TO_MASK), true, TEST_LOCATION);
1179   DALI_TEST_EQUALS(view.GetProperty<float>(Dali::Scene3D::SceneView::Property::MASK_CONTENT_SCALE), 1.0f, TEST_LOCATION);
1180
1181   auto yFlipMaskTextureIndex = view.GetPropertyIndex(Y_FLIP_MASK_TEXTURE.data());
1182   DALI_TEST_EQUALS(yFlipMaskTextureIndex, Property::INVALID_INDEX, TEST_LOCATION);
1183
1184   view.UseFramebuffer(true);
1185   view.SetProperty(Dali::Scene3D::SceneView::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
1186   view.SetProperty(Dali::Scene3D::SceneView::Property::CROP_TO_MASK, false);
1187   view.SetProperty(Dali::Scene3D::SceneView::Property::MASK_CONTENT_SCALE, 0.5f);
1188
1189   DALI_TEST_EQUALS(view.GetProperty<std::string>(Dali::Scene3D::SceneView::Property::ALPHA_MASK_URL), TEST_MASK_IMAGE_FILE_NAME, TEST_LOCATION);
1190   DALI_TEST_EQUALS(view.GetProperty<bool>(Dali::Scene3D::SceneView::Property::CROP_TO_MASK), false, TEST_LOCATION);
1191   DALI_TEST_EQUALS(view.GetProperty<float>(Dali::Scene3D::SceneView::Property::MASK_CONTENT_SCALE), 0.5f, TEST_LOCATION);
1192
1193   yFlipMaskTextureIndex = view.GetPropertyIndex(std::string(Y_FLIP_MASK_TEXTURE));
1194   DALI_TEST_EQUALS(view.GetProperty<float>(yFlipMaskTextureIndex), 1.0f, TEST_LOCATION);
1195
1196   END_TEST;
1197 }