Remove deprecated APIs in Tizen 3.0
[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::DRAW_MODE ) );
417   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE_FACTOR ) );
418
419   END_TEST;
420 }
421
422
423 int UtcDaliHandleGetPropertyType(void)
424 {
425   tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
426   TestApplication application;
427
428   Actor actor = Actor::New();
429   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::PARENT_ORIGIN ) );
430   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::ANCHOR_POINT ) );
431   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::SIZE ) );
432   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::POSITION ) );
433   DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( Actor::Property::ORIENTATION ) );
434   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::SCALE ) );
435   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( Actor::Property::VISIBLE ) );
436   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( Actor::Property::COLOR ) );
437
438   // Register some dynamic properties
439   Property::Index boolIndex     = actor.RegisterProperty( "boolProperty",      bool(true) );
440   Property::Index floatIndex    = actor.RegisterProperty( "floatProperty",     float(123.0f) );
441   Property::Index intIndex      = actor.RegisterProperty( "intProperty",       123 );
442   Property::Index vector2Index  = actor.RegisterProperty( "vector2Property",   Vector2(1.0f, 2.0f) );
443   Property::Index vector3Index  = actor.RegisterProperty( "vector3Property",   Vector3(1.0f, 2.0f, 3.0f) );
444   Property::Index vector4Index  = actor.RegisterProperty( "vector4Property",   Vector4(1.0f, 2.0f, 3.0f, 4.0f) );
445   Property::Index rotationIndex = actor.RegisterProperty( "rotationProperty",  AngleAxis(Degree(180.0f), Vector3::YAXIS) );
446
447   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( boolIndex ) );
448   DALI_TEST_CHECK( Property::FLOAT    == actor.GetPropertyType( floatIndex ) );
449   DALI_TEST_CHECK( Property::INTEGER  == actor.GetPropertyType( intIndex ) );
450   DALI_TEST_CHECK( Property::VECTOR2  == actor.GetPropertyType( vector2Index ) );
451   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( vector3Index ) );
452   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( vector4Index ) );
453   DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) );
454
455   // Non animatable properties
456   Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte",   std::string("yes"), Property::READ_WRITE);
457   Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE);
458   Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
459   Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
460   Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE);
461   Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE);
462   Property::Index nonAnimIntegerIndex = actor.RegisterProperty( "int", 0, Property::READ_WRITE);
463
464   DALI_TEST_CHECK( nonAnimStringIndex  != Property::INVALID_INDEX );
465   DALI_TEST_CHECK( nonAnimV2Index      != Property::INVALID_INDEX );
466   DALI_TEST_CHECK( nonAnimV3Index      != Property::INVALID_INDEX );
467   DALI_TEST_CHECK( nonAnimV4Index      != Property::INVALID_INDEX );
468   DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX );
469   DALI_TEST_CHECK( nonAnimFloatIndex   != Property::INVALID_INDEX );
470   DALI_TEST_CHECK( nonAnimIntegerIndex != Property::INVALID_INDEX );
471
472   DALI_TEST_CHECK( Property::STRING   == actor.GetPropertyType( nonAnimStringIndex ) );
473   DALI_TEST_CHECK( Property::VECTOR2  == actor.GetPropertyType( nonAnimV2Index ) );
474   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( nonAnimV3Index ) );
475   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( nonAnimV4Index ) );
476   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( nonAnimBooleanIndex ) );
477   DALI_TEST_CHECK( Property::FLOAT    == actor.GetPropertyType( nonAnimFloatIndex ) );
478   DALI_TEST_CHECK( Property::INTEGER  == actor.GetPropertyType( nonAnimIntegerIndex ) );
479
480   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) );
481   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) );
482   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV3Index ) );
483   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) );
484   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) );
485   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) );
486   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimIntegerIndex ) );
487
488   DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
489   DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get<Vector2>(), TEST_LOCATION );
490   DALI_TEST_EQUALS( Vector3(1.f, 2.f, 3.f) , actor.GetProperty( nonAnimV3Index ).Get<Vector3>(), TEST_LOCATION );
491   DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get<Vector4>(), TEST_LOCATION );
492   DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get<bool>(), TEST_LOCATION );
493   DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get<float>(), TEST_LOCATION );
494   DALI_TEST_EQUALS( 0, actor.GetProperty( nonAnimIntegerIndex ).Get<int>(), TEST_LOCATION );
495
496   END_TEST;
497 }
498
499 int UtcDaliHandleNonAnimatableProperties(void)
500 {
501   tet_infoline("Test Non Animatable Properties");
502   TestApplication application;
503
504   Actor actor = Actor::New();
505
506   Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE);
507
508   //// modify writable?
509   actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
510
511   DALI_TEST_CHECK( "yes"  == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
512
513   //// cannot modify read only?
514   Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY);
515
516   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
517   DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
518
519   actor.SetProperty( readonly, Property::Value(1.f) );
520   // trying to set a read-only property is a no-op
521
522   DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
523
524   /// animatable can be set
525   Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE);
526
527   DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
528   DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
529
530   actor.SetProperty( write_anim, Property::Value(1.f) );
531
532   //// animate a non animatable property throws
533   float durationSeconds(2.0f);
534   Animation animation = Animation::New(durationSeconds);
535   bool relativeValue(true);
536   try
537   {
538     animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
539   }
540   catch ( Dali::DaliException& e )
541   {
542     DALI_TEST_ASSERT( e, "Property type is not animatable", TEST_LOCATION );
543   }
544
545   DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
546
547   END_TEST;
548 }
549
550 int UtcDaliHandleNonAnimtableCompositeProperties(void)
551 {
552   tet_infoline("Test Non Animatable Composite Properties");
553   TestApplication application;
554
555   Actor actor = Actor::New();
556
557   Property::Value value(Property::ARRAY);
558   Property::Array* array = value.GetArray();
559   DALI_TEST_CHECK( array );
560
561   array->PushBack( Property::Value( 0.1f ) );
562   array->PushBack( "a string" );
563   array->PushBack( Property::Value( Vector3(1,2,3) ) );
564
565   DALI_TEST_EQUALS( 3u, array->Count(), TEST_LOCATION );
566
567   Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE );
568
569   Property::Value out = actor.GetProperty( propertyIndex );
570   Property::Array* outArray = out.GetArray();
571   DALI_TEST_CHECK( outArray != NULL );
572
573   DALI_TEST_CHECK( Property::FLOAT     == outArray->GetElementAt(0).GetType());
574   DALI_TEST_CHECK( Property::STRING    == outArray->GetElementAt(1).GetType());
575   DALI_TEST_CHECK( Property::VECTOR3   == outArray->GetElementAt(2).GetType());
576
577   DALI_TEST_EQUALS( 0.1f,            outArray->GetElementAt(0).Get<float>(),       TEST_LOCATION);
578   DALI_TEST_EQUALS( "a string",     outArray->GetElementAt(1).Get<std::string>(),  TEST_LOCATION);
579   DALI_TEST_EQUALS( Vector3(1,2,3), outArray->GetElementAt(2).Get<Vector3>(),      TEST_LOCATION);
580
581   // composite types not animatable
582   bool exception = false;
583   try
584   {
585     actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE);
586   }
587   catch (Dali::DaliException& e)
588   {
589     exception = true;
590     DALI_TEST_PRINT_ASSERT( e );
591   }
592
593   DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
594
595   // Map of maps
596   Property::Value mapOfMaps(Property::MAP);
597   Property::Map* map = mapOfMaps.GetMap();
598
599   map->Insert( "key", Property::Value(Property::MAP) );
600   map->Insert( "2key", "a string" );
601
602   DALI_TEST_EQUALS( "a string",  (*map)["2key"].Get<std::string>(),  TEST_LOCATION);
603
604   Property::Map* innerMap = map->Find("key")->GetMap();
605   innerMap->Insert( "subkey", 5.f );
606
607   DALI_TEST_CHECK( NULL != map->Find("key")->GetMap()->Find("subkey") );
608   DALI_TEST_EQUALS( 5.f, map->Find("key")->GetMap()->Find("subkey")->Get<float>(), TEST_LOCATION);
609   END_TEST;
610 }
611
612 int UtcDaliHandleSetProperty01(void)
613 {
614   tet_infoline("Positive Test Dali::Handle::SetProperty()");
615   TestApplication application;
616
617   Actor actor = Actor::New();
618   DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
619
620   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
621   // flush the queue and render once
622   application.SendNotification();
623   application.Render();
624   DALI_TEST_CHECK( ParentOrigin::CENTER == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
625   END_TEST;
626 }
627
628 int UtcDaliHandleSetProperty02(void)
629 {
630   tet_infoline("Positive Test Dali::Handle::SetProperty()");
631   TestApplication application;
632
633   Actor actor = Actor::New();
634
635   DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
636
637   // World position is not writable so this is a no-op and should not crash
638   actor.SetProperty( Actor::Property::WORLD_POSITION, Vector3(1,2,3) );
639
640   END_TEST;
641 }
642
643 int UtcDaliHandleRegisterProperty01(void)
644 {
645   tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
646   TestApplication application;
647
648   Stage stage = Stage::GetCurrent();
649
650   Actor actor = Actor::New();
651   stage.Add( actor );
652
653   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
654
655   application.SendNotification();
656   application.Render();
657
658   Property::Index index1 = actor.RegisterProperty( "MyProperty", Vector3::ONE );
659
660   application.SendNotification();
661   application.Render();
662
663   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION );
664   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
665
666   // No new property should be registered when we call the below function
667   Property::Index index2 = actor.RegisterProperty( "MyProperty", Vector3::ZAXIS );
668
669   application.SendNotification();
670   application.Render();
671
672
673   DALI_TEST_EQUALS( index1, index2, TEST_LOCATION ); // We should have the same index as per the first registration
674   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION ); // Property count should be the same
675   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index2 ), Vector3::ZAXIS, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
676
677   END_TEST;
678 }
679
680 int UtcDaliHandleRegisterProperty02(void)
681 {
682   tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key");
683   TestApplication application;
684
685   Stage stage = Stage::GetCurrent();
686
687   Actor actor = Actor::New();
688   stage.Add( actor );
689
690   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
691
692   application.SendNotification();
693   application.Render();
694
695   Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
696   Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
697
698   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
699   const float withFlake(99.f);
700
701   Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
702   Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
703   Property::Index index3 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
704
705   application.SendNotification();
706   application.Render();
707
708   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION );
709   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
710   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), testColor, TEST_LOCATION );
711   DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), withFlake, TEST_LOCATION );
712
713   // No new property should be registered when we call the below functions
714   Property::Index testIndex2 = actor.RegisterProperty( "iceCream", 2200.f );
715   Property::Index testIndex1 = actor.RegisterProperty( "sideColor", Color::BLACK );
716   application.SendNotification();
717   application.Render();
718
719   DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION ); // We should have the same index as per the first registration
720   DALI_TEST_EQUALS( index3, testIndex2, TEST_LOCATION ); // We should have the same index as per the first registration
721   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION ); // Property count should be the same
722   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), Color::BLACK, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
723   DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), 2200.f, TEST_LOCATION );
724
725   END_TEST;
726 }
727
728
729
730 int UtcDaliHandleGetProperty(void)
731 {
732   tet_infoline("Positive Test Dali::Handle::GetProperty()");
733   TestApplication application;
734
735   Actor actor = Actor::New();
736
737   DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN   ).Get<Vector3>() );
738   DALI_TEST_CHECK( AnchorPoint::CENTER    == actor.GetProperty( Actor::Property::ANCHOR_POINT    ).Get<Vector3>() );
739   DALI_TEST_CHECK( Vector3::ZERO          == actor.GetProperty( Actor::Property::SIZE            ).Get<Vector3>() );
740   DALI_TEST_CHECK( Vector3::ZERO          == actor.GetProperty( Actor::Property::POSITION        ).Get<Vector3>() );
741   DALI_TEST_CHECK( Vector3::ONE           == actor.GetProperty( Actor::Property::SCALE           ).Get<Vector3>() );
742   DALI_TEST_CHECK( true                   == actor.GetProperty( Actor::Property::VISIBLE         ).Get<bool>() );
743   DALI_TEST_CHECK( Color::WHITE           == actor.GetProperty( Actor::Property::COLOR           ).Get<Vector4>() );
744   END_TEST;
745 }
746
747 int UtcDaliHandleDownCast(void)
748 {
749   TestApplication application;
750   tet_infoline("Testing Dali::Handle::DownCast()");
751
752   Actor actor = Actor::New();
753
754   BaseHandle baseHandle = actor;
755
756   Handle handle = Handle::DownCast(baseHandle);
757
758   DALI_TEST_CHECK( handle );
759
760   baseHandle = BaseHandle();
761
762   handle = Handle::DownCast(baseHandle);
763
764   DALI_TEST_CHECK( !handle );
765
766   END_TEST;
767 }
768
769 int UtcDaliHandleDownCastNegative(void)
770 {
771   TestApplication application;
772
773   // BaseObject is NOT an Object, so this DownCast should fail
774   BaseHandle handle( new BaseObjectType );
775   Handle customHandle1 = Handle::DownCast( handle );
776   DALI_TEST_CHECK( ! customHandle1 );
777
778   // A DownCast on an empty handle will also fail
779   Handle empty;
780   Handle customHandle2 = Handle::DownCast( empty );
781   DALI_TEST_CHECK( ! customHandle2 );
782   END_TEST;
783 }
784
785 int UtcDaliHandleGetPropertyIndices(void)
786 {
787   TestApplication application;
788   Property::IndexContainer indices;
789
790   // Actor
791   Actor actor = Actor::New();
792   actor.GetPropertyIndices( indices );
793   int numDefaultProperties = indices.Size();
794   DALI_TEST_CHECK( numDefaultProperties > 0 );
795   DALI_TEST_EQUALS( numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION );
796
797   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
798   const float withFlake(99.f);
799
800   Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
801   Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
802
803   actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
804   DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
805   actor.RegisterProperty( "MyPropertyTwo", 1234 );
806   Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
807   actor.RegisterProperty( "MyPropertyThree", Vector2(.2f,.7f) );
808
809   actor.GetPropertyIndices( indices );
810
811   DALI_TEST_EQUALS( indices.Size(), numDefaultProperties + 5, TEST_LOCATION );
812   DALI_TEST_EQUALS( indices[indices.Size()-2], index4, TEST_LOCATION );
813
814   END_TEST;
815 }
816
817 int UtcDaliHandleRegisterPropertyTypes(void)
818 {
819   TestApplication application;
820
821   struct PropertyTypeAnimatable
822   {
823     const char * name;
824     Property::Value value;
825     bool animatable;
826   };
827
828   Property::Array array;
829   Property::Map map;
830
831   PropertyTypeAnimatable properties[] =
832   {
833     { "Property::BOOLEAN",          true,              true  },
834     { "Property::FLOAT",            1.0f,              true  },
835     { "Property::INTEGER",          1,                 true  },
836     { "Property::VECTOR2",          Vector2::ONE,      true  },
837     { "Property::VECTOR3",          Vector3::ONE,      true  },
838     { "Property::VECTOR4",          Vector4::ONE,      true  },
839     { "Property::MATRIX3",          Matrix3::IDENTITY, true  },
840     { "Property::MATRIX",           Matrix::IDENTITY,  true  },
841     { "Property::RECTANGLE",        Rect<int>(),       false },
842     { "Property::ROTATION",         AngleAxis(),       true  },
843     { "Property::STRING",           std::string("Me"), false },
844     { "Property::ARRAY",            array,             false },
845     { "Property::MAP",              map,               false },
846   };
847
848   unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
849
850   for ( unsigned int i = 0; i < numOfProperties; ++i )
851   {
852     tet_printf( "Testing: %s\n", properties[i].name );
853
854     bool exception = false;
855     try
856     {
857       Actor actor = Actor::New();
858       actor.RegisterProperty( "manFromDelmonte",   properties[i].value );
859     }
860     catch (Dali::DaliException& e)
861     {
862       exception = true;
863     }
864
865     DALI_TEST_CHECK( properties[i].animatable != exception );
866   }
867   END_TEST;
868 }
869
870 int UtcDaliHandleCustomProperty(void)
871 {
872   TestApplication application;
873
874   Handle handle = Handle::New();
875
876   float startValue(1.0f);
877   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
878   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
879
880   application.SendNotification();
881   application.Render(0);
882   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
883   application.Render(0);
884   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
885
886   handle.SetProperty( index, 5.0f );
887
888   application.SendNotification();
889   application.Render(0);
890   DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
891   application.Render(0);
892   DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
893   END_TEST;
894 }
895
896 int UtcDaliHandleCustomPropertyNone(void)
897 {
898   TestApplication application;
899
900   Handle handle = Handle::New();
901
902   Property::Value value( Property::NONE );
903   Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
904
905   // Negative test i.e. setting a property of type NONE is meaningless
906   handle.SetProperty( index, 5.0f );
907
908   DALI_TEST_CHECK( true ); // got here without crashing
909
910   END_TEST;
911 }
912
913 int UtcDaliHandleCustomPropertyIntToFloat(void)
914 {
915   TestApplication application;
916
917   Handle handle = Handle::New();
918
919   float startValue(5.0f);
920   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
921   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
922
923   application.SendNotification();
924   application.Render(0);
925   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
926
927   handle.SetProperty( index, int(1) );
928
929   application.SendNotification();
930   application.Render(0);
931   DALI_TEST_CHECK( handle.GetProperty<float>(index) == 1.0f );
932   END_TEST;
933 }
934
935 int UtcDaliHandleCustomPropertyFloatToInt(void)
936 {
937   TestApplication application;
938
939   Handle handle = Handle::New();
940
941   int startValue(5);
942   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
943   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
944
945   application.SendNotification();
946   application.Render(0);
947   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
948
949   handle.SetProperty( index, float(1.5) );
950
951   application.SendNotification();
952   application.Render(0);
953   DALI_TEST_CHECK( handle.GetProperty<int>(index) == 1 );
954   END_TEST;
955 }
956
957 int UtcDaliHandleCustomPropertyInvalidToRect(void)
958 {
959   TestApplication application;
960
961   Handle handle = Handle::New();
962
963   Rect<int> startValue(1,2,3,4);
964   Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
965   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
966
967   application.SendNotification();
968   application.Render(0);
969   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
970
971   // Negative test i.e. there is no conversion from float to Rect
972   handle.SetProperty( index, float(1.5) );
973
974   application.SendNotification();
975   application.Render(0);
976   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
977
978   // Positive test (sanity check)
979   Rect<int> endValue(5,6,7,8);
980   handle.SetProperty( index, endValue );
981   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
982
983   application.SendNotification();
984   application.Render(0);
985   DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
986
987   END_TEST;
988 }
989
990 int UtcDaliHandleCustomPropertyInvalidToString(void)
991 {
992   TestApplication application;
993
994   Handle handle = Handle::New();
995
996   std::string startValue( "Libraries gave us power" );
997   Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
998   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
999
1000   application.SendNotification();
1001   application.Render(0);
1002   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1003
1004   // No conversion from Vector3 to std::string, therefore this should be a NOOP
1005   handle.SetProperty( index, Vector3(1,2,3) );
1006
1007   application.SendNotification();
1008   application.Render(0);
1009   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1010
1011   // Positive test (sanity check)
1012   std::string endValue( "Then work came and made us free" );
1013   handle.SetProperty( index, endValue );
1014   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
1015
1016   application.SendNotification();
1017   application.Render(0);
1018   DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
1019
1020   END_TEST;
1021 }
1022
1023 int UtcDaliHandleCustomPropertyInvalidToArray(void)
1024 {
1025   TestApplication application;
1026
1027   Handle handle = Handle::New();
1028
1029   Property::Value value( Property::ARRAY );
1030   std::string startValue( "The future teaches you to be alone" );
1031   value.GetArray()->PushBack( startValue );
1032
1033   Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
1034   Property::Array check1 = handle.GetProperty< Property::Array >( index );
1035   DALI_TEST_EQUALS( check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1036
1037   application.SendNotification();
1038   application.Render(0);
1039   Property::Array check2 = handle.GetProperty< Property::Array >( index );
1040   DALI_TEST_EQUALS( check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1041
1042   // No conversion from int to ARRAY, therefore this should be a NOOP
1043   handle.SetProperty( index, int(2) );
1044
1045   application.SendNotification();
1046   application.Render(0);
1047   Property::Array check3 = handle.GetProperty< Property::Array >( index );
1048   DALI_TEST_EQUALS( check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1049
1050   // Positive test (sanity check)
1051   Property::Value value2(Property::ARRAY);
1052   std::string endValue( "The present to be afraid and cold" );
1053   value2.GetArray()->PushBack( endValue );
1054   handle.SetProperty( index, value2 );
1055
1056   Property::Array check4 = handle.GetProperty< Property::Array >( index );
1057   DALI_TEST_EQUALS( check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
1058
1059   application.SendNotification();
1060   application.Render(0);
1061   Property::Array check5 = handle.GetProperty< Property::Array >( index );
1062   DALI_TEST_EQUALS( check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
1063
1064   END_TEST;
1065 }
1066
1067 int UtcDaliHandleCustomPropertyInvalidToMap(void)
1068 {
1069   TestApplication application;
1070
1071   Handle handle = Handle::New();
1072
1073   Property::Value value( Property::MAP );
1074   std::string startValue( "Culture sucks down words" );
1075   value.GetMap()->Insert( "1", startValue );
1076
1077   Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE );
1078   Property::Value* check1 = handle.GetProperty< Property::Map >( index ).Find("1");
1079   DALI_TEST_CHECK( NULL != check1 );
1080
1081   // No conversion from float to MAP, therefore this should be a NOOP
1082   handle.SetProperty( index, float(3.0) );
1083
1084   // Positive test (sanity check)
1085   Property::Value value2( Property::MAP );
1086   std::string endValue( "Itemise loathing and feed yourself smiles" );
1087   value.GetMap()->Insert( "1", endValue );
1088   handle.SetProperty( index, value2 );
1089
1090   END_TEST;
1091 }
1092
1093 int UtcDaliHandleCustomPropertyInvalidToExtents(void)
1094 {
1095   TestApplication application;
1096
1097   Handle handle = Handle::New();
1098
1099   Extents startValue(1,2,3,4);
1100   Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1101   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1102
1103   application.SendNotification();
1104   application.Render(0);
1105   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1106
1107   // Negative test i.e. there is no conversion from float to Extents
1108   handle.SetProperty( index, float(1.5) );
1109
1110   application.SendNotification();
1111   application.Render(0);
1112   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1113
1114   // Positive test (sanity check)
1115   Extents endValue(5,6,7,8);
1116   handle.SetProperty( index, endValue );
1117   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
1118
1119   application.SendNotification();
1120   application.Render(0);
1121   DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
1122
1123   END_TEST;
1124 }
1125
1126 int UtcDaliHandleCustomPropertyInvalidToBool(void)
1127 {
1128   TestApplication application;
1129
1130   Handle handle = Handle::New();
1131
1132   bool startValue(true);
1133   Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1134   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1135
1136   application.SendNotification();
1137   application.Render(0);
1138   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1139
1140   // Negative test i.e. there is no conversion from float to bool
1141   handle.SetProperty( index, float(0.0) );
1142
1143   application.SendNotification();
1144   application.Render(0);
1145   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1146
1147   // Positive test (sanity check)
1148   bool endValue(false);
1149   handle.SetProperty( index, endValue );
1150   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
1151
1152   application.SendNotification();
1153   application.Render(0);
1154   DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
1155
1156   END_TEST;
1157 }
1158
1159 int UtcDaliHandleCustomPropertyInvalidToInt(void)
1160 {
1161   TestApplication application;
1162
1163   Handle handle = Handle::New();
1164
1165   int startValue(5);
1166   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1167   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1168
1169   application.SendNotification();
1170   application.Render(0);
1171   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1172
1173   // Negative test i.e. there is no conversion from Vector3 to int
1174   handle.SetProperty( index, Vector3(1,2,3) );
1175
1176   application.SendNotification();
1177   application.Render(0);
1178   DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1179   END_TEST;
1180 }
1181
1182 int UtcDaliHandleCustomPropertyInvalidToFloat(void)
1183 {
1184   TestApplication application;
1185
1186   Handle handle = Handle::New();
1187
1188   float startValue(5.0);
1189   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1190   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1191
1192   application.SendNotification();
1193   application.Render(0);
1194   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1195
1196   // Negative test i.e. there is no conversion from Vector3 to float
1197   handle.SetProperty( index, Vector3(1,2,3) );
1198
1199   application.SendNotification();
1200   application.Render(0);
1201   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1202   END_TEST;
1203 }
1204
1205 int UtcDaliHandleCustomPropertyInvalidToRotation(void)
1206 {
1207   TestApplication application;
1208
1209   Handle handle = Handle::New();
1210
1211   Quaternion startValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1212   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1213   DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1214
1215   application.SendNotification();
1216   application.Render(0);
1217   DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1218
1219   // Negative test i.e. there is no conversion from float to Quaternion
1220   handle.SetProperty( index, float(7.0) );
1221
1222   application.SendNotification();
1223   application.Render(0);
1224   DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1225
1226   // Positive test (sanity check)
1227   Quaternion endValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1228   handle.SetProperty( index, endValue );
1229   DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == endValue );
1230
1231   END_TEST;
1232 }
1233
1234 int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
1235 {
1236   TestApplication application;
1237
1238   Handle handle = Handle::New();
1239
1240   Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1241   Matrix startValue(rotation);
1242   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1243   DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1244
1245   application.SendNotification();
1246   application.Render(0);
1247   DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1248
1249   // Negative test i.e. there is no conversion from float to Matrix
1250   handle.SetProperty( index, float(7.0) );
1251
1252   application.SendNotification();
1253   application.Render(0);
1254   DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1255
1256   // Positive test (sanity check)
1257   Quaternion endRotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1258   Matrix endValue(endRotation);
1259   handle.SetProperty( index, endValue );
1260   DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == endValue );
1261
1262   END_TEST;
1263 }
1264
1265 int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
1266 {
1267   TestApplication application;
1268
1269   Handle handle = Handle::New();
1270
1271   Matrix3 startValue(11,12,13,
1272                      21,22,23,
1273                      31,32,33);
1274
1275   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
1276   DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1277
1278   application.SendNotification();
1279   application.Render(0);
1280   DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1281
1282   // Negative test i.e. there is no conversion from float to Matrix3
1283   handle.SetProperty( index, float(7.0) );
1284
1285   application.SendNotification();
1286   application.Render(0);
1287   DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1288
1289   // Positive test (sanity check)
1290   Matrix3 endValue(31,32,33,
1291                    21,22,23,
1292                    11,12,13);
1293   handle.SetProperty( index, endValue );
1294   DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == endValue );
1295
1296   END_TEST;
1297 }
1298
1299 int UtcDaliHandleWeightNew(void)
1300 {
1301   TestApplication application;
1302
1303   Handle handle = WeightObject::New();
1304   DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
1305
1306   // process the message so scene object is added to update manager
1307   application.SendNotification();
1308   application.Render(0);
1309
1310   // no message to release scene object in this scenario
1311
1312   END_TEST;
1313 }
1314
1315 int UtcDaliHandleWeightNew2(void)
1316 {
1317   TestApplication application;
1318
1319   // scope for the weight object
1320   {
1321     Handle handle = WeightObject::New();
1322     DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
1323
1324     // process the message so scene object is added to update manager
1325     application.SendNotification();
1326     application.Render(0);
1327   }
1328   // handle out of scope so object gets destroyed
1329   // process the message so update manager destroys the scene object
1330   application.SendNotification();
1331   application.Render(0);
1332
1333   END_TEST;
1334 }
1335
1336 int UtcDaliHandleSetTypeInfo(void)
1337 {
1338   TestApplication application;
1339   TypeRegistry typeRegistry = TypeRegistry::Get();
1340
1341   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
1342   DALI_TEST_CHECK( typeInfo );
1343
1344   Actor actor = Actor::DownCast(typeInfo.CreateInstance());
1345   DALI_TEST_CHECK( actor );
1346
1347   DevelHandle::SetTypeInfo(actor, typeInfo);
1348
1349   TypeInfo newTypeInfo;
1350   bool success = actor.GetTypeInfo( newTypeInfo );
1351   DALI_TEST_CHECK( success );
1352
1353   DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
1354   DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
1355
1356   END_TEST;
1357 }
1358
1359 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
1360 {
1361   TestApplication application;
1362
1363   tet_infoline( "Create a custom property and set the value ensuring it can be retrieved synchronously" );
1364
1365   Actor actor = Actor::New();
1366   Stage::GetCurrent().Add( actor );
1367
1368   tet_infoline( "Create the custom property with an initial value" );
1369   float startValue(1.0f);
1370   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
1371   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), startValue, TEST_LOCATION );
1372
1373   tet_infoline( "Set the value, retrieve it and ensure both the synchronous and the async version work" );
1374   actor.SetProperty( index, 5.0f );
1375   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
1376   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
1377
1378   tet_infoline( "Render and retrieve values again" );
1379   application.SendNotification();
1380   application.Render(0);
1381
1382   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
1383   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 5.0f, TEST_LOCATION );
1384
1385   END_TEST;
1386 }
1387
1388 int UtcDaliHandleCustomPropertyGetType(void)
1389 {
1390   TestApplication application;
1391
1392   tet_infoline( "Create a custom property and retrieve its type" );
1393
1394   Handle handle = Handle::New();
1395   Property::Index index = handle.RegisterProperty( "testProperty",  1.0f );
1396   DALI_TEST_EQUALS( handle.GetPropertyType( index ), Property::FLOAT, TEST_LOCATION );
1397
1398   END_TEST;
1399 }
1400
1401 int UtcDaliHandleCustomPropertyAccessMode(void)
1402 {
1403   TestApplication application;
1404
1405   tet_infoline( "Create a custom property and retrieve whether it's animatable etc." );
1406
1407   Handle handle = Handle::New();
1408   Property::Index index = handle.RegisterProperty( "testProperty",  1.0f );
1409   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), true, TEST_LOCATION );
1410   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1411
1412   index = handle.RegisterProperty( "testProperty2", 1.0f, Property::READ_ONLY );
1413   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1414   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), false, TEST_LOCATION );
1415
1416   index = handle.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1417   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1418   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1419
1420   END_TEST;
1421 }
1422
1423 int UtcDaliHandleGetCurrentProperty(void)
1424 {
1425   TestApplication application;
1426
1427   tet_infoline( "Get a default and non-animatable custom property using the GetCurrentProperty API" );
1428
1429   Actor actor = Actor::New();
1430   Stage::GetCurrent().Add( actor );
1431   DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
1432
1433   Property::Index index = actor.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1434   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 1.0f, TEST_LOCATION );
1435   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 1.0f, TEST_LOCATION );
1436
1437   actor.SetProperty( index, 2.0f );
1438   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 2.0f, TEST_LOCATION );
1439   DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 2.0f, TEST_LOCATION );
1440
1441   END_TEST;
1442 }
1443
1444 int UtcDaliHandleDoesCustomPropertyExistP1(void)
1445 {
1446   TestApplication application; // Needs type registry
1447
1448   tet_infoline( "Test if a registered custom property exists on object" );
1449
1450   Actor actor = Actor::New();
1451   auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1452
1453   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex ), true, TEST_LOCATION );
1454   END_TEST;
1455 }
1456
1457 int UtcDaliHandleDoesCustomPropertyExistN1(void)
1458 {
1459   TestApplication application; // Needs type registry
1460
1461   tet_infoline( "Test if a registered custom property does not exist on object" );
1462
1463   Actor actor = Actor::New();
1464   auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1465
1466   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex+1 ), false, TEST_LOCATION );
1467   END_TEST;
1468 }
1469
1470 int UtcDaliHandleDoesCustomPropertyExistN2(void)
1471 {
1472   TestApplication application; // Needs type registry
1473
1474   tet_infoline( "Test that a default property does not show as a custom property on object" );
1475
1476   Actor actor = Actor::New();
1477   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, Actor::Property::POSITION ), false, TEST_LOCATION );
1478   END_TEST;
1479 }
1480
1481 int UtcDaliHandleDoesCustomPropertyExistN3(void)
1482 {
1483   TestApplication application; // Needs type registry
1484
1485   tet_infoline( "Test that a child property does not exist on actor after parenting to container" );
1486   TypeRegistry typeRegistry = TypeRegistry::Get();
1487
1488   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1489
1490   const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1491   const char* CHILD_PROPERTY_NAME( "childProperty" );
1492
1493   ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1494
1495   auto container = Test::TestCustomActor::New();
1496   Stage::GetCurrent().Add( container );
1497   auto child = Actor::New();
1498   container.Add( child ); // Resolve child properties (if any)
1499
1500   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), false, TEST_LOCATION );
1501   END_TEST;
1502 }
1503
1504 int UtcDaliHandleDoesCustomPropertyExistP2(void)
1505 {
1506   TestApplication application; // Needs type registry
1507
1508   tet_infoline( "Test that a child property exists after being set" );
1509   TypeRegistry typeRegistry = TypeRegistry::Get();
1510
1511   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1512
1513   const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1514   const char* CHILD_PROPERTY_NAME( "childProperty" );
1515
1516   ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1517
1518   auto container = Test::TestCustomActor::New();
1519   Stage::GetCurrent().Add( container );
1520   auto child = Actor::New();
1521   container.Add( child ); // Resolve child properties (if any)
1522   child.SetProperty( CHILD_PROPERTY, 2 );
1523
1524   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1525   DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 2, TEST_LOCATION );
1526   END_TEST;
1527 }
1528
1529 int UtcDaliHandleDoesCustomPropertyExistP3(void)
1530 {
1531   TestApplication application; // Needs type registry
1532
1533   tet_infoline( "Test that a child property is re-indexed after registration, and that it exists" );
1534   TypeRegistry typeRegistry = TypeRegistry::Get();
1535
1536   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1537
1538   const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1539   const char* CHILD_PROPERTY_NAME( "childProperty" );
1540
1541   ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1542
1543   auto container = Test::TestCustomActor::New();
1544   Stage::GetCurrent().Add( container );
1545   auto child = Actor::New();
1546   child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
1547   container.Add( child ); // Resolve child properties (if any)
1548
1549   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1550   DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
1551   END_TEST;
1552 }
1553
1554 namespace
1555 {
1556
1557 struct PropertySetSignalCheck
1558 {
1559   PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
1560   : mSignalReceived(signalReceived),
1561     mValue(value)
1562   {
1563   }
1564
1565   void operator()(Handle& handle, Property::Index index, Property::Value value)
1566   {
1567     mSignalReceived = true;
1568     mValue = value;
1569   }
1570
1571   void Reset()
1572   {
1573     mSignalReceived = false;
1574   }
1575
1576   void CheckSignalReceived()
1577   {
1578     if (!mSignalReceived)
1579     {
1580       tet_printf("Expected Property Set signal was not received\n");
1581       tet_result(TET_FAIL);
1582     }
1583     else
1584     {
1585       tet_result(TET_PASS);
1586     }
1587   }
1588
1589   bool& mSignalReceived; // owned by individual tests
1590   Property::Value& mValue;
1591 };
1592
1593 } // anon namespace
1594
1595 int UtcDaliHandlePropertySetSignal01(void)
1596 {
1597   TestApplication app;
1598
1599   bool signalReceived(false);
1600   Property::Value value;
1601   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1602
1603   tet_infoline( "Test that setting a default property triggers a signal" );
1604
1605   auto actor = Actor::New();
1606   DevelHandle::PropertySetSignal(actor).Connect(&app, propertySetCheck);
1607
1608   actor.SetProperty( Actor::Property::POSITION, Vector3::XAXIS );
1609   propertySetCheck.CheckSignalReceived();
1610
1611   END_TEST;
1612 }
1613
1614
1615 int UtcDaliHandlePropertySetSignal02(void)
1616 {
1617   TestApplication app;
1618
1619   bool signalReceived(false);
1620   Property::Value value;
1621   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1622
1623   tet_infoline( "Test that setting a custom property triggers a signal" );
1624
1625   auto actor = Actor::New();
1626   DevelHandle::PropertySetSignal(actor).Connect(&app, propertySetCheck);
1627
1628   auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
1629   actor.SetProperty( propertyIndex, 5.0f );
1630   propertySetCheck.CheckSignalReceived();
1631   DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 5.0f ), 0.001f, TEST_LOCATION );
1632
1633   END_TEST;
1634 }
1635
1636 int UtcDaliHandlePropertySetSignal03(void)
1637 {
1638   TestApplication app;
1639   TypeRegistry typeRegistry = TypeRegistry::Get();
1640
1641   bool signalReceived(false);
1642   Property::Value value;
1643   PropertySetSignalCheck propertySetCheck(signalReceived, value);
1644
1645   tet_infoline( "Test that setting a child property triggers a signal" );
1646
1647   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1648
1649   const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1650   const char* CHILD_PROPERTY_NAME( "childProperty" );
1651
1652   ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1653
1654   auto container = Test::TestCustomActor::New();
1655   Stage::GetCurrent().Add( container );
1656   auto child = Actor::New();
1657   child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
1658   DevelHandle::PropertySetSignal(child).Connect(&app, propertySetCheck);
1659   container.Add( child ); // Resolve child properties (if any)
1660
1661   DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1662   DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
1663
1664   child.SetProperty( CHILD_PROPERTY, 29 );
1665   propertySetCheck.CheckSignalReceived();
1666   DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 29 ), TEST_LOCATION );
1667   END_TEST;
1668 }