2 * Copyright (c) 2019 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 UtcDaliHandleSupports(void)
140 tet_infoline("Positive Test Dali::Handle::Supports()");
141 TestApplication application;
143 Actor actor = Actor::New();
144 DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) );
148 int UtcDaliHandleGetPropertyCount(void)
150 tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
151 TestApplication application;
153 Actor actor = Actor::New();
154 int defaultPropertyCount( actor.GetPropertyCount() );
156 // Register a dynamic property
157 actor.RegisterProperty( "testProperty", float(123.0f) );
158 DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() );
162 int UtcDaliHandleGetPropertyName(void)
164 tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
165 TestApplication application;
167 Actor actor = Actor::New();
168 DALI_TEST_CHECK( "parentOrigin" == actor.GetPropertyName( Actor::Property::PARENT_ORIGIN ) );
170 // Register a dynamic property
171 std::string name("thisNameShouldMatch");
172 Property::Index index = actor.RegisterProperty( name, float(123.0f) );
173 DALI_TEST_CHECK( name == actor.GetPropertyName( index ) );
178 int UtcDaliHandleGetPropertyIndex01(void)
180 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
181 TestApplication application;
183 Actor actor = Actor::New();
184 DALI_TEST_CHECK( Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parentOrigin") );
186 // Register a dynamic property
187 std::string name("thisNameShouldMatch");
188 Property::Index index = actor.RegisterProperty( name, float(123.0f) );
189 DALI_TEST_CHECK( index == actor.GetPropertyIndex( name ) );
193 int UtcDaliHandleGetPropertyIndex02(void)
195 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex() int key");
196 TestApplication application;
198 Stage stage = Stage::GetCurrent();
200 Actor actor = Actor::New();
203 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
205 application.SendNotification();
206 application.Render();
208 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
209 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
211 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
212 const float withFlake(99.f);
214 Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
215 Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
216 Property::Index index3 = actor.RegisterProperty( "MyPropertyTwo", Vector3::ONE );
217 Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
218 Property::Index index5 = actor.RegisterProperty( "MyPropertyThree", Vector3::ONE );
220 application.SendNotification();
221 application.Render();
223 // Test that we can get the property index from the integer key
224 Property::Index testIndex1 = DevelHandle::GetPropertyIndex( actor, key1 );
225 Property::Index testIndex2 = DevelHandle::GetPropertyIndex( actor, key2 );
227 DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION );
228 DALI_TEST_EQUALS( index4, testIndex2, TEST_LOCATION );
230 // Test that we keep the same indices on the named properties
231 Property::Index testIndex = actor.GetPropertyIndex("MyPropertyOne");
232 DALI_TEST_EQUALS(testIndex, index1, TEST_LOCATION);
233 testIndex = actor.GetPropertyIndex("MyPropertyTwo");
234 DALI_TEST_EQUALS(testIndex, index3, TEST_LOCATION);
235 testIndex = actor.GetPropertyIndex("MyPropertyThree");
236 DALI_TEST_EQUALS(testIndex, index5, TEST_LOCATION);
237 testIndex = actor.GetPropertyIndex("sideColor");
238 DALI_TEST_EQUALS(testIndex, index2, TEST_LOCATION);
239 testIndex = actor.GetPropertyIndex("iceCream");
240 DALI_TEST_EQUALS(testIndex, index4, TEST_LOCATION);
242 DALI_TEST_EQUALS(defaultPropertyCount+5, actor.GetPropertyCount(), TEST_LOCATION);
246 int UtcDaliHandleGetPropertyIndex03(void)
248 TestApplication application;
250 Actor actor = Actor::New();
252 std::string myName("croydon");
253 Property::Index intKey = CORE_PROPERTY_MAX_INDEX+1;
254 Property::Value value( Color::GREEN );
255 Property::Index myIndex = DevelHandle::RegisterProperty( actor, intKey, myName, value );
257 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, intKey ), TEST_LOCATION );
259 Property::Key key1(myName);
260 Property::Key key2(intKey);
262 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key1 ), TEST_LOCATION );
263 DALI_TEST_EQUALS( myIndex, DevelHandle::GetPropertyIndex( actor, key2 ), TEST_LOCATION );
268 int UtcDaliHandleIsPropertyWritable(void)
270 tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
271 TestApplication application;
273 Actor actor = Actor::New();
275 // Actor properties which are writable:
276 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN ) );
277 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_X ) );
278 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Y ) );
279 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Z ) );
280 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT ) );
281 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_X ) );
282 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Y ) );
283 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Z ) );
284 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE ) );
285 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_WIDTH ) );
286 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_HEIGHT ) );
287 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_DEPTH ) );
288 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION ) );
289 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_X ) );
290 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Y ) );
291 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Z ) );
292 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ORIENTATION ) );
293 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE ) );
294 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_X ) );
295 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Y ) );
296 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Z ) );
297 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::VISIBLE ) );
298 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR ) );
299 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_RED ) );
300 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_GREEN ) );
301 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_BLUE ) );
302 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_ALPHA ) );
303 DALI_TEST_CHECK( true == actor.IsPropertyWritable( DevelActor::Property::OPACITY ) );
305 // World-properties are not writable:
306 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
307 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_ORIENTATION ) );
308 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_SCALE ) );
309 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_COLOR ) );
310 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_X ) );
311 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Y ) );
312 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Z ) );
317 int UtcDaliHandleIsPropertyAnimatable(void)
319 tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
320 TestApplication application;
322 Actor actor = Actor::New();
324 // Actor properties which are animatable:
325 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN ) );
326 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_X ) );
327 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Y ) );
328 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Z ) );
329 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT ) );
330 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_X ) );
331 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Y ) );
332 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Z ) );
333 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE ) );
334 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_WIDTH ) );
335 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_HEIGHT ) );
336 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_DEPTH ) );
337 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION ) );
338 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_X ) );
339 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Y ) );
340 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Z ) );
341 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::ORIENTATION ) );
342 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE ) );
343 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_X ) );
344 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Y ) );
345 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Z ) );
346 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::VISIBLE ) );
347 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR ) );
348 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_RED ) );
349 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_GREEN ) );
350 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_BLUE ) );
351 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_ALPHA ) );
352 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( DevelActor::Property::OPACITY ) );
354 // World-properties can not be animated
355 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION ) );
356 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_ORIENTATION ) );
357 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_SCALE ) );
358 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_COLOR ) );
359 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_X ) );
360 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Y ) );
361 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Z ) );
366 int UtcDaliHandleIsPropertyAConstraintInput(void)
368 TestApplication application;
370 Actor actor = Actor::New();
372 // Actor properties which can be used as a constraint input:
373 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN ) );
374 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_X ) );
375 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Y ) );
376 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Z ) );
377 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT ) );
378 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_X ) );
379 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Y ) );
380 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Z ) );
381 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE ) );
382 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_WIDTH ) );
383 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_HEIGHT ) );
384 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_DEPTH ) );
385 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION ) );
386 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_X ) );
387 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Y ) );
388 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Z ) );
389 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ORIENTATION ) );
390 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE ) );
391 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_X ) );
392 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Y ) );
393 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Z ) );
394 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::VISIBLE ) );
395 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR ) );
396 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_RED ) );
397 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_GREEN ) );
398 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_BLUE ) );
399 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_ALPHA ) );
400 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( DevelActor::Property::OPACITY ) );
401 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION ) );
402 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_ORIENTATION ) );
403 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_SCALE ) );
404 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_COLOR ) );
405 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_X ) );
406 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Y ) );
407 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Z ) );
409 // Actor properties that cannot be used as a constraint input
410 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::NAME ) );
411 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SENSITIVE ) );
412 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::LEAVE_REQUIRED ) );
413 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_ORIENTATION ) );
414 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_SCALE ) );
415 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_MODE ) );
416 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::DRAW_MODE ) );
417 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE_FACTOR ) );
423 int UtcDaliHandleGetPropertyType(void)
425 tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
426 TestApplication application;
428 Actor actor = Actor::New();
429 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::PARENT_ORIGIN ) );
430 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::ANCHOR_POINT ) );
431 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::SIZE ) );
432 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::POSITION ) );
433 DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( Actor::Property::ORIENTATION ) );
434 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::SCALE ) );
435 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( Actor::Property::VISIBLE ) );
436 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( Actor::Property::COLOR ) );
438 // Register some dynamic properties
439 Property::Index boolIndex = actor.RegisterProperty( "boolProperty", bool(true) );
440 Property::Index floatIndex = actor.RegisterProperty( "floatProperty", float(123.0f) );
441 Property::Index intIndex = actor.RegisterProperty( "intProperty", 123 );
442 Property::Index vector2Index = actor.RegisterProperty( "vector2Property", Vector2(1.0f, 2.0f) );
443 Property::Index vector3Index = actor.RegisterProperty( "vector3Property", Vector3(1.0f, 2.0f, 3.0f) );
444 Property::Index vector4Index = actor.RegisterProperty( "vector4Property", Vector4(1.0f, 2.0f, 3.0f, 4.0f) );
445 Property::Index rotationIndex = actor.RegisterProperty( "rotationProperty", AngleAxis(Degree(180.0f), Vector3::YAXIS) );
447 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( boolIndex ) );
448 DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( floatIndex ) );
449 DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( intIndex ) );
450 DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( vector2Index ) );
451 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) );
452 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) );
453 DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) );
455 // Non animatable properties
456 Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("yes"), Property::READ_WRITE);
457 Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE);
458 Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
459 Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
460 Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE);
461 Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE);
462 Property::Index nonAnimIntegerIndex = actor.RegisterProperty( "int", 0, Property::READ_WRITE);
464 DALI_TEST_CHECK( nonAnimStringIndex != Property::INVALID_INDEX );
465 DALI_TEST_CHECK( nonAnimV2Index != Property::INVALID_INDEX );
466 DALI_TEST_CHECK( nonAnimV3Index != Property::INVALID_INDEX );
467 DALI_TEST_CHECK( nonAnimV4Index != Property::INVALID_INDEX );
468 DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX );
469 DALI_TEST_CHECK( nonAnimFloatIndex != Property::INVALID_INDEX );
470 DALI_TEST_CHECK( nonAnimIntegerIndex != Property::INVALID_INDEX );
472 DALI_TEST_CHECK( Property::STRING == actor.GetPropertyType( nonAnimStringIndex ) );
473 DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( nonAnimV2Index ) );
474 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( nonAnimV3Index ) );
475 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( nonAnimV4Index ) );
476 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( nonAnimBooleanIndex ) );
477 DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( nonAnimFloatIndex ) );
478 DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( nonAnimIntegerIndex ) );
480 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) );
481 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) );
482 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV3Index ) );
483 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) );
484 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) );
485 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) );
486 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimIntegerIndex ) );
488 DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
489 DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get<Vector2>(), TEST_LOCATION );
490 DALI_TEST_EQUALS( Vector3(1.f, 2.f, 3.f) , actor.GetProperty( nonAnimV3Index ).Get<Vector3>(), TEST_LOCATION );
491 DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get<Vector4>(), TEST_LOCATION );
492 DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get<bool>(), TEST_LOCATION );
493 DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get<float>(), TEST_LOCATION );
494 DALI_TEST_EQUALS( 0, actor.GetProperty( nonAnimIntegerIndex ).Get<int>(), TEST_LOCATION );
499 int UtcDaliHandleNonAnimatableProperties(void)
501 tet_infoline("Test Non Animatable Properties");
502 TestApplication application;
504 Actor actor = Actor::New();
506 Property::Index nonAnimStringIndex = actor.RegisterProperty( "manFromDelmonte", std::string("no"), Property::READ_WRITE);
508 //// modify writable?
509 actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
511 DALI_TEST_CHECK( "yes" == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
513 //// cannot modify read only?
514 Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY);
516 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
517 DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
519 actor.SetProperty( readonly, Property::Value(1.f) );
520 // trying to set a read-only property is a no-op
522 DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
524 /// animatable can be set
525 Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE);
527 DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
528 DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
530 actor.SetProperty( write_anim, Property::Value(1.f) );
532 //// animate a non animatable property throws
533 float durationSeconds(2.0f);
534 Animation animation = Animation::New(durationSeconds);
535 bool relativeValue(true);
538 animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
540 catch ( Dali::DaliException& e )
542 DALI_TEST_ASSERT( e, "Property type is not animatable", TEST_LOCATION );
545 DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
550 int UtcDaliHandleNonAnimtableCompositeProperties(void)
552 tet_infoline("Test Non Animatable Composite Properties");
553 TestApplication application;
555 Actor actor = Actor::New();
557 Property::Value value(Property::ARRAY);
558 Property::Array* array = value.GetArray();
559 DALI_TEST_CHECK( array );
561 array->PushBack( Property::Value( 0.1f ) );
562 array->PushBack( "a string" );
563 array->PushBack( Property::Value( Vector3(1,2,3) ) );
565 DALI_TEST_EQUALS( 3u, array->Count(), TEST_LOCATION );
567 Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE );
569 Property::Value out = actor.GetProperty( propertyIndex );
570 Property::Array* outArray = out.GetArray();
571 DALI_TEST_CHECK( outArray != NULL );
573 DALI_TEST_CHECK( Property::FLOAT == outArray->GetElementAt(0).GetType());
574 DALI_TEST_CHECK( Property::STRING == outArray->GetElementAt(1).GetType());
575 DALI_TEST_CHECK( Property::VECTOR3 == outArray->GetElementAt(2).GetType());
577 DALI_TEST_EQUALS( 0.1f, outArray->GetElementAt(0).Get<float>(), TEST_LOCATION);
578 DALI_TEST_EQUALS( "a string", outArray->GetElementAt(1).Get<std::string>(), TEST_LOCATION);
579 DALI_TEST_EQUALS( Vector3(1,2,3), outArray->GetElementAt(2).Get<Vector3>(), TEST_LOCATION);
581 // composite types not animatable
582 bool exception = false;
585 actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE);
587 catch (Dali::DaliException& e)
590 DALI_TEST_PRINT_ASSERT( e );
593 DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
596 Property::Value mapOfMaps(Property::MAP);
597 Property::Map* map = mapOfMaps.GetMap();
599 map->Insert( "key", Property::Value(Property::MAP) );
600 map->Insert( "2key", "a string" );
602 DALI_TEST_EQUALS( "a string", (*map)["2key"].Get<std::string>(), TEST_LOCATION);
604 Property::Map* innerMap = map->Find("key")->GetMap();
605 innerMap->Insert( "subkey", 5.f );
607 DALI_TEST_CHECK( NULL != map->Find("key")->GetMap()->Find("subkey") );
608 DALI_TEST_EQUALS( 5.f, map->Find("key")->GetMap()->Find("subkey")->Get<float>(), TEST_LOCATION);
612 int UtcDaliHandleSetProperty01(void)
614 tet_infoline("Positive Test Dali::Handle::SetProperty()");
615 TestApplication application;
617 Actor actor = Actor::New();
618 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
620 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
621 // flush the queue and render once
622 application.SendNotification();
623 application.Render();
624 DALI_TEST_CHECK( ParentOrigin::CENTER == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
628 int UtcDaliHandleSetProperty02(void)
630 tet_infoline("Positive Test Dali::Handle::SetProperty()");
631 TestApplication application;
633 Actor actor = Actor::New();
635 DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
637 // World position is not writable so this is a no-op and should not crash
638 actor.SetProperty( Actor::Property::WORLD_POSITION, Vector3(1,2,3) );
643 int UtcDaliHandleRegisterProperty01(void)
645 tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
646 TestApplication application;
648 Stage stage = Stage::GetCurrent();
650 Actor actor = Actor::New();
653 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
655 application.SendNotification();
656 application.Render();
658 Property::Index index1 = actor.RegisterProperty( "MyProperty", Vector3::ONE );
660 application.SendNotification();
661 application.Render();
663 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION );
664 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
666 // No new property should be registered when we call the below function
667 Property::Index index2 = actor.RegisterProperty( "MyProperty", Vector3::ZAXIS );
669 application.SendNotification();
670 application.Render();
673 DALI_TEST_EQUALS( index1, index2, TEST_LOCATION ); // We should have the same index as per the first registration
674 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION ); // Property count should be the same
675 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index2 ), Vector3::ZAXIS, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
680 int UtcDaliHandleRegisterProperty02(void)
682 tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key");
683 TestApplication application;
685 Stage stage = Stage::GetCurrent();
687 Actor actor = Actor::New();
690 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
692 application.SendNotification();
693 application.Render();
695 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
696 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
698 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
699 const float withFlake(99.f);
701 Property::Index index1 = actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
702 Property::Index index2 = DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
703 Property::Index index3 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
705 application.SendNotification();
706 application.Render();
708 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION );
709 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( index1 ), Vector3::ONE, TEST_LOCATION );
710 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), testColor, TEST_LOCATION );
711 DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), withFlake, TEST_LOCATION );
713 // No new property should be registered when we call the below functions
714 Property::Index testIndex2 = actor.RegisterProperty( "iceCream", 2200.f );
715 Property::Index testIndex1 = actor.RegisterProperty( "sideColor", Color::BLACK );
716 application.SendNotification();
717 application.Render();
719 DALI_TEST_EQUALS( index2, testIndex1, TEST_LOCATION ); // We should have the same index as per the first registration
720 DALI_TEST_EQUALS( index3, testIndex2, TEST_LOCATION ); // We should have the same index as per the first registration
721 DALI_TEST_EQUALS( actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION ); // Property count should be the same
722 DALI_TEST_EQUALS( actor.GetProperty< Vector4 >( index2 ), Color::BLACK, TEST_LOCATION ); // Value should be what we sent on second RegisterProperty call
723 DALI_TEST_EQUALS( actor.GetProperty< float >( index3 ), 2200.f, TEST_LOCATION );
730 int UtcDaliHandleGetProperty(void)
732 tet_infoline("Positive Test Dali::Handle::GetProperty()");
733 TestApplication application;
735 Actor actor = Actor::New();
737 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
738 DALI_TEST_CHECK( AnchorPoint::CENTER == actor.GetProperty( Actor::Property::ANCHOR_POINT ).Get<Vector3>() );
739 DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::Property::SIZE ).Get<Vector3>() );
740 DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::Property::POSITION ).Get<Vector3>() );
741 DALI_TEST_CHECK( Vector3::ONE == actor.GetProperty( Actor::Property::SCALE ).Get<Vector3>() );
742 DALI_TEST_CHECK( true == actor.GetProperty( Actor::Property::VISIBLE ).Get<bool>() );
743 DALI_TEST_CHECK( Color::WHITE == actor.GetProperty( Actor::Property::COLOR ).Get<Vector4>() );
747 int UtcDaliHandleDownCast(void)
749 TestApplication application;
750 tet_infoline("Testing Dali::Handle::DownCast()");
752 Actor actor = Actor::New();
754 BaseHandle baseHandle = actor;
756 Handle handle = Handle::DownCast(baseHandle);
758 DALI_TEST_CHECK( handle );
760 baseHandle = BaseHandle();
762 handle = Handle::DownCast(baseHandle);
764 DALI_TEST_CHECK( !handle );
769 int UtcDaliHandleDownCastNegative(void)
771 TestApplication application;
773 // BaseObject is NOT an Object, so this DownCast should fail
774 BaseHandle handle( new BaseObjectType );
775 Handle customHandle1 = Handle::DownCast( handle );
776 DALI_TEST_CHECK( ! customHandle1 );
778 // A DownCast on an empty handle will also fail
780 Handle customHandle2 = Handle::DownCast( empty );
781 DALI_TEST_CHECK( ! customHandle2 );
785 int UtcDaliHandleGetPropertyIndices(void)
787 TestApplication application;
788 Property::IndexContainer indices;
791 Actor actor = Actor::New();
792 actor.GetPropertyIndices( indices );
793 int numDefaultProperties = indices.Size();
794 DALI_TEST_CHECK( numDefaultProperties > 0 );
795 DALI_TEST_EQUALS( numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION );
797 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
798 const float withFlake(99.f);
800 Property::Index key1 = CORE_PROPERTY_MAX_INDEX+1;
801 Property::Index key2 = CORE_PROPERTY_MAX_INDEX+2;
803 actor.RegisterProperty( "MyPropertyOne", Vector3::ONE );
804 DevelHandle::RegisterProperty( actor, key1, "sideColor", testColor);
805 actor.RegisterProperty( "MyPropertyTwo", 1234 );
806 Property::Index index4 = DevelHandle::RegisterProperty( actor, key2, "iceCream", withFlake );
807 actor.RegisterProperty( "MyPropertyThree", Vector2(.2f,.7f) );
809 actor.GetPropertyIndices( indices );
811 DALI_TEST_EQUALS( indices.Size(), numDefaultProperties + 5, TEST_LOCATION );
812 DALI_TEST_EQUALS( indices[indices.Size()-2], index4, TEST_LOCATION );
817 int UtcDaliHandleRegisterPropertyTypes(void)
819 TestApplication application;
821 struct PropertyTypeAnimatable
824 Property::Value value;
828 Property::Array array;
831 PropertyTypeAnimatable properties[] =
833 { "Property::BOOLEAN", true, true },
834 { "Property::FLOAT", 1.0f, true },
835 { "Property::INTEGER", 1, true },
836 { "Property::VECTOR2", Vector2::ONE, true },
837 { "Property::VECTOR3", Vector3::ONE, true },
838 { "Property::VECTOR4", Vector4::ONE, true },
839 { "Property::MATRIX3", Matrix3::IDENTITY, true },
840 { "Property::MATRIX", Matrix::IDENTITY, true },
841 { "Property::RECTANGLE", Rect<int>(), false },
842 { "Property::ROTATION", AngleAxis(), true },
843 { "Property::STRING", std::string("Me"), false },
844 { "Property::ARRAY", array, false },
845 { "Property::MAP", map, false },
848 unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
850 for ( unsigned int i = 0; i < numOfProperties; ++i )
852 tet_printf( "Testing: %s\n", properties[i].name );
854 bool exception = false;
857 Actor actor = Actor::New();
858 actor.RegisterProperty( "manFromDelmonte", properties[i].value );
860 catch (Dali::DaliException& e)
865 DALI_TEST_CHECK( properties[i].animatable != exception );
870 int UtcDaliHandleCustomProperty(void)
872 TestApplication application;
874 Handle handle = Handle::New();
876 float startValue(1.0f);
877 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
878 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
880 application.SendNotification();
881 application.Render(0);
882 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
883 application.Render(0);
884 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
886 handle.SetProperty( index, 5.0f );
888 application.SendNotification();
889 application.Render(0);
890 DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
891 application.Render(0);
892 DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
896 int UtcDaliHandleCustomPropertyNone(void)
898 TestApplication application;
900 Handle handle = Handle::New();
902 Property::Value value( Property::NONE );
903 Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
905 // Negative test i.e. setting a property of type NONE is meaningless
906 handle.SetProperty( index, 5.0f );
908 DALI_TEST_CHECK( true ); // got here without crashing
913 int UtcDaliHandleCustomPropertyIntToFloat(void)
915 TestApplication application;
917 Handle handle = Handle::New();
919 float startValue(5.0f);
920 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
921 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
923 application.SendNotification();
924 application.Render(0);
925 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
927 handle.SetProperty( index, int(1) );
929 application.SendNotification();
930 application.Render(0);
931 DALI_TEST_CHECK( handle.GetProperty<float>(index) == 1.0f );
935 int UtcDaliHandleCustomPropertyFloatToInt(void)
937 TestApplication application;
939 Handle handle = Handle::New();
942 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
943 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
945 application.SendNotification();
946 application.Render(0);
947 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
949 handle.SetProperty( index, float(1.5) );
951 application.SendNotification();
952 application.Render(0);
953 DALI_TEST_CHECK( handle.GetProperty<int>(index) == 1 );
957 int UtcDaliHandleCustomPropertyInvalidToRect(void)
959 TestApplication application;
961 Handle handle = Handle::New();
963 Rect<int> startValue(1,2,3,4);
964 Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
965 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
967 application.SendNotification();
968 application.Render(0);
969 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
971 // Negative test i.e. there is no conversion from float to Rect
972 handle.SetProperty( index, float(1.5) );
974 application.SendNotification();
975 application.Render(0);
976 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), startValue, TEST_LOCATION );
978 // Positive test (sanity check)
979 Rect<int> endValue(5,6,7,8);
980 handle.SetProperty( index, endValue );
981 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
983 application.SendNotification();
984 application.Render(0);
985 DALI_TEST_EQUALS( handle.GetProperty< Rect<int> >( index ), endValue, TEST_LOCATION );
990 int UtcDaliHandleCustomPropertyInvalidToString(void)
992 TestApplication application;
994 Handle handle = Handle::New();
996 std::string startValue( "Libraries gave us power" );
997 Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
998 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1000 application.SendNotification();
1001 application.Render(0);
1002 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1004 // No conversion from Vector3 to std::string, therefore this should be a NOOP
1005 handle.SetProperty( index, Vector3(1,2,3) );
1007 application.SendNotification();
1008 application.Render(0);
1009 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), startValue, TEST_LOCATION );
1011 // Positive test (sanity check)
1012 std::string endValue( "Then work came and made us free" );
1013 handle.SetProperty( index, endValue );
1014 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
1016 application.SendNotification();
1017 application.Render(0);
1018 DALI_TEST_EQUALS( handle.GetProperty< std::string >( index ), endValue, TEST_LOCATION );
1023 int UtcDaliHandleCustomPropertyInvalidToArray(void)
1025 TestApplication application;
1027 Handle handle = Handle::New();
1029 Property::Value value( Property::ARRAY );
1030 std::string startValue( "The future teaches you to be alone" );
1031 value.GetArray()->PushBack( startValue );
1033 Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE);
1034 Property::Array check1 = handle.GetProperty< Property::Array >( index );
1035 DALI_TEST_EQUALS( check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1037 application.SendNotification();
1038 application.Render(0);
1039 Property::Array check2 = handle.GetProperty< Property::Array >( index );
1040 DALI_TEST_EQUALS( check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1042 // No conversion from int to ARRAY, therefore this should be a NOOP
1043 handle.SetProperty( index, int(2) );
1045 application.SendNotification();
1046 application.Render(0);
1047 Property::Array check3 = handle.GetProperty< Property::Array >( index );
1048 DALI_TEST_EQUALS( check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION );
1050 // Positive test (sanity check)
1051 Property::Value value2(Property::ARRAY);
1052 std::string endValue( "The present to be afraid and cold" );
1053 value2.GetArray()->PushBack( endValue );
1054 handle.SetProperty( index, value2 );
1056 Property::Array check4 = handle.GetProperty< Property::Array >( index );
1057 DALI_TEST_EQUALS( check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
1059 application.SendNotification();
1060 application.Render(0);
1061 Property::Array check5 = handle.GetProperty< Property::Array >( index );
1062 DALI_TEST_EQUALS( check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION );
1067 int UtcDaliHandleCustomPropertyInvalidToMap(void)
1069 TestApplication application;
1071 Handle handle = Handle::New();
1073 Property::Value value( Property::MAP );
1074 std::string startValue( "Culture sucks down words" );
1075 value.GetMap()->Insert( "1", startValue );
1077 Property::Index index = handle.RegisterProperty( "testProperty", value, Property::READ_WRITE );
1078 Property::Value* check1 = handle.GetProperty< Property::Map >( index ).Find("1");
1079 DALI_TEST_CHECK( NULL != check1 );
1081 // No conversion from float to MAP, therefore this should be a NOOP
1082 handle.SetProperty( index, float(3.0) );
1084 // Positive test (sanity check)
1085 Property::Value value2( Property::MAP );
1086 std::string endValue( "Itemise loathing and feed yourself smiles" );
1087 value.GetMap()->Insert( "1", endValue );
1088 handle.SetProperty( index, value2 );
1093 int UtcDaliHandleCustomPropertyInvalidToExtents(void)
1095 TestApplication application;
1097 Handle handle = Handle::New();
1099 Extents startValue(1,2,3,4);
1100 Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1101 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1103 application.SendNotification();
1104 application.Render(0);
1105 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1107 // Negative test i.e. there is no conversion from float to Extents
1108 handle.SetProperty( index, float(1.5) );
1110 application.SendNotification();
1111 application.Render(0);
1112 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), startValue, TEST_LOCATION );
1114 // Positive test (sanity check)
1115 Extents endValue(5,6,7,8);
1116 handle.SetProperty( index, endValue );
1117 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
1119 application.SendNotification();
1120 application.Render(0);
1121 DALI_TEST_EQUALS( handle.GetProperty< Extents >( index ), endValue, TEST_LOCATION );
1126 int UtcDaliHandleCustomPropertyInvalidToBool(void)
1128 TestApplication application;
1130 Handle handle = Handle::New();
1132 bool startValue(true);
1133 Property::Index index = handle.RegisterProperty( "testProperty", startValue, Property::READ_WRITE);
1134 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1136 application.SendNotification();
1137 application.Render(0);
1138 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1140 // Negative test i.e. there is no conversion from float to bool
1141 handle.SetProperty( index, float(0.0) );
1143 application.SendNotification();
1144 application.Render(0);
1145 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), startValue, TEST_LOCATION );
1147 // Positive test (sanity check)
1148 bool endValue(false);
1149 handle.SetProperty( index, endValue );
1150 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
1152 application.SendNotification();
1153 application.Render(0);
1154 DALI_TEST_EQUALS( handle.GetProperty< bool >( index ), endValue, TEST_LOCATION );
1159 int UtcDaliHandleCustomPropertyInvalidToInt(void)
1161 TestApplication application;
1163 Handle handle = Handle::New();
1166 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1167 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1169 application.SendNotification();
1170 application.Render(0);
1171 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1173 // Negative test i.e. there is no conversion from Vector3 to int
1174 handle.SetProperty( index, Vector3(1,2,3) );
1176 application.SendNotification();
1177 application.Render(0);
1178 DALI_TEST_CHECK( handle.GetProperty<int>(index) == startValue );
1182 int UtcDaliHandleCustomPropertyInvalidToFloat(void)
1184 TestApplication application;
1186 Handle handle = Handle::New();
1188 float startValue(5.0);
1189 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1190 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1192 application.SendNotification();
1193 application.Render(0);
1194 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1196 // Negative test i.e. there is no conversion from Vector3 to float
1197 handle.SetProperty( index, Vector3(1,2,3) );
1199 application.SendNotification();
1200 application.Render(0);
1201 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
1205 int UtcDaliHandleCustomPropertyInvalidToRotation(void)
1207 TestApplication application;
1209 Handle handle = Handle::New();
1211 Quaternion startValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1212 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1213 DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1215 application.SendNotification();
1216 application.Render(0);
1217 DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1219 // Negative test i.e. there is no conversion from float to Quaternion
1220 handle.SetProperty( index, float(7.0) );
1222 application.SendNotification();
1223 application.Render(0);
1224 DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == startValue );
1226 // Positive test (sanity check)
1227 Quaternion endValue( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1228 handle.SetProperty( index, endValue );
1229 DALI_TEST_CHECK( handle.GetProperty<Quaternion>(index) == endValue );
1234 int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
1236 TestApplication application;
1238 Handle handle = Handle::New();
1240 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1241 Matrix startValue(rotation);
1242 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1243 DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1245 application.SendNotification();
1246 application.Render(0);
1247 DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1249 // Negative test i.e. there is no conversion from float to Matrix
1250 handle.SetProperty( index, float(7.0) );
1252 application.SendNotification();
1253 application.Render(0);
1254 DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == startValue );
1256 // Positive test (sanity check)
1257 Quaternion endRotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1258 Matrix endValue(endRotation);
1259 handle.SetProperty( index, endValue );
1260 DALI_TEST_CHECK( handle.GetProperty<Matrix>(index) == endValue );
1265 int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
1267 TestApplication application;
1269 Handle handle = Handle::New();
1271 Matrix3 startValue(11,12,13,
1275 Property::Index index = handle.RegisterProperty( "testProperty", startValue );
1276 DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1278 application.SendNotification();
1279 application.Render(0);
1280 DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1282 // Negative test i.e. there is no conversion from float to Matrix3
1283 handle.SetProperty( index, float(7.0) );
1285 application.SendNotification();
1286 application.Render(0);
1287 DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == startValue );
1289 // Positive test (sanity check)
1290 Matrix3 endValue(31,32,33,
1293 handle.SetProperty( index, endValue );
1294 DALI_TEST_CHECK( handle.GetProperty<Matrix3>(index) == endValue );
1299 int UtcDaliHandleWeightNew(void)
1301 TestApplication application;
1303 Handle handle = WeightObject::New();
1304 DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
1306 // process the message so scene object is added to update manager
1307 application.SendNotification();
1308 application.Render(0);
1310 // no message to release scene object in this scenario
1315 int UtcDaliHandleWeightNew2(void)
1317 TestApplication application;
1319 // scope for the weight object
1321 Handle handle = WeightObject::New();
1322 DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
1324 // process the message so scene object is added to update manager
1325 application.SendNotification();
1326 application.Render(0);
1328 // handle out of scope so object gets destroyed
1329 // process the message so update manager destroys the scene object
1330 application.SendNotification();
1331 application.Render(0);
1336 int UtcDaliHandleSetTypeInfo(void)
1338 TestApplication application;
1339 TypeRegistry typeRegistry = TypeRegistry::Get();
1341 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
1342 DALI_TEST_CHECK( typeInfo );
1344 Actor actor = Actor::DownCast(typeInfo.CreateInstance());
1345 DALI_TEST_CHECK( actor );
1347 DevelHandle::SetTypeInfo(actor, typeInfo);
1349 TypeInfo newTypeInfo;
1350 bool success = actor.GetTypeInfo( newTypeInfo );
1351 DALI_TEST_CHECK( success );
1353 DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
1354 DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
1359 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
1361 TestApplication application;
1363 tet_infoline( "Create a custom property and set the value ensuring it can be retrieved synchronously" );
1365 Actor actor = Actor::New();
1366 Stage::GetCurrent().Add( actor );
1368 tet_infoline( "Create the custom property with an initial value" );
1369 float startValue(1.0f);
1370 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
1371 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), startValue, TEST_LOCATION );
1373 tet_infoline( "Set the value, retrieve it and ensure both the synchronous and the async version work" );
1374 actor.SetProperty( index, 5.0f );
1375 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
1376 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), startValue, TEST_LOCATION );
1378 tet_infoline( "Render and retrieve values again" );
1379 application.SendNotification();
1380 application.Render(0);
1382 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 5.0f, TEST_LOCATION );
1383 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 5.0f, TEST_LOCATION );
1388 int UtcDaliHandleCustomPropertyGetType(void)
1390 TestApplication application;
1392 tet_infoline( "Create a custom property and retrieve its type" );
1394 Handle handle = Handle::New();
1395 Property::Index index = handle.RegisterProperty( "testProperty", 1.0f );
1396 DALI_TEST_EQUALS( handle.GetPropertyType( index ), Property::FLOAT, TEST_LOCATION );
1401 int UtcDaliHandleCustomPropertyAccessMode(void)
1403 TestApplication application;
1405 tet_infoline( "Create a custom property and retrieve whether it's animatable etc." );
1407 Handle handle = Handle::New();
1408 Property::Index index = handle.RegisterProperty( "testProperty", 1.0f );
1409 DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), true, TEST_LOCATION );
1410 DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1412 index = handle.RegisterProperty( "testProperty2", 1.0f, Property::READ_ONLY );
1413 DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1414 DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), false, TEST_LOCATION );
1416 index = handle.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1417 DALI_TEST_EQUALS( handle.IsPropertyAnimatable( index ), false, TEST_LOCATION );
1418 DALI_TEST_EQUALS( handle.IsPropertyWritable( index ), true, TEST_LOCATION );
1423 int UtcDaliHandleGetCurrentProperty(void)
1425 TestApplication application;
1427 tet_infoline( "Get a default and non-animatable custom property using the GetCurrentProperty API" );
1429 Actor actor = Actor::New();
1430 Stage::GetCurrent().Add( actor );
1431 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
1433 Property::Index index = actor.RegisterProperty( "testProperty3", 1.0f, Property::READ_WRITE );
1434 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 1.0f, TEST_LOCATION );
1435 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 1.0f, TEST_LOCATION );
1437 actor.SetProperty( index, 2.0f );
1438 DALI_TEST_EQUALS( actor.GetProperty< float >( index ), 2.0f, TEST_LOCATION );
1439 DALI_TEST_EQUALS( actor.GetCurrentProperty< float >( index ), 2.0f, TEST_LOCATION );
1444 int UtcDaliHandleDoesCustomPropertyExistP1(void)
1446 TestApplication application; // Needs type registry
1448 tet_infoline( "Test if a registered custom property exists on object" );
1450 Actor actor = Actor::New();
1451 auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1453 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex ), true, TEST_LOCATION );
1457 int UtcDaliHandleDoesCustomPropertyExistN1(void)
1459 TestApplication application; // Needs type registry
1461 tet_infoline( "Test if a registered custom property does not exist on object" );
1463 Actor actor = Actor::New();
1464 auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1466 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, propertyIndex+1 ), false, TEST_LOCATION );
1470 int UtcDaliHandleDoesCustomPropertyExistN2(void)
1472 TestApplication application; // Needs type registry
1474 tet_infoline( "Test that a default property does not show as a custom property on object" );
1476 Actor actor = Actor::New();
1477 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( actor, Actor::Property::POSITION ), false, TEST_LOCATION );
1481 int UtcDaliHandleDoesCustomPropertyExistN3(void)
1483 TestApplication application; // Needs type registry
1485 tet_infoline( "Test that a child property does not exist on actor after parenting to container" );
1486 TypeRegistry typeRegistry = TypeRegistry::Get();
1488 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1490 const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1491 const char* CHILD_PROPERTY_NAME( "childProperty" );
1493 ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1495 auto container = Test::TestCustomActor::New();
1496 Stage::GetCurrent().Add( container );
1497 auto child = Actor::New();
1498 container.Add( child ); // Resolve child properties (if any)
1500 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), false, TEST_LOCATION );
1504 int UtcDaliHandleDoesCustomPropertyExistP2(void)
1506 TestApplication application; // Needs type registry
1508 tet_infoline( "Test that a child property exists after being set" );
1509 TypeRegistry typeRegistry = TypeRegistry::Get();
1511 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1513 const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1514 const char* CHILD_PROPERTY_NAME( "childProperty" );
1516 ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1518 auto container = Test::TestCustomActor::New();
1519 Stage::GetCurrent().Add( container );
1520 auto child = Actor::New();
1521 container.Add( child ); // Resolve child properties (if any)
1522 child.SetProperty( CHILD_PROPERTY, 2 );
1524 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1525 DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 2, TEST_LOCATION );
1529 int UtcDaliHandleDoesCustomPropertyExistP3(void)
1531 TestApplication application; // Needs type registry
1533 tet_infoline( "Test that a child property is re-indexed after registration, and that it exists" );
1534 TypeRegistry typeRegistry = TypeRegistry::Get();
1536 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1538 const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1539 const char* CHILD_PROPERTY_NAME( "childProperty" );
1541 ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1543 auto container = Test::TestCustomActor::New();
1544 Stage::GetCurrent().Add( container );
1545 auto child = Actor::New();
1546 child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
1547 container.Add( child ); // Resolve child properties (if any)
1549 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1550 DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
1557 struct PropertySetSignalCheck
1559 PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
1560 : mSignalReceived(signalReceived),
1565 void operator()(Handle& handle, Property::Index index, Property::Value value)
1567 mSignalReceived = true;
1573 mSignalReceived = false;
1576 void CheckSignalReceived()
1578 if (!mSignalReceived)
1580 tet_printf("Expected Property Set signal was not received\n");
1581 tet_result(TET_FAIL);
1585 tet_result(TET_PASS);
1589 bool& mSignalReceived; // owned by individual tests
1590 Property::Value& mValue;
1595 int UtcDaliHandlePropertySetSignal01(void)
1597 TestApplication app;
1599 bool signalReceived(false);
1600 Property::Value value;
1601 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1603 tet_infoline( "Test that setting a default property triggers a signal" );
1605 auto actor = Actor::New();
1606 DevelHandle::PropertySetSignal(actor).Connect(&app, propertySetCheck);
1608 actor.SetProperty( Actor::Property::POSITION, Vector3::XAXIS );
1609 propertySetCheck.CheckSignalReceived();
1615 int UtcDaliHandlePropertySetSignal02(void)
1617 TestApplication app;
1619 bool signalReceived(false);
1620 Property::Value value;
1621 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1623 tet_infoline( "Test that setting a custom property triggers a signal" );
1625 auto actor = Actor::New();
1626 DevelHandle::PropertySetSignal(actor).Connect(&app, propertySetCheck);
1628 auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
1629 actor.SetProperty( propertyIndex, 5.0f );
1630 propertySetCheck.CheckSignalReceived();
1631 DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 5.0f ), 0.001f, TEST_LOCATION );
1636 int UtcDaliHandlePropertySetSignal03(void)
1638 TestApplication app;
1639 TypeRegistry typeRegistry = TypeRegistry::Get();
1641 bool signalReceived(false);
1642 Property::Value value;
1643 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1645 tet_infoline( "Test that setting a child property triggers a signal" );
1647 auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(Test::TestCustomActor) );
1649 const Property::Index CHILD_PROPERTY( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1650 const char* CHILD_PROPERTY_NAME( "childProperty" );
1652 ChildPropertyRegistration( customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER );
1654 auto container = Test::TestCustomActor::New();
1655 Stage::GetCurrent().Add( container );
1656 auto child = Actor::New();
1657 child.RegisterProperty( CHILD_PROPERTY_NAME, Property::Value(3) );
1658 DevelHandle::PropertySetSignal(child).Connect(&app, propertySetCheck);
1659 container.Add( child ); // Resolve child properties (if any)
1661 DALI_TEST_EQUALS( DevelHandle::DoesCustomPropertyExist( child, CHILD_PROPERTY ), true, TEST_LOCATION );
1662 DALI_TEST_EQUALS( child.GetProperty<int>( CHILD_PROPERTY ), 3, TEST_LOCATION );
1664 child.SetProperty( CHILD_PROPERTY, 29 );
1665 propertySetCheck.CheckSignalReceived();
1666 DALI_TEST_EQUALS( propertySetCheck.mValue, Property::Value( 29 ), TEST_LOCATION );
1670 int UtcDaliHandlePropertySetProperties(void)
1672 TestApplication application;
1673 const Vector3 actorSize( 10.0f, 20.0f, 30.0f );
1674 const Vector3 anchorPoint( 1.0f, 0.5f, 0.0f );
1675 const Vector4 color( 0.1f, 0.2, 0.3f, 0.4f );
1677 Handle handle = Actor::New();
1678 DevelHandle::SetProperties(
1682 { Actor::Property::SIZE, actorSize },
1683 { Actor::Property::ANCHOR_POINT, anchorPoint },
1685 { "invalid", Vector2::ZERO } // It should quietly ignore invalid data
1688 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(), actorSize, TEST_LOCATION );
1689 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::ANCHOR_POINT ).Get< Vector3 >(), anchorPoint, TEST_LOCATION );
1690 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::COLOR ).Get< Vector4 >(), color, TEST_LOCATION );
1695 int UtcDaliHandleTemplateNew(void)
1697 TestApplication application;
1698 const Vector3 actorSize( 10.0f, 20.0f, 30.0f );
1699 const Vector3 anchorPoint( 1.0f, 0.5f, 0.0f );
1700 const Vector4 color( 0.1f, 0.2, 0.3f, 0.4f );
1702 Handle handle = DevelHandle::New< Actor >(
1705 { Actor::Property::SIZE, actorSize },
1706 { Actor::Property::ANCHOR_POINT, anchorPoint },
1708 { "invalid", Vector2::ZERO } // It should quietly ignore invalid data
1712 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(), actorSize, TEST_LOCATION );
1713 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::ANCHOR_POINT ).Get< Vector3 >(), anchorPoint, TEST_LOCATION );
1714 DALI_TEST_EQUALS( handle.GetProperty( Actor::Property::COLOR ).Get< Vector4 >(), color, TEST_LOCATION );
1719 int UtcDaliHandleGetProperties(void)
1721 TestApplication application;
1723 Handle handle = Actor::New();
1724 DevelHandle::SetProperties(
1728 { Actor::Property::SIZE, Vector3( 400.0f, 200.0f, 100.0f ) },
1729 { Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER },
1730 { Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER },
1731 { Actor::Property::NAME, "Actor" },
1732 { Actor::Property::LEAVE_REQUIRED, true },
1733 { "color", Color::RED },
1738 DevelHandle::GetProperties( handle, map );
1740 // Get all the properties and ensure they match
1742 DALI_TEST_EQUALS( handle.GetPropertyCount(), map.Count(), TEST_LOCATION );
1744 for( auto position = 0u; position < map.Count(); ++position )
1746 auto keyValuePair = map.GetKeyValue( position );
1747 const auto& index = keyValuePair.first.indexKey;
1748 const auto& value = keyValuePair.second;
1749 auto handleValue = handle.GetProperty( index );
1751 switch( value.GetType() )
1753 case Property::NONE: break;
1754 case Property::BOOLEAN: DALI_TEST_EQUALS( value.Get< bool >(), handleValue.Get< bool >(), TEST_LOCATION ); break;
1755 case Property::FLOAT: DALI_TEST_EQUALS( value.Get< float >(), handleValue.Get< float >(), TEST_LOCATION ); break;
1756 case Property::INTEGER: DALI_TEST_EQUALS( value.Get< int >(), handleValue.Get< int >(), TEST_LOCATION ); break;
1757 case Property::VECTOR2: DALI_TEST_EQUALS( value.Get< Vector2 >(), handleValue.Get< Vector2 >(), TEST_LOCATION ); break;
1758 case Property::VECTOR3: DALI_TEST_EQUALS( value.Get< Vector3 >(), handleValue.Get< Vector3 >(), TEST_LOCATION ); break;
1759 case Property::VECTOR4: DALI_TEST_EQUALS( value.Get< Vector4 >(), handleValue.Get< Vector4 >(), TEST_LOCATION ); break;
1760 case Property::MATRIX3: DALI_TEST_EQUALS( value.Get< Matrix3 >(), handleValue.Get< Matrix3 >(), TEST_LOCATION ); break;
1761 case Property::MATRIX: DALI_TEST_EQUALS( value.Get< Matrix >(), handleValue.Get< Matrix >(), TEST_LOCATION ); break;
1762 case Property::RECTANGLE: DALI_TEST_EQUALS( value.Get< Rect< int > >(), handleValue.Get< Rect< int > >(), TEST_LOCATION ); break;
1763 case Property::ROTATION: DALI_TEST_EQUALS( value.Get< Quaternion >(), handleValue.Get< Quaternion >(), TEST_LOCATION ); break;
1764 case Property::STRING: DALI_TEST_EQUALS( value.Get< std::string >(), handleValue.Get< std::string >(), TEST_LOCATION ); break;
1765 case Property::ARRAY: DALI_TEST_EQUALS( value.GetArray()->Count(), handleValue.GetArray()->Count(), TEST_LOCATION ); break;
1766 case Property::MAP: DALI_TEST_EQUALS( value.GetMap()->Count(), handleValue.GetMap()->Count(), TEST_LOCATION ); break;
1767 case Property::EXTENTS: DALI_TEST_EQUALS( value.Get< Extents >(), handleValue.Get< Extents >(), TEST_LOCATION ); break;
1771 // Add a custom property and ensure the count goes up by one.
1772 const auto countBefore = map.Count();
1773 handle.RegisterProperty( "tempProperty", Color::GREEN );
1774 DevelHandle::GetProperties( handle, map );
1775 DALI_TEST_EQUALS( countBefore + 1, map.Count(), TEST_LOCATION );