Harmonize Animation API parameter checking and add test cases for them
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Handle.cpp
1 /*
2  * Copyright (c) 2018 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 <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/devel-api/object/handle-devel.h>
24 #include "dali-test-suite-utils/dali-test-suite-utils.h"
25 #include "dali-test-suite-utils/test-custom-actor.h"
26
27 #include <mesh-builder.h>
28
29 using namespace Dali;
30
31 void handle_test_startup(void)
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void handle_test_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41 namespace
42 {
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 } // anon namespace
66
67
68 int UtcDaliHandleConstructorVoid(void)
69 {
70   TestApplication application;
71   tet_infoline("Testing Dali::Handle::Handle()");
72
73   Handle object;
74
75   DALI_TEST_CHECK(!object);
76
77   END_TEST;
78 }
79
80 int UtcDaliHandleCopyConstructor(void)
81 {
82   TestApplication application;
83   tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
84
85   // Initialize an object, ref count == 1
86   Handle object = Actor::New();
87
88   DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
89
90   // Copy the object, ref count == 2
91   Handle copy(object);
92   DALI_TEST_CHECK(copy);
93   if (copy)
94   {
95     DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
96   }
97
98   {
99     // Pass by value, and return another copy, ref count == 3
100     Handle anotherCopy = ImplicitCopyConstructor(copy);
101
102     DALI_TEST_CHECK(anotherCopy);
103     if (anotherCopy)
104     {
105       DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
106     }
107   }
108
109   // anotherCopy out of scope, ref count == 2
110   DALI_TEST_CHECK(copy);
111   if (copy)
112   {
113     DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
114   }
115   END_TEST;
116 }
117
118 int UtcDaliHandleAssignmentOperator(void)
119 {
120   TestApplication application;
121   tet_infoline("Testing Dali::Handle::operator=");
122
123   Handle object = Actor::New();
124
125   DALI_TEST_CHECK(object);
126   DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
127
128   Handle copy;
129   DALI_TEST_CHECK(!copy);
130
131   copy = object;
132   DALI_TEST_CHECK(copy);
133   DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
134   DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject()));
135   END_TEST;
136 }
137
138 int UtcDaliHandleSupports(void)
139 {
140   tet_infoline("Positive Test Dali::Handle::Supports()");
141   TestApplication application;
142
143   Actor actor = Actor::New();
144   DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) );
145   END_TEST;
146 }
147
148 int UtcDaliHandleGetPropertyCount(void)
149 {
150   tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
151   TestApplication application;
152
153   Actor actor = Actor::New();
154   int defaultPropertyCount( actor.GetPropertyCount() );
155
156   // Register a dynamic property
157   actor.RegisterProperty( "testProperty",  float(123.0f) );
158   DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() );
159   END_TEST;
160 }
161
162 int UtcDaliHandleGetPropertyName(void)
163 {
164   tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
165   TestApplication application;
166
167   Actor actor = Actor::New();
168   DALI_TEST_CHECK( "parentOrigin" == actor.GetPropertyName( Actor::Property::PARENT_ORIGIN ) );
169
170   // Register a dynamic property
171   std::string name("thisNameShouldMatch");
172   Property::Index index = actor.RegisterProperty( name, float(123.0f) );
173   DALI_TEST_CHECK( name == actor.GetPropertyName( index ) );
174
175   END_TEST;
176 }
177
178 int UtcDaliHandleGetPropertyIndex01(void)
179 {
180   tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
181   TestApplication application;
182
183   Actor actor = Actor::New();
184   DALI_TEST_CHECK( Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parentOrigin") );
185
186   // Register a dynamic property
187   std::string name("thisNameShouldMatch");
188   Property::Index index = actor.RegisterProperty( name, float(123.0f) );
189   DALI_TEST_CHECK( index == actor.GetPropertyIndex( name ) );
190   END_TEST;
191 }
192
193 int UtcDaliHandleGetPropertyIndex02(void)
194 {
195   tet_infoline("Positive Test Dali::Handle::GetPropertyIndex() int key");
196   TestApplication application;
197
198   Stage stage = Stage::GetCurrent();
199
200   Actor actor = Actor::New();
201   stage.Add( actor );
202
203   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
204
205   application.SendNotification();
206   application.Render();
207
208   Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
209   Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
210
211   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
212   const float withFlake(99.f);
213
214   Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
215   Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
216   Property::Index index3 = actor.RegisterProperty( "MyPropertyTwo", Vector3::ONE );
217   Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
218   Property::Index index5 = actor.RegisterProperty( "MyPropertyThree", Vector3::ONE );
219
220   application.SendNotification();
221   application.Render();
222
223   // Test that we can get the property index from the integer key
224   Property::Index testIndex1 = DevelHandle::GetPropertyIndex( actor, key1 );
225   Property::Index testIndex2 = DevelHandle::GetPropertyIndex( actor, key2 );
226
227   DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION );
228   DALI_TEST_EQUALS( index4, testIndex2, TEST_LOCATION );
229
230   // Test that we keep the same indices on the named properties
231   Property::Index testIndex = actor.GetPropertyIndex("MyPropertyOne");
232   DALI_TEST_EQUALS(testIndex, index1, TEST_LOCATION);
233   testIndex = actor.GetPropertyIndex("MyPropertyTwo");
234   DALI_TEST_EQUALS(testIndex, index3, TEST_LOCATION);
235   testIndex = actor.GetPropertyIndex("MyPropertyThree");
236   DALI_TEST_EQUALS(testIndex, index5, TEST_LOCATION);
237   testIndex = actor.GetPropertyIndex("sideColor");
238   DALI_TEST_EQUALS(testIndex, index2, TEST_LOCATION);
239   testIndex = actor.GetPropertyIndex("iceCream");
240   DALI_TEST_EQUALS(testIndex, index4, TEST_LOCATION);
241
242   DALI_TEST_EQUALS(defaultPropertyCount+5, actor.GetPropertyCount(), TEST_LOCATION);
243   END_TEST;
244 }
245
246 int UtcDaliHandleGetPropertyIndex03(void)
247 {
248   TestApplication application;
249
250   Actor actor = Actor::New();
251
252   std::string myName("croydon");
253   Property::Index intKey = CORE_PROPERTY_MAX_INDEX+1;
254   Property::Value value( Color::GREEN );
255   Property::Index myIndex = DevelHandle::RegisterProperty( actor, intKey, myName, value );
256
257   DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, intKey ), TEST_LOCATION );
258
259   Property::Key key1(myName);
260   Property::Key key2(intKey);
261
262   DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key1 ), TEST_LOCATION );
263   DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key2 ), TEST_LOCATION );
264   END_TEST;
265 }
266
267
268 int UtcDaliHandleIsPropertyWritable(void)
269 {
270   tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
271   TestApplication application;
272
273   Actor actor = Actor::New();
274
275   // Actor properties which are writable:
276   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN ) );
277   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_X ) );
278   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Y ) );
279   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Z ) );
280   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT ) );
281   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_X ) );
282   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Y ) );
283   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Z ) );
284   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE ) );
285   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_WIDTH  ) );
286   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_HEIGHT ) );
287   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_DEPTH  ) );
288   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION ) );
289   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_X ) );
290   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Y ) );
291   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Z ) );
292   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ORIENTATION ) );
293   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE ) );
294   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_X ) );
295   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Y ) );
296   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Z ) );
297   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::VISIBLE ) );
298   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR ) );
299   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_RED ) );
300   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_GREEN ) );
301   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_BLUE ) );
302   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_ALPHA ) );
303   DALI_TEST_CHECK( true == actor.IsPropertyWritable( DevelActor::Property::OPACITY ) );
304
305   // World-properties are not writable:
306   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
307   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_ORIENTATION ) );
308   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_SCALE ) );
309   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_COLOR ) );
310   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_X ) );
311   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Y ) );
312   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Z ) );
313
314   END_TEST;
315 }
316
317 int UtcDaliHandleIsPropertyAnimatable(void)
318 {
319   tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
320   TestApplication application;
321
322   Actor actor = Actor::New();
323
324   // Actor properties which are animatable:
325   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN ) );
326   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_X ) );
327   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Y ) );
328   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Z ) );
329   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT ) );
330   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_X ) );
331   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Y ) );
332   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Z ) );
333   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE ) );
334   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_WIDTH  ) );
335   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_HEIGHT ) );
336   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_DEPTH  ) );
337   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION ) );
338   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_X ) );
339   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Y ) );
340   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Z ) );
341   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::ORIENTATION ) );
342   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE ) );
343   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_X ) );
344   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Y ) );
345   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Z ) );
346   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::VISIBLE ) );
347   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR ) );
348   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_RED ) );
349   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_GREEN ) );
350   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_BLUE ) );
351   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_ALPHA ) );
352   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( DevelActor::Property::OPACITY ) );
353
354   // World-properties can not be animated
355   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION ) );
356   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_ORIENTATION ) );
357   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_SCALE ) );
358   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_COLOR ) );
359   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_X ) );
360   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Y ) );
361   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Z ) );
362
363   END_TEST;
364 }
365
366 int UtcDaliHandleIsPropertyAConstraintInput(void)
367 {
368   TestApplication application;
369
370   Actor actor = Actor::New();
371
372   // Actor properties which can be used as a constraint input:
373   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN ) );
374   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_X ) );
375   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Y ) );
376   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Z ) );
377   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT ) );
378   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_X ) );
379   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Y ) );
380   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Z ) );
381   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE ) );
382   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_WIDTH  ) );
383   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_HEIGHT ) );
384   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_DEPTH  ) );
385   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION ) );
386   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_X ) );
387   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Y ) );
388   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Z ) );
389   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ORIENTATION ) );
390   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE ) );
391   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_X ) );
392   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Y ) );
393   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Z ) );
394   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::VISIBLE ) );
395   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR ) );
396   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_RED ) );
397   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_GREEN ) );
398   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_BLUE ) );
399   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_ALPHA ) );
400   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( DevelActor::Property::OPACITY ) );
401   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION ) );
402   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_ORIENTATION ) );
403   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_SCALE ) );
404   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_COLOR ) );
405   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_X ) );
406   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Y ) );
407   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Z ) );
408
409   // Actor properties that cannot be used as a constraint input
410   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::NAME ) );
411   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SENSITIVE ) );
412   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::LEAVE_REQUIRED ) );
413   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_ORIENTATION ) );
414   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_SCALE ) );
415   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_MODE ) );
416   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_INHERITANCE ) );
417   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::DRAW_MODE ) );
418   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE_FACTOR ) );
419
420   END_TEST;
421 }
422
423
424 int UtcDaliHandleGetPropertyType(void)
425 {
426   tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
427   TestApplication application;
428
429   Actor actor = Actor::New();
430   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::PARENT_ORIGIN ) );
431   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::ANCHOR_POINT ) );
432   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::SIZE ) );
433   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::POSITION ) );
434   DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( Actor::Property::ORIENTATION ) );
435   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::SCALE ) );
436   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( Actor::Property::VISIBLE ) );
437   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( Actor::Property::COLOR ) );
438
439   // Register some dynamic properties
440   Property::Index boolIndex     = actor.RegisterProperty( "boolProperty",      bool(true) );
441   Property::Index floatIndex    = actor.RegisterProperty( "floatProperty",     float(123.0f) );
442   Property::Index intIndex      = actor.RegisterProperty( "intProperty",       123 );
443   Property::Index vector2Index  = actor.RegisterProperty( "vector2Property",   Vector2(1.0f, 2.0f) );
444   Property::Index vector3Index  = actor.RegisterProperty( "vector3Property",   Vector3(1.0f, 2.0f, 3.0f) );
445   Property::Index vector4Index  = actor.RegisterProperty( "vector4Property",   Vector4(1.0f, 2.0f, 3.0f, 4.0f) );
446   Property::Index rotationIndex = actor.RegisterProperty( "rotationProperty",  AngleAxis(Degree(180.0f), Vector3::YAXIS) );
447
448   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( boolIndex ) );
449   DALI_TEST_CHECK( Property::FLOAT    == actor.GetPropertyType( floatIndex ) );
450   DALI_TEST_CHECK( Property::INTEGER  == actor.GetPropertyType( intIndex ) );
451   DALI_TEST_CHECK( Property::VECTOR2  == actor.GetPropertyType( vector2Index ) );
452   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( vector3Index ) );
453   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( vector4Index ) );
454   DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) );
455
456   // Non animatable properties
457   Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte",   std::string("yes"), Property::READ_WRITE);
458   Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE);
459   Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
460   Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
461   Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE);
462   Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE);
463   Property::Index nonAnimIntegerIndex = actor.RegisterProperty( "int", 0, Property::READ_WRITE);
464
465   DALI_TEST_CHECK( nonAnimStringIndex  != Property::INVALID_INDEX );
466   DALI_TEST_CHECK( nonAnimV2Index      != Property::INVALID_INDEX );
467   DALI_TEST_CHECK( nonAnimV3Index      != Property::INVALID_INDEX );
468   DALI_TEST_CHECK( nonAnimV4Index      != Property::INVALID_INDEX );
469   DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX );
470   DALI_TEST_CHECK( nonAnimFloatIndex   != Property::INVALID_INDEX );
471   DALI_TEST_CHECK( nonAnimIntegerIndex != Property::INVALID_INDEX );
472
473   DALI_TEST_CHECK( Property::STRING   == actor.GetPropertyType( nonAnimStringIndex ) );
474   DALI_TEST_CHECK( Property::VECTOR2  == actor.GetPropertyType( nonAnimV2Index ) );
475   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( nonAnimV3Index ) );
476   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( nonAnimV4Index ) );
477   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( nonAnimBooleanIndex ) );
478   DALI_TEST_CHECK( Property::FLOAT    == actor.GetPropertyType( nonAnimFloatIndex ) );
479   DALI_TEST_CHECK( Property::INTEGER  == actor.GetPropertyType( nonAnimIntegerIndex ) );
480
481   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) );
482   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) );
483   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV3Index ) );
484   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) );
485   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) );
486   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) );
487   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimIntegerIndex ) );
488
489   DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
490   DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get<Vector2>(), TEST_LOCATION );
491   DALI_TEST_EQUALS( Vector3(1.f, 2.f, 3.f) , actor.GetProperty( nonAnimV3Index ).Get<Vector3>(), TEST_LOCATION );
492   DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get<Vector4>(), TEST_LOCATION );
493   DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get<bool>(), TEST_LOCATION );
494   DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get<float>(), TEST_LOCATION );
495   DALI_TEST_EQUALS( 0, actor.GetProperty( nonAnimIntegerIndex ).Get<int>(), TEST_LOCATION );
496
497   END_TEST;
498 }
499
500 int UtcDaliHandleNonAnimatableProperties(void)
501 {
502   tet_infoline("Test Non Animatable Properties");
503   TestApplication application;
504
505   Actor actor = Actor::New();
506
507   Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE);
508
509   //// modify writable?
510   actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
511
512   DALI_TEST_CHECK( "yes"  == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
513
514   //// cannot modify read only?
515   Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY);
516
517   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
518   DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
519
520   actor.SetProperty( readonly, Property::Value(1.f) );
521   // trying to set a read-only property is a no-op
522
523   DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
524
525   /// animatable can be set
526   Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE);
527
528   DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
529   DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
530
531   actor.SetProperty( write_anim, Property::Value(1.f) );
532
533   //// animate a non animatable property throws
534   float durationSeconds(2.0f);
535   Animation animation = Animation::New(durationSeconds);
536   bool relativeValue(true);
537   try
538   {
539     animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
540   }
541   catch ( Dali::DaliException& e )
542   {
543     DALI_TEST_ASSERT( e, "Property type is not animatable", TEST_LOCATION );
544   }
545
546   DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
547
548   END_TEST;
549 }
550
551 int UtcDaliHandleNonAnimtableCompositeProperties(void)
552 {
553   tet_infoline("Test Non Animatable Composite Properties");
554   TestApplication application;
555
556   Actor actor = Actor::New();
557
558   Property::Value value(Property::ARRAY);
559   Property::Array* array = value.GetArray();
560   DALI_TEST_CHECK( array );
561
562   array->PushBack( Property::Value( 0.1f ) );
563   array->PushBack( "a string" );
564   array->PushBack( Property::Value( Vector3(1,2,3) ) );
565
566   DALI_TEST_EQUALS( 3u, array->Count(), TEST_LOCATION );
567
568   Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE );
569
570   Property::Value out = actor.GetProperty( propertyIndex );
571   Property::Array* outArray = out.GetArray();
572   DALI_TEST_CHECK( outArray != NULL );
573
574   DALI_TEST_CHECK( Property::FLOAT     == outArray->GetElementAt(0).GetType());
575   DALI_TEST_CHECK( Property::STRING    == outArray->GetElementAt(1).GetType());
576   DALI_TEST_CHECK( Property::VECTOR3   == outArray->GetElementAt(2).GetType());
577
578   DALI_TEST_EQUALS( 0.1f,            outArray->GetElementAt(0).Get<float>(),       TEST_LOCATION);
579   DALI_TEST_EQUALS( "a string",     outArray->GetElementAt(1).Get<std::string>(),  TEST_LOCATION);
580   DALI_TEST_EQUALS( Vector3(1,2,3), outArray->GetElementAt(2).Get<Vector3>(),      TEST_LOCATION);
581
582   // composite types not animatable
583   bool exception = false;
584   try
585   {
586     actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE);
587   }
588   catch (Dali::DaliException& e)
589   {
590     exception = true;
591     DALI_TEST_PRINT_ASSERT( e );
592   }
593
594   DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
595
596   // Map of maps
597   Property::Value mapOfMaps(Property::MAP);
598   Property::Map* map = mapOfMaps.GetMap();
599
600   map->Insert( "key", Property::Value(Property::MAP) );
601   map->Insert( "2key", "a string" );
602
603   DALI_TEST_EQUALS( "a string",  (*map)["2key"].Get<std::string>(),  TEST_LOCATION);
604
605   Property::Map* innerMap = map->Find("key")->GetMap();
606   innerMap->Insert( "subkey", 5.f );
607
608   DALI_TEST_CHECK( NULL != map->Find("key")->GetMap()->Find("subkey") );
609   DALI_TEST_EQUALS( 5.f, map->Find("key")->GetMap()->Find("subkey")->Get<float>(), TEST_LOCATION);
610   END_TEST;
611 }
612
613 int UtcDaliHandleSetProperty01(void)
614 {
615   tet_infoline("Positive Test Dali::Handle::SetProperty()");
616   TestApplication application;
617
618   Actor actor = Actor::New();
619   DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
620
621   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
622   // flush the queue and render once
623   application.SendNotification();
624   application.Render();
625   DALI_TEST_CHECK( ParentOrigin::CENTER == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
626   END_TEST;
627 }
628
629 int UtcDaliHandleSetProperty02(void)
630 {
631   tet_infoline("Positive Test Dali::Handle::SetProperty()");
632   TestApplication application;
633
634   Actor actor = Actor::New();
635
636   DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
637
638   // World position is not writable so this is a no-op and should not crash
639   actor.SetProperty( Actor::Property::WORLD_POSITION, Vector3(1,2,3) );
640
641   END_TEST;
642 }
643
644 int UtcDaliHandleRegisterProperty01(void)
645 {
646   tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
647   TestApplication application;
648
649   Stage stage = Stage::GetCurrent();
650
651   Actor actor = Actor::New();
652   stage.Add( actor );
653
654   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
655
656   application.SendNotification();
657   application.Render();
658
659   Property::Index index1 = actor.RegisterProperty( "MyProperty", Vector3::ONE );
660
661   application.SendNotification();
662   application.Render();
663
664   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION );
665   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
666
667   // No new property should be registered when we call the below function
668   Property::Index index2 = actor.RegisterProperty( "MyProperty", Vector3::ZAXIS );
669
670   application.SendNotification();
671   application.Render();
672
673
674   DALI_TEST_EQUALS( index1, index2, TEST_LOCATION ); // We should have the same index as per the first registration
675   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION ); // Property count should be the same
676   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index2 ), Vector3::ZAXIS, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
677
678   END_TEST;
679 }
680
681 int UtcDaliHandleRegisterProperty02(void)
682 {
683   tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key");
684   TestApplication application;
685
686   Stage stage = Stage::GetCurrent();
687
688   Actor actor = Actor::New();
689   stage.Add( actor );
690
691   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
692
693   application.SendNotification();
694   application.Render();
695
696   Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
697   Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
698
699   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
700   const float withFlake(99.f);
701
702   Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
703   Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
704   Property::Index index3 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
705
706   application.SendNotification();
707   application.Render();
708
709   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION );
710   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
711   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), testColor, TEST_LOCATION );
712   DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), withFlake, TEST_LOCATION );
713
714   // No new property should be registered when we call the below functions
715   Property::Index testIndex2 = actor.RegisterProperty( "iceCream", 2200.f );
716   Property::Index testIndex1 = actor.RegisterProperty( "sideColor", Color::BLACK );
717   application.SendNotification();
718   application.Render();
719
720   DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION ); // We should have the same index as per the first registration
721   DALI_TEST_EQUALS( index3, testIndex2, TEST_LOCATION ); // We should have the same index as per the first registration
722   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION ); // Property count should be the same
723   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), Color::BLACK, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
724   DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), 2200.f, TEST_LOCATION );
725
726   END_TEST;
727 }
728
729
730
731 int UtcDaliHandleGetProperty(void)
732 {
733   tet_infoline("Positive Test Dali::Handle::GetProperty()");
734   TestApplication application;
735
736   Actor actor = Actor::New();
737
738   DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN   ).Get<Vector3>() );
739   DALI_TEST_CHECK( AnchorPoint::CENTER    == actor.GetProperty( Actor::Property::ANCHOR_POINT    ).Get<Vector3>() );
740   DALI_TEST_CHECK( Vector3::ZERO          == actor.GetProperty( Actor::Property::SIZE            ).Get<Vector3>() );
741   DALI_TEST_CHECK( Vector3::ZERO          == actor.GetProperty( Actor::Property::POSITION        ).Get<Vector3>() );
742   DALI_TEST_CHECK( Vector3::ONE           == actor.GetProperty( Actor::Property::SCALE           ).Get<Vector3>() );
743   DALI_TEST_CHECK( true                   == actor.GetProperty( Actor::Property::VISIBLE         ).Get<bool>() );
744   DALI_TEST_CHECK( Color::WHITE           == actor.GetProperty( Actor::Property::COLOR           ).Get<Vector4>() );
745   END_TEST;
746 }
747
748 int UtcDaliHandleDownCast(void)
749 {
750   TestApplication application;
751   tet_infoline("Testing Dali::Handle::DownCast()");
752
753   Actor actor = Actor::New();
754
755   BaseHandle baseHandle = actor;
756
757   Handle handle = Handle::DownCast(baseHandle);
758
759   DALI_TEST_CHECK( handle );
760
761   baseHandle = BaseHandle();
762
763   handle = Handle::DownCast(baseHandle);
764
765   DALI_TEST_CHECK( !handle );
766
767   END_TEST;
768 }
769
770 int UtcDaliHandleDownCastNegative(void)
771 {
772   TestApplication application;
773
774   // BaseObject is NOT an Object, so this DownCast should fail
775   BaseHandle handle( new BaseObjectType );
776   Handle customHandle1 = Handle::DownCast( handle );
777   DALI_TEST_CHECK( ! customHandle1 );
778
779   // A DownCast on an empty handle will also fail
780   Handle empty;
781   Handle customHandle2 = Handle::DownCast( empty );
782   DALI_TEST_CHECK( ! customHandle2 );
783   END_TEST;
784 }
785
786 int UtcDaliHandleGetPropertyIndices(void)
787 {
788   TestApplication application;
789   Property::IndexContainer indices;
790
791   // Actor
792   Actor actor = Actor::New();
793   actor.GetPropertyIndices( indices );
794   int numDefaultProperties = indices.Size();
795   DALI_TEST_CHECK( numDefaultProperties > 0 );
796   DALI_TEST_EQUALS( numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION );
797
798   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
799   const float withFlake(99.f);
800
801   Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
802   Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
803
804   actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
805   DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
806   actor.RegisterProperty( "MyPropertyTwo", 1234 );
807   Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
808   actor.RegisterProperty( "MyPropertyThree", Vector2(.2f,.7f) );
809
810   actor.GetPropertyIndices( indices );
811
812   DALI_TEST_EQUALS( indices.Size(), numDefaultProperties + 5, TEST_LOCATION );
813   DALI_TEST_EQUALS( indices[indices.Size()-2], index4, TEST_LOCATION );
814
815   END_TEST;
816 }
817
818 int UtcDaliHandleRegisterPropertyTypes(void)
819 {
820   TestApplication application;
821
822   struct PropertyTypeAnimatable
823   {
824     const char * name;
825     Property::Value value;
826     bool animatable;
827   };
828
829   Property::Array array;
830   Property::Map map;
831
832   PropertyTypeAnimatable properties[] =
833   {
834     { "Property::BOOLEAN",          true,              true  },
835     { "Property::FLOAT",            1.0f,              true  },
836     { "Property::INTEGER",          1,                 true  },
837     { "Property::VECTOR2",          Vector2::ONE,      true  },
838     { "Property::VECTOR3",          Vector3::ONE,      true  },
839     { "Property::VECTOR4",          Vector4::ONE,      true  },
840     { "Property::MATRIX3",          Matrix3::IDENTITY, true  },
841     { "Property::MATRIX",           Matrix::IDENTITY,  true  },
842     { "Property::RECTANGLE",        Rect<int>(),       false },
843     { "Property::ROTATION",         AngleAxis(),       true  },
844     { "Property::STRING",           std::string("Me"), false },
845     { "Property::ARRAY",            array,             false },
846     { "Property::MAP",              map,               false },
847   };
848
849   unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
850
851   for ( unsigned int i = 0; i < numOfProperties; ++i )
852   {
853     tet_printf( "Testing: %s\n", properties[i].name );
854
855     bool exception = false;
856     try
857     {
858       Actor actor = Actor::New();
859       actor.RegisterProperty( "manFromDelmonte",   properties[i].value );
860     }
861     catch (Dali::DaliException& e)
862     {
863       exception = true;
864     }
865
866     DALI_TEST_CHECK( properties[i].animatable != exception );
867   }
868   END_TEST;
869 }
870
871 int UtcDaliHandleCustomProperty(void)
872 {
873   TestApplication application;
874
875   Handle handle = Handle::New();
876
877   float startValue(1.0f);
878   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
879   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
880
881   application.SendNotification();
882   application.Render(0);
883   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
884   application.Render(0);
885   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
886
887   handle.SetProperty( index, 5.0f );
888
889   application.SendNotification();
890   application.Render(0);
891   DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
892   application.Render(0);
893   DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
894   END_TEST;
895 }
896
897 int UtcDaliHandleCustomPropertyNone(void)
898 {
899   TestApplication application;
900
901   Handle handle = Handle::New();
902
903   Property::Value value( Property::NONE );
904   Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
905
906   // Negative test i.e. setting a property of type NONE is meaningless
907   handle.SetProperty( index, 5.0f );
908
909   DALI_TEST_CHECK( true ); // got here without crashing
910
911   END_TEST;
912 }
913
914 int UtcDaliHandleCustomPropertyIntToFloat(void)
915 {
916   TestApplication application;
917
918   Handle handle = Handle::New();
919
920   float startValue(5.0f);
921   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
922   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
923
924   application.SendNotification();
925   application.Render(0);
926   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
927
928   handle.SetProperty( index, int(1) );
929
930   application.SendNotification();
931   application.Render(0);
932   DALI_TEST_CHECK( handle.GetProperty<float>(index) == 1.0f );
933   END_TEST;
934 }
935
936 int UtcDaliHandleCustomPropertyFloatToInt(void)
937 {
938   TestApplication application;
939
940   Handle handle = Handle::New();
941
942   int startValue(5);
943   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
944   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
945
946   application.SendNotification();
947   application.Render(0);
948   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
949
950   handle.SetProperty( index, float(1.5) );
951
952   application.SendNotification();
953   application.Render(0);
954   DALI_TEST_CHECK( handle.GetProperty<int>(index) == 1 );
955   END_TEST;
956 }
957
958 int UtcDaliHandleCustomPropertyInvalidToRect(void)
959 {
960   TestApplication application;
961
962   Handle handle = Handle::New();
963
964   Rect<int> startValue(1,2,3,4);
965   Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
966   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
967
968   application.SendNotification();
969   application.Render(0);
970   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
971
972   // Negative test i.e. there is no conversion from float to Rect
973   handle.SetProperty( index, float(1.5) );
974
975   application.SendNotification();
976   application.Render(0);
977   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
978
979   // Positive test (sanity check)
980   Rect<int> endValue(5,6,7,8);
981   handle.SetProperty( index, endValue );
982   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
983
984   application.SendNotification();
985   application.Render(0);
986   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
987
988   END_TEST;
989 }
990
991 int UtcDaliHandleCustomPropertyInvalidToString(void)
992 {
993   TestApplication application;
994
995   Handle handle = Handle::New();
996
997   std::string startValue( "Libraries gave us power" );
998   Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
999   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1000
1001   application.SendNotification();
1002   application.Render(0);
1003   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1004
1005   // No conversion from Vector3 to std::string, therefore this should be a NOOP
1006   handle.SetProperty( index, Vector3(1,2,3) );
1007
1008   application.SendNotification();
1009   application.Render(0);
1010   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1011
1012   // Positive test (sanity check)
1013   std::string endValue( "Then work came and made us free" );
1014   handle.SetProperty( index, endValue );
1015   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
1016
1017   application.SendNotification();
1018   application.Render(0);
1019   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
1020
1021   END_TEST;
1022 }
1023
1024 int UtcDaliHandleCustomPropertyInvalidToArray(void)
1025 {
1026   TestApplication application;
1027
1028   Handle handle = Handle::New();
1029
1030   Property::Value value( Property::ARRAY );
1031   std::string startValue( "The future teaches you to be alone" );
1032   value.GetArray()->PushBack( startValue );
1033
1034   Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
1035   Property::Array check1 = handle.GetProperty< Property::Array >( index );
1036   DALI_TEST_EQUALS( check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1037
1038   application.SendNotification();
1039   application.Render(0);
1040   Property::Array check2 = handle.GetProperty< Property::Array >( index );
1041   DALI_TEST_EQUALS( check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1042
1043   // No conversion from int to ARRAY, therefore this should be a NOOP
1044   handle.SetProperty( index, int(2) );
1045
1046   application.SendNotification();
1047   application.Render(0);
1048   Property::Array check3 = handle.GetProperty< Property::Array >( index );
1049   DALI_TEST_EQUALS( check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1050
1051   // Positive test (sanity check)
1052   Property::Value value2(Property::ARRAY);
1053   std::string endValue( "The present to be afraid and cold" );
1054   value2.GetArray()->PushBack( endValue );
1055   handle.SetProperty( index, value2 );
1056
1057   Property::Array check4 = handle.GetProperty< Property::Array >( index );
1058   DALI_TEST_EQUALS( check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
1059
1060   application.SendNotification();
1061   application.Render(0);
1062   Property::Array check5 = handle.GetProperty< Property::Array >( index );
1063   DALI_TEST_EQUALS( check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
1064
1065   END_TEST;
1066 }
1067
1068 int UtcDaliHandleCustomPropertyInvalidToMap(void)
1069 {
1070   TestApplication application;
1071
1072   Handle handle = Handle::New();
1073
1074   Property::Value value( Property::MAP );
1075   std::string startValue( "Culture sucks down words" );
1076   value.GetMap()->Insert( "1", startValue );
1077
1078   Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE );
1079   Property::Value* check1 = handle.GetProperty< Property::Map >( index ).Find("1");
1080   DALI_TEST_CHECK( NULL != check1 );
1081
1082   // No conversion from float to MAP, therefore this should be a NOOP
1083   handle.SetProperty( index, float(3.0) );
1084
1085   // Positive test (sanity check)
1086   Property::Value value2( Property::MAP );
1087   std::string endValue( "Itemise loathing and feed yourself smiles" );
1088   value.GetMap()->Insert( "1", endValue );
1089   handle.SetProperty( index, value2 );
1090
1091   END_TEST;
1092 }
1093
1094 int UtcDaliHandleCustomPropertyInvalidToExtents(void)
1095 {
1096   TestApplication application;
1097
1098   Handle handle = Handle::New();
1099
1100   Extents startValue(1,2,3,4);
1101   Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1102   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1103
1104   application.SendNotification();
1105   application.Render(0);
1106   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1107
1108   // Negative test i.e. there is no conversion from float to Extents
1109   handle.SetProperty( index, float(1.5) );
1110
1111   application.SendNotification();
1112   application.Render(0);
1113   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1114
1115   // Positive test (sanity check)
1116   Extents endValue(5,6,7,8);
1117   handle.SetProperty( index, endValue );
1118   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
1119
1120   application.SendNotification();
1121   application.Render(0);
1122   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
1123
1124   END_TEST;
1125 }
1126
1127 int UtcDaliHandleCustomPropertyInvalidToBool(void)
1128 {
1129   TestApplication application;
1130
1131   Handle handle = Handle::New();
1132
1133   bool startValue(true);
1134   Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1135   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1136
1137   application.SendNotification();
1138   application.Render(0);
1139   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1140
1141   // Negative test i.e. there is no conversion from float to bool
1142   handle.SetProperty( index, float(0.0) );
1143
1144   application.SendNotification();
1145   application.Render(0);
1146   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1147
1148   // Positive test (sanity check)
1149   bool endValue(false);
1150   handle.SetProperty( index, endValue );
1151   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
1152
1153   application.SendNotification();
1154   application.Render(0);
1155   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
1156
1157   END_TEST;
1158 }
1159
1160 int UtcDaliHandleCustomPropertyInvalidToInt(void)
1161 {
1162   TestApplication application;
1163
1164   Handle handle = Handle::New();
1165
1166   int startValue(5);
1167   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1168   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1169
1170   application.SendNotification();
1171   application.Render(0);
1172   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1173
1174   // Negative test i.e. there is no conversion from Vector3 to int
1175   handle.SetProperty( index, Vector3(1,2,3) );
1176
1177   application.SendNotification();
1178   application.Render(0);
1179   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1180   END_TEST;
1181 }
1182
1183 int UtcDaliHandleCustomPropertyInvalidToFloat(void)
1184 {
1185   TestApplication application;
1186
1187   Handle handle = Handle::New();
1188
1189   float startValue(5.0);
1190   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1191   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1192
1193   application.SendNotification();
1194   application.Render(0);
1195   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1196
1197   // Negative test i.e. there is no conversion from Vector3 to float
1198   handle.SetProperty( index, Vector3(1,2,3) );
1199
1200   application.SendNotification();
1201   application.Render(0);
1202   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1203   END_TEST;
1204 }
1205
1206 int UtcDaliHandleCustomPropertyInvalidToRotation(void)
1207 {
1208   TestApplication application;
1209
1210   Handle handle = Handle::New();
1211
1212   Quaternion startValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1213   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1214   DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1215
1216   application.SendNotification();
1217   application.Render(0);
1218   DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1219
1220   // Negative test i.e. there is no conversion from float to Quaternion
1221   handle.SetProperty( index, float(7.0) );
1222
1223   application.SendNotification();
1224   application.Render(0);
1225   DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1226
1227   // Positive test (sanity check)
1228   Quaternion endValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1229   handle.SetProperty( index, endValue );
1230   DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == endValue );
1231
1232   END_TEST;
1233 }
1234
1235 int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
1236 {
1237   TestApplication application;
1238
1239   Handle handle = Handle::New();
1240
1241   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1242   Matrix startValue(rotation);
1243   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1244   DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1245
1246   application.SendNotification();
1247   application.Render(0);
1248   DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1249
1250   // Negative test i.e. there is no conversion from float to Matrix
1251   handle.SetProperty( index, float(7.0) );
1252
1253   application.SendNotification();
1254   application.Render(0);
1255   DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1256
1257   // Positive test (sanity check)
1258   Quaternion endRotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1259   Matrix endValue(endRotation);
1260   handle.SetProperty( index, endValue );
1261   DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == endValue );
1262
1263   END_TEST;
1264 }
1265
1266 int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
1267 {
1268   TestApplication application;
1269
1270   Handle handle = Handle::New();
1271
1272   Matrix3 startValue(11,12,13,
1273                      21,22,23,
1274                      31,32,33);
1275
1276   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1277   DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1278
1279   application.SendNotification();
1280   application.Render(0);
1281   DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1282
1283   // Negative test i.e. there is no conversion from float to Matrix3
1284   handle.SetProperty( index, float(7.0) );
1285
1286   application.SendNotification();
1287   application.Render(0);
1288   DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1289
1290   // Positive test (sanity check)
1291   Matrix3 endValue(31,32,33,
1292                    21,22,23,
1293                    11,12,13);
1294   handle.SetProperty( index, endValue );
1295   DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == endValue );
1296
1297   END_TEST;
1298 }
1299
1300 int UtcDaliHandleWeightNew(void)
1301 {
1302   TestApplication application;
1303
1304   Handle handle = WeightObject::New();
1305   DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
1306
1307   // process the message so scene object is added to update manager
1308   application.SendNotification();
1309   application.Render(0);
1310
1311   // no message to release scene object in this scenario
1312
1313   END_TEST;
1314 }
1315
1316 int UtcDaliHandleWeightNew2(void)
1317 {
1318   TestApplication application;
1319
1320   // scope for the weight object
1321   {
1322     Handle handle = WeightObject::New();
1323     DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
1324
1325     // process the message so scene object is added to update manager
1326     application.SendNotification();
1327     application.Render(0);
1328   }
1329   // handle out of scope so object gets destroyed
1330   // process the message so update manager destroys the scene object
1331   application.SendNotification();
1332   application.Render(0);
1333
1334   END_TEST;
1335 }
1336
1337 int UtcDaliHandleSetTypeInfo(void)
1338 {
1339   TestApplication application;
1340   TypeRegistry typeRegistry = TypeRegistry::Get();
1341
1342   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
1343   DALI_TEST_CHECK( typeInfo );
1344
1345   Actor actor = Actor::DownCast(typeInfo.CreateInstance());
1346   DALI_TEST_CHECK( actor );
1347
1348   DevelHandle::SetTypeInfo(actor, typeInfo);
1349
1350   TypeInfo newTypeInfo;
1351   bool success = actor.GetTypeInfo( newTypeInfo );
1352   DALI_TEST_CHECK( success );
1353
1354   DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
1355   DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
1356
1357   END_TEST;
1358 }
1359
1360 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
1361 {
1362   TestApplication application;
1363
1364   tet_infoline( "Create a custom property and set the value ensuring it can be retrieved synchronously" );
1365
1366   Actor actor = Actor::New();
1367   Stage::GetCurrent().Add( actor );
1368
1369   tet_infoline( "Create the custom property with an initial value" );
1370   float startValue(1.0f);
1371   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
1372   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), startValue, TEST_LOCATION );
1373
1374   tet_infoline( "Set the value, retrieve it and ensure both the synchronous and the async version work" );
1375   actor.SetProperty( index, 5.0f );
1376   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
1377   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
1378
1379   tet_infoline( "Render and retrieve values again" );
1380   application.SendNotification();
1381   application.Render(0);
1382
1383   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
1384   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 5.0f, TEST_LOCATION );
1385
1386   END_TEST;
1387 }
1388
1389 int UtcDaliHandleCustomPropertyGetType(void)
1390 {
1391   TestApplication application;
1392
1393   tet_infoline( "Create a custom property and retrieve its type" );
1394
1395   Handle handle = Handle::New();
1396   Property::Index index = handle.RegisterProperty( "testProperty",  1.0f );
1397   DALI_TEST_EQUALS( handle.GetPropertyType( index ), Property::FLOAT, TEST_LOCATION );
1398
1399   END_TEST;
1400 }
1401
1402 int UtcDaliHandleCustomPropertyAccessMode(void)
1403 {
1404   TestApplication application;
1405
1406   tet_infoline( "Create a custom property and retrieve whether it's animatable etc." );
1407
1408   Handle handle = Handle::New();
1409   Property::Index index = handle.RegisterProperty( "testProperty",  1.0f );
1410   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), true, TEST_LOCATION );
1411   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1412
1413   index = handle.RegisterProperty( "testProperty2", 1.0f, Property::READ_ONLY );
1414   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1415   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), false, TEST_LOCATION );
1416
1417   index = handle.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1418   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1419   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1420
1421   END_TEST;
1422 }
1423
1424 int UtcDaliHandleGetCurrentProperty(void)
1425 {
1426   TestApplication application;
1427
1428   tet_infoline( "Get a default and non-animatable custom property using the GetCurrentProperty API" );
1429
1430   Actor actor = Actor::New();
1431   Stage::GetCurrent().Add( actor );
1432   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
1433
1434   Property::Index index = actor.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1435   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 1.0f, TEST_LOCATION );
1436   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 1.0f, TEST_LOCATION );
1437
1438   actor.SetProperty( index, 2.0f );
1439   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 2.0f, TEST_LOCATION );
1440   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 2.0f, TEST_LOCATION );
1441
1442   END_TEST;
1443 }
1444
1445 int UtcDaliHandleDoesCustomPropertyExistP1(void)
1446 {
1447   TestApplication application; // Needs type registry
1448
1449   tet_infoline( "Test if a registered custom property exists on object" );
1450
1451   Actor actor = Actor::New();
1452   auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1453
1454   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex ), true, TEST_LOCATION );
1455   END_TEST;
1456 }
1457
1458 int UtcDaliHandleDoesCustomPropertyExistN1(void)
1459 {
1460   TestApplication application; // Needs type registry
1461
1462   tet_infoline( "Test if a registered custom property does not exist on object" );
1463
1464   Actor actor = Actor::New();
1465   auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1466
1467   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex+1 ), false, TEST_LOCATION );
1468   END_TEST;
1469 }
1470
1471 int UtcDaliHandleDoesCustomPropertyExistN2(void)
1472 {
1473   TestApplication application; // Needs type registry
1474
1475   tet_infoline( "Test that a default property does not show as a custom property on object" );
1476
1477   Actor actor = Actor::New();
1478   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, Actor::Property::POSITION ), false, TEST_LOCATION );
1479   END_TEST;
1480 }
1481
1482 int UtcDaliHandleDoesCustomPropertyExistN3(void)
1483 {
1484   TestApplication application; // Needs type registry
1485
1486   tet_infoline( "Test that a child property does not exist on actor after parenting to container" );
1487   TypeRegistry typeRegistry = TypeRegistry::Get();
1488
1489   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1490
1491   const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1492   const char* CHILD_PROPERTY_NAME( "childProperty" );
1493
1494   ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1495
1496   auto container = Test::TestCustomActor::New();
1497   Stage::GetCurrent().Add( container );
1498   auto child = Actor::New();
1499   container.Add( child ); // Resolve child properties (if any)
1500
1501   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), false, TEST_LOCATION );
1502   END_TEST;
1503 }
1504
1505 int UtcDaliHandleDoesCustomPropertyExistP2(void)
1506 {
1507   TestApplication application; // Needs type registry
1508
1509   tet_infoline( "Test that a child property exists after being set" );
1510   TypeRegistry typeRegistry = TypeRegistry::Get();
1511
1512   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1513
1514   const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1515   const char* CHILD_PROPERTY_NAME( "childProperty" );
1516
1517   ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1518
1519   auto container = Test::TestCustomActor::New();
1520   Stage::GetCurrent().Add( container );
1521   auto child = Actor::New();
1522   container.Add( child ); // Resolve child properties (if any)
1523   child.SetProperty( CHILD_PROPERTY, 2 );
1524
1525   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1526   DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 2, TEST_LOCATION );
1527   END_TEST;
1528 }
1529
1530 int UtcDaliHandleDoesCustomPropertyExistP3(void)
1531 {
1532   TestApplication application; // Needs type registry
1533
1534   tet_infoline( "Test that a child property is re-indexed after registration, and that it exists" );
1535   TypeRegistry typeRegistry = TypeRegistry::Get();
1536
1537   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1538
1539   const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1540   const char* CHILD_PROPERTY_NAME( "childProperty" );
1541
1542   ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1543
1544   auto container = Test::TestCustomActor::New();
1545   Stage::GetCurrent().Add( container );
1546   auto child = Actor::New();
1547   child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
1548   container.Add( child ); // Resolve child properties (if any)
1549
1550   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1551   DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
1552   END_TEST;
1553 }
1554
1555 namespace
1556 {
1557
1558 struct PropertySetSignalCheck
1559 {
1560   PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
1561   : mSignalReceived(signalReceived),
1562     mValue(value)
1563   {
1564   }
1565
1566   void operator()(Handle& handle, Property::Index index, Property::Value value)
1567   {
1568     mSignalReceived = true;
1569     mValue = value;
1570   }
1571
1572   void Reset()
1573   {
1574     mSignalReceived = false;
1575   }
1576
1577   void CheckSignalReceived()
1578   {
1579     if (!mSignalReceived)
1580     {
1581       tet_printf("Expected Property Set signal was not received\n");
1582       tet_result(TET_FAIL);
1583     }
1584     else
1585     {
1586       tet_result(TET_PASS);
1587     }
1588   }
1589
1590   bool& mSignalReceived; // owned by individual tests
1591   Property::Value& mValue;
1592 };
1593
1594 } // anon namespace
1595
1596 int UtcDaliHandlePropertySetSignal01(void)
1597 {
1598   TestApplication app;
1599
1600   bool signalReceived(false);
1601   Property::Value value;
1602   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1603
1604   tet_infoline( "Test that setting a default property triggers a signal" );
1605
1606   auto actor = Actor::New();
1607   DevelHandle::PropertySetSignal(actor).Connect(&app, propertySetCheck);
1608
1609   actor.SetProperty( Actor::Property::POSITION, Vector3::XAXIS );
1610   propertySetCheck.CheckSignalReceived();
1611
1612   END_TEST;
1613 }
1614
1615
1616 int UtcDaliHandlePropertySetSignal02(void)
1617 {
1618   TestApplication app;
1619
1620   bool signalReceived(false);
1621   Property::Value value;
1622   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1623
1624   tet_infoline( "Test that setting a custom property triggers a signal" );
1625
1626   auto actor = Actor::New();
1627   DevelHandle::PropertySetSignal(actor).Connect(&app, propertySetCheck);
1628
1629   auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
1630   actor.SetProperty( propertyIndex, 5.0f );
1631   propertySetCheck.CheckSignalReceived();
1632   DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 5.0f ), 0.001f, TEST_LOCATION );
1633
1634   END_TEST;
1635 }
1636
1637 int UtcDaliHandlePropertySetSignal03(void)
1638 {
1639   TestApplication app;
1640   TypeRegistry typeRegistry = TypeRegistry::Get();
1641
1642   bool signalReceived(false);
1643   Property::Value value;
1644   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1645
1646   tet_infoline( "Test that setting a child property triggers a signal" );
1647
1648   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1649
1650   const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1651   const char* CHILD_PROPERTY_NAME( "childProperty" );
1652
1653   ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1654
1655   auto container = Test::TestCustomActor::New();
1656   Stage::GetCurrent().Add( container );
1657   auto child = Actor::New();
1658   child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
1659   DevelHandle::PropertySetSignal(child).Connect(&app, propertySetCheck);
1660   container.Add( child ); // Resolve child properties (if any)
1661
1662   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1663   DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
1664
1665   child.SetProperty( CHILD_PROPERTY, 29 );
1666   propertySetCheck.CheckSignalReceived();
1667   DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 29 ), TEST_LOCATION );
1668   END_TEST;
1669 }