2 * Copyright (c) 2022 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 UtcDaliHandleRegisterProperty03(void)
777 tet_infoline("Test Dali::Handle::RegisterUniqueProperty() int key against default property");
778 TestApplication application;
780 Integration::Scene stage = application.GetScene();
782 Actor actor = Actor::New();
785 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
787 application.SendNotification();
788 application.Render();
790 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
791 actor.SetProperty(Actor::Property::COLOR, testColor);
793 application.SendNotification();
794 application.Render();
796 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount, TEST_LOCATION);
798 // No uniqueness tests are done on the properties. Check that the indices are different
800 Property::Index key = CORE_PROPERTY_MAX_INDEX + 1;
801 Property::Index testIndex = actor.RegisterUniqueProperty(key, "color", Color::BLACK);
803 application.SendNotification();
804 application.Render();
806 DALI_TEST_EQUALS(testIndex != Actor::Property::COLOR, true, TEST_LOCATION);
807 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 1, TEST_LOCATION); // Property count should be different
809 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(Actor::Property::COLOR), testColor, TEST_LOCATION); // Value should not have changed
810 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(testIndex), Color::BLACK, TEST_LOCATION); // Value should not have changed
812 // Check that name lookup returns the default property
813 DALI_TEST_EQUALS((int)actor.GetPropertyIndex(Property::Key("color")), (int)Actor::Property::COLOR, TEST_LOCATION);
815 // Check that they have different scene graph properties
816 DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::COLOR), Property::Value(testColor), 0.0001f, TEST_LOCATION);
817 DALI_TEST_EQUALS(actor.GetCurrentProperty(testIndex), Property::Value(Color::BLACK), 0.0001f, TEST_LOCATION);
822 int UtcDaliHandleRegisterProperty04(void)
824 tet_infoline("Negative Test Dali::Handle::RegisterUniqueProperty() same int key against custom property");
825 TestApplication application;
827 Integration::Scene stage = application.GetScene();
829 Actor actor = Actor::New();
832 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
834 application.SendNotification();
835 application.Render();
837 Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
838 Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
840 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
841 const float withFlake(99.f);
843 Property::Index index1 = actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
844 Property::Index index2 = actor.RegisterUniqueProperty(key1, "sideColor", testColor);
845 Property::Index index3 = actor.RegisterUniqueProperty(key2, "iceCream", withFlake);
847 application.SendNotification();
848 application.Render();
850 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION);
851 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index1), Vector3::ONE, TEST_LOCATION);
852 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), testColor, TEST_LOCATION);
853 DALI_TEST_EQUALS(actor.GetProperty<float>(index3), withFlake, TEST_LOCATION);
855 // If property key matches, ignore new name.
856 Property::Index testIndex2 = actor.RegisterUniqueProperty(key1, "sideColor", Color::BLACK);
857 Property::Index testIndex3 = actor.RegisterUniqueProperty(key2, "iceCream", 2200.f);
858 application.SendNotification();
859 application.Render();
861 DALI_TEST_EQUALS(index2 == testIndex2, true, TEST_LOCATION);
862 DALI_TEST_EQUALS(index3 == testIndex3, true, TEST_LOCATION);
863 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION); // Property count should be same
864 // Test that the value has actually been updated
865 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), Color::BLACK, TEST_LOCATION);
866 DALI_TEST_EQUALS(actor.GetProperty<float>(index3), 2200.f, TEST_LOCATION);
868 // Check that name lookup returns the first registered property
869 DALI_TEST_EQUALS(actor.GetPropertyIndex(Property::Key("sideColor")), index2, TEST_LOCATION);
870 DALI_TEST_EQUALS(actor.GetPropertyIndex(Property::Key("iceCream")), index3, TEST_LOCATION);
875 int UtcDaliHandleRegisterProperty05(void)
877 tet_infoline("Positive Test Dali::Handle::RegisterUniqueProperty() different int key against custom property");
878 TestApplication application;
880 Integration::Scene stage = application.GetScene();
882 Actor actor = Actor::New();
885 const unsigned int defaultPropertyCount = actor.GetPropertyCount();
887 application.SendNotification();
888 application.Render();
890 Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
891 Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
893 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
894 const float withFlake(99.f);
896 Property::Index index1 = actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
897 Property::Index index2 = actor.RegisterUniqueProperty(key1, "sideColor", testColor);
898 Property::Index index3 = actor.RegisterUniqueProperty(key2, "iceCream", withFlake);
900 application.SendNotification();
901 application.Render();
903 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 3, TEST_LOCATION);
904 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(index1), Vector3::ONE, TEST_LOCATION);
905 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), testColor, TEST_LOCATION);
906 DALI_TEST_EQUALS(actor.GetProperty<float>(index3), withFlake, TEST_LOCATION);
908 // No uniqueness tests are done on the names. Check that the indices are different if the keys are different
909 Property::Index newKey1 = key2 + 1;
910 Property::Index newKey2 = key2 + 2;
912 Property::Index testIndex2 = actor.RegisterUniqueProperty(newKey1, "sideColor", Color::BLACK);
913 Property::Index testIndex3 = actor.RegisterUniqueProperty(newKey2, "iceCream", 2200.f);
914 application.SendNotification();
915 application.Render();
917 DALI_TEST_EQUALS(index2 == testIndex2, false, TEST_LOCATION);
918 DALI_TEST_EQUALS(index3 == testIndex3, false, TEST_LOCATION);
919 DALI_TEST_EQUALS(actor.GetPropertyCount(), defaultPropertyCount + 5, TEST_LOCATION); // Property count should be different
921 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(index2), testColor, TEST_LOCATION); // Value should not have changed
922 DALI_TEST_EQUALS(actor.GetProperty<float>(index3), withFlake, TEST_LOCATION);
924 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(testIndex2), Color::BLACK, TEST_LOCATION); // Value should not have changed
925 DALI_TEST_EQUALS(actor.GetProperty<float>(testIndex3), 2200.f, TEST_LOCATION);
927 // Check that name lookup returns the first registered property
928 DALI_TEST_EQUALS(actor.GetPropertyIndex(Property::Key("sideColor")), index2, TEST_LOCATION);
929 DALI_TEST_EQUALS(actor.GetPropertyIndex(Property::Key("iceCream")), index3, TEST_LOCATION);
934 int UtcDaliHandleGetProperty(void)
936 tet_infoline("Positive Test Dali::Handle::GetProperty()");
937 TestApplication application;
939 Actor actor = Actor::New();
941 DALI_TEST_CHECK(ParentOrigin::TOP_LEFT == actor.GetProperty(Actor::Property::PARENT_ORIGIN).Get<Vector3>());
942 DALI_TEST_CHECK(AnchorPoint::CENTER == actor.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>());
943 DALI_TEST_CHECK(Vector3::ZERO == actor.GetProperty(Actor::Property::SIZE).Get<Vector3>());
944 DALI_TEST_CHECK(Vector3::ZERO == actor.GetProperty(Actor::Property::POSITION).Get<Vector3>());
945 DALI_TEST_CHECK(Vector3::ONE == actor.GetProperty(Actor::Property::SCALE).Get<Vector3>());
946 DALI_TEST_CHECK(true == actor.GetProperty(Actor::Property::VISIBLE).Get<bool>());
947 DALI_TEST_CHECK(Color::WHITE == actor.GetProperty(Actor::Property::COLOR).Get<Vector4>());
951 int UtcDaliHandleDownCast(void)
953 TestApplication application;
954 tet_infoline("Testing Dali::Handle::DownCast()");
956 Actor actor = Actor::New();
958 BaseHandle baseHandle = actor;
960 Handle handle = Handle::DownCast(baseHandle);
962 DALI_TEST_CHECK(handle);
964 baseHandle = BaseHandle();
966 handle = Handle::DownCast(baseHandle);
968 DALI_TEST_CHECK(!handle);
973 int UtcDaliHandleDownCastNegative(void)
975 TestApplication application;
977 // BaseObject is NOT an Object, so this DownCast should fail
978 BaseHandle handle(new BaseObjectType);
979 Handle customHandle1 = Handle::DownCast(handle);
980 DALI_TEST_CHECK(!customHandle1);
982 // A DownCast on an empty handle will also fail
984 Handle customHandle2 = Handle::DownCast(empty);
985 DALI_TEST_CHECK(!customHandle2);
989 int UtcDaliHandleGetPropertyIndices(void)
991 TestApplication application;
992 Property::IndexContainer indices;
995 Actor actor = Actor::New();
996 actor.GetPropertyIndices(indices);
997 int numDefaultProperties = indices.Size();
998 DALI_TEST_CHECK(numDefaultProperties > 0);
999 DALI_TEST_EQUALS(numDefaultProperties, actor.GetPropertyCount(), TEST_LOCATION);
1001 const Vector4 testColor(0.5f, 0.2f, 0.9f, 1.0f);
1002 const float withFlake(99.f);
1004 Property::Index key1 = CORE_PROPERTY_MAX_INDEX + 1;
1005 Property::Index key2 = CORE_PROPERTY_MAX_INDEX + 2;
1007 actor.RegisterProperty("MyPropertyOne", Vector3::ONE);
1008 actor.RegisterProperty(key1, "sideColor", testColor);
1009 actor.RegisterProperty("MyPropertyTwo", 1234);
1010 Property::Index index4 = actor.RegisterProperty(key2, "iceCream", withFlake);
1011 actor.RegisterProperty("MyPropertyThree", Vector2(.2f, .7f));
1013 actor.GetPropertyIndices(indices);
1015 DALI_TEST_EQUALS(indices.Size(), numDefaultProperties + 5, TEST_LOCATION);
1016 DALI_TEST_EQUALS(indices[indices.Size() - 2], index4, TEST_LOCATION);
1021 int UtcDaliHandleRegisterPropertyTypes(void)
1023 TestApplication application;
1025 struct PropertyTypeAnimatable
1028 Property::Value value;
1032 Property::Array array;
1035 PropertyTypeAnimatable properties[] =
1037 {"Property::BOOLEAN", true, true},
1038 {"Property::FLOAT", 1.0f, true},
1039 {"Property::INTEGER", 1, true},
1040 {"Property::VECTOR2", Vector2::ONE, true},
1041 {"Property::VECTOR3", Vector3::ONE, true},
1042 {"Property::VECTOR4", Vector4::ONE, true},
1043 {"Property::MATRIX3", Matrix3::IDENTITY, true},
1044 {"Property::MATRIX", Matrix::IDENTITY, true},
1045 {"Property::RECTANGLE", Rect<int>(), false},
1046 {"Property::ROTATION", AngleAxis(), true},
1047 {"Property::STRING", std::string("Me"), false},
1048 {"Property::ARRAY", array, false},
1049 {"Property::MAP", map, false},
1052 unsigned int numOfProperties(sizeof(properties) / sizeof(properties[0]));
1054 for(unsigned int i = 0; i < numOfProperties; ++i)
1056 tet_printf("Testing: %s\n", properties[i].name);
1058 bool exception = false;
1061 Actor actor = Actor::New();
1062 actor.RegisterProperty("manFromDelmonte", properties[i].value);
1064 catch(Dali::DaliException& e)
1069 DALI_TEST_CHECK(properties[i].animatable != exception);
1074 int UtcDaliHandleCustomProperty(void)
1076 TestApplication application;
1078 Handle handle = Handle::New();
1080 float startValue(1.0f);
1081 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1082 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1084 application.SendNotification();
1085 application.Render(0);
1086 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1087 application.Render(0);
1088 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1090 handle.SetProperty(index, 5.0f);
1092 application.SendNotification();
1093 application.Render(0);
1094 DALI_TEST_CHECK(handle.GetProperty<float>(index) == 5.0f);
1095 application.Render(0);
1096 DALI_TEST_CHECK(handle.GetProperty<float>(index) == 5.0f);
1100 int UtcDaliHandleCustomPropertyNone(void)
1102 TestApplication application;
1104 Handle handle = Handle::New();
1106 Property::Value value(Property::NONE);
1107 Property::Index index = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1109 // Negative test i.e. setting a property of type NONE is meaningless
1110 handle.SetProperty(index, 5.0f);
1112 DALI_TEST_CHECK(true); // got here without crashing
1117 int UtcDaliHandleCustomPropertyIntToFloat(void)
1119 TestApplication application;
1121 Handle handle = Handle::New();
1123 float startValue(5.0f);
1124 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1125 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1127 application.SendNotification();
1128 application.Render(0);
1129 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1131 handle.SetProperty(index, int(1));
1133 application.SendNotification();
1134 application.Render(0);
1135 DALI_TEST_CHECK(handle.GetProperty<float>(index) == 1.0f);
1139 int UtcDaliHandleCustomPropertyFloatToInt(void)
1141 TestApplication application;
1143 Handle handle = Handle::New();
1146 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1147 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1149 application.SendNotification();
1150 application.Render(0);
1151 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1153 handle.SetProperty(index, float(1.5));
1155 application.SendNotification();
1156 application.Render(0);
1157 DALI_TEST_CHECK(handle.GetProperty<int>(index) == 1);
1161 int UtcDaliHandleCustomPropertyInvalidToRect(void)
1163 TestApplication application;
1165 Handle handle = Handle::New();
1167 Rect<int> startValue(1, 2, 3, 4);
1168 Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1169 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1171 application.SendNotification();
1172 application.Render(0);
1173 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1175 // Negative test i.e. there is no conversion from float to Rect
1176 handle.SetProperty(index, float(1.5));
1178 application.SendNotification();
1179 application.Render(0);
1180 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), startValue, TEST_LOCATION);
1182 // Positive test (sanity check)
1183 Rect<int> endValue(5, 6, 7, 8);
1184 handle.SetProperty(index, endValue);
1185 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), endValue, TEST_LOCATION);
1187 application.SendNotification();
1188 application.Render(0);
1189 DALI_TEST_EQUALS(handle.GetProperty<Rect<int> >(index), endValue, TEST_LOCATION);
1194 int UtcDaliHandleCustomPropertyInvalidToString(void)
1196 TestApplication application;
1198 Handle handle = Handle::New();
1200 std::string startValue("Libraries gave us power");
1201 Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1202 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1204 application.SendNotification();
1205 application.Render(0);
1206 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1208 // No conversion from Vector3 to std::string, therefore this should be a NOOP
1209 handle.SetProperty(index, Vector3(1, 2, 3));
1211 application.SendNotification();
1212 application.Render(0);
1213 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), startValue, TEST_LOCATION);
1215 // Positive test (sanity check)
1216 std::string endValue("Then work came and made us free");
1217 handle.SetProperty(index, endValue);
1218 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), endValue, TEST_LOCATION);
1220 application.SendNotification();
1221 application.Render(0);
1222 DALI_TEST_EQUALS(handle.GetProperty<std::string>(index), endValue, TEST_LOCATION);
1227 int UtcDaliHandleCustomPropertyInvalidToArray(void)
1229 TestApplication application;
1231 Handle handle = Handle::New();
1233 Property::Value value(Property::ARRAY);
1234 std::string startValue("The future teaches you to be alone");
1235 value.GetArray()->PushBack(startValue);
1237 Property::Index index = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1238 Property::Array check1 = handle.GetProperty<Property::Array>(index);
1239 DALI_TEST_EQUALS(check1.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1241 application.SendNotification();
1242 application.Render(0);
1243 Property::Array check2 = handle.GetProperty<Property::Array>(index);
1244 DALI_TEST_EQUALS(check2.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1246 // No conversion from int to ARRAY, therefore this should be a NOOP
1247 handle.SetProperty(index, int(2));
1249 application.SendNotification();
1250 application.Render(0);
1251 Property::Array check3 = handle.GetProperty<Property::Array>(index);
1252 DALI_TEST_EQUALS(check3.GetElementAt(0).Get<std::string>(), startValue, TEST_LOCATION);
1254 // Positive test (sanity check)
1255 Property::Value value2(Property::ARRAY);
1256 std::string endValue("The present to be afraid and cold");
1257 value2.GetArray()->PushBack(endValue);
1258 handle.SetProperty(index, value2);
1260 Property::Array check4 = handle.GetProperty<Property::Array>(index);
1261 DALI_TEST_EQUALS(check4.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION);
1263 application.SendNotification();
1264 application.Render(0);
1265 Property::Array check5 = handle.GetProperty<Property::Array>(index);
1266 DALI_TEST_EQUALS(check5.GetElementAt(0).Get<std::string>(), endValue, TEST_LOCATION);
1271 int UtcDaliHandleCustomPropertyInvalidToMap(void)
1273 TestApplication application;
1275 Handle handle = Handle::New();
1277 Property::Value value(Property::MAP);
1278 std::string startValue("Culture sucks down words");
1279 value.GetMap()->Insert("1", startValue);
1281 Property::Index index = handle.RegisterProperty("testProperty", value, Property::READ_WRITE);
1282 Property::Value* check1 = handle.GetProperty<Property::Map>(index).Find("1");
1283 DALI_TEST_CHECK(NULL != check1);
1285 // No conversion from float to MAP, therefore this should be a NOOP
1286 handle.SetProperty(index, float(3.0));
1288 // Positive test (sanity check)
1289 Property::Value value2(Property::MAP);
1290 std::string endValue("Itemise loathing and feed yourself smiles");
1291 value.GetMap()->Insert("1", endValue);
1292 handle.SetProperty(index, value2);
1297 int UtcDaliHandleCustomPropertyInvalidToExtents(void)
1299 TestApplication application;
1301 Handle handle = Handle::New();
1303 Extents startValue(1, 2, 3, 4);
1304 Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1305 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1307 application.SendNotification();
1308 application.Render(0);
1309 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1311 // Negative test i.e. there is no conversion from float to Extents
1312 handle.SetProperty(index, float(1.5));
1314 application.SendNotification();
1315 application.Render(0);
1316 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), startValue, TEST_LOCATION);
1318 // Positive test (sanity check)
1319 Extents endValue(5, 6, 7, 8);
1320 handle.SetProperty(index, endValue);
1321 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), endValue, TEST_LOCATION);
1323 application.SendNotification();
1324 application.Render(0);
1325 DALI_TEST_EQUALS(handle.GetProperty<Extents>(index), endValue, TEST_LOCATION);
1330 int UtcDaliHandleCustomPropertyInvalidToBool(void)
1332 TestApplication application;
1334 Handle handle = Handle::New();
1336 bool startValue(true);
1337 Property::Index index = handle.RegisterProperty("testProperty", startValue, Property::READ_WRITE);
1338 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1340 application.SendNotification();
1341 application.Render(0);
1342 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1344 // Negative test i.e. there is no conversion from float to bool
1345 handle.SetProperty(index, float(0.0));
1347 application.SendNotification();
1348 application.Render(0);
1349 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), startValue, TEST_LOCATION);
1351 // Positive test (sanity check)
1352 bool endValue(false);
1353 handle.SetProperty(index, endValue);
1354 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), endValue, TEST_LOCATION);
1356 application.SendNotification();
1357 application.Render(0);
1358 DALI_TEST_EQUALS(handle.GetProperty<bool>(index), endValue, TEST_LOCATION);
1363 int UtcDaliHandleCustomPropertyInvalidToInt(void)
1365 TestApplication application;
1367 Handle handle = Handle::New();
1370 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1371 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1373 application.SendNotification();
1374 application.Render(0);
1375 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1377 // Negative test i.e. there is no conversion from Vector3 to int
1378 handle.SetProperty(index, Vector3(1, 2, 3));
1380 application.SendNotification();
1381 application.Render(0);
1382 DALI_TEST_CHECK(handle.GetProperty<int>(index) == startValue);
1386 int UtcDaliHandleCustomPropertyInvalidToFloat(void)
1388 TestApplication application;
1390 Handle handle = Handle::New();
1392 float startValue(5.0);
1393 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1394 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1396 application.SendNotification();
1397 application.Render(0);
1398 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1400 // Negative test i.e. there is no conversion from Vector3 to float
1401 handle.SetProperty(index, Vector3(1, 2, 3));
1403 application.SendNotification();
1404 application.Render(0);
1405 DALI_TEST_CHECK(handle.GetProperty<float>(index) == startValue);
1409 int UtcDaliHandleCustomPropertyInvalidToRotation(void)
1411 TestApplication application;
1413 Handle handle = Handle::New();
1415 Quaternion startValue(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1416 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1417 DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1419 application.SendNotification();
1420 application.Render(0);
1421 DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1423 // Negative test i.e. there is no conversion from float to Quaternion
1424 handle.SetProperty(index, float(7.0));
1426 application.SendNotification();
1427 application.Render(0);
1428 DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == startValue);
1430 // Positive test (sanity check)
1431 Quaternion endValue(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1432 handle.SetProperty(index, endValue);
1433 DALI_TEST_CHECK(handle.GetProperty<Quaternion>(index) == endValue);
1438 int UtcDaliHandleCustomPropertyInvalidToMatrix(void)
1440 TestApplication application;
1442 Handle handle = Handle::New();
1444 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1445 Matrix startValue(rotation);
1446 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1447 DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1449 application.SendNotification();
1450 application.Render(0);
1451 DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1453 // Negative test i.e. there is no conversion from float to Matrix
1454 handle.SetProperty(index, float(7.0));
1456 application.SendNotification();
1457 application.Render(0);
1458 DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == startValue);
1460 // Positive test (sanity check)
1461 Quaternion endRotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1462 Matrix endValue(endRotation);
1463 handle.SetProperty(index, endValue);
1464 DALI_TEST_CHECK(handle.GetProperty<Matrix>(index) == endValue);
1469 int UtcDaliHandleCustomPropertyInvalidToMatrix3(void)
1471 TestApplication application;
1473 Handle handle = Handle::New();
1475 Matrix3 startValue(11, 12, 13, 21, 22, 23, 31, 32, 33);
1477 Property::Index index = handle.RegisterProperty("testProperty", startValue);
1478 DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1480 application.SendNotification();
1481 application.Render(0);
1482 DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1484 // Negative test i.e. there is no conversion from float to Matrix3
1485 handle.SetProperty(index, float(7.0));
1487 application.SendNotification();
1488 application.Render(0);
1489 DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == startValue);
1491 // Positive test (sanity check)
1492 Matrix3 endValue(31, 32, 33, 21, 22, 23, 11, 12, 13);
1493 handle.SetProperty(index, endValue);
1494 DALI_TEST_CHECK(handle.GetProperty<Matrix3>(index) == endValue);
1499 int UtcDaliHandleWeightNew(void)
1501 TestApplication application;
1503 Handle handle = WeightObject::New();
1504 DALI_TEST_CHECK(handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f);
1506 // process the message so scene object is added to update manager
1507 application.SendNotification();
1508 application.Render(0);
1510 // no message to release scene object in this scenario
1515 int UtcDaliHandleWeightNew2(void)
1517 TestApplication application;
1519 // scope for the weight object
1521 Handle handle = WeightObject::New();
1522 DALI_TEST_CHECK(handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f);
1524 // process the message so scene object is added to update manager
1525 application.SendNotification();
1526 application.Render(0);
1528 // handle out of scope so object gets destroyed
1529 // process the message so update manager destroys the scene object
1530 application.SendNotification();
1531 application.Render(0);
1536 int UtcDaliHandleSetTypeInfo(void)
1538 TestApplication application;
1539 TypeRegistry typeRegistry = TypeRegistry::Get();
1541 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Actor");
1542 DALI_TEST_CHECK(typeInfo);
1544 Actor actor = Actor::DownCast(typeInfo.CreateInstance());
1545 DALI_TEST_CHECK(actor);
1547 DevelHandle::SetTypeInfo(actor, typeInfo);
1549 TypeInfo newTypeInfo;
1550 bool success = actor.GetTypeInfo(newTypeInfo);
1551 DALI_TEST_CHECK(success);
1553 DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
1554 DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
1559 int UtcDaliHandleCustomPropertySynchronousGetSet(void)
1561 TestApplication application;
1563 tet_infoline("Create a custom property and set the value ensuring it can be retrieved synchronously");
1565 Actor actor = Actor::New();
1566 application.GetScene().Add(actor);
1568 tet_infoline("Create the custom property with an initial value");
1569 float startValue(1.0f);
1570 Property::Index index = actor.RegisterProperty("testProperty", startValue);
1571 DALI_TEST_EQUALS(actor.GetProperty<float>(index), startValue, TEST_LOCATION);
1573 tet_infoline("Set the value, retrieve it and ensure both the synchronous and the async version work");
1574 actor.SetProperty(index, 5.0f);
1575 DALI_TEST_EQUALS(actor.GetProperty<float>(index), 5.0f, TEST_LOCATION);
1576 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), startValue, TEST_LOCATION);
1578 tet_infoline("Render and retrieve values again");
1579 application.SendNotification();
1580 application.Render(0);
1582 DALI_TEST_EQUALS(actor.GetProperty<float>(index), 5.0f, TEST_LOCATION);
1583 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 5.0f, TEST_LOCATION);
1588 int UtcDaliHandleCustomPropertyGetType(void)
1590 TestApplication application;
1592 tet_infoline("Create a custom property and retrieve its type");
1594 Handle handle = Handle::New();
1595 Property::Index index = handle.RegisterProperty("testProperty", 1.0f);
1596 DALI_TEST_EQUALS(handle.GetPropertyType(index), Property::FLOAT, TEST_LOCATION);
1601 int UtcDaliHandleCustomPropertyAccessMode(void)
1603 TestApplication application;
1605 tet_infoline("Create a custom property and retrieve whether it's animatable etc.");
1607 Handle handle = Handle::New();
1608 Property::Index index = handle.RegisterProperty("testProperty", 1.0f);
1609 DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), true, TEST_LOCATION);
1610 DALI_TEST_EQUALS(handle.IsPropertyWritable(index), true, TEST_LOCATION);
1612 index = handle.RegisterProperty("testProperty2", 1.0f, Property::READ_ONLY);
1613 DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), false, TEST_LOCATION);
1614 DALI_TEST_EQUALS(handle.IsPropertyWritable(index), false, TEST_LOCATION);
1616 index = handle.RegisterProperty("testProperty3", 1.0f, Property::READ_WRITE);
1617 DALI_TEST_EQUALS(handle.IsPropertyAnimatable(index), false, TEST_LOCATION);
1618 DALI_TEST_EQUALS(handle.IsPropertyWritable(index), true, TEST_LOCATION);
1623 int UtcDaliHandleGetCurrentProperty(void)
1625 TestApplication application;
1627 tet_infoline("Get a default and non-animatable custom property using the GetCurrentProperty API");
1629 Actor actor = Actor::New();
1630 application.GetScene().Add(actor);
1631 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
1633 Property::Index index = actor.RegisterProperty("testProperty3", 1.0f, Property::READ_WRITE);
1634 DALI_TEST_EQUALS(actor.GetProperty<float>(index), 1.0f, TEST_LOCATION);
1635 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 1.0f, TEST_LOCATION);
1637 actor.SetProperty(index, 2.0f);
1638 DALI_TEST_EQUALS(actor.GetProperty<float>(index), 2.0f, TEST_LOCATION);
1639 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(index), 2.0f, TEST_LOCATION);
1644 int UtcDaliHandleDoesCustomPropertyExistP1(void)
1646 TestApplication application; // Needs type registry
1648 tet_infoline("Test if a registered custom property exists on object");
1650 Actor actor = Actor::New();
1651 auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1653 DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(propertyIndex), true, TEST_LOCATION);
1657 int UtcDaliHandleDoesCustomPropertyExistN1(void)
1659 TestApplication application; // Needs type registry
1661 tet_infoline("Test if a registered custom property does not exist on object");
1663 Actor actor = Actor::New();
1664 auto propertyIndex = actor.RegisterProperty("customProperty1", 1.0f);
1666 DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(propertyIndex + 1), false, TEST_LOCATION);
1670 int UtcDaliHandleDoesCustomPropertyExistN2(void)
1672 TestApplication application; // Needs type registry
1674 tet_infoline("Test that a default property does not show as a custom property on object");
1676 Actor actor = Actor::New();
1677 DALI_TEST_EQUALS(actor.DoesCustomPropertyExist(Actor::Property::POSITION), false, TEST_LOCATION);
1681 int UtcDaliHandleDoesCustomPropertyExistN3(void)
1683 TestApplication application; // Needs type registry
1685 tet_infoline("Test that a child property does not exist on actor after parenting to container");
1686 TypeRegistry typeRegistry = TypeRegistry::Get();
1688 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1690 const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1691 const char* CHILD_PROPERTY_NAME("childProperty");
1693 ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1695 auto container = Test::TestCustomActor::New();
1696 application.GetScene().Add(container);
1697 auto child = Actor::New();
1698 container.Add(child); // Resolve child properties (if any)
1700 DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), false, TEST_LOCATION);
1704 int UtcDaliHandleDoesCustomPropertyExistP2(void)
1706 TestApplication application; // Needs type registry
1708 tet_infoline("Test that a child property exists after being set");
1709 TypeRegistry typeRegistry = TypeRegistry::Get();
1711 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1713 const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1714 const char* CHILD_PROPERTY_NAME("childProperty");
1716 ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1718 auto container = Test::TestCustomActor::New();
1719 application.GetScene().Add(container);
1720 auto child = Actor::New();
1721 container.Add(child); // Resolve child properties (if any)
1722 child.SetProperty(CHILD_PROPERTY, 2);
1724 DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1725 DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 2, TEST_LOCATION);
1729 int UtcDaliHandleDoesCustomPropertyExistP3(void)
1731 TestApplication application; // Needs type registry
1733 tet_infoline("Test that a child property is re-indexed after registration, and that it exists");
1734 TypeRegistry typeRegistry = TypeRegistry::Get();
1736 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1738 const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1739 const char* CHILD_PROPERTY_NAME("childProperty");
1741 ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1743 auto container = Test::TestCustomActor::New();
1744 application.GetScene().Add(container);
1745 auto child = Actor::New();
1746 child.RegisterProperty(CHILD_PROPERTY_NAME, Property::Value(3));
1747 container.Add(child); // Resolve child properties (if any)
1749 DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1750 DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 3, TEST_LOCATION);
1756 struct PropertySetSignalCheck
1758 PropertySetSignalCheck(bool& signalReceived, Property::Value& value)
1759 : mSignalReceived(signalReceived),
1764 void operator()(Handle& handle, Property::Index index, Property::Value value)
1766 mSignalReceived = true;
1772 mSignalReceived = false;
1775 void CheckSignalReceived()
1777 if(!mSignalReceived)
1779 tet_printf("Expected Property Set signal was not received\n");
1780 tet_result(TET_FAIL);
1784 tet_result(TET_PASS);
1788 bool& mSignalReceived; // owned by individual tests
1789 Property::Value& mValue;
1794 int UtcDaliHandlePropertySetSignal01(void)
1796 TestApplication application;
1798 bool signalReceived(false);
1799 Property::Value value;
1800 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1802 tet_infoline("Test that setting a default property triggers a signal");
1804 auto actor = Actor::New();
1805 actor.PropertySetSignal().Connect(&application, propertySetCheck);
1807 actor.SetProperty(Actor::Property::POSITION, Vector3::XAXIS);
1808 propertySetCheck.CheckSignalReceived();
1813 int UtcDaliHandlePropertySetSignal02(void)
1815 TestApplication application;
1817 bool signalReceived(false);
1818 Property::Value value;
1819 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1821 tet_infoline("Test that setting a custom property triggers a signal");
1823 auto actor = Actor::New();
1824 actor.PropertySetSignal().Connect(&application, propertySetCheck);
1826 auto propertyIndex = actor.RegisterProperty("propName", 3.0f);
1827 actor.SetProperty(propertyIndex, 5.0f);
1828 propertySetCheck.CheckSignalReceived();
1829 DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(5.0f), 0.001f, TEST_LOCATION);
1834 int UtcDaliHandlePropertySetSignal03(void)
1836 TestApplication application;
1837 TypeRegistry typeRegistry = TypeRegistry::Get();
1839 bool signalReceived(false);
1840 Property::Value value;
1841 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1843 tet_infoline("Test that setting a child property triggers a signal");
1845 auto customActorTypeInfo = typeRegistry.GetTypeInfo(typeid(Test::TestCustomActor));
1847 const Property::Index CHILD_PROPERTY(CHILD_PROPERTY_REGISTRATION_START_INDEX);
1848 const char* CHILD_PROPERTY_NAME("childProperty");
1850 ChildPropertyRegistration(customActorTypeInfo.GetName(), CHILD_PROPERTY_NAME, CHILD_PROPERTY, Property::INTEGER);
1852 auto container = Test::TestCustomActor::New();
1853 application.GetScene().Add(container);
1854 auto child = Actor::New();
1855 child.RegisterProperty(CHILD_PROPERTY_NAME, Property::Value(3));
1856 child.PropertySetSignal().Connect(&application, propertySetCheck);
1857 container.Add(child); // Resolve child properties (if any)
1859 DALI_TEST_EQUALS(child.DoesCustomPropertyExist(CHILD_PROPERTY), true, TEST_LOCATION);
1860 DALI_TEST_EQUALS(child.GetProperty<int>(CHILD_PROPERTY), 3, TEST_LOCATION);
1862 child.SetProperty(CHILD_PROPERTY, 29);
1863 propertySetCheck.CheckSignalReceived();
1864 DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(29), TEST_LOCATION);
1868 int UtcDaliHandlePropertySetSignal04(void)
1870 TestApplication application;
1871 TypeRegistry typeRegistry = TypeRegistry::Get();
1873 bool signalReceived(false);
1874 Property::Value value;
1875 PropertySetSignalCheck propertySetCheck(signalReceived, value);
1877 tet_infoline("Test that setting a property on a vanilla Object triggers a signal");
1879 constexpr Property::Index TEST_PROPERTY_KEY_INDEX = 1;
1880 const std::string TEST_PROPERTY_KEY_NAME = "testProperty";
1882 Handle vanillaObject = Handle::New();
1883 auto propertyIndex = vanillaObject.RegisterProperty(
1884 TEST_PROPERTY_KEY_INDEX,
1885 TEST_PROPERTY_KEY_NAME,
1888 vanillaObject.PropertySetSignal().Connect(&application, propertySetCheck);
1890 DALI_TEST_EQUALS(vanillaObject.DoesCustomPropertyExist(propertyIndex), true, TEST_LOCATION);
1891 DALI_TEST_EQUALS(vanillaObject.GetProperty<Vector4>(propertyIndex), Color::WHITE, 0.001f, TEST_LOCATION);
1893 vanillaObject[TEST_PROPERTY_KEY_NAME] = Color::RED;
1895 propertySetCheck.CheckSignalReceived();
1896 DALI_TEST_EQUALS(propertySetCheck.mValue, Property::Value(Color::RED), 0.001f, TEST_LOCATION);
1897 DALI_TEST_VALUE_EQUALS(vanillaObject[propertyIndex], Property::Value(Color::RED), 0.001f, TEST_LOCATION);
1902 int UtcDaliHandlePropertySetProperties(void)
1904 TestApplication application;
1905 const Vector3 actorSize(10.0f, 20.0f, 30.0f);
1906 const Vector3 anchorPoint(1.0f, 0.5f, 0.0f);
1907 const Vector4 color(0.1f, 0.2, 0.3f, 0.4f);
1909 Handle handle = Actor::New();
1910 handle.SetProperties(
1912 {Actor::Property::SIZE, actorSize},
1913 {Actor::Property::ANCHOR_POINT, anchorPoint},
1915 {"invalid", Vector2::ZERO} // It should quietly ignore invalid data
1917 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SIZE).Get<Vector3>(), actorSize, TEST_LOCATION);
1918 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>(), anchorPoint, TEST_LOCATION);
1919 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR).Get<Vector4>(), color, TEST_LOCATION);
1924 int UtcDaliHandleTemplateNew01(void)
1926 TestApplication application;
1927 const Vector3 actorSize(10.0f, 20.0f, 30.0f);
1928 const Vector3 anchorPoint(1.0f, 0.5f, 0.0f);
1929 const Vector4 color(0.1f, 0.2, 0.3f, 0.4f);
1931 Handle handle = Handle::New<Actor>(
1933 {Actor::Property::SIZE, actorSize},
1934 {Actor::Property::ANCHOR_POINT, anchorPoint},
1936 {"invalid", Vector2::ZERO} // It should quietly ignore invalid data
1939 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::SIZE).Get<Vector3>(), actorSize, TEST_LOCATION);
1940 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::ANCHOR_POINT).Get<Vector3>(), anchorPoint, TEST_LOCATION);
1941 DALI_TEST_EQUALS(handle.GetProperty(Actor::Property::COLOR).Get<Vector4>(), color, TEST_LOCATION);
1946 int UtcDaliHandleGetProperties(void)
1948 TestApplication application;
1950 Handle handle = Actor::New();
1951 handle.SetProperties(
1953 {Actor::Property::SIZE, Vector3(400.0f, 200.0f, 100.0f)},
1954 {Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER},
1955 {Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER},
1956 {Actor::Property::NAME, "Actor"},
1957 {Actor::Property::LEAVE_REQUIRED, true},
1958 {"color", Color::RED},
1962 handle.GetProperties(map);
1964 // Get all the properties and ensure they match
1966 DALI_TEST_EQUALS(handle.GetPropertyCount(), map.Count(), TEST_LOCATION);
1968 for(auto position = 0u; position < map.Count(); ++position)
1970 auto keyValuePair = map.GetKeyValue(position);
1971 const auto& index = keyValuePair.first.indexKey;
1972 const auto& value = keyValuePair.second;
1973 auto handleValue = handle.GetProperty(index);
1975 switch(value.GetType())
1977 case Property::NONE:
1979 case Property::BOOLEAN:
1980 DALI_TEST_EQUALS(value.Get<bool>(), handleValue.Get<bool>(), TEST_LOCATION);
1982 case Property::FLOAT:
1983 DALI_TEST_EQUALS(value.Get<float>(), handleValue.Get<float>(), TEST_LOCATION);
1985 case Property::INTEGER:
1986 DALI_TEST_EQUALS(value.Get<int>(), handleValue.Get<int>(), TEST_LOCATION);
1988 case Property::VECTOR2:
1989 DALI_TEST_EQUALS(value.Get<Vector2>(), handleValue.Get<Vector2>(), TEST_LOCATION);
1991 case Property::VECTOR3:
1992 DALI_TEST_EQUALS(value.Get<Vector3>(), handleValue.Get<Vector3>(), TEST_LOCATION);
1994 case Property::VECTOR4:
1995 DALI_TEST_EQUALS(value.Get<Vector4>(), handleValue.Get<Vector4>(), TEST_LOCATION);
1997 case Property::MATRIX3:
1998 DALI_TEST_EQUALS(value.Get<Matrix3>(), handleValue.Get<Matrix3>(), TEST_LOCATION);
2000 case Property::MATRIX:
2001 DALI_TEST_EQUALS(value.Get<Matrix>(), handleValue.Get<Matrix>(), TEST_LOCATION);
2003 case Property::RECTANGLE:
2004 DALI_TEST_EQUALS(value.Get<Rect<int> >(), handleValue.Get<Rect<int> >(), TEST_LOCATION);
2006 case Property::ROTATION:
2007 DALI_TEST_EQUALS(value.Get<Quaternion>(), handleValue.Get<Quaternion>(), TEST_LOCATION);
2009 case Property::STRING:
2010 DALI_TEST_EQUALS(value.Get<std::string>(), handleValue.Get<std::string>(), TEST_LOCATION);
2012 case Property::ARRAY:
2013 DALI_TEST_EQUALS(value.GetArray()->Count(), handleValue.GetArray()->Count(), TEST_LOCATION);
2016 DALI_TEST_EQUALS(value.GetMap()->Count(), handleValue.GetMap()->Count(), TEST_LOCATION);
2018 case Property::EXTENTS:
2019 DALI_TEST_EQUALS(value.Get<Extents>(), handleValue.Get<Extents>(), TEST_LOCATION);
2024 // Add a custom property and ensure the count goes up by one.
2025 const auto countBefore = map.Count();
2026 handle.RegisterProperty("tempProperty", Color::GREEN);
2027 handle.GetProperties(map);
2028 DALI_TEST_EQUALS(countBefore + 1, map.Count(), TEST_LOCATION);
2033 int UtcDaliHandleReserveProperties(void)
2035 TestApplication application;
2036 Dali::Handle instance = Handle::New();
2037 DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
2039 instance.ReserveCustomProperties(0);
2040 DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
2042 instance.ReserveCustomProperties(20);
2043 DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
2045 instance.RegisterProperty("testProperty", 22.0f);
2046 DALI_TEST_EQUALS(instance.GetPropertyCount(), 1, TEST_LOCATION);
2048 // Test that reserving actor properties doesn't change property count
2049 Dali::Actor actor = Actor::New();
2050 auto count = actor.GetPropertyCount();
2052 actor.ReserveCustomProperties(15);
2053 DALI_TEST_EQUALS(actor.GetPropertyCount(), count, TEST_LOCATION);
2055 // Test that reserving renderer properties doesn't change property count
2056 Geometry geom = Geometry::New();
2057 Shader shader = Shader::New("vertex", "frag");
2058 Dali::Renderer renderer = Renderer::New(geom, shader);
2059 count = renderer.GetPropertyCount();
2060 renderer.ReserveCustomProperties(22);
2061 DALI_TEST_EQUALS(renderer.GetPropertyCount(), count, TEST_LOCATION);
2063 count = shader.GetPropertyCount();
2064 shader.ReserveCustomProperties(5);
2065 DALI_TEST_EQUALS(shader.GetPropertyCount(), count, TEST_LOCATION);
2067 application.SendNotification();
2068 application.Render();
2073 int UtcDaliHandleSetPropertyNegative(void)
2075 TestApplication application;
2076 Dali::Handle instance;
2080 Dali::Property::Value arg2;
2081 instance.SetProperty(arg1, arg2);
2082 DALI_TEST_CHECK(false); // Should not get here
2086 DALI_TEST_CHECK(true); // We expect an assert
2091 int UtcDaliHandleRegisterPropertyNegative01(void)
2093 TestApplication application;
2094 Dali::Handle instance;
2098 Dali::Property::Value arg2;
2099 instance.RegisterProperty(arg1, arg2);
2100 DALI_TEST_CHECK(false); // Should not get here
2104 DALI_TEST_CHECK(true); // We expect an assert
2109 int UtcDaliHandleRegisterPropertyNegative02(void)
2111 TestApplication application;
2112 Dali::Handle instance;
2116 Dali::Property::Value arg2;
2117 Dali::Property::AccessMode arg3(Property::READ_ONLY);
2118 instance.RegisterProperty(arg1, arg2, arg3);
2119 DALI_TEST_CHECK(false); // Should not get here
2123 DALI_TEST_CHECK(true); // We expect an assert
2128 int UtcDaliHandleRemoveConstraintsNegative01(void)
2130 TestApplication application;
2131 Dali::Handle instance;
2134 unsigned int arg1(0u);
2135 instance.RemoveConstraints(arg1);
2136 DALI_TEST_CHECK(false); // Should not get here
2140 DALI_TEST_CHECK(true); // We expect an assert
2145 int UtcDaliHandleRemoveConstraintsNegative02(void)
2147 TestApplication application;
2148 Dali::Handle instance;
2151 instance.RemoveConstraints();
2152 DALI_TEST_CHECK(false); // Should not get here
2156 DALI_TEST_CHECK(true); // We expect an assert
2161 int UtcDaliHandleAddPropertyNotificationNegative01(void)
2163 TestApplication application;
2164 Dali::Handle instance;
2169 Dali::PropertyCondition arg3;
2170 instance.AddPropertyNotification(arg1, arg2, arg3);
2171 DALI_TEST_CHECK(false); // Should not get here
2175 DALI_TEST_CHECK(true); // We expect an assert
2180 int UtcDaliHandleAddPropertyNotificationNegative02(void)
2182 TestApplication application;
2183 Dali::Handle instance;
2187 Dali::PropertyCondition arg2;
2188 instance.AddPropertyNotification(arg1, arg2);
2189 DALI_TEST_CHECK(false); // Should not get here
2193 DALI_TEST_CHECK(true); // We expect an assert
2198 int UtcDaliHandleRemovePropertyNotificationNegative(void)
2200 TestApplication application;
2201 Dali::Handle instance;
2204 Dali::PropertyNotification arg1;
2205 instance.RemovePropertyNotification(arg1);
2206 DALI_TEST_CHECK(false); // Should not get here
2210 DALI_TEST_CHECK(true); // We expect an assert
2215 int UtcDaliHandleRemovePropertyNotificationsNegative(void)
2217 TestApplication application;
2218 Dali::Handle instance;
2221 instance.RemovePropertyNotifications();
2222 DALI_TEST_CHECK(false); // Should not get here
2226 DALI_TEST_CHECK(true); // We expect an assert
2231 int UtcDaliHandleGetPropertyNegative(void)
2233 TestApplication application;
2234 Dali::Handle instance;
2238 instance.GetProperty(arg1);
2239 DALI_TEST_CHECK(false); // Should not get here
2243 DALI_TEST_CHECK(true); // We expect an assert
2248 int UtcDaliHandleGetPropertyNameNegative(void)
2250 TestApplication application;
2251 Dali::Handle instance;
2255 instance.GetPropertyName(arg1);
2256 DALI_TEST_CHECK(false); // Should not get here
2260 DALI_TEST_CHECK(true); // We expect an assert
2265 int UtcDaliHandleGetPropertyTypeNegative(void)
2267 TestApplication application;
2268 Dali::Handle instance;
2272 instance.GetPropertyType(arg1);
2273 DALI_TEST_CHECK(false); // Should not get here
2277 DALI_TEST_CHECK(true); // We expect an assert
2282 int UtcDaliHandleGetPropertyCountNegative(void)
2284 TestApplication application;
2285 Dali::Handle instance;
2288 instance.GetPropertyCount();
2289 DALI_TEST_CHECK(false); // Should not get here
2293 DALI_TEST_CHECK(true); // We expect an assert
2298 int UtcDaliHandleGetPropertyIndexNegative(void)
2300 TestApplication application;
2301 Dali::Handle instance;
2305 instance.GetPropertyIndex(arg1);
2306 DALI_TEST_CHECK(false); // Should not get here
2310 DALI_TEST_CHECK(true); // We expect an assert
2315 int UtcDaliHandleGetCurrentPropertyNegative(void)
2317 TestApplication application;
2318 Dali::Handle instance;
2322 instance.GetCurrentProperty(arg1);
2323 DALI_TEST_CHECK(false); // Should not get here
2327 DALI_TEST_CHECK(true); // We expect an assert
2332 int UtcDaliHandleGetPropertyIndicesNegative(void)
2334 TestApplication application;
2335 Dali::Handle instance;
2338 Dali::Vector<int> arg1;
2339 instance.GetPropertyIndices(arg1);
2340 DALI_TEST_CHECK(false); // Should not get here
2344 DALI_TEST_CHECK(true); // We expect an assert
2349 int UtcDaliHandleIsPropertyWritableNegative(void)
2351 TestApplication application;
2352 Dali::Handle instance;
2356 instance.IsPropertyWritable(arg1);
2357 DALI_TEST_CHECK(false); // Should not get here
2361 DALI_TEST_CHECK(true); // We expect an assert
2366 int UtcDaliHandleIsPropertyAnimatableNegative(void)
2368 TestApplication application;
2369 Dali::Handle instance;
2373 instance.IsPropertyAnimatable(arg1);
2374 DALI_TEST_CHECK(false); // Should not get here
2378 DALI_TEST_CHECK(true); // We expect an assert
2383 int UtcDaliHandleIsPropertyAConstraintInputNegative(void)
2385 TestApplication application;
2386 Dali::Handle instance;
2390 instance.IsPropertyAConstraintInput(arg1);
2391 DALI_TEST_CHECK(false); // Should not get here
2395 DALI_TEST_CHECK(true); // We expect an assert
2400 int UtcDaliHandleSupportsNegative(void)
2402 TestApplication application;
2403 Dali::Handle instance;
2406 Dali::Handle::Capability arg1(Handle::DYNAMIC_PROPERTIES);
2407 instance.Supports(arg1);
2408 DALI_TEST_CHECK(false); // Should not get here
2412 DALI_TEST_CHECK(true); // We expect an assert
2417 int UtcDaliHandleIndexOperatorByIndexP01(void)
2419 TestApplication application;
2420 Actor actor = Actor::New();
2422 actor[Actor::Property::SIZE] = Vector3(100.0f, 200.0f, 1.0f);
2424 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(100.0f, 200.0f, 1.0f), 0.001f, TEST_LOCATION);
2426 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2428 Vector3 position = actor[Actor::Property::POSITION];
2429 DALI_TEST_EQUALS(position, Vector3(10.0f, 20.0f, 0.0f), TEST_LOCATION);
2434 int UtcDaliHandleIndexOperatorByIndexP02(void)
2436 TestApplication application;
2437 Actor actor = Actor::New();
2439 const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2440 actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2441 actor[Actor::Property::COLOR_RED] = 0.5f;
2443 DALI_TEST_EQUALS(actor.GetProperty<float>(Actor::Property::COLOR_RED), 0.5f, 0.001f, TEST_LOCATION);
2444 DALI_TEST_EQUALS(actor.GetProperty<Vector4>(Actor::Property::COLOR), Vector4(0.5f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
2446 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2448 DALI_TEST_EQUALS((float)actor[Actor::Property::POSITION_Z], 0.0f, 0.001f, TEST_LOCATION);
2453 int UtcDaliHandleIndexOperatorByIndexP03(void)
2455 TestApplication application;
2456 Actor actor = Actor::New();
2458 const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2459 actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2461 // Value under test is second to allow compiler to deduce type
2462 DALI_TEST_VALUE_EQUALS(actor[Actor::Property::COLOR_RED], 1.0f, 0.001f, TEST_LOCATION);
2464 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2466 DALI_TEST_EQUALS((float)actor[Actor::Property::POSITION_Z], 0.0f, 0.001f, TEST_LOCATION);
2471 int UtcDaliHandleIndexOperatorByNameP01(void)
2473 TestApplication application;
2474 Actor actor = Actor::New();
2476 actor["size"] = Vector3(100.0f, 200.0f, 1.0f);
2478 DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::SIZE), Vector3(100.0f, 200.0f, 1.0f), 0.001f, TEST_LOCATION);
2480 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2481 Vector3 position = actor["position"];
2483 DALI_TEST_EQUALS(position, Vector3(10.0f, 20.0f, 0.0f), 0.001f, TEST_LOCATION);
2488 int UtcDaliHandleIndexOperatorByNameP02(void)
2490 TestApplication application;
2491 Actor actor = Actor::New();
2493 const Vector4 defaultActorColor(1.0f, 1.0f, 1.0f, 1.0f);
2494 actor.SetProperty(Actor::Property::COLOR, defaultActorColor);
2495 actor["colorRed"] = 0.5f;
2497 DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::COLOR_RED), 0.5f, 0.001f, TEST_LOCATION);
2498 DALI_TEST_VALUE_EQUALS(actor.GetProperty(Actor::Property::COLOR), Vector4(0.5f, 1.0f, 1.0f, 1.0f), 0.001f, TEST_LOCATION);
2500 actor.SetProperty(Actor::Property::POSITION, Vector3(10.0f, 20.0f, 0.0f));
2502 float positionY = actor["positionY"];
2503 DALI_TEST_EQUALS(positionY, 20.0f, 0.001f, TEST_LOCATION);
2505 // Should automatically promote IndirectValue to Property::Value rvalue.
2506 DALI_TEST_VALUE_EQUALS(actor["positionZ"], 0.0f, 0.001f, TEST_LOCATION);
2511 int UtcDaliHandleIndexOperatorNegative02(void)
2513 TestApplication application;
2518 Vector3 position = actor[Actor::Property::POSITION];
2519 if(position == position)
2521 DALI_TEST_CHECK(false); // Should throw before reaching here.
2523 DALI_TEST_CHECK(false); // Should throw before reaching here.
2527 DALI_TEST_CHECK(true); // Assert expected