2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
29 void handle_test_startup(void)
31 test_return_value = TET_UNDEF;
34 void handle_test_cleanup(void)
36 test_return_value = TET_PASS;
42 /// Allows the creation of a BaseObject
43 class BaseObjectType : public BaseObject
51 Handle ImplicitCopyConstructor(Handle passedByValue)
53 // object + copy + passedByValue, ref count == 3
54 DALI_TEST_CHECK(passedByValue);
57 DALI_TEST_EQUALS(3, passedByValue.GetBaseObject().ReferenceCount(), TEST_LOCATION);
66 int UtcDaliHandleConstructorVoid(void)
68 TestApplication application;
69 tet_infoline("Testing Dali::Handle::Handle()");
73 DALI_TEST_CHECK(!object);
78 int UtcDaliHandleCopyConstructor(void)
80 TestApplication application;
81 tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
83 // Initialize an object, ref count == 1
84 Handle object = Actor::New();
86 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
88 // Copy the object, ref count == 2
90 DALI_TEST_CHECK(copy);
93 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
97 // Pass by value, and return another copy, ref count == 3
98 Handle anotherCopy = ImplicitCopyConstructor(copy);
100 DALI_TEST_CHECK(anotherCopy);
103 DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
107 // anotherCopy out of scope, ref count == 2
108 DALI_TEST_CHECK(copy);
111 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
116 int UtcDaliHandleAssignmentOperator(void)
118 TestApplication application;
119 tet_infoline("Testing Dali::Handle::operator=");
121 Handle object = Actor::New();
123 DALI_TEST_CHECK(object);
124 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
127 DALI_TEST_CHECK(!copy);
130 DALI_TEST_CHECK(copy);
131 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
132 DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject()));
136 int UtcDaliHandleSupports(void)
138 tet_infoline("Positive Test Dali::Handle::Supports()");
139 TestApplication application;
141 Actor actor = Actor::New();
142 DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) );
146 int UtcDaliHandleGetPropertyCount(void)
148 tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
149 TestApplication application;
151 Actor actor = Actor::New();
152 int defaultPropertyCount( actor.GetPropertyCount() );
154 // Register a dynamic property
155 actor.RegisterProperty( "testProperty", float(123.0f) );
156 DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() );
160 int UtcDaliHandleGetPropertyName(void)
162 tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
163 TestApplication application;
165 Actor actor = Actor::New();
166 DALI_TEST_CHECK( "parentOrigin" == actor.GetPropertyName( Actor::Property::PARENT_ORIGIN ) );
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 ) );
176 int UtcDaliHandleGetPropertyIndex01(void)
178 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
179 TestApplication application;
181 Actor actor = Actor::New();
182 DALI_TEST_CHECK( Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parentOrigin") );
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 ) );
191 int UtcDaliHandleGetPropertyIndex02(void)
193 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex() int key");
194 TestApplication application;
196 Stage stage = Stage::GetCurrent();
198 Actor actor = Actor::New();
201 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
203 application.SendNotification();
204 application.Render();
206 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
207 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
209 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
210 const float withFlake(99.f);
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 );
218 application.SendNotification();
219 application.Render();
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 );
225 DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION );
226 DALI_TEST_EQUALS( index4, testIndex2, TEST_LOCATION );
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);
240 DALI_TEST_EQUALS(defaultPropertyCount+5, actor.GetPropertyCount(), TEST_LOCATION);
244 int UtcDaliHandleGetPropertyIndex03(void)
246 TestApplication application;
248 Actor actor = Actor::New();
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 );
255 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, intKey ), TEST_LOCATION );
257 Property::Key key1(myName);
258 Property::Key key2(intKey);
260 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key1 ), TEST_LOCATION );
261 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key2 ), TEST_LOCATION );
266 int UtcDaliHandleIsPropertyWritable(void)
268 tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
269 TestApplication application;
271 Actor actor = Actor::New();
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 ) );
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 ) );
315 int UtcDaliHandleIsPropertyAnimatable(void)
317 tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
318 TestApplication application;
320 Actor actor = Actor::New();
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 ) );
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 ) );
364 int UtcDaliHandleIsPropertyAConstraintInput(void)
366 TestApplication application;
368 Actor actor = Actor::New();
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 ) );
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 ) );
422 int UtcDaliHandleGetPropertyType(void)
424 tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
425 TestApplication application;
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 ) );
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) );
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 ) );
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);
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 );
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 ) );
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 ) );
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 );
498 int UtcDaliHandleNonAnimatableProperties(void)
500 tet_infoline("Test Non Animatable Properties");
501 TestApplication application;
503 Actor actor = Actor::New();
505 Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE);
507 //// modify writable?
508 actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
510 DALI_TEST_CHECK( "yes" == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
512 //// cannot modify read only?
513 Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY);
515 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
516 DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
518 actor.SetProperty( readonly, Property::Value(1.f) );
519 // trying to set a read-only property is a no-op
521 DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
523 /// animatable can be set
524 Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE);
526 DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
527 DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
529 actor.SetProperty( write_anim, Property::Value(1.f) );
531 //// animate a non animatable property throws
532 float durationSeconds(2.0f);
533 Animation animation = Animation::New(durationSeconds);
534 bool relativeValue(true);
537 animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
539 catch ( Dali::DaliException& e )
541 DALI_TEST_ASSERT( e, "Animated value and Property type don't match", TEST_LOCATION );
544 DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
549 int UtcDaliHandleNonAnimtableCompositeProperties(void)
551 tet_infoline("Test Non Animatable Composite Properties");
552 TestApplication application;
554 Actor actor = Actor::New();
556 Property::Value value(Property::ARRAY);
557 Property::Array* array = value.GetArray();
558 DALI_TEST_CHECK( array );
560 array->PushBack( Property::Value( 0.1f ) );
561 array->PushBack( "a string" );
562 array->PushBack( Property::Value( Vector3(1,2,3) ) );
564 DALI_TEST_EQUALS( 3u, array->Count(), TEST_LOCATION );
566 Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE );
568 Property::Value out = actor.GetProperty( propertyIndex );
569 Property::Array* outArray = out.GetArray();
570 DALI_TEST_CHECK( outArray != NULL );
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());
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);
580 // composite types not animatable
581 bool exception = false;
584 actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE);
586 catch (Dali::DaliException& e)
589 DALI_TEST_PRINT_ASSERT( e );
592 DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
595 Property::Value mapOfMaps(Property::MAP);
596 Property::Map* map = mapOfMaps.GetMap();
598 map->Insert( "key", Property::Value(Property::MAP) );
599 map->Insert( "2key", "a string" );
601 DALI_TEST_EQUALS( "a string", (*map)["2key"].Get<std::string>(), TEST_LOCATION);
603 Property::Map* innerMap = map->Find("key")->GetMap();
604 innerMap->Insert( "subkey", 5.f );
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);
611 int UtcDaliHandleSetProperty01(void)
613 tet_infoline("Positive Test Dali::Handle::SetProperty()");
614 TestApplication application;
616 Actor actor = Actor::New();
617 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
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>() );
627 int UtcDaliHandleSetProperty02(void)
629 tet_infoline("Positive Test Dali::Handle::SetProperty()");
630 TestApplication application;
632 Actor actor = Actor::New();
634 DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
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) );
642 int UtcDaliHandleRegisterProperty01(void)
644 tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
645 TestApplication application;
647 Stage stage = Stage::GetCurrent();
649 Actor actor = Actor::New();
652 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
654 application.SendNotification();
655 application.Render();
657 Property::Index index1 = actor.RegisterProperty( "MyProperty", Vector3::ONE );
659 application.SendNotification();
660 application.Render();
662 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION );
663 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
665 // No new property should be registered when we call the below function
666 Property::Index index2 = actor.RegisterProperty( "MyProperty", Vector3::ZAXIS );
668 application.SendNotification();
669 application.Render();
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
679 int UtcDaliHandleRegisterProperty02(void)
681 tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key");
682 TestApplication application;
684 Stage stage = Stage::GetCurrent();
686 Actor actor = Actor::New();
689 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
691 application.SendNotification();
692 application.Render();
694 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
695 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
697 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
698 const float withFlake(99.f);
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 );
704 application.SendNotification();
705 application.Render();
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 );
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();
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 );
729 int UtcDaliHandleGetProperty(void)
731 tet_infoline("Positive Test Dali::Handle::GetProperty()");
732 TestApplication application;
734 Actor actor = Actor::New();
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>() );
746 int UtcDaliHandleDownCast(void)
748 TestApplication application;
749 tet_infoline("Testing Dali::Handle::DownCast()");
751 Actor actor = Actor::New();
753 BaseHandle baseHandle = actor;
755 Handle handle = Handle::DownCast(baseHandle);
757 DALI_TEST_CHECK( handle );
759 baseHandle = BaseHandle();
761 handle = Handle::DownCast(baseHandle);
763 DALI_TEST_CHECK( !handle );
768 int UtcDaliHandleDownCastNegative(void)
770 TestApplication application;
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 );
777 // A DownCast on an empty handle will also fail
779 Handle customHandle2 = Handle::DownCast( empty );
780 DALI_TEST_CHECK( ! customHandle2 );
784 int UtcDaliHandleGetPropertyIndices(void)
786 TestApplication application;
787 Property::IndexContainer indices;
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 );
796 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
797 const float withFlake(99.f);
799 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
800 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
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) );
808 actor.GetPropertyIndices( indices );
810 DALI_TEST_EQUALS( indices.Size(), numDefaultProperties + 5, TEST_LOCATION );
811 DALI_TEST_EQUALS( indices[indices.Size()-2], index4, TEST_LOCATION );
816 int UtcDaliHandleRegisterPropertyTypes(void)
818 TestApplication application;
820 struct PropertyTypeAnimatable
823 Property::Value value;
827 Property::Array array;
830 PropertyTypeAnimatable properties[] =
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 },
847 unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
849 for ( unsigned int i = 0; i < numOfProperties; ++i )
851 tet_printf( "Testing: %s\n", properties[i].name );
853 bool exception = false;
856 Actor actor = Actor::New();
857 actor.RegisterProperty( "manFromDelmonte", properties[i].value );
859 catch (Dali::DaliException& e)
864 DALI_TEST_CHECK( properties[i].animatable != exception );
869 int UtcDaliHandleCustomProperty(void)
871 TestApplication application;
873 Handle handle = Handle::New();
875 float startValue(1.0f);
876 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
877 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
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 );
885 handle.SetProperty( index, 5.0f );
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 );
895 int UtcDaliHandleWeightNew(void)
897 TestApplication application;
899 Handle handle = WeightObject::New();
900 DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
902 // process the message so scene object is added to update manager
903 application.SendNotification();
904 application.Render(0);
906 // no message to release scene object in this scenario
911 int UtcDaliHandleWeightNew2(void)
913 TestApplication application;
915 // scope for the weight object
917 Handle handle = WeightObject::New();
918 DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
920 // process the message so scene object is added to update manager
921 application.SendNotification();
922 application.Render(0);
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);
932 int UtcDaliHandleSetTypeInfo(void)
934 TestApplication application;
935 TypeRegistry typeRegistry = TypeRegistry::Get();
937 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
938 DALI_TEST_CHECK( typeInfo );
940 Actor actor = Actor::DownCast(typeInfo.CreateInstance());
941 DALI_TEST_CHECK( actor );
943 DevelHandle::SetTypeInfo(actor, typeInfo);
945 TypeInfo newTypeInfo;
946 bool success = actor.GetTypeInfo( newTypeInfo );
947 DALI_TEST_CHECK( success );
949 DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
950 DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
955 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
957 TestApplication application;
959 tet_infoline( "Create a custom property and set the value ensuring it can be retrieved synchronously" );
961 Actor actor = Actor::New();
962 Stage::GetCurrent().Add( actor );
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 );
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( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
974 tet_infoline( "Render and retrieve values again" );
975 application.SendNotification();
976 application.Render(0);
978 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
979 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 5.0f, TEST_LOCATION );
984 int UtcDaliHandleCustomPropertyGetType(void)
986 TestApplication application;
988 tet_infoline( "Create a custom property and retrieve its type" );
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 );
997 int UtcDaliHandleCustomPropertyAccessMode(void)
999 TestApplication application;
1001 tet_infoline( "Create a custom property and retrieve whether it's animatable etc." );
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 );
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 );
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 );
1019 int UtcDaliHandleGetCurrentProperty(void)
1021 TestApplication application;
1023 tet_infoline( "Get a default and non-animatable custom property using the GetCurrentProperty API" );
1025 Actor actor = Actor::New();
1026 Stage::GetCurrent().Add( actor );
1027 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
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( actor.GetCurrentProperty< float >( index ), 1.0f, TEST_LOCATION );
1033 actor.SetProperty( index, 2.0f );
1034 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 2.0f, TEST_LOCATION );
1035 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 2.0f, TEST_LOCATION );