[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Handle.cpp
1 /*
2  * Copyright (c) 2022 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/devel-api/actors/actor-devel.h>
19 #include <dali/devel-api/object/handle-devel.h>
20 #include <dali/public-api/dali-core.h>
21 #include <mesh-builder.h>
22 #include <stdlib.h>
23
24 #include <iostream>
25 #include <typeinfo>
26
27 #include "dali-test-suite-utils/dali-test-suite-utils.h"
28 #include "dali-test-suite-utils/test-custom-actor.h"
29
30 using namespace Dali;
31
32 void handle_test_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void handle_test_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42 namespace
43 {
44 /// Allows the creation of a BaseObject
45 class BaseObjectType : public BaseObject
46 {
47 public:
48   BaseObjectType()
49   {
50   }
51 };
52
53 Handle ImplicitCopyConstructor(Handle passedByValue)
54 {
55   // object + copy + passedByValue, ref count == 3
56   DALI_TEST_CHECK(passedByValue);
57   if(passedByValue)
58   {
59     DALI_TEST_EQUALS(3, passedByValue.GetBaseObject().ReferenceCount(), TEST_LOCATION);
60   }
61
62   return passedByValue;
63 }
64
65 } // namespace
66
67 int UtcDaliHandleConstructorVoid(void)
68 {
69   TestApplication application;
70   tet_infoline("Testing Dali::Handle::Handle()");
71
72   Handle object;
73
74   DALI_TEST_CHECK(!object);
75
76   END_TEST;
77 }
78
79 int UtcDaliHandleCopyConstructor(void)
80 {
81   TestApplication application;
82   tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
83
84   // Initialize an object, ref count == 1
85   Handle object = Actor::New();
86
87   DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
88
89   // Copy the object, ref count == 2
90   Handle copy(object);
91   DALI_TEST_CHECK(copy);
92   if(copy)
93   {
94     DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
95   }
96
97   {
98     // Pass by value, and return another copy, ref count == 3
99     Handle anotherCopy = ImplicitCopyConstructor(copy);
100
101     DALI_TEST_CHECK(anotherCopy);
102     if(anotherCopy)
103     {
104       DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
105     }
106   }
107
108   // anotherCopy out of scope, ref count == 2
109   DALI_TEST_CHECK(copy);
110   if(copy)
111   {
112     DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
113   }
114   END_TEST;
115 }
116
117 int UtcDaliHandleAssignmentOperator(void)
118 {
119   TestApplication application;
120   tet_infoline("Testing Dali::Handle::operator=");
121
122   Handle object = Actor::New();
123
124   DALI_TEST_CHECK(object);
125   DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
126
127   Handle copy;
128   DALI_TEST_CHECK(!copy);
129
130   copy = object;
131   DALI_TEST_CHECK(copy);
132   DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
133   DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject()));
134   END_TEST;
135 }
136
137 int UtcDaliHandleMoveConstructor(void)
138 {
139   TestApplication application;
140
141   // Initialize a handle, ref count == 1
142   Handle handle = Actor::New();
143
144   DALI_TEST_EQUALS(1, handle.GetBaseObject().ReferenceCount(), TEST_LOCATION);
145
146   int             value(20);
147   Property::Index index = handle.RegisterProperty("customProperty", value);
148   DALI_TEST_CHECK(handle.GetProperty<int>(index) == value);
149
150   // Move the object, ref count == 1
151   Handle move = std::move(handle);
152   DALI_TEST_CHECK(move);
153
154   // Check that object is moved (not copied, so ref count keeps the same)
155   DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
156   DALI_TEST_CHECK(move.GetProperty<int>(index) == value);
157   DALI_TEST_CHECK(!handle);
158
159   END_TEST;
160 }
161
162 int UtcDaliHandleMoveAssignment(void)
163 {
164   TestApplication application;
165
166   // Initialize a handle, ref count == 1
167   Handle handle = Actor::New();
168
169   DALI_TEST_EQUALS(1, handle.GetBaseObject().ReferenceCount(), TEST_LOCATION);
170
171   int             value(20);
172   Property::Index index = handle.RegisterProperty("customProperty", value);
173   DALI_TEST_CHECK(handle.GetProperty<int>(index) == value);
174
175   // Move the object, ref count == 1
176   Handle move;
177   move = std::move(handle);
178   DALI_TEST_CHECK(move);
179
180   // Check that object is moved (not copied, so ref count keeps the same)
181   DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
182   DALI_TEST_CHECK(move.GetProperty<int>(index) == value);
183   DALI_TEST_CHECK(!handle);
184
185   END_TEST;
186 }
187
188 int UtcDaliHandleSupports(void)
189 {
190   tet_infoline("Positive Test Dali::Handle::Supports()");
191   TestApplication application;
192
193   Actor actor = Actor::New();
194   DALI_TEST_CHECK(true == actor.Supports(Handle::DYNAMIC_PROPERTIES));
195   END_TEST;
196 }
197
198 int UtcDaliHandleGetPropertyCount(void)
199 {
200   tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
201   TestApplication application;
202
203   Actor actor = Actor::New();
204   int   defaultPropertyCount(actor.GetPropertyCount());
205
206   // Register a dynamic property
207   actor.RegisterProperty("testProperty", float(123.0f));
208   DALI_TEST_CHECK((defaultPropertyCount + 1u) == actor.GetPropertyCount());
209   END_TEST;
210 }
211
212 int UtcDaliHandleGetPropertyName(void)
213 {
214   tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
215   TestApplication application;
216
217   Actor actor = Actor::New();
218   DALI_TEST_CHECK("parentOrigin" == actor.GetPropertyName(Actor::Property::PARENT_ORIGIN));
219
220   // Register a dynamic property
221   std::string     name("thisNameShouldMatch");
222   Property::Index index = actor.RegisterProperty(name, float(123.0f));
223   DALI_TEST_CHECK(name == actor.GetPropertyName(index));
224
225   END_TEST;
226 }
227
228 int UtcDaliHandleGetPropertyIndex01(void)
229 {
230   tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
231   TestApplication application;
232
233   Actor actor = Actor::New();
234   DALI_TEST_CHECK(Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parentOrigin"));
235
236   // Register a dynamic property
237   std::string     name("thisNameShouldMatch");
238   Property::Index index = actor.RegisterProperty(name, float(123.0f));
239   DALI_TEST_CHECK(index == actor.GetPropertyIndex(name));
240   END_TEST;
241 }
242
243 int UtcDaliHandleGetPropertyIndex02(void)
244 {
245   tet_infoline("Positive Test Dali::Handle::GetPropertyIndex() int key");
246   TestApplication application;
247
248   Integration::Scene stage = application.GetScene();
249
250   Actor actor = Actor::New();
251   stage.Add(actor);
252
253   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
254
255   application.SendNotification();
256   application.Render();
257
258   Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
259   Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
260
261   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
262   const float   withFlake(99.f);
263
264   Property::Index index1 = actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
265   Property::Index index2 = actor.RegisterProperty(key1, "sideColor", testColor);
266   Property::Index index3 = actor.RegisterProperty("MyPropertyTwo", Vector3::ONE);
267   Property::Index index4 = actor.RegisterProperty(key2, "iceCream", withFlake);
268   Property::Index index5 = actor.RegisterProperty("MyPropertyThree", Vector3::ONE);
269
270   application.SendNotification();
271   application.Render();
272
273   // Test that we can get the property index from the integer key
274   Property::Index testIndex1 = actor.GetPropertyIndex(key1);
275   Property::Index testIndex2 = actor.GetPropertyIndex(key2);
276
277   DALI_TEST_EQUALS(index2, testIndex1, TEST_LOCATION);
278   DALI_TEST_EQUALS(index4, testIndex2, TEST_LOCATION);
279
280   // Test that we keep the same indices on the named properties
281   Property::Index testIndex = actor.GetPropertyIndex("MyPropertyOne");
282   DALI_TEST_EQUALS(testIndex, index1, TEST_LOCATION);
283   testIndex = actor.GetPropertyIndex("MyPropertyTwo");
284   DALI_TEST_EQUALS(testIndex, index3, TEST_LOCATION);
285   testIndex = actor.GetPropertyIndex("MyPropertyThree");
286   DALI_TEST_EQUALS(testIndex, index5, TEST_LOCATION);
287   testIndex = actor.GetPropertyIndex("sideColor");
288   DALI_TEST_EQUALS(testIndex, index2, TEST_LOCATION);
289   testIndex = actor.GetPropertyIndex("iceCream");
290   DALI_TEST_EQUALS(testIndex, index4, TEST_LOCATION);
291
292   DALI_TEST_EQUALS(defaultPropertyCount + 5, actor.GetPropertyCount(), TEST_LOCATION);
293   END_TEST;
294 }
295
296 int UtcDaliHandleGetPropertyIndex03(void)
297 {
298   TestApplication application;
299
300   Actor actor = Actor::New();
301
302   std::string     myName("croydon");
303   Property::Index intKey = CORE_PROPERTY_MAX_INDEX + 1;
304   Property::Value value(Color::GREEN);
305   Property::Index myIndex = actor.RegisterProperty(intKey, myName, value);
306
307   DALI_TEST_EQUALS(myIndex, actor.GetPropertyIndex(intKey), TEST_LOCATION);
308
309   Property::Key key1(myName);
310   Property::Key key2(intKey);
311
312   DALI_TEST_EQUALS(myIndex, actor.GetPropertyIndex(key1), TEST_LOCATION);
313   DALI_TEST_EQUALS(myIndex, actor.GetPropertyIndex(key2), TEST_LOCATION);
314   END_TEST;
315 }
316
317 int UtcDaliHandleIsPropertyWritable(void)
318 {
319   tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
320   TestApplication application;
321
322   Actor actor = Actor::New();
323
324   // Actor properties which are writable:
325   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::PARENT_ORIGIN));
326   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::PARENT_ORIGIN_X));
327   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::PARENT_ORIGIN_Y));
328   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::PARENT_ORIGIN_Z));
329   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ANCHOR_POINT));
330   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ANCHOR_POINT_X));
331   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ANCHOR_POINT_Y));
332   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ANCHOR_POINT_Z));
333   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SIZE));
334   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SIZE_WIDTH));
335   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SIZE_HEIGHT));
336   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SIZE_DEPTH));
337   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::POSITION));
338   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::POSITION_X));
339   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::POSITION_Y));
340   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::POSITION_Z));
341   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ORIENTATION));
342   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SCALE));
343   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SCALE_X));
344   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SCALE_Y));
345   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SCALE_Z));
346   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::VISIBLE));
347   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR));
348   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR_RED));
349   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR_GREEN));
350   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR_BLUE));
351   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR_ALPHA));
352   DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::OPACITY));
353
354   // World-properties are not writable:
355   DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_POSITION));
356   DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_ORIENTATION));
357   DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_SCALE));
358   DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_COLOR));
359   DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_POSITION_X));
360   DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_POSITION_Y));
361   DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_POSITION_Z));
362
363   END_TEST;
364 }
365
366 int UtcDaliHandleIsPropertyAnimatable(void)
367 {
368   tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
369   TestApplication application;
370
371   Actor actor = Actor::New();
372
373   // Actor properties which are animatable:
374   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::PARENT_ORIGIN));
375   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::PARENT_ORIGIN_X));
376   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::PARENT_ORIGIN_Y));
377   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::PARENT_ORIGIN_Z));
378   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::ANCHOR_POINT));
379   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::ANCHOR_POINT_X));
380   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::ANCHOR_POINT_Y));
381   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::ANCHOR_POINT_Z));
382   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SIZE));
383   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SIZE_WIDTH));
384   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SIZE_HEIGHT));
385   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SIZE_DEPTH));
386   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::POSITION));
387   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::POSITION_X));
388   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::POSITION_Y));
389   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::POSITION_Z));
390   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::ORIENTATION));
391   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SCALE));
392   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SCALE_X));
393   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SCALE_Y));
394   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SCALE_Z));
395   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::VISIBLE));
396   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR));
397   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR_RED));
398   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR_GREEN));
399   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR_BLUE));
400   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR_ALPHA));
401   DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::OPACITY));
402
403   // World-properties can not be animated
404   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_POSITION));
405   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_ORIENTATION));
406   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_SCALE));
407   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_COLOR));
408   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_POSITION_X));
409   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_POSITION_Y));
410   DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_POSITION_Z));
411
412   END_TEST;
413 }
414
415 int UtcDaliHandleIsPropertyAConstraintInput(void)
416 {
417   TestApplication application;
418
419   Actor actor = Actor::New();
420
421   // Actor properties which can be used as a constraint input:
422   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::PARENT_ORIGIN));
423   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::PARENT_ORIGIN_X));
424   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::PARENT_ORIGIN_Y));
425   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::PARENT_ORIGIN_Z));
426   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ANCHOR_POINT));
427   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ANCHOR_POINT_X));
428   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ANCHOR_POINT_Y));
429   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ANCHOR_POINT_Z));
430   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SIZE));
431   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SIZE_WIDTH));
432   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SIZE_HEIGHT));
433   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SIZE_DEPTH));
434   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::POSITION));
435   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::POSITION_X));
436   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::POSITION_Y));
437   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::POSITION_Z));
438   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ORIENTATION));
439   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SCALE));
440   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SCALE_X));
441   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SCALE_Y));
442   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SCALE_Z));
443   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::VISIBLE));
444   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR));
445   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_RED));
446   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_GREEN));
447   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_BLUE));
448   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_ALPHA));
449   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::OPACITY));
450   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_POSITION));
451   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_ORIENTATION));
452   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_SCALE));
453   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_COLOR));
454   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_POSITION_X));
455   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_POSITION_Y));
456   DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_POSITION_Z));
457
458   // Actor properties that cannot be used as a constraint input
459   DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::NAME));
460   DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::SENSITIVE));
461   DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::LEAVE_REQUIRED));
462   DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::INHERIT_ORIENTATION));
463   DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::INHERIT_SCALE));
464   DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_MODE));
465   DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::DRAW_MODE));
466   DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::SIZE_MODE_FACTOR));
467
468   END_TEST;
469 }
470
471 int UtcDaliHandleGetPropertyType(void)
472 {
473   tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
474   TestApplication application;
475
476   Actor actor = Actor::New();
477   DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::PARENT_ORIGIN));
478   DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::ANCHOR_POINT));
479   DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::SIZE));
480   DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::POSITION));
481   DALI_TEST_CHECK(Property::ROTATION == actor.GetPropertyType(Actor::Property::ORIENTATION));
482   DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::SCALE));
483   DALI_TEST_CHECK(Property::BOOLEAN == actor.GetPropertyType(Actor::Property::VISIBLE));
484   DALI_TEST_CHECK(Property::VECTOR4 == actor.GetPropertyType(Actor::Property::COLOR));
485
486   // Register some dynamic properties
487   Property::Index boolIndex     = actor.RegisterProperty("boolProperty", bool(true));
488   Property::Index floatIndex    = actor.RegisterProperty("floatProperty", float(123.0f));
489   Property::Index intIndex      = actor.RegisterProperty("intProperty", 123);
490   Property::Index vector2Index  = actor.RegisterProperty("vector2Property", Vector2(1.0f, 2.0f));
491   Property::Index vector3Index  = actor.RegisterProperty("vector3Property", Vector3(1.0f, 2.0f, 3.0f));
492   Property::Index vector4Index  = actor.RegisterProperty("vector4Property", Vector4(1.0f, 2.0f, 3.0f, 4.0f));
493   Property::Index rotationIndex = actor.RegisterProperty("rotationProperty", AngleAxis(Degree(180.0f), Vector3::YAXIS));
494
495   DALI_TEST_CHECK(Property::BOOLEAN == actor.GetPropertyType(boolIndex));
496   DALI_TEST_CHECK(Property::FLOAT == actor.GetPropertyType(floatIndex));
497   DALI_TEST_CHECK(Property::INTEGER == actor.GetPropertyType(intIndex));
498   DALI_TEST_CHECK(Property::VECTOR2 == actor.GetPropertyType(vector2Index));
499   DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(vector3Index));
500   DALI_TEST_CHECK(Property::VECTOR4 == actor.GetPropertyType(vector4Index));
501   DALI_TEST_CHECK(Property::ROTATION == actor.GetPropertyType(rotationIndex));
502
503   // Non animatable properties
504   Property::Index nonAnimStringIndex  = actor.RegisterProperty("manFromDelmonte", std::string("yes"), Property::READ_WRITE);
505   Property::Index nonAnimV2Index      = actor.RegisterProperty("v2", Vector2(1.f, 2.f), Property::READ_WRITE);
506   Property::Index nonAnimV3Index      = actor.RegisterProperty("v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
507   Property::Index nonAnimV4Index      = actor.RegisterProperty("v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
508   Property::Index nonAnimBooleanIndex = actor.RegisterProperty("bool", true, Property::READ_WRITE);
509   Property::Index nonAnimFloatIndex   = actor.RegisterProperty("float", 0.f, Property::READ_WRITE);
510   Property::Index nonAnimIntegerIndex = actor.RegisterProperty("int", 0, Property::READ_WRITE);
511
512   DALI_TEST_CHECK(nonAnimStringIndex != Property::INVALID_INDEX);
513   DALI_TEST_CHECK(nonAnimV2Index != Property::INVALID_INDEX);
514   DALI_TEST_CHECK(nonAnimV3Index != Property::INVALID_INDEX);
515   DALI_TEST_CHECK(nonAnimV4Index != Property::INVALID_INDEX);
516   DALI_TEST_CHECK(nonAnimBooleanIndex != Property::INVALID_INDEX);
517   DALI_TEST_CHECK(nonAnimFloatIndex != Property::INVALID_INDEX);
518   DALI_TEST_CHECK(nonAnimIntegerIndex != Property::INVALID_INDEX);
519
520   DALI_TEST_CHECK(Property::STRING == actor.GetPropertyType(nonAnimStringIndex));
521   DALI_TEST_CHECK(Property::VECTOR2 == actor.GetPropertyType(nonAnimV2Index));
522   DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(nonAnimV3Index));
523   DALI_TEST_CHECK(Property::VECTOR4 == actor.GetPropertyType(nonAnimV4Index));
524   DALI_TEST_CHECK(Property::BOOLEAN == actor.GetPropertyType(nonAnimBooleanIndex));
525   DALI_TEST_CHECK(Property::FLOAT == actor.GetPropertyType(nonAnimFloatIndex));
526   DALI_TEST_CHECK(Property::INTEGER == actor.GetPropertyType(nonAnimIntegerIndex));
527
528   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimStringIndex));
529   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimV2Index));
530   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimV3Index));
531   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimV4Index));
532   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimBooleanIndex));
533   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimFloatIndex));
534   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimIntegerIndex));
535
536   DALI_TEST_EQUALS("yes", actor.GetProperty(nonAnimStringIndex).Get<std::string>(), TEST_LOCATION);
537   DALI_TEST_EQUALS(Vector2(1.f, 2.f), actor.GetProperty(nonAnimV2Index).Get<Vector2>(), TEST_LOCATION);
538   DALI_TEST_EQUALS(Vector3(1.f, 2.f, 3.f), actor.GetProperty(nonAnimV3Index).Get<Vector3>(), TEST_LOCATION);
539   DALI_TEST_EQUALS(Vector4(1.f, 2.f, 3.f, 4.f), actor.GetProperty(nonAnimV4Index).Get<Vector4>(), TEST_LOCATION);
540   DALI_TEST_EQUALS(true, actor.GetProperty(nonAnimBooleanIndex).Get<bool>(), TEST_LOCATION);
541   DALI_TEST_EQUALS(0.f, actor.GetProperty(nonAnimFloatIndex).Get<float>(), TEST_LOCATION);
542   DALI_TEST_EQUALS(0, actor.GetProperty(nonAnimIntegerIndex).Get<int>(), TEST_LOCATION);
543
544   END_TEST;
545 }
546
547 int UtcDaliHandleNonAnimatableProperties(void)
548 {
549   tet_infoline("Test Non Animatable Properties");
550   TestApplication application;
551
552   Actor actor = Actor::New();
553
554   Property::Index nonAnimStringIndex = actor.RegisterProperty("manFromDelmonte", std::string("no"), Property::READ_WRITE);
555
556   //// modify writable?
557   actor.SetProperty(nonAnimStringIndex, Property::Value("yes"));
558
559   DALI_TEST_CHECK("yes" == actor.GetProperty(nonAnimStringIndex).Get<std::string>());
560
561   //// cannot modify read only?
562   Property::Index readonly = actor.RegisterProperty("float", 0.f, Property::READ_ONLY);
563
564   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
565   DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
566
567   actor.SetProperty(readonly, Property::Value(1.f));
568   // trying to set a read-only property is a no-op
569
570   DALI_TEST_EQUALS(0.f, actor.GetProperty(readonly).Get<float>(), TEST_LOCATION);
571
572   /// animatable can be set
573   Property::Index write_anim = actor.RegisterProperty("write_float", 0.f, Property::ANIMATABLE);
574
575   DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
576   DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
577
578   actor.SetProperty(write_anim, Property::Value(1.f));
579
580   //// animate a non animatable property throws
581   float     durationSeconds(2.0f);
582   Animation animation = Animation::New(durationSeconds);
583   bool      relativeValue(true);
584   try
585   {
586     animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
587   }
588   catch(Dali::DaliException& e)
589   {
590     DALI_TEST_ASSERT(e, "Property type is not animatable", TEST_LOCATION);
591   }
592
593   DALI_TEST_EQUALS("yes", actor.GetProperty(nonAnimStringIndex).Get<std::string>(), TEST_LOCATION);
594
595   END_TEST;
596 }
597
598 int UtcDaliHandleNonAnimtableCompositeProperties(void)
599 {
600   tet_infoline("Test Non Animatable Composite Properties");
601   TestApplication application;
602
603   Actor actor = Actor::New();
604
605   Property::Value  value(Property::ARRAY);
606   Property::Array* array = value.GetArray();
607   DALI_TEST_CHECK(array);
608
609   array->PushBack(Property::Value(0.1f));
610   array->PushBack("a string");
611   array->PushBack(Property::Value(Vector3(1, 2, 3)));
612
613   DALI_TEST_EQUALS(3u, array->Count(), TEST_LOCATION);
614
615   Property::Index propertyIndex = actor.RegisterProperty("composite", value, Property::READ_WRITE);
616
617   Property::Value  out      = actor.GetProperty(propertyIndex);
618   Property::Array* outArray = out.GetArray();
619   DALI_TEST_CHECK(outArray != NULL);
620
621   DALI_TEST_CHECK(Property::FLOAT == outArray->GetElementAt(0).GetType());
622   DALI_TEST_CHECK(Property::STRING == outArray->GetElementAt(1).GetType());
623   DALI_TEST_CHECK(Property::VECTOR3 == outArray->GetElementAt(2).GetType());
624
625   DALI_TEST_EQUALS(0.1f, outArray->GetElementAt(0).Get<float>(), TEST_LOCATION);
626   DALI_TEST_EQUALS("a string", outArray->GetElementAt(1).Get<std::string>(), TEST_LOCATION);
627   DALI_TEST_EQUALS(Vector3(1, 2, 3), outArray->GetElementAt(2).Get<Vector3>(), TEST_LOCATION);
628
629   // composite types not animatable
630   bool exception = false;
631   try
632   {
633     actor.RegisterProperty("compositemap", value, Property::ANIMATABLE);
634   }
635   catch(Dali::DaliException& e)
636   {
637     exception = true;
638     DALI_TEST_PRINT_ASSERT(e);
639   }
640
641   DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
642
643   // Map of maps
644   Property::Value mapOfMaps(Property::MAP);
645   Property::Map*  map = mapOfMaps.GetMap();
646
647   map->Insert("key", Property::Value(Property::MAP));
648   map->Insert("2key", "a string");
649
650   DALI_TEST_EQUALS("a string", (*map)["2key"].Get<std::string>(), TEST_LOCATION);
651
652   Property::Map* innerMap = map->Find("key")->GetMap();
653   innerMap->Insert("subkey", 5.f);
654
655   DALI_TEST_CHECK(NULL != map->Find("key")->GetMap()->Find("subkey"));
656   DALI_TEST_EQUALS(5.f, map->Find("key")->GetMap()->Find("subkey")->Get<float>(), TEST_LOCATION);
657   END_TEST;
658 }
659
660 int UtcDaliHandleSetProperty01(void)
661 {
662   tet_infoline("Positive Test Dali::Handle::SetProperty()");
663   TestApplication application;
664
665   Actor actor = Actor::New();
666   DALI_TEST_CHECK(ParentOrigin::TOP_LEFT == actor.GetProperty(Actor::Property::PARENT_ORIGIN).Get<Vector3>());
667
668   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
669   // flush the queue and render once
670   application.SendNotification();
671   application.Render();
672   DALI_TEST_CHECK(ParentOrigin::CENTER == actor.GetProperty(Actor::Property::PARENT_ORIGIN).Get<Vector3>());
673   END_TEST;
674 }
675
676 int UtcDaliHandleSetProperty02(void)
677 {
678   tet_infoline("Positive Test Dali::Handle::SetProperty()");
679   TestApplication application;
680
681   Actor actor = Actor::New();
682
683   DALI_TEST_CHECK(!actor.IsPropertyWritable(Actor::Property::WORLD_POSITION));
684
685   // World position is not writable so this is a no-op and should not crash
686   actor.SetProperty(Actor::Property::WORLD_POSITION, Vector3(1, 2, 3));
687
688   END_TEST;
689 }
690
691 int UtcDaliHandleRegisterProperty01(void)
692 {
693   tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
694   TestApplication application;
695
696   Integration::Scene stage = application.GetScene();
697
698   Actor actor = Actor::New();
699   stage.Add(actor);
700
701   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
702
703   application.SendNotification();
704   application.Render();
705
706   Property::Index index1 = actor.RegisterProperty("MyProperty", Vector3::ONE);
707
708   application.SendNotification();
709   application.Render();
710
711   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION);
712   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index1), Vector3::ONE, TEST_LOCATION);
713
714   // No new property should be registered when we call the below function
715   Property::Index index2 = actor.RegisterProperty("MyProperty", Vector3::ZAXIS);
716
717   application.SendNotification();
718   application.Render();
719
720   DALI_TEST_EQUALS(index1, index2, TEST_LOCATION);                                     // We should have the same index as per the first registration
721   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION); // Property count should be the same
722   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index2), Vector3::ZAXIS, TEST_LOCATION); // Value should be what we sent on second RegisterProperty call
723
724   END_TEST;
725 }
726
727 int UtcDaliHandleRegisterProperty02(void)
728 {
729   tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key");
730   TestApplication application;
731
732   Integration::Scene stage = application.GetScene();
733
734   Actor actor = Actor::New();
735   stage.Add(actor);
736
737   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
738
739   application.SendNotification();
740   application.Render();
741
742   Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
743   Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
744
745   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
746   const float   withFlake(99.f);
747
748   Property::Index index1 = actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
749   Property::Index index2 = actor.RegisterProperty(key1, "sideColor", testColor);
750   Property::Index index3 = actor.RegisterProperty(key2, "iceCream", withFlake);
751
752   application.SendNotification();
753   application.Render();
754
755   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION);
756   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index1), Vector3::ONE, TEST_LOCATION);
757   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), testColor, TEST_LOCATION);
758   DALI_TEST_EQUALS(actor.GetProperty<float>(index3), withFlake, TEST_LOCATION);
759
760   // No new property should be registered when we call the below functions
761   Property::Index testIndex2 = actor.RegisterProperty("iceCream", 2200.f);
762   Property::Index testIndex1 = actor.RegisterProperty("sideColor", Color::BLACK);
763   application.SendNotification();
764   application.Render();
765
766   DALI_TEST_EQUALS(index2, testIndex1, TEST_LOCATION);                                 // We should have the same index as per the first registration
767   DALI_TEST_EQUALS(index3, testIndex2, TEST_LOCATION);                                 // We should have the same index as per the first registration
768   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION); // Property count should be the same
769   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), Color::BLACK, TEST_LOCATION);   // Value should be what we sent on second RegisterProperty call
770   DALI_TEST_EQUALS(actor.GetProperty<float>(index3), 2200.f, TEST_LOCATION);
771
772   END_TEST;
773 }
774
775 int UtcDaliHandleRegisterProperty03(void)
776 {
777   tet_infoline("Test Dali::Handle::RegisterUniqueProperty() int key against default property");
778   TestApplication application;
779
780   Integration::Scene stage = application.GetScene();
781
782   Actor actor = Actor::New();
783   stage.Add(actor);
784
785   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
786
787   application.SendNotification();
788   application.Render();
789
790   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
791   actor.SetProperty(Actor::Property::COLOR, testColor);
792
793   application.SendNotification();
794   application.Render();
795
796   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount, TEST_LOCATION);
797
798   // No uniqueness tests are done on the properties. Check that the indices are different
799
800   Property::Index key       = CORE_PROPERTY_MAX_INDEX + 1;
801   Property::Index testIndex = actor.RegisterUniqueProperty(key, "color", Color::BLACK);
802
803   application.SendNotification();
804   application.Render();
805
806   DALI_TEST_EQUALS(testIndex != Actor::Property::COLOR, true, TEST_LOCATION);
807   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION); // Property count should be different
808
809   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(Actor::Property::COLOR), testColor, TEST_LOCATION); // Value should not have changed
810   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(testIndex), Color::BLACK, TEST_LOCATION);           // Value should not have changed
811
812   // Check that name lookup returns the default property
813   DALI_TEST_EQUALS((int)actor.GetPropertyIndex(Property::Key("color")), (int)Actor::Property::COLOR, TEST_LOCATION);
814
815   // Check that they have different scene graph properties
816   DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::COLOR), Property::Value(testColor), 0.0001f, TEST_LOCATION);
817   DALI_TEST_EQUALS(actor.GetCurrentProperty(testIndex), Property::Value(Color::BLACK), 0.0001f, TEST_LOCATION);
818
819   END_TEST;
820 }
821
822 int UtcDaliHandleRegisterProperty04(void)
823 {
824   tet_infoline("Negative Test Dali::Handle::RegisterUniqueProperty() same int key against custom property");
825   TestApplication application;
826
827   Integration::Scene stage = application.GetScene();
828
829   Actor actor = Actor::New();
830   stage.Add(actor);
831
832   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
833
834   application.SendNotification();
835   application.Render();
836
837   Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
838   Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
839
840   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
841   const float   withFlake(99.f);
842
843   Property::Index index1 = actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
844   Property::Index index2 = actor.RegisterUniqueProperty(key1, "sideColor", testColor);
845   Property::Index index3 = actor.RegisterUniqueProperty(key2, "iceCream", withFlake);
846
847   application.SendNotification();
848   application.Render();
849
850   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION);
851   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index1), Vector3::ONE, TEST_LOCATION);
852   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), testColor, TEST_LOCATION);
853   DALI_TEST_EQUALS(actor.GetProperty<float>(index3), withFlake, TEST_LOCATION);
854
855   // If property key matches, ignore new name.
856   Property::Index testIndex2 = actor.RegisterUniqueProperty(key1, "sideColor", Color::BLACK);
857   Property::Index testIndex3 = actor.RegisterUniqueProperty(key2, "iceCream", 2200.f);
858   application.SendNotification();
859   application.Render();
860
861   DALI_TEST_EQUALS(index2 == testIndex2, true, TEST_LOCATION);
862   DALI_TEST_EQUALS(index3 == testIndex3, true, TEST_LOCATION);
863   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION); // Property count should be same
864   // Test that the value has actually been updated
865   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), Color::BLACK, TEST_LOCATION);
866   DALI_TEST_EQUALS(actor.GetProperty<float>(index3), 2200.f, TEST_LOCATION);
867
868   // Check that name lookup returns the first registered property
869   DALI_TEST_EQUALS(actor.GetPropertyIndex(Property::Key("sideColor")), index2, TEST_LOCATION);
870   DALI_TEST_EQUALS(actor.GetPropertyIndex(Property::Key("iceCream")), index3, TEST_LOCATION);
871
872   END_TEST;
873 }
874
875 int UtcDaliHandleRegisterProperty05(void)
876 {
877   tet_infoline("Positive Test Dali::Handle::RegisterUniqueProperty() different int key against custom property");
878   TestApplication application;
879
880   Integration::Scene stage = application.GetScene();
881
882   Actor actor = Actor::New();
883   stage.Add(actor);
884
885   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
886
887   application.SendNotification();
888   application.Render();
889
890   Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
891   Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
892
893   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
894   const float   withFlake(99.f);
895
896   Property::Index index1 = actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
897   Property::Index index2 = actor.RegisterUniqueProperty(key1, "sideColor", testColor);
898   Property::Index index3 = actor.RegisterUniqueProperty(key2, "iceCream", withFlake);
899
900   application.SendNotification();
901   application.Render();
902
903   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION);
904   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index1), Vector3::ONE, TEST_LOCATION);
905   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), testColor, TEST_LOCATION);
906   DALI_TEST_EQUALS(actor.GetProperty<float>(index3), withFlake, TEST_LOCATION);
907
908   // No uniqueness tests are done on the names. Check that the indices are different if the keys are different
909   Property::Index newKey1 = key2 + 1;
910   Property::Index newKey2 = key2 + 2;
911
912   Property::Index testIndex2 = actor.RegisterUniqueProperty(newKey1, "sideColor", Color::BLACK);
913   Property::Index testIndex3 = actor.RegisterUniqueProperty(newKey2, "iceCream", 2200.f);
914   application.SendNotification();
915   application.Render();
916
917   DALI_TEST_EQUALS(index2 == testIndex2, false, TEST_LOCATION);
918   DALI_TEST_EQUALS(index3 == testIndex3, false, TEST_LOCATION);
919   DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 5, TEST_LOCATION); // Property count should be different
920
921   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), testColor, TEST_LOCATION); // Value should not have changed
922   DALI_TEST_EQUALS(actor.GetProperty<float>(index3), withFlake, TEST_LOCATION);
923
924   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(testIndex2), Color::BLACK, TEST_LOCATION); // Value should not have changed
925   DALI_TEST_EQUALS(actor.GetProperty<float>(testIndex3), 2200.f, TEST_LOCATION);
926
927   // Check that name lookup returns the first registered property
928   DALI_TEST_EQUALS(actor.GetPropertyIndex(Property::Key("sideColor")), index2, TEST_LOCATION);
929   DALI_TEST_EQUALS(actor.GetPropertyIndex(Property::Key("iceCream")), index3, TEST_LOCATION);
930
931   END_TEST;
932 }
933
934 int UtcDaliHandleGetProperty(void)
935 {
936   tet_infoline("Positive Test Dali::Handle::GetProperty()");
937   TestApplication application;
938
939   Actor actor = Actor::New();
940
941   DALI_TEST_CHECK(ParentOrigin::TOP_LEFT == actor.GetProperty(Actor::Property::PARENT_ORIGIN).Get<Vector3>());
942   DALI_TEST_CHECK(AnchorPoint::CENTER == actor.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>());
943   DALI_TEST_CHECK(Vector3::ZERO == actor.GetProperty(Actor::Property::SIZE).Get<Vector3>());
944   DALI_TEST_CHECK(Vector3::ZERO == actor.GetProperty(Actor::Property::POSITION).Get<Vector3>());
945   DALI_TEST_CHECK(Vector3::ONE == actor.GetProperty(Actor::Property::SCALE).Get<Vector3>());
946   DALI_TEST_CHECK(true == actor.GetProperty(Actor::Property::VISIBLE).Get<bool>());
947   DALI_TEST_CHECK(Color::WHITE == actor.GetProperty(Actor::Property::COLOR).Get<Vector4>());
948   END_TEST;
949 }
950
951 int UtcDaliHandleDownCast(void)
952 {
953   TestApplication application;
954   tet_infoline("Testing Dali::Handle::DownCast()");
955
956   Actor actor = Actor::New();
957
958   BaseHandle baseHandle = actor;
959
960   Handle handle = Handle::DownCast(baseHandle);
961
962   DALI_TEST_CHECK(handle);
963
964   baseHandle = BaseHandle();
965
966   handle = Handle::DownCast(baseHandle);
967
968   DALI_TEST_CHECK(!handle);
969
970   END_TEST;
971 }
972
973 int UtcDaliHandleDownCastNegative(void)
974 {
975   TestApplication application;
976
977   // BaseObject is NOT an Object, so this DownCast should fail
978   BaseHandle handle(new BaseObjectType);
979   Handle     customHandle1 = Handle::DownCast(handle);
980   DALI_TEST_CHECK(!customHandle1);
981
982   // A DownCast on an empty handle will also fail
983   Handle empty;
984   Handle customHandle2 = Handle::DownCast(empty);
985   DALI_TEST_CHECK(!customHandle2);
986   END_TEST;
987 }
988
989 int UtcDaliHandleGetPropertyIndices(void)
990 {
991   TestApplication          application;
992   Property::IndexContainer indices;
993
994   // Actor
995   Actor actor = Actor::New();
996   actor.GetPropertyIndices(indices);
997   int numDefaultProperties = indices.Size();
998   DALI_TEST_CHECK(numDefaultProperties > 0);
999   DALI_TEST_EQUALS(numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION);
1000
1001   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
1002   const float   withFlake(99.f);
1003
1004   Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
1005   Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
1006
1007   actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
1008   actor.RegisterProperty(key1, "sideColor", testColor);
1009   actor.RegisterProperty("MyPropertyTwo", 1234);
1010   Property::Index index4 = actor.RegisterProperty(key2, "iceCream", withFlake);
1011   actor.RegisterProperty("MyPropertyThree", Vector2(.2f, .7f));
1012
1013   actor.GetPropertyIndices(indices);
1014
1015   DALI_TEST_EQUALS(indices.Size(), numDefaultProperties + 5, TEST_LOCATION);
1016   DALI_TEST_EQUALS(indices[indices.Size() - 2], index4, TEST_LOCATION);
1017
1018   END_TEST;
1019 }
1020
1021 int UtcDaliHandleRegisterPropertyTypes(void)
1022 {
1023   TestApplication application;
1024
1025   struct PropertyTypeAnimatable
1026   {
1027     const char*     name;
1028     Property::Value value;
1029     bool            animatable;
1030   };
1031
1032   Property::Array array;
1033   Property::Map   map;
1034
1035   PropertyTypeAnimatable properties[] =
1036     {
1037       {"Property::BOOLEAN", true, true},
1038       {"Property::FLOAT", 1.0f, true},
1039       {"Property::INTEGER", 1, true},
1040       {"Property::VECTOR2", Vector2::ONE, true},
1041       {"Property::VECTOR3", Vector3::ONE, true},
1042       {"Property::VECTOR4", Vector4::ONE, true},
1043       {"Property::MATRIX3", Matrix3::IDENTITY, true},
1044       {"Property::MATRIX", Matrix::IDENTITY, true},
1045       {"Property::RECTANGLE", Rect<int>(), false},
1046       {"Property::ROTATION", AngleAxis(), true},
1047       {"Property::STRING", std::string("Me"), false},
1048       {"Property::ARRAY", array, false},
1049       {"Property::MAP", map, false},
1050     };
1051
1052   unsigned int numOfProperties(sizeof(properties) / sizeof(properties[0]));
1053
1054   for(unsigned int i = 0; i < numOfProperties; ++i)
1055   {
1056     tet_printf("Testing: %s\n", properties[i].name);
1057
1058     bool exception = false;
1059     try
1060     {
1061       Actor actor = Actor::New();
1062       actor.RegisterProperty("manFromDelmonte", properties[i].value);
1063     }
1064     catch(Dali::DaliException& e)
1065     {
1066       exception = true;
1067     }
1068
1069     DALI_TEST_CHECK(properties[i].animatable != exception);
1070   }
1071   END_TEST;
1072 }
1073
1074 int UtcDaliHandleCustomProperty(void)
1075 {
1076   TestApplication application;
1077
1078   Handle handle = Handle::New();
1079
1080   float           startValue(1.0f);
1081   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1082   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1083
1084   application.SendNotification();
1085   application.Render(0);
1086   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1087   application.Render(0);
1088   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1089
1090   handle.SetProperty(index, 5.0f);
1091
1092   application.SendNotification();
1093   application.Render(0);
1094   DALI_TEST_CHECK(handle.GetProperty<float>(index) == 5.0f);
1095   application.Render(0);
1096   DALI_TEST_CHECK(handle.GetProperty<float>(index) == 5.0f);
1097   END_TEST;
1098 }
1099
1100 int UtcDaliHandleCustomPropertyNone(void)
1101 {
1102   TestApplication application;
1103
1104   Handle handle = Handle::New();
1105
1106   Property::Value value(Property::NONE);
1107   Property::Index index = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1108
1109   // Negative test i.e. setting a property of type NONE is meaningless
1110   handle.SetProperty(index, 5.0f);
1111
1112   DALI_TEST_CHECK(true); // got here without crashing
1113
1114   END_TEST;
1115 }
1116
1117 int UtcDaliHandleCustomPropertyIntToFloat(void)
1118 {
1119   TestApplication application;
1120
1121   Handle handle = Handle::New();
1122
1123   float           startValue(5.0f);
1124   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1125   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1126
1127   application.SendNotification();
1128   application.Render(0);
1129   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1130
1131   handle.SetProperty(index, int(1));
1132
1133   application.SendNotification();
1134   application.Render(0);
1135   DALI_TEST_CHECK(handle.GetProperty<float>(index) == 1.0f);
1136   END_TEST;
1137 }
1138
1139 int UtcDaliHandleCustomPropertyFloatToInt(void)
1140 {
1141   TestApplication application;
1142
1143   Handle handle = Handle::New();
1144
1145   int             startValue(5);
1146   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1147   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1148
1149   application.SendNotification();
1150   application.Render(0);
1151   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1152
1153   handle.SetProperty(index, float(1.5));
1154
1155   application.SendNotification();
1156   application.Render(0);
1157   DALI_TEST_CHECK(handle.GetProperty<int>(index) == 1);
1158   END_TEST;
1159 }
1160
1161 int UtcDaliHandleCustomPropertyInvalidToRect(void)
1162 {
1163   TestApplication application;
1164
1165   Handle handle = Handle::New();
1166
1167   Rect<int>       startValue(1, 2, 3, 4);
1168   Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1169   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1170
1171   application.SendNotification();
1172   application.Render(0);
1173   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1174
1175   // Negative test i.e. there is no conversion from float to Rect
1176   handle.SetProperty(index, float(1.5));
1177
1178   application.SendNotification();
1179   application.Render(0);
1180   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1181
1182   // Positive test (sanity check)
1183   Rect<int> endValue(5, 6, 7, 8);
1184   handle.SetProperty(index, endValue);
1185   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), endValue, TEST_LOCATION);
1186
1187   application.SendNotification();
1188   application.Render(0);
1189   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), endValue, TEST_LOCATION);
1190
1191   END_TEST;
1192 }
1193
1194 int UtcDaliHandleCustomPropertyInvalidToString(void)
1195 {
1196   TestApplication application;
1197
1198   Handle handle = Handle::New();
1199
1200   std::string     startValue("Libraries gave us power");
1201   Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1202   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1203
1204   application.SendNotification();
1205   application.Render(0);
1206   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1207
1208   // No conversion from Vector3 to std::string, therefore this should be a NOOP
1209   handle.SetProperty(index, Vector3(1, 2, 3));
1210
1211   application.SendNotification();
1212   application.Render(0);
1213   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1214
1215   // Positive test (sanity check)
1216   std::string endValue("Then work came and made us free");
1217   handle.SetProperty(index, endValue);
1218   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), endValue, TEST_LOCATION);
1219
1220   application.SendNotification();
1221   application.Render(0);
1222   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), endValue, TEST_LOCATION);
1223
1224   END_TEST;
1225 }
1226
1227 int UtcDaliHandleCustomPropertyInvalidToArray(void)
1228 {
1229   TestApplication application;
1230
1231   Handle handle = Handle::New();
1232
1233   Property::Value value(Property::ARRAY);
1234   std::string     startValue("The future teaches you to be alone");
1235   value.GetArray()->PushBack(startValue);
1236
1237   Property::Index index  = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1238   Property::Array check1 = handle.GetProperty<Property::Array>(index);
1239   DALI_TEST_EQUALS(check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1240
1241   application.SendNotification();
1242   application.Render(0);
1243   Property::Array check2 = handle.GetProperty<Property::Array>(index);
1244   DALI_TEST_EQUALS(check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1245
1246   // No conversion from int to ARRAY, therefore this should be a NOOP
1247   handle.SetProperty(index, int(2));
1248
1249   application.SendNotification();
1250   application.Render(0);
1251   Property::Array check3 = handle.GetProperty<Property::Array>(index);
1252   DALI_TEST_EQUALS(check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1253
1254   // Positive test (sanity check)
1255   Property::Value value2(Property::ARRAY);
1256   std::string     endValue("The present to be afraid and cold");
1257   value2.GetArray()->PushBack(endValue);
1258   handle.SetProperty(index, value2);
1259
1260   Property::Array check4 = handle.GetProperty<Property::Array>(index);
1261   DALI_TEST_EQUALS(check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION);
1262
1263   application.SendNotification();
1264   application.Render(0);
1265   Property::Array check5 = handle.GetProperty<Property::Array>(index);
1266   DALI_TEST_EQUALS(check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION);
1267
1268   END_TEST;
1269 }
1270
1271 int UtcDaliHandleCustomPropertyInvalidToMap(void)
1272 {
1273   TestApplication application;
1274
1275   Handle handle = Handle::New();
1276
1277   Property::Value value(Property::MAP);
1278   std::string     startValue("Culture sucks down words");
1279   value.GetMap()->Insert("1", startValue);
1280
1281   Property::Index  index  = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1282   Property::Value* check1 = handle.GetProperty<Property::Map>(index).Find("1");
1283   DALI_TEST_CHECK(NULL != check1);
1284
1285   // No conversion from float to MAP, therefore this should be a NOOP
1286   handle.SetProperty(index, float(3.0));
1287
1288   // Positive test (sanity check)
1289   Property::Value value2(Property::MAP);
1290   std::string     endValue("Itemise loathing and feed yourself smiles");
1291   value.GetMap()->Insert("1", endValue);
1292   handle.SetProperty(index, value2);
1293
1294   END_TEST;
1295 }
1296
1297 int UtcDaliHandleCustomPropertyInvalidToExtents(void)
1298 {
1299   TestApplication application;
1300
1301   Handle handle = Handle::New();
1302
1303   Extents         startValue(1, 2, 3, 4);
1304   Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1305   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1306
1307   application.SendNotification();
1308   application.Render(0);
1309   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1310
1311   // Negative test i.e. there is no conversion from float to Extents
1312   handle.SetProperty(index, float(1.5));
1313
1314   application.SendNotification();
1315   application.Render(0);
1316   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1317
1318   // Positive test (sanity check)
1319   Extents endValue(5, 6, 7, 8);
1320   handle.SetProperty(index, endValue);
1321   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), endValue, TEST_LOCATION);
1322
1323   application.SendNotification();
1324   application.Render(0);
1325   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), endValue, TEST_LOCATION);
1326
1327   END_TEST;
1328 }
1329
1330 int UtcDaliHandleCustomPropertyInvalidToBool(void)
1331 {
1332   TestApplication application;
1333
1334   Handle handle = Handle::New();
1335
1336   bool            startValue(true);
1337   Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1338   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1339
1340   application.SendNotification();
1341   application.Render(0);
1342   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1343
1344   // Negative test i.e. there is no conversion from float to bool
1345   handle.SetProperty(index, float(0.0));
1346
1347   application.SendNotification();
1348   application.Render(0);
1349   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1350
1351   // Positive test (sanity check)
1352   bool endValue(false);
1353   handle.SetProperty(index, endValue);
1354   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), endValue, TEST_LOCATION);
1355
1356   application.SendNotification();
1357   application.Render(0);
1358   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), endValue, TEST_LOCATION);
1359
1360   END_TEST;
1361 }
1362
1363 int UtcDaliHandleCustomPropertyInvalidToInt(void)
1364 {
1365   TestApplication application;
1366
1367   Handle handle = Handle::New();
1368
1369   int             startValue(5);
1370   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1371   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1372
1373   application.SendNotification();
1374   application.Render(0);
1375   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1376
1377   // Negative test i.e. there is no conversion from Vector3 to int
1378   handle.SetProperty(index, Vector3(1, 2, 3));
1379
1380   application.SendNotification();
1381   application.Render(0);
1382   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1383   END_TEST;
1384 }
1385
1386 int UtcDaliHandleCustomPropertyInvalidToFloat(void)
1387 {
1388   TestApplication application;
1389
1390   Handle handle = Handle::New();
1391
1392   float           startValue(5.0);
1393   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1394   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1395
1396   application.SendNotification();
1397   application.Render(0);
1398   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1399
1400   // Negative test i.e. there is no conversion from Vector3 to float
1401   handle.SetProperty(index, Vector3(1, 2, 3));
1402
1403   application.SendNotification();
1404   application.Render(0);
1405   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1406   END_TEST;
1407 }
1408
1409 int UtcDaliHandleCustomPropertyInvalidToRotation(void)
1410 {
1411   TestApplication application;
1412
1413   Handle handle = Handle::New();
1414
1415   Quaternion      startValue(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1416   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1417   DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1418
1419   application.SendNotification();
1420   application.Render(0);
1421   DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1422
1423   // Negative test i.e. there is no conversion from float to Quaternion
1424   handle.SetProperty(index, float(7.0));
1425
1426   application.SendNotification();
1427   application.Render(0);
1428   DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1429
1430   // Positive test (sanity check)
1431   Quaternion endValue(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1432   handle.SetProperty(index, endValue);
1433   DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == endValue);
1434
1435   END_TEST;
1436 }
1437
1438 int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
1439 {
1440   TestApplication application;
1441
1442   Handle handle = Handle::New();
1443
1444   Quaternion      rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1445   Matrix          startValue(rotation);
1446   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1447   DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1448
1449   application.SendNotification();
1450   application.Render(0);
1451   DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1452
1453   // Negative test i.e. there is no conversion from float to Matrix
1454   handle.SetProperty(index, float(7.0));
1455
1456   application.SendNotification();
1457   application.Render(0);
1458   DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1459
1460   // Positive test (sanity check)
1461   Quaternion endRotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1462   Matrix     endValue(endRotation);
1463   handle.SetProperty(index, endValue);
1464   DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == endValue);
1465
1466   END_TEST;
1467 }
1468
1469 int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
1470 {
1471   TestApplication application;
1472
1473   Handle handle = Handle::New();
1474
1475   Matrix3 startValue(11, 12, 13, 21, 22, 23, 31, 32, 33);
1476
1477   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1478   DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1479
1480   application.SendNotification();
1481   application.Render(0);
1482   DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1483
1484   // Negative test i.e. there is no conversion from float to Matrix3
1485   handle.SetProperty(index, float(7.0));
1486
1487   application.SendNotification();
1488   application.Render(0);
1489   DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1490
1491   // Positive test (sanity check)
1492   Matrix3 endValue(31, 32, 33, 21, 22, 23, 11, 12, 13);
1493   handle.SetProperty(index, endValue);
1494   DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == endValue);
1495
1496   END_TEST;
1497 }
1498
1499 int UtcDaliHandleWeightNew(void)
1500 {
1501   TestApplication application;
1502
1503   Handle handle = WeightObject::New();
1504   DALI_TEST_CHECK(handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f);
1505
1506   // process the message so scene object is added to update manager
1507   application.SendNotification();
1508   application.Render(0);
1509
1510   // no message to release scene object in this scenario
1511
1512   END_TEST;
1513 }
1514
1515 int UtcDaliHandleWeightNew2(void)
1516 {
1517   TestApplication application;
1518
1519   // scope for the weight object
1520   {
1521     Handle handle = WeightObject::New();
1522     DALI_TEST_CHECK(handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f);
1523
1524     // process the message so scene object is added to update manager
1525     application.SendNotification();
1526     application.Render(0);
1527   }
1528   // handle out of scope so object gets destroyed
1529   // process the message so update manager destroys the scene object
1530   application.SendNotification();
1531   application.Render(0);
1532
1533   END_TEST;
1534 }
1535
1536 int UtcDaliHandleSetTypeInfo(void)
1537 {
1538   TestApplication application;
1539   TypeRegistry    typeRegistry = TypeRegistry::Get();
1540
1541   TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
1542   DALI_TEST_CHECK(typeInfo);
1543
1544   Actor actor = Actor::DownCast(typeInfo.CreateInstance());
1545   DALI_TEST_CHECK(actor);
1546
1547   DevelHandle::SetTypeInfo(actor, typeInfo);
1548
1549   TypeInfo newTypeInfo;
1550   bool     success = actor.GetTypeInfo(newTypeInfo);
1551   DALI_TEST_CHECK(success);
1552
1553   DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
1554   DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
1555
1556   END_TEST;
1557 }
1558
1559 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
1560 {
1561   TestApplication application;
1562
1563   tet_infoline("Create a custom property and set the value ensuring it can be retrieved synchronously");
1564
1565   Actor actor = Actor::New();
1566   application.GetScene().Add(actor);
1567
1568   tet_infoline("Create the custom property with an initial value");
1569   float           startValue(1.0f);
1570   Property::Index index = actor.RegisterProperty("testProperty", startValue);
1571   DALI_TEST_EQUALS(actor.GetProperty<float>(index), startValue, TEST_LOCATION);
1572
1573   tet_infoline("Set the value, retrieve it and ensure both the synchronous and the async version work");
1574   actor.SetProperty(index, 5.0f);
1575   DALI_TEST_EQUALS(actor.GetProperty<float>(index), 5.0f, TEST_LOCATION);
1576   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), startValue, TEST_LOCATION);
1577
1578   tet_infoline("Render and retrieve values again");
1579   application.SendNotification();
1580   application.Render(0);
1581
1582   DALI_TEST_EQUALS(actor.GetProperty<float>(index), 5.0f, TEST_LOCATION);
1583   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 5.0f, TEST_LOCATION);
1584
1585   END_TEST;
1586 }
1587
1588 int UtcDaliHandleCustomPropertyGetType(void)
1589 {
1590   TestApplication application;
1591
1592   tet_infoline("Create a custom property and retrieve its type");
1593
1594   Handle          handle = Handle::New();
1595   Property::Index index  = handle.RegisterProperty("testProperty", 1.0f);
1596   DALI_TEST_EQUALS(handle.GetPropertyType(index), Property::FLOAT, TEST_LOCATION);
1597
1598   END_TEST;
1599 }
1600
1601 int UtcDaliHandleCustomPropertyAccessMode(void)
1602 {
1603   TestApplication application;
1604
1605   tet_infoline("Create a custom property and retrieve whether it's animatable etc.");
1606
1607   Handle          handle = Handle::New();
1608   Property::Index index  = handle.RegisterProperty("testProperty", 1.0f);
1609   DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), true, TEST_LOCATION);
1610   DALI_TEST_EQUALS(handle.IsPropertyWritable(index), true, TEST_LOCATION);
1611
1612   index = handle.RegisterProperty("testProperty2", 1.0f, Property::READ_ONLY);
1613   DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), false, TEST_LOCATION);
1614   DALI_TEST_EQUALS(handle.IsPropertyWritable(index), false, TEST_LOCATION);
1615
1616   index = handle.RegisterProperty("testProperty3", 1.0f, Property::READ_WRITE);
1617   DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), false, TEST_LOCATION);
1618   DALI_TEST_EQUALS(handle.IsPropertyWritable(index), true, TEST_LOCATION);
1619
1620   END_TEST;
1621 }
1622
1623 int UtcDaliHandleGetCurrentProperty(void)
1624 {
1625   TestApplication application;
1626
1627   tet_infoline("Get a default and non-animatable custom property using the GetCurrentProperty API");
1628
1629   Actor actor = Actor::New();
1630   application.GetScene().Add(actor);
1631   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
1632
1633   Property::Index index = actor.RegisterProperty("testProperty3", 1.0f, Property::READ_WRITE);
1634   DALI_TEST_EQUALS(actor.GetProperty<float>(index), 1.0f, TEST_LOCATION);
1635   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 1.0f, TEST_LOCATION);
1636
1637   actor.SetProperty(index, 2.0f);
1638   DALI_TEST_EQUALS(actor.GetProperty<float>(index), 2.0f, TEST_LOCATION);
1639   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 2.0f, TEST_LOCATION);
1640
1641   END_TEST;
1642 }
1643
1644 int UtcDaliHandleDoesCustomPropertyExistP1(void)
1645 {
1646   TestApplication application; // Needs type registry
1647
1648   tet_infoline("Test if a registered custom property exists on object");
1649
1650   Actor actor         = Actor::New();
1651   auto  propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1652
1653   DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(propertyIndex), true, TEST_LOCATION);
1654   END_TEST;
1655 }
1656
1657 int UtcDaliHandleDoesCustomPropertyExistN1(void)
1658 {
1659   TestApplication application; // Needs type registry
1660
1661   tet_infoline("Test if a registered custom property does not exist on object");
1662
1663   Actor actor         = Actor::New();
1664   auto  propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1665
1666   DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(propertyIndex + 1), false, TEST_LOCATION);
1667   END_TEST;
1668 }
1669
1670 int UtcDaliHandleDoesCustomPropertyExistN2(void)
1671 {
1672   TestApplication application; // Needs type registry
1673
1674   tet_infoline("Test that a default property does not show as a custom property on object");
1675
1676   Actor actor = Actor::New();
1677   DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(Actor::Property::POSITION), false, TEST_LOCATION);
1678   END_TEST;
1679 }
1680
1681 int UtcDaliHandleDoesCustomPropertyExistN3(void)
1682 {
1683   TestApplication application; // Needs type registry
1684
1685   tet_infoline("Test that a child property does not exist on actor after parenting to container");
1686   TypeRegistry typeRegistry = TypeRegistry::Get();
1687
1688   auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1689
1690   const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1691   const char*           CHILD_PROPERTY_NAME("childProperty");
1692
1693   ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1694
1695   auto container = Test::TestCustomActor::New();
1696   application.GetScene().Add(container);
1697   auto child = Actor::New();
1698   container.Add(child); // Resolve child properties (if any)
1699
1700   DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), false, TEST_LOCATION);
1701   END_TEST;
1702 }
1703
1704 int UtcDaliHandleDoesCustomPropertyExistP2(void)
1705 {
1706   TestApplication application; // Needs type registry
1707
1708   tet_infoline("Test that a child property exists after being set");
1709   TypeRegistry typeRegistry = TypeRegistry::Get();
1710
1711   auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1712
1713   const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1714   const char*           CHILD_PROPERTY_NAME("childProperty");
1715
1716   ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1717
1718   auto container = Test::TestCustomActor::New();
1719   application.GetScene().Add(container);
1720   auto child = Actor::New();
1721   container.Add(child); // Resolve child properties (if any)
1722   child.SetProperty(CHILD_PROPERTY, 2);
1723
1724   DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1725   DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 2, TEST_LOCATION);
1726   END_TEST;
1727 }
1728
1729 int UtcDaliHandleDoesCustomPropertyExistP3(void)
1730 {
1731   TestApplication application; // Needs type registry
1732
1733   tet_infoline("Test that a child property is re-indexed after registration, and that it exists");
1734   TypeRegistry typeRegistry = TypeRegistry::Get();
1735
1736   auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1737
1738   const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1739   const char*           CHILD_PROPERTY_NAME("childProperty");
1740
1741   ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1742
1743   auto container = Test::TestCustomActor::New();
1744   application.GetScene().Add(container);
1745   auto child = Actor::New();
1746   child.RegisterProperty(CHILD_PROPERTY_NAME, Property::Value(3));
1747   container.Add(child); // Resolve child properties (if any)
1748
1749   DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1750   DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 3, TEST_LOCATION);
1751   END_TEST;
1752 }
1753
1754 namespace
1755 {
1756 struct PropertySetSignalCheck
1757 {
1758   PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
1759   : mSignalReceived(signalReceived),
1760     mValue(value)
1761   {
1762   }
1763
1764   void operator()(Handle& handle, Property::Index index, Property::Value value)
1765   {
1766     mSignalReceived = true;
1767     mValue          = value;
1768   }
1769
1770   void Reset()
1771   {
1772     mSignalReceived = false;
1773   }
1774
1775   void CheckSignalReceived()
1776   {
1777     if(!mSignalReceived)
1778     {
1779       tet_printf("Expected Property Set signal was not received\n");
1780       tet_result(TET_FAIL);
1781     }
1782     else
1783     {
1784       tet_result(TET_PASS);
1785     }
1786   }
1787
1788   bool&            mSignalReceived; // owned by individual tests
1789   Property::Value& mValue;
1790 };
1791
1792 } // namespace
1793
1794 int UtcDaliHandlePropertySetSignal01(void)
1795 {
1796   TestApplication application;
1797
1798   bool                   signalReceived(false);
1799   Property::Value        value;
1800   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1801
1802   tet_infoline("Test that setting a default property triggers a signal");
1803
1804   auto actor = Actor::New();
1805   actor.PropertySetSignal().Connect(&application, propertySetCheck);
1806
1807   actor.SetProperty(Actor::Property::POSITION, Vector3::XAXIS);
1808   propertySetCheck.CheckSignalReceived();
1809
1810   END_TEST;
1811 }
1812
1813 int UtcDaliHandlePropertySetSignal02(void)
1814 {
1815   TestApplication application;
1816
1817   bool                   signalReceived(false);
1818   Property::Value        value;
1819   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1820
1821   tet_infoline("Test that setting a custom property triggers a signal");
1822
1823   auto actor = Actor::New();
1824   actor.PropertySetSignal().Connect(&application, propertySetCheck);
1825
1826   auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
1827   actor.SetProperty(propertyIndex, 5.0f);
1828   propertySetCheck.CheckSignalReceived();
1829   DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(5.0f), 0.001f, TEST_LOCATION);
1830
1831   END_TEST;
1832 }
1833
1834 int UtcDaliHandlePropertySetSignal03(void)
1835 {
1836   TestApplication application;
1837   TypeRegistry    typeRegistry = TypeRegistry::Get();
1838
1839   bool                   signalReceived(false);
1840   Property::Value        value;
1841   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1842
1843   tet_infoline("Test that setting a child property triggers a signal");
1844
1845   auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1846
1847   const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1848   const char*           CHILD_PROPERTY_NAME("childProperty");
1849
1850   ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1851
1852   auto container = Test::TestCustomActor::New();
1853   application.GetScene().Add(container);
1854   auto child = Actor::New();
1855   child.RegisterProperty(CHILD_PROPERTY_NAME, Property::Value(3));
1856   child.PropertySetSignal().Connect(&application, propertySetCheck);
1857   container.Add(child); // Resolve child properties (if any)
1858
1859   DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1860   DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 3, TEST_LOCATION);
1861
1862   child.SetProperty(CHILD_PROPERTY, 29);
1863   propertySetCheck.CheckSignalReceived();
1864   DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(29), TEST_LOCATION);
1865   END_TEST;
1866 }
1867
1868 int UtcDaliHandlePropertySetSignal04(void)
1869 {
1870   TestApplication application;
1871   TypeRegistry    typeRegistry = TypeRegistry::Get();
1872
1873   bool                   signalReceived(false);
1874   Property::Value        value;
1875   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1876
1877   tet_infoline("Test that setting a property on a vanilla Object triggers a signal");
1878
1879   constexpr Property::Index TEST_PROPERTY_KEY_INDEX = 1;
1880   const std::string         TEST_PROPERTY_KEY_NAME  = "testProperty";
1881
1882   Handle vanillaObject = Handle::New();
1883   auto   propertyIndex = vanillaObject.RegisterProperty(
1884     TEST_PROPERTY_KEY_INDEX,
1885     TEST_PROPERTY_KEY_NAME,
1886     Color::WHITE);
1887
1888   vanillaObject.PropertySetSignal().Connect(&application, propertySetCheck);
1889
1890   DALI_TEST_EQUALS(vanillaObject.DoesCustomPropertyExist(propertyIndex), true, TEST_LOCATION);
1891   DALI_TEST_EQUALS(vanillaObject.GetProperty<Vector4>(propertyIndex), Color::WHITE, 0.001f, TEST_LOCATION);
1892
1893   vanillaObject[TEST_PROPERTY_KEY_NAME] = Color::RED;
1894
1895   propertySetCheck.CheckSignalReceived();
1896   DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(Color::RED), 0.001f, TEST_LOCATION);
1897   DALI_TEST_VALUE_EQUALS(vanillaObject[propertyIndex], Property::Value(Color::RED), 0.001f, TEST_LOCATION);
1898
1899   END_TEST;
1900 }
1901
1902 int UtcDaliHandlePropertySetProperties(void)
1903 {
1904   TestApplication application;
1905   const Vector3   actorSize(10.0f, 20.0f, 30.0f);
1906   const Vector3   anchorPoint(1.0f, 0.5f, 0.0f);
1907   const Vector4   color(0.1f, 0.2, 0.3f, 0.4f);
1908
1909   Handle handle = Actor::New();
1910   handle.SetProperties(
1911     Property::Map{
1912       {Actor::Property::SIZE, actorSize},
1913       {Actor::Property::ANCHOR_POINT, anchorPoint},
1914       {"color", color},
1915       {"invalid", Vector2::ZERO} // It should quietly ignore invalid data
1916     });
1917   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SIZE).Get<Vector3>(), actorSize, TEST_LOCATION);
1918   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>(), anchorPoint, TEST_LOCATION);
1919   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR).Get<Vector4>(), color, TEST_LOCATION);
1920
1921   END_TEST;
1922 }
1923
1924 int UtcDaliHandleTemplateNew01(void)
1925 {
1926   TestApplication application;
1927   const Vector3   actorSize(10.0f, 20.0f, 30.0f);
1928   const Vector3   anchorPoint(1.0f, 0.5f, 0.0f);
1929   const Vector4   color(0.1f, 0.2, 0.3f, 0.4f);
1930
1931   Handle handle = Handle::New<Actor>(
1932     Property::Map{
1933       {Actor::Property::SIZE, actorSize},
1934       {Actor::Property::ANCHOR_POINT, anchorPoint},
1935       {"color", color},
1936       {"invalid", Vector2::ZERO} // It should quietly ignore invalid data
1937     });
1938
1939   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SIZE).Get<Vector3>(), actorSize, TEST_LOCATION);
1940   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>(), anchorPoint, TEST_LOCATION);
1941   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR).Get<Vector4>(), color, TEST_LOCATION);
1942
1943   END_TEST;
1944 }
1945
1946 int UtcDaliHandleGetProperties(void)
1947 {
1948   TestApplication application;
1949
1950   Handle handle = Actor::New();
1951   handle.SetProperties(
1952     Property::Map{
1953       {Actor::Property::SIZE, Vector3(400.0f, 200.0f, 100.0f)},
1954       {Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER},
1955       {Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER},
1956       {Actor::Property::NAME, "Actor"},
1957       {Actor::Property::LEAVE_REQUIRED, true},
1958       {"color", Color::RED},
1959     });
1960
1961   Property::Map map;
1962   handle.GetProperties(map);
1963
1964   // Get all the properties and ensure they match
1965
1966   DALI_TEST_EQUALS(handle.GetPropertyCount(), map.Count(), TEST_LOCATION);
1967
1968   for(auto position = 0u; position < map.Count(); ++position)
1969   {
1970     auto        keyValuePair = map.GetKeyValue(position);
1971     const auto& index        = keyValuePair.first.indexKey;
1972     const auto& value        = keyValuePair.second;
1973     auto        handleValue  = handle.GetProperty(index);
1974
1975     switch(value.GetType())
1976     {
1977       case Property::NONE:
1978         break;
1979       case Property::BOOLEAN:
1980         DALI_TEST_EQUALS(value.Get<bool>(), handleValue.Get<bool>(), TEST_LOCATION);
1981         break;
1982       case Property::FLOAT:
1983         DALI_TEST_EQUALS(value.Get<float>(), handleValue.Get<float>(), TEST_LOCATION);
1984         break;
1985       case Property::INTEGER:
1986         DALI_TEST_EQUALS(value.Get<int>(), handleValue.Get<int>(), TEST_LOCATION);
1987         break;
1988       case Property::VECTOR2:
1989         DALI_TEST_EQUALS(value.Get<Vector2>(), handleValue.Get<Vector2>(), TEST_LOCATION);
1990         break;
1991       case Property::VECTOR3:
1992         DALI_TEST_EQUALS(value.Get<Vector3>(), handleValue.Get<Vector3>(), TEST_LOCATION);
1993         break;
1994       case Property::VECTOR4:
1995         DALI_TEST_EQUALS(value.Get<Vector4>(), handleValue.Get<Vector4>(), TEST_LOCATION);
1996         break;
1997       case Property::MATRIX3:
1998         DALI_TEST_EQUALS(value.Get<Matrix3>(), handleValue.Get<Matrix3>(), TEST_LOCATION);
1999         break;
2000       case Property::MATRIX:
2001         DALI_TEST_EQUALS(value.Get<Matrix>(), handleValue.Get<Matrix>(), TEST_LOCATION);
2002         break;
2003       case Property::RECTANGLE:
2004         DALI_TEST_EQUALS(value.Get<Rect<int> >(), handleValue.Get<Rect<int> >(), TEST_LOCATION);
2005         break;
2006       case Property::ROTATION:
2007         DALI_TEST_EQUALS(value.Get<Quaternion>(), handleValue.Get<Quaternion>(), TEST_LOCATION);
2008         break;
2009       case Property::STRING:
2010         DALI_TEST_EQUALS(value.Get<std::string>(), handleValue.Get<std::string>(), TEST_LOCATION);
2011         break;
2012       case Property::ARRAY:
2013         DALI_TEST_EQUALS(value.GetArray()->Count(), handleValue.GetArray()->Count(), TEST_LOCATION);
2014         break;
2015       case Property::MAP:
2016         DALI_TEST_EQUALS(value.GetMap()->Count(), handleValue.GetMap()->Count(), TEST_LOCATION);
2017         break;
2018       case Property::EXTENTS:
2019         DALI_TEST_EQUALS(value.Get<Extents>(), handleValue.Get<Extents>(), TEST_LOCATION);
2020         break;
2021     }
2022   }
2023
2024   // Add a custom property and ensure the count goes up by one.
2025   const auto countBefore = map.Count();
2026   handle.RegisterProperty("tempProperty", Color::GREEN);
2027   handle.GetProperties(map);
2028   DALI_TEST_EQUALS(countBefore + 1, map.Count(), TEST_LOCATION);
2029
2030   END_TEST;
2031 }
2032
2033 int UtcDaliHandleReserveProperties(void)
2034 {
2035   TestApplication application;
2036   Dali::Handle    instance = Handle::New();
2037   DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
2038
2039   instance.ReserveCustomProperties(0);
2040   DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
2041
2042   instance.ReserveCustomProperties(20);
2043   DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
2044
2045   instance.RegisterProperty("testProperty", 22.0f);
2046   DALI_TEST_EQUALS(instance.GetPropertyCount(), 1, TEST_LOCATION);
2047
2048   // Test that reserving actor properties doesn't change property count
2049   Dali::Actor actor = Actor::New();
2050   auto        count = actor.GetPropertyCount();
2051
2052   actor.ReserveCustomProperties(15);
2053   DALI_TEST_EQUALS(actor.GetPropertyCount(), count, TEST_LOCATION);
2054
2055   // Test that reserving renderer properties doesn't change property count
2056   Geometry       geom     = Geometry::New();
2057   Shader         shader   = Shader::New("vertex", "frag");
2058   Dali::Renderer renderer = Renderer::New(geom, shader);
2059   count                   = renderer.GetPropertyCount();
2060   renderer.ReserveCustomProperties(22);
2061   DALI_TEST_EQUALS(renderer.GetPropertyCount(), count, TEST_LOCATION);
2062
2063   count = shader.GetPropertyCount();
2064   shader.ReserveCustomProperties(5);
2065   DALI_TEST_EQUALS(shader.GetPropertyCount(), count, TEST_LOCATION);
2066
2067   application.SendNotification();
2068   application.Render();
2069
2070   END_TEST;
2071 }
2072
2073 int UtcDaliHandleSetPropertyNegative(void)
2074 {
2075   TestApplication application;
2076   Dali::Handle    instance;
2077   try
2078   {
2079     int                   arg1(0);
2080     Dali::Property::Value arg2;
2081     instance.SetProperty(arg1, arg2);
2082     DALI_TEST_CHECK(false); // Should not get here
2083   }
2084   catch(...)
2085   {
2086     DALI_TEST_CHECK(true); // We expect an assert
2087   }
2088   END_TEST;
2089 }
2090
2091 int UtcDaliHandleRegisterPropertyNegative01(void)
2092 {
2093   TestApplication application;
2094   Dali::Handle    instance;
2095   try
2096   {
2097     std::string           arg1;
2098     Dali::Property::Value arg2;
2099     instance.RegisterProperty(arg1, arg2);
2100     DALI_TEST_CHECK(false); // Should not get here
2101   }
2102   catch(...)
2103   {
2104     DALI_TEST_CHECK(true); // We expect an assert
2105   }
2106   END_TEST;
2107 }
2108
2109 int UtcDaliHandleRegisterPropertyNegative02(void)
2110 {
2111   TestApplication application;
2112   Dali::Handle    instance;
2113   try
2114   {
2115     std::string                arg1;
2116     Dali::Property::Value      arg2;
2117     Dali::Property::AccessMode arg3(Property::READ_ONLY);
2118     instance.RegisterProperty(arg1, arg2, arg3);
2119     DALI_TEST_CHECK(false); // Should not get here
2120   }
2121   catch(...)
2122   {
2123     DALI_TEST_CHECK(true); // We expect an assert
2124   }
2125   END_TEST;
2126 }
2127
2128 int UtcDaliHandleRemoveConstraintsNegative01(void)
2129 {
2130   TestApplication application;
2131   Dali::Handle    instance;
2132   try
2133   {
2134     unsigned int arg1(0u);
2135     instance.RemoveConstraints(arg1);
2136     DALI_TEST_CHECK(false); // Should not get here
2137   }
2138   catch(...)
2139   {
2140     DALI_TEST_CHECK(true); // We expect an assert
2141   }
2142   END_TEST;
2143 }
2144
2145 int UtcDaliHandleRemoveConstraintsNegative02(void)
2146 {
2147   TestApplication application;
2148   Dali::Handle    instance;
2149   try
2150   {
2151     instance.RemoveConstraints();
2152     DALI_TEST_CHECK(false); // Should not get here
2153   }
2154   catch(...)
2155   {
2156     DALI_TEST_CHECK(true); // We expect an assert
2157   }
2158   END_TEST;
2159 }
2160
2161 int UtcDaliHandleAddPropertyNotificationNegative01(void)
2162 {
2163   TestApplication application;
2164   Dali::Handle    instance;
2165   try
2166   {
2167     int                     arg1(0);
2168     int                     arg2(0);
2169     Dali::PropertyCondition arg3;
2170     instance.AddPropertyNotification(arg1, arg2, arg3);
2171     DALI_TEST_CHECK(false); // Should not get here
2172   }
2173   catch(...)
2174   {
2175     DALI_TEST_CHECK(true); // We expect an assert
2176   }
2177   END_TEST;
2178 }
2179
2180 int UtcDaliHandleAddPropertyNotificationNegative02(void)
2181 {
2182   TestApplication application;
2183   Dali::Handle    instance;
2184   try
2185   {
2186     int                     arg1(0);
2187     Dali::PropertyCondition arg2;
2188     instance.AddPropertyNotification(arg1, arg2);
2189     DALI_TEST_CHECK(false); // Should not get here
2190   }
2191   catch(...)
2192   {
2193     DALI_TEST_CHECK(true); // We expect an assert
2194   }
2195   END_TEST;
2196 }
2197
2198 int UtcDaliHandleRemovePropertyNotificationNegative(void)
2199 {
2200   TestApplication application;
2201   Dali::Handle    instance;
2202   try
2203   {
2204     Dali::PropertyNotification arg1;
2205     instance.RemovePropertyNotification(arg1);
2206     DALI_TEST_CHECK(false); // Should not get here
2207   }
2208   catch(...)
2209   {
2210     DALI_TEST_CHECK(true); // We expect an assert
2211   }
2212   END_TEST;
2213 }
2214
2215 int UtcDaliHandleRemovePropertyNotificationsNegative(void)
2216 {
2217   TestApplication application;
2218   Dali::Handle    instance;
2219   try
2220   {
2221     instance.RemovePropertyNotifications();
2222     DALI_TEST_CHECK(false); // Should not get here
2223   }
2224   catch(...)
2225   {
2226     DALI_TEST_CHECK(true); // We expect an assert
2227   }
2228   END_TEST;
2229 }
2230
2231 int UtcDaliHandleGetPropertyNegative(void)
2232 {
2233   TestApplication application;
2234   Dali::Handle    instance;
2235   try
2236   {
2237     int arg1(0);
2238     instance.GetProperty(arg1);
2239     DALI_TEST_CHECK(false); // Should not get here
2240   }
2241   catch(...)
2242   {
2243     DALI_TEST_CHECK(true); // We expect an assert
2244   }
2245   END_TEST;
2246 }
2247
2248 int UtcDaliHandleGetPropertyNameNegative(void)
2249 {
2250   TestApplication application;
2251   Dali::Handle    instance;
2252   try
2253   {
2254     int arg1(0);
2255     instance.GetPropertyName(arg1);
2256     DALI_TEST_CHECK(false); // Should not get here
2257   }
2258   catch(...)
2259   {
2260     DALI_TEST_CHECK(true); // We expect an assert
2261   }
2262   END_TEST;
2263 }
2264
2265 int UtcDaliHandleGetPropertyTypeNegative(void)
2266 {
2267   TestApplication application;
2268   Dali::Handle    instance;
2269   try
2270   {
2271     int arg1(0);
2272     instance.GetPropertyType(arg1);
2273     DALI_TEST_CHECK(false); // Should not get here
2274   }
2275   catch(...)
2276   {
2277     DALI_TEST_CHECK(true); // We expect an assert
2278   }
2279   END_TEST;
2280 }
2281
2282 int UtcDaliHandleGetPropertyCountNegative(void)
2283 {
2284   TestApplication application;
2285   Dali::Handle    instance;
2286   try
2287   {
2288     instance.GetPropertyCount();
2289     DALI_TEST_CHECK(false); // Should not get here
2290   }
2291   catch(...)
2292   {
2293     DALI_TEST_CHECK(true); // We expect an assert
2294   }
2295   END_TEST;
2296 }
2297
2298 int UtcDaliHandleGetPropertyIndexNegative(void)
2299 {
2300   TestApplication application;
2301   Dali::Handle    instance;
2302   try
2303   {
2304     std::string arg1;
2305     instance.GetPropertyIndex(arg1);
2306     DALI_TEST_CHECK(false); // Should not get here
2307   }
2308   catch(...)
2309   {
2310     DALI_TEST_CHECK(true); // We expect an assert
2311   }
2312   END_TEST;
2313 }
2314
2315 int UtcDaliHandleGetCurrentPropertyNegative(void)
2316 {
2317   TestApplication application;
2318   Dali::Handle    instance;
2319   try
2320   {
2321     int arg1(0);
2322     instance.GetCurrentProperty(arg1);
2323     DALI_TEST_CHECK(false); // Should not get here
2324   }
2325   catch(...)
2326   {
2327     DALI_TEST_CHECK(true); // We expect an assert
2328   }
2329   END_TEST;
2330 }
2331
2332 int UtcDaliHandleGetPropertyIndicesNegative(void)
2333 {
2334   TestApplication application;
2335   Dali::Handle    instance;
2336   try
2337   {
2338     Dali::Vector<int> arg1;
2339     instance.GetPropertyIndices(arg1);
2340     DALI_TEST_CHECK(false); // Should not get here
2341   }
2342   catch(...)
2343   {
2344     DALI_TEST_CHECK(true); // We expect an assert
2345   }
2346   END_TEST;
2347 }
2348
2349 int UtcDaliHandleIsPropertyWritableNegative(void)
2350 {
2351   TestApplication application;
2352   Dali::Handle    instance;
2353   try
2354   {
2355     int arg1(0);
2356     instance.IsPropertyWritable(arg1);
2357     DALI_TEST_CHECK(false); // Should not get here
2358   }
2359   catch(...)
2360   {
2361     DALI_TEST_CHECK(true); // We expect an assert
2362   }
2363   END_TEST;
2364 }
2365
2366 int UtcDaliHandleIsPropertyAnimatableNegative(void)
2367 {
2368   TestApplication application;
2369   Dali::Handle    instance;
2370   try
2371   {
2372     int arg1(0);
2373     instance.IsPropertyAnimatable(arg1);
2374     DALI_TEST_CHECK(false); // Should not get here
2375   }
2376   catch(...)
2377   {
2378     DALI_TEST_CHECK(true); // We expect an assert
2379   }
2380   END_TEST;
2381 }
2382
2383 int UtcDaliHandleIsPropertyAConstraintInputNegative(void)
2384 {
2385   TestApplication application;
2386   Dali::Handle    instance;
2387   try
2388   {
2389     int arg1(0);
2390     instance.IsPropertyAConstraintInput(arg1);
2391     DALI_TEST_CHECK(false); // Should not get here
2392   }
2393   catch(...)
2394   {
2395     DALI_TEST_CHECK(true); // We expect an assert
2396   }
2397   END_TEST;
2398 }
2399
2400 int UtcDaliHandleSupportsNegative(void)
2401 {
2402   TestApplication application;
2403   Dali::Handle    instance;
2404   try
2405   {
2406     Dali::Handle::Capability arg1(Handle::DYNAMIC_PROPERTIES);
2407     instance.Supports(arg1);
2408     DALI_TEST_CHECK(false); // Should not get here
2409   }
2410   catch(...)
2411   {
2412     DALI_TEST_CHECK(true); // We expect an assert
2413   }
2414   END_TEST;
2415 }
2416
2417 int UtcDaliHandleIndexOperatorByIndexP01(void)
2418 {
2419   TestApplication application;
2420   Actor           actor = Actor::New();
2421
2422   actor[Actor::Property::SIZE] = Vector3(100.0f, 200.0f, 1.0f);
2423
2424   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(100.0f, 200.0f, 1.0f), 0.001f, TEST_LOCATION);
2425
2426   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2427
2428   Vector3 position = actor[Actor::Property::POSITION];
2429   DALI_TEST_EQUALS(position, Vector3(10.0f, 20.0f, 0.0f), TEST_LOCATION);
2430
2431   END_TEST;
2432 }
2433
2434 int UtcDaliHandleIndexOperatorByIndexP02(void)
2435 {
2436   TestApplication application;
2437   Actor           actor = Actor::New();
2438
2439   const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2440   actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2441   actor[Actor::Property::COLOR_RED] = 0.5f;
2442
2443   DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.001f, TEST_LOCATION);
2444   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(Actor::Property::COLOR), Vector4(0.5f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
2445
2446   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2447
2448   DALI_TEST_EQUALS((float)actor[Actor::Property::POSITION_Z], 0.0f, 0.001f, TEST_LOCATION);
2449
2450   END_TEST;
2451 }
2452
2453 int UtcDaliHandleIndexOperatorByIndexP03(void)
2454 {
2455   TestApplication application;
2456   Actor           actor = Actor::New();
2457
2458   const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2459   actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2460
2461   // Value under test is second to allow compiler to deduce type
2462   DALI_TEST_VALUE_EQUALS(actor[Actor::Property::COLOR_RED], 1.0f, 0.001f, TEST_LOCATION);
2463
2464   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2465
2466   DALI_TEST_EQUALS((float)actor[Actor::Property::POSITION_Z], 0.0f, 0.001f, TEST_LOCATION);
2467
2468   END_TEST;
2469 }
2470
2471 int UtcDaliHandleIndexOperatorByNameP01(void)
2472 {
2473   TestApplication application;
2474   Actor           actor = Actor::New();
2475
2476   actor["size"] = Vector3(100.0f, 200.0f, 1.0f);
2477
2478   DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::SIZE), Vector3(100.0f, 200.0f, 1.0f), 0.001f, TEST_LOCATION);
2479
2480   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2481   Vector3 position = actor["position"];
2482
2483   DALI_TEST_EQUALS(position, Vector3(10.0f, 20.0f, 0.0f), 0.001f, TEST_LOCATION);
2484
2485   END_TEST;
2486 }
2487
2488 int UtcDaliHandleIndexOperatorByNameP02(void)
2489 {
2490   TestApplication application;
2491   Actor           actor = Actor::New();
2492
2493   const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2494   actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2495   actor["colorRed"] = 0.5f;
2496
2497   DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::COLOR_RED), 0.5f, 0.001f, TEST_LOCATION);
2498   DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::COLOR), Vector4(0.5f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
2499
2500   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2501
2502   float positionY = actor["positionY"];
2503   DALI_TEST_EQUALS(positionY, 20.0f, 0.001f, TEST_LOCATION);
2504
2505   // Should automatically promote IndirectValue to Property::Value rvalue.
2506   DALI_TEST_VALUE_EQUALS(actor["positionZ"], 0.0f, 0.001f, TEST_LOCATION);
2507
2508   END_TEST;
2509 }
2510
2511 int UtcDaliHandleIndexOperatorNegative02(void)
2512 {
2513   TestApplication application;
2514
2515   Actor actor;
2516   try
2517   {
2518     Vector3 position = actor[Actor::Property::POSITION];
2519     if(position == position)
2520     {
2521       DALI_TEST_CHECK(false); // Should throw before reaching here.
2522     }
2523     DALI_TEST_CHECK(false); // Should throw before reaching here.
2524   }
2525   catch(...)
2526   {
2527     DALI_TEST_CHECK(true); // Assert expected
2528   }
2529
2530   END_TEST;
2531 }