Revert "[Tizen] Move DevelHandle::GetCurrentProperty to public"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Handle.cpp
1 /*
2  * Copyright (c) 2017 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 <mesh-builder.h>
26
27 using namespace Dali;
28
29 void handle_test_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void handle_test_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 namespace
40 {
41
42 /// Allows the creation of a BaseObject
43 class BaseObjectType : public BaseObject
44 {
45 public:
46   BaseObjectType()
47   {
48   }
49 };
50
51 Handle ImplicitCopyConstructor(Handle passedByValue)
52 {
53   // object + copy + passedByValue, ref count == 3
54   DALI_TEST_CHECK(passedByValue);
55   if (passedByValue)
56   {
57     DALI_TEST_EQUALS(3, passedByValue.GetBaseObject().ReferenceCount(), TEST_LOCATION);
58   }
59
60   return passedByValue;
61 }
62
63 } // anon namespace
64
65
66 int UtcDaliHandleConstructorVoid(void)
67 {
68   TestApplication application;
69   tet_infoline("Testing Dali::Handle::Handle()");
70
71   Handle object;
72
73   DALI_TEST_CHECK(!object);
74
75   END_TEST;
76 }
77
78 int UtcDaliHandleCopyConstructor(void)
79 {
80   TestApplication application;
81   tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
82
83   // Initialize an object, ref count == 1
84   Handle object = Actor::New();
85
86   DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
87
88   // Copy the object, ref count == 2
89   Handle copy(object);
90   DALI_TEST_CHECK(copy);
91   if (copy)
92   {
93     DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
94   }
95
96   {
97     // Pass by value, and return another copy, ref count == 3
98     Handle anotherCopy = ImplicitCopyConstructor(copy);
99
100     DALI_TEST_CHECK(anotherCopy);
101     if (anotherCopy)
102     {
103       DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
104     }
105   }
106
107   // anotherCopy out of scope, ref count == 2
108   DALI_TEST_CHECK(copy);
109   if (copy)
110   {
111     DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
112   }
113   END_TEST;
114 }
115
116 int UtcDaliHandleAssignmentOperator(void)
117 {
118   TestApplication application;
119   tet_infoline("Testing Dali::Handle::operator=");
120
121   Handle object = Actor::New();
122
123   DALI_TEST_CHECK(object);
124   DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
125
126   Handle copy;
127   DALI_TEST_CHECK(!copy);
128
129   copy = object;
130   DALI_TEST_CHECK(copy);
131   DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
132   DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject()));
133   END_TEST;
134 }
135
136 int UtcDaliHandleSupports(void)
137 {
138   tet_infoline("Positive Test Dali::Handle::Supports()");
139   TestApplication application;
140
141   Actor actor = Actor::New();
142   DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) );
143   END_TEST;
144 }
145
146 int UtcDaliHandleGetPropertyCount(void)
147 {
148   tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
149   TestApplication application;
150
151   Actor actor = Actor::New();
152   int defaultPropertyCount( actor.GetPropertyCount() );
153
154   // Register a dynamic property
155   actor.RegisterProperty( "testProperty",  float(123.0f) );
156   DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() );
157   END_TEST;
158 }
159
160 int UtcDaliHandleGetPropertyName(void)
161 {
162   tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
163   TestApplication application;
164
165   Actor actor = Actor::New();
166   DALI_TEST_CHECK( "parentOrigin" == actor.GetPropertyName( Actor::Property::PARENT_ORIGIN ) );
167
168   // Register a dynamic property
169   std::string name("thisNameShouldMatch");
170   Property::Index index = actor.RegisterProperty( name, float(123.0f) );
171   DALI_TEST_CHECK( name == actor.GetPropertyName( index ) );
172
173   END_TEST;
174 }
175
176 int UtcDaliHandleGetPropertyIndex01(void)
177 {
178   tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
179   TestApplication application;
180
181   Actor actor = Actor::New();
182   DALI_TEST_CHECK( Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parentOrigin") );
183
184   // Register a dynamic property
185   std::string name("thisNameShouldMatch");
186   Property::Index index = actor.RegisterProperty( name, float(123.0f) );
187   DALI_TEST_CHECK( index == actor.GetPropertyIndex( name ) );
188   END_TEST;
189 }
190
191 int UtcDaliHandleGetPropertyIndex02(void)
192 {
193   tet_infoline("Positive Test Dali::Handle::GetPropertyIndex() int key");
194   TestApplication application;
195
196   Stage stage = Stage::GetCurrent();
197
198   Actor actor = Actor::New();
199   stage.Add( actor );
200
201   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
202
203   application.SendNotification();
204   application.Render();
205
206   Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
207   Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
208
209   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
210   const float withFlake(99.f);
211
212   Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
213   Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
214   Property::Index index3 = actor.RegisterProperty( "MyPropertyTwo", Vector3::ONE );
215   Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
216   Property::Index index5 = actor.RegisterProperty( "MyPropertyThree", Vector3::ONE );
217
218   application.SendNotification();
219   application.Render();
220
221   // Test that we can get the property index from the integer key
222   Property::Index testIndex1 = DevelHandle::GetPropertyIndex( actor, key1 );
223   Property::Index testIndex2 = DevelHandle::GetPropertyIndex( actor, key2 );
224
225   DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION );
226   DALI_TEST_EQUALS( index4, testIndex2, TEST_LOCATION );
227
228   // Test that we keep the same indices on the named properties
229   Property::Index testIndex = actor.GetPropertyIndex("MyPropertyOne");
230   DALI_TEST_EQUALS(testIndex, index1, TEST_LOCATION);
231   testIndex = actor.GetPropertyIndex("MyPropertyTwo");
232   DALI_TEST_EQUALS(testIndex, index3, TEST_LOCATION);
233   testIndex = actor.GetPropertyIndex("MyPropertyThree");
234   DALI_TEST_EQUALS(testIndex, index5, TEST_LOCATION);
235   testIndex = actor.GetPropertyIndex("sideColor");
236   DALI_TEST_EQUALS(testIndex, index2, TEST_LOCATION);
237   testIndex = actor.GetPropertyIndex("iceCream");
238   DALI_TEST_EQUALS(testIndex, index4, TEST_LOCATION);
239
240   DALI_TEST_EQUALS(defaultPropertyCount+5, actor.GetPropertyCount(), TEST_LOCATION);
241   END_TEST;
242 }
243
244 int UtcDaliHandleGetPropertyIndex03(void)
245 {
246   TestApplication application;
247
248   Actor actor = Actor::New();
249
250   std::string myName("croydon");
251   Property::Index intKey = CORE_PROPERTY_MAX_INDEX+1;
252   Property::Value value( Color::GREEN );
253   Property::Index myIndex = DevelHandle::RegisterProperty( actor, intKey, myName, value );
254
255   DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, intKey ), TEST_LOCATION );
256
257   Property::Key key1(myName);
258   Property::Key key2(intKey);
259
260   DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key1 ), TEST_LOCATION );
261   DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key2 ), TEST_LOCATION );
262   END_TEST;
263 }
264
265
266 int UtcDaliHandleIsPropertyWritable(void)
267 {
268   tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
269   TestApplication application;
270
271   Actor actor = Actor::New();
272
273   // Actor properties which are writable:
274   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN ) );
275   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_X ) );
276   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Y ) );
277   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Z ) );
278   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT ) );
279   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_X ) );
280   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Y ) );
281   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Z ) );
282   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE ) );
283   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_WIDTH  ) );
284   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_HEIGHT ) );
285   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_DEPTH  ) );
286   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION ) );
287   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_X ) );
288   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Y ) );
289   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Z ) );
290   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ORIENTATION ) );
291   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE ) );
292   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_X ) );
293   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Y ) );
294   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Z ) );
295   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::VISIBLE ) );
296   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR ) );
297   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_RED ) );
298   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_GREEN ) );
299   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_BLUE ) );
300   DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_ALPHA ) );
301   DALI_TEST_CHECK( true == actor.IsPropertyWritable( DevelActor::Property::OPACITY ) );
302
303   // World-properties are not writable:
304   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
305   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_ORIENTATION ) );
306   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_SCALE ) );
307   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_COLOR ) );
308   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_X ) );
309   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Y ) );
310   DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Z ) );
311
312   END_TEST;
313 }
314
315 int UtcDaliHandleIsPropertyAnimatable(void)
316 {
317   tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
318   TestApplication application;
319
320   Actor actor = Actor::New();
321
322   // Actor properties which are animatable:
323   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN ) );
324   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_X ) );
325   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Y ) );
326   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Z ) );
327   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT ) );
328   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_X ) );
329   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Y ) );
330   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Z ) );
331   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE ) );
332   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_WIDTH  ) );
333   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_HEIGHT ) );
334   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_DEPTH  ) );
335   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION ) );
336   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_X ) );
337   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Y ) );
338   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Z ) );
339   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::ORIENTATION ) );
340   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE ) );
341   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_X ) );
342   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Y ) );
343   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Z ) );
344   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::VISIBLE ) );
345   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR ) );
346   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_RED ) );
347   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_GREEN ) );
348   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_BLUE ) );
349   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_ALPHA ) );
350   DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( DevelActor::Property::OPACITY ) );
351
352   // World-properties can not be animated
353   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION ) );
354   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_ORIENTATION ) );
355   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_SCALE ) );
356   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_COLOR ) );
357   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_X ) );
358   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Y ) );
359   DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Z ) );
360
361   END_TEST;
362 }
363
364 int UtcDaliHandleIsPropertyAConstraintInput(void)
365 {
366   TestApplication application;
367
368   Actor actor = Actor::New();
369
370   // Actor properties which can be used as a constraint input:
371   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN ) );
372   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_X ) );
373   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Y ) );
374   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Z ) );
375   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT ) );
376   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_X ) );
377   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Y ) );
378   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Z ) );
379   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE ) );
380   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_WIDTH  ) );
381   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_HEIGHT ) );
382   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_DEPTH  ) );
383   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION ) );
384   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_X ) );
385   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Y ) );
386   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Z ) );
387   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ORIENTATION ) );
388   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE ) );
389   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_X ) );
390   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Y ) );
391   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Z ) );
392   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::VISIBLE ) );
393   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR ) );
394   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_RED ) );
395   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_GREEN ) );
396   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_BLUE ) );
397   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_ALPHA ) );
398   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( DevelActor::Property::OPACITY ) );
399   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION ) );
400   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_ORIENTATION ) );
401   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_SCALE ) );
402   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_COLOR ) );
403   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_X ) );
404   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Y ) );
405   DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Z ) );
406
407   // Actor properties that cannot be used as a constraint input
408   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::NAME ) );
409   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SENSITIVE ) );
410   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::LEAVE_REQUIRED ) );
411   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_ORIENTATION ) );
412   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_SCALE ) );
413   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_MODE ) );
414   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_INHERITANCE ) );
415   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::DRAW_MODE ) );
416   DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE_FACTOR ) );
417
418   END_TEST;
419 }
420
421
422 int UtcDaliHandleGetPropertyType(void)
423 {
424   tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
425   TestApplication application;
426
427   Actor actor = Actor::New();
428   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::PARENT_ORIGIN ) );
429   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::ANCHOR_POINT ) );
430   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::SIZE ) );
431   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::POSITION ) );
432   DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( Actor::Property::ORIENTATION ) );
433   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( Actor::Property::SCALE ) );
434   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( Actor::Property::VISIBLE ) );
435   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( Actor::Property::COLOR ) );
436
437   // Register some dynamic properties
438   Property::Index boolIndex     = actor.RegisterProperty( "boolProperty",      bool(true) );
439   Property::Index floatIndex    = actor.RegisterProperty( "floatProperty",     float(123.0f) );
440   Property::Index intIndex      = actor.RegisterProperty( "intProperty",       123 );
441   Property::Index vector2Index  = actor.RegisterProperty( "vector2Property",   Vector2(1.0f, 2.0f) );
442   Property::Index vector3Index  = actor.RegisterProperty( "vector3Property",   Vector3(1.0f, 2.0f, 3.0f) );
443   Property::Index vector4Index  = actor.RegisterProperty( "vector4Property",   Vector4(1.0f, 2.0f, 3.0f, 4.0f) );
444   Property::Index rotationIndex = actor.RegisterProperty( "rotationProperty",  AngleAxis(Degree(180.0f), Vector3::YAXIS) );
445
446   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( boolIndex ) );
447   DALI_TEST_CHECK( Property::FLOAT    == actor.GetPropertyType( floatIndex ) );
448   DALI_TEST_CHECK( Property::INTEGER  == actor.GetPropertyType( intIndex ) );
449   DALI_TEST_CHECK( Property::VECTOR2  == actor.GetPropertyType( vector2Index ) );
450   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( vector3Index ) );
451   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( vector4Index ) );
452   DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) );
453
454   // Non animatable properties
455   Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte",   std::string("yes"), Property::READ_WRITE);
456   Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE);
457   Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
458   Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
459   Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE);
460   Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE);
461   Property::Index nonAnimIntegerIndex = actor.RegisterProperty( "int", 0, Property::READ_WRITE);
462
463   DALI_TEST_CHECK( nonAnimStringIndex  != Property::INVALID_INDEX );
464   DALI_TEST_CHECK( nonAnimV2Index      != Property::INVALID_INDEX );
465   DALI_TEST_CHECK( nonAnimV3Index      != Property::INVALID_INDEX );
466   DALI_TEST_CHECK( nonAnimV4Index      != Property::INVALID_INDEX );
467   DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX );
468   DALI_TEST_CHECK( nonAnimFloatIndex   != Property::INVALID_INDEX );
469   DALI_TEST_CHECK( nonAnimIntegerIndex != Property::INVALID_INDEX );
470
471   DALI_TEST_CHECK( Property::STRING   == actor.GetPropertyType( nonAnimStringIndex ) );
472   DALI_TEST_CHECK( Property::VECTOR2  == actor.GetPropertyType( nonAnimV2Index ) );
473   DALI_TEST_CHECK( Property::VECTOR3  == actor.GetPropertyType( nonAnimV3Index ) );
474   DALI_TEST_CHECK( Property::VECTOR4  == actor.GetPropertyType( nonAnimV4Index ) );
475   DALI_TEST_CHECK( Property::BOOLEAN  == actor.GetPropertyType( nonAnimBooleanIndex ) );
476   DALI_TEST_CHECK( Property::FLOAT    == actor.GetPropertyType( nonAnimFloatIndex ) );
477   DALI_TEST_CHECK( Property::INTEGER  == actor.GetPropertyType( nonAnimIntegerIndex ) );
478
479   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) );
480   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) );
481   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV3Index ) );
482   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) );
483   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) );
484   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) );
485   DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimIntegerIndex ) );
486
487   DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
488   DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get<Vector2>(), TEST_LOCATION );
489   DALI_TEST_EQUALS( Vector3(1.f, 2.f, 3.f) , actor.GetProperty( nonAnimV3Index ).Get<Vector3>(), TEST_LOCATION );
490   DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get<Vector4>(), TEST_LOCATION );
491   DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get<bool>(), TEST_LOCATION );
492   DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get<float>(), TEST_LOCATION );
493   DALI_TEST_EQUALS( 0, actor.GetProperty( nonAnimIntegerIndex ).Get<int>(), TEST_LOCATION );
494
495   END_TEST;
496 }
497
498 int UtcDaliHandleNonAnimatableProperties(void)
499 {
500   tet_infoline("Test Non Animatable Properties");
501   TestApplication application;
502
503   Actor actor = Actor::New();
504
505   Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE);
506
507   //// modify writable?
508   actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
509
510   DALI_TEST_CHECK( "yes"  == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
511
512   //// cannot modify read only?
513   Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY);
514
515   DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
516   DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
517
518   actor.SetProperty( readonly, Property::Value(1.f) );
519   // trying to set a read-only property is a no-op
520
521   DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
522
523   /// animatable can be set
524   Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE);
525
526   DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
527   DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
528
529   actor.SetProperty( write_anim, Property::Value(1.f) );
530
531   //// animate a non animatable property throws
532   float durationSeconds(2.0f);
533   Animation animation = Animation::New(durationSeconds);
534   bool relativeValue(true);
535   try
536   {
537     animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
538   }
539   catch ( Dali::DaliException& e )
540   {
541     DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
542   }
543
544   DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
545
546   END_TEST;
547 }
548
549 int UtcDaliHandleNonAnimtableCompositeProperties(void)
550 {
551   tet_infoline("Test Non Animatable Composite Properties");
552   TestApplication application;
553
554   Actor actor = Actor::New();
555
556   Property::Value value(Property::ARRAY);
557   Property::Array* array = value.GetArray();
558   DALI_TEST_CHECK( array );
559
560   array->PushBack( Property::Value( 0.1f ) );
561   array->PushBack( "a string" );
562   array->PushBack( Property::Value( Vector3(1,2,3) ) );
563
564   DALI_TEST_EQUALS( 3u, array->Count(), TEST_LOCATION );
565
566   Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE );
567
568   Property::Value out = actor.GetProperty( propertyIndex );
569   Property::Array* outArray = out.GetArray();
570   DALI_TEST_CHECK( outArray != NULL );
571
572   DALI_TEST_CHECK( Property::FLOAT     == outArray->GetElementAt(0).GetType());
573   DALI_TEST_CHECK( Property::STRING    == outArray->GetElementAt(1).GetType());
574   DALI_TEST_CHECK( Property::VECTOR3   == outArray->GetElementAt(2).GetType());
575
576   DALI_TEST_EQUALS( 0.1f,            outArray->GetElementAt(0).Get<float>(),       TEST_LOCATION);
577   DALI_TEST_EQUALS( "a string",     outArray->GetElementAt(1).Get<std::string>(),  TEST_LOCATION);
578   DALI_TEST_EQUALS( Vector3(1,2,3), outArray->GetElementAt(2).Get<Vector3>(),      TEST_LOCATION);
579
580   // composite types not animatable
581   bool exception = false;
582   try
583   {
584     actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE);
585   }
586   catch (Dali::DaliException& e)
587   {
588     exception = true;
589     DALI_TEST_PRINT_ASSERT( e );
590   }
591
592   DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
593
594   // Map of maps
595   Property::Value mapOfMaps(Property::MAP);
596   Property::Map* map = mapOfMaps.GetMap();
597
598   map->Insert( "key", Property::Value(Property::MAP) );
599   map->Insert( "2key", "a string" );
600
601   DALI_TEST_EQUALS( "a string",  (*map)["2key"].Get<std::string>(),  TEST_LOCATION);
602
603   Property::Map* innerMap = map->Find("key")->GetMap();
604   innerMap->Insert( "subkey", 5.f );
605
606   DALI_TEST_CHECK( NULL != map->Find("key")->GetMap()->Find("subkey") );
607   DALI_TEST_EQUALS( 5.f, map->Find("key")->GetMap()->Find("subkey")->Get<float>(), TEST_LOCATION);
608   END_TEST;
609 }
610
611 int UtcDaliHandleSetProperty01(void)
612 {
613   tet_infoline("Positive Test Dali::Handle::SetProperty()");
614   TestApplication application;
615
616   Actor actor = Actor::New();
617   DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
618
619   actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
620   // flush the queue and render once
621   application.SendNotification();
622   application.Render();
623   DALI_TEST_CHECK( ParentOrigin::CENTER == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
624   END_TEST;
625 }
626
627 int UtcDaliHandleSetProperty02(void)
628 {
629   tet_infoline("Positive Test Dali::Handle::SetProperty()");
630   TestApplication application;
631
632   Actor actor = Actor::New();
633
634   DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
635
636   // World position is not writable so this is a no-op and should not crash
637   actor.SetProperty( Actor::Property::WORLD_POSITION, Vector3(1,2,3) );
638
639   END_TEST;
640 }
641
642 int UtcDaliHandleRegisterProperty01(void)
643 {
644   tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
645   TestApplication application;
646
647   Stage stage = Stage::GetCurrent();
648
649   Actor actor = Actor::New();
650   stage.Add( actor );
651
652   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
653
654   application.SendNotification();
655   application.Render();
656
657   Property::Index index1 = actor.RegisterProperty( "MyProperty", Vector3::ONE );
658
659   application.SendNotification();
660   application.Render();
661
662   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION );
663   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
664
665   // No new property should be registered when we call the below function
666   Property::Index index2 = actor.RegisterProperty( "MyProperty", Vector3::ZAXIS );
667
668   application.SendNotification();
669   application.Render();
670
671
672   DALI_TEST_EQUALS( index1, index2, TEST_LOCATION ); // We should have the same index as per the first registration
673   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION ); // Property count should be the same
674   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index2 ), Vector3::ZAXIS, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
675
676   END_TEST;
677 }
678
679 int UtcDaliHandleRegisterProperty02(void)
680 {
681   tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key");
682   TestApplication application;
683
684   Stage stage = Stage::GetCurrent();
685
686   Actor actor = Actor::New();
687   stage.Add( actor );
688
689   const unsigned int defaultPropertyCount = actor.GetPropertyCount();
690
691   application.SendNotification();
692   application.Render();
693
694   Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
695   Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
696
697   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
698   const float withFlake(99.f);
699
700   Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
701   Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
702   Property::Index index3 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
703
704   application.SendNotification();
705   application.Render();
706
707   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION );
708   DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
709   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), testColor, TEST_LOCATION );
710   DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), withFlake, TEST_LOCATION );
711
712   // No new property should be registered when we call the below functions
713   Property::Index testIndex2 = actor.RegisterProperty( "iceCream", 2200.f );
714   Property::Index testIndex1 = actor.RegisterProperty( "sideColor", Color::BLACK );
715   application.SendNotification();
716   application.Render();
717
718   DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION ); // We should have the same index as per the first registration
719   DALI_TEST_EQUALS( index3, testIndex2, TEST_LOCATION ); // We should have the same index as per the first registration
720   DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION ); // Property count should be the same
721   DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), Color::BLACK, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
722   DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), 2200.f, TEST_LOCATION );
723
724   END_TEST;
725 }
726
727
728
729 int UtcDaliHandleGetProperty(void)
730 {
731   tet_infoline("Positive Test Dali::Handle::GetProperty()");
732   TestApplication application;
733
734   Actor actor = Actor::New();
735
736   DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN   ).Get<Vector3>() );
737   DALI_TEST_CHECK( AnchorPoint::CENTER    == actor.GetProperty( Actor::Property::ANCHOR_POINT    ).Get<Vector3>() );
738   DALI_TEST_CHECK( Vector3::ZERO          == actor.GetProperty( Actor::Property::SIZE            ).Get<Vector3>() );
739   DALI_TEST_CHECK( Vector3::ZERO          == actor.GetProperty( Actor::Property::POSITION        ).Get<Vector3>() );
740   DALI_TEST_CHECK( Vector3::ONE           == actor.GetProperty( Actor::Property::SCALE           ).Get<Vector3>() );
741   DALI_TEST_CHECK( true                   == actor.GetProperty( Actor::Property::VISIBLE         ).Get<bool>() );
742   DALI_TEST_CHECK( Color::WHITE           == actor.GetProperty( Actor::Property::COLOR           ).Get<Vector4>() );
743   END_TEST;
744 }
745
746 int UtcDaliHandleDownCast(void)
747 {
748   TestApplication application;
749   tet_infoline("Testing Dali::Handle::DownCast()");
750
751   Actor actor = Actor::New();
752
753   BaseHandle baseHandle = actor;
754
755   Handle handle = Handle::DownCast(baseHandle);
756
757   DALI_TEST_CHECK( handle );
758
759   baseHandle = BaseHandle();
760
761   handle = Handle::DownCast(baseHandle);
762
763   DALI_TEST_CHECK( !handle );
764
765   END_TEST;
766 }
767
768 int UtcDaliHandleDownCastNegative(void)
769 {
770   TestApplication application;
771
772   // BaseObject is NOT an Object, so this DownCast should fail
773   BaseHandle handle( new BaseObjectType );
774   Handle customHandle1 = Handle::DownCast( handle );
775   DALI_TEST_CHECK( ! customHandle1 );
776
777   // A DownCast on an empty handle will also fail
778   Handle empty;
779   Handle customHandle2 = Handle::DownCast( empty );
780   DALI_TEST_CHECK( ! customHandle2 );
781   END_TEST;
782 }
783
784 int UtcDaliHandleGetPropertyIndices(void)
785 {
786   TestApplication application;
787   Property::IndexContainer indices;
788
789   // Actor
790   Actor actor = Actor::New();
791   actor.GetPropertyIndices( indices );
792   int numDefaultProperties = indices.Size();
793   DALI_TEST_CHECK( numDefaultProperties > 0 );
794   DALI_TEST_EQUALS( numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION );
795
796   const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
797   const float withFlake(99.f);
798
799   Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
800   Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
801
802   actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
803   DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
804   actor.RegisterProperty( "MyPropertyTwo", 1234 );
805   Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
806   actor.RegisterProperty( "MyPropertyThree", Vector2(.2f,.7f) );
807
808   actor.GetPropertyIndices( indices );
809
810   DALI_TEST_EQUALS( indices.Size(), numDefaultProperties + 5, TEST_LOCATION );
811   DALI_TEST_EQUALS( indices[indices.Size()-2], index4, TEST_LOCATION );
812
813   END_TEST;
814 }
815
816 int UtcDaliHandleRegisterPropertyTypes(void)
817 {
818   TestApplication application;
819
820   struct PropertyTypeAnimatable
821   {
822     const char * name;
823     Property::Value value;
824     bool animatable;
825   };
826
827   Property::Array array;
828   Property::Map map;
829
830   PropertyTypeAnimatable properties[] =
831   {
832     { "Property::BOOLEAN",          true,              true  },
833     { "Property::FLOAT",            1.0f,              true  },
834     { "Property::INTEGER",          1,                 true  },
835     { "Property::VECTOR2",          Vector2::ONE,      true  },
836     { "Property::VECTOR3",          Vector3::ONE,      true  },
837     { "Property::VECTOR4",          Vector4::ONE,      true  },
838     { "Property::MATRIX3",          Matrix3::IDENTITY, true  },
839     { "Property::MATRIX",           Matrix::IDENTITY,  true  },
840     { "Property::RECTANGLE",        Rect<int>(),       false },
841     { "Property::ROTATION",         AngleAxis(),       true  },
842     { "Property::STRING",           std::string("Me"), false },
843     { "Property::ARRAY",            array,             false },
844     { "Property::MAP",              map,               false },
845   };
846
847   unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
848
849   for ( unsigned int i = 0; i < numOfProperties; ++i )
850   {
851     tet_printf( "Testing: %s\n", properties[i].name );
852
853     bool exception = false;
854     try
855     {
856       Actor actor = Actor::New();
857       actor.RegisterProperty( "manFromDelmonte",   properties[i].value );
858     }
859     catch (Dali::DaliException& e)
860     {
861       exception = true;
862     }
863
864     DALI_TEST_CHECK( properties[i].animatable != exception );
865   }
866   END_TEST;
867 }
868
869 int UtcDaliHandleCustomProperty(void)
870 {
871   TestApplication application;
872
873   Handle handle = Handle::New();
874
875   float startValue(1.0f);
876   Property::Index index = handle.RegisterProperty( "testProperty",  startValue );
877   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
878
879   application.SendNotification();
880   application.Render(0);
881   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
882   application.Render(0);
883   DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
884
885   handle.SetProperty( index, 5.0f );
886
887   application.SendNotification();
888   application.Render(0);
889   DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
890   application.Render(0);
891   DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
892   END_TEST;
893 }
894
895 int UtcDaliHandleWeightNew(void)
896 {
897   TestApplication application;
898
899   Handle handle = WeightObject::New();
900   DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
901
902   // process the message so scene object is added to update manager
903   application.SendNotification();
904   application.Render(0);
905
906   // no message to release scene object in this scenario
907
908   END_TEST;
909 }
910
911 int UtcDaliHandleWeightNew2(void)
912 {
913   TestApplication application;
914
915   // scope for the weight object
916   {
917     Handle handle = WeightObject::New();
918     DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
919
920     // process the message so scene object is added to update manager
921     application.SendNotification();
922     application.Render(0);
923   }
924   // handle out of scope so object gets destroyed
925   // process the message so update manager destroys the scene object
926   application.SendNotification();
927   application.Render(0);
928
929   END_TEST;
930 }
931
932 int UtcDaliHandleSetTypeInfo(void)
933 {
934   TestApplication application;
935   TypeRegistry typeRegistry = TypeRegistry::Get();
936
937   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
938   DALI_TEST_CHECK( typeInfo );
939
940   Actor actor = Actor::DownCast(typeInfo.CreateInstance());
941   DALI_TEST_CHECK( actor );
942
943   DevelHandle::SetTypeInfo(actor, typeInfo);
944
945   TypeInfo newTypeInfo;
946   bool success = actor.GetTypeInfo( newTypeInfo );
947   DALI_TEST_CHECK( success );
948
949   DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
950   DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
951
952   END_TEST;
953 }
954
955 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
956 {
957   TestApplication application;
958
959   tet_infoline( "Create a custom property and set the value ensuring it can be retrieved synchronously" );
960
961   Actor actor = Actor::New();
962   Stage::GetCurrent().Add( actor );
963
964   tet_infoline( "Create the custom property with an initial value" );
965   float startValue(1.0f);
966   Property::Index index = actor.RegisterProperty( "testProperty",  startValue );
967   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), startValue, TEST_LOCATION );
968
969   tet_infoline( "Set the value, retrieve it and ensure both the synchronous and the async version work" );
970   actor.SetProperty( index, 5.0f );
971   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
972   DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, index ), startValue, TEST_LOCATION );
973
974   tet_infoline( "Render and retrieve values again" );
975   application.SendNotification();
976   application.Render(0);
977
978   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
979   DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, index ), 5.0f, TEST_LOCATION );
980
981   END_TEST;
982 }
983
984 int UtcDaliHandleCustomPropertyGetType(void)
985 {
986   TestApplication application;
987
988   tet_infoline( "Create a custom property and retrieve its type" );
989
990   Handle handle = Handle::New();
991   Property::Index index = handle.RegisterProperty( "testProperty",  1.0f );
992   DALI_TEST_EQUALS( handle.GetPropertyType( index ), Property::FLOAT, TEST_LOCATION );
993
994   END_TEST;
995 }
996
997 int UtcDaliHandleCustomPropertyAccessMode(void)
998 {
999   TestApplication application;
1000
1001   tet_infoline( "Create a custom property and retrieve whether it's animatable etc." );
1002
1003   Handle handle = Handle::New();
1004   Property::Index index = handle.RegisterProperty( "testProperty",  1.0f );
1005   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), true, TEST_LOCATION );
1006   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1007
1008   index = handle.RegisterProperty( "testProperty2", 1.0f, Property::READ_ONLY );
1009   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1010   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), false, TEST_LOCATION );
1011
1012   index = handle.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1013   DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1014   DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1015
1016   END_TEST;
1017 }
1018
1019 int UtcDaliHandleGetCurrentProperty(void)
1020 {
1021   TestApplication application;
1022
1023   tet_infoline( "Get a default and non-animatable custom property using the DevelHandle::GetCurrentProperty API" );
1024
1025   Actor actor = Actor::New();
1026   Stage::GetCurrent().Add( actor );
1027   DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( actor, Actor::Property::VISIBLE ), true, TEST_LOCATION );
1028
1029   Property::Index index = actor.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1030   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 1.0f, TEST_LOCATION );
1031   DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, index ), 1.0f, TEST_LOCATION );
1032
1033   actor.SetProperty( index, 2.0f );
1034   DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 2.0f, TEST_LOCATION );
1035   DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< float >( actor, index ), 2.0f, TEST_LOCATION );
1036
1037   END_TEST;
1038 }