[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-CameraActor.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali/public-api/dali-core.h>
19
20 #include <dali/devel-api/actors/actor-devel.h>
21 #include <dali/devel-api/actors/camera-actor-devel.h>
22 #include <stdlib.h>
23
24 #include <cmath>
25 #include <iostream>
26
27 #include "dali-test-suite-utils/dali-test-suite-utils.h"
28
29 using namespace Dali;
30
31 void camera_actor_test_startup(void)
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void camera_actor_test_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41 namespace
42 {
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;
48
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"
54   "\n"
55   "void main()\n"
56   "{\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"
60   "}\n";
61
62 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
63   "uniform lowp vec4 uShadowColor;\n"
64   "void main()\n"
65   "{\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"
69   "}\n";
70
71 struct PropertyDetails
72 {
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.
79 };
80
81 } // Anonymous namespace
82
83 int UtcDaliCameraActorConstructorP(void)
84 {
85   TestApplication application;
86   tet_infoline("Testing Dali::CameraActor::CameraActor()");
87
88   CameraActor actor;
89
90   DALI_TEST_CHECK(!actor);
91   END_TEST;
92 }
93
94 // Note: No negative test for UtcDaliCameraActorConstructor.
95
96 int UtcDaliCameraActorDestructorP(void)
97 {
98   TestApplication application;
99   tet_infoline("Testing Dali::~CameraActor (P)");
100   CameraActor* actor = new CameraActor();
101   delete actor;
102   actor = NULL;
103
104   DALI_TEST_CHECK(true);
105   END_TEST;
106 }
107
108 // Note: No negative test for UtcDaliCameraActorDestructor.
109
110 int UtcDaliCameraActorCopyConstructorP(void)
111 {
112   TestApplication application;
113   tet_infoline("Testing Dali::CameraActor Copy Constructor (P)");
114   CameraActor actor = CameraActor::New();
115
116   CameraActor copyActor(actor);
117
118   DALI_TEST_CHECK(copyActor);
119   DALI_TEST_CHECK(copyActor == actor);
120
121   END_TEST;
122 }
123
124 int UtcDaliCameraActorCopyConstructorN(void)
125 {
126   TestApplication application;
127   tet_infoline("Testing Dali::CameraActor Copy Constructor (N)");
128   CameraActor actor;
129
130   CameraActor copyActor(actor);
131
132   DALI_TEST_CHECK(!copyActor);
133
134   END_TEST;
135 }
136
137 int UtcDaliCameraActorAssignmentOperatorP(void)
138 {
139   TestApplication application;
140   tet_infoline("Testing Dali::CameraActor Assignment Operator (P)");
141   const CameraActor actor = CameraActor::New();
142
143   CameraActor copyActor = actor;
144
145   DALI_TEST_CHECK(copyActor);
146   DALI_TEST_CHECK(copyActor == actor);
147
148   END_TEST;
149 }
150
151 int UtcDaliCameraActorAssignmentOperatorN(void)
152 {
153   TestApplication application;
154   tet_infoline("Testing Dali::CameraActor = (N)");
155   CameraActor actor;
156
157   CameraActor copyActor = actor;
158
159   DALI_TEST_CHECK(!copyActor);
160
161   END_TEST;
162 }
163
164 int UtcDaliCameraActorMoveConstructor(void)
165 {
166   TestApplication application;
167
168   CameraActor actor = CameraActor::New();
169   DALI_TEST_CHECK(actor);
170
171   int id = actor.GetProperty<int>(Actor::Property::ID);
172
173   CameraActor moved = std::move(actor);
174   DALI_TEST_CHECK(moved);
175   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
176   DALI_TEST_CHECK(!actor);
177
178   END_TEST;
179 }
180
181 int UtcDaliCameraActorMoveAssignment(void)
182 {
183   TestApplication application;
184
185   CameraActor actor = CameraActor::New();
186   DALI_TEST_CHECK(actor);
187
188   int id = actor.GetProperty<int>(Actor::Property::ID);
189
190   CameraActor moved;
191   moved = std::move(actor);
192   DALI_TEST_CHECK(moved);
193   DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
194   DALI_TEST_CHECK(!actor);
195
196   END_TEST;
197 }
198
199 int UtcDaliCameraActorNewP(void)
200 {
201   TestApplication application;
202   tet_infoline("Testing Dali::CameraActor::New (P)");
203
204   CameraActor actor = CameraActor::New();
205
206   DALI_TEST_CHECK(actor);
207
208   actor.Reset();
209
210   DALI_TEST_CHECK(!actor);
211   END_TEST;
212 }
213
214 int UtcDaliCameraActorNew3DCameraP(void)
215 {
216   TestApplication application;
217   tet_infoline("Testing Dali::CameraActor::New3DCamera (P)");
218
219   CameraActor actor = CameraActor::New3DCamera();
220
221   DALI_TEST_CHECK(actor);
222
223   actor.Reset();
224
225   DALI_TEST_CHECK(!actor);
226   END_TEST;
227 }
228
229 int UtcDaliCameraActorNewDefaultPerspectiveProjection(void)
230 {
231   TestApplication application;
232   tet_infoline("Test the perspective projection of a camera actor is set appropriately when not passing in a size");
233
234   CameraActor actor = CameraActor::New();
235   DALI_TEST_CHECK(actor);
236
237   // All the properties should still be the default values
238   // Defaults taken from scene-graph-camera.cpp
239   DALI_TEST_EQUALS(480.0f / 800.0f, actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
240   DALI_TEST_EQUALS(45.0f * (Math::PI / 180.0f), actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
241   DALI_TEST_EQUALS(800.0f, actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
242   DALI_TEST_EQUALS(3.0f * 800.0f, actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
243   DALI_TEST_EQUALS(400.0f, actor.GetProperty(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
244   DALI_TEST_EQUALS(0.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
245   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
246
247   // Add it to the stage, then the values should be updated to reflect a 480.0f by 800.0f scene (default stage size)
248   application.GetScene().Add(actor);
249
250   DALI_TEST_EQUALS(0.6f, actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
251   DALI_TEST_EQUALS(0.489957f, actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
252   DALI_TEST_EQUALS(800.0f, actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
253   DALI_TEST_EQUALS(4895.0f, actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
254   DALI_TEST_EQUALS(400.0f, actor.GetProperty(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
255   DALI_TEST_EQUALS(1600.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
256   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
257
258   // Ensure the values stay the same after update/render
259   application.SendNotification();
260   application.Render();
261
262   DALI_TEST_EQUALS(0.6f, actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
263   DALI_TEST_EQUALS(0.489957f, actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
264   DALI_TEST_EQUALS(800.0f, actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
265   DALI_TEST_EQUALS(4895.0f, actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
266   DALI_TEST_EQUALS(400.0f, actor.GetProperty(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
267   DALI_TEST_EQUALS(1600.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
268   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
269
270   END_TEST;
271 }
272
273 // Note: No negative test for UtcDaliCameraActorNew.
274
275 int UtcDaliCameraActorDownCastP(void)
276 {
277   TestApplication application;
278   tet_infoline("Testing Dali::CameraActor::DownCast (P)");
279
280   CameraActor camera  = CameraActor::New();
281   Actor       anActor = Actor::New();
282   anActor.Add(camera);
283
284   Actor       child       = anActor.GetChildAt(0);
285   CameraActor cameraActor = CameraActor::DownCast(child);
286   DALI_TEST_CHECK(cameraActor);
287
288   cameraActor.Reset();
289   DALI_TEST_CHECK(!cameraActor);
290
291   cameraActor = DownCast<CameraActor>(child);
292   DALI_TEST_CHECK(cameraActor);
293   END_TEST;
294 }
295
296 int UtcDaliCameraActorDownCastN(void)
297 {
298   TestApplication application;
299   tet_infoline("Testing Dali::CameraActor::DownCast (N)");
300
301   Actor actor1  = Actor::New();
302   Actor anActor = Actor::New();
303   anActor.Add(actor1);
304
305   Actor       child       = anActor.GetChildAt(0);
306   CameraActor cameraActor = CameraActor::DownCast(child);
307   DALI_TEST_CHECK(!cameraActor);
308
309   Actor unInitialzedActor;
310   cameraActor = CameraActor::DownCast(unInitialzedActor);
311   DALI_TEST_CHECK(!cameraActor);
312
313   cameraActor = DownCast<CameraActor>(unInitialzedActor);
314   DALI_TEST_CHECK(!cameraActor);
315   END_TEST;
316 }
317
318 // Note: SetType and GetType are tested within the same test cases.
319
320 int UtcDaliCameraActorSetGetTypeP(void)
321 {
322   TestApplication application;
323   tet_infoline("Testing Dali::CameraActor GetType (P)");
324
325   CameraActor actor = CameraActor::New();
326   DALI_TEST_EQUALS(actor.GetType(), Dali::Camera::FREE_LOOK, TEST_LOCATION);
327
328   actor.SetType(Dali::Camera::LOOK_AT_TARGET);
329   DALI_TEST_EQUALS(actor.GetType(), Dali::Camera::LOOK_AT_TARGET, TEST_LOCATION);
330
331   Dali::Camera::Type cameraType        = actor.GetProperty<Dali::Camera::Type>(CameraActor::Property::TYPE);
332   Dali::Camera::Type currentCameraType = actor.GetCurrentProperty<Dali::Camera::Type>(CameraActor::Property::TYPE);
333   DALI_TEST_EQUALS(Camera::LOOK_AT_TARGET, cameraType, TEST_LOCATION);
334   DALI_TEST_EQUALS(Camera::LOOK_AT_TARGET, currentCameraType, TEST_LOCATION);
335   END_TEST;
336 }
337
338 int UtcDaliCameraActorSetGetTypeN(void)
339 {
340   TestApplication application;
341   tet_infoline("Testing Dali::CameraActor GetType (N)");
342
343   CameraActor actor;
344
345   Dali::Camera::Type cameraType = Dali::Camera::FREE_LOOK;
346   try
347   {
348     cameraType = actor.GetType();
349   }
350   catch(Dali::DaliException& e)
351   {
352     DALI_TEST_PRINT_ASSERT(e);
353     DALI_TEST_ASSERT(e, "camera", TEST_LOCATION);
354   }
355
356   const CameraActor aConstActor;
357
358   try
359   {
360     cameraType = aConstActor.GetType();
361   }
362   catch(Dali::DaliException& e)
363   {
364     DALI_TEST_PRINT_ASSERT(e);
365     DALI_TEST_ASSERT(e, "camera", TEST_LOCATION);
366   }
367
368   DALI_TEST_EQUALS(cameraType, Dali::Camera::FREE_LOOK, TEST_LOCATION);
369   END_TEST;
370 }
371
372 int UtcDaliCameraActorSetFieldOfViewP(void)
373 {
374   TestApplication application;
375   tet_infoline("Testing Dali::CameraActor Set Field of view (P)");
376
377   CameraActor defaultCamera      = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
378   const float defaultFieldOfView = defaultCamera.GetFieldOfView();
379
380   CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
381   DALI_TEST_EQUALS(actor.GetFieldOfView(), defaultFieldOfView, TEST_LOCATION);
382
383   float fieldOfView = Math::PI / 3.0f;
384   actor.SetFieldOfView(fieldOfView);
385   DALI_TEST_EQUALS(actor.GetFieldOfView(), fieldOfView, TEST_LOCATION);
386
387   float value;
388   actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
389   DALI_TEST_EQUALS(fieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
390   END_TEST;
391 }
392
393 int UtcDaliCameraActorSetFieldOfViewN(void)
394 {
395   TestApplication application;
396   tet_infoline("Testing Dali::CameraActor Set Field of view (N)");
397
398   CameraActor defaultCamera      = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
399   const float defaultFieldOfView = defaultCamera.GetFieldOfView();
400
401   CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
402   DALI_TEST_EQUALS(actor.GetFieldOfView(), defaultFieldOfView, TEST_LOCATION);
403
404   float fieldOfView = Math::PI / 3.0f;
405   actor.SetFieldOfView(fieldOfView);
406   DALI_TEST_EQUALS(actor.GetFieldOfView(), fieldOfView, TEST_LOCATION);
407
408   float value;
409   actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
410   DALI_TEST_EQUALS(fieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
411   END_TEST;
412 }
413
414 int UtcDaliCameraActorGetFieldOfViewP(void)
415 {
416   TestApplication application;
417   tet_infoline("Testing Dali::CameraActor Get Field of view (P)");
418   const Vector2 size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
419
420   CameraActor defaultCamera = CameraActor::New(size);
421
422   const float cameraZ             = 2.0f * std::max(size.width, size.height);
423   const float expectedFieldOfView = 2.0f * std::atan(size.height * 0.5f / cameraZ);
424
425   CameraActor actor = CameraActor::New(size);
426   DALI_TEST_EQUALS(actor.GetFieldOfView(), expectedFieldOfView, TEST_LOCATION);
427
428   float value;
429   actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
430   DALI_TEST_EQUALS(expectedFieldOfView, value, FLOAT_EPSILON, TEST_LOCATION);
431   END_TEST;
432 }
433
434 int UtcDaliCameraActorGetFieldOfViewN(void)
435 {
436   TestApplication application;
437   tet_infoline("Testing Dali::CameraActor Get Field of view (N)");
438
439   CameraActor defaultCamera = CameraActor::New();
440
441   bool asserted = true;
442   try
443   {
444     defaultCamera.GetFieldOfView();
445   }
446   catch(Dali::DaliException& e)
447   {
448     DALI_TEST_PRINT_ASSERT(e);
449     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
450     asserted = true;
451   }
452   DALI_TEST_CHECK(asserted);
453
454   END_TEST;
455 }
456
457 int UtcDaliCameraActorSetAspectRatioP(void)
458 {
459   TestApplication application;
460   tet_infoline("Testing Dali::CameraActor Set Aspect Ratio (P)");
461
462   CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
463   DALI_TEST_EQUALS(actor.GetAspectRatio(), static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH) / static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT), TEST_LOCATION);
464
465   // Set an initial value to confirm a further set changes it.
466   float aspect = 4.0f / 3.0f;
467   actor.SetAspectRatio(aspect);
468   DALI_TEST_EQUALS(actor.GetAspectRatio(), aspect, TEST_LOCATION);
469
470   aspect = 16.0f / 9.0f;
471   actor.SetAspectRatio(aspect);
472   DALI_TEST_EQUALS(actor.GetAspectRatio(), aspect, TEST_LOCATION);
473
474   END_TEST;
475 }
476
477 int UtcDaliCameraActorSetAspectRatioN(void)
478 {
479   TestApplication application;
480   tet_infoline("Testing Dali::CameraActor Set Aspect Ratio (N)");
481
482   CameraActor actor;
483
484   bool asserted = true;
485   try
486   {
487     actor.SetAspectRatio(16.0f / 9.0f);
488   }
489   catch(Dali::DaliException& e)
490   {
491     DALI_TEST_PRINT_ASSERT(e);
492     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
493     asserted = true;
494   }
495   DALI_TEST_CHECK(asserted);
496
497   END_TEST;
498 }
499
500 int UtcDaliCameraActorGetAspectRatioP(void)
501 {
502   TestApplication application;
503   tet_infoline("Testing Dali::CameraActor Get Aspect Ratio");
504
505   CameraActor actor         = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
506   float       defaultAspect = static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH) / static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT);
507
508   DALI_TEST_EQUALS(actor.GetAspectRatio(), defaultAspect, TEST_LOCATION);
509
510   float value = 0.0f;
511   actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
512   DALI_TEST_EQUALS(defaultAspect, value, FLOAT_EPSILON, TEST_LOCATION);
513
514   END_TEST;
515 }
516
517 int UtcDaliCameraActorGetAspectRatioN(void)
518 {
519   TestApplication application;
520   tet_infoline("Testing Dali::CameraActor Get Aspect Ratio (N)");
521
522   CameraActor actor;
523
524   bool asserted = true;
525   try
526   {
527     actor.GetAspectRatio();
528   }
529   catch(Dali::DaliException& e)
530   {
531     DALI_TEST_PRINT_ASSERT(e);
532     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
533     asserted = true;
534   }
535
536   DALI_TEST_CHECK(asserted);
537
538   END_TEST;
539 }
540
541 int UtcDaliCameraActorSetNearClippingPlaneP(void)
542 {
543   TestApplication application;
544   tet_infoline("Testing Dali::CameraActor Set Near clipping plane (P)");
545
546   CameraActor actor = CameraActor::New();
547
548   // Set a value so we are not relying on a particular default for this test case.
549   actor.SetNearClippingPlane(200.0f);
550   DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 200.0f, TEST_LOCATION);
551
552   actor.SetNearClippingPlane(400.0f);
553   DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 400.0f, TEST_LOCATION);
554
555   // Check setting the property.
556   actor.SetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE, Property::Value(300.0f));
557   DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 300.0f, FLOAT_EPSILON, TEST_LOCATION);
558   END_TEST;
559 }
560
561 int UtcDaliCameraActorSetNearClippingPlaneN(void)
562 {
563   TestApplication application;
564   tet_infoline("Testing Dali::CameraActor Set Near clipping plane (N)");
565
566   CameraActor actor;
567
568   bool asserted = true;
569   try
570   {
571     actor.SetNearClippingPlane(200.0f);
572   }
573   catch(Dali::DaliException& e)
574   {
575     DALI_TEST_PRINT_ASSERT(e);
576     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
577     asserted = true;
578   }
579
580   DALI_TEST_CHECK(asserted);
581
582   END_TEST;
583 }
584
585 int UtcDaliCameraActorGetNearClippingPlaneP(void)
586 {
587   TestApplication application;
588   tet_infoline("Testing Dali::CameraActor Get Near clipping plane (P)");
589
590   // Check the default value.
591   CameraActor actor        = CameraActor::New();
592   float       defaultValue = 800.0f;
593   DALI_TEST_EQUALS(actor.GetNearClippingPlane(), defaultValue, TEST_LOCATION);
594
595   // Check getting the property.
596   float value;
597   actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
598   DALI_TEST_EQUALS(defaultValue, value, FLOAT_EPSILON, TEST_LOCATION);
599   END_TEST;
600 }
601
602 int UtcDaliCameraActorGetNearClippingPlaneN(void)
603 {
604   TestApplication application;
605   tet_infoline("Testing Dali::CameraActor Get Near clipping plane (N)");
606
607   CameraActor actor;
608   bool        asserted = true;
609   try
610   {
611     actor.GetNearClippingPlane();
612   }
613   catch(Dali::DaliException& e)
614   {
615     DALI_TEST_PRINT_ASSERT(e);
616     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
617     asserted = true;
618   }
619
620   DALI_TEST_CHECK(asserted);
621
622   END_TEST;
623 }
624
625 int UtcDaliCameraActorSetFarClippingPlaneP(void)
626 {
627   TestApplication application;
628   tet_infoline("Testing Dali::CameraActor Set Far clipping plane (P)");
629
630   CameraActor actor = CameraActor::New();
631
632   // Set a value so we are not relying on a particular default for this test case.
633   actor.SetFarClippingPlane(2000.0f);
634   DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 2000.0f, TEST_LOCATION);
635
636   actor.SetFarClippingPlane(4000.0f);
637   DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 4000.0f, TEST_LOCATION);
638
639   // Check setting the property.
640   actor.SetProperty(CameraActor::Property::FAR_PLANE_DISTANCE, 2000.0f);
641   DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 2000.0f, FLOAT_EPSILON, TEST_LOCATION);
642   END_TEST;
643 }
644
645 int UtcDaliCameraActorSetFarClippingPlaneN(void)
646 {
647   TestApplication application;
648   tet_infoline("Testing Dali::CameraActor Set Far clipping plane (N)");
649
650   CameraActor actor;
651
652   bool asserted = true;
653   try
654   {
655     actor.SetFarClippingPlane(2000.0f);
656   }
657   catch(Dali::DaliException& e)
658   {
659     DALI_TEST_PRINT_ASSERT(e);
660     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
661     asserted = true;
662   }
663
664   DALI_TEST_CHECK(asserted);
665
666   END_TEST;
667 }
668
669 int UtcDaliCameraActorGetFarClippingPlaneP(void)
670 {
671   TestApplication application;
672   tet_infoline("Testing Dali::CameraActor Get Far clipping plane (P)");
673
674   CameraActor actor        = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
675   float       defaultValue = 800.0f + (0xFFFF >> 4);
676   DALI_TEST_EQUALS(actor.GetFarClippingPlane(), defaultValue, TEST_LOCATION);
677
678   // Check getting the property.
679   float value;
680   actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
681   DALI_TEST_EQUALS(defaultValue, value, FLOAT_EPSILON, TEST_LOCATION);
682   END_TEST;
683 }
684
685 int UtcDaliCameraActorGetFarClippingPlaneN(void)
686 {
687   TestApplication application;
688   tet_infoline("Testing Dali::CameraActor Get Far clipping plane (N)");
689
690   CameraActor actor;
691
692   bool asserted = true;
693   try
694   {
695     actor.GetFarClippingPlane();
696   }
697   catch(Dali::DaliException& e)
698   {
699     DALI_TEST_PRINT_ASSERT(e);
700     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
701     asserted = true;
702   }
703
704   DALI_TEST_CHECK(asserted);
705
706   END_TEST;
707 }
708
709 int UtcDaliCameraActorSetTargetPositionP(void)
710 {
711   TestApplication application;
712   tet_infoline("Testing Dali::CameraActor Set Target Position (P)");
713
714   CameraActor actor = CameraActor::New();
715
716   Vector3 target1(10.0f, 20.0f, 30.0f);
717   Vector3 target2(15.0f, 25.0f, 35.0f);
718
719   // Set a value so we are not relying on a particular default for this test case.
720   actor.SetTargetPosition(target1);
721   DALI_TEST_EQUALS(actor.GetTargetPosition(), target1, TEST_LOCATION);
722
723   actor.SetTargetPosition(target2);
724   DALI_TEST_EQUALS(actor.GetTargetPosition(), target2, TEST_LOCATION);
725
726   // Check setting the property.
727   actor.SetProperty(CameraActor::Property::TARGET_POSITION, target1);
728   DALI_TEST_EQUALS(actor.GetTargetPosition(), target1, FLOAT_EPSILON, TEST_LOCATION);
729   END_TEST;
730 }
731
732 int UtcDaliCameraActorSetTargetPositionN(void)
733 {
734   TestApplication application;
735   tet_infoline("Testing Dali::CameraActor Set Target Position (N)");
736
737   CameraActor actor;
738
739   bool asserted = true;
740   try
741   {
742     actor.SetTargetPosition(Vector3(10.0f, 20.0f, 30.0f));
743   }
744   catch(Dali::DaliException& e)
745   {
746     DALI_TEST_PRINT_ASSERT(e);
747     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
748     asserted = true;
749   }
750   DALI_TEST_CHECK(asserted);
751
752   END_TEST;
753 }
754
755 int UtcDaliCameraActorGetTargetPositionP(void)
756 {
757   TestApplication application;
758   tet_infoline("Testing Dali::CameraActor Get Target Position (P)");
759
760   CameraActor actor = CameraActor::New();
761   Vector3     defaultValue(Vector3::ZERO);
762   DALI_TEST_EQUALS(actor.GetTargetPosition(), defaultValue, TEST_LOCATION);
763
764   // Check getting the property.
765   Vector3 value;
766   actor.GetProperty(CameraActor::Property::TARGET_POSITION).Get(value);
767   DALI_TEST_EQUALS(defaultValue, value, FLOAT_EPSILON, TEST_LOCATION);
768   END_TEST;
769 }
770
771 int UtcDaliCameraActorGetTargetPositionN(void)
772 {
773   TestApplication application;
774   tet_infoline("Testing Dali::CameraActor Get Target Position (N)");
775
776   CameraActor actor;
777
778   bool asserted = true;
779   try
780   {
781     actor.GetTargetPosition();
782   }
783   catch(Dali::DaliException& e)
784   {
785     DALI_TEST_PRINT_ASSERT(e);
786     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
787     asserted = true;
788   }
789   DALI_TEST_CHECK(asserted);
790
791   END_TEST;
792 }
793
794 int UtcDaliCameraActorSetInvertYAxisP(void)
795 {
796   TestApplication application;
797   tet_infoline("Testing Dali::CameraActor Set InvertYAxis (P)");
798
799   CameraActor actor = CameraActor::New();
800
801   // Set a value so we are not relying on a particular default for this test case.
802   actor.SetInvertYAxis(false);
803   DALI_TEST_EQUALS(actor.GetInvertYAxis(), false, TEST_LOCATION);
804
805   actor.SetInvertYAxis(true);
806   DALI_TEST_EQUALS(actor.GetInvertYAxis(), true, TEST_LOCATION);
807
808   actor.SetProperty(CameraActor::Property::INVERT_Y_AXIS, false);
809   DALI_TEST_EQUALS(actor.GetInvertYAxis(), false, TEST_LOCATION);
810   END_TEST;
811 }
812
813 int UtcDaliCameraActorSetInvertYAxisN(void)
814 {
815   TestApplication application;
816   tet_infoline("Testing Dali::CameraActor Set InvertYAxis (N)");
817
818   CameraActor actor;
819
820   bool asserted = true;
821   try
822   {
823     actor.SetInvertYAxis(false);
824   }
825   catch(Dali::DaliException& e)
826   {
827     DALI_TEST_PRINT_ASSERT(e);
828     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
829     asserted = true;
830   }
831   DALI_TEST_CHECK(asserted);
832   END_TEST;
833 }
834
835 int UtcDaliCameraActorGetInvertYAxisP(void)
836 {
837   TestApplication application;
838   tet_infoline("Testing Dali::CameraActor Get InvertYAxis (P)");
839
840   // Check the default value.
841   CameraActor actor = CameraActor::New();
842   DALI_TEST_EQUALS(actor.GetInvertYAxis(), false, TEST_LOCATION);
843
844   // Check getting the property.
845   bool bValue;
846   actor.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(bValue);
847   DALI_TEST_EQUALS(false, bValue, TEST_LOCATION);
848   END_TEST;
849 }
850
851 int UtcDaliCameraActorGetInvertYAxisN(void)
852 {
853   TestApplication application;
854   tet_infoline("Testing Dali::CameraActor Get InvertYAxis (N)");
855
856   CameraActor actor;
857
858   bool asserted = true;
859   try
860   {
861     actor.GetInvertYAxis();
862   }
863   catch(Dali::DaliException& e)
864   {
865     DALI_TEST_PRINT_ASSERT(e);
866     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
867     asserted = true;
868   }
869   DALI_TEST_CHECK(asserted);
870   END_TEST;
871 }
872
873 int UtcDaliCameraActorSetGetOthographicSizeP(void)
874 {
875   TestApplication application;
876   tet_infoline("Testing Dali::CameraActor Set Orthographic Size (P)");
877
878   CameraActor actor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
879   actor.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
880
881   // Get default orthographic size by inputed size
882   DALI_TEST_EQUALS(actor.GetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE).Get<float>(), static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT) * 0.5f, TEST_LOCATION);
883
884   float value = 0.0f;
885
886   // Set an initial value to confirm a further set changes it.
887   float size = 300.0f;
888   actor.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, size);
889
890   value = 0.0f;
891   DALI_TEST_CHECK(actor.GetProperty(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE).Get(value));
892   DALI_TEST_EQUALS(value, size, TEST_LOCATION);
893
894   size = 1600.0f;
895   actor.SetProperty(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, size);
896
897   value = 0.0f;
898   DALI_TEST_CHECK(actor.GetProperty(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE).Get(value));
899   DALI_TEST_EQUALS(value, size, TEST_LOCATION);
900
901   actor.SetProperty(DevelCameraActor::Property::PROJECTION_DIRECTION, DevelCameraActor::ProjectionDirection::HORIZONTAL);
902
903   size = 600.0f;
904   actor.SetProperty(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, size);
905
906   value = 0.0f;
907   DALI_TEST_CHECK(actor.GetProperty(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE).Get(value));
908   DALI_TEST_EQUALS(value, size, TEST_LOCATION);
909
910   END_TEST;
911 }
912
913 int UtcDaliCameraActorSetPerspectiveProjectionP(void)
914 {
915   TestApplication application;
916   tet_infoline("Testing Dali::CameraActor::SetPerspectiveProjection (P)");
917
918   CameraActor actor = CameraActor::New();
919   actor.SetPerspectiveProjection(Size(100.f, 150.f));
920
921   DALI_TEST_CHECK(actor);
922
923   float value;
924   actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
925   DALI_TEST_EQUALS(0.666666f, value, FLOAT_EPSILON, TEST_LOCATION);
926   actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
927   DALI_TEST_EQUALS(0.489957f, value, FLOAT_EPSILON, TEST_LOCATION);
928   actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
929   DALI_TEST_EQUALS(150.f, value, FLOAT_EPSILON, TEST_LOCATION);
930   actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
931   DALI_TEST_EQUALS(4245.f, value, FLOAT_EPSILON, TEST_LOCATION);
932
933   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
934
935   // Ensure these values persist after adding to the stage and an update/render pass
936   application.GetScene().Add(actor);
937   application.SendNotification();
938   application.Render();
939
940   actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
941   DALI_TEST_EQUALS(0.666666f, value, FLOAT_EPSILON, TEST_LOCATION);
942   actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
943   DALI_TEST_EQUALS(0.489957f, value, FLOAT_EPSILON, TEST_LOCATION);
944   actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
945   DALI_TEST_EQUALS(150.f, value, FLOAT_EPSILON, TEST_LOCATION);
946   actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
947   DALI_TEST_EQUALS(4245.f, value, FLOAT_EPSILON, TEST_LOCATION);
948
949   // Call method with a ZERO size, this should reset the perspective projection using the size of the scene we've been added to
950   actor.SetPerspectiveProjection(Vector2::ZERO);
951
952   DALI_TEST_EQUALS(0.6f, actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
953   DALI_TEST_EQUALS(0.489957f, actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
954   DALI_TEST_EQUALS(800.0f, actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
955   DALI_TEST_EQUALS(4895.0f, actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get<float>(), FLOAT_EPSILON, TEST_LOCATION);
956   DALI_TEST_EQUALS(1600.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
957   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
958
959   END_TEST;
960 }
961
962 int UtcDaliCameraActorSetPerspectiveProjectionN(void)
963 {
964   TestApplication application;
965   tet_infoline("Testing Dali::CameraActor::SetPerspectiveProjection (N)");
966
967   CameraActor actor = CameraActor::New();
968
969   // Check that setting perspective projection without a size does not do anything.
970   actor.SetPerspectiveProjection(Size::ZERO);
971
972   // So the default values should be the same as defined in CameraActor
973   float nearClippingPlane = 800.0f;
974   float farClippingPlane  = nearClippingPlane + 2.0f * nearClippingPlane;
975
976   DALI_TEST_EQUALS(nearClippingPlane, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
977   DALI_TEST_EQUALS(farClippingPlane, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
978   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
979
980   END_TEST;
981 }
982
983 int UtcDaliCameraActorSetOrthographicProjectionP1(void)
984 {
985   TestApplication application;
986   tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection (P,1)");
987
988   CameraActor actor = CameraActor::New(Size(1080.0f, 1920.0f));
989   DALI_TEST_CHECK(actor);
990
991   application.GetScene().Add(actor);
992
993   actor.SetOrthographicProjection(Size(1080.0f, 1920.0f));
994
995   application.SendNotification();
996   application.Render(0);
997   application.Render();
998   application.SendNotification();
999
1000   float defaultAspectRatio;
1001   float defaultNearPlaneDistance;
1002   float defaultFarPlaneDistance;
1003   actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(defaultAspectRatio);
1004   actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(defaultNearPlaneDistance);
1005   actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(defaultFarPlaneDistance);
1006   Vector3 defaultPos = actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1007
1008   auto TestOrthographicPlaneDistance = [&](float width, float height, float expectOrthographicSize) {
1009     actor.SetOrthographicProjection(Size(width, height));
1010
1011     DALI_TEST_EQUALS(expectOrthographicSize, actor.GetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE).Get<float>(), TEST_LOCATION);
1012
1013     application.SendNotification();
1014     application.Render(0);
1015     application.Render();
1016     application.SendNotification();
1017
1018     float value;
1019     actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
1020     DALI_TEST_EQUALS(defaultAspectRatio, value, FLOAT_EPSILON, TEST_LOCATION);
1021     actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
1022     DALI_TEST_EQUALS(defaultNearPlaneDistance, value, FLOAT_EPSILON, TEST_LOCATION);
1023     actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
1024     DALI_TEST_EQUALS(defaultFarPlaneDistance, value, FLOAT_EPSILON, TEST_LOCATION);
1025
1026     actor.GetProperty(CameraActor::Property::LEFT_PLANE_DISTANCE).Get(value);
1027     DALI_TEST_EQUALS(-540.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1028     actor.GetProperty(CameraActor::Property::RIGHT_PLANE_DISTANCE).Get(value);
1029     DALI_TEST_EQUALS(540.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1030     actor.GetProperty(CameraActor::Property::TOP_PLANE_DISTANCE).Get(value);
1031     DALI_TEST_EQUALS(960.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1032     actor.GetProperty(CameraActor::Property::BOTTOM_PLANE_DISTANCE).Get(value);
1033     DALI_TEST_EQUALS(-960.0f, value, FLOAT_EPSILON, TEST_LOCATION);
1034
1035     Vector3 pos = actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
1036     DALI_TEST_EQUALS(defaultPos.z, pos.z, 0.001f, TEST_LOCATION);
1037
1038     DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
1039   };
1040
1041   TestOrthographicPlaneDistance(1080.0f, 1920.0f, 960.0f);
1042   // Change projection direction
1043   actor.SetProperty(DevelCameraActor::Property::PROJECTION_DIRECTION, DevelCameraActor::ProjectionDirection::HORIZONTAL);
1044   TestOrthographicPlaneDistance(1080.0f, 1920.0f, 540.0f);
1045   END_TEST;
1046 }
1047
1048 int UtcDaliCameraActorSetOrthographicProjectionN(void)
1049 {
1050   TestApplication application;
1051   tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection (N)");
1052
1053   CameraActor actor;
1054   bool        asserted = true;
1055   try
1056   {
1057     actor.GetProjectionMode();
1058   }
1059   catch(Dali::DaliException& e)
1060   {
1061     DALI_TEST_PRINT_ASSERT(e);
1062     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
1063     asserted = true;
1064   }
1065   DALI_TEST_CHECK(asserted);
1066   END_TEST;
1067 }
1068
1069 int UtcDaliCameraActorSetProjectionModeP(void)
1070 {
1071   TestApplication application;
1072   tet_infoline("Testing Dali::CameraActor::SetProjectionModeP (P)");
1073
1074   CameraActor actor = CameraActor::New();
1075
1076   // Check that changing the projection mode alone does not alter other presets.
1077   actor.SetNearClippingPlane(200.0f);
1078   actor.SetFarClippingPlane(400.0f);
1079
1080   actor.SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
1081
1082   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1083   DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 200.0f, FLOAT_EPSILON, TEST_LOCATION);
1084   DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 400.0f, FLOAT_EPSILON, TEST_LOCATION);
1085
1086   actor.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
1087
1088   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
1089   DALI_TEST_EQUALS(actor.GetNearClippingPlane(), 200.0f, FLOAT_EPSILON, TEST_LOCATION);
1090   DALI_TEST_EQUALS(actor.GetFarClippingPlane(), 400.0f, FLOAT_EPSILON, TEST_LOCATION);
1091
1092   // Check setting the property.
1093   Property::Value setValue = Dali::Camera::PERSPECTIVE_PROJECTION;
1094   actor.SetProperty(CameraActor::Property::PROJECTION_MODE, setValue);
1095   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1096   END_TEST;
1097 }
1098
1099 int UtcDaliCameraActorSetProjectionModeN(void)
1100 {
1101   TestApplication application;
1102   tet_infoline("Testing Dali::CameraActor::SetProjectionModeP (N)");
1103
1104   CameraActor actor;
1105
1106   bool asserted = true;
1107   try
1108   {
1109     actor.SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
1110   }
1111   catch(Dali::DaliException& e)
1112   {
1113     DALI_TEST_PRINT_ASSERT(e);
1114     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
1115     asserted = true;
1116   }
1117   DALI_TEST_CHECK(asserted);
1118   END_TEST;
1119 }
1120
1121 int UtcDaliCameraActorGetProjectionModeP(void)
1122 {
1123   TestApplication application;
1124   tet_infoline("Testing Dali::CameraActor::GetPerspectiveProjection (P)");
1125
1126   CameraActor actor = CameraActor::New();
1127
1128   actor.SetOrthographicProjection(Size::ONE);
1129   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
1130
1131   actor.SetPerspectiveProjection(Size(100.f, 150.f));
1132   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1133
1134   // Check getting the property.
1135   Dali::Camera::ProjectionMode projectionMode = actor.GetProperty<Dali::Camera::ProjectionMode>(CameraActor::Property::PROJECTION_MODE);
1136   DALI_TEST_EQUALS(projectionMode, Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION);
1137   END_TEST;
1138 }
1139
1140 int UtcDaliCameraActorGetProjectionModeN(void)
1141 {
1142   TestApplication application;
1143   tet_infoline("Testing Dali::CameraActor::GetProjectionMode (N)");
1144
1145   CameraActor actor;
1146
1147   bool asserted = true;
1148   try
1149   {
1150     actor.GetProjectionMode();
1151   }
1152   catch(Dali::DaliException& e)
1153   {
1154     DALI_TEST_PRINT_ASSERT(e);
1155     DALI_TEST_ASSERT(e, "camera && \"Camera handle is empty\"", TEST_LOCATION);
1156     asserted = true;
1157   }
1158   DALI_TEST_CHECK(asserted);
1159   END_TEST;
1160 }
1161
1162 int UtcDaliCameraActorSetCameraOffScene(void)
1163 {
1164   TestApplication application;
1165   tet_infoline("Testing Dali::CameraActor::SetCamera()");
1166
1167   CameraActor actor = CameraActor::New();
1168
1169   actor.SetType(Camera::FREE_LOOK);
1170   actor.SetFieldOfView(TEST_FIELD_OF_VIEW);
1171   actor.SetAspectRatio(TEST_ASPECT_RATIO);
1172   actor.SetNearClippingPlane(TEST_NEAR_PLANE_DISTANCE);
1173   actor.SetFarClippingPlane(TEST_FAR_PLANE_DISTANCE);
1174   actor.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION);
1175
1176   actor.SetInvertYAxis(false);
1177
1178   DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION); //change to machine epsilon
1179   DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION);
1180   DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1181   DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1182   DALI_TEST_EQUALS(Camera::PERSPECTIVE_PROJECTION, actor.GetProjectionMode(), TEST_LOCATION);
1183   DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION);
1184
1185   float       value;
1186   std::string sValue;
1187   actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
1188   DALI_TEST_EQUALS(TEST_ASPECT_RATIO, value, FLOAT_EPSILON, TEST_LOCATION);
1189   actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
1190   DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, value, FLOAT_EPSILON, TEST_LOCATION);
1191   actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
1192   DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION);
1193   actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
1194   DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION);
1195
1196   Dali::Camera::ProjectionMode projectionMode = actor.GetProperty<Dali::Camera::ProjectionMode>(CameraActor::Property::PROJECTION_MODE);
1197   DALI_TEST_EQUALS(Dali::Camera::PERSPECTIVE_PROJECTION, projectionMode, TEST_LOCATION);
1198   bool bValue;
1199   actor.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(bValue);
1200   DALI_TEST_EQUALS(false, bValue, TEST_LOCATION);
1201   END_TEST;
1202 }
1203
1204 int UtcDaliCameraActorSetCameraOnScene(void)
1205 {
1206   TestApplication application;
1207   tet_infoline("Testing Dali::CameraActor::SetCamera()");
1208
1209   CameraActor actor = CameraActor::New();
1210   application.GetScene().Add(actor);
1211   application.Render(0);
1212   application.SendNotification();
1213
1214   actor.SetType(Camera::LOOK_AT_TARGET);
1215   actor.SetFieldOfView(TEST_FIELD_OF_VIEW);
1216   actor.SetAspectRatio(TEST_ASPECT_RATIO);
1217   actor.SetNearClippingPlane(TEST_NEAR_PLANE_DISTANCE);
1218   actor.SetFarClippingPlane(TEST_FAR_PLANE_DISTANCE);
1219   actor.SetInvertYAxis(false);
1220
1221   DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION);
1222
1223   // Will need 2 frames to ensure both buffers are set to same values:
1224   application.Render();
1225   application.SendNotification();
1226   application.Render();
1227   application.SendNotification();
1228
1229   DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION);
1230   DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION);
1231   DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1232   DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1233   DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION);
1234
1235   Dali::Camera::Type cameraType = actor.GetProperty<Dali::Camera::Type>(CameraActor::Property::TYPE);
1236   DALI_TEST_EQUALS(cameraType, Camera::LOOK_AT_TARGET, TEST_LOCATION);
1237
1238   float value;
1239   actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
1240   DALI_TEST_EQUALS(TEST_ASPECT_RATIO, value, FLOAT_EPSILON, TEST_LOCATION);
1241   actor.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(value);
1242   DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, value, FLOAT_EPSILON, TEST_LOCATION);
1243   actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
1244   DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION);
1245   actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
1246   DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION);
1247
1248   bool bValue;
1249   actor.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(bValue);
1250   DALI_TEST_EQUALS(false, bValue, TEST_LOCATION);
1251   END_TEST;
1252 }
1253
1254 int UtcDaliCameraActorGetCamera(void)
1255 {
1256   TestApplication application;
1257   tet_infoline("Testing Dali::CameraActor::GetCamera()");
1258
1259   CameraActor actor = CameraActor::New();
1260
1261   actor.SetAspectRatio(TEST_ASPECT_RATIO);
1262
1263   DALI_TEST_EQUALS(actor.GetAspectRatio(), TEST_ASPECT_RATIO, FLOAT_EPSILON, TEST_LOCATION);
1264
1265   actor.SetProperty(CameraActor::Property::TYPE, Camera::FREE_LOOK);
1266   actor.SetProperty(CameraActor::Property::ASPECT_RATIO, TEST_ASPECT_RATIO);
1267   actor.SetProperty(CameraActor::Property::FIELD_OF_VIEW, TEST_FIELD_OF_VIEW);
1268   actor.SetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE, TEST_NEAR_PLANE_DISTANCE);
1269   actor.SetProperty(CameraActor::Property::FAR_PLANE_DISTANCE, TEST_FAR_PLANE_DISTANCE);
1270
1271   DALI_TEST_EQUALS(Camera::FREE_LOOK, actor.GetType(), TEST_LOCATION);
1272   DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION);
1273   DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION);
1274   DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1275   DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION);
1276   END_TEST;
1277 }
1278
1279 int UtcDaliCameraActorDefaultProperties(void)
1280 {
1281   TestApplication application;
1282   tet_infoline("Testing Dali::CameraActor DefaultProperties");
1283
1284   CameraActor        actor = CameraActor::New();
1285   Integration::Scene stage = application.GetScene();
1286   stage.Add(actor);
1287   stage.GetRenderTaskList().GetTask(0).SetCameraActor(actor);
1288
1289   actor.SetAspectRatio(TEST_ASPECT_RATIO);
1290   application.GetScene().Add(actor);
1291   application.Render(0);
1292   application.SendNotification();
1293   bool bValue;
1294   actor.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(bValue);
1295   DALI_TEST_EQUALS(false, bValue, TEST_LOCATION);
1296
1297   std::vector<Property::Index> indices;
1298   indices.push_back(CameraActor::Property::TYPE);
1299   indices.push_back(CameraActor::Property::PROJECTION_MODE);
1300   indices.push_back(CameraActor::Property::FIELD_OF_VIEW);
1301   indices.push_back(CameraActor::Property::ASPECT_RATIO);
1302   indices.push_back(CameraActor::Property::NEAR_PLANE_DISTANCE);
1303   indices.push_back(CameraActor::Property::FAR_PLANE_DISTANCE);
1304   indices.push_back(CameraActor::Property::LEFT_PLANE_DISTANCE);
1305   indices.push_back(CameraActor::Property::RIGHT_PLANE_DISTANCE);
1306   indices.push_back(CameraActor::Property::TOP_PLANE_DISTANCE);
1307   indices.push_back(CameraActor::Property::BOTTOM_PLANE_DISTANCE);
1308   indices.push_back(CameraActor::Property::TARGET_POSITION);
1309   indices.push_back(CameraActor::Property::PROJECTION_MATRIX);
1310   indices.push_back(CameraActor::Property::VIEW_MATRIX);
1311   indices.push_back(CameraActor::Property::INVERT_Y_AXIS);
1312   indices.push_back(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE);
1313   indices.push_back(DevelCameraActor::Property::PROJECTION_DIRECTION);
1314
1315   DALI_TEST_CHECK(actor.GetPropertyCount() == (Actor::New().GetPropertyCount() + indices.size()));
1316
1317   for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
1318   {
1319     DALI_TEST_EQUALS(*iter, actor.GetPropertyIndex(actor.GetPropertyName(*iter)), TEST_LOCATION);
1320
1321     if(*iter == CameraActor::Property::FIELD_OF_VIEW || *iter == CameraActor::Property::ASPECT_RATIO || *iter == DevelCameraActor::Property::ORTHOGRAPHIC_SIZE || *iter == CameraActor::Property::NEAR_PLANE_DISTANCE || *iter == CameraActor::Property::FAR_PLANE_DISTANCE)
1322     {
1323       DALI_TEST_CHECK(actor.IsPropertyAnimatable(*iter));
1324     }
1325     else
1326     {
1327       DALI_TEST_CHECK(!actor.IsPropertyAnimatable(*iter));
1328     }
1329
1330     if((*iter == CameraActor::Property::LEFT_PLANE_DISTANCE) ||
1331        (*iter == CameraActor::Property::RIGHT_PLANE_DISTANCE) ||
1332        (*iter == CameraActor::Property::TOP_PLANE_DISTANCE) ||
1333        (*iter == CameraActor::Property::BOTTOM_PLANE_DISTANCE) ||
1334        (*iter == CameraActor::Property::PROJECTION_MATRIX) ||
1335        (*iter == CameraActor::Property::VIEW_MATRIX))
1336     {
1337       DALI_TEST_CHECK(!actor.IsPropertyWritable(*iter));
1338     }
1339     else
1340     {
1341       DALI_TEST_CHECK(actor.IsPropertyWritable(*iter));
1342     }
1343
1344     DALI_TEST_CHECK(actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter)); // just checking call succeeds
1345   }
1346
1347   // Set/Get one of them.
1348   const float newAspect = TEST_ASPECT_RATIO * 2.0f;
1349
1350   actor.SetProperty(CameraActor::Property::ASPECT_RATIO, Property::Value(newAspect));
1351   application.Render();
1352   application.SendNotification();
1353   application.Render();
1354   application.SendNotification();
1355
1356   DALI_TEST_EQUALS(actor.GetAspectRatio(), newAspect, TEST_LOCATION);
1357   END_TEST;
1358 }
1359
1360 template<typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
1361 void TEST_CAMERA_PROPERTY(P1 camera, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION)
1362 {
1363   DALI_TEST_EQUALS(camera.GetPropertyName(enumName), stringName, LOCATION);
1364   DALI_TEST_EQUALS(camera.GetPropertyIndex(stringName), static_cast<Property::Index>(enumName), LOCATION);
1365   DALI_TEST_EQUALS(camera.GetPropertyType(enumName), type, LOCATION);
1366   DALI_TEST_EQUALS(camera.IsPropertyWritable(enumName), isWriteable, LOCATION);
1367   DALI_TEST_EQUALS(camera.IsPropertyAnimatable(enumName), isAnimateable, LOCATION);
1368   DALI_TEST_EQUALS(camera.IsPropertyAConstraintInput(enumName), isConstraintInput, LOCATION);
1369 }
1370 int UtcDaliCameraActorDefaultPropertiesInherited(void)
1371 {
1372   TestApplication application;
1373
1374   CameraActor        actor = CameraActor::New();
1375   Integration::Scene stage = application.GetScene();
1376   stage.Add(actor);
1377   stage.GetRenderTaskList().GetTask(0).SetCameraActor(actor);
1378
1379   application.GetScene().Add(actor);
1380   application.Render(0);
1381   application.SendNotification();
1382
1383   const PropertyDetails CAMERA_DEFAULT_PROPERTY[] =
1384     {
1385       // actor
1386       {"parentOrigin", Property::VECTOR3, true, false, true, Dali::Actor::Property::PARENT_ORIGIN},
1387       {"parentOriginX", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_X},
1388       {"parentOriginY", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Y},
1389       {"parentOriginZ", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Z},
1390       {"anchorPoint", Property::VECTOR3, true, false, true, Dali::Actor::Property::ANCHOR_POINT},
1391       {"anchorPointX", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_X},
1392       {"anchorPointY", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Y},
1393       {"anchorPointZ", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Z},
1394       {"size", Property::VECTOR3, true, true, true, Dali::Actor::Property::SIZE},
1395       {"sizeWidth", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_WIDTH},
1396       {"sizeHeight", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_HEIGHT},
1397       {"sizeDepth", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_DEPTH},
1398       {"position", Property::VECTOR3, true, true, true, Dali::Actor::Property::POSITION},
1399       {"positionX", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_X},
1400       {"positionY", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_Y},
1401       {"positionZ", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_Z},
1402       {"worldPosition", Property::VECTOR3, false, false, true, Dali::Actor::Property::WORLD_POSITION},
1403       {"worldPositionX", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_X},
1404       {"worldPositionY", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Y},
1405       {"worldPositionZ", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Z},
1406       {"orientation", Property::ROTATION, true, true, true, Dali::Actor::Property::ORIENTATION},
1407       {"worldOrientation", Property::ROTATION, false, false, true, Dali::Actor::Property::WORLD_ORIENTATION},
1408       {"scale", Property::VECTOR3, true, true, true, Dali::Actor::Property::SCALE},
1409       {"scaleX", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_X},
1410       {"scaleY", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_Y},
1411       {"scaleZ", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_Z},
1412       {"worldScale", Property::VECTOR3, false, false, true, Dali::Actor::Property::WORLD_SCALE},
1413       {"visible", Property::BOOLEAN, true, true, true, Dali::Actor::Property::VISIBLE},
1414       {"color", Property::VECTOR4, true, true, true, Dali::Actor::Property::COLOR},
1415       {"colorRed", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_RED},
1416       {"colorGreen", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_GREEN},
1417       {"colorBlue", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_BLUE},
1418       {"colorAlpha", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_ALPHA},
1419       {"worldColor", Property::VECTOR4, false, false, true, Dali::Actor::Property::WORLD_COLOR},
1420       {"worldMatrix", Property::MATRIX, false, false, true, Dali::Actor::Property::WORLD_MATRIX},
1421       {"name", Property::STRING, true, false, false, Dali::Actor::Property::NAME},
1422       {"sensitive", Property::BOOLEAN, true, false, false, Dali::Actor::Property::SENSITIVE},
1423       {"leaveRequired", Property::BOOLEAN, true, false, false, Dali::Actor::Property::LEAVE_REQUIRED},
1424       {"inheritOrientation", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION},
1425       {"inheritScale", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE},
1426       {"colorMode", Property::INTEGER, true, false, false, Dali::Actor::Property::COLOR_MODE},
1427       {"drawMode", Property::INTEGER, true, false, false, Dali::Actor::Property::DRAW_MODE},
1428       {"sizeModeFactor", Property::VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR},
1429       {"widthResizePolicy", Property::STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY},
1430       {"heightResizePolicy", Property::STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY},
1431       {"sizeScalePolicy", Property::INTEGER, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY},
1432       {"widthForHeight", Property::BOOLEAN, true, false, false, Dali::Actor::Property::WIDTH_FOR_HEIGHT},
1433       {"heightForWidth", Property::BOOLEAN, true, false, false, Dali::Actor::Property::HEIGHT_FOR_WIDTH},
1434       {"padding", Property::VECTOR4, true, false, false, Dali::Actor::Property::PADDING},
1435       {"minimumSize", Property::VECTOR2, true, false, false, Dali::Actor::Property::MINIMUM_SIZE},
1436       {"maximumSize", Property::VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE},
1437       {"inheritPosition", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_POSITION},
1438       {"clippingMode", Property::STRING, true, false, false, Dali::Actor::Property::CLIPPING_MODE},
1439       {"layoutDirection", Property::STRING, true, false, false, Dali::Actor::Property::LAYOUT_DIRECTION},
1440       {"inheritLayoutDirection", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION},
1441       {"opacity", Property::FLOAT, true, true, true, Dali::Actor::Property::OPACITY},
1442       {"screenPosition", Property::VECTOR2, false, false, false, Dali::Actor::Property::SCREEN_POSITION},
1443       {"positionUsesAnchorPoint", Property::BOOLEAN, true, false, false, Dali::Actor::Property::POSITION_USES_ANCHOR_POINT},
1444       {"culled", Property::BOOLEAN, false, false, true, Dali::Actor::Property::CULLED},
1445       {"id", Property::INTEGER, false, false, false, Dali::Actor::Property::ID},
1446       {"hierarchyDepth", Property::INTEGER, false, false, false, Dali::Actor::Property::HIERARCHY_DEPTH},
1447       {"isRoot", Property::BOOLEAN, false, false, false, Dali::Actor::Property::IS_ROOT},
1448       {"isLayer", Property::BOOLEAN, false, false, false, Dali::Actor::Property::IS_LAYER},
1449       {"connectedToScene", Property::BOOLEAN, false, false, false, Dali::Actor::Property::CONNECTED_TO_SCENE},
1450       {"keyboardFocusable", Property::BOOLEAN, true, false, false, Dali::Actor::Property::KEYBOARD_FOCUSABLE},
1451       {"siblingOrder", Property::INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER},
1452       // camera own
1453       {"type", Property::INTEGER, true, false, true, Dali::CameraActor::Property::TYPE},
1454       {"projectionMode", Property::INTEGER, true, false, true, Dali::CameraActor::Property::PROJECTION_MODE},
1455       {"fieldOfView", Property::FLOAT, true, true, true, Dali::CameraActor::Property::FIELD_OF_VIEW},
1456       {"aspectRatio", Property::FLOAT, true, true, true, Dali::CameraActor::Property::ASPECT_RATIO},
1457       {"nearPlaneDistance", Property::FLOAT, true, true, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE},
1458       {"farPlaneDistance", Property::FLOAT, true, true, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE},
1459       {"leftPlaneDistance", Property::FLOAT, false, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE},
1460       {"rightPlaneDistance", Property::FLOAT, false, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE},
1461       {"topPlaneDistance", Property::FLOAT, false, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE},
1462       {"bottomPlaneDistance", Property::FLOAT, false, false, true, Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE},
1463       {"targetPosition", Property::VECTOR3, true, false, true, Dali::CameraActor::Property::TARGET_POSITION},
1464       {"projectionMatrix", Property::MATRIX, false, false, true, Dali::CameraActor::Property::PROJECTION_MATRIX},
1465       {"viewMatrix", Property::MATRIX, false, false, true, Dali::CameraActor::Property::VIEW_MATRIX},
1466       {"invertYAxis", Property::BOOLEAN, true, false, true, Dali::CameraActor::Property::INVERT_Y_AXIS},
1467       {"orthographicSize", Property::FLOAT, true, true, true, Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE},
1468       {"projectionDirection", Property::INTEGER, true, false, true, Dali::DevelCameraActor::Property::PROJECTION_DIRECTION}};
1469
1470   for(uint32_t index = 0; index < (sizeof(CAMERA_DEFAULT_PROPERTY) / sizeof(PropertyDetails)); ++index)
1471   {
1472     TEST_CAMERA_PROPERTY(actor,
1473                          CAMERA_DEFAULT_PROPERTY[index].name,
1474                          CAMERA_DEFAULT_PROPERTY[index].type,
1475                          CAMERA_DEFAULT_PROPERTY[index].writable,
1476                          CAMERA_DEFAULT_PROPERTY[index].animatable,
1477                          CAMERA_DEFAULT_PROPERTY[index].constraintInput,
1478                          CAMERA_DEFAULT_PROPERTY[index].enumIndex,
1479                          TEST_LOCATION);
1480   }
1481   END_TEST;
1482 }
1483
1484 int UtcDaliCameraActorModelView(void)
1485 {
1486   TestApplication application;
1487   tet_infoline("Testing Dali::CameraActor Test view application");
1488
1489   Actor actor = CreateRenderableActor();
1490   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1491   actor.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 30.0f, 40.0f));
1492   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1493   application.GetScene().Add(actor);
1494
1495   application.SendNotification();
1496   application.Render(0);
1497   application.Render();
1498   application.SendNotification();
1499
1500   Matrix resultMatrix(true);
1501   resultMatrix.SetTransformComponents(Vector3::ONE, Quaternion::IDENTITY, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1502
1503   RenderTask  task        = application.GetScene().GetRenderTaskList().GetTask(0);
1504   CameraActor cameraActor = task.GetCameraActor();
1505
1506   Matrix viewMatrix(false);
1507   cameraActor.GetProperty(CameraActor::Property::VIEW_MATRIX).Get(viewMatrix);
1508   Matrix::Multiply(resultMatrix, resultMatrix, viewMatrix);
1509
1510   DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uModelView", resultMatrix));
1511   END_TEST;
1512 }
1513
1514 int UtcDaliCameraActorReadProjectionMatrix(void)
1515 {
1516   TestApplication application;
1517   tet_infoline("Testing Dali::CameraActor::ReadProjectionMatrix()");
1518
1519   CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1520   application.SendNotification();
1521   application.Render(0);
1522   application.Render();
1523   application.SendNotification();
1524   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
1525   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
1526   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1527   application.GetScene().Add(actor);
1528
1529   Matrix projectionMatrix;
1530   Matrix viewMatrix;
1531
1532   camera.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
1533   camera.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(viewMatrix);
1534
1535   actor.RegisterProperty(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY);
1536   actor.RegisterProperty(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY);
1537
1538   Property::Index projectionMatrixPropertyIndex = actor.GetPropertyIndex(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME);
1539   Property::Index viewMatrixPropertyIndex       = actor.GetPropertyIndex(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME);
1540
1541   Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>(actor, projectionMatrixPropertyIndex, EqualToConstraint());
1542   projectionMatrixConstraint.AddSource(Source(camera, CameraActor::Property::PROJECTION_MATRIX));
1543   Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>(actor, viewMatrixPropertyIndex, EqualToConstraint());
1544   viewMatrixConstraint.AddSource(Source(camera, CameraActor::Property::VIEW_MATRIX));
1545
1546   projectionMatrixConstraint.Apply();
1547   viewMatrixConstraint.Apply();
1548
1549   application.SendNotification();
1550   application.Render();
1551
1552   // Test effects of Constraint.
1553   DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME.c_str(), projectionMatrix));
1554
1555   DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME.c_str(), viewMatrix));
1556   END_TEST;
1557 }
1558
1559 int UtcDaliCameraActorAnimatedProperties01(void)
1560 {
1561   TestApplication application;
1562   tet_infoline("Testing Dali::Internal::CameraActor::GetSceneObjectAnimatableProperty()");
1563
1564   CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1565   Actor       actor  = Actor::New();
1566   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1567   application.GetScene().Add(actor);
1568
1569   Constraint constraint = Constraint::New<Dali::Vector3>(actor, Actor::Property::POSITION, EqualToConstraint());
1570   constraint.AddSource(Source(camera, Actor::Property::POSITION));
1571   constraint.Apply();
1572
1573   camera.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 200.0f, 300.0f));
1574   application.SendNotification();
1575   application.Render();
1576
1577   DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(100.0f, 200.0f, 300.0f), TEST_LOCATION);
1578   END_TEST;
1579 }
1580
1581 int UtcDaliCameraActorAnimatedProperties02(void)
1582 {
1583   TestApplication application;
1584   tet_infoline("Testing Dali::Internal::CameraActor::GetSceneObjectAnimatableProperty()");
1585
1586   CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1587   Actor       actor  = Actor::New();
1588   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1589   actor.SetProperty(Actor::Property::POSITION, Vector2(0.1f, 0.0f));
1590   application.GetScene().Add(actor);
1591
1592   camera.SetFieldOfView(0.1f);
1593   camera.SetAspectRatio(0.5f);
1594   camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, 200.0f);
1595
1596   Constraint constraintX = Constraint::New<float>(actor, Actor::Property::POSITION_X, EqualToConstraint());
1597   constraintX.AddSource(Source(camera, CameraActor::Property::FIELD_OF_VIEW));
1598   constraintX.Apply();
1599
1600   Constraint constraintY = Constraint::New<float>(actor, Actor::Property::POSITION_Y, EqualToConstraint());
1601   constraintY.AddSource(Source(camera, CameraActor::Property::ASPECT_RATIO));
1602   constraintY.Apply();
1603
1604   Constraint constraintZ = Constraint::New<float>(actor, Actor::Property::POSITION_Z, EqualToConstraint());
1605   constraintZ.AddSource(Source(camera, DevelCameraActor::Property::ORTHOGRAPHIC_SIZE));
1606   constraintZ.Apply();
1607
1608   application.SendNotification();
1609   application.Render();
1610
1611   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), 0.1f, TEST_LOCATION);
1612   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), 0.5f, TEST_LOCATION);
1613   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), 200.0f, TEST_LOCATION);
1614
1615   camera.SetFieldOfView(0.5f);
1616   camera.SetAspectRatio(0.2f);
1617   camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, 100.0f);
1618
1619   application.SendNotification();
1620   application.Render();
1621
1622   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), 0.5f, TEST_LOCATION);
1623   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), 0.2f, TEST_LOCATION);
1624   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), 100.0f, TEST_LOCATION);
1625   END_TEST;
1626 }
1627
1628 int UtcDaliCameraActorAnimatedProperties03(void)
1629 {
1630   TestApplication application;
1631   tet_infoline("Testing Dali::Internal::CameraActor::GetSceneObjectAnimatableProperty()");
1632
1633   CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1634
1635   // Add dummy actor
1636   Actor actor = Actor::New();
1637   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1638   actor.SetProperty(Actor::Property::POSITION, Vector2(0.1f, 0.0f));
1639   application.GetScene().Add(actor);
1640
1641   Radian sourceFoV    = Radian(0.6f);
1642   float  sourceAspect = 0.7f;
1643   float  sourceNearDistance = 0.5f;
1644   float  sourceFarDistance  = 1000.0f;
1645
1646   Radian targetFoV    = Radian(0.1f);
1647   float  targetAspect = 1.3f;
1648   float  targetNearDistance = 20.5f;
1649   float  targetFarDistance  = 30.0f;
1650
1651   Matrix expectedProjectionMatrix1;
1652   Matrix expectedProjectionMatrix2;
1653   Matrix expectedProjectionMatrix3;
1654
1655   // Build expect projection matrix
1656   camera.SetFieldOfView(sourceFoV.radian);
1657   camera.SetAspectRatio(sourceAspect);
1658   camera.SetNearClippingPlane(sourceNearDistance);
1659   camera.SetFarClippingPlane(sourceFarDistance);
1660   application.SendNotification();
1661   application.Render();
1662   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix1);
1663
1664   camera.SetFieldOfView(sourceFoV.radian * 0.6f + targetFoV.radian * 0.4f);
1665   camera.SetAspectRatio(sourceAspect * 0.6f + targetAspect * 0.4f);
1666   camera.SetNearClippingPlane(sourceNearDistance * 0.6f + targetNearDistance * 0.4f);
1667   camera.SetFarClippingPlane(sourceFarDistance * 0.6f + targetFarDistance * 0.4f);
1668   application.SendNotification();
1669   application.Render();
1670   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix2);
1671
1672   camera.SetFieldOfView(targetFoV.radian);
1673   camera.SetAspectRatio(targetAspect);
1674   camera.SetNearClippingPlane(targetNearDistance);
1675   camera.SetFarClippingPlane(targetFarDistance);
1676   application.SendNotification();
1677   application.Render();
1678   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix3);
1679
1680   auto TestAnimationProgress = [&]()
1681   {
1682     Matrix projectionMatrix;
1683
1684     application.SendNotification();
1685     application.Render(0);
1686
1687     // progress 0.0
1688     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FIELD_OF_VIEW), sourceFoV.radian, TEST_LOCATION);
1689     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), sourceAspect, TEST_LOCATION);
1690     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::NEAR_PLANE_DISTANCE), sourceNearDistance, TEST_LOCATION);
1691     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FAR_PLANE_DISTANCE), sourceFarDistance, TEST_LOCATION);
1692
1693     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
1694     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix1, Epsilon<100000>::value, TEST_LOCATION);
1695
1696     application.SendNotification();
1697     application.Render(400);
1698
1699     // progress 0.4
1700     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FIELD_OF_VIEW), sourceFoV.radian * 0.6f + targetFoV.radian * 0.4f, TEST_LOCATION);
1701     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), sourceAspect * 0.6f + targetAspect * 0.4f, TEST_LOCATION);
1702     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::NEAR_PLANE_DISTANCE), sourceNearDistance * 0.6f + targetNearDistance * 0.4f, TEST_LOCATION);
1703     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FAR_PLANE_DISTANCE), sourceFarDistance * 0.6f + targetFarDistance * 0.4f, TEST_LOCATION);
1704
1705     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
1706     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix2, Epsilon<100000>::value, TEST_LOCATION);
1707
1708     application.SendNotification();
1709     application.Render(600);
1710
1711     // progress 1.0
1712     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FIELD_OF_VIEW), targetFoV.radian, TEST_LOCATION);
1713     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), targetAspect, TEST_LOCATION);
1714     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::NEAR_PLANE_DISTANCE), targetNearDistance, TEST_LOCATION);
1715     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FAR_PLANE_DISTANCE), targetFarDistance, TEST_LOCATION);
1716
1717     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
1718     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix3, Epsilon<100000>::value, TEST_LOCATION);
1719
1720     // Ensure Animate finished.
1721     application.SendNotification();
1722     application.Render(16);
1723   };
1724
1725   // AnimateTo
1726   {
1727     tet_printf("AnimateTo\n");
1728     camera.SetProperty(CameraActor::Property::FIELD_OF_VIEW, sourceFoV.radian);
1729     camera.SetProperty(CameraActor::Property::ASPECT_RATIO, sourceAspect);
1730     camera.SetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE, sourceNearDistance);
1731     camera.SetProperty(CameraActor::Property::FAR_PLANE_DISTANCE, sourceFarDistance);
1732     Animation animation = Animation::New(1.0f);
1733     animation.AnimateTo(Property(camera, CameraActor::Property::FIELD_OF_VIEW), targetFoV.radian);
1734     animation.AnimateTo(Property(camera, CameraActor::Property::ASPECT_RATIO), targetAspect);
1735     animation.AnimateTo(Property(camera, CameraActor::Property::NEAR_PLANE_DISTANCE), targetNearDistance);
1736     animation.AnimateTo(Property(camera, CameraActor::Property::FAR_PLANE_DISTANCE), targetFarDistance);
1737     animation.AnimateTo(Property(camera, Actor::Property::POSITION_X), 0.0f); ///< For line coverage.
1738     animation.Play();
1739
1740     TestAnimationProgress();
1741   }
1742
1743   // AnimateBetween
1744   {
1745     tet_printf("AnimateBetween\n");
1746     Animation animation = Animation::New(1.0f);
1747
1748     KeyFrames keyFrames1 = KeyFrames::New();
1749     keyFrames1.Add(0.0f, sourceFoV.radian);
1750     keyFrames1.Add(1.0f, targetFoV.radian);
1751
1752     KeyFrames keyFrames2 = KeyFrames::New();
1753     keyFrames2.Add(0.0f, sourceAspect);
1754     keyFrames2.Add(1.0f, targetAspect);
1755
1756     KeyFrames keyFrames3 = KeyFrames::New();
1757     keyFrames3.Add(0.0f, sourceNearDistance);
1758     keyFrames3.Add(1.0f, targetNearDistance);
1759
1760     KeyFrames keyFrames4 = KeyFrames::New();
1761     keyFrames4.Add(0.0f, sourceFarDistance);
1762     keyFrames4.Add(1.0f, targetFarDistance);
1763
1764     animation.AnimateBetween(Property(camera, CameraActor::Property::FIELD_OF_VIEW), keyFrames1);
1765     animation.AnimateBetween(Property(camera, CameraActor::Property::ASPECT_RATIO), keyFrames2);
1766     animation.AnimateBetween(Property(camera, CameraActor::Property::NEAR_PLANE_DISTANCE), keyFrames3);
1767     animation.AnimateBetween(Property(camera, CameraActor::Property::FAR_PLANE_DISTANCE), keyFrames4);
1768
1769     animation.Play();
1770
1771     TestAnimationProgress();
1772   }
1773
1774   // AnimateBy
1775   {
1776     tet_printf("AnimateBy\n");
1777     camera.SetProperty(CameraActor::Property::FIELD_OF_VIEW, sourceFoV.radian);
1778     camera.SetProperty(CameraActor::Property::ASPECT_RATIO, sourceAspect);
1779     camera.SetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE, sourceNearDistance);
1780     camera.SetProperty(CameraActor::Property::FAR_PLANE_DISTANCE, sourceFarDistance);
1781     Animation animation = Animation::New(1.0f);
1782     animation.AnimateBy(Property(camera, CameraActor::Property::FIELD_OF_VIEW), targetFoV.radian - sourceFoV.radian);
1783     animation.AnimateBy(Property(camera, CameraActor::Property::ASPECT_RATIO), targetAspect - sourceAspect);
1784     animation.AnimateBy(Property(camera, CameraActor::Property::NEAR_PLANE_DISTANCE), targetNearDistance - sourceNearDistance);
1785     animation.AnimateBy(Property(camera, CameraActor::Property::FAR_PLANE_DISTANCE), targetFarDistance - sourceFarDistance);
1786     animation.Play();
1787
1788     TestAnimationProgress();
1789   }
1790
1791   END_TEST;
1792 }
1793
1794 int UtcDaliCameraActorAnimatedProperties04(void)
1795 {
1796   TestApplication application;
1797   tet_infoline("Testing Dali::Internal::CameraActor::GetSceneObjectAnimatableProperty()");
1798
1799   CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1800
1801   // Make camera as orthographic mode
1802   camera.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
1803
1804   // Add dummy actor
1805   Actor actor = Actor::New();
1806   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1807   actor.SetProperty(Actor::Property::POSITION, Vector2(0.1f, 0.0f));
1808   application.GetScene().Add(actor);
1809
1810   float sourceOrthographic = 2.0f;
1811   float sourceAspect       = 0.7f;
1812
1813   float targetOrthographic = 4.0f;
1814   float targetAspect       = 1.3f;
1815
1816   Matrix expectedProjectionMatrix1;
1817   Matrix expectedProjectionMatrix2;
1818   Matrix expectedProjectionMatrix3;
1819
1820   // Reduce near-far value for projection matrix epsilon
1821   camera.SetNearClippingPlane(1.0f);
1822   camera.SetFarClippingPlane(3.0f);
1823
1824   // Build expect projection matrix
1825   camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, sourceOrthographic);
1826   camera.SetAspectRatio(sourceAspect);
1827   application.SendNotification();
1828   application.Render();
1829   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix1);
1830
1831   camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, sourceOrthographic * 0.6f + targetOrthographic * 0.4f);
1832   camera.SetAspectRatio(sourceAspect * 0.6f + targetAspect * 0.4f);
1833   application.SendNotification();
1834   application.Render();
1835   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix2);
1836
1837   camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, targetOrthographic);
1838   camera.SetAspectRatio(targetAspect);
1839   application.SendNotification();
1840   application.Render();
1841   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix3);
1842
1843   auto TestAnimationProgress = [&]() {
1844     Matrix projectionMatrix;
1845
1846     application.SendNotification();
1847     application.Render(0);
1848
1849     float expectOrthographic;
1850     float expectAspect;
1851     float expectLeft;
1852     float expectRight;
1853     float expectTop;
1854     float expectBottom;
1855
1856     auto UpdateExpectPlaneDistance = [&]() {
1857       bool isVertical = camera.GetProperty<int>(DevelCameraActor::Property::PROJECTION_DIRECTION) == static_cast<int>(DevelCameraActor::ProjectionDirection::VERTICAL);
1858       expectLeft      = -(isVertical ? expectOrthographic * expectAspect : expectOrthographic);
1859       expectRight     = (isVertical ? expectOrthographic * expectAspect : expectOrthographic);
1860       expectTop       = (isVertical ? expectOrthographic : expectOrthographic / expectAspect);
1861       expectBottom    = -(isVertical ? expectOrthographic : expectOrthographic / expectAspect);
1862     };
1863
1864     // progress 0.0
1865     expectOrthographic = sourceOrthographic;
1866     expectAspect       = sourceAspect;
1867     UpdateExpectPlaneDistance();
1868     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), expectOrthographic, TEST_LOCATION);
1869     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), expectAspect, TEST_LOCATION);
1870     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::LEFT_PLANE_DISTANCE), expectLeft, TEST_LOCATION);
1871     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::RIGHT_PLANE_DISTANCE), expectRight, TEST_LOCATION);
1872     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::TOP_PLANE_DISTANCE), expectTop, TEST_LOCATION);
1873     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::BOTTOM_PLANE_DISTANCE), expectBottom, TEST_LOCATION);
1874
1875     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
1876     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix1, Epsilon<100000>::value, TEST_LOCATION);
1877
1878     application.SendNotification();
1879     application.Render(400);
1880
1881     // progress 0.4
1882     expectOrthographic = sourceOrthographic * 0.6f + targetOrthographic * 0.4f;
1883     expectAspect       = sourceAspect * 0.6f + targetAspect * 0.4f;
1884     UpdateExpectPlaneDistance();
1885     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), expectOrthographic, TEST_LOCATION);
1886     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), expectAspect, TEST_LOCATION);
1887     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::LEFT_PLANE_DISTANCE), expectLeft, TEST_LOCATION);
1888     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::RIGHT_PLANE_DISTANCE), expectRight, TEST_LOCATION);
1889     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::TOP_PLANE_DISTANCE), expectTop, TEST_LOCATION);
1890     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::BOTTOM_PLANE_DISTANCE), expectBottom, TEST_LOCATION);
1891
1892     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
1893     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix2, Epsilon<100000>::value, TEST_LOCATION);
1894
1895     application.SendNotification();
1896     application.Render(600);
1897
1898     // progress 1.0
1899     expectOrthographic = targetOrthographic;
1900     expectAspect       = targetAspect;
1901     UpdateExpectPlaneDistance();
1902     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), expectOrthographic, TEST_LOCATION);
1903     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), expectAspect, TEST_LOCATION);
1904     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::LEFT_PLANE_DISTANCE), expectLeft, TEST_LOCATION);
1905     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::RIGHT_PLANE_DISTANCE), expectRight, TEST_LOCATION);
1906     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::TOP_PLANE_DISTANCE), expectTop, TEST_LOCATION);
1907     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::BOTTOM_PLANE_DISTANCE), expectBottom, TEST_LOCATION);
1908
1909     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
1910     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix3, Epsilon<100000>::value, TEST_LOCATION);
1911
1912     // Ensure Animate finished.
1913     application.SendNotification();
1914     application.Render(16);
1915   };
1916
1917   // AnimateTo
1918   {
1919     tet_printf("AnimateTo - vertical\n");
1920     camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, sourceOrthographic);
1921     camera.SetProperty(CameraActor::Property::ASPECT_RATIO, sourceAspect);
1922     Animation animation = Animation::New(1.0f);
1923     animation.AnimateTo(Property(camera, DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), targetOrthographic);
1924     animation.AnimateTo(Property(camera, CameraActor::Property::ASPECT_RATIO), targetAspect);
1925     animation.Play();
1926     TestAnimationProgress();
1927   }
1928
1929   // AnimateBetween
1930   {
1931     tet_printf("AnimateBetween - vertical\n");
1932     Animation animation = Animation::New(1.0f);
1933
1934     KeyFrames keyFrames1 = KeyFrames::New();
1935     keyFrames1.Add(0.0f, sourceOrthographic);
1936     keyFrames1.Add(1.0f, targetOrthographic);
1937
1938     KeyFrames keyFrames2 = KeyFrames::New();
1939     keyFrames2.Add(0.0f, sourceAspect);
1940     keyFrames2.Add(1.0f, targetAspect);
1941
1942     animation.AnimateBetween(Property(camera, DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), keyFrames1);
1943     animation.AnimateBetween(Property(camera, CameraActor::Property::ASPECT_RATIO), keyFrames2);
1944
1945     animation.Play();
1946     TestAnimationProgress();
1947   }
1948
1949   // AnimateBy
1950   {
1951     tet_printf("AnimateBy - vertical\n");
1952     camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, sourceOrthographic);
1953     camera.SetProperty(CameraActor::Property::ASPECT_RATIO, sourceAspect);
1954     Animation animation = Animation::New(1.0f);
1955     animation.AnimateBy(Property(camera, DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), targetOrthographic - sourceOrthographic);
1956     animation.AnimateBy(Property(camera, CameraActor::Property::ASPECT_RATIO), targetAspect - sourceAspect);
1957     animation.Play();
1958     TestAnimationProgress();
1959   }
1960
1961   END_TEST;
1962 }
1963
1964 int UtcDaliCameraActorAnimatedProperties05(void)
1965 {
1966   TestApplication application;
1967   tet_infoline("Testing Dali::Internal::CameraActor::GetSceneObjectAnimatableProperty()");
1968
1969   CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
1970
1971   // Make camera as orthographic mode and horizontal
1972   camera.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
1973   camera.SetProperty(DevelCameraActor::Property::PROJECTION_DIRECTION, DevelCameraActor::ProjectionDirection::HORIZONTAL);
1974
1975   // Add dummy actor
1976   Actor actor = Actor::New();
1977   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1978   actor.SetProperty(Actor::Property::POSITION, Vector2(0.1f, 0.0f));
1979   application.GetScene().Add(actor);
1980
1981   float sourceOrthographic = 2.0f;
1982   float sourceAspect       = 0.7f;
1983
1984   float targetOrthographic = 4.0f;
1985   float targetAspect       = 1.3f;
1986
1987   Matrix expectedProjectionMatrix1;
1988   Matrix expectedProjectionMatrix2;
1989   Matrix expectedProjectionMatrix3;
1990
1991   // Reduce near-far value for projection matrix epsilon
1992   camera.SetNearClippingPlane(1.0f);
1993   camera.SetFarClippingPlane(3.0f);
1994
1995   // Build expect projection matrix
1996   camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, sourceOrthographic);
1997   camera.SetAspectRatio(sourceAspect);
1998   application.SendNotification();
1999   application.Render();
2000   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix1);
2001
2002   camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, sourceOrthographic * 0.6f + targetOrthographic * 0.4f);
2003   camera.SetAspectRatio(sourceAspect * 0.6f + targetAspect * 0.4f);
2004   application.SendNotification();
2005   application.Render();
2006   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix2);
2007
2008   camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, targetOrthographic);
2009   camera.SetAspectRatio(targetAspect);
2010   application.SendNotification();
2011   application.Render();
2012   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix3);
2013
2014   auto TestAnimationProgress = [&]() {
2015     Matrix projectionMatrix;
2016
2017     application.SendNotification();
2018     application.Render(0);
2019
2020     float expectOrthographic;
2021     float expectAspect;
2022     float expectLeft;
2023     float expectRight;
2024     float expectTop;
2025     float expectBottom;
2026
2027     auto UpdateExpectPlaneDistance = [&]() {
2028       bool isVertical = camera.GetProperty<int>(DevelCameraActor::Property::PROJECTION_DIRECTION) == static_cast<int>(DevelCameraActor::ProjectionDirection::VERTICAL);
2029       expectLeft      = -(isVertical ? expectOrthographic * expectAspect : expectOrthographic);
2030       expectRight     = (isVertical ? expectOrthographic * expectAspect : expectOrthographic);
2031       expectTop       = (isVertical ? expectOrthographic : expectOrthographic / expectAspect);
2032       expectBottom    = -(isVertical ? expectOrthographic : expectOrthographic / expectAspect);
2033     };
2034
2035     // progress 0.0
2036     expectOrthographic = sourceOrthographic;
2037     expectAspect       = sourceAspect;
2038     UpdateExpectPlaneDistance();
2039     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), expectOrthographic, TEST_LOCATION);
2040     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), expectAspect, TEST_LOCATION);
2041     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::LEFT_PLANE_DISTANCE), expectLeft, TEST_LOCATION);
2042     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::RIGHT_PLANE_DISTANCE), expectRight, TEST_LOCATION);
2043     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::TOP_PLANE_DISTANCE), expectTop, TEST_LOCATION);
2044     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::BOTTOM_PLANE_DISTANCE), expectBottom, TEST_LOCATION);
2045
2046     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
2047     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix1, Epsilon<100000>::value, TEST_LOCATION);
2048
2049     application.SendNotification();
2050     application.Render(400);
2051
2052     // progress 0.4
2053     expectOrthographic = sourceOrthographic * 0.6f + targetOrthographic * 0.4f;
2054     expectAspect       = sourceAspect * 0.6f + targetAspect * 0.4f;
2055     UpdateExpectPlaneDistance();
2056     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), expectOrthographic, TEST_LOCATION);
2057     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), expectAspect, TEST_LOCATION);
2058     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::LEFT_PLANE_DISTANCE), expectLeft, TEST_LOCATION);
2059     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::RIGHT_PLANE_DISTANCE), expectRight, TEST_LOCATION);
2060     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::TOP_PLANE_DISTANCE), expectTop, TEST_LOCATION);
2061     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::BOTTOM_PLANE_DISTANCE), expectBottom, TEST_LOCATION);
2062
2063     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
2064     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix2, Epsilon<100000>::value, TEST_LOCATION);
2065
2066     application.SendNotification();
2067     application.Render(600);
2068
2069     // progress 1.0
2070     expectOrthographic = targetOrthographic;
2071     expectAspect       = targetAspect;
2072     UpdateExpectPlaneDistance();
2073     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), expectOrthographic, TEST_LOCATION);
2074     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), expectAspect, TEST_LOCATION);
2075     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::LEFT_PLANE_DISTANCE), expectLeft, TEST_LOCATION);
2076     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::RIGHT_PLANE_DISTANCE), expectRight, TEST_LOCATION);
2077     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::TOP_PLANE_DISTANCE), expectTop, TEST_LOCATION);
2078     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::BOTTOM_PLANE_DISTANCE), expectBottom, TEST_LOCATION);
2079
2080     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
2081     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix3, Epsilon<100000>::value, TEST_LOCATION);
2082
2083     // Ensure Animate finished.
2084     application.SendNotification();
2085     application.Render(16);
2086   };
2087
2088   // AnimateTo
2089   {
2090     tet_printf("AnimateTo - horizontal\n");
2091     camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, sourceOrthographic);
2092     camera.SetProperty(CameraActor::Property::ASPECT_RATIO, sourceAspect);
2093     Animation animation = Animation::New(1.0f);
2094     animation.AnimateTo(Property(camera, DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), targetOrthographic);
2095     animation.AnimateTo(Property(camera, CameraActor::Property::ASPECT_RATIO), targetAspect);
2096     animation.Play();
2097     TestAnimationProgress();
2098   }
2099
2100   // AnimateBetween
2101   {
2102     tet_printf("AnimateBetween - horizontal\n");
2103     Animation animation = Animation::New(1.0f);
2104
2105     KeyFrames keyFrames1 = KeyFrames::New();
2106     keyFrames1.Add(0.0f, sourceOrthographic);
2107     keyFrames1.Add(1.0f, targetOrthographic);
2108
2109     KeyFrames keyFrames2 = KeyFrames::New();
2110     keyFrames2.Add(0.0f, sourceAspect);
2111     keyFrames2.Add(1.0f, targetAspect);
2112
2113     animation.AnimateBetween(Property(camera, DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), keyFrames1);
2114     animation.AnimateBetween(Property(camera, CameraActor::Property::ASPECT_RATIO), keyFrames2);
2115
2116     animation.Play();
2117     TestAnimationProgress();
2118   }
2119
2120   // AnimateBy
2121   {
2122     tet_printf("AnimateBy - horizontal\n");
2123     camera.SetProperty(Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE, sourceOrthographic);
2124     camera.SetProperty(CameraActor::Property::ASPECT_RATIO, sourceAspect);
2125     Animation animation = Animation::New(1.0f);
2126     animation.AnimateBy(Property(camera, DevelCameraActor::Property::ORTHOGRAPHIC_SIZE), targetOrthographic - sourceOrthographic);
2127     animation.AnimateBy(Property(camera, CameraActor::Property::ASPECT_RATIO), targetAspect - sourceAspect);
2128     animation.Play();
2129     TestAnimationProgress();
2130   }
2131
2132   END_TEST;
2133 }
2134
2135 int UtcDaliCameraActorPropertyIndices(void)
2136 {
2137   TestApplication application;
2138   CameraActor     camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
2139
2140   Actor                    basicActor = Actor::New();
2141   Property::IndexContainer indices;
2142   camera.GetPropertyIndices(indices);
2143   DALI_TEST_CHECK(indices.Size() > basicActor.GetPropertyCount());
2144   DALI_TEST_EQUALS(indices.Size(), camera.GetPropertyCount(), TEST_LOCATION);
2145   END_TEST;
2146 }
2147
2148 int UtcDaliCameraActorCheckLookAtAndFreeLookViews01(void)
2149 {
2150   TestApplication    application;
2151   Integration::Scene stage     = application.GetScene();
2152   Vector2            stageSize = stage.GetSize();
2153
2154   CameraActor freeLookCameraActor = CameraActor::New(stageSize);
2155   freeLookCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2156   freeLookCameraActor.SetType(Camera::FREE_LOOK);
2157
2158   Vector3 targetPosition(30.0f, 240.0f, -256.0f);
2159   Actor   target = Actor::New();
2160   target.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2161   target.SetProperty(Actor::Property::POSITION, targetPosition);
2162
2163   Constraint cameraOrientationConstraint = Constraint::New<Quaternion>(freeLookCameraActor, Actor::Property::ORIENTATION, &LookAt);
2164   cameraOrientationConstraint.AddSource(Source(target, Actor::Property::WORLD_POSITION));
2165   cameraOrientationConstraint.AddSource(Source(freeLookCameraActor, Actor::Property::WORLD_POSITION));
2166   cameraOrientationConstraint.AddSource(Source(target, Actor::Property::WORLD_ORIENTATION));
2167   cameraOrientationConstraint.Apply();
2168
2169   CameraActor lookAtCameraActor = CameraActor::New(stageSize);
2170   lookAtCameraActor.SetType(Camera::LOOK_AT_TARGET);
2171   lookAtCameraActor.SetTargetPosition(targetPosition);
2172   lookAtCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2173
2174   stage.Add(target);
2175   stage.Add(freeLookCameraActor);
2176   stage.Add(lookAtCameraActor);
2177
2178   // Create an arbitrary vector
2179   for(float x = -1.0f; x <= 1.0f; x += 0.1f)
2180   {
2181     for(float y = -1.0f; y < 1.0f; y += 0.1f)
2182     {
2183       for(float z = -1.0f; z < 1.0f; z += 0.1f)
2184       {
2185         Vector3 position(x, y, z);
2186         position.Normalize();
2187         position *= 200.0f;
2188
2189         freeLookCameraActor.SetProperty(Actor::Property::POSITION, position);
2190         lookAtCameraActor.SetProperty(Actor::Property::POSITION, position);
2191
2192         application.SendNotification();
2193         application.Render();
2194         application.SendNotification();
2195         application.Render();
2196         Matrix freeLookViewMatrix;
2197         Matrix lookAtViewMatrix;
2198         freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(freeLookViewMatrix);
2199         lookAtCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(lookAtViewMatrix);
2200
2201         DALI_TEST_EQUALS(freeLookViewMatrix, lookAtViewMatrix, 0.01, TEST_LOCATION);
2202       }
2203     }
2204   }
2205   END_TEST;
2206 }
2207
2208 int UtcDaliCameraActorCheckLookAtAndFreeLookViews02(void)
2209 {
2210   TestApplication    application;
2211   Integration::Scene stage     = application.GetScene();
2212   Vector2            stageSize = stage.GetSize();
2213
2214   CameraActor freeLookCameraActor = CameraActor::New(stageSize);
2215   freeLookCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2216   freeLookCameraActor.SetType(Camera::FREE_LOOK);
2217
2218   Vector3 targetPosition(30.0f, 240.0f, -256.0f);
2219   Actor   target = Actor::New();
2220   target.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2221   target.SetProperty(Actor::Property::POSITION, targetPosition);
2222
2223   Constraint cameraOrientationConstraint = Constraint::New<Quaternion>(freeLookCameraActor, Actor::Property::ORIENTATION, &LookAt);
2224   cameraOrientationConstraint.AddSource(Source(target, Actor::Property::WORLD_POSITION));
2225   cameraOrientationConstraint.AddSource(Source(freeLookCameraActor, Actor::Property::WORLD_POSITION));
2226   cameraOrientationConstraint.AddSource(Source(target, Actor::Property::WORLD_ORIENTATION));
2227   cameraOrientationConstraint.Apply();
2228
2229   CameraActor lookAtCameraActor = CameraActor::New(stageSize);
2230   lookAtCameraActor.SetType(Camera::LOOK_AT_TARGET);
2231   lookAtCameraActor.SetTargetPosition(targetPosition);
2232   lookAtCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2233
2234   stage.Add(target);
2235   stage.Add(freeLookCameraActor);
2236   stage.Add(lookAtCameraActor);
2237   stage.GetRenderTaskList().GetTask(0).SetCameraActor(freeLookCameraActor);
2238
2239   // Create an arbitrary vector
2240   for(float x = -1.0f; x <= 1.0f; x += 0.1f)
2241   {
2242     for(float y = -1.0f; y < 1.0f; y += 0.1f)
2243     {
2244       for(float z = -1.0f; z < 1.0f; z += 0.1f)
2245       {
2246         Vector3 position(x, y, z);
2247         position.Normalize();
2248         position *= 200.0f;
2249
2250         freeLookCameraActor.SetProperty(Actor::Property::POSITION, position);
2251         lookAtCameraActor.SetProperty(Actor::Property::POSITION, position);
2252
2253         application.SendNotification();
2254         application.Render();
2255         application.SendNotification();
2256         application.Render();
2257         Matrix freeLookViewMatrix;
2258         freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(freeLookViewMatrix);
2259
2260         Matrix freeLookWorld = freeLookCameraActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
2261
2262         Matrix freeLookTest(false);
2263         Matrix::Multiply(freeLookTest, freeLookViewMatrix, freeLookWorld);
2264         DALI_TEST_EQUALS(freeLookTest, Matrix::IDENTITY, 0.01f, TEST_LOCATION);
2265       }
2266     }
2267   }
2268
2269   END_TEST;
2270 }
2271
2272 int UtcDaliCameraActorCheckLookAtAndFreeLookViews03(void)
2273 {
2274   TestApplication    application;
2275   Integration::Scene stage     = application.GetScene();
2276   Vector2            stageSize = stage.GetSize();
2277
2278   Vector3 targetPosition(Vector3::ZERO);
2279   Vector3 cameraOffset(0.0f, 0.0f, 100.0f);
2280
2281   CameraActor freeLookCameraActor = CameraActor::New(stageSize);
2282   freeLookCameraActor.SetType(Camera::FREE_LOOK);
2283   freeLookCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2284
2285   Quaternion cameraOrientation(Radian(Degree(180.0f)), Vector3::YAXIS);
2286   freeLookCameraActor.SetProperty(Actor::Property::POSITION, cameraOffset);
2287   freeLookCameraActor.SetProperty(Actor::Property::ORIENTATION, cameraOrientation);
2288
2289   Actor cameraAnchor = Actor::New();
2290   cameraAnchor.Add(freeLookCameraActor);
2291   stage.Add(cameraAnchor);
2292   stage.GetRenderTaskList().GetTask(0).SetCameraActor(freeLookCameraActor);
2293
2294   for(float angle = 1.0f; angle <= 180.0f; angle += 1.0f)
2295   {
2296     Quaternion rotation(Radian(Degree(angle)), Vector3::YAXIS);
2297
2298     freeLookCameraActor.SetProperty(Actor::Property::POSITION, rotation.Rotate(cameraOffset));
2299     cameraAnchor.SetProperty(Actor::Property::ORIENTATION, rotation);
2300
2301     application.SendNotification();
2302     application.Render();
2303     application.SendNotification();
2304     application.Render();
2305
2306     Matrix freeLookViewMatrix;
2307     freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(freeLookViewMatrix);
2308
2309     Matrix freeLookWorld = freeLookCameraActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
2310
2311     Matrix freeLookTest(false);
2312     Matrix::Multiply(freeLookTest, freeLookViewMatrix, freeLookWorld);
2313     DALI_TEST_EQUALS(freeLookTest, Matrix::IDENTITY, 0.01f, TEST_LOCATION);
2314   }
2315   END_TEST;
2316 }
2317
2318 int UtcDaliCameraActorReflectionByPlane(void)
2319 {
2320   TestApplication application;
2321
2322   Integration::Scene stage = application.GetScene();
2323
2324   Vector3 targetPosition(Vector3::ZERO);
2325   Vector3 cameraOffset(0.0f, 100.0f, 100.0f);
2326
2327   CameraActor freeLookCameraActor = stage.GetRenderTaskList().GetTask(0).GetCameraActor();
2328   freeLookCameraActor.SetType(Camera::LOOK_AT_TARGET);
2329   freeLookCameraActor.SetTargetPosition(targetPosition);
2330   freeLookCameraActor.SetProperty(Actor::Property::POSITION, cameraOffset);
2331
2332   stage.GetRootLayer().SetProperty(Actor::Property::POSITION, Vector2(1, 0));
2333
2334   application.SendNotification();
2335   application.Render();
2336   application.SendNotification();
2337   application.Render();
2338
2339   Matrix matrixBefore, matrixAfter;
2340   freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(matrixBefore);
2341   freeLookCameraActor.SetProperty(Dali::DevelCameraActor::Property::REFLECTION_PLANE, Vector4(0.0f, 1.0f, 0.0f, 0.0f));
2342   stage.GetRootLayer().SetProperty(Actor::Property::POSITION, Vector2(0, 0));
2343   application.SendNotification();
2344   application.Render();
2345   application.SendNotification();
2346   application.Render();
2347
2348   freeLookCameraActor.GetProperty(CameraActor::CameraActor::Property::VIEW_MATRIX).Get(matrixAfter);
2349
2350   Vector3    position, scale;
2351   Quaternion rotation;
2352   matrixAfter.GetTransformComponents(position, rotation, scale);
2353
2354   Quaternion reflected(0, 0, 1, 0);
2355
2356   DALI_TEST_EQUALS(reflected, rotation, 0.01f, TEST_LOCATION);
2357
2358   // Test Free Look camera
2359   freeLookCameraActor.SetType(Camera::FREE_LOOK);
2360
2361   // Make sure the recalculation will take place
2362   freeLookCameraActor.SetProperty(Dali::DevelCameraActor::Property::REFLECTION_PLANE, Vector4(0.0f, 1.0f, 0.0f, 0.0f));
2363
2364   application.SendNotification();
2365   application.Render();
2366   application.SendNotification();
2367   application.Render();
2368
2369   // Nothing should change despite of different camera type
2370   matrixAfter.GetTransformComponents(position, rotation, scale);
2371   DALI_TEST_EQUALS(reflected, rotation, 0.01f, TEST_LOCATION);
2372
2373   // Test Orthographic camera
2374   freeLookCameraActor.SetProjectionMode(Dali::Camera::ProjectionMode::ORTHOGRAPHIC_PROJECTION);
2375
2376   // Make sure the recalculation will take place
2377   freeLookCameraActor.SetProperty(Dali::DevelCameraActor::Property::REFLECTION_PLANE, Vector4(0.0f, 1.0f, 0.0f, 0.0f));
2378
2379   application.SendNotification();
2380   application.Render();
2381   application.SendNotification();
2382   application.Render();
2383
2384   // Nothing should change despite of different camera type
2385   matrixAfter.GetTransformComponents(position, rotation, scale);
2386   DALI_TEST_EQUALS(reflected, rotation, 0.01f, TEST_LOCATION);
2387
2388   // Test Orthographic camera + Look at target
2389   freeLookCameraActor.SetType(Camera::LOOK_AT_TARGET);
2390   freeLookCameraActor.SetTargetPosition(targetPosition);
2391
2392   // Make sure the recalculation will take place
2393   freeLookCameraActor.SetProperty(Dali::DevelCameraActor::Property::REFLECTION_PLANE, Vector4(0.0f, 1.0f, 0.0f, 0.0f));
2394
2395   application.SendNotification();
2396   application.Render();
2397   application.SendNotification();
2398   application.Render();
2399
2400   // Nothing should change despite of different camera type
2401   matrixAfter.GetTransformComponents(position, rotation, scale);
2402   DALI_TEST_EQUALS(reflected, rotation, 0.01f, TEST_LOCATION);
2403
2404   END_TEST;
2405 }
2406
2407 int UtcDaliCameraActorProjectionDirection(void)
2408 {
2409   TestApplication application;
2410
2411   Integration::Scene stage     = application.GetScene();
2412   Vector2            stageSize = stage.GetSize();
2413
2414   CameraActor defaultCameraActor = stage.GetRenderTaskList().GetTask(0).GetCameraActor();
2415   CameraActor expectCameraActor1 = CameraActor::New(stageSize);
2416   CameraActor expectCameraActor2 = CameraActor::New(stageSize);
2417   CameraActor expectCameraActor3 = CameraActor::New(stageSize);
2418
2419   float fieldOfView = defaultCameraActor.GetFieldOfView();
2420   float aspectRatio = defaultCameraActor.GetAspectRatio();
2421
2422   // Calculate expect camera 1's fov.
2423   float anotherFieldOfView = 2.0f * std::atan(std::tan(fieldOfView * 0.5f) / aspectRatio);
2424   expectCameraActor1.SetFieldOfView(anotherFieldOfView);
2425
2426   // Calculate expect camera 2's fov and aspect ratio.
2427   float anotherFieldOfView2 = 2.0f * std::atan(std::tan(fieldOfView * 0.5f) * aspectRatio);
2428   float anotherAspectRatio  = 1.0f / aspectRatio;
2429   expectCameraActor2.SetFieldOfView(anotherFieldOfView2);
2430   expectCameraActor2.SetAspectRatio(anotherAspectRatio);
2431
2432   // Calculate expect camera 3's aspect raio
2433   expectCameraActor3.SetAspectRatio(anotherAspectRatio);
2434
2435   stage.Add(expectCameraActor1);
2436   stage.Add(expectCameraActor2);
2437   stage.Add(expectCameraActor3);
2438
2439   application.SendNotification();
2440   application.Render();
2441   application.SendNotification();
2442   application.Render();
2443
2444   // Test default projection direction is VERTICAL
2445   DALI_TEST_EQUALS(defaultCameraActor.GetProperty<int>(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION), static_cast<int>(Dali::DevelCameraActor::ProjectionDirection::VERTICAL), TEST_LOCATION);
2446
2447   Matrix matrixBefore, matrixAfter;
2448   Matrix matrixExpect1, matrixExpect2, matrixExpect3;
2449
2450   defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixBefore);
2451   expectCameraActor1.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixExpect1);
2452   expectCameraActor2.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixExpect2);
2453   expectCameraActor3.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixExpect3);
2454
2455   tet_printf("Check ProjectionDirection::HORIZONTAL\n");
2456
2457   defaultCameraActor.SetProperty(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION, Dali::DevelCameraActor::ProjectionDirection::HORIZONTAL);
2458   DALI_TEST_EQUALS(defaultCameraActor.GetProperty<int>(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION), static_cast<int>(Dali::DevelCameraActor::ProjectionDirection::HORIZONTAL), TEST_LOCATION);
2459   // NOTE : ProjectionDirection doesn't change camera actor's FieldOfView and AspectRatio value.)
2460   DALI_TEST_EQUALS(defaultCameraActor.GetFieldOfView(), fieldOfView, TEST_LOCATION);
2461   DALI_TEST_EQUALS(defaultCameraActor.GetAspectRatio(), aspectRatio, TEST_LOCATION);
2462
2463   application.SendNotification();
2464   application.Render();
2465   application.SendNotification();
2466   application.Render();
2467
2468   defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixAfter);
2469
2470   // Check camera's ProjectionMatrix same as expect camera 1's ProjectionMatrix.
2471   DALI_TEST_EQUALS(matrixAfter, matrixExpect1, Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2472
2473   tet_printf("Check ProjectionDirection::HORIZONTAL + Change aspect ratio\n");
2474
2475   defaultCameraActor.SetAspectRatio(anotherAspectRatio);
2476   DALI_TEST_EQUALS(defaultCameraActor.GetAspectRatio(), anotherAspectRatio, TEST_LOCATION);
2477
2478   application.SendNotification();
2479   application.Render();
2480   application.SendNotification();
2481   application.Render();
2482
2483   defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixAfter);
2484
2485   // Check camera's ProjectionMatrix same as expect camera 2's ProjectionMatrix.
2486   DALI_TEST_EQUALS(matrixAfter, matrixExpect2, Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2487
2488   tet_printf("Check ProjectionDirection::HORIZONTAL + Change aspect ratio + Change fov\n");
2489
2490   defaultCameraActor.SetFieldOfView(anotherFieldOfView);
2491   DALI_TEST_EQUALS(defaultCameraActor.GetFieldOfView(), anotherFieldOfView, TEST_LOCATION);
2492   DALI_TEST_EQUALS(defaultCameraActor.GetAspectRatio(), anotherAspectRatio, TEST_LOCATION);
2493
2494   application.SendNotification();
2495   application.Render();
2496   application.SendNotification();
2497   application.Render();
2498
2499   defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixAfter);
2500
2501   // Check camera's ProjectionMatrix same as expect camera 3's ProjectionMatrix.
2502   DALI_TEST_EQUALS(matrixAfter, matrixExpect3, Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2503
2504   tet_printf("Check ProjectionDirection::VERTICAL, the original camera\n");
2505
2506   defaultCameraActor.SetProperty(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION, Dali::DevelCameraActor::ProjectionDirection::VERTICAL);
2507   defaultCameraActor.SetFieldOfView(fieldOfView);
2508   defaultCameraActor.SetAspectRatio(aspectRatio);
2509   DALI_TEST_EQUALS(defaultCameraActor.GetProperty<int>(Dali::DevelCameraActor::Property::PROJECTION_DIRECTION), static_cast<int>(Dali::DevelCameraActor::ProjectionDirection::VERTICAL), TEST_LOCATION);
2510   DALI_TEST_EQUALS(defaultCameraActor.GetFieldOfView(), fieldOfView, TEST_LOCATION);
2511   DALI_TEST_EQUALS(defaultCameraActor.GetAspectRatio(), aspectRatio, TEST_LOCATION);
2512
2513   application.SendNotification();
2514   application.Render();
2515   application.SendNotification();
2516   application.Render();
2517
2518   defaultCameraActor.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(matrixAfter);
2519
2520   // Check vertical camera's ProjectionMatrix same as original ProjectionMatrix.
2521   DALI_TEST_EQUALS(matrixAfter, matrixBefore, Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION);
2522
2523   END_TEST;
2524 }
2525
2526 int UtcDaliCameraActorGetAspectRatioNegative(void)
2527 {
2528   TestApplication   application;
2529   Dali::CameraActor instance;
2530   try
2531   {
2532     instance.GetAspectRatio();
2533     DALI_TEST_CHECK(false); // Should not get here
2534   }
2535   catch(...)
2536   {
2537     DALI_TEST_CHECK(true); // We expect an assert
2538   }
2539   END_TEST;
2540 }
2541
2542 int UtcDaliCameraActorGetFieldOfViewNegative(void)
2543 {
2544   TestApplication   application;
2545   Dali::CameraActor instance;
2546   try
2547   {
2548     instance.GetFieldOfView();
2549     DALI_TEST_CHECK(false); // Should not get here
2550   }
2551   catch(...)
2552   {
2553     DALI_TEST_CHECK(true); // We expect an assert
2554   }
2555   END_TEST;
2556 }
2557
2558 int UtcDaliCameraActorGetInvertYAxisNegative(void)
2559 {
2560   TestApplication   application;
2561   Dali::CameraActor instance;
2562   try
2563   {
2564     instance.GetInvertYAxis();
2565     DALI_TEST_CHECK(false); // Should not get here
2566   }
2567   catch(...)
2568   {
2569     DALI_TEST_CHECK(true); // We expect an assert
2570   }
2571   END_TEST;
2572 }
2573
2574 int UtcDaliCameraActorSetAspectRatioNegative(void)
2575 {
2576   TestApplication   application;
2577   Dali::CameraActor instance;
2578   try
2579   {
2580     float arg1(0.0f);
2581     instance.SetAspectRatio(arg1);
2582     DALI_TEST_CHECK(false); // Should not get here
2583   }
2584   catch(...)
2585   {
2586     DALI_TEST_CHECK(true); // We expect an assert
2587   }
2588   END_TEST;
2589 }
2590
2591 int UtcDaliCameraActorSetFieldOfViewNegative(void)
2592 {
2593   TestApplication   application;
2594   Dali::CameraActor instance;
2595   try
2596   {
2597     float arg1(0.0f);
2598     instance.SetFieldOfView(arg1);
2599     DALI_TEST_CHECK(false); // Should not get here
2600   }
2601   catch(...)
2602   {
2603     DALI_TEST_CHECK(true); // We expect an assert
2604   }
2605   END_TEST;
2606 }
2607
2608 int UtcDaliCameraActorSetInvertYAxisNegative(void)
2609 {
2610   TestApplication   application;
2611   Dali::CameraActor instance;
2612   try
2613   {
2614     bool arg1(false);
2615     instance.SetInvertYAxis(arg1);
2616     DALI_TEST_CHECK(false); // Should not get here
2617   }
2618   catch(...)
2619   {
2620     DALI_TEST_CHECK(true); // We expect an assert
2621   }
2622   END_TEST;
2623 }
2624
2625 int UtcDaliCameraActorSetProjectionModeNegative(void)
2626 {
2627   TestApplication   application;
2628   Dali::CameraActor instance;
2629   try
2630   {
2631     Dali::Camera::ProjectionMode arg1(Camera::PERSPECTIVE_PROJECTION);
2632     instance.SetProjectionMode(arg1);
2633     DALI_TEST_CHECK(false); // Should not get here
2634   }
2635   catch(...)
2636   {
2637     DALI_TEST_CHECK(true); // We expect an assert
2638   }
2639   END_TEST;
2640 }
2641
2642 int UtcDaliCameraActorSetTargetPositionNegative(void)
2643 {
2644   TestApplication   application;
2645   Dali::CameraActor instance;
2646   try
2647   {
2648     Dali::Vector3 arg1;
2649     instance.SetTargetPosition(arg1);
2650     DALI_TEST_CHECK(false); // Should not get here
2651   }
2652   catch(...)
2653   {
2654     DALI_TEST_CHECK(true); // We expect an assert
2655   }
2656   END_TEST;
2657 }
2658
2659 int UtcDaliCameraActorGetFarClippingPlaneNegative(void)
2660 {
2661   TestApplication   application;
2662   Dali::CameraActor instance;
2663   try
2664   {
2665     instance.GetFarClippingPlane();
2666     DALI_TEST_CHECK(false); // Should not get here
2667   }
2668   catch(...)
2669   {
2670     DALI_TEST_CHECK(true); // We expect an assert
2671   }
2672   END_TEST;
2673 }
2674
2675 int UtcDaliCameraActorSetFarClippingPlaneNegative(void)
2676 {
2677   TestApplication   application;
2678   Dali::CameraActor instance;
2679   try
2680   {
2681     float arg1(0.0f);
2682     instance.SetFarClippingPlane(arg1);
2683     DALI_TEST_CHECK(false); // Should not get here
2684   }
2685   catch(...)
2686   {
2687     DALI_TEST_CHECK(true); // We expect an assert
2688   }
2689   END_TEST;
2690 }
2691
2692 int UtcDaliCameraActorGetNearClippingPlaneNegative(void)
2693 {
2694   TestApplication   application;
2695   Dali::CameraActor instance;
2696   try
2697   {
2698     instance.GetNearClippingPlane();
2699     DALI_TEST_CHECK(false); // Should not get here
2700   }
2701   catch(...)
2702   {
2703     DALI_TEST_CHECK(true); // We expect an assert
2704   }
2705   END_TEST;
2706 }
2707
2708 int UtcDaliCameraActorSetNearClippingPlaneNegative(void)
2709 {
2710   TestApplication   application;
2711   Dali::CameraActor instance;
2712   try
2713   {
2714     float arg1(0.0f);
2715     instance.SetNearClippingPlane(arg1);
2716     DALI_TEST_CHECK(false); // Should not get here
2717   }
2718   catch(...)
2719   {
2720     DALI_TEST_CHECK(true); // We expect an assert
2721   }
2722   END_TEST;
2723 }
2724
2725 int UtcDaliCameraActorSetPerspectiveProjectionNegative(void)
2726 {
2727   TestApplication   application;
2728   Dali::CameraActor instance;
2729   try
2730   {
2731     Dali::Vector2 arg1;
2732     instance.SetPerspectiveProjection(arg1);
2733     DALI_TEST_CHECK(false); // Should not get here
2734   }
2735   catch(...)
2736   {
2737     DALI_TEST_CHECK(true); // We expect an assert
2738   }
2739   END_TEST;
2740 }
2741
2742 int UtcDaliCameraActorSetOrthographicProjectionNegative02(void)
2743 {
2744   TestApplication   application;
2745   Dali::CameraActor instance;
2746   try
2747   {
2748     Dali::Vector2 arg1;
2749     instance.SetOrthographicProjection(arg1);
2750     DALI_TEST_CHECK(false); // Should not get here
2751   }
2752   catch(...)
2753   {
2754     DALI_TEST_CHECK(true); // We expect an assert
2755   }
2756   END_TEST;
2757 }
2758
2759 int UtcDaliCameraActorSetTypeNegative(void)
2760 {
2761   TestApplication   application;
2762   Dali::CameraActor instance;
2763   try
2764   {
2765     Dali::Camera::Type arg1(Camera::FREE_LOOK);
2766     instance.SetType(arg1);
2767     DALI_TEST_CHECK(false); // Should not get here
2768   }
2769   catch(...)
2770   {
2771     DALI_TEST_CHECK(true); // We expect an assert
2772   }
2773   END_TEST;
2774 }
2775
2776 int UtcDaliCameraActorGetProjectionModeNegative(void)
2777 {
2778   TestApplication   application;
2779   Dali::CameraActor instance;
2780   try
2781   {
2782     instance.GetProjectionMode();
2783     DALI_TEST_CHECK(false); // Should not get here
2784   }
2785   catch(...)
2786   {
2787     DALI_TEST_CHECK(true); // We expect an assert
2788   }
2789   END_TEST;
2790 }
2791
2792 int UtcDaliCameraActorGetTargetPositionNegative(void)
2793 {
2794   TestApplication   application;
2795   Dali::CameraActor instance;
2796   try
2797   {
2798     instance.GetTargetPosition();
2799     DALI_TEST_CHECK(false); // Should not get here
2800   }
2801   catch(...)
2802   {
2803     DALI_TEST_CHECK(true); // We expect an assert
2804   }
2805   END_TEST;
2806 }
2807
2808 int UtcDaliCameraActorGetTypeNegative(void)
2809 {
2810   TestApplication   application;
2811   Dali::CameraActor instance;
2812   try
2813   {
2814     instance.GetType();
2815     DALI_TEST_CHECK(false); // Should not get here
2816   }
2817   catch(...)
2818   {
2819     DALI_TEST_CHECK(true); // We expect an assert
2820   }
2821   END_TEST;
2822 }
2823
2824 int UtcDaliCameraActorNewDefaultOrthogonalProjection01(void)
2825 {
2826   TestApplication application;
2827   tet_infoline("Test that changing to orthogonal projection and then adding to scene calculates the right defaults");
2828
2829   CameraActor actor = CameraActor::New();
2830   DALI_TEST_CHECK(actor);
2831
2832   actor.SetProjectionMode(Camera::ORTHOGRAPHIC_PROJECTION);
2833   application.GetScene().Add(actor);
2834
2835   // Test application screen size is 480x800
2836   // Check that the properties match to that screen size
2837   float value;
2838   actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
2839   DALI_TEST_EQUALS(480.0f / 800.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2840
2841   actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
2842   DALI_TEST_EQUALS(800.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2843
2844   actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
2845   DALI_TEST_EQUALS(4895.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2846
2847   actor.GetProperty(CameraActor::Property::LEFT_PLANE_DISTANCE).Get(value);
2848   DALI_TEST_EQUALS(-240.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2849   actor.GetProperty(CameraActor::Property::RIGHT_PLANE_DISTANCE).Get(value);
2850   DALI_TEST_EQUALS(240.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2851
2852   actor.GetProperty(CameraActor::Property::TOP_PLANE_DISTANCE).Get(value);
2853   DALI_TEST_EQUALS(400.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2854   actor.GetProperty(CameraActor::Property::BOTTOM_PLANE_DISTANCE).Get(value);
2855   DALI_TEST_EQUALS(-400.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2856
2857   DALI_TEST_EQUALS(1600.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
2858
2859   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
2860   END_TEST;
2861 }
2862
2863 int UtcDaliCameraActorNewDefaultOrthogonalProjection02(void)
2864 {
2865   TestApplication application;
2866   tet_infoline("Test that changing to orthogonal projection and then adding to scene calculates the right defaults");
2867
2868   CameraActor actor = CameraActor::New();
2869   DALI_TEST_CHECK(actor);
2870
2871   actor.SetOrthographicProjection(Vector2::ZERO);
2872   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
2873   application.GetScene().Add(actor);
2874
2875   // Test application screen size is 480x800
2876   // Check that the properties match to that screen size
2877   float value;
2878   actor.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(value);
2879   DALI_TEST_EQUALS(480.0f / 800.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2880
2881   actor.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(value);
2882   DALI_TEST_EQUALS(800.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2883
2884   actor.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(value);
2885   DALI_TEST_EQUALS(4895.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2886
2887   actor.GetProperty(CameraActor::Property::LEFT_PLANE_DISTANCE).Get(value);
2888   DALI_TEST_EQUALS(-240.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2889   actor.GetProperty(CameraActor::Property::RIGHT_PLANE_DISTANCE).Get(value);
2890   DALI_TEST_EQUALS(240.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2891
2892   actor.GetProperty(CameraActor::Property::TOP_PLANE_DISTANCE).Get(value);
2893   DALI_TEST_EQUALS(400.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2894   actor.GetProperty(CameraActor::Property::BOTTOM_PLANE_DISTANCE).Get(value);
2895   DALI_TEST_EQUALS(-400.0f, value, FLOAT_EPSILON, TEST_LOCATION);
2896
2897   DALI_TEST_EQUALS(1600.0f, actor.GetProperty(Actor::Property::POSITION_Z).Get<float>(), TEST_LOCATION);
2898
2899   DALI_TEST_EQUALS(actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION);
2900   END_TEST;
2901 }
2902
2903 // Add tests for culling:
2904 //   add large actor just outside canvas, & rotate it 45% - should still be rendered
2905 //   Rotate back to 0, should be culled.
2906
2907 int UtcDaliCameraActorCulling01(void)
2908 {
2909   TestApplication application;
2910   auto&           gfx = application.GetGraphicsController();
2911
2912   tet_infoline("Create a renderable actor and position it slightly to the left of the scene");
2913   tet_infoline("The actor should not be rendered");
2914
2915   Actor a = CreateRenderableActor(CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 200, 200));
2916
2917   a[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER_LEFT;
2918   a[Actor::Property::ANCHOR_POINT]  = ParentOrigin::CENTER_RIGHT;
2919   a[Actor::Property::POSITION]      = Vector3(-10.0f, 0.0f, 0.0f);
2920
2921   application.GetScene().Add(a);
2922
2923   application.SendNotification();
2924   application.Render();
2925
2926   auto& cmdStack = gfx.mCommandBufferCallStack;
2927   DALI_TEST_CHECK(!cmdStack.FindMethod("Draw") && !cmdStack.FindMethod("DrawIndexed"));
2928
2929   tet_infoline("Rotate the actor 45 degrees, the actor should now be rendered");
2930   a[Actor::Property::ORIENTATION] = Quaternion(Dali::ANGLE_45, Vector3::ZAXIS);
2931   application.SendNotification();
2932   application.Render();
2933
2934   DALI_TEST_CHECK(cmdStack.FindMethod("Draw") || cmdStack.FindMethod("DrawIndexed"));
2935
2936   END_TEST;
2937 }
2938
2939 int UtcDaliCameraActorSetProperty(void)
2940 {
2941   TestApplication application;
2942
2943   tet_infoline("Test the CameraActor reset properties when On Scene, if user set property explicitly.");
2944
2945   CameraActor camera = CameraActor::New();
2946   camera.SetFieldOfView(1.0f);
2947   application.GetScene().Add(camera);
2948   DALI_TEST_EQUALS(1.0f, camera.GetFieldOfView(), TEST_LOCATION);
2949   camera.Unparent();
2950   camera.Reset();
2951
2952   camera = CameraActor::New();
2953   camera.SetAspectRatio(1.0f);
2954   application.GetScene().Add(camera);
2955   DALI_TEST_EQUALS(1.0f, camera.GetAspectRatio(), TEST_LOCATION);
2956   camera.Unparent();
2957   camera.Reset();
2958
2959   camera = CameraActor::New();
2960   camera.SetNearClippingPlane(1.0f);
2961   application.GetScene().Add(camera);
2962   DALI_TEST_EQUALS(1.0f, camera.GetNearClippingPlane(), TEST_LOCATION);
2963   camera.Unparent();
2964   camera.Reset();
2965
2966   camera = CameraActor::New();
2967   camera.SetFarClippingPlane(1.0f);
2968   application.GetScene().Add(camera);
2969   DALI_TEST_EQUALS(1.0f, camera.GetFarClippingPlane(), TEST_LOCATION);
2970   camera.Unparent();
2971   camera.Reset();
2972
2973   camera = CameraActor::New();
2974   camera.SetProperty(Dali::Actor::Property::POSITION, Vector3(100.0f, 100.0f, 100.0f));
2975   application.GetScene().Add(camera);
2976   DALI_TEST_EQUALS(Vector3(100.0f, 100.0f, 100.0f), camera.GetProperty<Vector3>(Dali::Actor::Property::POSITION), TEST_LOCATION);
2977   camera.Unparent();
2978   camera.Reset();
2979
2980   camera = CameraActor::New();
2981   camera.SetProperty(Dali::Actor::Property::POSITION_X, 1.0f);
2982   application.GetScene().Add(camera);
2983   DALI_TEST_EQUALS(1.0f, camera.GetProperty<float>(Dali::Actor::Property::POSITION_X), TEST_LOCATION);
2984   camera.Unparent();
2985   camera.Reset();
2986
2987   camera = CameraActor::New();
2988   camera.SetProperty(Dali::Actor::Property::POSITION_Y, 1.0f);
2989   application.GetScene().Add(camera);
2990   DALI_TEST_EQUALS(1.0f, camera.GetProperty<float>(Dali::Actor::Property::POSITION_Y), TEST_LOCATION);
2991   camera.Unparent();
2992   camera.Reset();
2993
2994   camera = CameraActor::New();
2995   camera.SetProperty(Dali::Actor::Property::POSITION_Z, 1.0f);
2996   application.GetScene().Add(camera);
2997   DALI_TEST_EQUALS(1.0f, camera.GetProperty<float>(Dali::Actor::Property::POSITION_Z), TEST_LOCATION);
2998   camera.Unparent();
2999   camera.Reset();
3000
3001   camera = CameraActor::New();
3002   camera.SetProperty(Dali::Actor::Property::ORIENTATION, Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS));
3003   application.GetScene().Add(camera);
3004   DALI_TEST_EQUALS(Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS), camera.GetProperty<Quaternion>(Dali::Actor::Property::ORIENTATION), TEST_LOCATION);
3005   camera.Unparent();
3006   camera.Reset();
3007
3008   END_TEST;
3009 }
3010
3011 int UtcDaliCameraActorConstraintInputProperty(void)
3012 {
3013   TestApplication application;
3014   tet_infoline("Testing Constraint input properties");
3015
3016   CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
3017   application.SendNotification();
3018   application.Render(0);
3019   application.Render();
3020   application.SendNotification();
3021   Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
3022   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
3023   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
3024   application.GetScene().Add(actor);
3025
3026   float projectionMode;
3027   float projectionDirection;
3028   float invertYAxis;
3029   float nearClippingPlane;
3030   float farClippingPlane;
3031
3032   camera.GetProperty(CameraActor::Property::PROJECTION_MODE).Get(projectionMode);
3033   camera.GetProperty(DevelCameraActor::Property::PROJECTION_DIRECTION).Get(projectionDirection);
3034   camera.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(invertYAxis);
3035   camera.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(nearClippingPlane);
3036   camera.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(farClippingPlane);
3037
3038   Property::Index projectionModePropertyIndex      = actor.RegisterProperty("projectionMode", 100.0f);
3039   Property::Index projectionDirectionPropertyIndex = actor.RegisterProperty("projectionDirection", 100.0f);
3040   Property::Index invertYAxisPropertyIndex         = actor.RegisterProperty("invertYAxis", 100.0f);
3041   Property::Index nearClippingPlanePropertyIndex   = actor.RegisterProperty("nearClippingPlane", 100.0f);
3042   Property::Index farClippingPlanePropertyIndex    = actor.RegisterProperty("farClippingPlane", 100.0f);
3043
3044   application.SendNotification();
3045   application.Render();
3046
3047   Constraint projectionModePropertyConstraint      = Constraint::New<float>(actor, projectionModePropertyIndex, [](float& output, const PropertyInputContainer& inputs)
3048                                                                     { output = static_cast<float>(inputs[0]->GetInteger()); });
3049   Constraint projectionDirectionPropertyConstraint = Constraint::New<float>(actor, projectionDirectionPropertyIndex, [](float& output, const PropertyInputContainer& inputs)
3050                                                                     { output = static_cast<float>(inputs[0]->GetInteger()); });
3051   Constraint invertYAxisPropertyConstraint         = Constraint::New<float>(actor, invertYAxisPropertyIndex, [](float& output, const PropertyInputContainer& inputs)
3052                                                                     { output = static_cast<float>(inputs[0]->GetBoolean()); });
3053   Constraint nearClippingPlanePropertyConstraint   = Constraint::New<float>(actor, nearClippingPlanePropertyIndex, EqualToConstraint());
3054   Constraint farClippingPlanePropertyConstraint    = Constraint::New<float>(actor, farClippingPlanePropertyIndex, EqualToConstraint());
3055
3056   projectionModePropertyConstraint.AddSource(Source(camera, CameraActor::Property::PROJECTION_MODE));
3057   projectionDirectionPropertyConstraint.AddSource(Source(camera, DevelCameraActor::Property::PROJECTION_DIRECTION));
3058   invertYAxisPropertyConstraint.AddSource(Source(camera, CameraActor::Property::INVERT_Y_AXIS));
3059   nearClippingPlanePropertyConstraint.AddSource(Source(camera, CameraActor::Property::NEAR_PLANE_DISTANCE));
3060   farClippingPlanePropertyConstraint.AddSource(Source(camera, CameraActor::Property::FAR_PLANE_DISTANCE));
3061
3062   projectionModePropertyConstraint.Apply();
3063   projectionDirectionPropertyConstraint.Apply();
3064   invertYAxisPropertyConstraint.Apply();
3065   nearClippingPlanePropertyConstraint.Apply();
3066   farClippingPlanePropertyConstraint.Apply();
3067
3068   application.SendNotification();
3069   application.Render();
3070
3071   float projectionModeResult      = actor.GetCurrentProperty<float>(projectionModePropertyIndex);
3072   float projectionDirectionResult = actor.GetCurrentProperty<float>(projectionDirectionPropertyIndex);
3073   float invertYAxisResult         = actor.GetCurrentProperty<float>(invertYAxisPropertyIndex);
3074   float nearClippingPlaneResult   = actor.GetCurrentProperty<float>(nearClippingPlanePropertyIndex);
3075   float farClippingPlaneResult    = actor.GetCurrentProperty<float>(farClippingPlanePropertyIndex);
3076
3077   DALI_TEST_EQUALS(projectionModeResult, projectionMode, TEST_LOCATION);
3078   DALI_TEST_EQUALS(projectionDirectionResult, projectionDirection, TEST_LOCATION);
3079   DALI_TEST_EQUALS(invertYAxisResult, invertYAxis, TEST_LOCATION);
3080   DALI_TEST_EQUALS(nearClippingPlaneResult, nearClippingPlane, TEST_LOCATION);
3081   DALI_TEST_EQUALS(farClippingPlaneResult, farClippingPlane, TEST_LOCATION);
3082
3083   END_TEST;
3084 }