2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
20 #include <dali/dali.h>
21 #include "dali-test-suite-utils/dali-test-suite-utils.h"
25 void handle_test_startup(void)
27 test_return_value = TET_UNDEF;
30 void handle_test_cleanup(void)
32 test_return_value = TET_PASS;
38 Handle ImplicitCopyConstructor(Handle passedByValue)
40 // object + copy + passedByValue, ref count == 3
41 DALI_TEST_CHECK(passedByValue);
44 DALI_TEST_EQUALS(3, passedByValue.GetBaseObject().ReferenceCount(), TEST_LOCATION);
50 void CheckTypeName(const Property::Type& type)
56 DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) );
59 case Property::BOOLEAN:
61 DALI_TEST_CHECK( "BOOLEAN" == std::string(PropertyTypes::GetName( type ) ) );
66 DALI_TEST_CHECK( "FLOAT" == std::string(PropertyTypes::GetName( type ) ) );
69 case Property::INTEGER:
71 DALI_TEST_CHECK( "INTEGER" == std::string(PropertyTypes::GetName( type ) ) );
74 case Property::UNSIGNED_INTEGER:
76 DALI_TEST_CHECK( "UNSIGNED_INTEGER" == std::string(PropertyTypes::GetName( type ) ) );
79 case Property::VECTOR2:
81 DALI_TEST_CHECK( "VECTOR2" == std::string(PropertyTypes::GetName( type ) ) );
84 case Property::VECTOR3:
86 DALI_TEST_CHECK( "VECTOR3" == std::string(PropertyTypes::GetName( type ) ) );
89 case Property::VECTOR4:
91 DALI_TEST_CHECK( "VECTOR4" == std::string(PropertyTypes::GetName( type ) ) );
94 case Property::MATRIX3:
96 DALI_TEST_CHECK( "MATRIX3" == std::string(PropertyTypes::GetName( type ) ) );
99 case Property::MATRIX:
101 DALI_TEST_CHECK( "MATRIX" == std::string(PropertyTypes::GetName( type ) ) );
104 case Property::RECTANGLE:
106 DALI_TEST_CHECK( "RECTANGLE" == std::string(PropertyTypes::GetName( type ) ) );
109 case Property::ROTATION:
111 DALI_TEST_CHECK( "ROTATION" == std::string(PropertyTypes::GetName( type ) ) );
114 case Property::STRING:
116 DALI_TEST_CHECK( "STRING" == std::string(PropertyTypes::GetName( type ) ) );
119 case Property::ARRAY:
121 DALI_TEST_CHECK( "ARRAY" == std::string(PropertyTypes::GetName( type ) ) );
126 DALI_TEST_CHECK( "MAP" == std::string(PropertyTypes::GetName( type ) ) );
129 case Property::TYPE_COUNT:
131 DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) );
141 int UtcDaliHandleConstructorVoid(void)
143 TestApplication application;
144 tet_infoline("Testing Dali::Handle::Handle()");
148 DALI_TEST_CHECK(!object);
152 int UtcDaliHandleCopyConstructor(void)
154 TestApplication application;
155 tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
157 // Initialize an object, ref count == 1
158 Handle object = Actor::New();
160 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
162 // Copy the object, ref count == 2
164 DALI_TEST_CHECK(copy);
167 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
171 // Pass by value, and return another copy, ref count == 3
172 Handle anotherCopy = ImplicitCopyConstructor(copy);
174 DALI_TEST_CHECK(anotherCopy);
177 DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
181 // anotherCopy out of scope, ref count == 2
182 DALI_TEST_CHECK(copy);
185 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
190 int UtcDaliHandleAssignmentOperator(void)
192 TestApplication application;
193 tet_infoline("Testing Dali::Handle::operator=");
195 Handle object = Actor::New();
197 DALI_TEST_CHECK(object);
198 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
201 DALI_TEST_CHECK(!copy);
204 DALI_TEST_CHECK(copy);
205 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
206 DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject()));
210 int UtcDaliHandleSupports(void)
212 tet_infoline("Positive Test Dali::Handle::Supports()");
213 TestApplication application;
215 Actor actor = Actor::New();
216 DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) );
220 int UtcDaliHandleGetPropertyCount(void)
222 tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
223 TestApplication application;
225 Actor actor = Actor::New();
226 int defaultPropertyCount( actor.GetPropertyCount() );
228 // Register a dynamic property
229 actor.RegisterProperty( "test-property", float(123.0f) );
230 DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() );
234 int UtcDaliHandleGetPropertyName(void)
236 tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
237 TestApplication application;
239 Actor actor = Actor::New();
240 DALI_TEST_CHECK( "parent-origin" == actor.GetPropertyName( Actor::PARENT_ORIGIN ) );
242 // Register a dynamic property
243 std::string name("this-name-should-match");
244 Property::Index index = actor.RegisterProperty( name, float(123.0f) );
245 DALI_TEST_CHECK( name == actor.GetPropertyName( index ) );
250 int UtcDaliHandleGetPropertyIndex(void)
252 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
253 TestApplication application;
255 Actor actor = Actor::New();
256 DALI_TEST_CHECK( Actor::PARENT_ORIGIN == actor.GetPropertyIndex("parent-origin") );
258 // Register a dynamic property
259 std::string name("this-name-should-match");
260 Property::Index index = actor.RegisterProperty( name, float(123.0f) );
261 DALI_TEST_CHECK( index == actor.GetPropertyIndex( name ) );
265 int UtcDaliHandleIsPropertyWritable(void)
267 tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
268 TestApplication application;
270 Actor actor = Actor::New();
272 // Actor properties which are writable:
273 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::PARENT_ORIGIN ) );
274 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::PARENT_ORIGIN_X ) );
275 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::PARENT_ORIGIN_Y ) );
276 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::PARENT_ORIGIN_Z ) );
277 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ANCHOR_POINT ) );
278 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ANCHOR_POINT_X ) );
279 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ANCHOR_POINT_Y ) );
280 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ANCHOR_POINT_Z ) );
281 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SIZE ) );
282 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SIZE_WIDTH ) );
283 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SIZE_HEIGHT ) );
284 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SIZE_DEPTH ) );
285 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION ) );
286 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION_X ) );
287 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION_Y ) );
288 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION_Z ) );
289 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ROTATION ) );
290 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SCALE ) );
291 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SCALE_X ) );
292 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SCALE_Y ) );
293 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SCALE_Z ) );
294 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::VISIBLE ) );
295 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR ) );
296 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_RED ) );
297 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_GREEN ) );
298 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_BLUE ) );
299 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_ALPHA ) );
301 // World-properties are not writable:
302 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION ) );
303 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_ROTATION ) );
304 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_SCALE ) );
305 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_COLOR ) );
306 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION_X ) );
307 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION_Y ) );
308 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION_Z ) );
313 int UtcDaliHandleIsPropertyAnimatable(void)
315 tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
316 TestApplication application;
318 Actor actor = Actor::New();
320 // Actor properties which are animatable:
321 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::PARENT_ORIGIN ) );
322 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::PARENT_ORIGIN_X ) );
323 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::PARENT_ORIGIN_Y ) );
324 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::PARENT_ORIGIN_Z ) );
325 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::ANCHOR_POINT ) );
326 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::ANCHOR_POINT_X ) );
327 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::ANCHOR_POINT_Y ) );
328 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::ANCHOR_POINT_Z ) );
329 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SIZE ) );
330 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SIZE_WIDTH ) );
331 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SIZE_HEIGHT ) );
332 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SIZE_DEPTH ) );
333 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::POSITION ) );
334 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::POSITION_X ) );
335 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::POSITION_Y ) );
336 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::POSITION_Z ) );
337 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::ROTATION ) );
338 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SCALE ) );
339 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SCALE_X ) );
340 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SCALE_Y ) );
341 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SCALE_Z ) );
342 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::VISIBLE ) );
343 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR ) );
344 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR_RED ) );
345 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR_GREEN ) );
346 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR_BLUE ) );
347 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR_ALPHA ) );
349 // World-properties can not be animated
350 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION ) );
351 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_ROTATION ) );
352 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_SCALE ) );
353 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_COLOR ) );
354 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION_X ) );
355 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION_Y ) );
356 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION_Z ) );
361 int UtcDaliHandleIsPropertyAConstraintInput(void)
363 TestApplication application;
365 Actor actor = Actor::New();
367 // Actor properties which can be used as a constraint input:
368 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN ) );
369 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_X ) );
370 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_Y ) );
371 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_Z ) );
372 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT ) );
373 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_X ) );
374 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_Y ) );
375 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_Z ) );
376 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE ) );
377 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_WIDTH ) );
378 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_HEIGHT ) );
379 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_DEPTH ) );
380 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION ) );
381 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_X ) );
382 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_Y ) );
383 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_Z ) );
384 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ROTATION ) );
385 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE ) );
386 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_X ) );
387 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_Y ) );
388 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_Z ) );
389 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::VISIBLE ) );
390 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR ) );
391 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_RED ) );
392 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_GREEN ) );
393 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_BLUE ) );
394 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_ALPHA ) );
395 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION ) );
396 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_ROTATION ) );
397 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_SCALE ) );
398 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_COLOR ) );
399 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_X ) );
400 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_Y ) );
401 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_Z ) );
403 // Actor properties that cannot be used as a constraint input
404 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::NAME ) );
405 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::SENSITIVE ) );
406 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::LEAVE_REQUIRED ) );
407 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SHADER_EFFECT ) );
408 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_ROTATION ) );
409 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SCALE ) );
410 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::COLOR_MODE ) );
411 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::POSITION_INHERITANCE ) );
412 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::DRAW_MODE ) );
418 int UtcDaliHandleGetPropertyType(void)
420 tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
421 TestApplication application;
422 unsigned int unsingedIntTest = 33;
424 Actor actor = Actor::New();
425 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::PARENT_ORIGIN ) );
426 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::ANCHOR_POINT ) );
427 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::SIZE ) );
428 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::POSITION ) );
429 DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( Actor::ROTATION ) );
430 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::SCALE ) );
431 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( Actor::VISIBLE ) );
432 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( Actor::COLOR ) );
434 // Register some dynamic properties
435 Property::Index boolIndex = actor.RegisterProperty( "bool-property", bool(true) );
436 Property::Index floatIndex = actor.RegisterProperty( "float-property", float(123.0f) );
437 Property::Index vector2Index = actor.RegisterProperty( "vector2-property", Vector2(1.0f, 2.0f) );
438 Property::Index vector3Index = actor.RegisterProperty( "vector3-property", Vector3(1.0f, 2.0f, 3.0f) );
439 Property::Index vector4Index = actor.RegisterProperty( "vector4-property", Vector4(1.0f, 2.0f, 3.0f, 4.0f) );
440 Property::Index rotationIndex = actor.RegisterProperty( "rotation-property", AngleAxis(Degree(180.0f), Vector3::YAXIS) );
442 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( boolIndex ) );
443 DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( floatIndex ) );
444 DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( vector2Index ) );
445 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) );
446 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) );
447 DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) );
449 // Non animatable properties
450 Property::Index nonAnimStringIndex = actor.RegisterProperty( "man-from-delmonte", std::string("yes"), Property::READ_WRITE);
451 Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE);
452 Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
453 Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
454 Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE);
455 Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE);
456 Property::Index nonAnimUnsignedIntIndex = actor.RegisterProperty( "unsinged-int", unsingedIntTest, Property::READ_WRITE);
458 DALI_TEST_CHECK( nonAnimStringIndex != Property::INVALID_INDEX );
459 DALI_TEST_CHECK( nonAnimV2Index != Property::INVALID_INDEX );
460 DALI_TEST_CHECK( nonAnimV3Index != Property::INVALID_INDEX );
461 DALI_TEST_CHECK( nonAnimV4Index != Property::INVALID_INDEX );
462 DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX );
463 DALI_TEST_CHECK( nonAnimFloatIndex != Property::INVALID_INDEX );
464 DALI_TEST_CHECK( nonAnimUnsignedIntIndex != Property::INVALID_INDEX );
466 DALI_TEST_CHECK( Property::STRING == actor.GetPropertyType( nonAnimStringIndex ) );
467 DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( nonAnimV2Index ) );
468 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( nonAnimV3Index ) );
469 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( nonAnimV4Index ) );
470 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( nonAnimBooleanIndex ) );
471 DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( nonAnimFloatIndex ) );
472 DALI_TEST_CHECK( Property::UNSIGNED_INTEGER == actor.GetPropertyType( nonAnimUnsignedIntIndex ) );
474 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) );
475 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) );
476 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV3Index ) );
477 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) );
478 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) );
479 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) );
480 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimUnsignedIntIndex ) );
482 DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
483 DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get<Vector2>(), TEST_LOCATION );
484 DALI_TEST_EQUALS( Vector3(1.f, 2.f, 3.f) , actor.GetProperty( nonAnimV3Index ).Get<Vector3>(), TEST_LOCATION );
485 DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get<Vector4>(), TEST_LOCATION );
486 DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get<bool>(), TEST_LOCATION );
487 DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get<float>(), TEST_LOCATION );
488 DALI_TEST_EQUALS( unsingedIntTest, actor.GetProperty( nonAnimUnsignedIntIndex ).Get<unsigned int>(), TEST_LOCATION );
493 int UtcDaliHandleNonAnimtableProperties(void)
495 tet_infoline("Test Non Animatable Properties");
496 TestApplication application;
498 Actor actor = Actor::New();
500 Property::Index nonAnimStringIndex = actor.RegisterProperty( "man-from-delmonte", std::string("no"), Property::READ_WRITE);
502 //// modify writable?
505 actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
507 catch (Dali::DaliException& e)
509 DALI_TEST_CHECK(!"exception");
512 DALI_TEST_CHECK( "yes" == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
514 //// cannot modify read only?
515 Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY);
517 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
518 DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
520 bool exception = false;
523 actor.SetProperty( readonly, Property::Value(1.f) );
525 catch (Dali::DaliException& e)
530 DALI_TEST_CHECK(exception);
532 DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
534 /// animatable can be set
535 Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE);
537 DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
538 DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
543 actor.SetProperty( write_anim, Property::Value(1.f) );
545 catch (Dali::DaliException& e)
550 DALI_TEST_CHECK(!exception);
552 //// animate a non animatable property is a noop?
553 float durationSeconds(2.0f);
554 Animation animation = Animation::New(durationSeconds);
555 bool relativeValue(true);
561 animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunctions::EaseIn);
563 application.SendNotification();
564 application.Render(static_cast<unsigned int>(durationSeconds*0100.0f)/* some progress */);
566 catch (Dali::DaliException& e)
571 DALI_TEST_CHECK(!exception);
572 DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
577 int UtcDaliHandleNonAnimtableCompositeProperties(void)
579 tet_infoline("Test Non Animatable Composite Properties");
580 TestApplication application;
582 Actor actor = Actor::New();
584 Property::Value value(Property::ARRAY);
585 Property::Array anArray;
586 DALI_TEST_CHECK( Property::Value(anArray).GetType() == Property::ARRAY ); // 2nd constructor
588 value.AppendItem( Property::Value( 0.f ) );
589 value.AppendItem( "a string" );
590 value.SetItem(0, Property::Value( 5.f )); // exercise SetItem
592 int index = value.AppendItem( Vector3(1,2,3) );
594 DALI_TEST_EQUALS( 2, index, TEST_LOCATION);
595 DALI_TEST_EQUALS( 3, value.GetSize(), TEST_LOCATION);
597 Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE);
599 Property::Value out = actor.GetProperty( propertyIndex );
601 DALI_TEST_CHECK( Property::FLOAT == out.GetItem(0).GetType());
602 DALI_TEST_CHECK( Property::STRING == out.GetItem(1).GetType());
603 DALI_TEST_CHECK( Property::VECTOR3 == out.GetItem(2).GetType());
605 DALI_TEST_EQUALS( 5.f, out.GetItem(0).Get<float>(), TEST_LOCATION);
606 DALI_TEST_EQUALS( "a string", out.GetItem(1).Get<std::string>(), TEST_LOCATION);
607 DALI_TEST_EQUALS( Vector3(1,2,3), out.GetItem(2).Get<Vector3>(), TEST_LOCATION);
610 Property::Value valueMap(Property::MAP);
611 Property::Map aKindofMap;
612 DALI_TEST_CHECK( Property::Value(aKindofMap).GetType() == Property::MAP ); // 2nd constructor
614 valueMap.SetValue("key", 5.f);
615 valueMap.SetValue("2key", "a string");
617 DALI_TEST_EQUALS( true, valueMap.HasKey("key"), TEST_LOCATION);
618 DALI_TEST_EQUALS( "key", valueMap.GetKey(0), TEST_LOCATION);
620 DALI_TEST_EQUALS( true, valueMap.HasKey("2key"), TEST_LOCATION);
621 DALI_TEST_EQUALS( "2key", valueMap.GetKey(1), TEST_LOCATION);
623 DALI_TEST_EQUALS( 5.f, valueMap.GetValue("key").Get<float>(), TEST_LOCATION);
624 DALI_TEST_EQUALS( "a string", valueMap.GetValue("2key").Get<std::string>(), TEST_LOCATION);
626 valueMap.SetItem(0, Property::Value("a string"));
627 valueMap.SetItem(1, Property::Value(5.f));
629 DALI_TEST_EQUALS( 5.f, valueMap.GetValue("2key").Get<float>(), TEST_LOCATION);
630 DALI_TEST_EQUALS( "a string", valueMap.GetValue("key").Get<std::string>(), TEST_LOCATION);
633 valueMap = Property::Value(Property::MAP);
635 valueMap.SetValue("key", 5.f);
636 valueMap.SetValue("2key", "a string");
638 DALI_TEST_EQUALS( 5.f, valueMap.GetItem(0).Get<float>(), TEST_LOCATION);
639 DALI_TEST_EQUALS( "a string", valueMap.GetItem(1).Get<std::string>(), TEST_LOCATION);
641 DALI_TEST_EQUALS( 2, valueMap.GetSize(), TEST_LOCATION);
643 // composite types not animatable
644 bool exception = false;
647 /* Property::Index mapPropertyIndex = */ actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE);
649 catch (Dali::DaliException& e)
652 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
655 DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
658 Property::Value mapOfMaps(Property::MAP);
660 mapOfMaps.SetValue( "key", Property::Value(Property::MAP) );
661 mapOfMaps.SetValue( "2key", "a string" );
663 DALI_TEST_EQUALS( "a string", mapOfMaps.GetValue("2key").Get<std::string>(), TEST_LOCATION);
665 mapOfMaps.GetValue("key").SetValue("subkey", 5.f);
667 DALI_TEST_EQUALS( true, mapOfMaps.GetValue("key").HasKey("subkey"), TEST_LOCATION);
668 DALI_TEST_EQUALS( 5.f, mapOfMaps.GetValue("key").GetValue("subkey").Get<float>(), TEST_LOCATION);
671 Property::Value listOfMaps(Property::ARRAY);
673 listOfMaps.AppendItem( Property::Value(Property::MAP) );
674 listOfMaps.AppendItem( Property::Value(Property::MAP) );
676 listOfMaps.GetItem(0).SetValue("key", 5.f);
677 listOfMaps.GetItem(1).SetValue("key",10.f);
679 DALI_TEST_EQUALS( 5.f, listOfMaps.GetItem(0).GetValue("key").Get<float>(), TEST_LOCATION );
680 DALI_TEST_EQUALS( 10.f, listOfMaps.GetItem(1).GetValue("key").Get<float>(), TEST_LOCATION );
685 int UtcDaliHandleSetProperty01(void)
687 tet_infoline("Positive Test Dali::Handle::SetProperty()");
688 TestApplication application;
690 Actor actor = Actor::New();
691 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::PARENT_ORIGIN ).Get<Vector3>() );
693 actor.SetProperty( Actor::PARENT_ORIGIN, ParentOrigin::CENTER );
694 // flush the queue and render once
695 application.SendNotification();
696 application.Render();
697 DALI_TEST_CHECK( ParentOrigin::CENTER == actor.GetProperty( Actor::PARENT_ORIGIN ).Get<Vector3>() );
701 int UtcDaliHandleSetProperty02(void)
703 tet_infoline("Positive Test Dali::Handle::SetProperty()");
704 TestApplication application;
706 Actor actor = Actor::New();
708 DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::WORLD_POSITION ) );
712 // World position is not writable
713 actor.SetProperty( Actor::WORLD_POSITION, Vector3(1,2,3) );
715 catch (Dali::DaliException& e)
717 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
718 DALI_TEST_ASSERT(e, "IsDefaultPropertyWritable(index) && \"Property is read-only\"", TEST_LOCATION);
724 int UtcDaliHandleRegisterProperty(void)
726 tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
727 TestApplication application;
729 Actor actor = Actor::New();
730 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::PARENT_ORIGIN ).Get<Vector3>() );
735 int UtcDaliHandleGetProperty(void)
737 tet_infoline("Positive Test Dali::Handle::GetProperty()");
738 TestApplication application;
740 Actor actor = Actor::New();
742 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::PARENT_ORIGIN ).Get<Vector3>() );
743 DALI_TEST_CHECK( AnchorPoint::CENTER == actor.GetProperty( Actor::ANCHOR_POINT ).Get<Vector3>() );
744 DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::SIZE ).Get<Vector3>() );
745 DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::POSITION ).Get<Vector3>() );
746 DALI_TEST_CHECK( Vector3::ONE == actor.GetProperty( Actor::SCALE ).Get<Vector3>() );
747 DALI_TEST_CHECK( true == actor.GetProperty( Actor::VISIBLE ).Get<bool>() );
748 DALI_TEST_CHECK( Color::WHITE == actor.GetProperty( Actor::COLOR ).Get<Vector4>() );
752 int UtcDaliHandleDownCast(void)
754 TestApplication application;
755 tet_infoline("Testing Dali::Handle::DownCast()");
757 Actor actor = Actor::New();
759 BaseHandle baseHandle = actor;
761 Handle handle = Handle::DownCast(baseHandle);
763 DALI_TEST_CHECK( handle );
765 baseHandle = BaseHandle();
767 handle = Handle::DownCast(baseHandle);
769 DALI_TEST_CHECK( !handle );
774 int UtcDaliHandleCreateProperty(void)
776 TestApplication application;
777 tet_infoline("Testing PropertyTypes::GetName()");
779 Property::Type type = Property::NONE;
781 // Value(Value&) ctor and Value(Type&) ctor
782 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
783 DALI_TEST_CHECK( Property::NONE == type );
786 type = Property::BOOLEAN;
788 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
789 DALI_TEST_CHECK( PropertyTypes::Get<bool>() == type );
791 type = Property::FLOAT;
793 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
794 DALI_TEST_CHECK( PropertyTypes::Get<float>() == type );
796 type = Property::INTEGER;
798 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
799 DALI_TEST_CHECK( PropertyTypes::Get<int>() == type );
801 type = Property::UNSIGNED_INTEGER;
803 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
804 DALI_TEST_CHECK( PropertyTypes::Get<unsigned int>() == type );
806 type = Property::VECTOR2;
808 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
809 DALI_TEST_CHECK( PropertyTypes::Get<Vector2>() == type );
811 type = Property::VECTOR3;
813 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
814 DALI_TEST_CHECK( PropertyTypes::Get<Vector3>() == type );
816 type = Property::VECTOR4;
818 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
819 DALI_TEST_CHECK( PropertyTypes::Get<Vector4>() == type );
821 type = Property::MATRIX3;
823 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
824 DALI_TEST_CHECK( PropertyTypes::Get<Matrix3>() == type );
826 type = Property::MATRIX;
828 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
829 DALI_TEST_CHECK( PropertyTypes::Get<Matrix>() == type );
831 typedef Dali::Rect<int> Rectangle;
832 type = Property::RECTANGLE;
834 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
835 DALI_TEST_CHECK( PropertyTypes::Get<Rectangle>() == type );
837 type = Property::ROTATION;
839 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
840 DALI_TEST_CHECK( PropertyTypes::Get<Quaternion>() == type );
842 type = Property::ROTATION;
844 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
845 DALI_TEST_CHECK( PropertyTypes::Get<AngleAxis>() == type );
847 type = Property::STRING;
849 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
850 DALI_TEST_CHECK( PropertyTypes::Get<std::string>() == type );
852 type = Property::ARRAY;
854 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
855 DALI_TEST_CHECK( PropertyTypes::Get<Property::Array>() == type );
857 type = Property::MAP;
859 DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
860 DALI_TEST_CHECK( PropertyTypes::Get<Property::Map>() == type );
864 int UtcDaliHandleGetPropertyGet(void)
866 TestApplication application;
867 tet_infoline("Testing PropertyTypes::GetName()");
869 Property::Value value;
872 value = Property::Value(true);
874 DALI_TEST_CHECK( true == b );
877 value = Property::Value(10.f);
879 DALI_TEST_CHECK( Dali::Equals(10.f, f) );
882 value = Property::Value(10);
884 DALI_TEST_CHECK( 10 == i );
887 value = Property::Value(10U);
889 DALI_TEST_CHECK( 10 == ui );
891 Vector2 v2 = Vector2(0,0);
892 value = Property::Value( Vector2(1,1) );
894 DALI_TEST_CHECK( Vector2(1,1) == v2 );
896 Vector3 v3 = Vector3(0.f,0.f,0.f);
897 value = Property::Value( Vector3(1.f,1.f,1.f) );
899 DALI_TEST_CHECK( Vector3(1.f,1.f,1.f) == v3 );
901 Vector4 v4 = Vector4(0,0,0,0);
902 value = Property::Value( Vector4(1,1,1,1) );
904 DALI_TEST_CHECK( Vector4(1,1,1,1) == v4 );
906 Matrix3 m3 = Matrix3(0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f);
907 value = Property::Value( Matrix3::IDENTITY );
909 DALI_TEST_CHECK( Matrix3::IDENTITY == m3 );
911 Matrix m = Matrix(true);
912 value = Property::Value( Matrix::IDENTITY );
914 DALI_TEST_CHECK( Matrix::IDENTITY == m );
916 typedef Dali::Rect<int> Rectangle;
917 Rectangle r = Rectangle(0,0,0,0);
918 value = Property::Value( Rectangle(1,1,1,1) );
920 DALI_TEST_CHECK( Rectangle(1,1,1,1) == r );
922 Quaternion q = Quaternion(0,0,0,0);
923 value = Property::Value( Quaternion(1,1,1,1) );
925 DALI_TEST_CHECK( Quaternion(1,1,1,1) == q );
927 AngleAxis aa = AngleAxis( Degree(0), Vector3(0.f,0.f,0.f) );
928 value = Property::Value( AngleAxis( Radian(Math::PI_2), Vector3::XAXIS ));
930 Quaternion r8(Radian(Degree(aa.angle)), aa.axis);
931 DALI_TEST_EQUALS(r8, Quaternion(Math::PI_2, Vector3::XAXIS), 0.001, TEST_LOCATION);
933 std::string s = "no";
934 value = Property::Value("yes");
936 DALI_TEST_CHECK( "yes" == s );
938 Property::Array array;
939 value = Property::Value(Property::ARRAY);
940 value.AppendItem(10);
943 array[0].Get(getItem);
944 DALI_TEST_CHECK( getItem == 10 );
947 value = Property::Value(Property::MAP);
948 value.SetValue("key", "value");
950 DALI_TEST_CHECK( map[0].first == "key" );
955 int UtcDaliHandleGetPropertyIndices(void)
957 TestApplication application;
958 Property::IndexContainer indices;
961 Actor actor = Actor::New();
962 actor.GetPropertyIndices( indices );
963 DALI_TEST_CHECK( ! indices.empty() );
964 DALI_TEST_EQUALS( indices.size(), actor.GetPropertyCount(), TEST_LOCATION );