Refactored more code into Actor::Relayouter
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Handle.cpp
1 /*
2  * Copyright (c) 2020 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 UtcDaliHandleGetProperty(void)
776 {
777   tet_infoline("Positive Test Dali::Handle::GetProperty()");
778   TestApplication application;
779
780   Actor actor = Actor::New();
781
782   DALI_TEST_CHECK(ParentOrigin::TOP_LEFT == actor.GetProperty(Actor::Property::PARENT_ORIGIN).Get<Vector3>());
783   DALI_TEST_CHECK(AnchorPoint::CENTER == actor.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>());
784   DALI_TEST_CHECK(Vector3::ZERO == actor.GetProperty(Actor::Property::SIZE).Get<Vector3>());
785   DALI_TEST_CHECK(Vector3::ZERO == actor.GetProperty(Actor::Property::POSITION).Get<Vector3>());
786   DALI_TEST_CHECK(Vector3::ONE == actor.GetProperty(Actor::Property::SCALE).Get<Vector3>());
787   DALI_TEST_CHECK(true == actor.GetProperty(Actor::Property::VISIBLE).Get<bool>());
788   DALI_TEST_CHECK(Color::WHITE == actor.GetProperty(Actor::Property::COLOR).Get<Vector4>());
789   END_TEST;
790 }
791
792 int UtcDaliHandleDownCast(void)
793 {
794   TestApplication application;
795   tet_infoline("Testing Dali::Handle::DownCast()");
796
797   Actor actor = Actor::New();
798
799   BaseHandle baseHandle = actor;
800
801   Handle handle = Handle::DownCast(baseHandle);
802
803   DALI_TEST_CHECK(handle);
804
805   baseHandle = BaseHandle();
806
807   handle = Handle::DownCast(baseHandle);
808
809   DALI_TEST_CHECK(!handle);
810
811   END_TEST;
812 }
813
814 int UtcDaliHandleDownCastNegative(void)
815 {
816   TestApplication application;
817
818   // BaseObject is NOT an Object, so this DownCast should fail
819   BaseHandle handle(new BaseObjectType);
820   Handle     customHandle1 = Handle::DownCast(handle);
821   DALI_TEST_CHECK(!customHandle1);
822
823   // A DownCast on an empty handle will also fail
824   Handle empty;
825   Handle customHandle2 = Handle::DownCast(empty);
826   DALI_TEST_CHECK(!customHandle2);
827   END_TEST;
828 }
829
830 int UtcDaliHandleGetPropertyIndices(void)
831 {
832   TestApplication          application;
833   Property::IndexContainer indices;
834
835   // Actor
836   Actor actor = Actor::New();
837   actor.GetPropertyIndices(indices);
838   int numDefaultProperties = indices.Size();
839   DALI_TEST_CHECK(numDefaultProperties > 0);
840   DALI_TEST_EQUALS(numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION);
841
842   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
843   const float   withFlake(99.f);
844
845   Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
846   Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
847
848   actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
849   actor.RegisterProperty(key1, "sideColor", testColor);
850   actor.RegisterProperty("MyPropertyTwo", 1234);
851   Property::Index index4 = actor.RegisterProperty(key2, "iceCream", withFlake);
852   actor.RegisterProperty("MyPropertyThree", Vector2(.2f, .7f));
853
854   actor.GetPropertyIndices(indices);
855
856   DALI_TEST_EQUALS(indices.Size(), numDefaultProperties + 5, TEST_LOCATION);
857   DALI_TEST_EQUALS(indices[indices.Size() - 2], index4, TEST_LOCATION);
858
859   END_TEST;
860 }
861
862 int UtcDaliHandleRegisterPropertyTypes(void)
863 {
864   TestApplication application;
865
866   struct PropertyTypeAnimatable
867   {
868     const char*     name;
869     Property::Value value;
870     bool            animatable;
871   };
872
873   Property::Array array;
874   Property::Map   map;
875
876   PropertyTypeAnimatable properties[] =
877     {
878       {"Property::BOOLEAN", true, true},
879       {"Property::FLOAT", 1.0f, true},
880       {"Property::INTEGER", 1, true},
881       {"Property::VECTOR2", Vector2::ONE, true},
882       {"Property::VECTOR3", Vector3::ONE, true},
883       {"Property::VECTOR4", Vector4::ONE, true},
884       {"Property::MATRIX3", Matrix3::IDENTITY, true},
885       {"Property::MATRIX", Matrix::IDENTITY, true},
886       {"Property::RECTANGLE", Rect<int>(), false},
887       {"Property::ROTATION", AngleAxis(), true},
888       {"Property::STRING", std::string("Me"), false},
889       {"Property::ARRAY", array, false},
890       {"Property::MAP", map, false},
891     };
892
893   unsigned int numOfProperties(sizeof(properties) / sizeof(properties[0]));
894
895   for(unsigned int i = 0; i < numOfProperties; ++i)
896   {
897     tet_printf("Testing: %s\n", properties[i].name);
898
899     bool exception = false;
900     try
901     {
902       Actor actor = Actor::New();
903       actor.RegisterProperty("manFromDelmonte", properties[i].value);
904     }
905     catch(Dali::DaliException& e)
906     {
907       exception = true;
908     }
909
910     DALI_TEST_CHECK(properties[i].animatable != exception);
911   }
912   END_TEST;
913 }
914
915 int UtcDaliHandleCustomProperty(void)
916 {
917   TestApplication application;
918
919   Handle handle = Handle::New();
920
921   float           startValue(1.0f);
922   Property::Index index = handle.RegisterProperty("testProperty", startValue);
923   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
924
925   application.SendNotification();
926   application.Render(0);
927   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
928   application.Render(0);
929   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
930
931   handle.SetProperty(index, 5.0f);
932
933   application.SendNotification();
934   application.Render(0);
935   DALI_TEST_CHECK(handle.GetProperty<float>(index) == 5.0f);
936   application.Render(0);
937   DALI_TEST_CHECK(handle.GetProperty<float>(index) == 5.0f);
938   END_TEST;
939 }
940
941 int UtcDaliHandleCustomPropertyNone(void)
942 {
943   TestApplication application;
944
945   Handle handle = Handle::New();
946
947   Property::Value value(Property::NONE);
948   Property::Index index = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
949
950   // Negative test i.e. setting a property of type NONE is meaningless
951   handle.SetProperty(index, 5.0f);
952
953   DALI_TEST_CHECK(true); // got here without crashing
954
955   END_TEST;
956 }
957
958 int UtcDaliHandleCustomPropertyIntToFloat(void)
959 {
960   TestApplication application;
961
962   Handle handle = Handle::New();
963
964   float           startValue(5.0f);
965   Property::Index index = handle.RegisterProperty("testProperty", startValue);
966   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
967
968   application.SendNotification();
969   application.Render(0);
970   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
971
972   handle.SetProperty(index, int(1));
973
974   application.SendNotification();
975   application.Render(0);
976   DALI_TEST_CHECK(handle.GetProperty<float>(index) == 1.0f);
977   END_TEST;
978 }
979
980 int UtcDaliHandleCustomPropertyFloatToInt(void)
981 {
982   TestApplication application;
983
984   Handle handle = Handle::New();
985
986   int             startValue(5);
987   Property::Index index = handle.RegisterProperty("testProperty", startValue);
988   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
989
990   application.SendNotification();
991   application.Render(0);
992   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
993
994   handle.SetProperty(index, float(1.5));
995
996   application.SendNotification();
997   application.Render(0);
998   DALI_TEST_CHECK(handle.GetProperty<int>(index) == 1);
999   END_TEST;
1000 }
1001
1002 int UtcDaliHandleCustomPropertyInvalidToRect(void)
1003 {
1004   TestApplication application;
1005
1006   Handle handle = Handle::New();
1007
1008   Rect<int>       startValue(1, 2, 3, 4);
1009   Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1010   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1011
1012   application.SendNotification();
1013   application.Render(0);
1014   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1015
1016   // Negative test i.e. there is no conversion from float to Rect
1017   handle.SetProperty(index, float(1.5));
1018
1019   application.SendNotification();
1020   application.Render(0);
1021   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1022
1023   // Positive test (sanity check)
1024   Rect<int> endValue(5, 6, 7, 8);
1025   handle.SetProperty(index, endValue);
1026   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), endValue, TEST_LOCATION);
1027
1028   application.SendNotification();
1029   application.Render(0);
1030   DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), endValue, TEST_LOCATION);
1031
1032   END_TEST;
1033 }
1034
1035 int UtcDaliHandleCustomPropertyInvalidToString(void)
1036 {
1037   TestApplication application;
1038
1039   Handle handle = Handle::New();
1040
1041   std::string     startValue("Libraries gave us power");
1042   Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1043   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1044
1045   application.SendNotification();
1046   application.Render(0);
1047   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1048
1049   // No conversion from Vector3 to std::string, therefore this should be a NOOP
1050   handle.SetProperty(index, Vector3(1, 2, 3));
1051
1052   application.SendNotification();
1053   application.Render(0);
1054   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1055
1056   // Positive test (sanity check)
1057   std::string endValue("Then work came and made us free");
1058   handle.SetProperty(index, endValue);
1059   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), endValue, TEST_LOCATION);
1060
1061   application.SendNotification();
1062   application.Render(0);
1063   DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), endValue, TEST_LOCATION);
1064
1065   END_TEST;
1066 }
1067
1068 int UtcDaliHandleCustomPropertyInvalidToArray(void)
1069 {
1070   TestApplication application;
1071
1072   Handle handle = Handle::New();
1073
1074   Property::Value value(Property::ARRAY);
1075   std::string     startValue("The future teaches you to be alone");
1076   value.GetArray()->PushBack(startValue);
1077
1078   Property::Index index  = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1079   Property::Array check1 = handle.GetProperty<Property::Array>(index);
1080   DALI_TEST_EQUALS(check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1081
1082   application.SendNotification();
1083   application.Render(0);
1084   Property::Array check2 = handle.GetProperty<Property::Array>(index);
1085   DALI_TEST_EQUALS(check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1086
1087   // No conversion from int to ARRAY, therefore this should be a NOOP
1088   handle.SetProperty(index, int(2));
1089
1090   application.SendNotification();
1091   application.Render(0);
1092   Property::Array check3 = handle.GetProperty<Property::Array>(index);
1093   DALI_TEST_EQUALS(check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1094
1095   // Positive test (sanity check)
1096   Property::Value value2(Property::ARRAY);
1097   std::string     endValue("The present to be afraid and cold");
1098   value2.GetArray()->PushBack(endValue);
1099   handle.SetProperty(index, value2);
1100
1101   Property::Array check4 = handle.GetProperty<Property::Array>(index);
1102   DALI_TEST_EQUALS(check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION);
1103
1104   application.SendNotification();
1105   application.Render(0);
1106   Property::Array check5 = handle.GetProperty<Property::Array>(index);
1107   DALI_TEST_EQUALS(check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION);
1108
1109   END_TEST;
1110 }
1111
1112 int UtcDaliHandleCustomPropertyInvalidToMap(void)
1113 {
1114   TestApplication application;
1115
1116   Handle handle = Handle::New();
1117
1118   Property::Value value(Property::MAP);
1119   std::string     startValue("Culture sucks down words");
1120   value.GetMap()->Insert("1", startValue);
1121
1122   Property::Index  index  = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1123   Property::Value* check1 = handle.GetProperty<Property::Map>(index).Find("1");
1124   DALI_TEST_CHECK(NULL != check1);
1125
1126   // No conversion from float to MAP, therefore this should be a NOOP
1127   handle.SetProperty(index, float(3.0));
1128
1129   // Positive test (sanity check)
1130   Property::Value value2(Property::MAP);
1131   std::string     endValue("Itemise loathing and feed yourself smiles");
1132   value.GetMap()->Insert("1", endValue);
1133   handle.SetProperty(index, value2);
1134
1135   END_TEST;
1136 }
1137
1138 int UtcDaliHandleCustomPropertyInvalidToExtents(void)
1139 {
1140   TestApplication application;
1141
1142   Handle handle = Handle::New();
1143
1144   Extents         startValue(1, 2, 3, 4);
1145   Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1146   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1147
1148   application.SendNotification();
1149   application.Render(0);
1150   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1151
1152   // Negative test i.e. there is no conversion from float to Extents
1153   handle.SetProperty(index, float(1.5));
1154
1155   application.SendNotification();
1156   application.Render(0);
1157   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1158
1159   // Positive test (sanity check)
1160   Extents endValue(5, 6, 7, 8);
1161   handle.SetProperty(index, endValue);
1162   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), endValue, TEST_LOCATION);
1163
1164   application.SendNotification();
1165   application.Render(0);
1166   DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), endValue, TEST_LOCATION);
1167
1168   END_TEST;
1169 }
1170
1171 int UtcDaliHandleCustomPropertyInvalidToBool(void)
1172 {
1173   TestApplication application;
1174
1175   Handle handle = Handle::New();
1176
1177   bool            startValue(true);
1178   Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1179   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1180
1181   application.SendNotification();
1182   application.Render(0);
1183   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1184
1185   // Negative test i.e. there is no conversion from float to bool
1186   handle.SetProperty(index, float(0.0));
1187
1188   application.SendNotification();
1189   application.Render(0);
1190   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1191
1192   // Positive test (sanity check)
1193   bool endValue(false);
1194   handle.SetProperty(index, endValue);
1195   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), endValue, TEST_LOCATION);
1196
1197   application.SendNotification();
1198   application.Render(0);
1199   DALI_TEST_EQUALS(handle.GetProperty<bool>(index), endValue, TEST_LOCATION);
1200
1201   END_TEST;
1202 }
1203
1204 int UtcDaliHandleCustomPropertyInvalidToInt(void)
1205 {
1206   TestApplication application;
1207
1208   Handle handle = Handle::New();
1209
1210   int             startValue(5);
1211   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1212   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1213
1214   application.SendNotification();
1215   application.Render(0);
1216   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1217
1218   // Negative test i.e. there is no conversion from Vector3 to int
1219   handle.SetProperty(index, Vector3(1, 2, 3));
1220
1221   application.SendNotification();
1222   application.Render(0);
1223   DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1224   END_TEST;
1225 }
1226
1227 int UtcDaliHandleCustomPropertyInvalidToFloat(void)
1228 {
1229   TestApplication application;
1230
1231   Handle handle = Handle::New();
1232
1233   float           startValue(5.0);
1234   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1235   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1236
1237   application.SendNotification();
1238   application.Render(0);
1239   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1240
1241   // Negative test i.e. there is no conversion from Vector3 to float
1242   handle.SetProperty(index, Vector3(1, 2, 3));
1243
1244   application.SendNotification();
1245   application.Render(0);
1246   DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1247   END_TEST;
1248 }
1249
1250 int UtcDaliHandleCustomPropertyInvalidToRotation(void)
1251 {
1252   TestApplication application;
1253
1254   Handle handle = Handle::New();
1255
1256   Quaternion      startValue(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1257   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1258   DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1259
1260   application.SendNotification();
1261   application.Render(0);
1262   DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1263
1264   // Negative test i.e. there is no conversion from float to Quaternion
1265   handle.SetProperty(index, float(7.0));
1266
1267   application.SendNotification();
1268   application.Render(0);
1269   DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1270
1271   // Positive test (sanity check)
1272   Quaternion endValue(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1273   handle.SetProperty(index, endValue);
1274   DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == endValue);
1275
1276   END_TEST;
1277 }
1278
1279 int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
1280 {
1281   TestApplication application;
1282
1283   Handle handle = Handle::New();
1284
1285   Quaternion      rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1286   Matrix          startValue(rotation);
1287   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1288   DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1289
1290   application.SendNotification();
1291   application.Render(0);
1292   DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1293
1294   // Negative test i.e. there is no conversion from float to Matrix
1295   handle.SetProperty(index, float(7.0));
1296
1297   application.SendNotification();
1298   application.Render(0);
1299   DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1300
1301   // Positive test (sanity check)
1302   Quaternion endRotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1303   Matrix     endValue(endRotation);
1304   handle.SetProperty(index, endValue);
1305   DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == endValue);
1306
1307   END_TEST;
1308 }
1309
1310 int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
1311 {
1312   TestApplication application;
1313
1314   Handle handle = Handle::New();
1315
1316   Matrix3 startValue(11, 12, 13, 21, 22, 23, 31, 32, 33);
1317
1318   Property::Index index = handle.RegisterProperty("testProperty", startValue);
1319   DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1320
1321   application.SendNotification();
1322   application.Render(0);
1323   DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1324
1325   // Negative test i.e. there is no conversion from float to Matrix3
1326   handle.SetProperty(index, float(7.0));
1327
1328   application.SendNotification();
1329   application.Render(0);
1330   DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1331
1332   // Positive test (sanity check)
1333   Matrix3 endValue(31, 32, 33, 21, 22, 23, 11, 12, 13);
1334   handle.SetProperty(index, endValue);
1335   DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == endValue);
1336
1337   END_TEST;
1338 }
1339
1340 int UtcDaliHandleWeightNew(void)
1341 {
1342   TestApplication application;
1343
1344   Handle handle = WeightObject::New();
1345   DALI_TEST_CHECK(handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f);
1346
1347   // process the message so scene object is added to update manager
1348   application.SendNotification();
1349   application.Render(0);
1350
1351   // no message to release scene object in this scenario
1352
1353   END_TEST;
1354 }
1355
1356 int UtcDaliHandleWeightNew2(void)
1357 {
1358   TestApplication application;
1359
1360   // scope for the weight object
1361   {
1362     Handle handle = WeightObject::New();
1363     DALI_TEST_CHECK(handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f);
1364
1365     // process the message so scene object is added to update manager
1366     application.SendNotification();
1367     application.Render(0);
1368   }
1369   // handle out of scope so object gets destroyed
1370   // process the message so update manager destroys the scene object
1371   application.SendNotification();
1372   application.Render(0);
1373
1374   END_TEST;
1375 }
1376
1377 int UtcDaliHandleSetTypeInfo(void)
1378 {
1379   TestApplication application;
1380   TypeRegistry    typeRegistry = TypeRegistry::Get();
1381
1382   TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
1383   DALI_TEST_CHECK(typeInfo);
1384
1385   Actor actor = Actor::DownCast(typeInfo.CreateInstance());
1386   DALI_TEST_CHECK(actor);
1387
1388   DevelHandle::SetTypeInfo(actor, typeInfo);
1389
1390   TypeInfo newTypeInfo;
1391   bool     success = actor.GetTypeInfo(newTypeInfo);
1392   DALI_TEST_CHECK(success);
1393
1394   DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
1395   DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
1396
1397   END_TEST;
1398 }
1399
1400 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
1401 {
1402   TestApplication application;
1403
1404   tet_infoline("Create a custom property and set the value ensuring it can be retrieved synchronously");
1405
1406   Actor actor = Actor::New();
1407   application.GetScene().Add(actor);
1408
1409   tet_infoline("Create the custom property with an initial value");
1410   float           startValue(1.0f);
1411   Property::Index index = actor.RegisterProperty("testProperty", startValue);
1412   DALI_TEST_EQUALS(actor.GetProperty<float>(index), startValue, TEST_LOCATION);
1413
1414   tet_infoline("Set the value, retrieve it and ensure both the synchronous and the async version work");
1415   actor.SetProperty(index, 5.0f);
1416   DALI_TEST_EQUALS(actor.GetProperty<float>(index), 5.0f, TEST_LOCATION);
1417   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), startValue, TEST_LOCATION);
1418
1419   tet_infoline("Render and retrieve values again");
1420   application.SendNotification();
1421   application.Render(0);
1422
1423   DALI_TEST_EQUALS(actor.GetProperty<float>(index), 5.0f, TEST_LOCATION);
1424   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 5.0f, TEST_LOCATION);
1425
1426   END_TEST;
1427 }
1428
1429 int UtcDaliHandleCustomPropertyGetType(void)
1430 {
1431   TestApplication application;
1432
1433   tet_infoline("Create a custom property and retrieve its type");
1434
1435   Handle          handle = Handle::New();
1436   Property::Index index  = handle.RegisterProperty("testProperty", 1.0f);
1437   DALI_TEST_EQUALS(handle.GetPropertyType(index), Property::FLOAT, TEST_LOCATION);
1438
1439   END_TEST;
1440 }
1441
1442 int UtcDaliHandleCustomPropertyAccessMode(void)
1443 {
1444   TestApplication application;
1445
1446   tet_infoline("Create a custom property and retrieve whether it's animatable etc.");
1447
1448   Handle          handle = Handle::New();
1449   Property::Index index  = handle.RegisterProperty("testProperty", 1.0f);
1450   DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), true, TEST_LOCATION);
1451   DALI_TEST_EQUALS(handle.IsPropertyWritable(index), true, TEST_LOCATION);
1452
1453   index = handle.RegisterProperty("testProperty2", 1.0f, Property::READ_ONLY);
1454   DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), false, TEST_LOCATION);
1455   DALI_TEST_EQUALS(handle.IsPropertyWritable(index), false, TEST_LOCATION);
1456
1457   index = handle.RegisterProperty("testProperty3", 1.0f, Property::READ_WRITE);
1458   DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), false, TEST_LOCATION);
1459   DALI_TEST_EQUALS(handle.IsPropertyWritable(index), true, TEST_LOCATION);
1460
1461   END_TEST;
1462 }
1463
1464 int UtcDaliHandleGetCurrentProperty(void)
1465 {
1466   TestApplication application;
1467
1468   tet_infoline("Get a default and non-animatable custom property using the GetCurrentProperty API");
1469
1470   Actor actor = Actor::New();
1471   application.GetScene().Add(actor);
1472   DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
1473
1474   Property::Index index = actor.RegisterProperty("testProperty3", 1.0f, Property::READ_WRITE);
1475   DALI_TEST_EQUALS(actor.GetProperty<float>(index), 1.0f, TEST_LOCATION);
1476   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 1.0f, TEST_LOCATION);
1477
1478   actor.SetProperty(index, 2.0f);
1479   DALI_TEST_EQUALS(actor.GetProperty<float>(index), 2.0f, TEST_LOCATION);
1480   DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 2.0f, TEST_LOCATION);
1481
1482   END_TEST;
1483 }
1484
1485 int UtcDaliHandleDoesCustomPropertyExistP1(void)
1486 {
1487   TestApplication application; // Needs type registry
1488
1489   tet_infoline("Test if a registered custom property exists on object");
1490
1491   Actor actor         = Actor::New();
1492   auto  propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1493
1494   DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(propertyIndex), true, TEST_LOCATION);
1495   END_TEST;
1496 }
1497
1498 int UtcDaliHandleDoesCustomPropertyExistN1(void)
1499 {
1500   TestApplication application; // Needs type registry
1501
1502   tet_infoline("Test if a registered custom property does not exist on object");
1503
1504   Actor actor         = Actor::New();
1505   auto  propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1506
1507   DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(propertyIndex + 1), false, TEST_LOCATION);
1508   END_TEST;
1509 }
1510
1511 int UtcDaliHandleDoesCustomPropertyExistN2(void)
1512 {
1513   TestApplication application; // Needs type registry
1514
1515   tet_infoline("Test that a default property does not show as a custom property on object");
1516
1517   Actor actor = Actor::New();
1518   DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(Actor::Property::POSITION), false, TEST_LOCATION);
1519   END_TEST;
1520 }
1521
1522 int UtcDaliHandleDoesCustomPropertyExistN3(void)
1523 {
1524   TestApplication application; // Needs type registry
1525
1526   tet_infoline("Test that a child property does not exist on actor after parenting to container");
1527   TypeRegistry typeRegistry = TypeRegistry::Get();
1528
1529   auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1530
1531   const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1532   const char*           CHILD_PROPERTY_NAME("childProperty");
1533
1534   ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1535
1536   auto container = Test::TestCustomActor::New();
1537   application.GetScene().Add(container);
1538   auto child = Actor::New();
1539   container.Add(child); // Resolve child properties (if any)
1540
1541   DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), false, TEST_LOCATION);
1542   END_TEST;
1543 }
1544
1545 int UtcDaliHandleDoesCustomPropertyExistP2(void)
1546 {
1547   TestApplication application; // Needs type registry
1548
1549   tet_infoline("Test that a child property exists after being set");
1550   TypeRegistry typeRegistry = TypeRegistry::Get();
1551
1552   auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1553
1554   const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1555   const char*           CHILD_PROPERTY_NAME("childProperty");
1556
1557   ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1558
1559   auto container = Test::TestCustomActor::New();
1560   application.GetScene().Add(container);
1561   auto child = Actor::New();
1562   container.Add(child); // Resolve child properties (if any)
1563   child.SetProperty(CHILD_PROPERTY, 2);
1564
1565   DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1566   DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 2, TEST_LOCATION);
1567   END_TEST;
1568 }
1569
1570 int UtcDaliHandleDoesCustomPropertyExistP3(void)
1571 {
1572   TestApplication application; // Needs type registry
1573
1574   tet_infoline("Test that a child property is re-indexed after registration, and that it exists");
1575   TypeRegistry typeRegistry = TypeRegistry::Get();
1576
1577   auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1578
1579   const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1580   const char*           CHILD_PROPERTY_NAME("childProperty");
1581
1582   ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1583
1584   auto container = Test::TestCustomActor::New();
1585   application.GetScene().Add(container);
1586   auto child = Actor::New();
1587   child.RegisterProperty(CHILD_PROPERTY_NAME, Property::Value(3));
1588   container.Add(child); // Resolve child properties (if any)
1589
1590   DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1591   DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 3, TEST_LOCATION);
1592   END_TEST;
1593 }
1594
1595 namespace
1596 {
1597 struct PropertySetSignalCheck
1598 {
1599   PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
1600   : mSignalReceived(signalReceived),
1601     mValue(value)
1602   {
1603   }
1604
1605   void operator()(Handle& handle, Property::Index index, Property::Value value)
1606   {
1607     mSignalReceived = true;
1608     mValue          = value;
1609   }
1610
1611   void Reset()
1612   {
1613     mSignalReceived = false;
1614   }
1615
1616   void CheckSignalReceived()
1617   {
1618     if(!mSignalReceived)
1619     {
1620       tet_printf("Expected Property Set signal was not received\n");
1621       tet_result(TET_FAIL);
1622     }
1623     else
1624     {
1625       tet_result(TET_PASS);
1626     }
1627   }
1628
1629   bool&            mSignalReceived; // owned by individual tests
1630   Property::Value& mValue;
1631 };
1632
1633 } // namespace
1634
1635 int UtcDaliHandlePropertySetSignal01(void)
1636 {
1637   TestApplication application;
1638
1639   bool                   signalReceived(false);
1640   Property::Value        value;
1641   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1642
1643   tet_infoline("Test that setting a default property triggers a signal");
1644
1645   auto actor = Actor::New();
1646   actor.PropertySetSignal().Connect(&application, propertySetCheck);
1647
1648   actor.SetProperty(Actor::Property::POSITION, Vector3::XAXIS);
1649   propertySetCheck.CheckSignalReceived();
1650
1651   END_TEST;
1652 }
1653
1654 int UtcDaliHandlePropertySetSignal02(void)
1655 {
1656   TestApplication application;
1657
1658   bool                   signalReceived(false);
1659   Property::Value        value;
1660   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1661
1662   tet_infoline("Test that setting a custom property triggers a signal");
1663
1664   auto actor = Actor::New();
1665   actor.PropertySetSignal().Connect(&application, propertySetCheck);
1666
1667   auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
1668   actor.SetProperty(propertyIndex, 5.0f);
1669   propertySetCheck.CheckSignalReceived();
1670   DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(5.0f), 0.001f, TEST_LOCATION);
1671
1672   END_TEST;
1673 }
1674
1675 int UtcDaliHandlePropertySetSignal03(void)
1676 {
1677   TestApplication application;
1678   TypeRegistry    typeRegistry = TypeRegistry::Get();
1679
1680   bool                   signalReceived(false);
1681   Property::Value        value;
1682   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1683
1684   tet_infoline("Test that setting a child property triggers a signal");
1685
1686   auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1687
1688   const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1689   const char*           CHILD_PROPERTY_NAME("childProperty");
1690
1691   ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1692
1693   auto container = Test::TestCustomActor::New();
1694   application.GetScene().Add(container);
1695   auto child = Actor::New();
1696   child.RegisterProperty(CHILD_PROPERTY_NAME, Property::Value(3));
1697   child.PropertySetSignal().Connect(&application, propertySetCheck);
1698   container.Add(child); // Resolve child properties (if any)
1699
1700   DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1701   DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 3, TEST_LOCATION);
1702
1703   child.SetProperty(CHILD_PROPERTY, 29);
1704   propertySetCheck.CheckSignalReceived();
1705   DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(29), TEST_LOCATION);
1706   END_TEST;
1707 }
1708
1709 int UtcDaliHandlePropertySetSignal04(void)
1710 {
1711   TestApplication application;
1712   TypeRegistry    typeRegistry = TypeRegistry::Get();
1713
1714   bool                   signalReceived(false);
1715   Property::Value        value;
1716   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1717
1718   tet_infoline("Test that setting a property on a vanilla Object triggers a signal");
1719
1720   constexpr Property::Index TEST_PROPERTY_KEY_INDEX = 1;
1721   const std::string         TEST_PROPERTY_KEY_NAME  = "testProperty";
1722
1723   Handle vanillaObject = Handle::New();
1724   auto   propertyIndex = vanillaObject.RegisterProperty(
1725     TEST_PROPERTY_KEY_INDEX,
1726     TEST_PROPERTY_KEY_NAME,
1727     Color::WHITE);
1728
1729   vanillaObject.PropertySetSignal().Connect(&application, propertySetCheck);
1730
1731   DALI_TEST_EQUALS(vanillaObject.DoesCustomPropertyExist(propertyIndex), true, TEST_LOCATION);
1732   DALI_TEST_EQUALS(vanillaObject.GetProperty<Vector4>(propertyIndex), Color::WHITE, 0.001f, TEST_LOCATION);
1733
1734   vanillaObject[TEST_PROPERTY_KEY_NAME] = Color::RED;
1735
1736   propertySetCheck.CheckSignalReceived();
1737   DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(Color::RED), 0.001f, TEST_LOCATION);
1738   DALI_TEST_VALUE_EQUALS(vanillaObject[propertyIndex], Property::Value(Color::RED), 0.001f, TEST_LOCATION);
1739
1740   END_TEST;
1741 }
1742
1743 int UtcDaliHandlePropertySetProperties(void)
1744 {
1745   TestApplication application;
1746   const Vector3   actorSize(10.0f, 20.0f, 30.0f);
1747   const Vector3   anchorPoint(1.0f, 0.5f, 0.0f);
1748   const Vector4   color(0.1f, 0.2, 0.3f, 0.4f);
1749
1750   Handle handle = Actor::New();
1751   handle.SetProperties(
1752     Property::Map{
1753       {Actor::Property::SIZE, actorSize},
1754       {Actor::Property::ANCHOR_POINT, anchorPoint},
1755       {"color", color},
1756       {"invalid", Vector2::ZERO} // It should quietly ignore invalid data
1757     });
1758   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SIZE).Get<Vector3>(), actorSize, TEST_LOCATION);
1759   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>(), anchorPoint, TEST_LOCATION);
1760   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR).Get<Vector4>(), color, TEST_LOCATION);
1761
1762   END_TEST;
1763 }
1764
1765 int UtcDaliHandleTemplateNew01(void)
1766 {
1767   TestApplication application;
1768   const Vector3   actorSize(10.0f, 20.0f, 30.0f);
1769   const Vector3   anchorPoint(1.0f, 0.5f, 0.0f);
1770   const Vector4   color(0.1f, 0.2, 0.3f, 0.4f);
1771
1772   Handle handle = Handle::New<Actor>(
1773     Property::Map{
1774       {Actor::Property::SIZE, actorSize},
1775       {Actor::Property::ANCHOR_POINT, anchorPoint},
1776       {"color", color},
1777       {"invalid", Vector2::ZERO} // It should quietly ignore invalid data
1778     });
1779
1780   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SIZE).Get<Vector3>(), actorSize, TEST_LOCATION);
1781   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>(), anchorPoint, TEST_LOCATION);
1782   DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR).Get<Vector4>(), color, TEST_LOCATION);
1783
1784   END_TEST;
1785 }
1786
1787 int UtcDaliHandleGetProperties(void)
1788 {
1789   TestApplication application;
1790
1791   Handle handle = Actor::New();
1792   handle.SetProperties(
1793     Property::Map{
1794       {Actor::Property::SIZE, Vector3(400.0f, 200.0f, 100.0f)},
1795       {Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER},
1796       {Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER},
1797       {Actor::Property::NAME, "Actor"},
1798       {Actor::Property::LEAVE_REQUIRED, true},
1799       {"color", Color::RED},
1800     });
1801
1802   Property::Map map;
1803   handle.GetProperties(map);
1804
1805   // Get all the properties and ensure they match
1806
1807   DALI_TEST_EQUALS(handle.GetPropertyCount(), map.Count(), TEST_LOCATION);
1808
1809   for(auto position = 0u; position < map.Count(); ++position)
1810   {
1811     auto        keyValuePair = map.GetKeyValue(position);
1812     const auto& index        = keyValuePair.first.indexKey;
1813     const auto& value        = keyValuePair.second;
1814     auto        handleValue  = handle.GetProperty(index);
1815
1816     switch(value.GetType())
1817     {
1818       case Property::NONE:
1819         break;
1820       case Property::BOOLEAN:
1821         DALI_TEST_EQUALS(value.Get<bool>(), handleValue.Get<bool>(), TEST_LOCATION);
1822         break;
1823       case Property::FLOAT:
1824         DALI_TEST_EQUALS(value.Get<float>(), handleValue.Get<float>(), TEST_LOCATION);
1825         break;
1826       case Property::INTEGER:
1827         DALI_TEST_EQUALS(value.Get<int>(), handleValue.Get<int>(), TEST_LOCATION);
1828         break;
1829       case Property::VECTOR2:
1830         DALI_TEST_EQUALS(value.Get<Vector2>(), handleValue.Get<Vector2>(), TEST_LOCATION);
1831         break;
1832       case Property::VECTOR3:
1833         DALI_TEST_EQUALS(value.Get<Vector3>(), handleValue.Get<Vector3>(), TEST_LOCATION);
1834         break;
1835       case Property::VECTOR4:
1836         DALI_TEST_EQUALS(value.Get<Vector4>(), handleValue.Get<Vector4>(), TEST_LOCATION);
1837         break;
1838       case Property::MATRIX3:
1839         DALI_TEST_EQUALS(value.Get<Matrix3>(), handleValue.Get<Matrix3>(), TEST_LOCATION);
1840         break;
1841       case Property::MATRIX:
1842         DALI_TEST_EQUALS(value.Get<Matrix>(), handleValue.Get<Matrix>(), TEST_LOCATION);
1843         break;
1844       case Property::RECTANGLE:
1845         DALI_TEST_EQUALS(value.Get<Rect<int> >(), handleValue.Get<Rect<int> >(), TEST_LOCATION);
1846         break;
1847       case Property::ROTATION:
1848         DALI_TEST_EQUALS(value.Get<Quaternion>(), handleValue.Get<Quaternion>(), TEST_LOCATION);
1849         break;
1850       case Property::STRING:
1851         DALI_TEST_EQUALS(value.Get<std::string>(), handleValue.Get<std::string>(), TEST_LOCATION);
1852         break;
1853       case Property::ARRAY:
1854         DALI_TEST_EQUALS(value.GetArray()->Count(), handleValue.GetArray()->Count(), TEST_LOCATION);
1855         break;
1856       case Property::MAP:
1857         DALI_TEST_EQUALS(value.GetMap()->Count(), handleValue.GetMap()->Count(), TEST_LOCATION);
1858         break;
1859       case Property::EXTENTS:
1860         DALI_TEST_EQUALS(value.Get<Extents>(), handleValue.Get<Extents>(), TEST_LOCATION);
1861         break;
1862     }
1863   }
1864
1865   // Add a custom property and ensure the count goes up by one.
1866   const auto countBefore = map.Count();
1867   handle.RegisterProperty("tempProperty", Color::GREEN);
1868   handle.GetProperties(map);
1869   DALI_TEST_EQUALS(countBefore + 1, map.Count(), TEST_LOCATION);
1870
1871   END_TEST;
1872 }
1873
1874 int UtcDaliHandleSetPropertyNegative(void)
1875 {
1876   TestApplication application;
1877   Dali::Handle    instance;
1878   try
1879   {
1880     int                   arg1(0);
1881     Dali::Property::Value arg2;
1882     instance.SetProperty(arg1, arg2);
1883     DALI_TEST_CHECK(false); // Should not get here
1884   }
1885   catch(...)
1886   {
1887     DALI_TEST_CHECK(true); // We expect an assert
1888   }
1889   END_TEST;
1890 }
1891
1892 int UtcDaliHandleRegisterPropertyNegative01(void)
1893 {
1894   TestApplication application;
1895   Dali::Handle    instance;
1896   try
1897   {
1898     std::string           arg1;
1899     Dali::Property::Value arg2;
1900     instance.RegisterProperty(arg1, arg2);
1901     DALI_TEST_CHECK(false); // Should not get here
1902   }
1903   catch(...)
1904   {
1905     DALI_TEST_CHECK(true); // We expect an assert
1906   }
1907   END_TEST;
1908 }
1909
1910 int UtcDaliHandleRegisterPropertyNegative02(void)
1911 {
1912   TestApplication application;
1913   Dali::Handle    instance;
1914   try
1915   {
1916     std::string                arg1;
1917     Dali::Property::Value      arg2;
1918     Dali::Property::AccessMode arg3(Property::READ_ONLY);
1919     instance.RegisterProperty(arg1, arg2, arg3);
1920     DALI_TEST_CHECK(false); // Should not get here
1921   }
1922   catch(...)
1923   {
1924     DALI_TEST_CHECK(true); // We expect an assert
1925   }
1926   END_TEST;
1927 }
1928
1929 int UtcDaliHandleRemoveConstraintsNegative01(void)
1930 {
1931   TestApplication application;
1932   Dali::Handle    instance;
1933   try
1934   {
1935     unsigned int arg1(0u);
1936     instance.RemoveConstraints(arg1);
1937     DALI_TEST_CHECK(false); // Should not get here
1938   }
1939   catch(...)
1940   {
1941     DALI_TEST_CHECK(true); // We expect an assert
1942   }
1943   END_TEST;
1944 }
1945
1946 int UtcDaliHandleRemoveConstraintsNegative02(void)
1947 {
1948   TestApplication application;
1949   Dali::Handle    instance;
1950   try
1951   {
1952     instance.RemoveConstraints();
1953     DALI_TEST_CHECK(false); // Should not get here
1954   }
1955   catch(...)
1956   {
1957     DALI_TEST_CHECK(true); // We expect an assert
1958   }
1959   END_TEST;
1960 }
1961
1962 int UtcDaliHandleAddPropertyNotificationNegative01(void)
1963 {
1964   TestApplication application;
1965   Dali::Handle    instance;
1966   try
1967   {
1968     int                     arg1(0);
1969     int                     arg2(0);
1970     Dali::PropertyCondition arg3;
1971     instance.AddPropertyNotification(arg1, arg2, arg3);
1972     DALI_TEST_CHECK(false); // Should not get here
1973   }
1974   catch(...)
1975   {
1976     DALI_TEST_CHECK(true); // We expect an assert
1977   }
1978   END_TEST;
1979 }
1980
1981 int UtcDaliHandleAddPropertyNotificationNegative02(void)
1982 {
1983   TestApplication application;
1984   Dali::Handle    instance;
1985   try
1986   {
1987     int                     arg1(0);
1988     Dali::PropertyCondition arg2;
1989     instance.AddPropertyNotification(arg1, arg2);
1990     DALI_TEST_CHECK(false); // Should not get here
1991   }
1992   catch(...)
1993   {
1994     DALI_TEST_CHECK(true); // We expect an assert
1995   }
1996   END_TEST;
1997 }
1998
1999 int UtcDaliHandleRemovePropertyNotificationNegative(void)
2000 {
2001   TestApplication application;
2002   Dali::Handle    instance;
2003   try
2004   {
2005     Dali::PropertyNotification arg1;
2006     instance.RemovePropertyNotification(arg1);
2007     DALI_TEST_CHECK(false); // Should not get here
2008   }
2009   catch(...)
2010   {
2011     DALI_TEST_CHECK(true); // We expect an assert
2012   }
2013   END_TEST;
2014 }
2015
2016 int UtcDaliHandleRemovePropertyNotificationsNegative(void)
2017 {
2018   TestApplication application;
2019   Dali::Handle    instance;
2020   try
2021   {
2022     instance.RemovePropertyNotifications();
2023     DALI_TEST_CHECK(false); // Should not get here
2024   }
2025   catch(...)
2026   {
2027     DALI_TEST_CHECK(true); // We expect an assert
2028   }
2029   END_TEST;
2030 }
2031
2032 int UtcDaliHandleGetPropertyNegative(void)
2033 {
2034   TestApplication application;
2035   Dali::Handle    instance;
2036   try
2037   {
2038     int arg1(0);
2039     instance.GetProperty(arg1);
2040     DALI_TEST_CHECK(false); // Should not get here
2041   }
2042   catch(...)
2043   {
2044     DALI_TEST_CHECK(true); // We expect an assert
2045   }
2046   END_TEST;
2047 }
2048
2049 int UtcDaliHandleGetPropertyNameNegative(void)
2050 {
2051   TestApplication application;
2052   Dali::Handle    instance;
2053   try
2054   {
2055     int arg1(0);
2056     instance.GetPropertyName(arg1);
2057     DALI_TEST_CHECK(false); // Should not get here
2058   }
2059   catch(...)
2060   {
2061     DALI_TEST_CHECK(true); // We expect an assert
2062   }
2063   END_TEST;
2064 }
2065
2066 int UtcDaliHandleGetPropertyTypeNegative(void)
2067 {
2068   TestApplication application;
2069   Dali::Handle    instance;
2070   try
2071   {
2072     int arg1(0);
2073     instance.GetPropertyType(arg1);
2074     DALI_TEST_CHECK(false); // Should not get here
2075   }
2076   catch(...)
2077   {
2078     DALI_TEST_CHECK(true); // We expect an assert
2079   }
2080   END_TEST;
2081 }
2082
2083 int UtcDaliHandleGetPropertyCountNegative(void)
2084 {
2085   TestApplication application;
2086   Dali::Handle    instance;
2087   try
2088   {
2089     instance.GetPropertyCount();
2090     DALI_TEST_CHECK(false); // Should not get here
2091   }
2092   catch(...)
2093   {
2094     DALI_TEST_CHECK(true); // We expect an assert
2095   }
2096   END_TEST;
2097 }
2098
2099 int UtcDaliHandleGetPropertyIndexNegative(void)
2100 {
2101   TestApplication application;
2102   Dali::Handle    instance;
2103   try
2104   {
2105     std::string arg1;
2106     instance.GetPropertyIndex(arg1);
2107     DALI_TEST_CHECK(false); // Should not get here
2108   }
2109   catch(...)
2110   {
2111     DALI_TEST_CHECK(true); // We expect an assert
2112   }
2113   END_TEST;
2114 }
2115
2116 int UtcDaliHandleGetCurrentPropertyNegative(void)
2117 {
2118   TestApplication application;
2119   Dali::Handle    instance;
2120   try
2121   {
2122     int arg1(0);
2123     instance.GetCurrentProperty(arg1);
2124     DALI_TEST_CHECK(false); // Should not get here
2125   }
2126   catch(...)
2127   {
2128     DALI_TEST_CHECK(true); // We expect an assert
2129   }
2130   END_TEST;
2131 }
2132
2133 int UtcDaliHandleGetPropertyIndicesNegative(void)
2134 {
2135   TestApplication application;
2136   Dali::Handle    instance;
2137   try
2138   {
2139     Dali::Vector<int> arg1;
2140     instance.GetPropertyIndices(arg1);
2141     DALI_TEST_CHECK(false); // Should not get here
2142   }
2143   catch(...)
2144   {
2145     DALI_TEST_CHECK(true); // We expect an assert
2146   }
2147   END_TEST;
2148 }
2149
2150 int UtcDaliHandleIsPropertyWritableNegative(void)
2151 {
2152   TestApplication application;
2153   Dali::Handle    instance;
2154   try
2155   {
2156     int arg1(0);
2157     instance.IsPropertyWritable(arg1);
2158     DALI_TEST_CHECK(false); // Should not get here
2159   }
2160   catch(...)
2161   {
2162     DALI_TEST_CHECK(true); // We expect an assert
2163   }
2164   END_TEST;
2165 }
2166
2167 int UtcDaliHandleIsPropertyAnimatableNegative(void)
2168 {
2169   TestApplication application;
2170   Dali::Handle    instance;
2171   try
2172   {
2173     int arg1(0);
2174     instance.IsPropertyAnimatable(arg1);
2175     DALI_TEST_CHECK(false); // Should not get here
2176   }
2177   catch(...)
2178   {
2179     DALI_TEST_CHECK(true); // We expect an assert
2180   }
2181   END_TEST;
2182 }
2183
2184 int UtcDaliHandleIsPropertyAConstraintInputNegative(void)
2185 {
2186   TestApplication application;
2187   Dali::Handle    instance;
2188   try
2189   {
2190     int arg1(0);
2191     instance.IsPropertyAConstraintInput(arg1);
2192     DALI_TEST_CHECK(false); // Should not get here
2193   }
2194   catch(...)
2195   {
2196     DALI_TEST_CHECK(true); // We expect an assert
2197   }
2198   END_TEST;
2199 }
2200
2201 int UtcDaliHandleSupportsNegative(void)
2202 {
2203   TestApplication application;
2204   Dali::Handle    instance;
2205   try
2206   {
2207     Dali::Handle::Capability arg1(Handle::DYNAMIC_PROPERTIES);
2208     instance.Supports(arg1);
2209     DALI_TEST_CHECK(false); // Should not get here
2210   }
2211   catch(...)
2212   {
2213     DALI_TEST_CHECK(true); // We expect an assert
2214   }
2215   END_TEST;
2216 }
2217
2218 int UtcDaliHandleIndexOperatorByIndexP01(void)
2219 {
2220   TestApplication application;
2221   Actor           actor = Actor::New();
2222
2223   actor[Actor::Property::SIZE] = Vector3(100.0f, 200.0f, 1.0f);
2224
2225   DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(100.0f, 200.0f, 1.0f), 0.001f, TEST_LOCATION);
2226
2227   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2228
2229   Vector3 position = actor[Actor::Property::POSITION];
2230   DALI_TEST_EQUALS(position, Vector3(10.0f, 20.0f, 0.0f), TEST_LOCATION);
2231
2232   END_TEST;
2233 }
2234
2235 int UtcDaliHandleIndexOperatorByIndexP02(void)
2236 {
2237   TestApplication application;
2238   Actor           actor = Actor::New();
2239
2240   const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2241   actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2242   actor[Actor::Property::COLOR_RED] = 0.5f;
2243
2244   DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.001f, TEST_LOCATION);
2245   DALI_TEST_EQUALS(actor.GetProperty<Vector4>(Actor::Property::COLOR), Vector4(0.5f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
2246
2247   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2248
2249   DALI_TEST_EQUALS((float)actor[Actor::Property::POSITION_Z], 0.0f, 0.001f, TEST_LOCATION);
2250
2251   END_TEST;
2252 }
2253
2254 int UtcDaliHandleIndexOperatorByIndexP03(void)
2255 {
2256   TestApplication application;
2257   Actor           actor = Actor::New();
2258
2259   const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2260   actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2261
2262   // Value under test is second to allow compiler to deduce type
2263   DALI_TEST_VALUE_EQUALS(actor[Actor::Property::COLOR_RED], 1.0f, 0.001f, TEST_LOCATION);
2264
2265   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2266
2267   DALI_TEST_EQUALS((float)actor[Actor::Property::POSITION_Z], 0.0f, 0.001f, TEST_LOCATION);
2268
2269   END_TEST;
2270 }
2271
2272 int UtcDaliHandleIndexOperatorByNameP01(void)
2273 {
2274   TestApplication application;
2275   Actor           actor = Actor::New();
2276
2277   actor["size"] = Vector3(100.0f, 200.0f, 1.0f);
2278
2279   DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::SIZE), Vector3(100.0f, 200.0f, 1.0f), 0.001f, TEST_LOCATION);
2280
2281   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2282   Vector3 position = actor["position"];
2283
2284   DALI_TEST_EQUALS(position, Vector3(10.0f, 20.0f, 0.0f), 0.001f, TEST_LOCATION);
2285
2286   END_TEST;
2287 }
2288
2289 int UtcDaliHandleIndexOperatorByNameP02(void)
2290 {
2291   TestApplication application;
2292   Actor           actor = Actor::New();
2293
2294   const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2295   actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2296   actor["colorRed"] = 0.5f;
2297
2298   DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::COLOR_RED), 0.5f, 0.001f, TEST_LOCATION);
2299   DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::COLOR), Vector4(0.5f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
2300
2301   actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2302
2303   float positionY = actor["positionY"];
2304   DALI_TEST_EQUALS(positionY, 20.0f, 0.001f, TEST_LOCATION);
2305
2306   // Should automatically promote IndirectValue to Property::Value rvalue.
2307   DALI_TEST_VALUE_EQUALS(actor["positionZ"], 0.0f, 0.001f, TEST_LOCATION);
2308
2309   END_TEST;
2310 }
2311
2312 int UtcDaliHandleIndexOperatorNegative02(void)
2313 {
2314   TestApplication application;
2315
2316   Actor actor;
2317   try
2318   {
2319     Vector3 position = actor[Actor::Property::POSITION];
2320     if(position == position)
2321     {
2322       DALI_TEST_CHECK(false); // Should throw before reaching here.
2323     }
2324     DALI_TEST_CHECK(false); // Should throw before reaching here.
2325   }
2326   catch(...)
2327   {
2328     DALI_TEST_CHECK(true); // Assert expected
2329   }
2330
2331   END_TEST;
2332 }