2 * Copyright (c) 2020 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/public-api/dali-core.h>
20 #include <dali/devel-api/actors/actor-devel.h>
21 #include <dali/devel-api/actors/camera-actor-devel.h>
27 #include "dali-test-suite-utils/dali-test-suite-utils.h"
31 void camera_actor_test_startup(void)
33 test_return_value = TET_UNDEF;
36 void camera_actor_test_cleanup(void)
38 test_return_value = TET_PASS;
43 const float FLOAT_EPSILON = 0.001f;
44 const float TEST_ASPECT_RATIO = 0.123f;
45 const float TEST_FIELD_OF_VIEW = Radian(Degree(40.0f));
46 const float TEST_NEAR_PLANE_DISTANCE = 0.23f;
47 const float TEST_FAR_PLANE_DISTANCE = 0.973f;
49 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
50 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
51 const char* const RENDER_SHADOW_VERTEX_SOURCE =
52 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
53 " uniform mediump mat4 uLightCameraViewMatrix;\n"
57 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
58 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
59 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
62 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
63 "uniform lowp vec4 uShadowColor;\n"
66 " lowp float alpha;\n"
67 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
68 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
71 struct PropertyDetails
73 std::string name; ///< The name of the property.
74 Property::Type type; ///< The property type.
75 bool writable; ///< Whether the property is writable
76 bool animatable; ///< Whether the property is animatable.
77 bool constraintInput; ///< Whether the property can be used as an input to a constraint.
78 Property::Index enumIndex; ///< Used to check the index is correct within a debug build.
81 } // Anonymous namespace
83 int UtcDaliCameraActorConstructorP(void)
85 TestApplication application;
86 tet_infoline("Testing Dali::CameraActor::CameraActor()");
90 DALI_TEST_CHECK(!actor);
94 // Note: No negative test for UtcDaliCameraActorConstructor.
96 int UtcDaliCameraActorDestructorP(void)
98 TestApplication application;
99 tet_infoline("Testing Dali::~CameraActor (P)");
100 CameraActor* actor = new CameraActor();
104 DALI_TEST_CHECK(true);
108 // Note: No negative test for UtcDaliCameraActorDestructor.
110 int UtcDaliCameraActorCopyConstructorP(void)
112 TestApplication application;
113 tet_infoline("Testing Dali::CameraActor Copy Constructor (P)");
114 CameraActor actor = CameraActor::New();
116 CameraActor copyActor(actor);
118 DALI_TEST_CHECK(copyActor);
119 DALI_TEST_CHECK(copyActor == actor);
124 int UtcDaliCameraActorCopyConstructorN(void)
126 TestApplication application;
127 tet_infoline("Testing Dali::CameraActor Copy Constructor (N)");
130 CameraActor copyActor(actor);
132 DALI_TEST_CHECK(!copyActor);
137 int UtcDaliCameraActorAssignmentOperatorP(void)
139 TestApplication application;
140 tet_infoline("Testing Dali::CameraActor Assignment Operator (P)");
141 const CameraActor actor = CameraActor::New();
143 CameraActor copyActor = actor;
145 DALI_TEST_CHECK(copyActor);
146 DALI_TEST_CHECK(copyActor == actor);
151 int UtcDaliCameraActorAssignmentOperatorN(void)
153 TestApplication application;
154 tet_infoline("Testing Dali::CameraActor = (N)");
157 CameraActor copyActor = actor;
159 DALI_TEST_CHECK(!copyActor);
164 int UtcDaliCameraActorNewP(void)
166 TestApplication application;
167 tet_infoline("Testing Dali::CameraActor::New (P)");
169 CameraActor actor = CameraActor::New();
171 DALI_TEST_CHECK(actor);
175 DALI_TEST_CHECK(!actor);
179 int UtcDaliCameraActorNewDefaultPerspectiveProjection(void)
181 TestApplication application;
182 tet_infoline("Test the perspective projection of a camera actor is set appropriately when not passing in a size");
184 CameraActor actor = CameraActor::New();
185 DALI_TEST_CHECK(actor);
187 // All the properties should still be the default values
188 // Defaults taken from scene-graph-camera.cpp
189 DALI_TEST_EQUALS(4.0f / 3.0f, actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
190 DALI_TEST_EQUALS(45.0f * (Math::PI / 180.0f), actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
191 DALI_TEST_EQUALS(800.0f, actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
192 DALI_TEST_EQUALS(3.0f * 800.0f, actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
193 DALI_TEST_EQUALS(0.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
194 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
196 // Add it to the stage, then the values should be updated to reflect a 480.0f by 800.0f scene (default stage size)
197 application.GetScene().Add(actor);
199 DALI_TEST_EQUALS(0.6f, actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
200 DALI_TEST_EQUALS(0.489957f, actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
201 DALI_TEST_EQUALS(800.0f, actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
202 DALI_TEST_EQUALS(4895.0f, actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
203 DALI_TEST_EQUALS(1600.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
204 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
206 // Ensure the values stay the same after update/render
207 application.SendNotification();
208 application.Render();
210 DALI_TEST_EQUALS(0.6f, actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
211 DALI_TEST_EQUALS(0.489957f, actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
212 DALI_TEST_EQUALS(800.0f, actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
213 DALI_TEST_EQUALS(4895.0f, actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
214 DALI_TEST_EQUALS(1600.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
215 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
220 // Note: No negative test for UtcDaliCameraActorNew.
222 int UtcDaliCameraActorDownCastP(void)
224 TestApplication application;
225 tet_infoline("Testing Dali::CameraActor::DownCast (P)");
227 CameraActor camera = CameraActor::New();
228 Actor anActor = Actor::New();
231 Actor child = anActor.GetChildAt(0);
232 CameraActor cameraActor = CameraActor::DownCast(child);
233 DALI_TEST_CHECK(cameraActor);
236 DALI_TEST_CHECK(!cameraActor);
238 cameraActor = DownCast<CameraActor>(child);
239 DALI_TEST_CHECK(cameraActor);
243 int UtcDaliCameraActorDownCastN(void)
245 TestApplication application;
246 tet_infoline("Testing Dali::CameraActor::DownCast (N)");
248 Actor actor1 = Actor::New();
249 Actor anActor = Actor::New();
252 Actor child = anActor.GetChildAt(0);
253 CameraActor cameraActor = CameraActor::DownCast(child);
254 DALI_TEST_CHECK(!cameraActor);
256 Actor unInitialzedActor;
257 cameraActor = CameraActor::DownCast(unInitialzedActor);
258 DALI_TEST_CHECK(!cameraActor);
260 cameraActor = DownCast<CameraActor>(unInitialzedActor);
261 DALI_TEST_CHECK(!cameraActor);
265 // Note: SetType and GetType are tested within the same test cases.
267 int UtcDaliCameraActorSetGetTypeP(void)
269 TestApplication application;
270 tet_infoline("Testing Dali::CameraActor GetType (P)");
272 CameraActor actor = CameraActor::New();
273 DALI_TEST_EQUALS(actor.GetType(), Dali::Camera::FREE_LOOK, TEST_LOCATION);
275 actor.SetType(Dali::Camera::LOOK_AT_TARGET);
276 DALI_TEST_EQUALS(actor.GetType(), Dali::Camera::LOOK_AT_TARGET, TEST_LOCATION);
278 DALI_TEST_EQUALS("LOOK_AT_TARGET", actor.GetProperty<std::string>(CameraActor::Property::TYPE), TEST_LOCATION);
279 DALI_TEST_EQUALS("LOOK_AT_TARGET", actor.GetCurrentProperty<std::string>(CameraActor::Property::TYPE), TEST_LOCATION);
283 int UtcDaliCameraActorSetGetTypeN(void)
285 TestApplication application;
286 tet_infoline("Testing Dali::CameraActor GetType (N)");
290 Dali::Camera::Type cameraType = Dali::Camera::FREE_LOOK;
293 cameraType = actor.GetType();
295 catch(Dali::DaliException& e)
297 DALI_TEST_PRINT_ASSERT(e);
298 DALI_TEST_ASSERT(e, "camera", TEST_LOCATION);
301 const CameraActor aConstActor;
305 cameraType = aConstActor.GetType();
307 catch(Dali::DaliException& e)
309 DALI_TEST_PRINT_ASSERT(e);
310 DALI_TEST_ASSERT(e, "camera", TEST_LOCATION);
313 DALI_TEST_EQUALS(cameraType, Dali::Camera::FREE_LOOK, TEST_LOCATION);
317 int UtcDaliCameraActorSetFieldOfViewP(void)
319 TestApplication application;
320 tet_infoline("Testing Dali::CameraActor Set Field of view (P)");
322 CameraActor defaultCamera = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
323 const float defaultFieldOfView = defaultCamera.GetFieldOfView();
325 CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
326 DALI_TEST_EQUALS(actor.GetFieldOfView(), defaultFieldOfView, TEST_LOCATION);
328 float fieldOfView = Math::PI / 3.0f;
329 actor.SetFieldOfView(fieldOfView);
330 DALI_TEST_EQUALS(actor.GetFieldOfView(), fieldOfView, TEST_LOCATION);
333 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
334 DALI_TEST_EQUALS(fieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
338 int UtcDaliCameraActorSetFieldOfViewN(void)
340 TestApplication application;
341 tet_infoline("Testing Dali::CameraActor Set Field of view (N)");
343 CameraActor defaultCamera = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
344 const float defaultFieldOfView = defaultCamera.GetFieldOfView();
346 CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
347 DALI_TEST_EQUALS(actor.GetFieldOfView(), defaultFieldOfView, TEST_LOCATION);
349 float fieldOfView = Math::PI / 3.0f;
350 actor.SetFieldOfView(fieldOfView);
351 DALI_TEST_EQUALS(actor.GetFieldOfView(), fieldOfView, TEST_LOCATION);
354 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
355 DALI_TEST_EQUALS(fieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
359 int UtcDaliCameraActorGetFieldOfViewP(void)
361 TestApplication application;
362 tet_infoline("Testing Dali::CameraActor Get Field of view (P)");
363 const Vector2 size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
365 CameraActor defaultCamera = CameraActor::New(size);
367 const float cameraZ = 2.0f * std::max(size.width, size.height);
368 const float expectedFieldOfView = 2.0f * std::atan(size.height * 0.5f / cameraZ);
370 CameraActor actor = CameraActor::New(size);
371 DALI_TEST_EQUALS(actor.GetFieldOfView(), expectedFieldOfView, TEST_LOCATION);
374 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
375 DALI_TEST_EQUALS(expectedFieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
379 int UtcDaliCameraActorGetFieldOfViewN(void)
381 TestApplication application;
382 tet_infoline("Testing Dali::CameraActor Get Field of view (N)");
384 CameraActor defaultCamera = CameraActor::New();
386 bool asserted = true;
389 defaultCamera.GetFieldOfView();
391 catch(Dali::DaliException& e)
393 DALI_TEST_PRINT_ASSERT(e);
394 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
397 DALI_TEST_CHECK(asserted);
402 int UtcDaliCameraActorSetAspectRatioP(void)
404 TestApplication application;
405 tet_infoline("Testing Dali::CameraActor Set Aspect Ratio (P)");
407 CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
408 DALI_TEST_EQUALS(actor.GetAspectRatio(), static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH) / static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT), TEST_LOCATION);
410 // Set an initial value to confirm a further set changes it.
411 float aspect = 4.0f / 3.0f;
412 actor.SetAspectRatio(aspect);
413 DALI_TEST_EQUALS(actor.GetAspectRatio(), aspect, TEST_LOCATION);
415 aspect = 16.0f / 9.0f;
416 actor.SetAspectRatio(aspect);
417 DALI_TEST_EQUALS(actor.GetAspectRatio(), aspect, TEST_LOCATION);
422 int UtcDaliCameraActorSetAspectRatioN(void)
424 TestApplication application;
425 tet_infoline("Testing Dali::CameraActor Set Aspect Ratio (N)");
429 bool asserted = true;
432 actor.SetAspectRatio(16.0f / 9.0f);
434 catch(Dali::DaliException& e)
436 DALI_TEST_PRINT_ASSERT(e);
437 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
440 DALI_TEST_CHECK(asserted);
445 int UtcDaliCameraActorGetAspectRatioP(void)
447 TestApplication application;
448 tet_infoline("Testing Dali::CameraActor Get Aspect Ratio");
450 CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
451 float defaultAspect = static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH) / static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT);
453 DALI_TEST_EQUALS(actor.GetAspectRatio(), defaultAspect, TEST_LOCATION);
456 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
457 DALI_TEST_EQUALS(defaultAspect, value, FLOAT_EPSILON, TEST_LOCATION);
462 int UtcDaliCameraActorGetAspectRatioN(void)
464 TestApplication application;
465 tet_infoline("Testing Dali::CameraActor Get Aspect Ratio (N)");
469 bool asserted = true;
472 actor.GetAspectRatio();
474 catch(Dali::DaliException& e)
476 DALI_TEST_PRINT_ASSERT(e);
477 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
481 DALI_TEST_CHECK(asserted);
486 int UtcDaliCameraActorSetNearClippingPlaneP(void)
488 TestApplication application;
489 tet_infoline("Testing Dali::CameraActor Set Near clipping plane (P)");
491 CameraActor actor = CameraActor::New();
493 // Set a value so we are not relying on a particular default for this test case.
494 actor.SetNearClippingPlane(200.0f);
495 DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 200.0f, TEST_LOCATION);
497 actor.SetNearClippingPlane(400.0f);
498 DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 400.0f, TEST_LOCATION);
500 // Check setting the property.
501 actor.SetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE, Property::Value(300.0f));
502 DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 300.0f, FLOAT_EPSILON, TEST_LOCATION);
506 int UtcDaliCameraActorSetNearClippingPlaneN(void)
508 TestApplication application;
509 tet_infoline("Testing Dali::CameraActor Set Near clipping plane (N)");
513 bool asserted = true;
516 actor.SetNearClippingPlane(200.0f);
518 catch(Dali::DaliException& e)
520 DALI_TEST_PRINT_ASSERT(e);
521 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
525 DALI_TEST_CHECK(asserted);
530 int UtcDaliCameraActorGetNearClippingPlaneP(void)
532 TestApplication application;
533 tet_infoline("Testing Dali::CameraActor Get Near clipping plane (P)");
535 // Check the default value.
536 CameraActor actor = CameraActor::New();
537 float defaultValue = 800.0f;
538 DALI_TEST_EQUALS(actor.GetNearClippingPlane(), defaultValue, TEST_LOCATION);
540 // Check getting the property.
542 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
543 DALI_TEST_EQUALS(defaultValue, value, FLOAT_EPSILON, TEST_LOCATION);
547 int UtcDaliCameraActorGetNearClippingPlaneN(void)
549 TestApplication application;
550 tet_infoline("Testing Dali::CameraActor Get Near clipping plane (N)");
553 bool asserted = true;
556 actor.GetNearClippingPlane();
558 catch(Dali::DaliException& e)
560 DALI_TEST_PRINT_ASSERT(e);
561 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
565 DALI_TEST_CHECK(asserted);
570 int UtcDaliCameraActorSetFarClippingPlaneP(void)
572 TestApplication application;
573 tet_infoline("Testing Dali::CameraActor Set Far clipping plane (P)");
575 CameraActor actor = CameraActor::New();
577 // Set a value so we are not relying on a particular default for this test case.
578 actor.SetFarClippingPlane(2000.0f);
579 DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 2000.0f, TEST_LOCATION);
581 actor.SetFarClippingPlane(4000.0f);
582 DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 4000.0f, TEST_LOCATION);
584 // Check setting the property.
585 actor.SetProperty(CameraActor::Property::FAR_PLANE_DISTANCE, 2000.0f);
586 DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 2000.0f, FLOAT_EPSILON, TEST_LOCATION);
590 int UtcDaliCameraActorSetFarClippingPlaneN(void)
592 TestApplication application;
593 tet_infoline("Testing Dali::CameraActor Set Far clipping plane (N)");
597 bool asserted = true;
600 actor.SetFarClippingPlane(2000.0f);
602 catch(Dali::DaliException& e)
604 DALI_TEST_PRINT_ASSERT(e);
605 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
609 DALI_TEST_CHECK(asserted);
614 int UtcDaliCameraActorGetFarClippingPlaneP(void)
616 TestApplication application;
617 tet_infoline("Testing Dali::CameraActor Get Far clipping plane (P)");
619 CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
620 float defaultValue = 800.0f + (0xFFFF >> 4);
621 DALI_TEST_EQUALS(actor.GetFarClippingPlane(), defaultValue, TEST_LOCATION);
623 // Check getting the property.
625 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
626 DALI_TEST_EQUALS(defaultValue, value, FLOAT_EPSILON, TEST_LOCATION);
630 int UtcDaliCameraActorGetFarClippingPlaneN(void)
632 TestApplication application;
633 tet_infoline("Testing Dali::CameraActor Get Far clipping plane (N)");
637 bool asserted = true;
640 actor.GetFarClippingPlane();
642 catch(Dali::DaliException& e)
644 DALI_TEST_PRINT_ASSERT(e);
645 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
649 DALI_TEST_CHECK(asserted);
654 int UtcDaliCameraActorSetTargetPositionP(void)
656 TestApplication application;
657 tet_infoline("Testing Dali::CameraActor Set Target Position (P)");
659 CameraActor actor = CameraActor::New();
661 Vector3 target1(10.0f, 20.0f, 30.0f);
662 Vector3 target2(15.0f, 25.0f, 35.0f);
664 // Set a value so we are not relying on a particular default for this test case.
665 actor.SetTargetPosition(target1);
666 DALI_TEST_EQUALS(actor.GetTargetPosition(), target1, TEST_LOCATION);
668 actor.SetTargetPosition(target2);
669 DALI_TEST_EQUALS(actor.GetTargetPosition(), target2, TEST_LOCATION);
671 // Check setting the property.
672 actor.SetProperty(CameraActor::Property::TARGET_POSITION, target1);
673 DALI_TEST_EQUALS(actor.GetTargetPosition(), target1, FLOAT_EPSILON, TEST_LOCATION);
677 int UtcDaliCameraActorSetTargetPositionN(void)
679 TestApplication application;
680 tet_infoline("Testing Dali::CameraActor Set Target Position (N)");
684 bool asserted = true;
687 actor.SetTargetPosition(Vector3(10.0f, 20.0f, 30.0f));
689 catch(Dali::DaliException& e)
691 DALI_TEST_PRINT_ASSERT(e);
692 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
695 DALI_TEST_CHECK(asserted);
700 int UtcDaliCameraActorGetTargetPositionP(void)
702 TestApplication application;
703 tet_infoline("Testing Dali::CameraActor Get Target Position (P)");
705 CameraActor actor = CameraActor::New();
706 Vector3 defaultValue(Vector3::ZERO);
707 DALI_TEST_EQUALS(actor.GetTargetPosition(), defaultValue, TEST_LOCATION);
709 // Check getting the property.
711 actor.GetProperty(CameraActor::Property::TARGET_POSITION).Get(value);
712 DALI_TEST_EQUALS(defaultValue, value, FLOAT_EPSILON, TEST_LOCATION);
716 int UtcDaliCameraActorGetTargetPositionN(void)
718 TestApplication application;
719 tet_infoline("Testing Dali::CameraActor Get Target Position (N)");
723 bool asserted = true;
726 actor.GetTargetPosition();
728 catch(Dali::DaliException& e)
730 DALI_TEST_PRINT_ASSERT(e);
731 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
734 DALI_TEST_CHECK(asserted);
739 int UtcDaliCameraActorSetInvertYAxisP(void)
741 TestApplication application;
742 tet_infoline("Testing Dali::CameraActor Set InvertYAxis (P)");
744 CameraActor actor = CameraActor::New();
746 // Set a value so we are not relying on a particular default for this test case.
747 actor.SetInvertYAxis(false);
748 DALI_TEST_EQUALS(actor.GetInvertYAxis(), false, TEST_LOCATION);
750 actor.SetInvertYAxis(true);
751 DALI_TEST_EQUALS(actor.GetInvertYAxis(), true, TEST_LOCATION);
753 actor.SetProperty(CameraActor::Property::INVERT_Y_AXIS, false);
754 DALI_TEST_EQUALS(actor.GetInvertYAxis(), false, TEST_LOCATION);
758 int UtcDaliCameraActorSetInvertYAxisN(void)
760 TestApplication application;
761 tet_infoline("Testing Dali::CameraActor Set InvertYAxis (N)");
765 bool asserted = true;
768 actor.SetInvertYAxis(false);
770 catch(Dali::DaliException& e)
772 DALI_TEST_PRINT_ASSERT(e);
773 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
776 DALI_TEST_CHECK(asserted);
780 int UtcDaliCameraActorGetInvertYAxisP(void)
782 TestApplication application;
783 tet_infoline("Testing Dali::CameraActor Get InvertYAxis (P)");
785 // Check the default value.
786 CameraActor actor = CameraActor::New();
787 DALI_TEST_EQUALS(actor.GetInvertYAxis(), false, TEST_LOCATION);
789 // Check getting the property.
791 actor.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(bValue);
792 DALI_TEST_EQUALS(false, bValue, TEST_LOCATION);
796 int UtcDaliCameraActorGetInvertYAxisN(void)
798 TestApplication application;
799 tet_infoline("Testing Dali::CameraActor Get InvertYAxis (N)");
803 bool asserted = true;
806 actor.GetInvertYAxis();
808 catch(Dali::DaliException& e)
810 DALI_TEST_PRINT_ASSERT(e);
811 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
814 DALI_TEST_CHECK(asserted);
818 int UtcDaliCameraActorSetPerspectiveProjectionP(void)
820 TestApplication application;
821 tet_infoline("Testing Dali::CameraActor::SetPerspectiveProjection (P)");
823 CameraActor actor = CameraActor::New();
824 actor.SetPerspectiveProjection(Size(100.f, 150.f));
826 DALI_TEST_CHECK(actor);
829 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
830 DALI_TEST_EQUALS(0.666666f, value, FLOAT_EPSILON, TEST_LOCATION);
831 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
832 DALI_TEST_EQUALS(0.489957f, value, FLOAT_EPSILON, TEST_LOCATION);
833 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
834 DALI_TEST_EQUALS(150.f, value, FLOAT_EPSILON, TEST_LOCATION);
835 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
836 DALI_TEST_EQUALS(4245.f, value, FLOAT_EPSILON, TEST_LOCATION);
838 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
840 // Ensure these values persist after adding to the stage and an update/render pass
841 application.GetScene().Add(actor);
842 application.SendNotification();
843 application.Render();
845 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
846 DALI_TEST_EQUALS(0.666666f, value, FLOAT_EPSILON, TEST_LOCATION);
847 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
848 DALI_TEST_EQUALS(0.489957f, value, FLOAT_EPSILON, TEST_LOCATION);
849 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
850 DALI_TEST_EQUALS(150.f, value, FLOAT_EPSILON, TEST_LOCATION);
851 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
852 DALI_TEST_EQUALS(4245.f, value, FLOAT_EPSILON, TEST_LOCATION);
854 // Call method with a ZERO size, this should reset the perspective projection using the size of the scene we've been added to
855 actor.SetPerspectiveProjection(Vector2::ZERO);
857 DALI_TEST_EQUALS(0.6f, actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
858 DALI_TEST_EQUALS(0.489957f, actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
859 DALI_TEST_EQUALS(800.0f, actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
860 DALI_TEST_EQUALS(4895.0f, actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
861 DALI_TEST_EQUALS(1600.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
862 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
867 int UtcDaliCameraActorSetPerspectiveProjectionN(void)
869 TestApplication application;
870 tet_infoline("Testing Dali::CameraActor::SetPerspectiveProjection (N)");
872 CameraActor actor = CameraActor::New();
874 // Check that setting perspective projection without a size does not do anything.
875 actor.SetPerspectiveProjection(Size::ZERO);
877 // So the default values should be the same as defined in CameraActor
878 float nearClippingPlane = 800.0f;
879 float farClippingPlane = nearClippingPlane + 2.0f * nearClippingPlane;
881 DALI_TEST_EQUALS(nearClippingPlane, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
882 DALI_TEST_EQUALS(farClippingPlane, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
883 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
888 int UtcDaliCameraActorSetOrthographicProjectionP1(void)
890 TestApplication application;
891 tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection (P,1)");
893 CameraActor actor = CameraActor::New(Size(1080.0f, 1920.0f));
894 DALI_TEST_CHECK(actor);
896 application.GetScene().Add(actor);
898 actor.SetOrthographicProjection(Size(1080.0f, 1920.0f));
899 application.SendNotification();
900 application.Render(0);
901 application.Render();
902 application.SendNotification();
904 float defaultAspectRatio;
905 float defaultFieldOfView;
906 float defaultNearPlaneDistance;
907 float defaultFarPlaneDistance;
908 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(defaultAspectRatio);
909 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(defaultFieldOfView);
910 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(defaultNearPlaneDistance);
911 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(defaultFarPlaneDistance);
912 Vector3 defaultPos = actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
914 actor.SetOrthographicProjection(Size(1080.0f, 1920.0f));
916 application.SendNotification();
917 application.Render(0);
918 application.Render();
919 application.SendNotification();
922 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
923 DALI_TEST_EQUALS(defaultAspectRatio, value, FLOAT_EPSILON, TEST_LOCATION);
924 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
925 DALI_TEST_EQUALS(defaultFieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
926 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
927 DALI_TEST_EQUALS(defaultNearPlaneDistance, value, FLOAT_EPSILON, TEST_LOCATION);
928 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
929 DALI_TEST_EQUALS(defaultFarPlaneDistance, value, FLOAT_EPSILON, TEST_LOCATION);
931 actor.GetProperty(CameraActor::Property::LEFT_PLANE_DISTANCE).Get(value);
932 DALI_TEST_EQUALS(-540.0f, value, FLOAT_EPSILON, TEST_LOCATION);
933 actor.GetProperty(CameraActor::Property::RIGHT_PLANE_DISTANCE).Get(value);
934 DALI_TEST_EQUALS(540.0f, value, FLOAT_EPSILON, TEST_LOCATION);
935 actor.GetProperty(CameraActor::Property::TOP_PLANE_DISTANCE).Get(value);
936 DALI_TEST_EQUALS(960.0f, value, FLOAT_EPSILON, TEST_LOCATION);
937 actor.GetProperty(CameraActor::Property::BOTTOM_PLANE_DISTANCE).Get(value);
938 DALI_TEST_EQUALS(-960.0f, value, FLOAT_EPSILON, TEST_LOCATION);
940 Vector3 pos = actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
941 DALI_TEST_EQUALS(defaultPos.z, pos.z, 0.001f, TEST_LOCATION);
943 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
947 int UtcDaliCameraActorSetOrthographicProjectionN(void)
949 TestApplication application;
950 tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection (N)");
953 bool asserted = true;
956 actor.GetProjectionMode();
958 catch(Dali::DaliException& e)
960 DALI_TEST_PRINT_ASSERT(e);
961 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
964 DALI_TEST_CHECK(asserted);
968 int UtcDaliCameraActorSetOrthographicProjectionP2(void)
970 TestApplication application;
971 tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection (P,2)");
973 CameraActor actor = CameraActor::New();
974 DALI_TEST_CHECK(actor);
976 float defaultAspectRatio;
977 float defaultFieldOfView;
978 float defaultNearPlaneDistance;
979 float defaultFarPlaneDistance;
980 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(defaultAspectRatio);
981 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(defaultFieldOfView);
982 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(defaultNearPlaneDistance);
983 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(defaultFarPlaneDistance);
985 // Check setting with specific near and far plane distances.
986 actor.SetOrthographicProjection(-100.0f, 200.0f, -300.0f, 500.0f, 400.0f, 4000.0f);
989 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
990 DALI_TEST_EQUALS(defaultAspectRatio, value, FLOAT_EPSILON, TEST_LOCATION);
991 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
992 DALI_TEST_EQUALS(defaultFieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
993 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
994 DALI_TEST_EQUALS(400.0f, value, FLOAT_EPSILON, TEST_LOCATION);
995 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
996 DALI_TEST_EQUALS(4000.0f, value, FLOAT_EPSILON, TEST_LOCATION);
998 actor.GetProperty(CameraActor::Property::LEFT_PLANE_DISTANCE).Get(value);
999 DALI_TEST_EQUALS(-100.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1000 actor.GetProperty(CameraActor::Property::RIGHT_PLANE_DISTANCE).Get(value);
1001 DALI_TEST_EQUALS(200.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1002 actor.GetProperty(CameraActor::Property::TOP_PLANE_DISTANCE).Get(value);
1003 DALI_TEST_EQUALS(-300.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1004 actor.GetProperty(CameraActor::Property::BOTTOM_PLANE_DISTANCE).Get(value);
1005 DALI_TEST_EQUALS(500.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1007 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
1012 int UtcDaliCameraActorSetOrthographicProjectionP3(void)
1014 TestApplication application;
1015 tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection (P,3)");
1017 CameraActor actor = CameraActor::New();
1018 DALI_TEST_CHECK(actor);
1020 float defaultAspectRatio;
1021 float defaultFieldOfView;
1022 float defaultNearPlaneDistance;
1023 float defaultFarPlaneDistance;
1024 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(defaultAspectRatio);
1025 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(defaultFieldOfView);
1026 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(defaultNearPlaneDistance);
1027 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(defaultFarPlaneDistance);
1029 actor.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
1031 actor.SetProperty(CameraActor::Property::LEFT_PLANE_DISTANCE, -100.0f);
1032 actor.SetProperty(CameraActor::Property::RIGHT_PLANE_DISTANCE, 200.0f);
1033 actor.SetProperty(CameraActor::Property::TOP_PLANE_DISTANCE, -300.0f);
1034 actor.SetProperty(CameraActor::Property::BOTTOM_PLANE_DISTANCE, 500.0f);
1035 actor.SetNearClippingPlane(400.0f);
1036 actor.SetFarClippingPlane(4000.0f);
1039 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
1040 DALI_TEST_EQUALS(defaultAspectRatio, value, FLOAT_EPSILON, TEST_LOCATION);
1041 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
1042 DALI_TEST_EQUALS(defaultFieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
1043 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
1044 DALI_TEST_EQUALS(400.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1045 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
1046 DALI_TEST_EQUALS(4000.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1048 actor.GetProperty(CameraActor::Property::LEFT_PLANE_DISTANCE).Get(value);
1049 DALI_TEST_EQUALS(-100.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1050 actor.GetProperty(CameraActor::Property::RIGHT_PLANE_DISTANCE).Get(value);
1051 DALI_TEST_EQUALS(200.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1052 actor.GetProperty(CameraActor::Property::TOP_PLANE_DISTANCE).Get(value);
1053 DALI_TEST_EQUALS(-300.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1054 actor.GetProperty(CameraActor::Property::BOTTOM_PLANE_DISTANCE).Get(value);
1055 DALI_TEST_EQUALS(500.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1057 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
1058 std::string stringValue;
1059 actor.GetProperty(CameraActor::Property::PROJECTION_MODE).Get(stringValue);
1060 DALI_TEST_EQUALS(stringValue, "ORTHOGRAPHIC_PROJECTION", TEST_LOCATION);
1064 int UtcDaliCameraActorSetProjectionModeP(void)
1066 TestApplication application;
1067 tet_infoline("Testing Dali::CameraActor::SetProjectionModeP (P)");
1069 CameraActor actor = CameraActor::New();
1071 // Check that changing the projection mode alone does not alter other presets.
1072 actor.SetNearClippingPlane(200.0f);
1073 actor.SetFarClippingPlane(400.0f);
1075 actor.SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
1077 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1078 DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 200.0f, FLOAT_EPSILON, TEST_LOCATION);
1079 DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 400.0f, FLOAT_EPSILON, TEST_LOCATION);
1081 actor.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
1083 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
1084 DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 200.0f, FLOAT_EPSILON, TEST_LOCATION);
1085 DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 400.0f, FLOAT_EPSILON, TEST_LOCATION);
1087 // Check setting the property.
1088 Property::Value setValue = "PERSPECTIVE_PROJECTION";
1089 actor.SetProperty(CameraActor::Property::PROJECTION_MODE, setValue);
1090 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1094 int UtcDaliCameraActorSetProjectionModeN(void)
1096 TestApplication application;
1097 tet_infoline("Testing Dali::CameraActor::SetProjectionModeP (N)");
1101 bool asserted = true;
1104 actor.SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
1106 catch(Dali::DaliException& e)
1108 DALI_TEST_PRINT_ASSERT(e);
1109 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
1112 DALI_TEST_CHECK(asserted);
1116 int UtcDaliCameraActorGetProjectionModeP(void)
1118 TestApplication application;
1119 tet_infoline("Testing Dali::CameraActor::GetPerspectiveProjection (P)");
1121 CameraActor actor = CameraActor::New();
1123 actor.SetOrthographicProjection(Size::ONE);
1124 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
1126 actor.SetPerspectiveProjection(Size(100.f, 150.f));
1127 DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1129 // Check getting the property.
1130 std::string stringValue;
1131 actor.GetProperty(CameraActor::Property::PROJECTION_MODE).Get(stringValue);
1132 DALI_TEST_EQUALS(stringValue, "PERSPECTIVE_PROJECTION", TEST_LOCATION);
1136 int UtcDaliCameraActorGetProjectionModeN(void)
1138 TestApplication application;
1139 tet_infoline("Testing Dali::CameraActor::GetProjectionMode (N)");
1143 bool asserted = true;
1146 actor.GetProjectionMode();
1148 catch(Dali::DaliException& e)
1150 DALI_TEST_PRINT_ASSERT(e);
1151 DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
1154 DALI_TEST_CHECK(asserted);
1158 int UtcDaliCameraActorSetCameraOffScene(void)
1160 TestApplication application;
1161 tet_infoline("Testing Dali::CameraActor::SetCamera()");
1163 CameraActor actor = CameraActor::New();
1165 actor.SetType(Camera::FREE_LOOK);
1166 actor.SetFieldOfView(TEST_FIELD_OF_VIEW);
1167 actor.SetAspectRatio(TEST_ASPECT_RATIO);
1168 actor.SetNearClippingPlane(TEST_NEAR_PLANE_DISTANCE);
1169 actor.SetFarClippingPlane(TEST_FAR_PLANE_DISTANCE);
1170 actor.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION);
1172 actor.SetInvertYAxis(false);
1174 DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION); //change to machine epsilon
1175 DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION);
1176 DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1177 DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1178 DALI_TEST_EQUALS(Camera::PERSPECTIVE_PROJECTION, actor.GetProjectionMode(), TEST_LOCATION);
1179 DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION);
1183 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
1184 DALI_TEST_EQUALS(TEST_ASPECT_RATIO, value, FLOAT_EPSILON, TEST_LOCATION);
1185 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
1186 DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, value, FLOAT_EPSILON, TEST_LOCATION);
1187 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
1188 DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION);
1189 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
1190 DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION);
1191 actor.GetProperty(CameraActor::Property::PROJECTION_MODE).Get(sValue);
1192 DALI_TEST_EQUALS("PERSPECTIVE_PROJECTION", sValue, TEST_LOCATION);
1194 actor.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(bValue);
1195 DALI_TEST_EQUALS(false, bValue, TEST_LOCATION);
1199 int UtcDaliCameraActorSetCameraOnScene(void)
1201 TestApplication application;
1202 tet_infoline("Testing Dali::CameraActor::SetCamera()");
1204 CameraActor actor = CameraActor::New();
1205 application.GetScene().Add(actor);
1206 application.Render(0);
1207 application.SendNotification();
1209 actor.SetType(Camera::LOOK_AT_TARGET);
1210 actor.SetFieldOfView(TEST_FIELD_OF_VIEW);
1211 actor.SetAspectRatio(TEST_ASPECT_RATIO);
1212 actor.SetNearClippingPlane(TEST_NEAR_PLANE_DISTANCE);
1213 actor.SetFarClippingPlane(TEST_FAR_PLANE_DISTANCE);
1214 actor.SetInvertYAxis(false);
1216 DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION);
1218 // Will need 2 frames to ensure both buffers are set to same values:
1219 application.Render();
1220 application.SendNotification();
1221 application.Render();
1222 application.SendNotification();
1224 DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION);
1225 DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION);
1226 DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1227 DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1228 DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION);
1231 actor.GetProperty(CameraActor::Property::TYPE).Get(sValue);
1232 DALI_TEST_EQUALS(sValue, "LOOK_AT_TARGET", TEST_LOCATION);
1235 actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
1236 DALI_TEST_EQUALS(TEST_ASPECT_RATIO, value, FLOAT_EPSILON, TEST_LOCATION);
1237 actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
1238 DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, value, FLOAT_EPSILON, TEST_LOCATION);
1239 actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
1240 DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION);
1241 actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
1242 DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION);
1245 actor.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(bValue);
1246 DALI_TEST_EQUALS(false, bValue, TEST_LOCATION);
1250 int UtcDaliCameraActorGetCamera(void)
1252 TestApplication application;
1253 tet_infoline("Testing Dali::CameraActor::GetCamera()");
1255 CameraActor actor = CameraActor::New();
1257 actor.SetAspectRatio(TEST_ASPECT_RATIO);
1259 DALI_TEST_EQUALS(actor.GetAspectRatio(), TEST_ASPECT_RATIO, FLOAT_EPSILON, TEST_LOCATION);
1261 actor.SetProperty(CameraActor::Property::TYPE, "FREE_LOOK");
1262 actor.SetProperty(CameraActor::Property::ASPECT_RATIO, TEST_ASPECT_RATIO);
1263 actor.SetProperty(CameraActor::Property::FIELD_OF_VIEW, TEST_FIELD_OF_VIEW);
1264 actor.SetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE, TEST_NEAR_PLANE_DISTANCE);
1265 actor.SetProperty(CameraActor::Property::FAR_PLANE_DISTANCE, TEST_FAR_PLANE_DISTANCE);
1267 DALI_TEST_EQUALS(Camera::FREE_LOOK, actor.GetType(), TEST_LOCATION);
1268 DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION);
1269 DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION);
1270 DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1271 DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1275 int UtcDaliCameraActorDefaultProperties(void)
1277 TestApplication application;
1278 tet_infoline("Testing Dali::CameraActor DefaultProperties");
1280 CameraActor actor = CameraActor::New();
1281 Integration::Scene stage = application.GetScene();
1283 stage.GetRenderTaskList().GetTask(0).SetCameraActor(actor);
1285 actor.SetAspectRatio(TEST_ASPECT_RATIO);
1286 application.GetScene().Add(actor);
1287 application.Render(0);
1288 application.SendNotification();
1290 actor.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(bValue);
1291 DALI_TEST_EQUALS(false, bValue, TEST_LOCATION);
1293 std::vector<Property::Index> indices;
1294 indices.push_back(CameraActor::Property::TYPE);
1295 indices.push_back(CameraActor::Property::PROJECTION_MODE);
1296 indices.push_back(CameraActor::Property::FIELD_OF_VIEW);
1297 indices.push_back(CameraActor::Property::ASPECT_RATIO);
1298 indices.push_back(CameraActor::Property::NEAR_PLANE_DISTANCE);
1299 indices.push_back(CameraActor::Property::FAR_PLANE_DISTANCE);
1300 indices.push_back(CameraActor::Property::LEFT_PLANE_DISTANCE);
1301 indices.push_back(CameraActor::Property::RIGHT_PLANE_DISTANCE);
1302 indices.push_back(CameraActor::Property::TOP_PLANE_DISTANCE);
1303 indices.push_back(CameraActor::Property::BOTTOM_PLANE_DISTANCE);
1304 indices.push_back(CameraActor::Property::TARGET_POSITION);
1305 indices.push_back(CameraActor::Property::PROJECTION_MATRIX);
1306 indices.push_back(CameraActor::Property::VIEW_MATRIX);
1307 indices.push_back(CameraActor::Property::INVERT_Y_AXIS);
1309 DALI_TEST_CHECK(actor.GetPropertyCount() == (Actor::New().GetPropertyCount() + indices.size()));
1311 for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
1313 DALI_TEST_EQUALS(*iter, actor.GetPropertyIndex(actor.GetPropertyName(*iter)), TEST_LOCATION);
1314 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(*iter));
1316 if((*iter == CameraActor::Property::PROJECTION_MATRIX) ||
1317 (*iter == CameraActor::Property::VIEW_MATRIX))
1319 DALI_TEST_CHECK(!actor.IsPropertyWritable(*iter));
1323 DALI_TEST_CHECK(actor.IsPropertyWritable(*iter));
1326 DALI_TEST_CHECK(actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter)); // just checking call succeeds
1329 // Set/Get one of them.
1330 const float newAspect = TEST_ASPECT_RATIO * 2.0f;
1332 actor.SetProperty(CameraActor::Property::ASPECT_RATIO, Property::Value(newAspect));
1333 application.Render();
1334 application.SendNotification();
1335 application.Render();
1336 application.SendNotification();
1338 DALI_TEST_EQUALS(actor.GetAspectRatio(), newAspect, TEST_LOCATION);
1342 template<typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
1343 void TEST_CAMERA_PROPERTY(P1 camera, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION)
1345 DALI_TEST_EQUALS(camera.GetPropertyName(enumName), stringName, LOCATION);
1346 DALI_TEST_EQUALS(camera.GetPropertyIndex(stringName), static_cast<Property::Index>(enumName), LOCATION);
1347 DALI_TEST_EQUALS(camera.GetPropertyType(enumName), type, LOCATION);
1348 DALI_TEST_EQUALS(camera.IsPropertyWritable(enumName), isWriteable, LOCATION);
1349 DALI_TEST_EQUALS(camera.IsPropertyAnimatable(enumName), isAnimateable, LOCATION);
1350 DALI_TEST_EQUALS(camera.IsPropertyAConstraintInput(enumName), isConstraintInput, LOCATION);
1352 int UtcDaliCameraActorDefaultPropertiesInherited(void)
1354 TestApplication application;
1356 CameraActor actor = CameraActor::New();
1357 Integration::Scene stage = application.GetScene();
1359 stage.GetRenderTaskList().GetTask(0).SetCameraActor(actor);
1361 application.GetScene().Add(actor);
1362 application.Render(0);
1363 application.SendNotification();
1365 const PropertyDetails CAMERA_DEFAULT_PROPERTY[] =
1368 {"parentOrigin", Property::VECTOR3, true, false, true, Dali::Actor::Property::PARENT_ORIGIN},
1369 {"parentOriginX", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_X},
1370 {"parentOriginY", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Y},
1371 {"parentOriginZ", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Z},
1372 {"anchorPoint", Property::VECTOR3, true, false, true, Dali::Actor::Property::ANCHOR_POINT},
1373 {"anchorPointX", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_X},
1374 {"anchorPointY", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Y},
1375 {"anchorPointZ", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Z},
1376 {"size", Property::VECTOR3, true, true, true, Dali::Actor::Property::SIZE},
1377 {"sizeWidth", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_WIDTH},
1378 {"sizeHeight", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_HEIGHT},
1379 {"sizeDepth", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_DEPTH},
1380 {"position", Property::VECTOR3, true, true, true, Dali::Actor::Property::POSITION},
1381 {"positionX", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_X},
1382 {"positionY", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_Y},
1383 {"positionZ", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_Z},
1384 {"worldPosition", Property::VECTOR3, false, false, true, Dali::Actor::Property::WORLD_POSITION},
1385 {"worldPositionX", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_X},
1386 {"worldPositionY", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Y},
1387 {"worldPositionZ", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Z},
1388 {"orientation", Property::ROTATION, true, true, true, Dali::Actor::Property::ORIENTATION},
1389 {"worldOrientation", Property::ROTATION, false, false, true, Dali::Actor::Property::WORLD_ORIENTATION},
1390 {"scale", Property::VECTOR3, true, true, true, Dali::Actor::Property::SCALE},
1391 {"scaleX", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_X},
1392 {"scaleY", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_Y},
1393 {"scaleZ", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_Z},
1394 {"worldScale", Property::VECTOR3, false, false, true, Dali::Actor::Property::WORLD_SCALE},
1395 {"visible", Property::BOOLEAN, true, true, true, Dali::Actor::Property::VISIBLE},
1396 {"color", Property::VECTOR4, true, true, true, Dali::Actor::Property::COLOR},
1397 {"colorRed", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_RED},
1398 {"colorGreen", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_GREEN},
1399 {"colorBlue", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_BLUE},
1400 {"colorAlpha", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_ALPHA},
1401 {"worldColor", Property::VECTOR4, false, false, true, Dali::Actor::Property::WORLD_COLOR},
1402 {"worldMatrix", Property::MATRIX, false, false, true, Dali::Actor::Property::WORLD_MATRIX},
1403 {"name", Property::STRING, true, false, false, Dali::Actor::Property::NAME},
1404 {"sensitive", Property::BOOLEAN, true, false, false, Dali::Actor::Property::SENSITIVE},
1405 {"leaveRequired", Property::BOOLEAN, true, false, false, Dali::Actor::Property::LEAVE_REQUIRED},
1406 {"inheritOrientation", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION},
1407 {"inheritScale", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE},
1408 {"colorMode", Property::INTEGER, true, false, false, Dali::Actor::Property::COLOR_MODE},
1409 {"drawMode", Property::INTEGER, true, false, false, Dali::Actor::Property::DRAW_MODE},
1410 {"sizeModeFactor", Property::VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR},
1411 {"widthResizePolicy", Property::STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY},
1412 {"heightResizePolicy", Property::STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY},
1413 {"sizeScalePolicy", Property::INTEGER, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY},
1414 {"widthForHeight", Property::BOOLEAN, true, false, false, Dali::Actor::Property::WIDTH_FOR_HEIGHT},
1415 {"heightForWidth", Property::BOOLEAN, true, false, false, Dali::Actor::Property::HEIGHT_FOR_WIDTH},
1416 {"padding", Property::VECTOR4, true, false, false, Dali::Actor::Property::PADDING},
1417 {"minimumSize", Property::VECTOR2, true, false, false, Dali::Actor::Property::MINIMUM_SIZE},
1418 {"maximumSize", Property::VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE},
1419 {"inheritPosition", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_POSITION},
1420 {"clippingMode", Property::STRING, true, false, false, Dali::Actor::Property::CLIPPING_MODE},
1421 {"layoutDirection", Property::STRING, true, false, false, Dali::Actor::Property::LAYOUT_DIRECTION},
1422 {"inheritLayoutDirection", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION},
1423 {"opacity", Property::FLOAT, true, true, true, Dali::Actor::Property::OPACITY},
1424 {"screenPosition", Property::VECTOR2, false, false, false, Dali::Actor::Property::SCREEN_POSITION},
1425 {"positionUsesAnchorPoint", Property::BOOLEAN, true, false, false, Dali::Actor::Property::POSITION_USES_ANCHOR_POINT},
1426 {"culled", Property::BOOLEAN, false, false, true, Dali::Actor::Property::CULLED},
1427 {"id", Property::INTEGER, false, false, false, Dali::Actor::Property::ID},
1428 {"hierarchyDepth", Property::INTEGER, false, false, false, Dali::Actor::Property::HIERARCHY_DEPTH},
1429 {"isRoot", Property::BOOLEAN, false, false, false, Dali::Actor::Property::IS_ROOT},
1430 {"isLayer", Property::BOOLEAN, false, false, false, Dali::Actor::Property::IS_LAYER},
1431 {"connectedToScene", Property::BOOLEAN, false, false, false, Dali::Actor::Property::CONNECTED_TO_SCENE},
1432 {"keyboardFocusable", Property::BOOLEAN, true, false, false, Dali::Actor::Property::KEYBOARD_FOCUSABLE},
1433 {"siblingOrder", Property::INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER},
1435 {"type", Property::STRING, true, false, true, Dali::CameraActor::Property::TYPE},
1436 {"projectionMode", Property::STRING, true, false, true, Dali::CameraActor::Property::PROJECTION_MODE},
1437 {"fieldOfView", Property::FLOAT, true, false, true, Dali::CameraActor::Property::FIELD_OF_VIEW},
1438 {"aspectRatio", Property::FLOAT, true, false, true, Dali::CameraActor::Property::ASPECT_RATIO},
1439 {"nearPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE},
1440 {"farPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE},
1441 {"leftPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE},
1442 {"rightPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE},
1443 {"topPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE},
1444 {"bottomPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE},
1445 {"targetPosition", Property::VECTOR3, true, false, true, Dali::CameraActor::Property::TARGET_POSITION},
1446 {"projectionMatrix", Property::MATRIX, false, false, true, Dali::CameraActor::Property::PROJECTION_MATRIX},
1447 {"viewMatrix", Property::MATRIX, false, false, true, Dali::CameraActor::Property::VIEW_MATRIX},
1448 {"invertYAxis", Property::BOOLEAN, true, false, true, Dali::CameraActor::Property::INVERT_Y_AXIS}};
1450 for(uint32_t index = 0; index < (sizeof(CAMERA_DEFAULT_PROPERTY) / sizeof(PropertyDetails)); ++index)
1452 TEST_CAMERA_PROPERTY(actor,
1453 CAMERA_DEFAULT_PROPERTY[index].name,
1454 CAMERA_DEFAULT_PROPERTY[index].type,
1455 CAMERA_DEFAULT_PROPERTY[index].writable,
1456 CAMERA_DEFAULT_PROPERTY[index].animatable,
1457 CAMERA_DEFAULT_PROPERTY[index].constraintInput,
1458 CAMERA_DEFAULT_PROPERTY[index].enumIndex,
1464 int UtcDaliCameraActorModelView(void)
1466 TestApplication application;
1467 tet_infoline("Testing Dali::CameraActor Test view application");
1469 Actor actor = CreateRenderableActor();
1470 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1471 actor.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 30.0f, 40.0f));
1472 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1473 application.GetScene().Add(actor);
1475 application.SendNotification();
1476 application.Render(0);
1477 application.Render();
1478 application.SendNotification();
1480 Matrix resultMatrix(true);
1481 resultMatrix.SetTransformComponents(Vector3::ONE, Quaternion::IDENTITY, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1483 RenderTask task = application.GetScene().GetRenderTaskList().GetTask(0);
1484 CameraActor cameraActor = task.GetCameraActor();
1486 Matrix viewMatrix(false);
1487 cameraActor.GetProperty(CameraActor::Property::VIEW_MATRIX).Get(viewMatrix);
1488 Matrix::Multiply(resultMatrix, resultMatrix, viewMatrix);
1490 DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uModelView", resultMatrix));
1494 int UtcDaliCameraActorReadProjectionMatrix(void)
1496 TestApplication application;
1497 tet_infoline("Testing Dali::CameraActor::ReadProjectionMatrix()");
1499 CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1500 application.SendNotification();
1501 application.Render(0);
1502 application.Render();
1503 application.SendNotification();
1504 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
1505 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
1506 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1507 application.GetScene().Add(actor);
1509 Matrix projectionMatrix;
1512 camera.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
1513 camera.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(viewMatrix);
1515 actor.RegisterProperty(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY);
1516 actor.RegisterProperty(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY);
1518 Property::Index projectionMatrixPropertyIndex = actor.GetPropertyIndex(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME);
1519 Property::Index viewMatrixPropertyIndex = actor.GetPropertyIndex(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME);
1521 Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>(actor, projectionMatrixPropertyIndex, EqualToConstraint());
1522 projectionMatrixConstraint.AddSource(Source(camera, CameraActor::Property::PROJECTION_MATRIX));
1523 Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>(actor, viewMatrixPropertyIndex, EqualToConstraint());
1524 viewMatrixConstraint.AddSource(Source(camera, CameraActor::Property::VIEW_MATRIX));
1526 projectionMatrixConstraint.Apply();
1527 viewMatrixConstraint.Apply();
1529 application.SendNotification();
1530 application.Render();
1532 // Test effects of Constraint.
1533 DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME.c_str(), projectionMatrix));
1535 DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME.c_str(), viewMatrix));
1539 int UtcDaliCameraActorAnimatedProperties(void)
1541 TestApplication application;
1542 tet_infoline("Testing Dali::Internal::CameraActor::GetSceneObjectAnimatableProperty()");
1544 CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1545 Actor actor = Actor::New();
1546 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1547 application.GetScene().Add(actor);
1549 Constraint constraint = Constraint::New<Dali::Vector3>(actor, Actor::Property::POSITION, EqualToConstraint());
1550 constraint.AddSource(Source(camera, Actor::Property::POSITION));
1553 camera.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 200.0f, 300.0f));
1554 application.SendNotification();
1555 application.Render();
1557 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(100.0f, 200.0f, 300.0f), TEST_LOCATION);
1561 int UtcDaliCameraActorPropertyIndices(void)
1563 TestApplication application;
1564 CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1566 Actor basicActor = Actor::New();
1567 Property::IndexContainer indices;
1568 camera.GetPropertyIndices(indices);
1569 DALI_TEST_CHECK(indices.Size() > basicActor.GetPropertyCount());
1570 DALI_TEST_EQUALS(indices.Size(), camera.GetPropertyCount(), TEST_LOCATION);
1574 int UtcDaliCameraActorCheckLookAtAndFreeLookViews01(void)
1576 TestApplication application;
1577 Integration::Scene stage = application.GetScene();
1578 Vector2 stageSize = stage.GetSize();
1580 CameraActor freeLookCameraActor = CameraActor::New(stageSize);
1581 freeLookCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1582 freeLookCameraActor.SetType(Camera::FREE_LOOK);
1584 Vector3 targetPosition(30.0f, 240.0f, -256.0f);
1585 Actor target = Actor::New();
1586 target.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1587 target.SetProperty(Actor::Property::POSITION, targetPosition);
1589 Constraint cameraOrientationConstraint = Constraint::New<Quaternion>(freeLookCameraActor, Actor::Property::ORIENTATION, &LookAt);
1590 cameraOrientationConstraint.AddSource(Source(target, Actor::Property::WORLD_POSITION));
1591 cameraOrientationConstraint.AddSource(Source(freeLookCameraActor, Actor::Property::WORLD_POSITION));
1592 cameraOrientationConstraint.AddSource(Source(target, Actor::Property::WORLD_ORIENTATION));
1593 cameraOrientationConstraint.Apply();
1595 CameraActor lookAtCameraActor = CameraActor::New(stageSize);
1596 lookAtCameraActor.SetType(Camera::LOOK_AT_TARGET);
1597 lookAtCameraActor.SetTargetPosition(targetPosition);
1598 lookAtCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1601 stage.Add(freeLookCameraActor);
1602 stage.Add(lookAtCameraActor);
1604 // Create an arbitrary vector
1605 for(float x = -1.0f; x <= 1.0f; x += 0.1f)
1607 for(float y = -1.0f; y < 1.0f; y += 0.1f)
1609 for(float z = -1.0f; z < 1.0f; z += 0.1f)
1611 Vector3 position(x, y, z);
1612 position.Normalize();
1615 freeLookCameraActor.SetProperty(Actor::Property::POSITION, position);
1616 lookAtCameraActor.SetProperty(Actor::Property::POSITION, position);
1618 application.SendNotification();
1619 application.Render();
1620 application.SendNotification();
1621 application.Render();
1622 Matrix freeLookViewMatrix;
1623 Matrix lookAtViewMatrix;
1624 freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(freeLookViewMatrix);
1625 lookAtCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(lookAtViewMatrix);
1627 DALI_TEST_EQUALS(freeLookViewMatrix, lookAtViewMatrix, 0.01, TEST_LOCATION);
1634 int UtcDaliCameraActorCheckLookAtAndFreeLookViews02(void)
1636 TestApplication application;
1637 Integration::Scene stage = application.GetScene();
1638 Vector2 stageSize = stage.GetSize();
1640 CameraActor freeLookCameraActor = CameraActor::New(stageSize);
1641 freeLookCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1642 freeLookCameraActor.SetType(Camera::FREE_LOOK);
1644 Vector3 targetPosition(30.0f, 240.0f, -256.0f);
1645 Actor target = Actor::New();
1646 target.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1647 target.SetProperty(Actor::Property::POSITION, targetPosition);
1649 Constraint cameraOrientationConstraint = Constraint::New<Quaternion>(freeLookCameraActor, Actor::Property::ORIENTATION, &LookAt);
1650 cameraOrientationConstraint.AddSource(Source(target, Actor::Property::WORLD_POSITION));
1651 cameraOrientationConstraint.AddSource(Source(freeLookCameraActor, Actor::Property::WORLD_POSITION));
1652 cameraOrientationConstraint.AddSource(Source(target, Actor::Property::WORLD_ORIENTATION));
1653 cameraOrientationConstraint.Apply();
1655 CameraActor lookAtCameraActor = CameraActor::New(stageSize);
1656 lookAtCameraActor.SetType(Camera::LOOK_AT_TARGET);
1657 lookAtCameraActor.SetTargetPosition(targetPosition);
1658 lookAtCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1661 stage.Add(freeLookCameraActor);
1662 stage.Add(lookAtCameraActor);
1663 stage.GetRenderTaskList().GetTask(0).SetCameraActor(freeLookCameraActor);
1665 // Create an arbitrary vector
1666 for(float x = -1.0f; x <= 1.0f; x += 0.1f)
1668 for(float y = -1.0f; y < 1.0f; y += 0.1f)
1670 for(float z = -1.0f; z < 1.0f; z += 0.1f)
1672 Vector3 position(x, y, z);
1673 position.Normalize();
1676 freeLookCameraActor.SetProperty(Actor::Property::POSITION, position);
1677 lookAtCameraActor.SetProperty(Actor::Property::POSITION, position);
1679 application.SendNotification();
1680 application.Render();
1681 application.SendNotification();
1682 application.Render();
1683 Matrix freeLookViewMatrix;
1684 freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(freeLookViewMatrix);
1686 Matrix freeLookWorld = freeLookCameraActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
1688 Matrix freeLookTest(false);
1689 Matrix::Multiply(freeLookTest, freeLookViewMatrix, freeLookWorld);
1690 DALI_TEST_EQUALS(freeLookTest, Matrix::IDENTITY, 0.01f, TEST_LOCATION);
1698 int UtcDaliCameraActorCheckLookAtAndFreeLookViews03(void)
1700 TestApplication application;
1701 Integration::Scene stage = application.GetScene();
1702 Vector2 stageSize = stage.GetSize();
1704 Vector3 targetPosition(Vector3::ZERO);
1705 Vector3 cameraOffset(0.0f, 0.0f, 100.0f);
1707 CameraActor freeLookCameraActor = CameraActor::New(stageSize);
1708 freeLookCameraActor.SetType(Camera::FREE_LOOK);
1709 freeLookCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1711 Quaternion cameraOrientation(Radian(Degree(180.0f)), Vector3::YAXIS);
1712 freeLookCameraActor.SetProperty(Actor::Property::POSITION, cameraOffset);
1713 freeLookCameraActor.SetProperty(Actor::Property::ORIENTATION, cameraOrientation);
1715 Actor cameraAnchor = Actor::New();
1716 cameraAnchor.Add(freeLookCameraActor);
1717 stage.Add(cameraAnchor);
1718 stage.GetRenderTaskList().GetTask(0).SetCameraActor(freeLookCameraActor);
1720 for(float angle = 1.0f; angle <= 180.0f; angle += 1.0f)
1722 Quaternion rotation(Radian(Degree(angle)), Vector3::YAXIS);
1724 freeLookCameraActor.SetProperty(Actor::Property::POSITION, rotation.Rotate(cameraOffset));
1725 cameraAnchor.SetProperty(Actor::Property::ORIENTATION, rotation);
1727 application.SendNotification();
1728 application.Render();
1729 application.SendNotification();
1730 application.Render();
1732 Matrix freeLookViewMatrix;
1733 freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(freeLookViewMatrix);
1735 Matrix freeLookWorld = freeLookCameraActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
1737 Matrix freeLookTest(false);
1738 Matrix::Multiply(freeLookTest, freeLookViewMatrix, freeLookWorld);
1739 DALI_TEST_EQUALS(freeLookTest, Matrix::IDENTITY, 0.01f, TEST_LOCATION);
1744 int UtcDaliCameraActorReflectionByPlane(void)
1746 TestApplication application;
1748 Integration::Scene stage = application.GetScene();
1750 Vector3 targetPosition(Vector3::ZERO);
1751 Vector3 cameraOffset(0.0f, 100.0f, 100.0f);
1753 CameraActor freeLookCameraActor = stage.GetRenderTaskList().GetTask(0).GetCameraActor();
1754 freeLookCameraActor.SetType(Camera::LOOK_AT_TARGET);
1755 freeLookCameraActor.SetTargetPosition(targetPosition);
1756 freeLookCameraActor.SetProperty(Actor::Property::POSITION, cameraOffset);
1758 stage.GetRootLayer().SetProperty(Actor::Property::POSITION, Vector2(1, 0));
1760 application.SendNotification();
1761 application.Render();
1762 application.SendNotification();
1763 application.Render();
1765 Matrix matrixBefore, matrixAfter;
1766 freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(matrixBefore);
1767 freeLookCameraActor.SetProperty(Dali::DevelCameraActor::Property::REFLECTION_PLANE, Vector4(0.0f, 1.0f, 0.0f, 0.0f));
1768 stage.GetRootLayer().SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1769 application.SendNotification();
1770 application.Render();
1771 application.SendNotification();
1772 application.Render();
1774 freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(matrixAfter);
1776 Vector3 position, scale;
1777 Quaternion rotation;
1778 matrixAfter.GetTransformComponents(position, rotation, scale);
1780 Quaternion reflected(0, 0, 1, 0);
1782 DALI_TEST_EQUALS(reflected, rotation, 0.01f, TEST_LOCATION);
1784 // Test Free Look camera
1785 freeLookCameraActor.SetType(Camera::FREE_LOOK);
1787 // Make sure the recalculation will take place
1788 freeLookCameraActor.SetProperty(Dali::DevelCameraActor::Property::REFLECTION_PLANE, Vector4(0.0f, 1.0f, 0.0f, 0.0f));
1790 application.SendNotification();
1791 application.Render();
1792 application.SendNotification();
1793 application.Render();
1795 // Nothing should change despite of different camera type
1796 matrixAfter.GetTransformComponents(position, rotation, scale);
1797 DALI_TEST_EQUALS(reflected, rotation, 0.01f, TEST_LOCATION);
1802 int UtcDaliCameraActorGetAspectRatioNegative(void)
1804 TestApplication application;
1805 Dali::CameraActor instance;
1808 instance.GetAspectRatio();
1809 DALI_TEST_CHECK(false); // Should not get here
1813 DALI_TEST_CHECK(true); // We expect an assert
1818 int UtcDaliCameraActorGetFieldOfViewNegative(void)
1820 TestApplication application;
1821 Dali::CameraActor instance;
1824 instance.GetFieldOfView();
1825 DALI_TEST_CHECK(false); // Should not get here
1829 DALI_TEST_CHECK(true); // We expect an assert
1834 int UtcDaliCameraActorGetInvertYAxisNegative(void)
1836 TestApplication application;
1837 Dali::CameraActor instance;
1840 instance.GetInvertYAxis();
1841 DALI_TEST_CHECK(false); // Should not get here
1845 DALI_TEST_CHECK(true); // We expect an assert
1850 int UtcDaliCameraActorSetAspectRatioNegative(void)
1852 TestApplication application;
1853 Dali::CameraActor instance;
1857 instance.SetAspectRatio(arg1);
1858 DALI_TEST_CHECK(false); // Should not get here
1862 DALI_TEST_CHECK(true); // We expect an assert
1867 int UtcDaliCameraActorSetFieldOfViewNegative(void)
1869 TestApplication application;
1870 Dali::CameraActor instance;
1874 instance.SetFieldOfView(arg1);
1875 DALI_TEST_CHECK(false); // Should not get here
1879 DALI_TEST_CHECK(true); // We expect an assert
1884 int UtcDaliCameraActorSetInvertYAxisNegative(void)
1886 TestApplication application;
1887 Dali::CameraActor instance;
1891 instance.SetInvertYAxis(arg1);
1892 DALI_TEST_CHECK(false); // Should not get here
1896 DALI_TEST_CHECK(true); // We expect an assert
1901 int UtcDaliCameraActorSetProjectionModeNegative(void)
1903 TestApplication application;
1904 Dali::CameraActor instance;
1907 Dali::Camera::ProjectionMode arg1(Camera::PERSPECTIVE_PROJECTION);
1908 instance.SetProjectionMode(arg1);
1909 DALI_TEST_CHECK(false); // Should not get here
1913 DALI_TEST_CHECK(true); // We expect an assert
1918 int UtcDaliCameraActorSetTargetPositionNegative(void)
1920 TestApplication application;
1921 Dali::CameraActor instance;
1925 instance.SetTargetPosition(arg1);
1926 DALI_TEST_CHECK(false); // Should not get here
1930 DALI_TEST_CHECK(true); // We expect an assert
1935 int UtcDaliCameraActorGetFarClippingPlaneNegative(void)
1937 TestApplication application;
1938 Dali::CameraActor instance;
1941 instance.GetFarClippingPlane();
1942 DALI_TEST_CHECK(false); // Should not get here
1946 DALI_TEST_CHECK(true); // We expect an assert
1951 int UtcDaliCameraActorSetFarClippingPlaneNegative(void)
1953 TestApplication application;
1954 Dali::CameraActor instance;
1958 instance.SetFarClippingPlane(arg1);
1959 DALI_TEST_CHECK(false); // Should not get here
1963 DALI_TEST_CHECK(true); // We expect an assert
1968 int UtcDaliCameraActorGetNearClippingPlaneNegative(void)
1970 TestApplication application;
1971 Dali::CameraActor instance;
1974 instance.GetNearClippingPlane();
1975 DALI_TEST_CHECK(false); // Should not get here
1979 DALI_TEST_CHECK(true); // We expect an assert
1984 int UtcDaliCameraActorSetNearClippingPlaneNegative(void)
1986 TestApplication application;
1987 Dali::CameraActor instance;
1991 instance.SetNearClippingPlane(arg1);
1992 DALI_TEST_CHECK(false); // Should not get here
1996 DALI_TEST_CHECK(true); // We expect an assert
2001 int UtcDaliCameraActorSetPerspectiveProjectionNegative(void)
2003 TestApplication application;
2004 Dali::CameraActor instance;
2008 instance.SetPerspectiveProjection(arg1);
2009 DALI_TEST_CHECK(false); // Should not get here
2013 DALI_TEST_CHECK(true); // We expect an assert
2018 int UtcDaliCameraActorSetOrthographicProjectionNegative01(void)
2020 TestApplication application;
2021 Dali::CameraActor instance;
2030 instance.SetOrthographicProjection(arg1, arg2, arg3, arg4, arg5, arg6);
2031 DALI_TEST_CHECK(false); // Should not get here
2035 DALI_TEST_CHECK(true); // We expect an assert
2040 int UtcDaliCameraActorSetOrthographicProjectionNegative02(void)
2042 TestApplication application;
2043 Dali::CameraActor instance;
2047 instance.SetOrthographicProjection(arg1);
2048 DALI_TEST_CHECK(false); // Should not get here
2052 DALI_TEST_CHECK(true); // We expect an assert
2057 int UtcDaliCameraActorSetTypeNegative(void)
2059 TestApplication application;
2060 Dali::CameraActor instance;
2063 Dali::Camera::Type arg1(Camera::FREE_LOOK);
2064 instance.SetType(arg1);
2065 DALI_TEST_CHECK(false); // Should not get here
2069 DALI_TEST_CHECK(true); // We expect an assert
2074 int UtcDaliCameraActorGetProjectionModeNegative(void)
2076 TestApplication application;
2077 Dali::CameraActor instance;
2080 instance.GetProjectionMode();
2081 DALI_TEST_CHECK(false); // Should not get here
2085 DALI_TEST_CHECK(true); // We expect an assert
2090 int UtcDaliCameraActorGetTargetPositionNegative(void)
2092 TestApplication application;
2093 Dali::CameraActor instance;
2096 instance.GetTargetPosition();
2097 DALI_TEST_CHECK(false); // Should not get here
2101 DALI_TEST_CHECK(true); // We expect an assert
2106 int UtcDaliCameraActorGetTypeNegative(void)
2108 TestApplication application;
2109 Dali::CameraActor instance;
2113 DALI_TEST_CHECK(false); // Should not get here
2117 DALI_TEST_CHECK(true); // We expect an assert