2 * Copyright (c) 2023 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>
20 #include <dali/devel-api/actors/actor-devel.h>
24 #include <dali-scene3d/public-api/controls/model/model.h>
25 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
26 #include <dali-scene3d/public-api/light/light.h>
27 #include <toolkit-event-thread-callback.h>
30 using namespace Dali::Toolkit;
32 void light_startup(void)
34 test_return_value = TET_UNDEF;
37 void light_cleanup(void)
39 test_return_value = TET_PASS;
44 const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/BoxAnimated.gltf";
47 // Negative test case for a method
48 int UtcDaliLightUninitialized(void)
50 ToolkitTestApplication application;
51 tet_infoline("UtcDaliLightUninitialized");
57 // New() must be called to create a Model or it wont be valid.
58 Actor a = Actor::New();
60 DALI_TEST_CHECK(false);
62 catch(Dali::DaliException& e)
64 // Tests that a negative test of an assertion succeeds
65 DALI_TEST_PRINT_ASSERT(e);
66 DALI_TEST_CHECK(!light);
71 // Positive test case for a method
72 int UtcDaliLightNew(void)
74 ToolkitTestApplication application;
75 tet_infoline("UtcDaliLightNew");
77 Scene3D::Light light = Scene3D::Light::New();
78 DALI_TEST_CHECK(light);
82 // Positive test case for a method
83 int UtcDaliLightDownCast(void)
85 ToolkitTestApplication application;
86 tet_infoline("UtcDaliLightDownCast");
88 Scene3D::Light light = Scene3D::Light::New();
89 BaseHandle handle(light);
91 Scene3D::Light light2 = Scene3D::Light::DownCast(handle);
92 DALI_TEST_CHECK(light);
93 DALI_TEST_CHECK(light2);
94 DALI_TEST_CHECK(light == light2);
98 // Positive test case for a method
99 int UtcDaliLightCopyAndAssignment(void)
101 ToolkitTestApplication application;
103 Scene3D::Light light = Scene3D::Light::New();
104 DALI_TEST_CHECK(light);
106 Scene3D::Light copy(light);
107 DALI_TEST_CHECK(light == copy);
109 Scene3D::Light assign;
110 DALI_TEST_CHECK(!assign);
113 DALI_TEST_CHECK(assign == light);
118 int UtcDaliLightMoveConstructor(void)
120 ToolkitTestApplication application;
122 Scene3D::Light light = Scene3D::Light::New();
123 DALI_TEST_EQUALS(1, light.GetBaseObject().ReferenceCount(), TEST_LOCATION);
124 light.SetProperty(Actor::Property::SENSITIVE, false);
125 DALI_TEST_CHECK(false == light.GetProperty<bool>(Actor::Property::SENSITIVE));
127 Scene3D::Light moved = std::move(light);
128 DALI_TEST_CHECK(moved);
129 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
130 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
131 DALI_TEST_CHECK(!light);
136 int UtcDaliLightMoveAssignment(void)
138 ToolkitTestApplication application;
140 Scene3D::Light light = Scene3D::Light::New();
141 DALI_TEST_EQUALS(1, light.GetBaseObject().ReferenceCount(), TEST_LOCATION);
142 light.SetProperty(Actor::Property::SENSITIVE, false);
143 DALI_TEST_CHECK(false == light.GetProperty<bool>(Actor::Property::SENSITIVE));
145 Scene3D::Light moved;
146 moved = std::move(light);
147 DALI_TEST_CHECK(moved);
148 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
149 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
150 DALI_TEST_CHECK(!light);
156 int UtcDaliLightSize(void)
158 ToolkitTestApplication application;
160 Scene3D::Light light = Scene3D::Light::New();
161 application.GetScene().Add(light);
163 application.SendNotification();
164 application.Render();
166 light.SetProperty(Dali::Actor::Property::SIZE, Vector3::ONE);
167 DALI_TEST_EQUALS(Vector3::ONE, light.GetProperty<Vector3>(Dali::Actor::Property::SIZE), 0.01f, TEST_LOCATION);
168 DALI_TEST_EQUALS(Vector3::ZERO, light.GetNaturalSize(), 0.01f, TEST_LOCATION);
170 application.SendNotification();
171 application.Render();
173 light.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FIXED);
174 DALI_TEST_EQUALS(ResizePolicy::FIXED, light.GetProperty<ResizePolicy::Type>(Dali::Actor::Property::WIDTH_RESIZE_POLICY), TEST_LOCATION);
176 application.SendNotification();
177 application.Render();
179 float widthForHeight = light.GetWidthForHeight(light.GetProperty<float>(Dali::Actor::Property::SIZE_HEIGHT));
180 float heightForWidth = light.GetHeightForWidth(light.GetProperty<float>(Dali::Actor::Property::SIZE_WIDTH));
181 DALI_TEST_EQUALS(0.0f, widthForHeight, 0.01f, TEST_LOCATION);
182 DALI_TEST_EQUALS(0.0f, heightForWidth, 0.01f, TEST_LOCATION);
187 int UtcDaliLightOnScene01(void)
189 ToolkitTestApplication application;
191 Scene3D::Light light = Scene3D::Light::New();
192 application.GetScene().Add(light);
194 application.SendNotification();
195 application.Render();
197 // Light is added on layer when on scene
198 DALI_TEST_EQUALS(true, light.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
200 application.GetScene().Remove(light);
202 application.SendNotification();
203 application.Render();
205 // Light is removed from layer when on scene
206 DALI_TEST_EQUALS(false, light.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE), TEST_LOCATION);
211 // Add a light on SceneView directly
212 int UtcDaliLightAdd01(void)
214 ToolkitTestApplication application;
215 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
216 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
217 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
218 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
219 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
220 application.GetScene().Add(sceneView);
222 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
223 sceneView.Add(model);
225 application.SendNotification();
226 application.Render();
227 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
228 application.SendNotification();
229 application.Render();
231 Scene3D::Light light = Scene3D::Light::New();
232 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
233 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
234 sceneView.Add(light);
236 application.SendNotification();
237 application.Render();
239 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
240 DALI_TEST_CHECK(renderer);
242 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
243 auto countPropertyIndex = renderer.GetPropertyIndex("uLightCount");
244 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
245 DALI_TEST_EQUALS(1, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
246 auto colorPropertyIndex = renderer.GetPropertyIndex("uLightColor[0]");
247 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), renderer.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
248 auto directionPropertyIndex = renderer.GetPropertyIndex("uLightDirection[0]");
249 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), renderer.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
253 DALI_TEST_EQUALS(0u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
254 DALI_TEST_EQUALS(0, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
259 // Add a light on an Actor that is child of SceneView.
260 int UtcDaliLightAdd02(void)
262 ToolkitTestApplication application;
264 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
265 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
266 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
267 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
268 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
269 application.GetScene().Add(sceneView);
271 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
272 sceneView.Add(model);
274 application.SendNotification();
275 application.Render();
276 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
277 application.SendNotification();
278 application.Render();
280 Actor actor = Actor::New();
281 sceneView.Add(actor);
283 Scene3D::Light light = Scene3D::Light::New();
284 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
285 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
288 application.SendNotification();
289 application.Render();
291 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
292 DALI_TEST_CHECK(renderer);
294 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
295 auto countPropertyIndex = renderer.GetPropertyIndex("uLightCount");
296 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
297 DALI_TEST_EQUALS(1, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
298 auto colorPropertyIndex = renderer.GetPropertyIndex("uLightColor[0]");
299 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), renderer.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
300 auto directionPropertyIndex = renderer.GetPropertyIndex("uLightDirection[0]");
301 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), renderer.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
305 DALI_TEST_EQUALS(0u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
306 DALI_TEST_EQUALS(0, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
311 // Enable a light after it is added on SceneView.
312 int UtcDaliLightAdd03(void)
314 ToolkitTestApplication application;
316 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
317 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
318 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
319 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
320 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
321 application.GetScene().Add(sceneView);
323 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
324 sceneView.Add(model);
326 application.SendNotification();
327 application.Render();
328 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
329 application.SendNotification();
330 application.Render();
332 Scene3D::Light light = Scene3D::Light::New();
333 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
334 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
336 sceneView.Add(light);
338 application.SendNotification();
339 application.Render();
341 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
342 DALI_TEST_CHECK(renderer);
344 DALI_TEST_EQUALS(0u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
345 auto countPropertyIndex = renderer.GetPropertyIndex("uLightCount");
346 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
347 DALI_TEST_EQUALS(0, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
351 application.SendNotification();
352 application.Render();
354 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
355 DALI_TEST_EQUALS(1, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
356 auto colorPropertyIndex = renderer.GetPropertyIndex("uLightColor[0]");
357 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), renderer.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
358 auto directionPropertyIndex = renderer.GetPropertyIndex("uLightDirection[0]");
359 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), renderer.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
363 application.SendNotification();
364 application.Render();
366 DALI_TEST_EQUALS(0u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
367 DALI_TEST_EQUALS(0, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
372 int UtcDaliLightAdd04(void)
374 ToolkitTestApplication application;
376 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
377 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
378 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
379 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
380 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
381 application.GetScene().Add(sceneView);
383 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
384 sceneView.Add(model);
386 application.SendNotification();
387 application.Render();
388 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
389 application.SendNotification();
390 application.Render();
392 Scene3D::Light light1 = Scene3D::Light::New();
393 light1.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
394 Dali::DevelActor::LookAt(light1, Vector3(1.0f, 0.0f, 0.0f));
395 sceneView.Add(light1);
397 Scene3D::Light light2 = Scene3D::Light::New();
398 light2.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
399 Dali::DevelActor::LookAt(light2, Vector3(0.0f, 0.0f, -1.0f));
400 sceneView.Add(light2);
402 application.SendNotification();
403 application.Render();
405 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
406 DALI_TEST_CHECK(renderer);
408 DALI_TEST_EQUALS(2u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
409 auto countPropertyIndex = renderer.GetPropertyIndex("uLightCount");
410 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
411 DALI_TEST_EQUALS(2, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
412 auto colorPropertyIndex1 = renderer.GetPropertyIndex("uLightColor[0]");
413 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), renderer.GetCurrentProperty<Vector3>(colorPropertyIndex1), 0.01f, TEST_LOCATION);
414 auto directionPropertyIndex1 = renderer.GetPropertyIndex("uLightDirection[0]");
415 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), renderer.GetCurrentProperty<Vector3>(directionPropertyIndex1), 0.01f, TEST_LOCATION);
416 auto colorPropertyIndex2 = renderer.GetPropertyIndex("uLightColor[1]");
417 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), renderer.GetCurrentProperty<Vector3>(colorPropertyIndex2), 0.01f, TEST_LOCATION);
418 auto directionPropertyIndex2 = renderer.GetPropertyIndex("uLightDirection[1]");
419 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, -1.0f), renderer.GetCurrentProperty<Vector3>(directionPropertyIndex2), 0.01f, TEST_LOCATION);
421 light1.Enable(false);
423 application.SendNotification();
424 application.Render();
426 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
427 DALI_TEST_EQUALS(1, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
429 // After light1 is disable, shader uniforms of lights are reordered.
430 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), renderer.GetCurrentProperty<Vector3>(colorPropertyIndex1), 0.01f, TEST_LOCATION);
431 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, -1.0f), renderer.GetCurrentProperty<Vector3>(directionPropertyIndex1), 0.01f, TEST_LOCATION);
436 // Check unactivated light in SceneView becomes activated when a light become disabled.
437 int UtcDaliLightAdd05(void)
439 ToolkitTestApplication application;
441 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
442 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
443 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
444 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
445 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
446 application.GetScene().Add(sceneView);
448 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
449 sceneView.Add(model);
451 application.SendNotification();
452 application.Render();
453 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
454 application.SendNotification();
455 application.Render();
457 uint32_t maxLightCount = Scene3D::Light::GetMaximumEnabledLightCount();
458 std::vector<Scene3D::Light> lightList;
459 for(uint32_t i = 0; i < maxLightCount; ++i)
461 Scene3D::Light light = Scene3D::Light::New();
462 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
463 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
464 sceneView.Add(light);
465 lightList.push_back(light);
468 Scene3D::Light light2 = Scene3D::Light::New();
469 light2.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
470 Dali::DevelActor::LookAt(light2, Vector3(0.0f, 0.0f, -1.0f));
471 sceneView.Add(light2);
472 lightList.push_back(light2);
474 application.SendNotification();
475 application.Render();
477 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
478 DALI_TEST_CHECK(renderer);
480 std::vector<int32_t> enableAnswers;
481 enableAnswers.assign(maxLightCount, 1);
483 DALI_TEST_EQUALS(maxLightCount, sceneView.GetActivatedLightCount(), TEST_LOCATION);
484 auto countPropertyIndex = renderer.GetPropertyIndex("uLightCount");
485 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
486 DALI_TEST_EQUALS(static_cast<int32_t>(maxLightCount), renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
487 for(uint32_t i = 0; i < maxLightCount; ++i)
489 std::string colorStringKey = std::string("uLightColor[") + std::to_string(i) + "]";
490 auto colorPropertyIndex = renderer.GetPropertyIndex(colorStringKey);
491 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), renderer.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
493 std::string directionStringKey = std::string("uLightDirection[") + std::to_string(i) + "]";
494 auto directionPropertyIndex = renderer.GetPropertyIndex(directionStringKey);
495 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), renderer.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
498 lightList[2].Enable(false);
500 application.SendNotification();
501 application.Render();
503 DALI_TEST_EQUALS(maxLightCount, sceneView.GetActivatedLightCount(), TEST_LOCATION);
504 DALI_TEST_EQUALS(static_cast<int32_t>(maxLightCount), renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
505 for(uint32_t i = 0; i < maxLightCount; ++i)
507 Vector3 color, direction;
510 color = Vector3(1.0f, 0.0f, 0.0f);
511 direction = Vector3(0.0f, 0.0f, -1.0f);
515 color = Vector3(0.0f, 0.0f, 1.0f);
516 direction = Vector3(1.0f, 0.0f, 0.0f);
518 std::string colorStringKey = std::string("uLightColor[") + std::to_string(i) + "]";
519 auto colorPropertyIndex = renderer.GetPropertyIndex(colorStringKey);
520 DALI_TEST_EQUALS(color, renderer.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
522 std::string directionStringKey = std::string("uLightDirection[") + std::to_string(i) + "]";
523 auto directionPropertyIndex = renderer.GetPropertyIndex(directionStringKey);
524 DALI_TEST_EQUALS(direction, renderer.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
527 for(uint32_t i = 0; i < lightList.size(); ++i)
531 DALI_TEST_EQUALS(false, lightList[i].IsEnabled(), TEST_LOCATION);
535 DALI_TEST_EQUALS(true, lightList[i].IsEnabled(), TEST_LOCATION);
542 int UtcDaliLightModelAddAndRemove(void)
544 ToolkitTestApplication application;
546 Scene3D::SceneView sceneView = Scene3D::SceneView::New();
547 sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
548 sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
549 sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
550 sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
551 application.GetScene().Add(sceneView);
553 Scene3D::Light light = Scene3D::Light::New();
554 light.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
555 Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f));
556 sceneView.Add(light);
558 application.SendNotification();
559 application.Render();
561 Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
562 sceneView.Add(model);
564 application.SendNotification();
565 application.Render();
566 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
567 application.SendNotification();
568 application.Render();
570 Renderer renderer = model.FindChildByName("node2").GetRendererAt(0u);
571 DALI_TEST_CHECK(renderer);
573 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
574 auto countPropertyIndex = renderer.GetPropertyIndex("uLightCount");
575 DALI_TEST_CHECK(countPropertyIndex != DALI_KEY_INVALID);
576 DALI_TEST_EQUALS(1, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);
578 auto colorPropertyIndex = renderer.GetPropertyIndex("uLightColor[0]");
579 DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 1.0f), renderer.GetCurrentProperty<Vector3>(colorPropertyIndex), 0.01f, TEST_LOCATION);
580 auto directionPropertyIndex = renderer.GetPropertyIndex("uLightDirection[0]");
581 DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f), renderer.GetCurrentProperty<Vector3>(directionPropertyIndex), 0.01f, TEST_LOCATION);
583 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
587 DALI_TEST_EQUALS(1u, sceneView.GetActivatedLightCount(), TEST_LOCATION);
588 DALI_TEST_EQUALS(0, renderer.GetProperty<int32_t>(countPropertyIndex), TEST_LOCATION);