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.
18 #include <dali/devel-api/actors/actor-devel.h>
19 #include <dali/devel-api/object/handle-devel.h>
20 #include <dali/public-api/dali-core.h>
21 #include <mesh-builder.h>
27 #include "dali-test-suite-utils/dali-test-suite-utils.h"
28 #include "dali-test-suite-utils/test-custom-actor.h"
32 void handle_test_startup(void)
34 test_return_value = TET_UNDEF;
37 void handle_test_cleanup(void)
39 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);
67 int UtcDaliHandleConstructorVoid(void)
69 TestApplication application;
70 tet_infoline("Testing Dali::Handle::Handle()");
74 DALI_TEST_CHECK(!object);
79 int UtcDaliHandleCopyConstructor(void)
81 TestApplication application;
82 tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
84 // Initialize an object, ref count == 1
85 Handle object = Actor::New();
87 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
89 // Copy the object, ref count == 2
91 DALI_TEST_CHECK(copy);
94 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
98 // Pass by value, and return another copy, ref count == 3
99 Handle anotherCopy = ImplicitCopyConstructor(copy);
101 DALI_TEST_CHECK(anotherCopy);
104 DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
108 // anotherCopy out of scope, ref count == 2
109 DALI_TEST_CHECK(copy);
112 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
117 int UtcDaliHandleAssignmentOperator(void)
119 TestApplication application;
120 tet_infoline("Testing Dali::Handle::operator=");
122 Handle object = Actor::New();
124 DALI_TEST_CHECK(object);
125 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
128 DALI_TEST_CHECK(!copy);
131 DALI_TEST_CHECK(copy);
132 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
133 DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject()));
137 int UtcDaliHandleMoveConstructor(void)
139 TestApplication application;
141 // Initialize a handle, ref count == 1
142 Handle handle = Actor::New();
144 DALI_TEST_EQUALS(1, handle.GetBaseObject().ReferenceCount(), TEST_LOCATION);
147 Property::Index index = handle.RegisterProperty("customProperty", value);
148 DALI_TEST_CHECK(handle.GetProperty<int>(index) == value);
150 // Move the object, ref count == 1
151 Handle move = std::move(handle);
152 DALI_TEST_CHECK(move);
154 // Check that object is moved (not copied, so ref count keeps the same)
155 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
156 DALI_TEST_CHECK(move.GetProperty<int>(index) == value);
157 DALI_TEST_CHECK(!handle);
162 int UtcDaliHandleMoveAssignment(void)
164 TestApplication application;
166 // Initialize a handle, ref count == 1
167 Handle handle = Actor::New();
169 DALI_TEST_EQUALS(1, handle.GetBaseObject().ReferenceCount(), TEST_LOCATION);
172 Property::Index index = handle.RegisterProperty("customProperty", value);
173 DALI_TEST_CHECK(handle.GetProperty<int>(index) == value);
175 // Move the object, ref count == 1
177 move = std::move(handle);
178 DALI_TEST_CHECK(move);
180 // Check that object is moved (not copied, so ref count keeps the same)
181 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
182 DALI_TEST_CHECK(move.GetProperty<int>(index) == value);
183 DALI_TEST_CHECK(!handle);
188 int UtcDaliHandleSupports(void)
190 tet_infoline("Positive Test Dali::Handle::Supports()");
191 TestApplication application;
193 Actor actor = Actor::New();
194 DALI_TEST_CHECK(true == actor.Supports(Handle::DYNAMIC_PROPERTIES));
198 int UtcDaliHandleGetPropertyCount(void)
200 tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
201 TestApplication application;
203 Actor actor = Actor::New();
204 int defaultPropertyCount(actor.GetPropertyCount());
206 // Register a dynamic property
207 actor.RegisterProperty("testProperty", float(123.0f));
208 DALI_TEST_CHECK((defaultPropertyCount + 1u) == actor.GetPropertyCount());
212 int UtcDaliHandleGetPropertyName(void)
214 tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
215 TestApplication application;
217 Actor actor = Actor::New();
218 DALI_TEST_CHECK("parentOrigin" == actor.GetPropertyName(Actor::Property::PARENT_ORIGIN));
220 // Register a dynamic property
221 std::string name("thisNameShouldMatch");
222 Property::Index index = actor.RegisterProperty(name, float(123.0f));
223 DALI_TEST_CHECK(name == actor.GetPropertyName(index));
228 int UtcDaliHandleGetPropertyIndex01(void)
230 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
231 TestApplication application;
233 Actor actor = Actor::New();
234 DALI_TEST_CHECK(Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parentOrigin"));
236 // Register a dynamic property
237 std::string name("thisNameShouldMatch");
238 Property::Index index = actor.RegisterProperty(name, float(123.0f));
239 DALI_TEST_CHECK(index == actor.GetPropertyIndex(name));
243 int UtcDaliHandleGetPropertyIndex02(void)
245 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex() int key");
246 TestApplication application;
248 Integration::Scene stage = application.GetScene();
250 Actor actor = Actor::New();
253 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
255 application.SendNotification();
256 application.Render();
258 Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
259 Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
261 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
262 const float withFlake(99.f);
264 Property::Index index1 = actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
265 Property::Index index2 = actor.RegisterProperty(key1, "sideColor", testColor);
266 Property::Index index3 = actor.RegisterProperty("MyPropertyTwo", Vector3::ONE);
267 Property::Index index4 = actor.RegisterProperty(key2, "iceCream", withFlake);
268 Property::Index index5 = actor.RegisterProperty("MyPropertyThree", Vector3::ONE);
270 application.SendNotification();
271 application.Render();
273 // Test that we can get the property index from the integer key
274 Property::Index testIndex1 = actor.GetPropertyIndex(key1);
275 Property::Index testIndex2 = actor.GetPropertyIndex(key2);
277 DALI_TEST_EQUALS(index2, testIndex1, TEST_LOCATION);
278 DALI_TEST_EQUALS(index4, testIndex2, TEST_LOCATION);
280 // Test that we keep the same indices on the named properties
281 Property::Index testIndex = actor.GetPropertyIndex("MyPropertyOne");
282 DALI_TEST_EQUALS(testIndex, index1, TEST_LOCATION);
283 testIndex = actor.GetPropertyIndex("MyPropertyTwo");
284 DALI_TEST_EQUALS(testIndex, index3, TEST_LOCATION);
285 testIndex = actor.GetPropertyIndex("MyPropertyThree");
286 DALI_TEST_EQUALS(testIndex, index5, TEST_LOCATION);
287 testIndex = actor.GetPropertyIndex("sideColor");
288 DALI_TEST_EQUALS(testIndex, index2, TEST_LOCATION);
289 testIndex = actor.GetPropertyIndex("iceCream");
290 DALI_TEST_EQUALS(testIndex, index4, TEST_LOCATION);
292 DALI_TEST_EQUALS(defaultPropertyCount + 5, actor.GetPropertyCount(), TEST_LOCATION);
296 int UtcDaliHandleGetPropertyIndex03(void)
298 TestApplication application;
300 Actor actor = Actor::New();
302 std::string myName("croydon");
303 Property::Index intKey = CORE_PROPERTY_MAX_INDEX + 1;
304 Property::Value value(Color::GREEN);
305 Property::Index myIndex = actor.RegisterProperty(intKey, myName, value);
307 DALI_TEST_EQUALS(myIndex, actor.GetPropertyIndex(intKey), TEST_LOCATION);
309 Property::Key key1(myName);
310 Property::Key key2(intKey);
312 DALI_TEST_EQUALS(myIndex, actor.GetPropertyIndex(key1), TEST_LOCATION);
313 DALI_TEST_EQUALS(myIndex, actor.GetPropertyIndex(key2), TEST_LOCATION);
317 int UtcDaliHandleIsPropertyWritable(void)
319 tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
320 TestApplication application;
322 Actor actor = Actor::New();
324 // Actor properties which are writable:
325 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::PARENT_ORIGIN));
326 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::PARENT_ORIGIN_X));
327 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::PARENT_ORIGIN_Y));
328 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::PARENT_ORIGIN_Z));
329 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ANCHOR_POINT));
330 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ANCHOR_POINT_X));
331 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ANCHOR_POINT_Y));
332 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ANCHOR_POINT_Z));
333 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SIZE));
334 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SIZE_WIDTH));
335 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SIZE_HEIGHT));
336 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SIZE_DEPTH));
337 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::POSITION));
338 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::POSITION_X));
339 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::POSITION_Y));
340 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::POSITION_Z));
341 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::ORIENTATION));
342 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SCALE));
343 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SCALE_X));
344 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SCALE_Y));
345 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::SCALE_Z));
346 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::VISIBLE));
347 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR));
348 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR_RED));
349 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR_GREEN));
350 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR_BLUE));
351 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::COLOR_ALPHA));
352 DALI_TEST_CHECK(true == actor.IsPropertyWritable(Actor::Property::OPACITY));
354 // World-properties are not writable:
355 DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_POSITION));
356 DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_ORIENTATION));
357 DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_SCALE));
358 DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_COLOR));
359 DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_POSITION_X));
360 DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_POSITION_Y));
361 DALI_TEST_CHECK(false == actor.IsPropertyWritable(Actor::Property::WORLD_POSITION_Z));
366 int UtcDaliHandleIsPropertyAnimatable(void)
368 tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
369 TestApplication application;
371 Actor actor = Actor::New();
373 // Actor properties which are animatable:
374 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::PARENT_ORIGIN));
375 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::PARENT_ORIGIN_X));
376 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::PARENT_ORIGIN_Y));
377 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::PARENT_ORIGIN_Z));
378 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::ANCHOR_POINT));
379 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::ANCHOR_POINT_X));
380 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::ANCHOR_POINT_Y));
381 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::ANCHOR_POINT_Z));
382 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SIZE));
383 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SIZE_WIDTH));
384 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SIZE_HEIGHT));
385 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SIZE_DEPTH));
386 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::POSITION));
387 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::POSITION_X));
388 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::POSITION_Y));
389 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::POSITION_Z));
390 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::ORIENTATION));
391 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SCALE));
392 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SCALE_X));
393 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SCALE_Y));
394 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::SCALE_Z));
395 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::VISIBLE));
396 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR));
397 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR_RED));
398 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR_GREEN));
399 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR_BLUE));
400 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::COLOR_ALPHA));
401 DALI_TEST_CHECK(true == actor.IsPropertyAnimatable(Actor::Property::OPACITY));
403 // World-properties can not be animated
404 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_POSITION));
405 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_ORIENTATION));
406 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_SCALE));
407 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_COLOR));
408 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_POSITION_X));
409 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_POSITION_Y));
410 DALI_TEST_CHECK(false == actor.IsPropertyAnimatable(Actor::Property::WORLD_POSITION_Z));
415 int UtcDaliHandleIsPropertyAConstraintInput(void)
417 TestApplication application;
419 Actor actor = Actor::New();
421 // Actor properties which can be used as a constraint input:
422 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::PARENT_ORIGIN));
423 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::PARENT_ORIGIN_X));
424 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::PARENT_ORIGIN_Y));
425 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::PARENT_ORIGIN_Z));
426 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ANCHOR_POINT));
427 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ANCHOR_POINT_X));
428 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ANCHOR_POINT_Y));
429 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ANCHOR_POINT_Z));
430 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SIZE));
431 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SIZE_WIDTH));
432 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SIZE_HEIGHT));
433 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SIZE_DEPTH));
434 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::POSITION));
435 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::POSITION_X));
436 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::POSITION_Y));
437 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::POSITION_Z));
438 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::ORIENTATION));
439 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SCALE));
440 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SCALE_X));
441 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SCALE_Y));
442 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::SCALE_Z));
443 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::VISIBLE));
444 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR));
445 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_RED));
446 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_GREEN));
447 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_BLUE));
448 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_ALPHA));
449 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::OPACITY));
450 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_POSITION));
451 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_ORIENTATION));
452 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_SCALE));
453 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_COLOR));
454 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_POSITION_X));
455 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_POSITION_Y));
456 DALI_TEST_CHECK(true == actor.IsPropertyAConstraintInput(Actor::Property::WORLD_POSITION_Z));
458 // Actor properties that cannot be used as a constraint input
459 DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::NAME));
460 DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::SENSITIVE));
461 DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::LEAVE_REQUIRED));
462 DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::INHERIT_ORIENTATION));
463 DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::INHERIT_SCALE));
464 DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::COLOR_MODE));
465 DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::DRAW_MODE));
466 DALI_TEST_CHECK(false == actor.IsPropertyAConstraintInput(Actor::Property::SIZE_MODE_FACTOR));
471 int UtcDaliHandleGetPropertyType(void)
473 tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
474 TestApplication application;
476 Actor actor = Actor::New();
477 DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::PARENT_ORIGIN));
478 DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::ANCHOR_POINT));
479 DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::SIZE));
480 DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::POSITION));
481 DALI_TEST_CHECK(Property::ROTATION == actor.GetPropertyType(Actor::Property::ORIENTATION));
482 DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(Actor::Property::SCALE));
483 DALI_TEST_CHECK(Property::BOOLEAN == actor.GetPropertyType(Actor::Property::VISIBLE));
484 DALI_TEST_CHECK(Property::VECTOR4 == actor.GetPropertyType(Actor::Property::COLOR));
486 // Register some dynamic properties
487 Property::Index boolIndex = actor.RegisterProperty("boolProperty", bool(true));
488 Property::Index floatIndex = actor.RegisterProperty("floatProperty", float(123.0f));
489 Property::Index intIndex = actor.RegisterProperty("intProperty", 123);
490 Property::Index vector2Index = actor.RegisterProperty("vector2Property", Vector2(1.0f, 2.0f));
491 Property::Index vector3Index = actor.RegisterProperty("vector3Property", Vector3(1.0f, 2.0f, 3.0f));
492 Property::Index vector4Index = actor.RegisterProperty("vector4Property", Vector4(1.0f, 2.0f, 3.0f, 4.0f));
493 Property::Index rotationIndex = actor.RegisterProperty("rotationProperty", AngleAxis(Degree(180.0f), Vector3::YAXIS));
495 DALI_TEST_CHECK(Property::BOOLEAN == actor.GetPropertyType(boolIndex));
496 DALI_TEST_CHECK(Property::FLOAT == actor.GetPropertyType(floatIndex));
497 DALI_TEST_CHECK(Property::INTEGER == actor.GetPropertyType(intIndex));
498 DALI_TEST_CHECK(Property::VECTOR2 == actor.GetPropertyType(vector2Index));
499 DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(vector3Index));
500 DALI_TEST_CHECK(Property::VECTOR4 == actor.GetPropertyType(vector4Index));
501 DALI_TEST_CHECK(Property::ROTATION == actor.GetPropertyType(rotationIndex));
503 // Non animatable properties
504 Property::Index nonAnimStringIndex = actor.RegisterProperty("manFromDelmonte", std::string("yes"), Property::READ_WRITE);
505 Property::Index nonAnimV2Index = actor.RegisterProperty("v2", Vector2(1.f, 2.f), Property::READ_WRITE);
506 Property::Index nonAnimV3Index = actor.RegisterProperty("v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
507 Property::Index nonAnimV4Index = actor.RegisterProperty("v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
508 Property::Index nonAnimBooleanIndex = actor.RegisterProperty("bool", true, Property::READ_WRITE);
509 Property::Index nonAnimFloatIndex = actor.RegisterProperty("float", 0.f, Property::READ_WRITE);
510 Property::Index nonAnimIntegerIndex = actor.RegisterProperty("int", 0, Property::READ_WRITE);
512 DALI_TEST_CHECK(nonAnimStringIndex != Property::INVALID_INDEX);
513 DALI_TEST_CHECK(nonAnimV2Index != Property::INVALID_INDEX);
514 DALI_TEST_CHECK(nonAnimV3Index != Property::INVALID_INDEX);
515 DALI_TEST_CHECK(nonAnimV4Index != Property::INVALID_INDEX);
516 DALI_TEST_CHECK(nonAnimBooleanIndex != Property::INVALID_INDEX);
517 DALI_TEST_CHECK(nonAnimFloatIndex != Property::INVALID_INDEX);
518 DALI_TEST_CHECK(nonAnimIntegerIndex != Property::INVALID_INDEX);
520 DALI_TEST_CHECK(Property::STRING == actor.GetPropertyType(nonAnimStringIndex));
521 DALI_TEST_CHECK(Property::VECTOR2 == actor.GetPropertyType(nonAnimV2Index));
522 DALI_TEST_CHECK(Property::VECTOR3 == actor.GetPropertyType(nonAnimV3Index));
523 DALI_TEST_CHECK(Property::VECTOR4 == actor.GetPropertyType(nonAnimV4Index));
524 DALI_TEST_CHECK(Property::BOOLEAN == actor.GetPropertyType(nonAnimBooleanIndex));
525 DALI_TEST_CHECK(Property::FLOAT == actor.GetPropertyType(nonAnimFloatIndex));
526 DALI_TEST_CHECK(Property::INTEGER == actor.GetPropertyType(nonAnimIntegerIndex));
528 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimStringIndex));
529 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimV2Index));
530 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimV3Index));
531 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimV4Index));
532 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimBooleanIndex));
533 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimFloatIndex));
534 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(nonAnimIntegerIndex));
536 DALI_TEST_EQUALS("yes", actor.GetProperty(nonAnimStringIndex).Get<std::string>(), TEST_LOCATION);
537 DALI_TEST_EQUALS(Vector2(1.f, 2.f), actor.GetProperty(nonAnimV2Index).Get<Vector2>(), TEST_LOCATION);
538 DALI_TEST_EQUALS(Vector3(1.f, 2.f, 3.f), actor.GetProperty(nonAnimV3Index).Get<Vector3>(), TEST_LOCATION);
539 DALI_TEST_EQUALS(Vector4(1.f, 2.f, 3.f, 4.f), actor.GetProperty(nonAnimV4Index).Get<Vector4>(), TEST_LOCATION);
540 DALI_TEST_EQUALS(true, actor.GetProperty(nonAnimBooleanIndex).Get<bool>(), TEST_LOCATION);
541 DALI_TEST_EQUALS(0.f, actor.GetProperty(nonAnimFloatIndex).Get<float>(), TEST_LOCATION);
542 DALI_TEST_EQUALS(0, actor.GetProperty(nonAnimIntegerIndex).Get<int>(), TEST_LOCATION);
547 int UtcDaliHandleNonAnimatableProperties(void)
549 tet_infoline("Test Non Animatable Properties");
550 TestApplication application;
552 Actor actor = Actor::New();
554 Property::Index nonAnimStringIndex = actor.RegisterProperty("manFromDelmonte", std::string("no"), Property::READ_WRITE);
556 //// modify writable?
557 actor.SetProperty(nonAnimStringIndex, Property::Value("yes"));
559 DALI_TEST_CHECK("yes" == actor.GetProperty(nonAnimStringIndex).Get<std::string>());
561 //// cannot modify read only?
562 Property::Index readonly = actor.RegisterProperty("float", 0.f, Property::READ_ONLY);
564 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
565 DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
567 actor.SetProperty(readonly, Property::Value(1.f));
568 // trying to set a read-only property is a no-op
570 DALI_TEST_EQUALS(0.f, actor.GetProperty(readonly).Get<float>(), TEST_LOCATION);
572 /// animatable can be set
573 Property::Index write_anim = actor.RegisterProperty("write_float", 0.f, Property::ANIMATABLE);
575 DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
576 DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
578 actor.SetProperty(write_anim, Property::Value(1.f));
580 //// animate a non animatable property throws
581 float durationSeconds(2.0f);
582 Animation animation = Animation::New(durationSeconds);
583 bool relativeValue(true);
586 animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
588 catch(Dali::DaliException& e)
590 DALI_TEST_ASSERT(e, "Property type is not animatable", TEST_LOCATION);
593 DALI_TEST_EQUALS("yes", actor.GetProperty(nonAnimStringIndex).Get<std::string>(), TEST_LOCATION);
598 int UtcDaliHandleNonAnimtableCompositeProperties(void)
600 tet_infoline("Test Non Animatable Composite Properties");
601 TestApplication application;
603 Actor actor = Actor::New();
605 Property::Value value(Property::ARRAY);
606 Property::Array* array = value.GetArray();
607 DALI_TEST_CHECK(array);
609 array->PushBack(Property::Value(0.1f));
610 array->PushBack("a string");
611 array->PushBack(Property::Value(Vector3(1, 2, 3)));
613 DALI_TEST_EQUALS(3u, array->Count(), TEST_LOCATION);
615 Property::Index propertyIndex = actor.RegisterProperty("composite", value, Property::READ_WRITE);
617 Property::Value out = actor.GetProperty(propertyIndex);
618 Property::Array* outArray = out.GetArray();
619 DALI_TEST_CHECK(outArray != NULL);
621 DALI_TEST_CHECK(Property::FLOAT == outArray->GetElementAt(0).GetType());
622 DALI_TEST_CHECK(Property::STRING == outArray->GetElementAt(1).GetType());
623 DALI_TEST_CHECK(Property::VECTOR3 == outArray->GetElementAt(2).GetType());
625 DALI_TEST_EQUALS(0.1f, outArray->GetElementAt(0).Get<float>(), TEST_LOCATION);
626 DALI_TEST_EQUALS("a string", outArray->GetElementAt(1).Get<std::string>(), TEST_LOCATION);
627 DALI_TEST_EQUALS(Vector3(1, 2, 3), outArray->GetElementAt(2).Get<Vector3>(), TEST_LOCATION);
629 // composite types not animatable
630 bool exception = false;
633 actor.RegisterProperty("compositemap", value, Property::ANIMATABLE);
635 catch(Dali::DaliException& e)
638 DALI_TEST_PRINT_ASSERT(e);
641 DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
644 Property::Value mapOfMaps(Property::MAP);
645 Property::Map* map = mapOfMaps.GetMap();
647 map->Insert("key", Property::Value(Property::MAP));
648 map->Insert("2key", "a string");
650 DALI_TEST_EQUALS("a string", (*map)["2key"].Get<std::string>(), TEST_LOCATION);
652 Property::Map* innerMap = map->Find("key")->GetMap();
653 innerMap->Insert("subkey", 5.f);
655 DALI_TEST_CHECK(NULL != map->Find("key")->GetMap()->Find("subkey"));
656 DALI_TEST_EQUALS(5.f, map->Find("key")->GetMap()->Find("subkey")->Get<float>(), TEST_LOCATION);
660 int UtcDaliHandleSetProperty01(void)
662 tet_infoline("Positive Test Dali::Handle::SetProperty()");
663 TestApplication application;
665 Actor actor = Actor::New();
666 DALI_TEST_CHECK(ParentOrigin::TOP_LEFT == actor.GetProperty(Actor::Property::PARENT_ORIGIN).Get<Vector3>());
668 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
669 // flush the queue and render once
670 application.SendNotification();
671 application.Render();
672 DALI_TEST_CHECK(ParentOrigin::CENTER == actor.GetProperty(Actor::Property::PARENT_ORIGIN).Get<Vector3>());
676 int UtcDaliHandleSetProperty02(void)
678 tet_infoline("Positive Test Dali::Handle::SetProperty()");
679 TestApplication application;
681 Actor actor = Actor::New();
683 DALI_TEST_CHECK(!actor.IsPropertyWritable(Actor::Property::WORLD_POSITION));
685 // World position is not writable so this is a no-op and should not crash
686 actor.SetProperty(Actor::Property::WORLD_POSITION, Vector3(1, 2, 3));
691 int UtcDaliHandleRegisterProperty01(void)
693 tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
694 TestApplication application;
696 Integration::Scene stage = application.GetScene();
698 Actor actor = Actor::New();
701 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
703 application.SendNotification();
704 application.Render();
706 Property::Index index1 = actor.RegisterProperty("MyProperty", Vector3::ONE);
708 application.SendNotification();
709 application.Render();
711 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION);
712 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index1), Vector3::ONE, TEST_LOCATION);
714 // No new property should be registered when we call the below function
715 Property::Index index2 = actor.RegisterProperty("MyProperty", Vector3::ZAXIS);
717 application.SendNotification();
718 application.Render();
720 DALI_TEST_EQUALS(index1, index2, TEST_LOCATION); // We should have the same index as per the first registration
721 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION); // Property count should be the same
722 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index2), Vector3::ZAXIS, TEST_LOCATION); // Value should be what we sent on second RegisterProperty call
727 int UtcDaliHandleRegisterProperty02(void)
729 tet_infoline("Positive Test Dali::Handle::RegisterProperty() int key");
730 TestApplication application;
732 Integration::Scene stage = application.GetScene();
734 Actor actor = Actor::New();
737 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
739 application.SendNotification();
740 application.Render();
742 Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
743 Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
745 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
746 const float withFlake(99.f);
748 Property::Index index1 = actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
749 Property::Index index2 = actor.RegisterProperty(key1, "sideColor", testColor);
750 Property::Index index3 = actor.RegisterProperty(key2, "iceCream", withFlake);
752 application.SendNotification();
753 application.Render();
755 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION);
756 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index1), Vector3::ONE, TEST_LOCATION);
757 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), testColor, TEST_LOCATION);
758 DALI_TEST_EQUALS(actor.GetProperty<float>(index3), withFlake, TEST_LOCATION);
760 // No new property should be registered when we call the below functions
761 Property::Index testIndex2 = actor.RegisterProperty("iceCream", 2200.f);
762 Property::Index testIndex1 = actor.RegisterProperty("sideColor", Color::BLACK);
763 application.SendNotification();
764 application.Render();
766 DALI_TEST_EQUALS(index2, testIndex1, TEST_LOCATION); // We should have the same index as per the first registration
767 DALI_TEST_EQUALS(index3, testIndex2, TEST_LOCATION); // We should have the same index as per the first registration
768 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION); // Property count should be the same
769 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), Color::BLACK, TEST_LOCATION); // Value should be what we sent on second RegisterProperty call
770 DALI_TEST_EQUALS(actor.GetProperty<float>(index3), 2200.f, TEST_LOCATION);
775 int UtcDaliHandleGetProperty(void)
777 tet_infoline("Positive Test Dali::Handle::GetProperty()");
778 TestApplication application;
780 Actor actor = Actor::New();
782 DALI_TEST_CHECK(ParentOrigin::TOP_LEFT == actor.GetProperty(Actor::Property::PARENT_ORIGIN).Get<Vector3>());
783 DALI_TEST_CHECK(AnchorPoint::CENTER == actor.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>());
784 DALI_TEST_CHECK(Vector3::ZERO == actor.GetProperty(Actor::Property::SIZE).Get<Vector3>());
785 DALI_TEST_CHECK(Vector3::ZERO == actor.GetProperty(Actor::Property::POSITION).Get<Vector3>());
786 DALI_TEST_CHECK(Vector3::ONE == actor.GetProperty(Actor::Property::SCALE).Get<Vector3>());
787 DALI_TEST_CHECK(true == actor.GetProperty(Actor::Property::VISIBLE).Get<bool>());
788 DALI_TEST_CHECK(Color::WHITE == actor.GetProperty(Actor::Property::COLOR).Get<Vector4>());
792 int UtcDaliHandleDownCast(void)
794 TestApplication application;
795 tet_infoline("Testing Dali::Handle::DownCast()");
797 Actor actor = Actor::New();
799 BaseHandle baseHandle = actor;
801 Handle handle = Handle::DownCast(baseHandle);
803 DALI_TEST_CHECK(handle);
805 baseHandle = BaseHandle();
807 handle = Handle::DownCast(baseHandle);
809 DALI_TEST_CHECK(!handle);
814 int UtcDaliHandleDownCastNegative(void)
816 TestApplication application;
818 // BaseObject is NOT an Object, so this DownCast should fail
819 BaseHandle handle(new BaseObjectType);
820 Handle customHandle1 = Handle::DownCast(handle);
821 DALI_TEST_CHECK(!customHandle1);
823 // A DownCast on an empty handle will also fail
825 Handle customHandle2 = Handle::DownCast(empty);
826 DALI_TEST_CHECK(!customHandle2);
830 int UtcDaliHandleGetPropertyIndices(void)
832 TestApplication application;
833 Property::IndexContainer indices;
836 Actor actor = Actor::New();
837 actor.GetPropertyIndices(indices);
838 int numDefaultProperties = indices.Size();
839 DALI_TEST_CHECK(numDefaultProperties > 0);
840 DALI_TEST_EQUALS(numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION);
842 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
843 const float withFlake(99.f);
845 Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
846 Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
848 actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
849 actor.RegisterProperty(key1, "sideColor", testColor);
850 actor.RegisterProperty("MyPropertyTwo", 1234);
851 Property::Index index4 = actor.RegisterProperty(key2, "iceCream", withFlake);
852 actor.RegisterProperty("MyPropertyThree", Vector2(.2f, .7f));
854 actor.GetPropertyIndices(indices);
856 DALI_TEST_EQUALS(indices.Size(), numDefaultProperties + 5, TEST_LOCATION);
857 DALI_TEST_EQUALS(indices[indices.Size() - 2], index4, TEST_LOCATION);
862 int UtcDaliHandleRegisterPropertyTypes(void)
864 TestApplication application;
866 struct PropertyTypeAnimatable
869 Property::Value value;
873 Property::Array array;
876 PropertyTypeAnimatable properties[] =
878 {"Property::BOOLEAN", true, true},
879 {"Property::FLOAT", 1.0f, true},
880 {"Property::INTEGER", 1, true},
881 {"Property::VECTOR2", Vector2::ONE, true},
882 {"Property::VECTOR3", Vector3::ONE, true},
883 {"Property::VECTOR4", Vector4::ONE, true},
884 {"Property::MATRIX3", Matrix3::IDENTITY, true},
885 {"Property::MATRIX", Matrix::IDENTITY, true},
886 {"Property::RECTANGLE", Rect<int>(), false},
887 {"Property::ROTATION", AngleAxis(), true},
888 {"Property::STRING", std::string("Me"), false},
889 {"Property::ARRAY", array, false},
890 {"Property::MAP", map, false},
893 unsigned int numOfProperties(sizeof(properties) / sizeof(properties[0]));
895 for(unsigned int i = 0; i < numOfProperties; ++i)
897 tet_printf("Testing: %s\n", properties[i].name);
899 bool exception = false;
902 Actor actor = Actor::New();
903 actor.RegisterProperty("manFromDelmonte", properties[i].value);
905 catch(Dali::DaliException& e)
910 DALI_TEST_CHECK(properties[i].animatable != exception);
915 int UtcDaliHandleCustomProperty(void)
917 TestApplication application;
919 Handle handle = Handle::New();
921 float startValue(1.0f);
922 Property::Index index = handle.RegisterProperty("testProperty", startValue);
923 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
925 application.SendNotification();
926 application.Render(0);
927 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
928 application.Render(0);
929 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
931 handle.SetProperty(index, 5.0f);
933 application.SendNotification();
934 application.Render(0);
935 DALI_TEST_CHECK(handle.GetProperty<float>(index) == 5.0f);
936 application.Render(0);
937 DALI_TEST_CHECK(handle.GetProperty<float>(index) == 5.0f);
941 int UtcDaliHandleCustomPropertyNone(void)
943 TestApplication application;
945 Handle handle = Handle::New();
947 Property::Value value(Property::NONE);
948 Property::Index index = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
950 // Negative test i.e. setting a property of type NONE is meaningless
951 handle.SetProperty(index, 5.0f);
953 DALI_TEST_CHECK(true); // got here without crashing
958 int UtcDaliHandleCustomPropertyIntToFloat(void)
960 TestApplication application;
962 Handle handle = Handle::New();
964 float startValue(5.0f);
965 Property::Index index = handle.RegisterProperty("testProperty", startValue);
966 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
968 application.SendNotification();
969 application.Render(0);
970 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
972 handle.SetProperty(index, int(1));
974 application.SendNotification();
975 application.Render(0);
976 DALI_TEST_CHECK(handle.GetProperty<float>(index) == 1.0f);
980 int UtcDaliHandleCustomPropertyFloatToInt(void)
982 TestApplication application;
984 Handle handle = Handle::New();
987 Property::Index index = handle.RegisterProperty("testProperty", startValue);
988 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
990 application.SendNotification();
991 application.Render(0);
992 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
994 handle.SetProperty(index, float(1.5));
996 application.SendNotification();
997 application.Render(0);
998 DALI_TEST_CHECK(handle.GetProperty<int>(index) == 1);
1002 int UtcDaliHandleCustomPropertyInvalidToRect(void)
1004 TestApplication application;
1006 Handle handle = Handle::New();
1008 Rect<int> startValue(1, 2, 3, 4);
1009 Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1010 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1012 application.SendNotification();
1013 application.Render(0);
1014 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1016 // Negative test i.e. there is no conversion from float to Rect
1017 handle.SetProperty(index, float(1.5));
1019 application.SendNotification();
1020 application.Render(0);
1021 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1023 // Positive test (sanity check)
1024 Rect<int> endValue(5, 6, 7, 8);
1025 handle.SetProperty(index, endValue);
1026 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), endValue, TEST_LOCATION);
1028 application.SendNotification();
1029 application.Render(0);
1030 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), endValue, TEST_LOCATION);
1035 int UtcDaliHandleCustomPropertyInvalidToString(void)
1037 TestApplication application;
1039 Handle handle = Handle::New();
1041 std::string startValue("Libraries gave us power");
1042 Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1043 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1045 application.SendNotification();
1046 application.Render(0);
1047 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1049 // No conversion from Vector3 to std::string, therefore this should be a NOOP
1050 handle.SetProperty(index, Vector3(1, 2, 3));
1052 application.SendNotification();
1053 application.Render(0);
1054 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1056 // Positive test (sanity check)
1057 std::string endValue("Then work came and made us free");
1058 handle.SetProperty(index, endValue);
1059 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), endValue, TEST_LOCATION);
1061 application.SendNotification();
1062 application.Render(0);
1063 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), endValue, TEST_LOCATION);
1068 int UtcDaliHandleCustomPropertyInvalidToArray(void)
1070 TestApplication application;
1072 Handle handle = Handle::New();
1074 Property::Value value(Property::ARRAY);
1075 std::string startValue("The future teaches you to be alone");
1076 value.GetArray()->PushBack(startValue);
1078 Property::Index index = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1079 Property::Array check1 = handle.GetProperty<Property::Array>(index);
1080 DALI_TEST_EQUALS(check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1082 application.SendNotification();
1083 application.Render(0);
1084 Property::Array check2 = handle.GetProperty<Property::Array>(index);
1085 DALI_TEST_EQUALS(check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1087 // No conversion from int to ARRAY, therefore this should be a NOOP
1088 handle.SetProperty(index, int(2));
1090 application.SendNotification();
1091 application.Render(0);
1092 Property::Array check3 = handle.GetProperty<Property::Array>(index);
1093 DALI_TEST_EQUALS(check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1095 // Positive test (sanity check)
1096 Property::Value value2(Property::ARRAY);
1097 std::string endValue("The present to be afraid and cold");
1098 value2.GetArray()->PushBack(endValue);
1099 handle.SetProperty(index, value2);
1101 Property::Array check4 = handle.GetProperty<Property::Array>(index);
1102 DALI_TEST_EQUALS(check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION);
1104 application.SendNotification();
1105 application.Render(0);
1106 Property::Array check5 = handle.GetProperty<Property::Array>(index);
1107 DALI_TEST_EQUALS(check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION);
1112 int UtcDaliHandleCustomPropertyInvalidToMap(void)
1114 TestApplication application;
1116 Handle handle = Handle::New();
1118 Property::Value value(Property::MAP);
1119 std::string startValue("Culture sucks down words");
1120 value.GetMap()->Insert("1", startValue);
1122 Property::Index index = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1123 Property::Value* check1 = handle.GetProperty<Property::Map>(index).Find("1");
1124 DALI_TEST_CHECK(NULL != check1);
1126 // No conversion from float to MAP, therefore this should be a NOOP
1127 handle.SetProperty(index, float(3.0));
1129 // Positive test (sanity check)
1130 Property::Value value2(Property::MAP);
1131 std::string endValue("Itemise loathing and feed yourself smiles");
1132 value.GetMap()->Insert("1", endValue);
1133 handle.SetProperty(index, value2);
1138 int UtcDaliHandleCustomPropertyInvalidToExtents(void)
1140 TestApplication application;
1142 Handle handle = Handle::New();
1144 Extents startValue(1, 2, 3, 4);
1145 Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1146 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1148 application.SendNotification();
1149 application.Render(0);
1150 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1152 // Negative test i.e. there is no conversion from float to Extents
1153 handle.SetProperty(index, float(1.5));
1155 application.SendNotification();
1156 application.Render(0);
1157 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1159 // Positive test (sanity check)
1160 Extents endValue(5, 6, 7, 8);
1161 handle.SetProperty(index, endValue);
1162 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), endValue, TEST_LOCATION);
1164 application.SendNotification();
1165 application.Render(0);
1166 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), endValue, TEST_LOCATION);
1171 int UtcDaliHandleCustomPropertyInvalidToBool(void)
1173 TestApplication application;
1175 Handle handle = Handle::New();
1177 bool startValue(true);
1178 Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1179 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1181 application.SendNotification();
1182 application.Render(0);
1183 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1185 // Negative test i.e. there is no conversion from float to bool
1186 handle.SetProperty(index, float(0.0));
1188 application.SendNotification();
1189 application.Render(0);
1190 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1192 // Positive test (sanity check)
1193 bool endValue(false);
1194 handle.SetProperty(index, endValue);
1195 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), endValue, TEST_LOCATION);
1197 application.SendNotification();
1198 application.Render(0);
1199 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), endValue, TEST_LOCATION);
1204 int UtcDaliHandleCustomPropertyInvalidToInt(void)
1206 TestApplication application;
1208 Handle handle = Handle::New();
1211 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1212 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1214 application.SendNotification();
1215 application.Render(0);
1216 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1218 // Negative test i.e. there is no conversion from Vector3 to int
1219 handle.SetProperty(index, Vector3(1, 2, 3));
1221 application.SendNotification();
1222 application.Render(0);
1223 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1227 int UtcDaliHandleCustomPropertyInvalidToFloat(void)
1229 TestApplication application;
1231 Handle handle = Handle::New();
1233 float startValue(5.0);
1234 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1235 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1237 application.SendNotification();
1238 application.Render(0);
1239 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1241 // Negative test i.e. there is no conversion from Vector3 to float
1242 handle.SetProperty(index, Vector3(1, 2, 3));
1244 application.SendNotification();
1245 application.Render(0);
1246 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1250 int UtcDaliHandleCustomPropertyInvalidToRotation(void)
1252 TestApplication application;
1254 Handle handle = Handle::New();
1256 Quaternion startValue(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1257 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1258 DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1260 application.SendNotification();
1261 application.Render(0);
1262 DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1264 // Negative test i.e. there is no conversion from float to Quaternion
1265 handle.SetProperty(index, float(7.0));
1267 application.SendNotification();
1268 application.Render(0);
1269 DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1271 // Positive test (sanity check)
1272 Quaternion endValue(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1273 handle.SetProperty(index, endValue);
1274 DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == endValue);
1279 int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
1281 TestApplication application;
1283 Handle handle = Handle::New();
1285 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1286 Matrix startValue(rotation);
1287 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1288 DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1290 application.SendNotification();
1291 application.Render(0);
1292 DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1294 // Negative test i.e. there is no conversion from float to Matrix
1295 handle.SetProperty(index, float(7.0));
1297 application.SendNotification();
1298 application.Render(0);
1299 DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1301 // Positive test (sanity check)
1302 Quaternion endRotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1303 Matrix endValue(endRotation);
1304 handle.SetProperty(index, endValue);
1305 DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == endValue);
1310 int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
1312 TestApplication application;
1314 Handle handle = Handle::New();
1316 Matrix3 startValue(11, 12, 13, 21, 22, 23, 31, 32, 33);
1318 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1319 DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1321 application.SendNotification();
1322 application.Render(0);
1323 DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1325 // Negative test i.e. there is no conversion from float to Matrix3
1326 handle.SetProperty(index, float(7.0));
1328 application.SendNotification();
1329 application.Render(0);
1330 DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1332 // Positive test (sanity check)
1333 Matrix3 endValue(31, 32, 33, 21, 22, 23, 11, 12, 13);
1334 handle.SetProperty(index, endValue);
1335 DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == endValue);
1340 int UtcDaliHandleWeightNew(void)
1342 TestApplication application;
1344 Handle handle = WeightObject::New();
1345 DALI_TEST_CHECK(handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f);
1347 // process the message so scene object is added to update manager
1348 application.SendNotification();
1349 application.Render(0);
1351 // no message to release scene object in this scenario
1356 int UtcDaliHandleWeightNew2(void)
1358 TestApplication application;
1360 // scope for the weight object
1362 Handle handle = WeightObject::New();
1363 DALI_TEST_CHECK(handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f);
1365 // process the message so scene object is added to update manager
1366 application.SendNotification();
1367 application.Render(0);
1369 // handle out of scope so object gets destroyed
1370 // process the message so update manager destroys the scene object
1371 application.SendNotification();
1372 application.Render(0);
1377 int UtcDaliHandleSetTypeInfo(void)
1379 TestApplication application;
1380 TypeRegistry typeRegistry = TypeRegistry::Get();
1382 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
1383 DALI_TEST_CHECK(typeInfo);
1385 Actor actor = Actor::DownCast(typeInfo.CreateInstance());
1386 DALI_TEST_CHECK(actor);
1388 DevelHandle::SetTypeInfo(actor, typeInfo);
1390 TypeInfo newTypeInfo;
1391 bool success = actor.GetTypeInfo(newTypeInfo);
1392 DALI_TEST_CHECK(success);
1394 DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
1395 DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
1400 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
1402 TestApplication application;
1404 tet_infoline("Create a custom property and set the value ensuring it can be retrieved synchronously");
1406 Actor actor = Actor::New();
1407 application.GetScene().Add(actor);
1409 tet_infoline("Create the custom property with an initial value");
1410 float startValue(1.0f);
1411 Property::Index index = actor.RegisterProperty("testProperty", startValue);
1412 DALI_TEST_EQUALS(actor.GetProperty<float>(index), startValue, TEST_LOCATION);
1414 tet_infoline("Set the value, retrieve it and ensure both the synchronous and the async version work");
1415 actor.SetProperty(index, 5.0f);
1416 DALI_TEST_EQUALS(actor.GetProperty<float>(index), 5.0f, TEST_LOCATION);
1417 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), startValue, TEST_LOCATION);
1419 tet_infoline("Render and retrieve values again");
1420 application.SendNotification();
1421 application.Render(0);
1423 DALI_TEST_EQUALS(actor.GetProperty<float>(index), 5.0f, TEST_LOCATION);
1424 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 5.0f, TEST_LOCATION);
1429 int UtcDaliHandleCustomPropertyGetType(void)
1431 TestApplication application;
1433 tet_infoline("Create a custom property and retrieve its type");
1435 Handle handle = Handle::New();
1436 Property::Index index = handle.RegisterProperty("testProperty", 1.0f);
1437 DALI_TEST_EQUALS(handle.GetPropertyType(index), Property::FLOAT, TEST_LOCATION);
1442 int UtcDaliHandleCustomPropertyAccessMode(void)
1444 TestApplication application;
1446 tet_infoline("Create a custom property and retrieve whether it's animatable etc.");
1448 Handle handle = Handle::New();
1449 Property::Index index = handle.RegisterProperty("testProperty", 1.0f);
1450 DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), true, TEST_LOCATION);
1451 DALI_TEST_EQUALS(handle.IsPropertyWritable(index), true, TEST_LOCATION);
1453 index = handle.RegisterProperty("testProperty2", 1.0f, Property::READ_ONLY);
1454 DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), false, TEST_LOCATION);
1455 DALI_TEST_EQUALS(handle.IsPropertyWritable(index), false, TEST_LOCATION);
1457 index = handle.RegisterProperty("testProperty3", 1.0f, Property::READ_WRITE);
1458 DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), false, TEST_LOCATION);
1459 DALI_TEST_EQUALS(handle.IsPropertyWritable(index), true, TEST_LOCATION);
1464 int UtcDaliHandleGetCurrentProperty(void)
1466 TestApplication application;
1468 tet_infoline("Get a default and non-animatable custom property using the GetCurrentProperty API");
1470 Actor actor = Actor::New();
1471 application.GetScene().Add(actor);
1472 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
1474 Property::Index index = actor.RegisterProperty("testProperty3", 1.0f, Property::READ_WRITE);
1475 DALI_TEST_EQUALS(actor.GetProperty<float>(index), 1.0f, TEST_LOCATION);
1476 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 1.0f, TEST_LOCATION);
1478 actor.SetProperty(index, 2.0f);
1479 DALI_TEST_EQUALS(actor.GetProperty<float>(index), 2.0f, TEST_LOCATION);
1480 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 2.0f, TEST_LOCATION);
1485 int UtcDaliHandleDoesCustomPropertyExistP1(void)
1487 TestApplication application; // Needs type registry
1489 tet_infoline("Test if a registered custom property exists on object");
1491 Actor actor = Actor::New();
1492 auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1494 DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(propertyIndex), true, TEST_LOCATION);
1498 int UtcDaliHandleDoesCustomPropertyExistN1(void)
1500 TestApplication application; // Needs type registry
1502 tet_infoline("Test if a registered custom property does not exist on object");
1504 Actor actor = Actor::New();
1505 auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1507 DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(propertyIndex + 1), false, TEST_LOCATION);
1511 int UtcDaliHandleDoesCustomPropertyExistN2(void)
1513 TestApplication application; // Needs type registry
1515 tet_infoline("Test that a default property does not show as a custom property on object");
1517 Actor actor = Actor::New();
1518 DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(Actor::Property::POSITION), false, TEST_LOCATION);
1522 int UtcDaliHandleDoesCustomPropertyExistN3(void)
1524 TestApplication application; // Needs type registry
1526 tet_infoline("Test that a child property does not exist on actor after parenting to container");
1527 TypeRegistry typeRegistry = TypeRegistry::Get();
1529 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1531 const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1532 const char* CHILD_PROPERTY_NAME("childProperty");
1534 ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1536 auto container = Test::TestCustomActor::New();
1537 application.GetScene().Add(container);
1538 auto child = Actor::New();
1539 container.Add(child); // Resolve child properties (if any)
1541 DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), false, TEST_LOCATION);
1545 int UtcDaliHandleDoesCustomPropertyExistP2(void)
1547 TestApplication application; // Needs type registry
1549 tet_infoline("Test that a child property exists after being set");
1550 TypeRegistry typeRegistry = TypeRegistry::Get();
1552 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1554 const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1555 const char* CHILD_PROPERTY_NAME("childProperty");
1557 ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1559 auto container = Test::TestCustomActor::New();
1560 application.GetScene().Add(container);
1561 auto child = Actor::New();
1562 container.Add(child); // Resolve child properties (if any)
1563 child.SetProperty(CHILD_PROPERTY, 2);
1565 DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1566 DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 2, TEST_LOCATION);
1570 int UtcDaliHandleDoesCustomPropertyExistP3(void)
1572 TestApplication application; // Needs type registry
1574 tet_infoline("Test that a child property is re-indexed after registration, and that it exists");
1575 TypeRegistry typeRegistry = TypeRegistry::Get();
1577 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1579 const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1580 const char* CHILD_PROPERTY_NAME("childProperty");
1582 ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1584 auto container = Test::TestCustomActor::New();
1585 application.GetScene().Add(container);
1586 auto child = Actor::New();
1587 child.RegisterProperty(CHILD_PROPERTY_NAME, Property::Value(3));
1588 container.Add(child); // Resolve child properties (if any)
1590 DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1591 DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 3, TEST_LOCATION);
1597 struct PropertySetSignalCheck
1599 PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
1600 : mSignalReceived(signalReceived),
1605 void operator()(Handle& handle, Property::Index index, Property::Value value)
1607 mSignalReceived = true;
1613 mSignalReceived = false;
1616 void CheckSignalReceived()
1618 if(!mSignalReceived)
1620 tet_printf("Expected Property Set signal was not received\n");
1621 tet_result(TET_FAIL);
1625 tet_result(TET_PASS);
1629 bool& mSignalReceived; // owned by individual tests
1630 Property::Value& mValue;
1635 int UtcDaliHandlePropertySetSignal01(void)
1637 TestApplication application;
1639 bool signalReceived(false);
1640 Property::Value value;
1641 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1643 tet_infoline("Test that setting a default property triggers a signal");
1645 auto actor = Actor::New();
1646 actor.PropertySetSignal().Connect(&application, propertySetCheck);
1648 actor.SetProperty(Actor::Property::POSITION, Vector3::XAXIS);
1649 propertySetCheck.CheckSignalReceived();
1654 int UtcDaliHandlePropertySetSignal02(void)
1656 TestApplication application;
1658 bool signalReceived(false);
1659 Property::Value value;
1660 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1662 tet_infoline("Test that setting a custom property triggers a signal");
1664 auto actor = Actor::New();
1665 actor.PropertySetSignal().Connect(&application, propertySetCheck);
1667 auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
1668 actor.SetProperty(propertyIndex, 5.0f);
1669 propertySetCheck.CheckSignalReceived();
1670 DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(5.0f), 0.001f, TEST_LOCATION);
1675 int UtcDaliHandlePropertySetSignal03(void)
1677 TestApplication application;
1678 TypeRegistry typeRegistry = TypeRegistry::Get();
1680 bool signalReceived(false);
1681 Property::Value value;
1682 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1684 tet_infoline("Test that setting a child property triggers a signal");
1686 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1688 const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1689 const char* CHILD_PROPERTY_NAME("childProperty");
1691 ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1693 auto container = Test::TestCustomActor::New();
1694 application.GetScene().Add(container);
1695 auto child = Actor::New();
1696 child.RegisterProperty(CHILD_PROPERTY_NAME, Property::Value(3));
1697 child.PropertySetSignal().Connect(&application, propertySetCheck);
1698 container.Add(child); // Resolve child properties (if any)
1700 DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1701 DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 3, TEST_LOCATION);
1703 child.SetProperty(CHILD_PROPERTY, 29);
1704 propertySetCheck.CheckSignalReceived();
1705 DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(29), TEST_LOCATION);
1709 int UtcDaliHandlePropertySetSignal04(void)
1711 TestApplication application;
1712 TypeRegistry typeRegistry = TypeRegistry::Get();
1714 bool signalReceived(false);
1715 Property::Value value;
1716 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1718 tet_infoline("Test that setting a property on a vanilla Object triggers a signal");
1720 constexpr Property::Index TEST_PROPERTY_KEY_INDEX = 1;
1721 const std::string TEST_PROPERTY_KEY_NAME = "testProperty";
1723 Handle vanillaObject = Handle::New();
1724 auto propertyIndex = vanillaObject.RegisterProperty(
1725 TEST_PROPERTY_KEY_INDEX,
1726 TEST_PROPERTY_KEY_NAME,
1729 vanillaObject.PropertySetSignal().Connect(&application, propertySetCheck);
1731 DALI_TEST_EQUALS(vanillaObject.DoesCustomPropertyExist(propertyIndex), true, TEST_LOCATION);
1732 DALI_TEST_EQUALS(vanillaObject.GetProperty<Vector4>(propertyIndex), Color::WHITE, 0.001f, TEST_LOCATION);
1734 vanillaObject[TEST_PROPERTY_KEY_NAME] = Color::RED;
1736 propertySetCheck.CheckSignalReceived();
1737 DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(Color::RED), 0.001f, TEST_LOCATION);
1738 DALI_TEST_VALUE_EQUALS(vanillaObject[propertyIndex], Property::Value(Color::RED), 0.001f, TEST_LOCATION);
1743 int UtcDaliHandlePropertySetProperties(void)
1745 TestApplication application;
1746 const Vector3 actorSize(10.0f, 20.0f, 30.0f);
1747 const Vector3 anchorPoint(1.0f, 0.5f, 0.0f);
1748 const Vector4 color(0.1f, 0.2, 0.3f, 0.4f);
1750 Handle handle = Actor::New();
1751 handle.SetProperties(
1753 {Actor::Property::SIZE, actorSize},
1754 {Actor::Property::ANCHOR_POINT, anchorPoint},
1756 {"invalid", Vector2::ZERO} // It should quietly ignore invalid data
1758 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SIZE).Get<Vector3>(), actorSize, TEST_LOCATION);
1759 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>(), anchorPoint, TEST_LOCATION);
1760 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR).Get<Vector4>(), color, TEST_LOCATION);
1765 int UtcDaliHandleTemplateNew01(void)
1767 TestApplication application;
1768 const Vector3 actorSize(10.0f, 20.0f, 30.0f);
1769 const Vector3 anchorPoint(1.0f, 0.5f, 0.0f);
1770 const Vector4 color(0.1f, 0.2, 0.3f, 0.4f);
1772 Handle handle = Handle::New<Actor>(
1774 {Actor::Property::SIZE, actorSize},
1775 {Actor::Property::ANCHOR_POINT, anchorPoint},
1777 {"invalid", Vector2::ZERO} // It should quietly ignore invalid data
1780 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SIZE).Get<Vector3>(), actorSize, TEST_LOCATION);
1781 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>(), anchorPoint, TEST_LOCATION);
1782 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR).Get<Vector4>(), color, TEST_LOCATION);
1787 int UtcDaliHandleGetProperties(void)
1789 TestApplication application;
1791 Handle handle = Actor::New();
1792 handle.SetProperties(
1794 {Actor::Property::SIZE, Vector3(400.0f, 200.0f, 100.0f)},
1795 {Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER},
1796 {Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER},
1797 {Actor::Property::NAME, "Actor"},
1798 {Actor::Property::LEAVE_REQUIRED, true},
1799 {"color", Color::RED},
1803 handle.GetProperties(map);
1805 // Get all the properties and ensure they match
1807 DALI_TEST_EQUALS(handle.GetPropertyCount(), map.Count(), TEST_LOCATION);
1809 for(auto position = 0u; position < map.Count(); ++position)
1811 auto keyValuePair = map.GetKeyValue(position);
1812 const auto& index = keyValuePair.first.indexKey;
1813 const auto& value = keyValuePair.second;
1814 auto handleValue = handle.GetProperty(index);
1816 switch(value.GetType())
1818 case Property::NONE:
1820 case Property::BOOLEAN:
1821 DALI_TEST_EQUALS(value.Get<bool>(), handleValue.Get<bool>(), TEST_LOCATION);
1823 case Property::FLOAT:
1824 DALI_TEST_EQUALS(value.Get<float>(), handleValue.Get<float>(), TEST_LOCATION);
1826 case Property::INTEGER:
1827 DALI_TEST_EQUALS(value.Get<int>(), handleValue.Get<int>(), TEST_LOCATION);
1829 case Property::VECTOR2:
1830 DALI_TEST_EQUALS(value.Get<Vector2>(), handleValue.Get<Vector2>(), TEST_LOCATION);
1832 case Property::VECTOR3:
1833 DALI_TEST_EQUALS(value.Get<Vector3>(), handleValue.Get<Vector3>(), TEST_LOCATION);
1835 case Property::VECTOR4:
1836 DALI_TEST_EQUALS(value.Get<Vector4>(), handleValue.Get<Vector4>(), TEST_LOCATION);
1838 case Property::MATRIX3:
1839 DALI_TEST_EQUALS(value.Get<Matrix3>(), handleValue.Get<Matrix3>(), TEST_LOCATION);
1841 case Property::MATRIX:
1842 DALI_TEST_EQUALS(value.Get<Matrix>(), handleValue.Get<Matrix>(), TEST_LOCATION);
1844 case Property::RECTANGLE:
1845 DALI_TEST_EQUALS(value.Get<Rect<int> >(), handleValue.Get<Rect<int> >(), TEST_LOCATION);
1847 case Property::ROTATION:
1848 DALI_TEST_EQUALS(value.Get<Quaternion>(), handleValue.Get<Quaternion>(), TEST_LOCATION);
1850 case Property::STRING:
1851 DALI_TEST_EQUALS(value.Get<std::string>(), handleValue.Get<std::string>(), TEST_LOCATION);
1853 case Property::ARRAY:
1854 DALI_TEST_EQUALS(value.GetArray()->Count(), handleValue.GetArray()->Count(), TEST_LOCATION);
1857 DALI_TEST_EQUALS(value.GetMap()->Count(), handleValue.GetMap()->Count(), TEST_LOCATION);
1859 case Property::EXTENTS:
1860 DALI_TEST_EQUALS(value.Get<Extents>(), handleValue.Get<Extents>(), TEST_LOCATION);
1865 // Add a custom property and ensure the count goes up by one.
1866 const auto countBefore = map.Count();
1867 handle.RegisterProperty("tempProperty", Color::GREEN);
1868 handle.GetProperties(map);
1869 DALI_TEST_EQUALS(countBefore + 1, map.Count(), TEST_LOCATION);
1874 int UtcDaliHandleSetPropertyNegative(void)
1876 TestApplication application;
1877 Dali::Handle instance;
1881 Dali::Property::Value arg2;
1882 instance.SetProperty(arg1, arg2);
1883 DALI_TEST_CHECK(false); // Should not get here
1887 DALI_TEST_CHECK(true); // We expect an assert
1892 int UtcDaliHandleRegisterPropertyNegative01(void)
1894 TestApplication application;
1895 Dali::Handle instance;
1899 Dali::Property::Value arg2;
1900 instance.RegisterProperty(arg1, arg2);
1901 DALI_TEST_CHECK(false); // Should not get here
1905 DALI_TEST_CHECK(true); // We expect an assert
1910 int UtcDaliHandleRegisterPropertyNegative02(void)
1912 TestApplication application;
1913 Dali::Handle instance;
1917 Dali::Property::Value arg2;
1918 Dali::Property::AccessMode arg3(Property::READ_ONLY);
1919 instance.RegisterProperty(arg1, arg2, arg3);
1920 DALI_TEST_CHECK(false); // Should not get here
1924 DALI_TEST_CHECK(true); // We expect an assert
1929 int UtcDaliHandleRemoveConstraintsNegative01(void)
1931 TestApplication application;
1932 Dali::Handle instance;
1935 unsigned int arg1(0u);
1936 instance.RemoveConstraints(arg1);
1937 DALI_TEST_CHECK(false); // Should not get here
1941 DALI_TEST_CHECK(true); // We expect an assert
1946 int UtcDaliHandleRemoveConstraintsNegative02(void)
1948 TestApplication application;
1949 Dali::Handle instance;
1952 instance.RemoveConstraints();
1953 DALI_TEST_CHECK(false); // Should not get here
1957 DALI_TEST_CHECK(true); // We expect an assert
1962 int UtcDaliHandleAddPropertyNotificationNegative01(void)
1964 TestApplication application;
1965 Dali::Handle instance;
1970 Dali::PropertyCondition arg3;
1971 instance.AddPropertyNotification(arg1, arg2, arg3);
1972 DALI_TEST_CHECK(false); // Should not get here
1976 DALI_TEST_CHECK(true); // We expect an assert
1981 int UtcDaliHandleAddPropertyNotificationNegative02(void)
1983 TestApplication application;
1984 Dali::Handle instance;
1988 Dali::PropertyCondition arg2;
1989 instance.AddPropertyNotification(arg1, arg2);
1990 DALI_TEST_CHECK(false); // Should not get here
1994 DALI_TEST_CHECK(true); // We expect an assert
1999 int UtcDaliHandleRemovePropertyNotificationNegative(void)
2001 TestApplication application;
2002 Dali::Handle instance;
2005 Dali::PropertyNotification arg1;
2006 instance.RemovePropertyNotification(arg1);
2007 DALI_TEST_CHECK(false); // Should not get here
2011 DALI_TEST_CHECK(true); // We expect an assert
2016 int UtcDaliHandleRemovePropertyNotificationsNegative(void)
2018 TestApplication application;
2019 Dali::Handle instance;
2022 instance.RemovePropertyNotifications();
2023 DALI_TEST_CHECK(false); // Should not get here
2027 DALI_TEST_CHECK(true); // We expect an assert
2032 int UtcDaliHandleGetPropertyNegative(void)
2034 TestApplication application;
2035 Dali::Handle instance;
2039 instance.GetProperty(arg1);
2040 DALI_TEST_CHECK(false); // Should not get here
2044 DALI_TEST_CHECK(true); // We expect an assert
2049 int UtcDaliHandleGetPropertyNameNegative(void)
2051 TestApplication application;
2052 Dali::Handle instance;
2056 instance.GetPropertyName(arg1);
2057 DALI_TEST_CHECK(false); // Should not get here
2061 DALI_TEST_CHECK(true); // We expect an assert
2066 int UtcDaliHandleGetPropertyTypeNegative(void)
2068 TestApplication application;
2069 Dali::Handle instance;
2073 instance.GetPropertyType(arg1);
2074 DALI_TEST_CHECK(false); // Should not get here
2078 DALI_TEST_CHECK(true); // We expect an assert
2083 int UtcDaliHandleGetPropertyCountNegative(void)
2085 TestApplication application;
2086 Dali::Handle instance;
2089 instance.GetPropertyCount();
2090 DALI_TEST_CHECK(false); // Should not get here
2094 DALI_TEST_CHECK(true); // We expect an assert
2099 int UtcDaliHandleGetPropertyIndexNegative(void)
2101 TestApplication application;
2102 Dali::Handle instance;
2106 instance.GetPropertyIndex(arg1);
2107 DALI_TEST_CHECK(false); // Should not get here
2111 DALI_TEST_CHECK(true); // We expect an assert
2116 int UtcDaliHandleGetCurrentPropertyNegative(void)
2118 TestApplication application;
2119 Dali::Handle instance;
2123 instance.GetCurrentProperty(arg1);
2124 DALI_TEST_CHECK(false); // Should not get here
2128 DALI_TEST_CHECK(true); // We expect an assert
2133 int UtcDaliHandleGetPropertyIndicesNegative(void)
2135 TestApplication application;
2136 Dali::Handle instance;
2139 Dali::Vector<int> arg1;
2140 instance.GetPropertyIndices(arg1);
2141 DALI_TEST_CHECK(false); // Should not get here
2145 DALI_TEST_CHECK(true); // We expect an assert
2150 int UtcDaliHandleIsPropertyWritableNegative(void)
2152 TestApplication application;
2153 Dali::Handle instance;
2157 instance.IsPropertyWritable(arg1);
2158 DALI_TEST_CHECK(false); // Should not get here
2162 DALI_TEST_CHECK(true); // We expect an assert
2167 int UtcDaliHandleIsPropertyAnimatableNegative(void)
2169 TestApplication application;
2170 Dali::Handle instance;
2174 instance.IsPropertyAnimatable(arg1);
2175 DALI_TEST_CHECK(false); // Should not get here
2179 DALI_TEST_CHECK(true); // We expect an assert
2184 int UtcDaliHandleIsPropertyAConstraintInputNegative(void)
2186 TestApplication application;
2187 Dali::Handle instance;
2191 instance.IsPropertyAConstraintInput(arg1);
2192 DALI_TEST_CHECK(false); // Should not get here
2196 DALI_TEST_CHECK(true); // We expect an assert
2201 int UtcDaliHandleSupportsNegative(void)
2203 TestApplication application;
2204 Dali::Handle instance;
2207 Dali::Handle::Capability arg1(Handle::DYNAMIC_PROPERTIES);
2208 instance.Supports(arg1);
2209 DALI_TEST_CHECK(false); // Should not get here
2213 DALI_TEST_CHECK(true); // We expect an assert
2218 int UtcDaliHandleIndexOperatorByIndexP01(void)
2220 TestApplication application;
2221 Actor actor = Actor::New();
2223 actor[Actor::Property::SIZE] = Vector3(100.0f, 200.0f, 1.0f);
2225 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(100.0f, 200.0f, 1.0f), 0.001f, TEST_LOCATION);
2227 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2229 Vector3 position = actor[Actor::Property::POSITION];
2230 DALI_TEST_EQUALS(position, Vector3(10.0f, 20.0f, 0.0f), TEST_LOCATION);
2235 int UtcDaliHandleIndexOperatorByIndexP02(void)
2237 TestApplication application;
2238 Actor actor = Actor::New();
2240 const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2241 actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2242 actor[Actor::Property::COLOR_RED] = 0.5f;
2244 DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.001f, TEST_LOCATION);
2245 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(Actor::Property::COLOR), Vector4(0.5f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
2247 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2249 DALI_TEST_EQUALS((float)actor[Actor::Property::POSITION_Z], 0.0f, 0.001f, TEST_LOCATION);
2254 int UtcDaliHandleIndexOperatorByIndexP03(void)
2256 TestApplication application;
2257 Actor actor = Actor::New();
2259 const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2260 actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2262 // Value under test is second to allow compiler to deduce type
2263 DALI_TEST_VALUE_EQUALS(actor[Actor::Property::COLOR_RED], 1.0f, 0.001f, TEST_LOCATION);
2265 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2267 DALI_TEST_EQUALS((float)actor[Actor::Property::POSITION_Z], 0.0f, 0.001f, TEST_LOCATION);
2272 int UtcDaliHandleIndexOperatorByNameP01(void)
2274 TestApplication application;
2275 Actor actor = Actor::New();
2277 actor["size"] = Vector3(100.0f, 200.0f, 1.0f);
2279 DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::SIZE), Vector3(100.0f, 200.0f, 1.0f), 0.001f, TEST_LOCATION);
2281 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2282 Vector3 position = actor["position"];
2284 DALI_TEST_EQUALS(position, Vector3(10.0f, 20.0f, 0.0f), 0.001f, TEST_LOCATION);
2289 int UtcDaliHandleIndexOperatorByNameP02(void)
2291 TestApplication application;
2292 Actor actor = Actor::New();
2294 const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2295 actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2296 actor["colorRed"] = 0.5f;
2298 DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::COLOR_RED), 0.5f, 0.001f, TEST_LOCATION);
2299 DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::COLOR), Vector4(0.5f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
2301 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2303 float positionY = actor["positionY"];
2304 DALI_TEST_EQUALS(positionY, 20.0f, 0.001f, TEST_LOCATION);
2306 // Should automatically promote IndirectValue to Property::Value rvalue.
2307 DALI_TEST_VALUE_EQUALS(actor["positionZ"], 0.0f, 0.001f, TEST_LOCATION);
2312 int UtcDaliHandleIndexOperatorNegative02(void)
2314 TestApplication application;
2319 Vector3 position = actor[Actor::Property::POSITION];
2320 if(position == position)
2322 DALI_TEST_CHECK(false); // Should throw before reaching here.
2324 DALI_TEST_CHECK(false); // Should throw before reaching here.
2328 DALI_TEST_CHECK(true); // Assert expected