2 * Copyright (c) 2020 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 "dali-test-suite-utils/test-custom-actor.h"
27 #include <mesh-builder.h>
31 void handle_test_startup(void)
33 test_return_value = TET_UNDEF;
36 void handle_test_cleanup(void)
38 test_return_value = TET_PASS;
44 /// Allows the creation of a BaseObject
45 class BaseObjectType : public BaseObject
53 Handle ImplicitCopyConstructor(Handle passedByValue)
55 // object + copy + passedByValue, ref count == 3
56 DALI_TEST_CHECK(passedByValue);
59 DALI_TEST_EQUALS(3, passedByValue.GetBaseObject().ReferenceCount(), TEST_LOCATION);
68 int UtcDaliHandleConstructorVoid(void)
70 TestApplication application;
71 tet_infoline("Testing Dali::Handle::Handle()");
75 DALI_TEST_CHECK(!object);
80 int UtcDaliHandleCopyConstructor(void)
82 TestApplication application;
83 tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
85 // Initialize an object, ref count == 1
86 Handle object = Actor::New();
88 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
90 // Copy the object, ref count == 2
92 DALI_TEST_CHECK(copy);
95 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
99 // Pass by value, and return another copy, ref count == 3
100 Handle anotherCopy = ImplicitCopyConstructor(copy);
102 DALI_TEST_CHECK(anotherCopy);
105 DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
109 // anotherCopy out of scope, ref count == 2
110 DALI_TEST_CHECK(copy);
113 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
118 int UtcDaliHandleAssignmentOperator(void)
120 TestApplication application;
121 tet_infoline("Testing Dali::Handle::operator=");
123 Handle object = Actor::New();
125 DALI_TEST_CHECK(object);
126 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
129 DALI_TEST_CHECK(!copy);
132 DALI_TEST_CHECK(copy);
133 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
134 DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject()));
138 int UtcDaliHandleMoveConstructor(void)
140 TestApplication application;
142 // Initialize a handle, ref count == 1
143 Handle handle = Actor::New();
145 DALI_TEST_EQUALS( 1, handle.GetBaseObject().ReferenceCount(), TEST_LOCATION );
148 Property::Index index = handle.RegisterProperty( "customProperty", value );
149 DALI_TEST_CHECK( handle.GetProperty<int>( index ) == value );
151 // Move the object, ref count == 1
152 Handle move = std::move( handle );
153 DALI_TEST_CHECK( move );
155 // Check that object is moved (not copied, so ref count keeps the same)
156 DALI_TEST_EQUALS( 1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
157 DALI_TEST_CHECK( move.GetProperty<int>( index ) == value );
158 DALI_TEST_CHECK( !handle );
163 int UtcDaliHandleMoveAssignment(void)
165 TestApplication application;
167 // Initialize a handle, ref count == 1
168 Handle handle = Actor::New();
170 DALI_TEST_EQUALS( 1, handle.GetBaseObject().ReferenceCount(), TEST_LOCATION );
173 Property::Index index = handle.RegisterProperty( "customProperty", value );
174 DALI_TEST_CHECK( handle.GetProperty<int>( index ) == value );
176 // Move the object, ref count == 1
178 move = std::move( handle );
179 DALI_TEST_CHECK( move );
181 // Check that object is moved (not copied, so ref count keeps the same)
182 DALI_TEST_EQUALS( 1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
183 DALI_TEST_CHECK( move.GetProperty<int>( index ) == value );
184 DALI_TEST_CHECK( !handle );
189 int UtcDaliHandleSupports(void)
191 tet_infoline("Positive Test Dali::Handle::Supports()");
192 TestApplication application;
194 Actor actor = Actor::New();
195 DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) );
199 int UtcDaliHandleGetPropertyCount(void)
201 tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
202 TestApplication application;
204 Actor actor = Actor::New();
205 int defaultPropertyCount( actor.GetPropertyCount() );
207 // Register a dynamic property
208 actor.RegisterProperty( "testProperty", float(123.0f) );
209 DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() );
213 int UtcDaliHandleGetPropertyName(void)
215 tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
216 TestApplication application;
218 Actor actor = Actor::New();
219 DALI_TEST_CHECK( "parentOrigin" == actor.GetPropertyName( Actor::Property::PARENT_ORIGIN ) );
221 // Register a dynamic property
222 std::string name("thisNameShouldMatch");
223 Property::Index index = actor.RegisterProperty( name, float(123.0f) );
224 DALI_TEST_CHECK( name == actor.GetPropertyName( index ) );
229 int UtcDaliHandleGetPropertyIndex01(void)
231 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
232 TestApplication application;
234 Actor actor = Actor::New();
235 DALI_TEST_CHECK( Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parentOrigin") );
237 // Register a dynamic property
238 std::string name("thisNameShouldMatch");
239 Property::Index index = actor.RegisterProperty( name, float(123.0f) );
240 DALI_TEST_CHECK( index == actor.GetPropertyIndex( name ) );
244 int UtcDaliHandleGetPropertyIndex02(void)
246 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex() int key");
247 TestApplication application;
249 Integration::Scene stage = application.GetScene();
251 Actor actor = Actor::New();
254 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
256 application.SendNotification();
257 application.Render();
259 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
260 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
262 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
263 const float withFlake(99.f);
265 Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
266 Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
267 Property::Index index3 = actor.RegisterProperty( "MyPropertyTwo", Vector3::ONE );
268 Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
269 Property::Index index5 = actor.RegisterProperty( "MyPropertyThree", Vector3::ONE );
271 application.SendNotification();
272 application.Render();
274 // Test that we can get the property index from the integer key
275 Property::Index testIndex1 = DevelHandle::GetPropertyIndex( actor, key1 );
276 Property::Index testIndex2 = DevelHandle::GetPropertyIndex( actor, key2 );
278 DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION );
279 DALI_TEST_EQUALS( index4, testIndex2, TEST_LOCATION );
281 // Test that we keep the same indices on the named properties
282 Property::Index testIndex = actor.GetPropertyIndex("MyPropertyOne");
283 DALI_TEST_EQUALS(testIndex, index1, TEST_LOCATION);
284 testIndex = actor.GetPropertyIndex("MyPropertyTwo");
285 DALI_TEST_EQUALS(testIndex, index3, TEST_LOCATION);
286 testIndex = actor.GetPropertyIndex("MyPropertyThree");
287 DALI_TEST_EQUALS(testIndex, index5, TEST_LOCATION);
288 testIndex = actor.GetPropertyIndex("sideColor");
289 DALI_TEST_EQUALS(testIndex, index2, TEST_LOCATION);
290 testIndex = actor.GetPropertyIndex("iceCream");
291 DALI_TEST_EQUALS(testIndex, index4, TEST_LOCATION);
293 DALI_TEST_EQUALS(defaultPropertyCount+5, actor.GetPropertyCount(), TEST_LOCATION);
297 int UtcDaliHandleGetPropertyIndex03(void)
299 TestApplication application;
301 Actor actor = Actor::New();
303 std::string myName("croydon");
304 Property::Index intKey = CORE_PROPERTY_MAX_INDEX+1;
305 Property::Value value( Color::GREEN );
306 Property::Index myIndex = DevelHandle::RegisterProperty( actor, intKey, myName, value );
308 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, intKey ), TEST_LOCATION );
310 Property::Key key1(myName);
311 Property::Key key2(intKey);
313 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key1 ), TEST_LOCATION );
314 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key2 ), TEST_LOCATION );
319 int UtcDaliHandleIsPropertyWritable(void)
321 tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
322 TestApplication application;
324 Actor actor = Actor::New();
326 // Actor properties which are writable:
327 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN ) );
328 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_X ) );
329 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Y ) );
330 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Z ) );
331 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT ) );
332 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_X ) );
333 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Y ) );
334 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Z ) );
335 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE ) );
336 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_WIDTH ) );
337 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_HEIGHT ) );
338 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_DEPTH ) );
339 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION ) );
340 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_X ) );
341 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Y ) );
342 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Z ) );
343 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ORIENTATION ) );
344 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE ) );
345 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_X ) );
346 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Y ) );
347 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Z ) );
348 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::VISIBLE ) );
349 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR ) );
350 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_RED ) );
351 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_GREEN ) );
352 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_BLUE ) );
353 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_ALPHA ) );
354 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::OPACITY ) );
356 // World-properties are not writable:
357 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
358 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_ORIENTATION ) );
359 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_SCALE ) );
360 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_COLOR ) );
361 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_X ) );
362 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Y ) );
363 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Z ) );
368 int UtcDaliHandleIsPropertyAnimatable(void)
370 tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
371 TestApplication application;
373 Actor actor = Actor::New();
375 // Actor properties which are animatable:
376 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN ) );
377 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_X ) );
378 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Y ) );
379 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Z ) );
380 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT ) );
381 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_X ) );
382 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Y ) );
383 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Z ) );
384 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE ) );
385 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_WIDTH ) );
386 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_HEIGHT ) );
387 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_DEPTH ) );
388 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION ) );
389 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_X ) );
390 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Y ) );
391 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Z ) );
392 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::ORIENTATION ) );
393 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE ) );
394 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_X ) );
395 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Y ) );
396 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Z ) );
397 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::VISIBLE ) );
398 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR ) );
399 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_RED ) );
400 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_GREEN ) );
401 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_BLUE ) );
402 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_ALPHA ) );
403 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::OPACITY ) );
405 // World-properties can not be animated
406 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION ) );
407 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_ORIENTATION ) );
408 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_SCALE ) );
409 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_COLOR ) );
410 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_X ) );
411 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Y ) );
412 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Z ) );
417 int UtcDaliHandleIsPropertyAConstraintInput(void)
419 TestApplication application;
421 Actor actor = Actor::New();
423 // Actor properties which can be used as a constraint input:
424 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN ) );
425 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_X ) );
426 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Y ) );
427 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Z ) );
428 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT ) );
429 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_X ) );
430 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Y ) );
431 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Z ) );
432 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE ) );
433 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_WIDTH ) );
434 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_HEIGHT ) );
435 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_DEPTH ) );
436 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION ) );
437 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_X ) );
438 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Y ) );
439 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Z ) );
440 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ORIENTATION ) );
441 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE ) );
442 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_X ) );
443 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Y ) );
444 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Z ) );
445 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::VISIBLE ) );
446 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR ) );
447 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_RED ) );
448 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_GREEN ) );
449 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_BLUE ) );
450 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_ALPHA ) );
451 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::OPACITY ) );
452 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION ) );
453 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_ORIENTATION ) );
454 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_SCALE ) );
455 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_COLOR ) );
456 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_X ) );
457 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Y ) );
458 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Z ) );
460 // Actor properties that cannot be used as a constraint input
461 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::NAME ) );
462 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SENSITIVE ) );
463 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::LEAVE_REQUIRED ) );
464 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_ORIENTATION ) );
465 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_SCALE ) );
466 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_MODE ) );
467 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::DRAW_MODE ) );
468 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE_FACTOR ) );
474 int UtcDaliHandleGetPropertyType(void)
476 tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
477 TestApplication application;
479 Actor actor = Actor::New();
480 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::PARENT_ORIGIN ) );
481 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::ANCHOR_POINT ) );
482 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::SIZE ) );
483 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::POSITION ) );
484 DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( Actor::Property::ORIENTATION ) );
485 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::SCALE ) );
486 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( Actor::Property::VISIBLE ) );
487 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( Actor::Property::COLOR ) );
489 // Register some dynamic properties
490 Property::Index boolIndex = actor.RegisterProperty( "boolProperty", bool(true) );
491 Property::Index floatIndex = actor.RegisterProperty( "floatProperty", float(123.0f) );
492 Property::Index intIndex = actor.RegisterProperty( "intProperty", 123 );
493 Property::Index vector2Index = actor.RegisterProperty( "vector2Property", Vector2(1.0f, 2.0f) );
494 Property::Index vector3Index = actor.RegisterProperty( "vector3Property", Vector3(1.0f, 2.0f, 3.0f) );
495 Property::Index vector4Index = actor.RegisterProperty( "vector4Property", Vector4(1.0f, 2.0f, 3.0f, 4.0f) );
496 Property::Index rotationIndex = actor.RegisterProperty( "rotationProperty", AngleAxis(Degree(180.0f), Vector3::YAXIS) );
498 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( boolIndex ) );
499 DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( floatIndex ) );
500 DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( intIndex ) );
501 DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( vector2Index ) );
502 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) );
503 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) );
504 DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) );
506 // Non animatable properties
507 Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("yes"), Property::READ_WRITE);
508 Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE);
509 Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
510 Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
511 Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE);
512 Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE);
513 Property::Index nonAnimIntegerIndex = actor.RegisterProperty( "int", 0, Property::READ_WRITE);
515 DALI_TEST_CHECK( nonAnimStringIndex != Property::INVALID_INDEX );
516 DALI_TEST_CHECK( nonAnimV2Index != Property::INVALID_INDEX );
517 DALI_TEST_CHECK( nonAnimV3Index != Property::INVALID_INDEX );
518 DALI_TEST_CHECK( nonAnimV4Index != Property::INVALID_INDEX );
519 DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX );
520 DALI_TEST_CHECK( nonAnimFloatIndex != Property::INVALID_INDEX );
521 DALI_TEST_CHECK( nonAnimIntegerIndex != Property::INVALID_INDEX );
523 DALI_TEST_CHECK( Property::STRING == actor.GetPropertyType( nonAnimStringIndex ) );
524 DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( nonAnimV2Index ) );
525 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( nonAnimV3Index ) );
526 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( nonAnimV4Index ) );
527 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( nonAnimBooleanIndex ) );
528 DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( nonAnimFloatIndex ) );
529 DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( nonAnimIntegerIndex ) );
531 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) );
532 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) );
533 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV3Index ) );
534 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) );
535 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) );
536 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) );
537 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimIntegerIndex ) );
539 DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
540 DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get<Vector2>(), TEST_LOCATION );
541 DALI_TEST_EQUALS( Vector3(1.f, 2.f, 3.f) , actor.GetProperty( nonAnimV3Index ).Get<Vector3>(), TEST_LOCATION );
542 DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get<Vector4>(), TEST_LOCATION );
543 DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get<bool>(), TEST_LOCATION );
544 DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get<float>(), TEST_LOCATION );
545 DALI_TEST_EQUALS( 0, actor.GetProperty( nonAnimIntegerIndex ).Get<int>(), TEST_LOCATION );
550 int UtcDaliHandleNonAnimatableProperties(void)
552 tet_infoline("Test Non Animatable Properties");
553 TestApplication application;
555 Actor actor = Actor::New();
557 Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE);
559 //// modify writable?
560 actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
562 DALI_TEST_CHECK( "yes" == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
564 //// cannot modify read only?
565 Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY);
567 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
568 DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
570 actor.SetProperty( readonly, Property::Value(1.f) );
571 // trying to set a read-only property is a no-op
573 DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
575 /// animatable can be set
576 Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE);
578 DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
579 DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
581 actor.SetProperty( write_anim, Property::Value(1.f) );
583 //// animate a non animatable property throws
584 float durationSeconds(2.0f);
585 Animation animation = Animation::New(durationSeconds);
586 bool relativeValue(true);
589 animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
591 catch ( Dali::DaliException& e )
593 DALI_TEST_ASSERT( e, "Property type is not animatable", TEST_LOCATION );
596 DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
601 int UtcDaliHandleNonAnimtableCompositeProperties(void)
603 tet_infoline("Test Non Animatable Composite Properties");
604 TestApplication application;
606 Actor actor = Actor::New();
608 Property::Value value(Property::ARRAY);
609 Property::Array* array = value.GetArray();
610 DALI_TEST_CHECK( array );
612 array->PushBack( Property::Value( 0.1f ) );
613 array->PushBack( "a string" );
614 array->PushBack( Property::Value( Vector3(1,2,3) ) );
616 DALI_TEST_EQUALS( 3u, array->Count(), TEST_LOCATION );
618 Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE );
620 Property::Value out = actor.GetProperty( propertyIndex );
621 Property::Array* outArray = out.GetArray();
622 DALI_TEST_CHECK( outArray != NULL );
624 DALI_TEST_CHECK( Property::FLOAT == outArray->GetElementAt(0).GetType());
625 DALI_TEST_CHECK( Property::STRING == outArray->GetElementAt(1).GetType());
626 DALI_TEST_CHECK( Property::VECTOR3 == outArray->GetElementAt(2).GetType());
628 DALI_TEST_EQUALS( 0.1f, outArray->GetElementAt(0).Get<float>(), TEST_LOCATION);
629 DALI_TEST_EQUALS( "a string", outArray->GetElementAt(1).Get<std::string>(), TEST_LOCATION);
630 DALI_TEST_EQUALS( Vector3(1,2,3), outArray->GetElementAt(2).Get<Vector3>(), TEST_LOCATION);
632 // composite types not animatable
633 bool exception = false;
636 actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE);
638 catch (Dali::DaliException& e)
641 DALI_TEST_PRINT_ASSERT( e );
644 DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
647 Property::Value mapOfMaps(Property::MAP);
648 Property::Map* map = mapOfMaps.GetMap();
650 map->Insert( "key", Property::Value(Property::MAP) );
651 map->Insert( "2key", "a string" );
653 DALI_TEST_EQUALS( "a string", (*map)["2key"].Get<std::string>(), TEST_LOCATION);
655 Property::Map* innerMap = map->Find("key")->GetMap();
656 innerMap->Insert( "subkey", 5.f );
658 DALI_TEST_CHECK( NULL != map->Find("key")->GetMap()->Find("subkey") );
659 DALI_TEST_EQUALS( 5.f, map->Find("key")->GetMap()->Find("subkey")->Get<float>(), TEST_LOCATION);
663 int UtcDaliHandleSetProperty01(void)
665 tet_infoline("Positive Test Dali::Handle::SetProperty()");
666 TestApplication application;
668 Actor actor = Actor::New();
669 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
671 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
672 // flush the queue and render once
673 application.SendNotification();
674 application.Render();
675 DALI_TEST_CHECK( ParentOrigin::CENTER == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
679 int UtcDaliHandleSetProperty02(void)
681 tet_infoline("Positive Test Dali::Handle::SetProperty()");
682 TestApplication application;
684 Actor actor = Actor::New();
686 DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
688 // World position is not writable so this is a no-op and should not crash
689 actor.SetProperty( Actor::Property::WORLD_POSITION, Vector3(1,2,3) );
694 int UtcDaliHandleRegisterProperty01(void)
696 tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
697 TestApplication application;
699 Integration::Scene stage = application.GetScene();
701 Actor actor = Actor::New();
704 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
706 application.SendNotification();
707 application.Render();
709 Property::Index index1 = actor.RegisterProperty( "MyProperty", Vector3::ONE );
711 application.SendNotification();
712 application.Render();
714 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION );
715 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
717 // No new property should be registered when we call the below function
718 Property::Index index2 = actor.RegisterProperty( "MyProperty", Vector3::ZAXIS );
720 application.SendNotification();
721 application.Render();
724 DALI_TEST_EQUALS( index1, index2, TEST_LOCATION ); // We should have the same index as per the first registration
725 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION ); // Property count should be the same
726 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index2 ), Vector3::ZAXIS, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
731 int UtcDaliHandleRegisterProperty02(void)
733 tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key");
734 TestApplication application;
736 Integration::Scene stage = application.GetScene();
738 Actor actor = Actor::New();
741 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
743 application.SendNotification();
744 application.Render();
746 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
747 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
749 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
750 const float withFlake(99.f);
752 Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
753 Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
754 Property::Index index3 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
756 application.SendNotification();
757 application.Render();
759 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION );
760 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
761 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), testColor, TEST_LOCATION );
762 DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), withFlake, TEST_LOCATION );
764 // No new property should be registered when we call the below functions
765 Property::Index testIndex2 = actor.RegisterProperty( "iceCream", 2200.f );
766 Property::Index testIndex1 = actor.RegisterProperty( "sideColor", Color::BLACK );
767 application.SendNotification();
768 application.Render();
770 DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION ); // We should have the same index as per the first registration
771 DALI_TEST_EQUALS( index3, testIndex2, TEST_LOCATION ); // We should have the same index as per the first registration
772 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION ); // Property count should be the same
773 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), Color::BLACK, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
774 DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), 2200.f, TEST_LOCATION );
781 int UtcDaliHandleGetProperty(void)
783 tet_infoline("Positive Test Dali::Handle::GetProperty()");
784 TestApplication application;
786 Actor actor = Actor::New();
788 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
789 DALI_TEST_CHECK( AnchorPoint::CENTER == actor.GetProperty( Actor::Property::ANCHOR_POINT ).Get<Vector3>() );
790 DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::Property::SIZE ).Get<Vector3>() );
791 DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::Property::POSITION ).Get<Vector3>() );
792 DALI_TEST_CHECK( Vector3::ONE == actor.GetProperty( Actor::Property::SCALE ).Get<Vector3>() );
793 DALI_TEST_CHECK( true == actor.GetProperty( Actor::Property::VISIBLE ).Get<bool>() );
794 DALI_TEST_CHECK( Color::WHITE == actor.GetProperty( Actor::Property::COLOR ).Get<Vector4>() );
798 int UtcDaliHandleDownCast(void)
800 TestApplication application;
801 tet_infoline("Testing Dali::Handle::DownCast()");
803 Actor actor = Actor::New();
805 BaseHandle baseHandle = actor;
807 Handle handle = Handle::DownCast(baseHandle);
809 DALI_TEST_CHECK( handle );
811 baseHandle = BaseHandle();
813 handle = Handle::DownCast(baseHandle);
815 DALI_TEST_CHECK( !handle );
820 int UtcDaliHandleDownCastNegative(void)
822 TestApplication application;
824 // BaseObject is NOT an Object, so this DownCast should fail
825 BaseHandle handle( new BaseObjectType );
826 Handle customHandle1 = Handle::DownCast( handle );
827 DALI_TEST_CHECK( ! customHandle1 );
829 // A DownCast on an empty handle will also fail
831 Handle customHandle2 = Handle::DownCast( empty );
832 DALI_TEST_CHECK( ! customHandle2 );
836 int UtcDaliHandleGetPropertyIndices(void)
838 TestApplication application;
839 Property::IndexContainer indices;
842 Actor actor = Actor::New();
843 actor.GetPropertyIndices( indices );
844 int numDefaultProperties = indices.Size();
845 DALI_TEST_CHECK( numDefaultProperties > 0 );
846 DALI_TEST_EQUALS( numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION );
848 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
849 const float withFlake(99.f);
851 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
852 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
854 actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
855 DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
856 actor.RegisterProperty( "MyPropertyTwo", 1234 );
857 Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
858 actor.RegisterProperty( "MyPropertyThree", Vector2(.2f,.7f) );
860 actor.GetPropertyIndices( indices );
862 DALI_TEST_EQUALS( indices.Size(), numDefaultProperties + 5, TEST_LOCATION );
863 DALI_TEST_EQUALS( indices[indices.Size()-2], index4, TEST_LOCATION );
868 int UtcDaliHandleRegisterPropertyTypes(void)
870 TestApplication application;
872 struct PropertyTypeAnimatable
875 Property::Value value;
879 Property::Array array;
882 PropertyTypeAnimatable properties[] =
884 { "Property::BOOLEAN", true, true },
885 { "Property::FLOAT", 1.0f, true },
886 { "Property::INTEGER", 1, true },
887 { "Property::VECTOR2", Vector2::ONE, true },
888 { "Property::VECTOR3", Vector3::ONE, true },
889 { "Property::VECTOR4", Vector4::ONE, true },
890 { "Property::MATRIX3", Matrix3::IDENTITY, true },
891 { "Property::MATRIX", Matrix::IDENTITY, true },
892 { "Property::RECTANGLE", Rect<int>(), false },
893 { "Property::ROTATION", AngleAxis(), true },
894 { "Property::STRING", std::string("Me"), false },
895 { "Property::ARRAY", array, false },
896 { "Property::MAP", map, false },
899 unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
901 for ( unsigned int i = 0; i < numOfProperties; ++i )
903 tet_printf( "Testing: %s\n", properties[i].name );
905 bool exception = false;
908 Actor actor = Actor::New();
909 actor.RegisterProperty( "manFromDelmonte", properties[i].value );
911 catch (Dali::DaliException& e)
916 DALI_TEST_CHECK( properties[i].animatable != exception );
921 int UtcDaliHandleCustomProperty(void)
923 TestApplication application;
925 Handle handle = Handle::New();
927 float startValue(1.0f);
928 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
929 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
931 application.SendNotification();
932 application.Render(0);
933 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
934 application.Render(0);
935 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
937 handle.SetProperty( index, 5.0f );
939 application.SendNotification();
940 application.Render(0);
941 DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
942 application.Render(0);
943 DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
947 int UtcDaliHandleCustomPropertyNone(void)
949 TestApplication application;
951 Handle handle = Handle::New();
953 Property::Value value( Property::NONE );
954 Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
956 // Negative test i.e. setting a property of type NONE is meaningless
957 handle.SetProperty( index, 5.0f );
959 DALI_TEST_CHECK( true ); // got here without crashing
964 int UtcDaliHandleCustomPropertyIntToFloat(void)
966 TestApplication application;
968 Handle handle = Handle::New();
970 float startValue(5.0f);
971 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
972 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
974 application.SendNotification();
975 application.Render(0);
976 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
978 handle.SetProperty( index, int(1) );
980 application.SendNotification();
981 application.Render(0);
982 DALI_TEST_CHECK( handle.GetProperty<float>(index) == 1.0f );
986 int UtcDaliHandleCustomPropertyFloatToInt(void)
988 TestApplication application;
990 Handle handle = Handle::New();
993 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
994 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
996 application.SendNotification();
997 application.Render(0);
998 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1000 handle.SetProperty( index, float(1.5) );
1002 application.SendNotification();
1003 application.Render(0);
1004 DALI_TEST_CHECK( handle.GetProperty<int>(index) == 1 );
1008 int UtcDaliHandleCustomPropertyInvalidToRect(void)
1010 TestApplication application;
1012 Handle handle = Handle::New();
1014 Rect<int> startValue(1,2,3,4);
1015 Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1016 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
1018 application.SendNotification();
1019 application.Render(0);
1020 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
1022 // Negative test i.e. there is no conversion from float to Rect
1023 handle.SetProperty( index, float(1.5) );
1025 application.SendNotification();
1026 application.Render(0);
1027 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
1029 // Positive test (sanity check)
1030 Rect<int> endValue(5,6,7,8);
1031 handle.SetProperty( index, endValue );
1032 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
1034 application.SendNotification();
1035 application.Render(0);
1036 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
1041 int UtcDaliHandleCustomPropertyInvalidToString(void)
1043 TestApplication application;
1045 Handle handle = Handle::New();
1047 std::string startValue( "Libraries gave us power" );
1048 Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1049 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1051 application.SendNotification();
1052 application.Render(0);
1053 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1055 // No conversion from Vector3 to std::string, therefore this should be a NOOP
1056 handle.SetProperty( index, Vector3(1,2,3) );
1058 application.SendNotification();
1059 application.Render(0);
1060 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1062 // Positive test (sanity check)
1063 std::string endValue( "Then work came and made us free" );
1064 handle.SetProperty( index, endValue );
1065 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
1067 application.SendNotification();
1068 application.Render(0);
1069 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
1074 int UtcDaliHandleCustomPropertyInvalidToArray(void)
1076 TestApplication application;
1078 Handle handle = Handle::New();
1080 Property::Value value( Property::ARRAY );
1081 std::string startValue( "The future teaches you to be alone" );
1082 value.GetArray()->PushBack( startValue );
1084 Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
1085 Property::Array check1 = handle.GetProperty< Property::Array >( index );
1086 DALI_TEST_EQUALS( check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1088 application.SendNotification();
1089 application.Render(0);
1090 Property::Array check2 = handle.GetProperty< Property::Array >( index );
1091 DALI_TEST_EQUALS( check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1093 // No conversion from int to ARRAY, therefore this should be a NOOP
1094 handle.SetProperty( index, int(2) );
1096 application.SendNotification();
1097 application.Render(0);
1098 Property::Array check3 = handle.GetProperty< Property::Array >( index );
1099 DALI_TEST_EQUALS( check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1101 // Positive test (sanity check)
1102 Property::Value value2(Property::ARRAY);
1103 std::string endValue( "The present to be afraid and cold" );
1104 value2.GetArray()->PushBack( endValue );
1105 handle.SetProperty( index, value2 );
1107 Property::Array check4 = handle.GetProperty< Property::Array >( index );
1108 DALI_TEST_EQUALS( check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
1110 application.SendNotification();
1111 application.Render(0);
1112 Property::Array check5 = handle.GetProperty< Property::Array >( index );
1113 DALI_TEST_EQUALS( check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
1118 int UtcDaliHandleCustomPropertyInvalidToMap(void)
1120 TestApplication application;
1122 Handle handle = Handle::New();
1124 Property::Value value( Property::MAP );
1125 std::string startValue( "Culture sucks down words" );
1126 value.GetMap()->Insert( "1", startValue );
1128 Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE );
1129 Property::Value* check1 = handle.GetProperty< Property::Map >( index ).Find("1");
1130 DALI_TEST_CHECK( NULL != check1 );
1132 // No conversion from float to MAP, therefore this should be a NOOP
1133 handle.SetProperty( index, float(3.0) );
1135 // Positive test (sanity check)
1136 Property::Value value2( Property::MAP );
1137 std::string endValue( "Itemise loathing and feed yourself smiles" );
1138 value.GetMap()->Insert( "1", endValue );
1139 handle.SetProperty( index, value2 );
1144 int UtcDaliHandleCustomPropertyInvalidToExtents(void)
1146 TestApplication application;
1148 Handle handle = Handle::New();
1150 Extents startValue(1,2,3,4);
1151 Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1152 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1154 application.SendNotification();
1155 application.Render(0);
1156 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1158 // Negative test i.e. there is no conversion from float to Extents
1159 handle.SetProperty( index, float(1.5) );
1161 application.SendNotification();
1162 application.Render(0);
1163 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1165 // Positive test (sanity check)
1166 Extents endValue(5,6,7,8);
1167 handle.SetProperty( index, endValue );
1168 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
1170 application.SendNotification();
1171 application.Render(0);
1172 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
1177 int UtcDaliHandleCustomPropertyInvalidToBool(void)
1179 TestApplication application;
1181 Handle handle = Handle::New();
1183 bool startValue(true);
1184 Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1185 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1187 application.SendNotification();
1188 application.Render(0);
1189 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1191 // Negative test i.e. there is no conversion from float to bool
1192 handle.SetProperty( index, float(0.0) );
1194 application.SendNotification();
1195 application.Render(0);
1196 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1198 // Positive test (sanity check)
1199 bool endValue(false);
1200 handle.SetProperty( index, endValue );
1201 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
1203 application.SendNotification();
1204 application.Render(0);
1205 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
1210 int UtcDaliHandleCustomPropertyInvalidToInt(void)
1212 TestApplication application;
1214 Handle handle = Handle::New();
1217 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1218 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1220 application.SendNotification();
1221 application.Render(0);
1222 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1224 // Negative test i.e. there is no conversion from Vector3 to int
1225 handle.SetProperty( index, Vector3(1,2,3) );
1227 application.SendNotification();
1228 application.Render(0);
1229 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1233 int UtcDaliHandleCustomPropertyInvalidToFloat(void)
1235 TestApplication application;
1237 Handle handle = Handle::New();
1239 float startValue(5.0);
1240 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1241 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1243 application.SendNotification();
1244 application.Render(0);
1245 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1247 // Negative test i.e. there is no conversion from Vector3 to float
1248 handle.SetProperty( index, Vector3(1,2,3) );
1250 application.SendNotification();
1251 application.Render(0);
1252 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1256 int UtcDaliHandleCustomPropertyInvalidToRotation(void)
1258 TestApplication application;
1260 Handle handle = Handle::New();
1262 Quaternion startValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1263 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1264 DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1266 application.SendNotification();
1267 application.Render(0);
1268 DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1270 // Negative test i.e. there is no conversion from float to Quaternion
1271 handle.SetProperty( index, float(7.0) );
1273 application.SendNotification();
1274 application.Render(0);
1275 DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1277 // Positive test (sanity check)
1278 Quaternion endValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1279 handle.SetProperty( index, endValue );
1280 DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == endValue );
1285 int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
1287 TestApplication application;
1289 Handle handle = Handle::New();
1291 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1292 Matrix startValue(rotation);
1293 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1294 DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1296 application.SendNotification();
1297 application.Render(0);
1298 DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1300 // Negative test i.e. there is no conversion from float to Matrix
1301 handle.SetProperty( index, float(7.0) );
1303 application.SendNotification();
1304 application.Render(0);
1305 DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1307 // Positive test (sanity check)
1308 Quaternion endRotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1309 Matrix endValue(endRotation);
1310 handle.SetProperty( index, endValue );
1311 DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == endValue );
1316 int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
1318 TestApplication application;
1320 Handle handle = Handle::New();
1322 Matrix3 startValue(11,12,13,
1326 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1327 DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1329 application.SendNotification();
1330 application.Render(0);
1331 DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1333 // Negative test i.e. there is no conversion from float to Matrix3
1334 handle.SetProperty( index, float(7.0) );
1336 application.SendNotification();
1337 application.Render(0);
1338 DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1340 // Positive test (sanity check)
1341 Matrix3 endValue(31,32,33,
1344 handle.SetProperty( index, endValue );
1345 DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == endValue );
1350 int UtcDaliHandleWeightNew(void)
1352 TestApplication application;
1354 Handle handle = WeightObject::New();
1355 DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
1357 // process the message so scene object is added to update manager
1358 application.SendNotification();
1359 application.Render(0);
1361 // no message to release scene object in this scenario
1366 int UtcDaliHandleWeightNew2(void)
1368 TestApplication application;
1370 // scope for the weight object
1372 Handle handle = WeightObject::New();
1373 DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
1375 // process the message so scene object is added to update manager
1376 application.SendNotification();
1377 application.Render(0);
1379 // handle out of scope so object gets destroyed
1380 // process the message so update manager destroys the scene object
1381 application.SendNotification();
1382 application.Render(0);
1387 int UtcDaliHandleSetTypeInfo(void)
1389 TestApplication application;
1390 TypeRegistry typeRegistry = TypeRegistry::Get();
1392 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
1393 DALI_TEST_CHECK( typeInfo );
1395 Actor actor = Actor::DownCast(typeInfo.CreateInstance());
1396 DALI_TEST_CHECK( actor );
1398 DevelHandle::SetTypeInfo(actor, typeInfo);
1400 TypeInfo newTypeInfo;
1401 bool success = actor.GetTypeInfo( newTypeInfo );
1402 DALI_TEST_CHECK( success );
1404 DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
1405 DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
1410 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
1412 TestApplication application;
1414 tet_infoline( "Create a custom property and set the value ensuring it can be retrieved synchronously" );
1416 Actor actor = Actor::New();
1417 application.GetScene().Add( actor );
1419 tet_infoline( "Create the custom property with an initial value" );
1420 float startValue(1.0f);
1421 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
1422 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), startValue, TEST_LOCATION );
1424 tet_infoline( "Set the value, retrieve it and ensure both the synchronous and the async version work" );
1425 actor.SetProperty( index, 5.0f );
1426 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
1427 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
1429 tet_infoline( "Render and retrieve values again" );
1430 application.SendNotification();
1431 application.Render(0);
1433 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
1434 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 5.0f, TEST_LOCATION );
1439 int UtcDaliHandleCustomPropertyGetType(void)
1441 TestApplication application;
1443 tet_infoline( "Create a custom property and retrieve its type" );
1445 Handle handle = Handle::New();
1446 Property::Index index = handle.RegisterProperty( "testProperty", 1.0f );
1447 DALI_TEST_EQUALS( handle.GetPropertyType( index ), Property::FLOAT, TEST_LOCATION );
1452 int UtcDaliHandleCustomPropertyAccessMode(void)
1454 TestApplication application;
1456 tet_infoline( "Create a custom property and retrieve whether it's animatable etc." );
1458 Handle handle = Handle::New();
1459 Property::Index index = handle.RegisterProperty( "testProperty", 1.0f );
1460 DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), true, TEST_LOCATION );
1461 DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1463 index = handle.RegisterProperty( "testProperty2", 1.0f, Property::READ_ONLY );
1464 DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1465 DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), false, TEST_LOCATION );
1467 index = handle.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1468 DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1469 DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1474 int UtcDaliHandleGetCurrentProperty(void)
1476 TestApplication application;
1478 tet_infoline( "Get a default and non-animatable custom property using the GetCurrentProperty API" );
1480 Actor actor = Actor::New();
1481 application.GetScene().Add( actor );
1482 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
1484 Property::Index index = actor.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1485 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 1.0f, TEST_LOCATION );
1486 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 1.0f, TEST_LOCATION );
1488 actor.SetProperty( index, 2.0f );
1489 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 2.0f, TEST_LOCATION );
1490 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 2.0f, TEST_LOCATION );
1495 int UtcDaliHandleDoesCustomPropertyExistP1(void)
1497 TestApplication application; // Needs type registry
1499 tet_infoline( "Test if a registered custom property exists on object" );
1501 Actor actor = Actor::New();
1502 auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1504 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex ), true, TEST_LOCATION );
1508 int UtcDaliHandleDoesCustomPropertyExistN1(void)
1510 TestApplication application; // Needs type registry
1512 tet_infoline( "Test if a registered custom property does not exist on object" );
1514 Actor actor = Actor::New();
1515 auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1517 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex+1 ), false, TEST_LOCATION );
1521 int UtcDaliHandleDoesCustomPropertyExistN2(void)
1523 TestApplication application; // Needs type registry
1525 tet_infoline( "Test that a default property does not show as a custom property on object" );
1527 Actor actor = Actor::New();
1528 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, Actor::Property::POSITION ), false, TEST_LOCATION );
1532 int UtcDaliHandleDoesCustomPropertyExistN3(void)
1534 TestApplication application; // Needs type registry
1536 tet_infoline( "Test that a child property does not exist on actor after parenting to container" );
1537 TypeRegistry typeRegistry = TypeRegistry::Get();
1539 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1541 const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1542 const char* CHILD_PROPERTY_NAME( "childProperty" );
1544 ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1546 auto container = Test::TestCustomActor::New();
1547 application.GetScene().Add( container );
1548 auto child = Actor::New();
1549 container.Add( child ); // Resolve child properties (if any)
1551 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), false, TEST_LOCATION );
1555 int UtcDaliHandleDoesCustomPropertyExistP2(void)
1557 TestApplication application; // Needs type registry
1559 tet_infoline( "Test that a child property exists after being set" );
1560 TypeRegistry typeRegistry = TypeRegistry::Get();
1562 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1564 const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1565 const char* CHILD_PROPERTY_NAME( "childProperty" );
1567 ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1569 auto container = Test::TestCustomActor::New();
1570 application.GetScene().Add( container );
1571 auto child = Actor::New();
1572 container.Add( child ); // Resolve child properties (if any)
1573 child.SetProperty( CHILD_PROPERTY, 2 );
1575 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1576 DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 2, TEST_LOCATION );
1580 int UtcDaliHandleDoesCustomPropertyExistP3(void)
1582 TestApplication application; // Needs type registry
1584 tet_infoline( "Test that a child property is re-indexed after registration, and that it exists" );
1585 TypeRegistry typeRegistry = TypeRegistry::Get();
1587 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1589 const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1590 const char* CHILD_PROPERTY_NAME( "childProperty" );
1592 ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1594 auto container = Test::TestCustomActor::New();
1595 application.GetScene().Add( container );
1596 auto child = Actor::New();
1597 child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
1598 container.Add( child ); // Resolve child properties (if any)
1600 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1601 DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
1608 struct PropertySetSignalCheck
1610 PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
1611 : mSignalReceived(signalReceived),
1616 void operator()(Handle& handle, Property::Index index, Property::Value value)
1618 mSignalReceived = true;
1624 mSignalReceived = false;
1627 void CheckSignalReceived()
1629 if (!mSignalReceived)
1631 tet_printf("Expected Property Set signal was not received\n");
1632 tet_result(TET_FAIL);
1636 tet_result(TET_PASS);
1640 bool& mSignalReceived; // owned by individual tests
1641 Property::Value& mValue;
1646 int UtcDaliHandlePropertySetSignal01(void)
1648 TestApplication application;
1650 bool signalReceived(false);
1651 Property::Value value;
1652 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1654 tet_infoline( "Test that setting a default property triggers a signal" );
1656 auto actor = Actor::New();
1657 DevelHandle::PropertySetSignal(actor).Connect(&application, propertySetCheck);
1659 actor.SetProperty( Actor::Property::POSITION, Vector3::XAXIS );
1660 propertySetCheck.CheckSignalReceived();
1666 int UtcDaliHandlePropertySetSignal02(void)
1668 TestApplication application;
1670 bool signalReceived(false);
1671 Property::Value value;
1672 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1674 tet_infoline( "Test that setting a custom property triggers a signal" );
1676 auto actor = Actor::New();
1677 DevelHandle::PropertySetSignal(actor).Connect(&application, propertySetCheck);
1679 auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
1680 actor.SetProperty( propertyIndex, 5.0f );
1681 propertySetCheck.CheckSignalReceived();
1682 DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 5.0f ), 0.001f, TEST_LOCATION );
1687 int UtcDaliHandlePropertySetSignal03(void)
1689 TestApplication application;
1690 TypeRegistry typeRegistry = TypeRegistry::Get();
1692 bool signalReceived(false);
1693 Property::Value value;
1694 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1696 tet_infoline( "Test that setting a child property triggers a signal" );
1698 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1700 const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1701 const char* CHILD_PROPERTY_NAME( "childProperty" );
1703 ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1705 auto container = Test::TestCustomActor::New();
1706 application.GetScene().Add( container );
1707 auto child = Actor::New();
1708 child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
1709 DevelHandle::PropertySetSignal(child).Connect(&application, propertySetCheck);
1710 container.Add( child ); // Resolve child properties (if any)
1712 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1713 DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
1715 child.SetProperty( CHILD_PROPERTY, 29 );
1716 propertySetCheck.CheckSignalReceived();
1717 DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 29 ), TEST_LOCATION );
1721 int UtcDaliHandlePropertySetProperties(void)
1723 TestApplication application;
1724 const Vector3 actorSize( 10.0f, 20.0f, 30.0f );
1725 const Vector3 anchorPoint( 1.0f, 0.5f, 0.0f );
1726 const Vector4 color( 0.1f, 0.2, 0.3f, 0.4f );
1728 Handle handle = Actor::New();
1729 DevelHandle::SetProperties(
1733 { Actor::Property::SIZE, actorSize },
1734 { Actor::Property::ANCHOR_POINT, anchorPoint },
1736 { "invalid", Vector2::ZERO } // It should quietly ignore invalid data
1739 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(), actorSize, TEST_LOCATION );
1740 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::ANCHOR_POINT ).Get< Vector3 >(), anchorPoint, TEST_LOCATION );
1741 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::COLOR ).Get< Vector4 >(), color, TEST_LOCATION );
1746 int UtcDaliHandleTemplateNew(void)
1748 TestApplication application;
1749 const Vector3 actorSize( 10.0f, 20.0f, 30.0f );
1750 const Vector3 anchorPoint( 1.0f, 0.5f, 0.0f );
1751 const Vector4 color( 0.1f, 0.2, 0.3f, 0.4f );
1753 Handle handle = DevelHandle::New< Actor >(
1756 { Actor::Property::SIZE, actorSize },
1757 { Actor::Property::ANCHOR_POINT, anchorPoint },
1759 { "invalid", Vector2::ZERO } // It should quietly ignore invalid data
1763 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(), actorSize, TEST_LOCATION );
1764 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::ANCHOR_POINT ).Get< Vector3 >(), anchorPoint, TEST_LOCATION );
1765 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::COLOR ).Get< Vector4 >(), color, TEST_LOCATION );
1770 int UtcDaliHandleGetProperties(void)
1772 TestApplication application;
1774 Handle handle = Actor::New();
1775 DevelHandle::SetProperties(
1779 { Actor::Property::SIZE, Vector3( 400.0f, 200.0f, 100.0f ) },
1780 { Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER },
1781 { Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER },
1782 { Actor::Property::NAME, "Actor" },
1783 { Actor::Property::LEAVE_REQUIRED, true },
1784 { "color", Color::RED },
1789 DevelHandle::GetProperties( handle, map );
1791 // Get all the properties and ensure they match
1793 DALI_TEST_EQUALS( handle.GetPropertyCount(), map.Count(), TEST_LOCATION );
1795 for( auto position = 0u; position < map.Count(); ++position )
1797 auto keyValuePair = map.GetKeyValue( position );
1798 const auto& index = keyValuePair.first.indexKey;
1799 const auto& value = keyValuePair.second;
1800 auto handleValue = handle.GetProperty( index );
1802 switch( value.GetType() )
1804 case Property::NONE: break;
1805 case Property::BOOLEAN: DALI_TEST_EQUALS( value.Get< bool >(), handleValue.Get< bool >(), TEST_LOCATION ); break;
1806 case Property::FLOAT: DALI_TEST_EQUALS( value.Get< float >(), handleValue.Get< float >(), TEST_LOCATION ); break;
1807 case Property::INTEGER: DALI_TEST_EQUALS( value.Get< int >(), handleValue.Get< int >(), TEST_LOCATION ); break;
1808 case Property::VECTOR2: DALI_TEST_EQUALS( value.Get< Vector2 >(), handleValue.Get< Vector2 >(), TEST_LOCATION ); break;
1809 case Property::VECTOR3: DALI_TEST_EQUALS( value.Get< Vector3 >(), handleValue.Get< Vector3 >(), TEST_LOCATION ); break;
1810 case Property::VECTOR4: DALI_TEST_EQUALS( value.Get< Vector4 >(), handleValue.Get< Vector4 >(), TEST_LOCATION ); break;
1811 case Property::MATRIX3: DALI_TEST_EQUALS( value.Get< Matrix3 >(), handleValue.Get< Matrix3 >(), TEST_LOCATION ); break;
1812 case Property::MATRIX: DALI_TEST_EQUALS( value.Get< Matrix >(), handleValue.Get< Matrix >(), TEST_LOCATION ); break;
1813 case Property::RECTANGLE: DALI_TEST_EQUALS( value.Get< Rect< int > >(), handleValue.Get< Rect< int > >(), TEST_LOCATION ); break;
1814 case Property::ROTATION: DALI_TEST_EQUALS( value.Get< Quaternion >(), handleValue.Get< Quaternion >(), TEST_LOCATION ); break;
1815 case Property::STRING: DALI_TEST_EQUALS( value.Get< std::string >(), handleValue.Get< std::string >(), TEST_LOCATION ); break;
1816 case Property::ARRAY: DALI_TEST_EQUALS( value.GetArray()->Count(), handleValue.GetArray()->Count(), TEST_LOCATION ); break;
1817 case Property::MAP: DALI_TEST_EQUALS( value.GetMap()->Count(), handleValue.GetMap()->Count(), TEST_LOCATION ); break;
1818 case Property::EXTENTS: DALI_TEST_EQUALS( value.Get< Extents >(), handleValue.Get< Extents >(), TEST_LOCATION ); break;
1822 // Add a custom property and ensure the count goes up by one.
1823 const auto countBefore = map.Count();
1824 handle.RegisterProperty( "tempProperty", Color::GREEN );
1825 DevelHandle::GetProperties( handle, map );
1826 DALI_TEST_EQUALS( countBefore + 1, map.Count(), TEST_LOCATION );