2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include "dali-test-suite-utils/dali-test-suite-utils.h"
23 #include <mesh-builder.h>
27 void handle_test_startup(void)
29 test_return_value = TET_UNDEF;
32 void handle_test_cleanup(void)
34 test_return_value = TET_PASS;
40 /// Allows the creation of a BaseObject
41 class BaseObjectType : public BaseObject
49 Handle ImplicitCopyConstructor(Handle passedByValue)
51 // object + copy + passedByValue, ref count == 3
52 DALI_TEST_CHECK(passedByValue);
55 DALI_TEST_EQUALS(3, passedByValue.GetBaseObject().ReferenceCount(), TEST_LOCATION);
64 int UtcDaliHandleConstructorVoid(void)
66 TestApplication application;
67 tet_infoline("Testing Dali::Handle::Handle()");
71 DALI_TEST_CHECK(!object);
76 int UtcDaliHandleCopyConstructor(void)
78 TestApplication application;
79 tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
81 // Initialize an object, ref count == 1
82 Handle object = Actor::New();
84 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
86 // Copy the object, ref count == 2
88 DALI_TEST_CHECK(copy);
91 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
95 // Pass by value, and return another copy, ref count == 3
96 Handle anotherCopy = ImplicitCopyConstructor(copy);
98 DALI_TEST_CHECK(anotherCopy);
101 DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
105 // anotherCopy out of scope, ref count == 2
106 DALI_TEST_CHECK(copy);
109 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
114 int UtcDaliHandleAssignmentOperator(void)
116 TestApplication application;
117 tet_infoline("Testing Dali::Handle::operator=");
119 Handle object = Actor::New();
121 DALI_TEST_CHECK(object);
122 DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION);
125 DALI_TEST_CHECK(!copy);
128 DALI_TEST_CHECK(copy);
129 DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION);
130 DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject()));
134 int UtcDaliHandleSupports(void)
136 tet_infoline("Positive Test Dali::Handle::Supports()");
137 TestApplication application;
139 Actor actor = Actor::New();
140 DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) );
144 int UtcDaliHandleGetPropertyCount(void)
146 tet_infoline("Positive Test Dali::Handle::GetPropertyCount()");
147 TestApplication application;
149 Actor actor = Actor::New();
150 int defaultPropertyCount( actor.GetPropertyCount() );
152 // Register a dynamic property
153 actor.RegisterProperty( "test-property", float(123.0f) );
154 DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() );
158 int UtcDaliHandleGetPropertyName(void)
160 tet_infoline("Positive Test Dali::Handle::GetPropertyName()");
161 TestApplication application;
163 Actor actor = Actor::New();
164 DALI_TEST_CHECK( "parent-origin" == actor.GetPropertyName( Actor::Property::PARENT_ORIGIN ) );
166 // Register a dynamic property
167 std::string name("this-name-should-match");
168 Property::Index index = actor.RegisterProperty( name, float(123.0f) );
169 DALI_TEST_CHECK( name == actor.GetPropertyName( index ) );
174 int UtcDaliHandleGetPropertyIndex(void)
176 tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()");
177 TestApplication application;
179 Actor actor = Actor::New();
180 DALI_TEST_CHECK( Actor::Property::PARENT_ORIGIN == actor.GetPropertyIndex("parent-origin") );
182 // Register a dynamic property
183 std::string name("this-name-should-match");
184 Property::Index index = actor.RegisterProperty( name, float(123.0f) );
185 DALI_TEST_CHECK( index == actor.GetPropertyIndex( name ) );
189 int UtcDaliHandleIsPropertyWritable(void)
191 tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()");
192 TestApplication application;
194 Actor actor = Actor::New();
196 // Actor properties which are writable:
197 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN ) );
198 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_X ) );
199 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Y ) );
200 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::PARENT_ORIGIN_Z ) );
201 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT ) );
202 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_X ) );
203 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Y ) );
204 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ANCHOR_POINT_Z ) );
205 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE ) );
206 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_WIDTH ) );
207 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_HEIGHT ) );
208 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SIZE_DEPTH ) );
209 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION ) );
210 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_X ) );
211 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Y ) );
212 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::POSITION_Z ) );
213 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::ORIENTATION ) );
214 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE ) );
215 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_X ) );
216 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Y ) );
217 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::SCALE_Z ) );
218 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::VISIBLE ) );
219 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR ) );
220 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_RED ) );
221 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_GREEN ) );
222 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_BLUE ) );
223 DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::Property::COLOR_ALPHA ) );
225 // World-properties are not writable:
226 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
227 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_ORIENTATION ) );
228 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_SCALE ) );
229 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_COLOR ) );
230 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_X ) );
231 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Y ) );
232 DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::Property::WORLD_POSITION_Z ) );
237 int UtcDaliHandleIsPropertyAnimatable(void)
239 tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()");
240 TestApplication application;
242 Actor actor = Actor::New();
244 // Actor properties which are animatable:
245 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN ) );
246 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_X ) );
247 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Y ) );
248 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::PARENT_ORIGIN_Z ) );
249 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT ) );
250 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_X ) );
251 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Y ) );
252 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::ANCHOR_POINT_Z ) );
253 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE ) );
254 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_WIDTH ) );
255 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_HEIGHT ) );
256 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SIZE_DEPTH ) );
257 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION ) );
258 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_X ) );
259 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Y ) );
260 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::POSITION_Z ) );
261 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::ORIENTATION ) );
262 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE ) );
263 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_X ) );
264 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Y ) );
265 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::SCALE_Z ) );
266 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::VISIBLE ) );
267 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR ) );
268 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_RED ) );
269 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_GREEN ) );
270 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_BLUE ) );
271 DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::Property::COLOR_ALPHA ) );
273 // World-properties can not be animated
274 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION ) );
275 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_ORIENTATION ) );
276 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_SCALE ) );
277 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_COLOR ) );
278 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_X ) );
279 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Y ) );
280 DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::Property::WORLD_POSITION_Z ) );
285 int UtcDaliHandleIsPropertyAConstraintInput(void)
287 TestApplication application;
289 Actor actor = Actor::New();
291 // Actor properties which can be used as a constraint input:
292 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN ) );
293 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_X ) );
294 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Y ) );
295 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::PARENT_ORIGIN_Z ) );
296 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT ) );
297 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_X ) );
298 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Y ) );
299 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ANCHOR_POINT_Z ) );
300 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE ) );
301 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_WIDTH ) );
302 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_HEIGHT ) );
303 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_DEPTH ) );
304 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION ) );
305 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_X ) );
306 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Y ) );
307 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_Z ) );
308 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::ORIENTATION ) );
309 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE ) );
310 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_X ) );
311 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Y ) );
312 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::SCALE_Z ) );
313 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::VISIBLE ) );
314 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR ) );
315 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_RED ) );
316 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_GREEN ) );
317 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_BLUE ) );
318 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_ALPHA ) );
319 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION ) );
320 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_ORIENTATION ) );
321 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_SCALE ) );
322 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_COLOR ) );
323 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_X ) );
324 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Y ) );
325 DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::Property::WORLD_POSITION_Z ) );
327 // Actor properties that cannot be used as a constraint input
328 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::NAME ) );
329 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SENSITIVE ) );
330 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::LEAVE_REQUIRED ) );
331 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_ORIENTATION ) );
332 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::INHERIT_SCALE ) );
333 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_MODE ) );
334 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_INHERITANCE ) );
335 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::DRAW_MODE ) );
336 DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE_FACTOR ) );
342 int UtcDaliHandleGetPropertyType(void)
344 tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
345 TestApplication application;
346 unsigned int unsingedIntTest = 33;
348 Actor actor = Actor::New();
349 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::PARENT_ORIGIN ) );
350 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::ANCHOR_POINT ) );
351 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::SIZE ) );
352 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::POSITION ) );
353 DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( Actor::Property::ORIENTATION ) );
354 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::Property::SCALE ) );
355 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( Actor::Property::VISIBLE ) );
356 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( Actor::Property::COLOR ) );
358 // Register some dynamic properties
359 Property::Index boolIndex = actor.RegisterProperty( "bool-property", bool(true) );
360 Property::Index floatIndex = actor.RegisterProperty( "float-property", float(123.0f) );
361 Property::Index intIndex = actor.RegisterProperty( "int-property", 123 );
362 Property::Index unsignedIntIndex = actor.RegisterProperty( "unsigned-int-property", 456u );
363 Property::Index vector2Index = actor.RegisterProperty( "vector2-property", Vector2(1.0f, 2.0f) );
364 Property::Index vector3Index = actor.RegisterProperty( "vector3-property", Vector3(1.0f, 2.0f, 3.0f) );
365 Property::Index vector4Index = actor.RegisterProperty( "vector4-property", Vector4(1.0f, 2.0f, 3.0f, 4.0f) );
366 Property::Index rotationIndex = actor.RegisterProperty( "rotation-property", AngleAxis(Degree(180.0f), Vector3::YAXIS) );
368 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( boolIndex ) );
369 DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( floatIndex ) );
370 DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( intIndex ) );
371 DALI_TEST_CHECK( Property::UNSIGNED_INTEGER == actor.GetPropertyType( unsignedIntIndex ) );
372 DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( vector2Index ) );
373 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) );
374 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) );
375 DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) );
377 // Non animatable properties
378 Property::Index nonAnimStringIndex = actor.RegisterProperty( "man-from-delmonte", std::string("yes"), Property::READ_WRITE);
379 Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE);
380 Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE);
381 Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE);
382 Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE);
383 Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE);
384 Property::Index nonAnimIntegerIndex = actor.RegisterProperty( "int", 0, Property::READ_WRITE);
385 Property::Index nonAnimUnsignedIntIndex = actor.RegisterProperty( "unsinged-int", unsingedIntTest, Property::READ_WRITE);
387 DALI_TEST_CHECK( nonAnimStringIndex != Property::INVALID_INDEX );
388 DALI_TEST_CHECK( nonAnimV2Index != Property::INVALID_INDEX );
389 DALI_TEST_CHECK( nonAnimV3Index != Property::INVALID_INDEX );
390 DALI_TEST_CHECK( nonAnimV4Index != Property::INVALID_INDEX );
391 DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX );
392 DALI_TEST_CHECK( nonAnimFloatIndex != Property::INVALID_INDEX );
393 DALI_TEST_CHECK( nonAnimIntegerIndex != Property::INVALID_INDEX );
394 DALI_TEST_CHECK( nonAnimUnsignedIntIndex != Property::INVALID_INDEX );
396 DALI_TEST_CHECK( Property::STRING == actor.GetPropertyType( nonAnimStringIndex ) );
397 DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( nonAnimV2Index ) );
398 DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( nonAnimV3Index ) );
399 DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( nonAnimV4Index ) );
400 DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( nonAnimBooleanIndex ) );
401 DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( nonAnimFloatIndex ) );
402 DALI_TEST_CHECK( Property::INTEGER == actor.GetPropertyType( nonAnimIntegerIndex ) );
403 DALI_TEST_CHECK( Property::UNSIGNED_INTEGER == actor.GetPropertyType( nonAnimUnsignedIntIndex ) );
405 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) );
406 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) );
407 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV3Index ) );
408 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) );
409 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) );
410 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) );
411 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimIntegerIndex ) );
412 DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimUnsignedIntIndex ) );
414 DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
415 DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get<Vector2>(), TEST_LOCATION );
416 DALI_TEST_EQUALS( Vector3(1.f, 2.f, 3.f) , actor.GetProperty( nonAnimV3Index ).Get<Vector3>(), TEST_LOCATION );
417 DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get<Vector4>(), TEST_LOCATION );
418 DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get<bool>(), TEST_LOCATION );
419 DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get<float>(), TEST_LOCATION );
420 DALI_TEST_EQUALS( 0, actor.GetProperty( nonAnimIntegerIndex ).Get<int>(), TEST_LOCATION );
421 DALI_TEST_EQUALS( unsingedIntTest, actor.GetProperty( nonAnimUnsignedIntIndex ).Get<unsigned int>(), TEST_LOCATION );
426 int UtcDaliHandleNonAnimtableProperties(void)
428 tet_infoline("Test Non Animatable Properties");
429 TestApplication application;
431 Actor actor = Actor::New();
433 Property::Index nonAnimStringIndex = actor.RegisterProperty( "man-from-delmonte", std::string("no"), Property::READ_WRITE);
435 //// modify writable?
438 actor.SetProperty( nonAnimStringIndex, Property::Value("yes") );
440 catch (Dali::DaliException& e)
442 DALI_TEST_CHECK(!"exception");
445 DALI_TEST_CHECK( "yes" == actor.GetProperty( nonAnimStringIndex ).Get<std::string>() );
447 //// cannot modify read only?
448 Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY);
450 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly));
451 DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly));
453 bool exception = false;
456 actor.SetProperty( readonly, Property::Value(1.f) );
458 catch (Dali::DaliException& e)
463 DALI_TEST_CHECK(!exception);// trying to set a read-only property is a no-op
465 DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
467 /// animatable can be set
468 Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE);
470 DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim));
471 DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim));
476 actor.SetProperty( write_anim, Property::Value(1.f) );
478 catch (Dali::DaliException& e)
483 DALI_TEST_CHECK(!exception);
485 //// animate a non animatable property is a noop?
486 float durationSeconds(2.0f);
487 Animation animation = Animation::New(durationSeconds);
488 bool relativeValue(true);
494 animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN);
496 application.SendNotification();
497 application.Render(static_cast<unsigned int>(durationSeconds*0100.0f)/* some progress */);
499 catch (Dali::DaliException& e)
504 DALI_TEST_CHECK(!exception);
505 DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get<std::string>(), TEST_LOCATION );
510 int UtcDaliHandleNonAnimtableCompositeProperties(void)
512 tet_infoline("Test Non Animatable Composite Properties");
513 TestApplication application;
515 Actor actor = Actor::New();
517 Property::Value value(Property::ARRAY);
518 Property::Array anArray;
519 DALI_TEST_CHECK( Property::Value(anArray).GetType() == Property::ARRAY ); // 2nd constructor
521 value.AppendItem( Property::Value( 0.f ) );
522 value.AppendItem( "a string" );
523 value.SetItem(0, Property::Value( 5.f )); // exercise SetItem
525 int index = value.AppendItem( Vector3(1,2,3) );
527 DALI_TEST_EQUALS( 2, index, TEST_LOCATION);
528 DALI_TEST_EQUALS( 3, value.GetSize(), TEST_LOCATION);
530 Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE);
532 Property::Value out = actor.GetProperty( propertyIndex );
534 DALI_TEST_CHECK( Property::FLOAT == out.GetItem(0).GetType());
535 DALI_TEST_CHECK( Property::STRING == out.GetItem(1).GetType());
536 DALI_TEST_CHECK( Property::VECTOR3 == out.GetItem(2).GetType());
538 DALI_TEST_EQUALS( 5.f, out.GetItem(0).Get<float>(), TEST_LOCATION);
539 DALI_TEST_EQUALS( "a string", out.GetItem(1).Get<std::string>(), TEST_LOCATION);
540 DALI_TEST_EQUALS( Vector3(1,2,3), out.GetItem(2).Get<Vector3>(), TEST_LOCATION);
543 Property::Value valueMap(Property::MAP);
544 Property::Map aKindofMap;
545 DALI_TEST_CHECK( Property::Value(aKindofMap).GetType() == Property::MAP ); // 2nd constructor
547 valueMap.SetValue("key", 5.f);
548 valueMap.SetValue("2key", "a string");
550 DALI_TEST_EQUALS( true, valueMap.HasKey("key"), TEST_LOCATION);
551 DALI_TEST_EQUALS( "key", valueMap.GetKey(0), TEST_LOCATION);
553 DALI_TEST_EQUALS( true, valueMap.HasKey("2key"), TEST_LOCATION);
554 DALI_TEST_EQUALS( "2key", valueMap.GetKey(1), TEST_LOCATION);
556 DALI_TEST_EQUALS( 5.f, valueMap.GetValue("key").Get<float>(), TEST_LOCATION);
557 DALI_TEST_EQUALS( "a string", valueMap.GetValue("2key").Get<std::string>(), TEST_LOCATION);
559 valueMap.SetItem(0, Property::Value("a string"));
560 valueMap.SetItem(1, Property::Value(5.f));
562 DALI_TEST_EQUALS( 5.f, valueMap.GetValue("2key").Get<float>(), TEST_LOCATION);
563 DALI_TEST_EQUALS( "a string", valueMap.GetValue("key").Get<std::string>(), TEST_LOCATION);
566 valueMap = Property::Value(Property::MAP);
568 valueMap.SetValue("key", 5.f);
569 valueMap.SetValue("2key", "a string");
571 DALI_TEST_EQUALS( 5.f, valueMap.GetItem(0).Get<float>(), TEST_LOCATION);
572 DALI_TEST_EQUALS( "a string", valueMap.GetItem(1).Get<std::string>(), TEST_LOCATION);
574 DALI_TEST_EQUALS( 2, valueMap.GetSize(), TEST_LOCATION);
576 // composite types not animatable
577 bool exception = false;
580 /* Property::Index mapPropertyIndex = */ actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE);
582 catch (Dali::DaliException& e)
585 DALI_TEST_PRINT_ASSERT( e );
588 DALI_TEST_EQUALS(exception, true, TEST_LOCATION);
591 Property::Value mapOfMaps(Property::MAP);
593 mapOfMaps.SetValue( "key", Property::Value(Property::MAP) );
594 mapOfMaps.SetValue( "2key", "a string" );
596 DALI_TEST_EQUALS( "a string", mapOfMaps.GetValue("2key").Get<std::string>(), TEST_LOCATION);
598 mapOfMaps.GetValue("key").SetValue("subkey", 5.f);
600 DALI_TEST_EQUALS( true, mapOfMaps.GetValue("key").HasKey("subkey"), TEST_LOCATION);
601 DALI_TEST_EQUALS( 5.f, mapOfMaps.GetValue("key").GetValue("subkey").Get<float>(), TEST_LOCATION);
604 Property::Value listOfMaps(Property::ARRAY);
606 listOfMaps.AppendItem( Property::Value(Property::MAP) );
607 listOfMaps.AppendItem( Property::Value(Property::MAP) );
609 listOfMaps.GetItem(0).SetValue("key", 5.f);
610 listOfMaps.GetItem(1).SetValue("key",10.f);
612 DALI_TEST_EQUALS( 5.f, listOfMaps.GetItem(0).GetValue("key").Get<float>(), TEST_LOCATION );
613 DALI_TEST_EQUALS( 10.f, listOfMaps.GetItem(1).GetValue("key").Get<float>(), TEST_LOCATION );
618 int UtcDaliHandleSetProperty01(void)
620 tet_infoline("Positive Test Dali::Handle::SetProperty()");
621 TestApplication application;
623 Actor actor = Actor::New();
624 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
626 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
627 // flush the queue and render once
628 application.SendNotification();
629 application.Render();
630 DALI_TEST_CHECK( ParentOrigin::CENTER == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
634 int UtcDaliHandleSetProperty02(void)
636 tet_infoline("Positive Test Dali::Handle::SetProperty()");
637 TestApplication application;
639 Actor actor = Actor::New();
641 DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::Property::WORLD_POSITION ) );
643 // World position is not writable so this is a no-op and should not crash
644 actor.SetProperty( Actor::Property::WORLD_POSITION, Vector3(1,2,3) );
649 int UtcDaliHandleRegisterProperty(void)
651 tet_infoline("Positive Test Dali::Handle::RegisterProperty()");
652 TestApplication application;
654 Actor actor = Actor::New();
655 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
660 int UtcDaliHandleGetProperty(void)
662 tet_infoline("Positive Test Dali::Handle::GetProperty()");
663 TestApplication application;
665 Actor actor = Actor::New();
667 DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::Property::PARENT_ORIGIN ).Get<Vector3>() );
668 DALI_TEST_CHECK( AnchorPoint::CENTER == actor.GetProperty( Actor::Property::ANCHOR_POINT ).Get<Vector3>() );
669 DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::Property::SIZE ).Get<Vector3>() );
670 DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::Property::POSITION ).Get<Vector3>() );
671 DALI_TEST_CHECK( Vector3::ONE == actor.GetProperty( Actor::Property::SCALE ).Get<Vector3>() );
672 DALI_TEST_CHECK( true == actor.GetProperty( Actor::Property::VISIBLE ).Get<bool>() );
673 DALI_TEST_CHECK( Color::WHITE == actor.GetProperty( Actor::Property::COLOR ).Get<Vector4>() );
677 int UtcDaliHandleDownCast(void)
679 TestApplication application;
680 tet_infoline("Testing Dali::Handle::DownCast()");
682 Actor actor = Actor::New();
684 BaseHandle baseHandle = actor;
686 Handle handle = Handle::DownCast(baseHandle);
688 DALI_TEST_CHECK( handle );
690 baseHandle = BaseHandle();
692 handle = Handle::DownCast(baseHandle);
694 DALI_TEST_CHECK( !handle );
699 int UtcDaliHandleDownCastNegative(void)
701 TestApplication application;
703 // BaseObject is NOT an Object, so this DownCast should fail
704 BaseHandle handle( new BaseObjectType );
705 Handle customHandle1 = Handle::DownCast( handle );
706 DALI_TEST_CHECK( ! customHandle1 );
708 // A DownCast on an empty handle will also fail
710 Handle customHandle2 = Handle::DownCast( empty );
711 DALI_TEST_CHECK( ! customHandle2 );
715 int UtcDaliHandleGetPropertyIndices(void)
717 TestApplication application;
718 Property::IndexContainer indices;
721 Actor actor = Actor::New();
722 actor.GetPropertyIndices( indices );
723 DALI_TEST_CHECK( indices.Size() );
724 DALI_TEST_EQUALS( indices.Size(), actor.GetPropertyCount(), TEST_LOCATION );
728 int UtcDaliHandleRegisterPropertyTypes(void)
730 TestApplication application;
732 struct PropertyTypeAnimatable
735 Property::Value value;
739 Property::Array array;
742 PropertyTypeAnimatable properties[] =
744 { "Property::BOOLEAN", true, true },
745 { "Property::FLOAT", 1.0f, true },
746 { "Property::INTEGER", 1, true },
747 { "Property::UNSIGNED_INTEGER", 1u, true },
748 { "Property::VECTOR2", Vector2::ONE, true },
749 { "Property::VECTOR3", Vector3::ONE, true },
750 { "Property::VECTOR4", Vector4::ONE, true },
751 { "Property::MATRIX3", Matrix3::IDENTITY, true },
752 { "Property::MATRIX", Matrix::IDENTITY, true },
753 { "Property::RECTANGLE", Rect<int>(), false },
754 { "Property::ROTATION", AngleAxis(), true },
755 { "Property::STRING", std::string("Me"), false },
756 { "Property::ARRAY", array, false },
757 { "Property::MAP", map, false },
760 unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
762 for ( unsigned int i = 0; i < numOfProperties; ++i )
764 tet_printf( "Testing: %s\n", properties[i].name );
766 bool exception = false;
769 Actor actor = Actor::New();
770 actor.RegisterProperty( "man-from-delmonte", properties[i].value );
772 catch (Dali::DaliException& e)
777 DALI_TEST_CHECK( properties[i].animatable != exception );
782 int UtcDaliHandleCustomProperty(void)
784 TestApplication application;
786 Handle handle = Handle::New();
788 float startValue(1.0f);
789 Property::Index index = handle.RegisterProperty( "test-property", startValue );
790 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
792 application.SendNotification();
793 application.Render(0);
794 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
795 application.Render(0);
796 DALI_TEST_CHECK( handle.GetProperty<float>(index) == startValue );
798 handle.SetProperty( index, 5.0f );
800 application.SendNotification();
801 application.Render(0);
802 DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
803 application.Render(0);
804 DALI_TEST_CHECK( handle.GetProperty<float>(index) == 5.0f );
807 int UtcDaliHandleWeightNew(void)
809 TestApplication application;
811 Handle handle = WeightObject::New();;
812 DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );