Refactoring Gestures Class
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-TypeRegistry.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <limits>
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/internal/event/common/type-info-impl.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26
27 using namespace Dali;
28
29
30 namespace
31 {
32
33 // Stores data that is populated in the callback and will be read by the Test cases
34 struct SignalData
35 {
36   SignalData()
37   : functorCalled( false ),
38     voidFunctorCalled( false ),
39     receivedGesture( ),
40     pressedActor()
41   {}
42
43   void Reset()
44   {
45     functorCalled = false;
46     voidFunctorCalled = false;
47
48     receivedGesture.Reset();
49
50     pressedActor.Reset();
51   }
52
53   bool functorCalled;
54   bool voidFunctorCalled;
55   LongPressGesture receivedGesture;
56   Actor pressedActor;
57 };
58
59 // Functor that sets the data when called
60 struct GestureReceivedFunctor
61 {
62   GestureReceivedFunctor(SignalData& data) : signalData(data) { }
63
64   void operator()(Actor actor, LongPressGesture longPress)
65   {
66     signalData.functorCalled = true;
67     signalData.receivedGesture = longPress;
68     signalData.pressedActor = actor;
69   }
70
71   void operator()()
72   {
73     signalData.voidFunctorCalled = true;
74   }
75
76   SignalData& signalData;
77 };
78
79 //
80 // Create function as Init function called
81 //
82 static bool CreateCustomInitCalled = false;
83 BaseHandle CreateCustomInit(void)
84 {
85   CreateCustomInitCalled = true;
86   return BaseHandle();
87 }
88
89 static bool CreateCustomNamedInitCalled = false;
90 BaseHandle CreateCustomNamedInit(void)
91 {
92   CreateCustomNamedInitCalled = true;
93   return BaseHandle();
94 }
95
96 const std::string scriptedName("PopupStyle");
97 static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
98
99 // Property Registration
100 bool setPropertyCalled = false;
101 bool getPropertyCalled = false;
102 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
103 {
104   setPropertyCalled = true;
105 }
106 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
107 {
108   getPropertyCalled = true;
109   return Property::Value( true );
110 }
111
112
113
114 /*******************************************************************************
115  *
116  * Custom Actor
117  *
118  ******************************************************************************/
119 namespace Impl
120 {
121 struct MyTestCustomActor : public CustomActorImpl
122 {
123   typedef Signal< void ()> SignalType;
124   typedef Signal< void (float)> SignalTypeFloat;
125
126   MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
127   { }
128
129   virtual ~MyTestCustomActor()
130   { }
131
132   void ResetCallStack()
133   {
134   }
135
136   // From CustomActorImpl
137   virtual void OnSceneConnection( int depth )
138   {
139   }
140   virtual void OnSceneDisconnection()
141   {
142   }
143   virtual void OnChildAdd(Actor& child)
144   {
145   }
146   virtual void OnChildRemove(Actor& child)
147   {
148   }
149   virtual void OnSizeSet(const Vector3& targetSize)
150   {
151   }
152   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
153   {
154   }
155   virtual bool OnHoverEvent(const HoverEvent& event)
156   {
157     return true;
158   }
159   virtual bool OnWheelEvent(const WheelEvent& event)
160   {
161     return true;
162   }
163   virtual bool OnKeyEvent(const KeyEvent& event)
164   {
165     return true;
166   }
167   virtual void OnKeyInputFocusGained()
168   {
169   }
170   virtual void OnKeyInputFocusLost()
171   {
172   }
173   virtual Vector3 GetNaturalSize()
174   {
175     return Vector3( 0.0f, 0.0f, 0.0f );
176   }
177
178   virtual float GetHeightForWidth( float width )
179   {
180     return 0.0f;
181   }
182
183   virtual float GetWidthForHeight( float height )
184   {
185     return 0.0f;
186   }
187
188   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
189   {
190   }
191
192   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
193   {
194   }
195
196   virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
197   {
198   }
199
200   virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
201   {
202     return 0.0f;
203   }
204
205   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
206   {
207   }
208
209   virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
210   {
211     return false;
212   }
213
214 public:
215
216   SignalType mSignal;
217 };
218
219 }; // namespace Impl
220
221 class MyTestCustomActor : public CustomActor
222 {
223 public:
224
225   typedef Signal< void ()> SignalType;
226   typedef Signal< void (float)> SignalTypeFloat;
227
228   MyTestCustomActor()
229   {
230   }
231
232   static MyTestCustomActor New()
233   {
234     Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
235     return MyTestCustomActor( *p ); // takes ownership
236   }
237
238   virtual ~MyTestCustomActor()
239   {
240   }
241
242   static MyTestCustomActor DownCast( BaseHandle handle )
243   {
244     MyTestCustomActor result;
245
246     CustomActor custom = Dali::CustomActor::DownCast( handle );
247     if ( custom )
248     {
249       CustomActorImpl& customImpl = custom.GetImplementation();
250
251       Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
252
253       if (impl)
254       {
255         result = MyTestCustomActor(customImpl.GetOwner());
256       }
257     }
258
259     return result;
260   }
261
262   SignalType& GetCustomSignal()
263   {
264     Dali::RefObject& obj = GetImplementation();
265     return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
266   }
267
268 private:
269
270   MyTestCustomActor(Internal::CustomActor* internal)
271   : CustomActor(internal)
272   {
273   }
274
275   MyTestCustomActor( Impl::MyTestCustomActor& impl )
276   : CustomActor( impl )
277   {
278   }
279 };
280
281
282 class MyTestCustomActor2 : public CustomActor
283 {
284 public:
285
286   struct Property
287   {
288     enum
289     {
290       P1=Dali::PROPERTY_REGISTRATION_START_INDEX,
291       P2
292     };
293   };
294
295
296   MyTestCustomActor2()
297   {
298   }
299
300   static MyTestCustomActor2 New()
301   {
302     return MyTestCustomActor2(); // takes ownership
303   }
304
305   virtual ~MyTestCustomActor2()
306   {
307   }
308
309   static MyTestCustomActor2 DownCast( BaseHandle handle )
310   {
311     MyTestCustomActor2 result;
312
313     CustomActor custom = Dali::CustomActor::DownCast( handle );
314     if ( custom )
315     {
316       CustomActorImpl& customImpl = custom.GetImplementation();
317
318       Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
319
320       if (impl)
321       {
322         result = MyTestCustomActor2(customImpl.GetOwner());
323       }
324     }
325
326     return result;
327   }
328
329 private:
330
331   MyTestCustomActor2(Internal::CustomActor* internal)
332   : CustomActor(internal)
333   {
334   }
335
336   MyTestCustomActor2( Impl::MyTestCustomActor& impl )
337   : CustomActor( impl )
338   {
339   }
340 };
341
342 static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true );
343
344 PropertyRegistration P1( customTypeInit, "propertyOne", MyTestCustomActor2::Property::P1, Property::INTEGER, &SetProperty, &GetProperty );
345 PropertyRegistration P2( customTypeInit, "propertyTwo", MyTestCustomActor2::Property::P2, Property::STRING, &SetProperty, &GetProperty );
346
347
348 class MyTestCustomActor3 : public CustomActor
349 {
350 public:
351   MyTestCustomActor3()
352   {
353   }
354
355   static MyTestCustomActor3 New()
356   {
357     return MyTestCustomActor3(); // takes ownership
358   }
359
360   virtual ~MyTestCustomActor3()
361   {
362   }
363
364   static MyTestCustomActor3 DownCast( BaseHandle handle )
365   {
366     MyTestCustomActor3 result;
367
368     CustomActor custom = Dali::CustomActor::DownCast( handle );
369     if ( custom )
370     {
371       CustomActorImpl& customImpl = custom.GetImplementation();
372
373       Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
374
375       if (impl)
376       {
377         result = MyTestCustomActor3(customImpl.GetOwner());
378       }
379     }
380
381     return result;
382   }
383
384 private:
385
386   MyTestCustomActor3(Internal::CustomActor* internal)
387   : CustomActor(internal)
388   {
389   }
390
391   MyTestCustomActor3( Impl::MyTestCustomActor& impl )
392   : CustomActor( impl )
393   {
394   }
395 };
396
397 static TypeRegistration customTypeBadInit( typeid(MyTestCustomActor3), typeid(Dali::CustomActor), NULL, false );
398
399 BaseHandle CreateCustom(void)
400 {
401   return MyTestCustomActor::New();
402 }
403
404 static std::string lastSignalConnectionCustom;
405
406 bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
407 {
408   lastSignalConnectionCustom = signalName;
409
410   bool connected( true );
411
412   Dali::BaseHandle handle(object);
413   MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle);
414
415   if( "sig1" == signalName )
416   {
417     customActor.GetCustomSignal().Connect( tracker, functor );
418   }
419   else
420   {
421     // signalName does not match any signal
422     connected = false;
423   }
424
425   return connected;
426 }
427
428 bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
429 {
430   lastSignalConnectionCustom = "failed";
431
432   return false; // This is supposed to fail
433 }
434
435 struct CustomTestFunctor
436 {
437   CustomTestFunctor()
438   {
439     ++mTotalInstanceCount;
440     ++mCurrentInstanceCount;
441   }
442
443   CustomTestFunctor( const CustomTestFunctor& copyMe )
444   {
445     ++mTotalInstanceCount;
446     ++mCurrentInstanceCount;
447   }
448
449   ~CustomTestFunctor()
450   {
451     --mCurrentInstanceCount;
452   }
453
454   void operator()()
455   {
456     ++mCallbackCount;
457   }
458
459   static int mTotalInstanceCount;
460   static int mCurrentInstanceCount;
461   static int mCallbackCount;
462 };
463
464 int CustomTestFunctor::mTotalInstanceCount = 0;
465 int CustomTestFunctor::mCurrentInstanceCount = 0;
466 int CustomTestFunctor::mCallbackCount = 0;
467
468 static void ResetFunctorCounts()
469 {
470   CustomTestFunctor::mTotalInstanceCount   = 0;
471   CustomTestFunctor::mCurrentInstanceCount = 0;
472   CustomTestFunctor::mCallbackCount        = 0;
473 }
474
475 static std::string lastActionCustom;
476 bool DoActionCustom(BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/)
477 {
478   lastActionCustom = actionName;
479   return true;
480 }
481
482 // Custom type registration
483 static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom );
484
485 // Custom signals
486 static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom );
487 static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure );
488 static const int TEST_SIGNAL_COUNT = 2;
489
490 // Custom actions
491 static TypeAction customAction1( customType1, "act1", DoActionCustom);
492 static const int TEST_ACTION_COUNT = 1;
493
494 class TestConnectionTracker : public ConnectionTracker
495 {
496 public:
497
498   TestConnectionTracker()
499   {
500   }
501 };
502
503 BaseHandle CreateNamedActorType()
504 {
505   Actor actor = Actor::New();
506   actor.SetProperty( Actor::Property::NAME, "NamedActor" );
507   return actor;
508 }
509
510 TypeRegistration namedActorType( "MyNamedActor", typeid(Dali::Actor), CreateNamedActorType );
511 PropertyRegistration namedActorPropertyOne( namedActorType, "propName",  PROPERTY_REGISTRATION_START_INDEX, Property::BOOLEAN, &SetProperty, &GetProperty );
512
513 } // Anonymous namespace
514
515 // Note: No negative test case for UtcDaliTypeRegistryGet can be implemented.
516 int UtcDaliTypeRegistryGetP(void)
517 {
518   TestApplication application;
519
520   TypeRegistry registry = TypeRegistry::Get();
521   DALI_TEST_CHECK( registry );
522
523   END_TEST;
524 }
525
526 // Note: No negative test case for UtcDaliTypeRegistryConstructor can be implemented.
527 int UtcDaliTypeRegistryConstructorP(void)
528 {
529   TestApplication application;
530
531   TypeRegistry registry;
532   DALI_TEST_CHECK( !registry );
533   END_TEST;
534 }
535
536 // Note: No negative test case for UtcDaliTypeRegistryCopyConstructor can be implemented.
537 int UtcDaliTypeRegistryCopyConstructorP(void)
538 {
539   TestApplication application;
540
541   TypeRegistry registry = TypeRegistry::Get();
542   DALI_TEST_CHECK( registry );
543
544   TypeRegistry copy( registry );
545   DALI_TEST_CHECK( copy );
546
547   DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
548
549   END_TEST;
550 }
551
552 // Note: No negative test case for UtcDaliTypeRegistryAssignmentOperator can be implemented.
553 int UtcDaliTypeRegistryAssignmentOperatorP(void)
554 {
555   TestApplication application;
556
557   TypeRegistry registry = TypeRegistry::Get();
558   DALI_TEST_CHECK( registry );
559
560   TypeRegistry copy = registry;
561   DALI_TEST_CHECK( copy );
562   DALI_TEST_CHECK( registry == copy );
563
564   DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == copy.GetTypeInfo( "Actor" ).GetName() );
565
566   END_TEST;
567 }
568
569 int UtcDaliTypeRegistryMoveConstructor(void)
570 {
571   TestApplication application;
572
573   TypeRegistry registry = TypeRegistry::Get();
574   DALI_TEST_CHECK( registry );
575   DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
576   DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
577
578   TypeRegistry movedRegistry = std::move( registry );
579   DALI_TEST_CHECK( movedRegistry );
580   DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
581   DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
582   DALI_TEST_CHECK( !registry );
583
584   Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
585   DALI_TEST_CHECK( info );
586   DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
587   DALI_TEST_CHECK( info.GetName() == "Actor" );
588
589   Dali::TypeInfo movedInfo = std::move( info );
590   DALI_TEST_CHECK( movedInfo );
591   DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
592   DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
593   DALI_TEST_CHECK( !info );
594
595   END_TEST;
596 }
597
598 int UtcDaliTypeRegistryMoveAssignment(void)
599 {
600   TestApplication application;
601
602   TypeRegistry registry = TypeRegistry::Get();
603   DALI_TEST_CHECK( registry );
604   DALI_TEST_EQUALS( 16, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
605   DALI_TEST_CHECK( registry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
606
607   TypeRegistry movedRegistry;
608   movedRegistry = std::move( registry );
609   DALI_TEST_CHECK( movedRegistry );
610   DALI_TEST_EQUALS( 16, movedRegistry.GetBaseObject().ReferenceCount(), TEST_LOCATION );
611   DALI_TEST_CHECK( movedRegistry.GetTypeInfo( "Actor" ).GetName() == "Actor" );
612   DALI_TEST_CHECK( !registry );
613
614   Dali::TypeInfo info = movedRegistry.GetTypeInfo( "Actor" );
615   DALI_TEST_CHECK( info );
616   DALI_TEST_EQUALS( 2, info.GetBaseObject().ReferenceCount(), TEST_LOCATION );
617   DALI_TEST_CHECK( info.GetName() == "Actor" );
618
619   Dali::TypeInfo movedInfo;
620   movedInfo = std::move( info );
621   DALI_TEST_CHECK( movedInfo );
622   DALI_TEST_EQUALS( 2, movedInfo.GetBaseObject().ReferenceCount(), TEST_LOCATION );
623   DALI_TEST_CHECK( movedInfo.GetName() == "Actor" );
624   DALI_TEST_CHECK( !info );
625
626   END_TEST;
627 }
628
629 int UtcDaliTypeRegistryAssignP(void)
630 {
631   TestApplication application;
632
633   TypeRegistry registry = TypeRegistry::Get();
634   TypeRegistry registry2;
635   registry2 = registry;
636   DALI_TEST_CHECK( registry2 );
637
638   DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
639
640   END_TEST;
641 }
642
643 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
644 {
645   TestApplication application;
646
647   TypeRegistry registry = TypeRegistry::Get();
648
649   TypeInfo type;
650
651   // camera actor
652   type = registry.GetTypeInfo( "CameraActor" );
653   DALI_TEST_CHECK( type );
654   CameraActor ca = CameraActor::DownCast(type.CreateInstance());
655   DALI_TEST_CHECK( ca );
656   application.GetScene().Add( ca );
657   application.Render();
658
659   // animations
660   type = registry.GetTypeInfo( "Animation" );
661   DALI_TEST_CHECK( type );
662   Animation an = Animation::DownCast(type.CreateInstance());
663   DALI_TEST_CHECK( an );
664   an.Play();
665   application.Render();
666
667   END_TEST;
668 }
669
670 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameN(void)
671 {
672   TestApplication application;
673
674   TypeRegistry registry = TypeRegistry::Get();
675
676   TypeInfo type;
677
678   type = registry.GetTypeInfo( "MyDummyActor" );
679   DALI_TEST_CHECK( !type );
680
681   END_TEST;
682 }
683
684 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdP(void)
685 {
686   TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "CameraActor" );
687   TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::CameraActor) );
688
689   DALI_TEST_CHECK( named_type );
690   DALI_TEST_CHECK( typeinfo_type );
691
692   // Check named and typeid are equivalent
693   DALI_TEST_CHECK( named_type == typeinfo_type );
694
695   DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() );
696   DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() );
697
698   END_TEST;
699 }
700
701 int UtcDaliTypeRegistryGetTypeInfoFromTypeIdN(void)
702 {
703   TestApplication application;
704   TypeRegistry typeRegistry = TypeRegistry::Get();
705
706   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(Vector2) );
707   DALI_TEST_CHECK( !typeInfo );
708
709   END_TEST;
710 }
711
712 int UtcDaliTypeRegistryGetTypeNameCountP(void)
713 {
714   TestApplication application;
715   TypeRegistry typeRegistry = TypeRegistry::Get();
716   TypeInfo type;
717
718   for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
719   {
720     type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
721     DALI_TEST_CHECK( type );
722   }
723
724   END_TEST;
725 }
726
727
728 int UtcDaliTypeRegistryGetTypeNamesP(void)
729 {
730   TestApplication application;
731   TypeRegistry typeRegistry = TypeRegistry::Get();
732   TypeInfo type;
733
734   for(size_t i = 0; i < typeRegistry.GetTypeNameCount(); i++)
735   {
736     type = typeRegistry.GetTypeInfo( typeRegistry.GetTypeName(i) );
737     DALI_TEST_CHECK( type );
738   }
739
740   END_TEST;
741 }
742
743
744 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
745 int UtcDaliTypeRegistryTypeRegistrationNotCallingCreateOnInitP(void)
746 {
747   ResetFunctorCounts();
748
749   TestApplication application;
750
751   TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
752   DALI_TEST_CHECK( type );
753
754   TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
755   DALI_TEST_CHECK( baseType );
756
757   BaseHandle handle = type.CreateInstance();
758   DALI_TEST_CHECK( handle );
759
760   MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
761   DALI_TEST_CHECK( customHandle );
762
763   DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
764
765   DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
766
767   {
768     TestConnectionTracker tracker;
769
770     bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
771     DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
772     DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
773     DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
774     DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
775
776     DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
777     customHandle.GetCustomSignal().Emit();
778     DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
779     DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
780     DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
781   }
782   // tracker should automatically disconnect here
783   DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
784   DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
785
786   // Test that functor is disconnected
787   DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
788   customHandle.GetCustomSignal().Emit();
789   DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
790   DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
791   DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
792
793   Property::Map attributes;
794   handle.DoAction("act1", attributes);
795   DALI_TEST_CHECK( lastActionCustom == "act1" );
796   END_TEST;
797 }
798
799 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
800 int UtcDaliTypeRegistryTypeRegistrationCallingCreateOnInitP(void)
801 {
802   TestApplication application;
803
804   DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() );
805
806   DALI_TEST_CHECK( true == CreateCustomInitCalled );
807   TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" );
808   DALI_TEST_CHECK( type );
809   END_TEST;
810 }
811
812 // Note: No negative test case for UtcDaliTypeRegistryTypeRegistration can be implemented.
813 int UtcDaliTypeRegistryTypeRegistrationForNamedTypeP(void)
814 {
815   TestApplication application;
816
817   // Create Named Actor Type
818   TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyNamedActor" );
819   DALI_TEST_CHECK( type );
820
821   BaseHandle namedHandle = type.CreateInstance();
822   DALI_TEST_CHECK( namedHandle );
823   Actor namedActor( Actor::DownCast( namedHandle ) );
824   DALI_TEST_CHECK( namedActor );
825
826   DALI_TEST_CHECK( namedActor.GetProperty< std::string >( Actor::Property::NAME ) == "NamedActor" );
827   DALI_TEST_CHECK( type.GetName() == "MyNamedActor" );
828   DALI_TEST_CHECK( type.GetBaseName() == "Actor" );
829
830   END_TEST;
831 }
832
833 int UtcDaliTypeRegistryRegisteredNameP(void)
834 {
835   TestApplication application;
836
837   DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
838
839   TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
840   DALI_TEST_CHECK( baseType );
841
842   BaseHandle handle = baseType.CreateInstance();
843
844   DALI_TEST_CHECK( true == CreateCustomNamedInitCalled );
845   TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName );
846   DALI_TEST_CHECK( type );
847   END_TEST;
848 }
849
850
851 int UtcDaliTypeRegistryRegisteredNameN(void)
852 {
853   TestApplication application;
854
855   DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() );
856
857   TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName );
858   DALI_TEST_CHECK( baseType );
859
860   // should cause an assert because we're registering same type twice
861   // once statically at the start of this file, then again now
862   try
863   {
864     TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit );
865     tet_result( TET_FAIL );
866   }
867   catch ( DaliException& e )
868   {
869     DALI_TEST_ASSERT( e, "Duplicate type name in Type Registration", TEST_LOCATION );
870   }
871
872   END_TEST;
873 }
874
875
876 int UtcDaliTypeRegistrySignalConnectorTypeP(void)
877 {
878   ResetFunctorCounts();
879
880   TestApplication application;
881
882   TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
883   DALI_TEST_CHECK( type );
884
885   BaseHandle handle = type.CreateInstance();
886   DALI_TEST_CHECK( handle );
887
888   MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
889   DALI_TEST_CHECK( customHandle );
890
891   {
892     TestConnectionTracker tracker;
893
894     bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() );
895     DALI_TEST_EQUALS( connected, true, TEST_LOCATION );
896     DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" );
897     DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
898     DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
899
900     DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
901     customHandle.GetCustomSignal().Emit();
902     DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
903     DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
904     DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION );
905   }
906   // tracker should automatically disconnect here
907   DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
908   DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
909
910   // Test that functor is disconnected
911   DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION );
912   customHandle.GetCustomSignal().Emit();
913   DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION );
914   DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
915   DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION );
916
917   END_TEST;
918 }
919
920 int UtcDaliTypeRegistrySignalConnectorTypeN(void)
921 {
922   // Test what happens when signal connnector (DoConnectSignalFailure method) returns false
923
924   ResetFunctorCounts();
925
926   TestApplication application;
927
928   TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
929   DALI_TEST_CHECK( type );
930
931   TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
932   DALI_TEST_CHECK( baseType );
933
934   BaseHandle handle = type.CreateInstance();
935   DALI_TEST_CHECK( handle );
936
937   MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle );
938   DALI_TEST_CHECK( customHandle );
939
940   DALI_TEST_EQUALS( type.GetActionCount(), TEST_ACTION_COUNT + baseType.GetActionCount(), TEST_LOCATION );
941
942   DALI_TEST_EQUALS( type.GetSignalCount(), TEST_SIGNAL_COUNT + baseType.GetSignalCount(), TEST_LOCATION );
943
944   {
945     TestConnectionTracker tracker;
946
947     bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() );
948     DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION );
949     DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" );
950     DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION );
951     DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION );
952
953     // Should be a NOOP
954     DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
955     customHandle.GetCustomSignal().Emit();
956     DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
957   }
958   // tracker should have nothing to disconnect here
959
960   // Should be a NOOP
961   DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION );
962   customHandle.GetCustomSignal().Emit();
963   DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION );
964   END_TEST;
965 }
966
967 int UtcDaliTypeRegistryTypeActionP(void)
968 {
969   ResetFunctorCounts();
970
971   TestApplication application;
972
973   TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
974   DALI_TEST_CHECK( type );
975
976   BaseHandle handle = type.CreateInstance();
977   DALI_TEST_CHECK( handle );
978
979   Property::Map attributes;
980   DALI_TEST_CHECK( handle.DoAction("act1", attributes) );
981   DALI_TEST_CHECK( lastActionCustom == "act1" );
982
983   END_TEST;
984 }
985
986 int UtcDaliTypeRegistryTypeActionN(void)
987 {
988   ResetFunctorCounts();
989
990   TestApplication application;
991
992   TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" );
993   DALI_TEST_CHECK( type );
994
995   BaseHandle handle = type.CreateInstance();
996   DALI_TEST_CHECK( handle );
997
998   Property::Map attributes;
999   DALI_TEST_CHECK( !handle.DoAction( "unknownAction",  attributes ) );
1000
1001   END_TEST;
1002 }
1003
1004 int UtcDaliTypeRegistryPropertyRegistrationP(void)
1005 {
1006   TestApplication application;
1007   TypeRegistry typeRegistry = TypeRegistry::Get();
1008
1009   // Check property count before property registration
1010   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1011   DALI_TEST_CHECK( typeInfo );
1012   BaseHandle handle = typeInfo.CreateInstance();
1013   DALI_TEST_CHECK( handle );
1014   Actor customActor = Actor::DownCast( handle );
1015   DALI_TEST_CHECK( customActor );
1016   unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1017
1018   std::string propertyName( "prop1" );
1019   int propertyIndex( PROPERTY_REGISTRATION_START_INDEX );
1020   Property::Type propertyType( Property::BOOLEAN );
1021   PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty );
1022
1023   // Check property count after registration
1024   unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() );
1025   DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION );
1026
1027   // Add custom property and check property count
1028   customActor.RegisterProperty( "customProp1",   true );
1029   unsigned int customPropertyCount( customActor.GetPropertyCount() );
1030   DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION );
1031
1032   // Set the property, ensure SetProperty called
1033   DALI_TEST_CHECK( !setPropertyCalled );
1034   customActor.SetProperty( propertyIndex, false );
1035   DALI_TEST_CHECK( setPropertyCalled );
1036
1037   // Get the property, ensure GetProperty called
1038   DALI_TEST_CHECK( !getPropertyCalled );
1039   (void)customActor.GetProperty< bool >( propertyIndex );
1040   DALI_TEST_CHECK( getPropertyCalled );
1041
1042   // Get the property using GetCurrentProperty and ensure GetProperty is called
1043   getPropertyCalled = false;
1044   DALI_TEST_CHECK( !getPropertyCalled );
1045   customActor.GetCurrentProperty< bool >( propertyIndex );
1046   DALI_TEST_CHECK( getPropertyCalled );
1047
1048   // Check the property name
1049   DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1050   DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1051
1052   // Check the property index
1053   DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1054
1055   // Check the property type
1056   DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1057
1058   // Check property count of type-info is 1
1059   Property::IndexContainer indices;
1060   typeInfo.GetPropertyIndices( indices );
1061
1062   size_t typePropertyCount = typeInfo.GetPropertyCount();
1063   DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION );
1064   DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION );
1065
1066   // Ensure indices returned from actor and customActor differ by two
1067   Actor actor = Actor::New();
1068   actor.GetPropertyIndices( indices );
1069   unsigned int actorIndices = indices.Size();
1070   customActor.GetPropertyIndices( indices );
1071   unsigned int customActorIndices = indices.Size();
1072   DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1073   END_TEST;
1074 }
1075
1076 int UtcDaliTypeRegistryPropertyRegistrationN(void)
1077 {
1078   TestApplication application;
1079   TypeRegistry typeRegistry = TypeRegistry::Get();
1080
1081   // Attempt to register a property type out-of-bounds index (less than)
1082   try
1083   {
1084     PropertyRegistration property1( customType1, "propName",  PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1085     tet_result( TET_FAIL );
1086   }
1087   catch ( DaliException& e )
1088   {
1089     DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1090   }
1091
1092   // Attempt to register a property type out-of-bounds index (greater than)
1093   try
1094   {
1095     PropertyRegistration property1( customType1, "propName",  PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty );
1096     tet_result( TET_FAIL );
1097   }
1098   catch ( DaliException& e )
1099   {
1100     DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1101   }
1102
1103   END_TEST;
1104 }
1105
1106 int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void)
1107 {
1108   TestApplication application;
1109   TypeRegistry typeRegistry = TypeRegistry::Get();
1110
1111   // Check property count before property registration
1112   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1113   DALI_TEST_CHECK( typeInfo );
1114   BaseHandle handle = typeInfo.CreateInstance();
1115   DALI_TEST_CHECK( handle );
1116   Actor customActor = Actor::DownCast( handle );
1117   DALI_TEST_CHECK( customActor );
1118   application.GetScene().Add(customActor);
1119
1120   unsigned int customPropertyCount( customActor.GetPropertyCount() );
1121
1122   // Register animatable property
1123   std::string animatablePropertyName( "animatableProp1" );
1124   int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1125   Property::Type animatablePropertyType( Property::FLOAT );
1126   AnimatablePropertyRegistration animatableProperty( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1127
1128   // Check property count after registration
1129   DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1130
1131   // Set the animatable property value
1132   customActor.SetProperty( animatablePropertyIndex, 25.0f );
1133
1134   // Render and notify
1135   application.SendNotification();
1136   application.Render();
1137
1138   // Check the animatable property value
1139   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.f, TEST_LOCATION );
1140
1141   // Check the animatable property name
1142   DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1143
1144   // Check the animatable property index
1145   DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1146
1147   // Check the animatable property type
1148   DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1149
1150   // Check property count of type-info is 1
1151   Property::IndexContainer indices;
1152   typeInfo.GetPropertyIndices( indices );
1153   DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1154
1155   // Ensure indices returned from actor and customActor differ by one
1156   Actor actor = Actor::New();
1157   actor.GetPropertyIndices( indices );
1158   unsigned int actorIndices = indices.Size();
1159   customActor.GetPropertyIndices( indices );
1160   unsigned int customActorIndices = indices.Size();
1161   DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1162
1163   // check that the property is animatable
1164   Animation animation = Animation::New(0.2f);
1165   animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 15.f, AlphaFunction::LINEAR );
1166   animation.Play();
1167
1168   // Target value should change straight away
1169   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 15.0f, TEST_LOCATION );
1170
1171   // Render and notify, animation play for 0.05 seconds
1172   application.SendNotification();
1173   application.Render(50);
1174   DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1175   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 22.5f, TEST_LOCATION );
1176
1177   // Render and notify, animation play for another 0.1 seconds
1178   application.SendNotification();
1179   application.Render(100);
1180   DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1181   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1182
1183   END_TEST;
1184 }
1185
1186 int UtcDaliTypeRegistryAnimatablePropertyRegistrationN(void)
1187 {
1188   TestApplication application;
1189   TypeRegistry typeRegistry = TypeRegistry::Get();
1190
1191   // Attempt to register an animatable property type out-of-bounds index (less than)
1192   try
1193   {
1194     AnimatablePropertyRegistration property1( customType1, "animPropName",   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1195     tet_result( TET_FAIL );
1196   }
1197   catch ( DaliException& e )
1198   {
1199     DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1200   }
1201
1202   // Attempt to register an animatable property type out-of-bounds index (greater than)
1203   try
1204   {
1205     AnimatablePropertyRegistration property1( customType1, "animPropName",   ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1206     tet_result( TET_FAIL );
1207   }
1208   catch ( DaliException& e )
1209   {
1210     DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1211   }
1212
1213   END_TEST;
1214 }
1215
1216 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void)
1217 {
1218   TestApplication application;
1219   TypeRegistry typeRegistry = TypeRegistry::Get();
1220
1221   // Check property count before property registration
1222   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1223   DALI_TEST_CHECK( typeInfo );
1224   BaseHandle handle = typeInfo.CreateInstance();
1225   DALI_TEST_CHECK( handle );
1226   Actor customActor = Actor::DownCast( handle );
1227   DALI_TEST_CHECK( customActor );
1228   application.GetScene().Add(customActor);
1229
1230   unsigned int customPropertyCount( customActor.GetPropertyCount() );
1231
1232   // Register animatable property
1233   std::string animatablePropertyName( "animatableProp1" );
1234   int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1235   AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, 10.f );
1236
1237   // Check property count after registration
1238   DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1239
1240   // Render and notify
1241   application.SendNotification();
1242   application.Render();
1243
1244   // Check the animatable property value
1245   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 10.f, TEST_LOCATION );
1246
1247   // Check the animatable property name
1248   DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1249
1250   // Check the animatable property index
1251   DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1252
1253   // Check the animatable property type
1254   DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION );
1255
1256   // Check property count of type-info
1257   Property::IndexContainer indices;
1258   typeInfo.GetPropertyIndices( indices );
1259   DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1260
1261   // Ensure indices returned from actor and customActor differ by one
1262   Actor actor = Actor::New();
1263   actor.GetPropertyIndices( indices );
1264   unsigned int actorIndices = indices.Size();
1265   customActor.GetPropertyIndices( indices );
1266   unsigned int customActorIndices = indices.Size();
1267   DALI_TEST_EQUALS( actorIndices + 1u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1268
1269   // check that the property is animatable
1270   Animation animation = Animation::New(0.2f);
1271   animation.AnimateTo( Property( customActor, animatablePropertyIndex ), 20.f, AlphaFunction::LINEAR );
1272   animation.Play();
1273
1274   // Target value should change straight away
1275   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 20.0f, TEST_LOCATION );
1276
1277   // Render and notify, animation play for 0.05 seconds
1278   application.SendNotification();
1279   application.Render(50);
1280   DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION );
1281   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 12.5f, TEST_LOCATION );
1282
1283   // Render and notify, animation play for another 0.1 seconds
1284   application.SendNotification();
1285   application.Render(100);
1286   DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION );
1287   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 17.5f, TEST_LOCATION );
1288
1289   END_TEST;
1290 }
1291
1292 int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultN(void)
1293 {
1294   TestApplication application;
1295   TypeRegistry typeRegistry = TypeRegistry::Get();
1296
1297   // Attempt to register an animatable property type out-of-bounds index (less than)
1298   try
1299   {
1300     AnimatablePropertyRegistration property1( customType1, "animPropName",   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, false );
1301     tet_result( TET_FAIL );
1302   }
1303   catch ( DaliException& e )
1304   {
1305     DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1306   }
1307
1308   // Attempt to register an animatable property type out-of-bounds index (greater than)
1309   try
1310   {
1311     AnimatablePropertyRegistration property1( customType1, "animPropName",   ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, true );
1312     tet_result( TET_FAIL );
1313   }
1314   catch ( DaliException& e )
1315   {
1316     DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1317   }
1318
1319   END_TEST;
1320 }
1321
1322 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void)
1323 {
1324   TestApplication application;
1325   TypeRegistry typeRegistry = TypeRegistry::Get();
1326
1327   // Check property count before property registration
1328   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1329   DALI_TEST_CHECK( typeInfo );
1330   BaseHandle handle = typeInfo.CreateInstance();
1331   DALI_TEST_CHECK( handle );
1332   Actor customActor = Actor::DownCast( handle );
1333   DALI_TEST_CHECK( customActor );
1334
1335   unsigned int customPropertyCount( customActor.GetPropertyCount() );
1336
1337   // Register animatable property
1338   std::string animatablePropertyName( "animatableProp1" );
1339   int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1340   Property::Type animatablePropertyType( Property::VECTOR2 );
1341   AnimatablePropertyRegistration animatableProperty1( customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType );
1342
1343   // Check property count after registration
1344   DALI_TEST_EQUALS( customPropertyCount + 1u, customActor.GetPropertyCount(), TEST_LOCATION );
1345
1346   // Set the animatable property value
1347   customActor.SetProperty( animatablePropertyIndex, Vector2(25.0f, 50.0f) );
1348
1349   // Render and notify
1350   application.SendNotification();
1351   application.Render();
1352
1353   // Check the animatable property value
1354   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(25.0f, 50.0f), TEST_LOCATION );
1355
1356   // Check the animatable property name
1357   DALI_TEST_EQUALS( customActor.GetPropertyName( animatablePropertyIndex ), animatablePropertyName, TEST_LOCATION );
1358
1359   // Check the animatable property index
1360   DALI_TEST_EQUALS( customActor.GetPropertyIndex( animatablePropertyName ), animatablePropertyIndex, TEST_LOCATION );
1361
1362   // Check the animatable property type
1363   DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION );
1364
1365   // Check property count of type-info
1366   Property::IndexContainer indices;
1367   typeInfo.GetPropertyIndices( indices );
1368   DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION );
1369
1370   // Register animatable property components
1371   std::string animatablePropertyComponentName1( "animatableProp1X" );
1372   int animatablePropertyComponentIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1 );
1373   AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, animatablePropertyComponentName1, animatablePropertyComponentIndex1, animatablePropertyIndex, 0 );
1374
1375   std::string animatablePropertyComponentName2( "animatableProp1Y" );
1376   int animatablePropertyComponentIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1377   AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, animatablePropertyComponentName2, animatablePropertyComponentIndex2, animatablePropertyIndex, 1 );
1378
1379   // Check property count after registration
1380   DALI_TEST_EQUALS( customPropertyCount + 3u, customActor.GetPropertyCount(), TEST_LOCATION );
1381
1382   // Check the animatable property component value
1383   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 25.0f, TEST_LOCATION );
1384   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1385
1386   // Set the animatable property component value
1387   customActor.SetProperty( animatablePropertyComponentIndex1, 150.0f );
1388
1389   // Render and notify
1390   application.SendNotification();
1391   application.Render();
1392
1393   // Check the animatable property value
1394   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 50.0f), TEST_LOCATION );
1395   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1396   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 50.0f, TEST_LOCATION );
1397
1398   // Set the animatable property component value
1399   customActor.SetProperty( animatablePropertyComponentIndex2, 225.0f );
1400
1401   // Render and notify
1402   application.SendNotification();
1403   application.Render();
1404
1405   // Check the animatable property value
1406   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( animatablePropertyIndex ), Vector2(150.0f, 225.0f), TEST_LOCATION );
1407   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex1 ), 150.0f, TEST_LOCATION );
1408   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1409
1410   // Ensure indices returned from actor and customActor differ by three
1411   Actor actor = Actor::New();
1412   actor.GetPropertyIndices( indices );
1413   unsigned int actorIndices = indices.Size();
1414   customActor.GetPropertyIndices( indices );
1415   unsigned int customActorIndices = indices.Size();
1416   DALI_TEST_EQUALS( actorIndices + 3u, customActorIndices, TEST_LOCATION ); // Custom property + registered property
1417
1418   // Attempt to animate component property, it should not crash
1419   Animation animation = Animation::New( 1.0f );
1420   animation.AnimateTo( Property( customActor, animatablePropertyComponentIndex1 ), 200.0f );
1421   animation.Play();
1422
1423   // Check the property value
1424   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( animatablePropertyIndex ), Vector2(200.0f, 225.0f), TEST_LOCATION );
1425   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex1 ), 200.0f, TEST_LOCATION );
1426   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyComponentIndex2 ), 225.0f, TEST_LOCATION );
1427
1428   END_TEST;
1429 }
1430
1431 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector2AnimateByP(void)
1432 {
1433   TestApplication application;
1434   TypeRegistry typeRegistry = TypeRegistry::Get();
1435
1436   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1437   DALI_TEST_CHECK( typeInfo );
1438   BaseHandle handle = typeInfo.CreateInstance();
1439   DALI_TEST_CHECK( handle );
1440   Actor customActor = Actor::DownCast( handle );
1441   DALI_TEST_CHECK( customActor );
1442
1443   const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1444   const unsigned int xComponentIndex = index + 1;
1445   const unsigned int yComponentIndex = index + 2;
1446   const Vector2 initialValue( 20.0f, 40.0f );
1447
1448   // Register animatable property & its components
1449   AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1450   AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1451   AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1452
1453   // Check the animatable property value
1454   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1455   DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1456   DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1457
1458   // Render and notify
1459   application.SendNotification();
1460   application.Render();
1461
1462   // Check the animatable property current value
1463   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( index ), initialValue, TEST_LOCATION );
1464   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1465   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1466
1467   // Do an AnimateBy
1468   const Vector2 targetValue( 45.0f, 53.0f );
1469   const Vector2 relativeValue( targetValue - initialValue );
1470
1471   Animation animation = Animation::New( 1.0f );
1472   animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1473   animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1474   animation.Play();
1475
1476   // Target values should change straight away
1477   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( index ), targetValue, TEST_LOCATION );
1478   DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1479   DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1480
1481   END_TEST;
1482 }
1483
1484 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector3AnimateByP(void)
1485 {
1486   TestApplication application;
1487   TypeRegistry typeRegistry = TypeRegistry::Get();
1488
1489   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1490   DALI_TEST_CHECK( typeInfo );
1491   BaseHandle handle = typeInfo.CreateInstance();
1492   DALI_TEST_CHECK( handle );
1493   Actor customActor = Actor::DownCast( handle );
1494   DALI_TEST_CHECK( customActor );
1495
1496   const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1497   const unsigned int xComponentIndex = index + 1;
1498   const unsigned int yComponentIndex = index + 2;
1499   const unsigned int zComponentIndex = index + 3;
1500   const Vector3 initialValue( 20.0f, 40.0f, 50.0f );
1501
1502   // Register animatable property & its components
1503   AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1504   AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1505   AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1506   AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1507
1508   // Check the animatable property value
1509   DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1510   DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1511   DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1512   DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1513
1514   // Render and notify
1515   application.SendNotification();
1516   application.Render();
1517
1518   // Check the animatable property current value
1519   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( index ), initialValue, TEST_LOCATION );
1520   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1521   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1522   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1523
1524   // Do an AnimateBy
1525   const Vector3 targetValue( 45.0f, 53.0f, 25.0f );
1526   const Vector3 relativeValue( targetValue - initialValue );
1527
1528   Animation animation = Animation::New( 1.0f );
1529   animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1530   animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1531   animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1532   animation.Play();
1533
1534   // Target values should change straight away
1535   DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( index ), targetValue, TEST_LOCATION );
1536   DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1537   DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1538   DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1539
1540   END_TEST;
1541 }
1542
1543 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationVector4AnimateByP(void)
1544 {
1545   TestApplication application;
1546   TypeRegistry typeRegistry = TypeRegistry::Get();
1547
1548   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1549   DALI_TEST_CHECK( typeInfo );
1550   BaseHandle handle = typeInfo.CreateInstance();
1551   DALI_TEST_CHECK( handle );
1552   Actor customActor = Actor::DownCast( handle );
1553   DALI_TEST_CHECK( customActor );
1554
1555   const unsigned int index = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX;
1556   const unsigned int xComponentIndex = index + 1;
1557   const unsigned int yComponentIndex = index + 2;
1558   const unsigned int zComponentIndex = index + 3;
1559   const unsigned int wComponentIndex = index + 4;
1560   const Vector4 initialValue( 20.0f, 40.0f, 50.0f, 60.0f );
1561
1562   // Register animatable property & its components
1563   AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1", index, initialValue );
1564   AnimatablePropertyComponentRegistration animatablePropertyComponent1( customType1, "animatableProp1X", xComponentIndex, index, 0 );
1565   AnimatablePropertyComponentRegistration animatablePropertyComponent2( customType1, "animatableProp1Y", yComponentIndex, index, 1 );
1566   AnimatablePropertyComponentRegistration animatablePropertyComponent3( customType1, "animatableProp1Z", zComponentIndex, index, 2 );
1567   AnimatablePropertyComponentRegistration animatablePropertyComponent4( customType1, "animatableProp1W", wComponentIndex, index, 3 );
1568
1569   // Check the animatable property value
1570   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1571   DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1572   DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1573   DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1574   DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1575
1576   // Render and notify
1577   application.SendNotification();
1578   application.Render();
1579
1580   // Check the animatable property current value
1581   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( index ), initialValue, TEST_LOCATION );
1582   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( xComponentIndex ), initialValue.x, TEST_LOCATION );
1583   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( yComponentIndex ), initialValue.y, TEST_LOCATION );
1584   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( zComponentIndex ), initialValue.z, TEST_LOCATION );
1585   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( wComponentIndex ), initialValue.w, TEST_LOCATION );
1586
1587   // Do an AnimateBy
1588   const Vector4 targetValue( 45.0f, 53.0f, 25.0f, 13.0f );
1589   const Vector4 relativeValue( targetValue - initialValue );
1590
1591   Animation animation = Animation::New( 1.0f );
1592   animation.AnimateBy( Property( customActor, xComponentIndex ), relativeValue.x );
1593   animation.AnimateBy( Property( customActor, yComponentIndex ), relativeValue.y );
1594   animation.AnimateBy( Property( customActor, zComponentIndex ), relativeValue.z );
1595   animation.AnimateBy( Property( customActor, wComponentIndex ), relativeValue.w );
1596   animation.Play();
1597
1598   // Target values should change straight away
1599   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( index ), targetValue, TEST_LOCATION );
1600   DALI_TEST_EQUALS( customActor.GetProperty< float >( xComponentIndex ), targetValue.x, TEST_LOCATION );
1601   DALI_TEST_EQUALS( customActor.GetProperty< float >( yComponentIndex ), targetValue.y, TEST_LOCATION );
1602   DALI_TEST_EQUALS( customActor.GetProperty< float >( zComponentIndex ), targetValue.z, TEST_LOCATION );
1603   DALI_TEST_EQUALS( customActor.GetProperty< float >( wComponentIndex ), targetValue.w, TEST_LOCATION );
1604
1605   END_TEST;
1606 }
1607
1608 int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationN(void)
1609 {
1610   TestApplication application;
1611   TypeRegistry typeRegistry = TypeRegistry::Get();
1612
1613   // Register animatable property with the type of Vector2
1614   int animatablePropertyIndex1( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
1615   AnimatablePropertyRegistration animatableProperty1( customType1, "animatableProp1",   animatablePropertyIndex1, Property::VECTOR2 );
1616
1617   // Attempt to register an animatable property component out-of-bounds index (less than)
1618   try
1619   {
1620     AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X",    ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX - 1, animatablePropertyIndex1, 0 );
1621     tet_result( TET_FAIL );
1622   }
1623   catch ( DaliException& e )
1624   {
1625     DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1626   }
1627
1628   // Attempt to register an animatable property component out-of-bounds index (greater than)
1629   try
1630   {
1631     AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X",    ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX + 1, animatablePropertyIndex1, 0 );
1632     tet_result( TET_FAIL );
1633   }
1634   catch ( DaliException& e )
1635   {
1636     DALI_TEST_ASSERT( e, "( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1637   }
1638
1639   // Register an animatable property component
1640   AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp1X",    ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1, animatablePropertyIndex1, 0 );
1641
1642   // Attempt to register another animatable property component with the same component index
1643   try
1644   {
1645     AnimatablePropertyComponentRegistration propertyComponent2( customType1, "animatableProp1Y",    ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2, animatablePropertyIndex1, 0 );
1646     tet_result( TET_FAIL );
1647   }
1648   catch ( DaliException& e )
1649   {
1650     DALI_TEST_ASSERT( e, "Property component already registered", TEST_LOCATION );
1651   }
1652
1653   // Register animatable property with the type of boolean
1654   int animatablePropertyIndex2( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2 );
1655   AnimatablePropertyRegistration animatableProperty2( customType1, "animatableProp2",   animatablePropertyIndex2, Property::BOOLEAN );
1656
1657   // Attempt to register an animatable property component for the above property with boolean type
1658   try
1659   {
1660     AnimatablePropertyComponentRegistration propertyComponent1( customType1, "animatableProp2X",    animatablePropertyIndex2 + 1, animatablePropertyIndex2, 0 );
1661     tet_result( TET_FAIL );
1662   }
1663   catch ( DaliException& e )
1664   {
1665     DALI_TEST_ASSERT( e, "Base property does not support component", TEST_LOCATION );
1666   }
1667
1668   END_TEST;
1669 }
1670
1671 int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
1672 {
1673   TestApplication application;
1674   TypeRegistry typeRegistry = TypeRegistry::Get();
1675
1676   // Check property count before property registration
1677   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
1678   DALI_TEST_CHECK( typeInfo );
1679   BaseHandle handle = typeInfo.CreateInstance();
1680   DALI_TEST_CHECK( handle );
1681   Actor customActor = Actor::DownCast( handle );
1682   DALI_TEST_CHECK( customActor );
1683   unsigned int initialPropertyCount( customActor.GetPropertyCount() );
1684
1685   // Register child properties to the parent
1686   std::string propertyName( "childProp1" );
1687   int propertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX );
1688   Property::Type propertyType( Property::BOOLEAN );
1689   ChildPropertyRegistration childProperty1( customType1, propertyName, propertyIndex, propertyType );
1690
1691   std::string propertyName2( "childProp2" );
1692   int propertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 );
1693   Property::Type propertyType2( Property::INTEGER );
1694   ChildPropertyRegistration childProperty2( customType1, propertyName2, propertyIndex2, propertyType2 );
1695
1696   std::string propertyName3( "childProp3" );
1697   int propertyIndex3( CHILD_PROPERTY_REGISTRATION_START_INDEX + 2 );
1698   Property::Type propertyType3( Property::FLOAT );
1699   ChildPropertyRegistration childProperty3( customType1, propertyName3, propertyIndex3, propertyType3 );
1700
1701   std::string propertyName4( "childProp4" );
1702   int propertyIndex4( CHILD_PROPERTY_REGISTRATION_START_INDEX + 3 );
1703   Property::Type propertyType4( Property::INTEGER );
1704   ChildPropertyRegistration childProperty4( customType1, propertyName4, propertyIndex4, propertyType4 );
1705
1706   // Check property count are not changed because the child properties will not be created for the parent
1707   DALI_TEST_EQUALS( initialPropertyCount, customActor.GetPropertyCount(), TEST_LOCATION );
1708
1709   // check the child property type
1710   Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
1711   Property::Type type = typeInfoImpl.GetChildPropertyType( typeInfoImpl.GetChildPropertyIndex("childProp4") );
1712   DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
1713
1714   std::string unRegisteredChildName( typeInfoImpl.GetChildPropertyName( CHILD_PROPERTY_REGISTRATION_START_INDEX + 4 ) );
1715   DALI_TEST_EQUALS( unRegisteredChildName, "", TEST_LOCATION );
1716
1717   // Create a child actor
1718   Actor childActor = Actor::New();
1719   DALI_TEST_CHECK( childActor );
1720   unsigned int initialChildActorPropertyCount( childActor.GetPropertyCount() );
1721
1722   // The type of child properties should be Property::None as the child hasn't registered any child property yet.
1723   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), Property::NONE, TEST_LOCATION );
1724   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), Property::NONE, TEST_LOCATION );
1725   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), Property::NONE, TEST_LOCATION );
1726   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), Property::NONE, TEST_LOCATION );
1727
1728   // Set the value for the first child property when the child actor doesn't have a parent yet
1729   childActor.SetProperty(propertyIndex, true);
1730
1731   // Check that the first child property is dynamically created
1732   DALI_TEST_EQUALS( initialChildActorPropertyCount + 1u, childActor.GetPropertyCount(), TEST_LOCATION );
1733
1734   // Check the first child property value
1735   DALI_TEST_EQUALS( childActor.GetProperty< bool >( propertyIndex ), true, TEST_LOCATION );
1736
1737   // Check the first child property type
1738   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1739
1740   // Check that the first child property have no name, as it doesn't have a parent yet.
1741   DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), "", TEST_LOCATION );
1742
1743   // Check that the first property can't be accessed through its name, as it doesn't have a parent yet.
1744   DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), Property::INVALID_INDEX, TEST_LOCATION );
1745
1746   // Create a custom property for the child with the same name as the second child property registered to the parent
1747   Property::Index customPropertyIndex = childActor.RegisterProperty(propertyName2, 100, Property::READ_WRITE);
1748
1749   // Check that the custom property is created
1750   DALI_TEST_EQUALS( initialChildActorPropertyCount + 2u, childActor.GetPropertyCount(), TEST_LOCATION );
1751
1752   // Check the property value
1753   DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1754
1755   // Check the property index
1756   DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), customPropertyIndex, TEST_LOCATION );
1757
1758   // Check the property type
1759   DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1760
1761   // Check the property name
1762   DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex ), propertyName2, TEST_LOCATION );
1763
1764   // Now add the child actor to the parent
1765   customActor.Add( childActor );
1766
1767   // Check that the first child property now has the correct name as previously registered to the parent
1768   DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1769
1770   // Check that the child property index for the first child property can now be retrieved through its child property name
1771   DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1772
1773   // Check that the second child property now has the correct index as previously registered to the parent
1774   DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex2 ), propertyName2, TEST_LOCATION );
1775
1776   // Check that the second child property can be accessed through both its custom property index and its child property index
1777   DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex ), 100, TEST_LOCATION );
1778   DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex2 ), 100, TEST_LOCATION );
1779   DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex ), propertyType2, TEST_LOCATION );
1780   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex2 ), propertyType2, TEST_LOCATION );
1781
1782   // Check that the child property index for the second child property can now be retrieved through its child property name
1783   DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName2 ), propertyIndex2, TEST_LOCATION );
1784
1785   // Set the value for the third child property when the child actor is already added to the parent
1786   childActor.SetProperty(propertyIndex3, 0.15f);
1787
1788   // Check that the third child property is dynamically created
1789   DALI_TEST_EQUALS( initialChildActorPropertyCount + 3u, childActor.GetPropertyCount(), TEST_LOCATION );
1790
1791   // Check the third child property value
1792   DALI_TEST_EQUALS( childActor.GetProperty< float >( propertyIndex3 ), 0.15f, TEST_LOCATION );
1793
1794   // Check the third child property type
1795   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex3 ), propertyType3, TEST_LOCATION );
1796
1797   // Check the third child property name
1798   DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex3 ), propertyName3, TEST_LOCATION );
1799
1800   // Check the third child property index.
1801   DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName3 ), propertyIndex3, TEST_LOCATION );
1802
1803   // Create a custom property for the child with the same name as the fourth child property registered to the parent
1804   Property::Index customPropertyIndex2 = childActor.RegisterProperty(propertyName4, 20, Property::READ_WRITE);
1805
1806   // Check that the custom property is created
1807   DALI_TEST_EQUALS( initialChildActorPropertyCount + 4u, childActor.GetPropertyCount(), TEST_LOCATION );
1808
1809   // Check the fourth child property value
1810   DALI_TEST_EQUALS( childActor.GetProperty< int >( propertyIndex4 ), 20, TEST_LOCATION );
1811   DALI_TEST_EQUALS( childActor.GetProperty< int >( customPropertyIndex2 ), 20, TEST_LOCATION );
1812
1813   // Check the fourth child property type
1814   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex4 ), propertyType4, TEST_LOCATION );
1815   DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex2 ), propertyType4, TEST_LOCATION );
1816
1817   // Check the fourth child property name
1818   DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex4 ), propertyName4, TEST_LOCATION );
1819   DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex2 ), propertyName4, TEST_LOCATION );
1820
1821   // Check the fourth child property index.
1822   DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName4 ), propertyIndex4, TEST_LOCATION );
1823
1824   // Now create another parent actor with different child properties registered
1825   TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyNamedActor" );
1826   DALI_TEST_CHECK( typeInfo2 );
1827   BaseHandle handle2 = typeInfo2.CreateInstance();
1828   DALI_TEST_CHECK( handle2 );
1829   Actor customActor2 = Actor::DownCast( handle2 );
1830   DALI_TEST_CHECK( customActor2 );
1831
1832   // Register child properties to the new parent
1833   std::string newPropertyName( "newChildProp" );
1834   int newPropertyIndex( CHILD_PROPERTY_REGISTRATION_START_INDEX ); // The same index as the first child property "childProp1" in the old parent
1835   Property::Type newPropertyType( Property::VECTOR2 );
1836   ChildPropertyRegistration newChildProperty( namedActorType, newPropertyName, newPropertyIndex, newPropertyType );
1837
1838   std::string newPropertyName2( "childProp3" ); // The same name as the third child property in the old parent
1839   int newPropertyIndex2( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1 ); // The same index as the second child property "childProp2" in the old parent
1840   Property::Type newPropertyType2( Property::FLOAT ); // The same type as the third child property in the old parent
1841   ChildPropertyRegistration newChildProperty2( namedActorType, newPropertyName2, newPropertyIndex2, newPropertyType2 );
1842
1843   // Now move the child actor to the new parent
1844   customActor2.Add( childActor );
1845
1846   // "childProp1" is not a valid child property supported by the new parent, so nothing changed
1847   DALI_TEST_EQUALS( childActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION );
1848   DALI_TEST_EQUALS( childActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION );
1849   DALI_TEST_EQUALS( childActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION );
1850
1851   // "childProp3" is a valid child property supported by the new parent
1852   // So it should get its new child property index and should just work
1853   DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex2 ), newPropertyType2, TEST_LOCATION );
1854   DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex2 ), newPropertyName2, TEST_LOCATION );
1855   DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName2 ), newPropertyIndex2, TEST_LOCATION );
1856   DALI_TEST_EQUALS( childActor.GetProperty< float >( newPropertyIndex2 ), 0.15f, TEST_LOCATION );
1857
1858   // Now register a custom property called "newChildProp"
1859   Property::Index customPropertyIndex3 = childActor.RegisterProperty("newChildProp", Vector2( 10.0f, 10.0f ), Property::READ_WRITE);
1860
1861   // Check that the custom property is created
1862   DALI_TEST_EQUALS( initialChildActorPropertyCount + 5u, childActor.GetPropertyCount(), TEST_LOCATION );
1863
1864   // This is a valid child property registered to the new parent
1865   // So should be able to access it through both its custom property index and its registered child property index
1866   DALI_TEST_EQUALS( childActor.GetPropertyType( newPropertyIndex ), newPropertyType, TEST_LOCATION );
1867   DALI_TEST_EQUALS( childActor.GetPropertyType( customPropertyIndex3 ), newPropertyType, TEST_LOCATION );
1868   DALI_TEST_EQUALS( childActor.GetPropertyName( newPropertyIndex ), newPropertyName, TEST_LOCATION ); // This should return the new name, although the child property index remains the same
1869   DALI_TEST_EQUALS( childActor.GetPropertyName( customPropertyIndex3 ), newPropertyName, TEST_LOCATION );
1870   DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( newPropertyIndex ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1871   DALI_TEST_EQUALS( childActor.GetProperty< Vector2 >( customPropertyIndex3 ), Vector2( 10.0f, 10.0f ), TEST_LOCATION );
1872
1873   // Should return the child property index by given its name
1874   DALI_TEST_EQUALS( childActor.GetPropertyIndex( newPropertyName ), newPropertyIndex, TEST_LOCATION );
1875
1876
1877   END_TEST;
1878 }
1879
1880 int UtcDaliTypeRegistryChildPropertyRegistrationN(void)
1881 {
1882   TestApplication application;
1883   TypeRegistry typeRegistry = TypeRegistry::Get();
1884
1885   // Attempt to register a child property type out-of-bounds index (less than)
1886   try
1887   {
1888     ChildPropertyRegistration property1( customType1, "propName",  CHILD_PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN );
1889     tet_result( TET_FAIL );
1890   }
1891   catch ( DaliException& e )
1892   {
1893     DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1894   }
1895
1896   // Attempt to register a child property type out-of-bounds index (greater than)
1897   try
1898   {
1899     ChildPropertyRegistration property1( customType1, "propName",  CHILD_PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN );
1900     tet_result( TET_FAIL );
1901   }
1902   catch ( DaliException& e )
1903   {
1904     DALI_TEST_ASSERT( e, "( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION );
1905   }
1906
1907   END_TEST;
1908 }
1909
1910
1911 /*******************************************************************************
1912  *
1913  * Action through the base handle
1914  *
1915  ******************************************************************************/
1916 int UtcDaliTypeRegistryActionViaBaseHandle(void)
1917 {
1918   TestApplication application;
1919
1920   TypeInfo type;
1921
1922   type = TypeRegistry::Get().GetTypeInfo( "Actor" );
1923   DALI_TEST_CHECK( type );
1924
1925   BaseHandle hdl = type.CreateInstance();
1926   DALI_TEST_CHECK( hdl );
1927
1928   Actor a = Actor::DownCast(hdl);
1929   DALI_TEST_CHECK( a );
1930
1931   a.SetProperty( Actor::Property::VISIBLE,false);
1932
1933   application.SendNotification();
1934   application.Render(0);
1935   DALI_TEST_CHECK(!a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1936
1937   Property::Map attributes;
1938
1939   DALI_TEST_CHECK(hdl.DoAction("show", attributes));
1940
1941   application.SendNotification();
1942   application.Render(0);
1943   DALI_TEST_CHECK(a.GetCurrentProperty< bool >( Actor::Property::VISIBLE ));
1944
1945   DALI_TEST_CHECK(!hdl.DoAction("unknownAction",  attributes));
1946   END_TEST;
1947 }
1948
1949 int UtcDaliPropertyRegistrationFunctions(void)
1950 {
1951   TestApplication application;
1952   int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10;
1953
1954   // Attempt to register a property without a setter
1955   try
1956   {
1957     PropertyRegistration property1( customType1, "propName",  propertyIndex++, Property::BOOLEAN, NULL, &GetProperty );
1958     tet_result( TET_PASS );
1959   }
1960   catch ( DaliException& e )
1961   {
1962     tet_result( TET_FAIL );
1963   }
1964
1965   // Attempt to register a property without a getter
1966   try
1967   {
1968     PropertyRegistration property1( customType1, "propName",  propertyIndex++, Property::BOOLEAN, NULL, NULL );
1969     tet_result( TET_FAIL );
1970   }
1971   catch ( DaliException& e )
1972   {
1973     DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION );
1974   }
1975   END_TEST;
1976 }
1977
1978 int UtcDaliPropertyRegistrationAddSameIndex(void)
1979 {
1980   TestApplication application;
1981   int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100;
1982
1983   // Add one property with a valid property index
1984   PropertyRegistration property1( customType1, "propName",  propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1985
1986   // Attempt to add another property with the same index
1987   try
1988   {
1989     PropertyRegistration property2( customType1, "propName2",   propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
1990   }
1991   catch ( DaliException& e )
1992   {
1993     DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
1994   }
1995
1996   int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
1997
1998   // Add one property with a valid property index
1999   AnimatablePropertyRegistration property3( customType1, "animPropName",   animatablePropertyIndex, Property::BOOLEAN );
2000
2001   // Attempt to add another property with the same index
2002   try
2003   {
2004     AnimatablePropertyRegistration property4( customType1, "animPropName2",    animatablePropertyIndex, Property::BOOLEAN );
2005   }
2006   catch ( DaliException& e )
2007   {
2008     DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION );
2009   }
2010   END_TEST;
2011 }
2012
2013 int UtcDaliPropertyRegistrationPropertyWritableP(void)
2014 {
2015   TestApplication application;
2016   int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200;
2017   int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201;
2018
2019   // Add two properties, one with SetProperty, one without
2020   PropertyRegistration property1( customType1, "propNameReadwrite",   propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty );
2021   PropertyRegistration property2( customType1, "propNameReadonly",    propertyIndex2, Property::BOOLEAN, NULL, &GetProperty );
2022
2023   // Create custom-actor
2024   TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2025   DALI_TEST_CHECK( typeInfo );
2026   BaseHandle handle = typeInfo.CreateInstance();
2027   DALI_TEST_CHECK( handle );
2028   Actor customActor = Actor::DownCast( handle );
2029   DALI_TEST_CHECK( customActor );
2030
2031   // Check whether properties are writable
2032   DALI_TEST_CHECK(   customActor.IsPropertyWritable( propertyIndex1 ) );
2033   DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) );
2034
2035
2036   // Check the property is writable in the type registry
2037   Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2038
2039   DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( propertyIndex1 ), true, TEST_LOCATION );
2040
2041   END_TEST;
2042 }
2043
2044 int UtcDaliPropertyRegistrationPropertyWritableN(void)
2045 {
2046   TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2047   Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo );
2048
2049   DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION );
2050
2051   END_TEST;
2052 }
2053
2054 int UtcDaliPropertyRegistrationPropertyAnimatable(void)
2055 {
2056   TestApplication application;
2057   int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400;
2058   int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 400;
2059
2060   // These properties are not animatable
2061   PropertyRegistration property1( customType1, "propName",  propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty );
2062
2063   // These properties are animatable
2064   AnimatablePropertyRegistration property2( customType1, "animPropName",   animatablePropertyIndex, Property::BOOLEAN );
2065
2066   // Create custom-actor
2067   TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2068   DALI_TEST_CHECK( typeInfo );
2069   BaseHandle handle = typeInfo.CreateInstance();
2070   DALI_TEST_CHECK( handle );
2071   Actor customActor = Actor::DownCast( handle );
2072   DALI_TEST_CHECK( customActor );
2073
2074   // Check if animatable
2075   DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) );
2076   DALI_TEST_CHECK( customActor.IsPropertyAnimatable( animatablePropertyIndex ) );
2077
2078   // Create another instance of custom-actor
2079   BaseHandle handle2 = typeInfo.CreateInstance();
2080   DALI_TEST_CHECK( handle2 );
2081   Actor customActor2 = Actor::DownCast( handle2 );
2082   DALI_TEST_CHECK( customActor2 );
2083
2084   // Check if animatable
2085   DALI_TEST_CHECK( ! customActor2.IsPropertyAnimatable( propertyIndex ) );
2086   DALI_TEST_CHECK( customActor2.IsPropertyAnimatable( animatablePropertyIndex ) );
2087   END_TEST;
2088 }
2089
2090 int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
2091 {
2092   TestApplication application;
2093   int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
2094   int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 2000;
2095
2096   // Create custom-actor
2097   TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) );
2098   DALI_TEST_CHECK( typeInfo );
2099   BaseHandle handle = typeInfo.CreateInstance();
2100   DALI_TEST_CHECK( handle );
2101   Actor customActor = Actor::DownCast( handle );
2102   DALI_TEST_CHECK( customActor );
2103
2104   // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future
2105   customActor.SetProperty( propertyIndex, true );
2106 //  DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get<bool>(), TEST_LOCATION);
2107
2108   // Try to set an index that hasn't been registered
2109   customActor.SetProperty( animatablePropertyIndex, true );
2110   DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get<bool>(), TEST_LOCATION);
2111
2112   END_TEST;
2113 }
2114
2115
2116 int UtcDaliLongPressGestureDetectorTypeRegistry(void)
2117 {
2118   TestApplication application;
2119
2120   Actor actor = Actor::New();
2121   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2122   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2123   application.GetScene().Add(actor);
2124
2125   // Register Type
2126   TypeInfo type;
2127   type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" );
2128   DALI_TEST_CHECK( type );
2129   BaseHandle handle = type.CreateInstance();
2130   DALI_TEST_CHECK( handle );
2131   LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle );
2132   DALI_TEST_CHECK( detector );
2133
2134   // Attach actor to detector
2135   SignalData data;
2136   GestureReceivedFunctor functor( data );
2137   detector.Attach(actor);
2138
2139   // Connect to signal through type
2140   handle.ConnectSignal( &application, "longPressDetected",   functor );
2141
2142   // Render and notify
2143   application.SendNotification();
2144   application.Render();
2145
2146   // Emit gesture
2147   TestGenerateLongPress( application, 50.0f, 10.0f );
2148   TestEndLongPress( application, 50.0f, 10.0f );
2149
2150   DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2151   END_TEST;
2152 }
2153
2154 int UtcDaliPanGestureDetectorTypeRegistry(void)
2155 {
2156   TestApplication application;
2157
2158   Actor actor = Actor::New();
2159   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2160   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2161   application.GetScene().Add(actor);
2162
2163   // Register Type
2164   TypeInfo type;
2165   type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" );
2166   DALI_TEST_CHECK( type );
2167   BaseHandle handle = type.CreateInstance();
2168   DALI_TEST_CHECK( handle );
2169   PanGestureDetector detector = PanGestureDetector::DownCast( handle );
2170   DALI_TEST_CHECK( detector );
2171
2172   // Attach actor to detector
2173   SignalData data;
2174   GestureReceivedFunctor functor( data );
2175   detector.Attach(actor);
2176
2177   // Connect to signal through type
2178   handle.ConnectSignal( &application, "panDetected",  functor );
2179
2180   // Render and notify
2181   application.SendNotification();
2182   application.Render();
2183
2184   // Emit gesture
2185   TestGenerateMiniPan( application );
2186   DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2187   END_TEST;
2188 }
2189
2190 int UtcDaliPinchGestureDetectorTypeRegistry(void)
2191 {
2192   TestApplication application;
2193
2194   Actor actor = Actor::New();
2195   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2196   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2197   application.GetScene().Add(actor);
2198
2199   // Register Type
2200   TypeInfo type;
2201   type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" );
2202   DALI_TEST_CHECK( type );
2203   BaseHandle handle = type.CreateInstance();
2204   DALI_TEST_CHECK( handle );
2205   PinchGestureDetector detector = PinchGestureDetector::DownCast( handle );
2206   DALI_TEST_CHECK( detector );
2207
2208   // Attach actor to detector
2209   SignalData data;
2210   GestureReceivedFunctor functor( data );
2211   detector.Attach(actor);
2212
2213   // Connect to signal through type
2214   handle.ConnectSignal( &application, "pinchDetected",  functor );
2215
2216   // Render and notify
2217   application.SendNotification();
2218   application.Render();
2219
2220   // Emit gesture
2221   TestGeneratePinch( application );
2222
2223   DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2224   END_TEST;
2225 }
2226
2227 int UtcDaliRotationGestureDetectorTypeRegistry(void)
2228 {
2229   TestApplication application;
2230
2231   Actor actor = Actor::New();
2232   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2233   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2234   application.GetScene().Add(actor);
2235
2236   // Register Type
2237   TypeInfo type;
2238   type = TypeRegistry::Get().GetTypeInfo( "RotationGestureDetector" );
2239   DALI_TEST_CHECK( type );
2240   BaseHandle handle = type.CreateInstance();
2241   DALI_TEST_CHECK( handle );
2242   RotationGestureDetector detector = RotationGestureDetector::DownCast( handle );
2243   DALI_TEST_CHECK( detector );
2244
2245   // Attach actor to detector
2246   SignalData data;
2247   GestureReceivedFunctor functor( data );
2248   detector.Attach(actor);
2249
2250   // Connect to signal through type
2251   handle.ConnectSignal( &application, "rotationDetected",  functor );
2252
2253   // Render and notify
2254   application.SendNotification();
2255   application.Render();
2256
2257   // Emit gesture
2258   TestGenerateRotation( application );
2259
2260   DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2261   END_TEST;
2262 }
2263
2264 int UtcDaliTapGestureDetectorTypeRegistry(void)
2265 {
2266   TestApplication application;
2267
2268   Actor actor = Actor::New();
2269   actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2270   actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2271   application.GetScene().Add(actor);
2272
2273   // Register Type
2274   TypeInfo type;
2275   type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" );
2276   DALI_TEST_CHECK( type );
2277   BaseHandle handle = type.CreateInstance();
2278   DALI_TEST_CHECK( handle );
2279   TapGestureDetector detector = TapGestureDetector::DownCast( handle );
2280   DALI_TEST_CHECK( detector );
2281
2282   // Attach actor to detector
2283   SignalData data;
2284   GestureReceivedFunctor functor( data );
2285   detector.Attach(actor);
2286
2287   // Connect to signal through type
2288   handle.ConnectSignal( &application, "tapDetected",  functor );
2289
2290   // Render and notify
2291   application.SendNotification();
2292   application.Render();
2293
2294   // Emit gesture
2295   TestGenerateTap( application, 50.0, 10.0, 100 );
2296
2297   DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION);
2298   END_TEST;
2299 }
2300
2301 int UtcDaliTypeRegistryNamedType(void)
2302 {
2303   TestApplication application;
2304   TypeRegistry typeRegistry = TypeRegistry::Get();
2305
2306   // Create a normal actor
2307   BaseHandle actorHandle = typeRegistry.GetTypeInfo( "Actor" ).CreateInstance();
2308   DALI_TEST_CHECK( actorHandle );
2309   Actor actor( Actor::DownCast( actorHandle ) );
2310   DALI_TEST_CHECK( actor );
2311   unsigned int actorPropertyCount( actor.GetPropertyCount() );
2312
2313   // Create Named Actor Type
2314   BaseHandle namedHandle = typeRegistry.GetTypeInfo( "MyNamedActor" ).CreateInstance();
2315   DALI_TEST_CHECK( namedHandle );
2316   Actor namedActor( Actor::DownCast( namedHandle ) );
2317   DALI_TEST_CHECK( namedActor );
2318   unsigned int namedActorPropertyCount( namedActor.GetPropertyCount() );
2319
2320   DALI_TEST_CHECK( namedActorPropertyCount > actorPropertyCount );
2321   END_TEST;
2322 }
2323
2324 int UtcDaliTypeInfoGetActionNameP(void)
2325 {
2326   TestApplication application;
2327   TypeRegistry typeRegistry = TypeRegistry::Get();
2328
2329   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2330   DALI_TEST_CHECK( typeInfo );
2331
2332   DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2333
2334   std::string name = typeInfo.GetActionName(0);
2335
2336   DALI_TEST_EQUALS( name, "show", TEST_LOCATION );
2337
2338
2339   TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2340
2341   //  search for show action in base class, given a derived class
2342   bool foundChildAction = false;
2343   for( std::size_t i = 0; i < typeInfo2.GetActionCount(); i++ )
2344   {
2345
2346        std::string name = typeInfo2.GetActionName( i );
2347        if( name == "show")
2348        {
2349          foundChildAction = true;
2350        }
2351
2352   }
2353
2354   DALI_TEST_EQUALS( foundChildAction, true, TEST_LOCATION );
2355
2356
2357   END_TEST;
2358 }
2359
2360 int UtcDaliTypeInfoGetActionNameN(void)
2361 {
2362   TestApplication application;
2363   TypeRegistry typeRegistry = TypeRegistry::Get();
2364
2365   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2366   DALI_TEST_CHECK( typeInfo );
2367
2368   DALI_TEST_CHECK( 0 != typeInfo.GetActionCount() );
2369
2370   std::string name = typeInfo.GetActionName(std::numeric_limits<size_t>::max());
2371
2372   DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2373
2374   END_TEST;
2375 }
2376
2377 int UtcDaliTypeInfoGetSignalNameP(void)
2378 {
2379   TestApplication application;
2380   TypeRegistry typeRegistry = TypeRegistry::Get();
2381
2382   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2383   DALI_TEST_CHECK( typeInfo );
2384
2385   DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2386
2387   std::string name = typeInfo.GetSignalName(0);
2388
2389   DALI_TEST_EQUALS( name, "hovered", TEST_LOCATION );
2390
2391   TypeInfo typeInfo2 = typeRegistry.GetTypeInfo( "MyTestCustomActor" );
2392
2393   //  search for signal in base class, given a derived class
2394   bool foundSignal = false;
2395   for( std::size_t i = 0; i < typeInfo2.GetSignalCount(); i++ )
2396   {
2397     std::string name = typeInfo2.GetSignalName( i );
2398     if( name == "hovered")
2399     {
2400       foundSignal = true;
2401     }
2402   }
2403
2404   DALI_TEST_EQUALS( foundSignal, true, TEST_LOCATION );
2405
2406   END_TEST;
2407 }
2408
2409 int UtcDaliTypeInfoGetSignalNameN(void)
2410 {
2411   TestApplication application;
2412   TypeRegistry typeRegistry = TypeRegistry::Get();
2413
2414   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2415   DALI_TEST_CHECK( typeInfo );
2416
2417   DALI_TEST_CHECK( 0 != typeInfo.GetSignalCount() );
2418
2419   std::string name = typeInfo.GetSignalName(std::numeric_limits<size_t>::max());
2420
2421   DALI_TEST_EQUALS( 0u, name.size(), TEST_LOCATION );
2422
2423   END_TEST;
2424 }
2425
2426
2427 int UtcDaliTypeInfoGetCreatorP(void)
2428 {
2429   TestApplication application;
2430   TypeRegistry typeRegistry = TypeRegistry::Get();
2431
2432   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2433   DALI_TEST_CHECK( typeInfo );
2434
2435   TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2436   DALI_TEST_EQUALS( createFn != NULL, true, TEST_LOCATION );
2437   if( createFn )
2438   {
2439     // try calling it:
2440     BaseHandle handle = createFn();
2441     DALI_TEST_EQUALS( (bool)handle, true, TEST_LOCATION );
2442   }
2443
2444   END_TEST;
2445 }
2446
2447 int UtcDaliTypeInfoGetCreatorN(void)
2448 {
2449   TestApplication application;
2450   TypeRegistry typeRegistry = TypeRegistry::Get();
2451
2452   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor3" );
2453   DALI_TEST_CHECK( typeInfo );
2454
2455   TypeInfo::CreateFunction createFn = typeInfo.GetCreator();
2456   DALI_TEST_EQUALS( createFn == NULL, true, TEST_LOCATION );
2457
2458   END_TEST;
2459 }
2460
2461 int UtcDaliTypeInfoGetPropertyCountP1(void)
2462 {
2463   TestApplication application;
2464   TypeRegistry typeRegistry = TypeRegistry::Get();
2465
2466   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
2467   DALI_TEST_CHECK( typeInfo );
2468   size_t actorPropertyCount = typeInfo.GetPropertyCount();
2469
2470   DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props
2471   END_TEST;
2472 }
2473
2474 int UtcDaliTypeInfoGetPropertyCountP2(void)
2475 {
2476   TestApplication application;
2477   TypeRegistry typeRegistry = TypeRegistry::Get();
2478
2479   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "MyTestCustomActor2" );
2480   DALI_TEST_CHECK( typeInfo );
2481   size_t propertyCount = typeInfo.GetPropertyCount();
2482   Property::IndexContainer indices;
2483   typeInfo.GetPropertyIndices( indices );
2484
2485   DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION );
2486   DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION );
2487
2488   END_TEST;
2489 }
2490
2491 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGet01(void)
2492 {
2493   TestApplication application;
2494   TypeRegistry typeRegistry = TypeRegistry::Get();
2495
2496   tet_infoline( "Register a type registered animatable property and ensure set/get behaviour works synchronously" );
2497
2498   // Register animatable property
2499   const int animatablePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2500   AnimatablePropertyRegistration animatableProperty( customType1, "animatableProp1", animatablePropertyIndex, Property::FLOAT );
2501
2502   // Check property count before property registration
2503   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2504   DALI_TEST_CHECK( typeInfo );
2505   BaseHandle handle = typeInfo.CreateInstance();
2506   DALI_TEST_CHECK( handle );
2507   Actor customActor = Actor::DownCast( handle );
2508   DALI_TEST_CHECK( customActor );
2509   application.GetScene().Add(customActor);
2510
2511   tet_infoline( "Set the value and ensure it changes straight away" );
2512   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2513   customActor.SetProperty( animatablePropertyIndex, 25.0f );
2514   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2515
2516   tet_infoline( "Check latest scene-graph value is unchanged" );
2517   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 0.0f, TEST_LOCATION );
2518
2519   // Render and notify
2520   application.SendNotification();
2521   application.Render();
2522
2523   tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2524
2525   DALI_TEST_EQUALS( customActor.GetProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2526   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( animatablePropertyIndex ), 25.0f, TEST_LOCATION );
2527
2528   END_TEST;
2529 }
2530
2531 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector2(void)
2532 {
2533   TestApplication application;
2534   TypeRegistry typeRegistry = TypeRegistry::Get();
2535
2536   tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" );
2537
2538   // Register the animatable propeties
2539   const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2540   const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2541   const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2542   AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector2( 13.0f, 24.0f ) );
2543   AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2544   AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2545
2546   // Check property count before property registration
2547   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2548   DALI_TEST_CHECK( typeInfo );
2549   BaseHandle handle = typeInfo.CreateInstance();
2550   DALI_TEST_CHECK( handle );
2551   Actor customActor = Actor::DownCast( handle );
2552   DALI_TEST_CHECK( customActor );
2553   application.GetScene().Add(customActor);
2554
2555   tet_infoline( "Get the component values, they should be the default value of the base-property" );
2556   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2557   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2558   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2559
2560   tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2561   customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2562   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2563   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 24.0f ), TEST_LOCATION );
2564
2565   customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2566   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2567   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2568
2569   tet_infoline( "Check latest scene-graph value is unchanged" );
2570   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 13.0f, 24.0f ), TEST_LOCATION );
2571   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2572   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2573
2574   // Render and notify
2575   application.SendNotification();
2576   application.Render();
2577
2578   tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2579   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2580   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2581   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2582
2583   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector2 >( basePropertyIndex ), Vector2( 125.0f, 225.0f ), TEST_LOCATION );
2584   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2585   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2586
2587   tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2588   customActor.SetProperty( basePropertyIndex, Vector2( 1.0f, 2.0f ) );
2589   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2590   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2591   DALI_TEST_EQUALS( customActor.GetProperty< Vector2 >( basePropertyIndex ), Vector2( 1.0f, 2.0f ), TEST_LOCATION );
2592
2593   END_TEST;
2594 }
2595
2596 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector3(void)
2597 {
2598   TestApplication application;
2599   TypeRegistry typeRegistry = TypeRegistry::Get();
2600
2601   tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" );
2602
2603   // Register the animatable propeties
2604   const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2605   const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2606   const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2607   const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2608   AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector3( 13.0f, 24.0f, 35.0 ) );
2609   AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2610   AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2611   AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2612
2613   // Check property count before property registration
2614   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2615   DALI_TEST_CHECK( typeInfo );
2616   BaseHandle handle = typeInfo.CreateInstance();
2617   DALI_TEST_CHECK( handle );
2618   Actor customActor = Actor::DownCast( handle );
2619   DALI_TEST_CHECK( customActor );
2620   application.GetScene().Add(customActor);
2621
2622   tet_infoline( "Get the component values, they should be the default value of the base-property" );
2623   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2624   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2625   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2626   DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2627
2628   tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2629   customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2630   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2631   DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 24.0f, 35.0f ), TEST_LOCATION );
2632
2633   customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2634   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2635   DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 35.0f ), TEST_LOCATION );
2636
2637   customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2638   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2639   DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2640
2641   tet_infoline( "Check latest scene-graph value is unchanged" );
2642   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 13.0f, 24.0f, 35.0f ), TEST_LOCATION );
2643   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2644   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2645   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2646
2647   // Render and notify
2648   application.SendNotification();
2649   application.Render();
2650
2651   tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2652   DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2653   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2654   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2655   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2656
2657   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector3 >( basePropertyIndex ), Vector3( 125.0f, 225.0f, 325.0f ), TEST_LOCATION );
2658   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2659   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2660   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2661
2662   tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2663   customActor.SetProperty( basePropertyIndex, Vector3( 1.0f, 2.0f, 3.0f ) );
2664   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2665   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2666   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2667   DALI_TEST_EQUALS( customActor.GetProperty< Vector3 >( basePropertyIndex ), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
2668
2669   END_TEST;
2670 }
2671
2672 int UtcDaliPropertyRegistrationPropertyAnimatableSynchronousSetGetWithComponentsVector4(void)
2673 {
2674   TestApplication application;
2675   TypeRegistry typeRegistry = TypeRegistry::Get();
2676
2677   tet_infoline( "Register a type registered animatable property that has component indices and ensure set/get behaviour works synchronously and is the same regardless of how the property is set" );
2678
2679   // Register the animatable propeties
2680   const int basePropertyIndex( ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX );
2681   const int componentZeroPropertyIndex( basePropertyIndex + 1 );
2682   const int componentOnePropertyIndex( componentZeroPropertyIndex + 1 );
2683   const int componentTwoPropertyIndex( componentOnePropertyIndex + 1 );
2684   const int componentThreePropertyIndex( componentTwoPropertyIndex + 1 );
2685   AnimatablePropertyRegistration baseAnimatableProperty( customType1, "baseProp", basePropertyIndex, Vector4( 13.0f, 24.0f, 35.0, 47.0f ) );
2686   AnimatablePropertyComponentRegistration componentZeroAnimatableProperty( customType1, "componentZeroProp", componentZeroPropertyIndex, basePropertyIndex, 0 );
2687   AnimatablePropertyComponentRegistration componentOneAnimatableProperty( customType1, "componentOneProp", componentOnePropertyIndex, basePropertyIndex, 1 );
2688   AnimatablePropertyComponentRegistration componentTwoAnimatableProperty( customType1, "componentTwoProp", componentTwoPropertyIndex, basePropertyIndex, 2 );
2689   AnimatablePropertyComponentRegistration componentThreeAnimatableProperty( customType1, "componentThreeProp", componentThreePropertyIndex, basePropertyIndex, 3 );
2690
2691   // Check property count before property registration
2692   TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2693   DALI_TEST_CHECK( typeInfo );
2694   BaseHandle handle = typeInfo.CreateInstance();
2695   DALI_TEST_CHECK( handle );
2696   Actor customActor = Actor::DownCast( handle );
2697   DALI_TEST_CHECK( customActor );
2698   application.GetScene().Add(customActor);
2699
2700   tet_infoline( "Get the component values, they should be the default value of the base-property" );
2701   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2702   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2703   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2704   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2705   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2706
2707   tet_infoline( "Set a component value and ensure it changes for the base property as well" );
2708   customActor.SetProperty( componentZeroPropertyIndex, 125.0f );
2709   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2710   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2711
2712   customActor.SetProperty( componentOnePropertyIndex, 225.0f );
2713   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2714   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 35.0f, 47.0f ), TEST_LOCATION );
2715
2716   customActor.SetProperty( componentTwoPropertyIndex, 325.0f );
2717   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2718   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 47.0f ), TEST_LOCATION );
2719
2720   customActor.SetProperty( componentThreePropertyIndex, 435.0f );
2721   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2722   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2723
2724   tet_infoline( "Check latest scene-graph value is unchanged" );
2725   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 13.0f, 24.0f, 35.0f, 47.0f ), TEST_LOCATION );
2726   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 13.0f, TEST_LOCATION );
2727   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 24.0f, TEST_LOCATION );
2728   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 35.0f, TEST_LOCATION );
2729   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 47.0f, TEST_LOCATION );
2730
2731   // Render and notify
2732   application.SendNotification();
2733   application.Render();
2734
2735   tet_infoline( "Check values after rendering and both retrieval methods should return the latest" );
2736   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2737   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2738   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2739   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2740   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2741
2742   DALI_TEST_EQUALS( customActor.GetCurrentProperty< Vector4 >( basePropertyIndex ), Vector4( 125.0f, 225.0f, 325.0f, 435.0f ), TEST_LOCATION );
2743   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentZeroPropertyIndex ), 125.0f, TEST_LOCATION );
2744   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentOnePropertyIndex ), 225.0f, TEST_LOCATION );
2745   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentTwoPropertyIndex ), 325.0f, TEST_LOCATION );
2746   DALI_TEST_EQUALS( customActor.GetCurrentProperty< float >( componentThreePropertyIndex ), 435.0f, TEST_LOCATION );
2747
2748   tet_infoline( "Set the base property value and ensure the component values reflect the change" );
2749   customActor.SetProperty( basePropertyIndex, Vector4( 1.0f, 2.0f, 3.0f, 4.0f ) );
2750   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentZeroPropertyIndex ), 1.0f, TEST_LOCATION );
2751   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentOnePropertyIndex ), 2.0f, TEST_LOCATION );
2752   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentTwoPropertyIndex ), 3.0f, TEST_LOCATION );
2753   DALI_TEST_EQUALS( customActor.GetProperty< float >( componentThreePropertyIndex ), 4.0f, TEST_LOCATION );
2754   DALI_TEST_EQUALS( customActor.GetProperty< Vector4 >( basePropertyIndex ), Vector4( 1.0f, 2.0f, 3.0f, 4.0f ), TEST_LOCATION );
2755
2756   END_TEST;
2757 }
2758
2759
2760 int UtcDaliTypeInfoRegisterChildProperties01(void)
2761 {
2762   TestApplication application;
2763   TypeRegistry typeRegistry = TypeRegistry::Get();
2764
2765   tet_infoline( "Register child properties on a type via name" );
2766
2767   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2768   auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2769   DALI_TEST_CHECK( customActorTypeInfo );
2770   DALI_TEST_CHECK( myCustomTypeInfo );
2771
2772   const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2773   const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2774   const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2775
2776   ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2777   ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2778   ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2779
2780   auto customActor = MyTestCustomActor::New();
2781   application.GetScene().Add( customActor );
2782   auto child = Actor::New();
2783   customActor.Add( child );
2784
2785   child.SetProperty( WIDTH_SPECIFICATION, 33 );
2786
2787   auto value = child.GetProperty( WIDTH_SPECIFICATION );
2788   DALI_TEST_EQUALS( value, Property::Value(33), TEST_LOCATION );
2789
2790   child.SetProperty( HEIGHT_SPECIFICATION, 44 );
2791   value = child.GetProperty( HEIGHT_SPECIFICATION );
2792   DALI_TEST_EQUALS( value, Property::Value(44), TEST_LOCATION );
2793
2794   child.SetProperty( MARGIN_SPECIFICATION, Extents(10, 10, 10, 10) );
2795   value = child.GetProperty( MARGIN_SPECIFICATION );
2796   DALI_TEST_EQUALS( value, Property::Value(Extents(10,10,10,10)), TEST_LOCATION );
2797
2798   END_TEST;
2799 }
2800
2801
2802 int UtcDaliTypeInfoRegisterChildProperties02(void)
2803 {
2804   TestApplication application;
2805   TypeRegistry typeRegistry = TypeRegistry::Get();
2806
2807   tet_infoline( "Register child properties on a type via name" );
2808
2809   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2810   auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2811   DALI_TEST_CHECK( customActorTypeInfo );
2812   DALI_TEST_CHECK( myCustomTypeInfo );
2813
2814   const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2815   const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2816   const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2817
2818   ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2819   ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2820   ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2821
2822
2823   auto index = customActorTypeInfo.GetChildPropertyIndex( "widthSpecification" );
2824   DALI_TEST_EQUALS( index, WIDTH_SPECIFICATION, TEST_LOCATION );
2825
2826   index = customActorTypeInfo.GetChildPropertyIndex( "heightSpecification" );
2827   DALI_TEST_EQUALS( index, HEIGHT_SPECIFICATION, TEST_LOCATION );
2828
2829   index = customActorTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2830   DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
2831
2832   index = myCustomTypeInfo.GetChildPropertyIndex( "marginSpecification" );
2833   DALI_TEST_EQUALS( index, MARGIN_SPECIFICATION, TEST_LOCATION );
2834
2835
2836   auto name = customActorTypeInfo.GetChildPropertyName( WIDTH_SPECIFICATION );
2837   DALI_TEST_EQUALS( name, "widthSpecification", TEST_LOCATION );
2838
2839   name = customActorTypeInfo.GetChildPropertyName( HEIGHT_SPECIFICATION );
2840   DALI_TEST_EQUALS( name, "heightSpecification", TEST_LOCATION );
2841
2842   name = myCustomTypeInfo.GetChildPropertyName( MARGIN_SPECIFICATION );
2843   DALI_TEST_EQUALS( name, "marginSpecification", TEST_LOCATION );
2844
2845
2846   auto type = customActorTypeInfo.GetChildPropertyType( WIDTH_SPECIFICATION );
2847   DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2848
2849   type = customActorTypeInfo.GetChildPropertyType( HEIGHT_SPECIFICATION );
2850   DALI_TEST_EQUALS( type, Property::INTEGER, TEST_LOCATION );
2851
2852   type = myCustomTypeInfo.GetChildPropertyType( MARGIN_SPECIFICATION );
2853   DALI_TEST_EQUALS( type, Property::EXTENTS, TEST_LOCATION );
2854
2855
2856   END_TEST;
2857 }
2858
2859
2860 int UtcDaliTypeInfoRegisterChildProperties03(void)
2861 {
2862   TestApplication application;
2863   TypeRegistry typeRegistry = TypeRegistry::Get();
2864
2865   tet_infoline( "Check registered child properties can be retrieved" );
2866
2867   auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
2868   auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
2869   DALI_TEST_CHECK( customActorTypeInfo );
2870   DALI_TEST_CHECK( myCustomTypeInfo );
2871
2872   const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
2873   const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
2874   const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
2875
2876   ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
2877   ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
2878   ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
2879
2880   Property::IndexContainer indices;
2881   myCustomTypeInfo.GetChildPropertyIndices( indices );
2882
2883   auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
2884   DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2885
2886   result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
2887   DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2888
2889   result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
2890   DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
2891
2892   END_TEST;
2893 }
2894
2895 int UtcDaliTypeInfoGetActionNameNegative(void)
2896 {
2897   TestApplication application;
2898   Dali::TypeInfo instance;
2899   try
2900   {
2901     unsigned long arg1(0u);
2902     instance.GetActionName(arg1);
2903     DALI_TEST_CHECK(false); // Should not get here
2904   }
2905   catch(...)
2906   {
2907     DALI_TEST_CHECK(true); // We expect an assert
2908   }
2909   END_TEST;
2910 }
2911
2912 int UtcDaliTypeInfoGetSignalNameNegative(void)
2913 {
2914   TestApplication application;
2915   Dali::TypeInfo instance;
2916   try
2917   {
2918     unsigned long arg1(0u);
2919     instance.GetSignalName(arg1);
2920     DALI_TEST_CHECK(false); // Should not get here
2921   }
2922   catch(...)
2923   {
2924     DALI_TEST_CHECK(true); // We expect an assert
2925   }
2926   END_TEST;
2927 }
2928
2929 int UtcDaliTypeInfoGetCreatorNegative(void)
2930 {
2931   TestApplication application;
2932   Dali::TypeInfo instance;
2933   try
2934   {
2935     instance.GetCreator();
2936     DALI_TEST_CHECK(false); // Should not get here
2937   }
2938   catch(...)
2939   {
2940     DALI_TEST_CHECK(true); // We expect an assert
2941   }
2942   END_TEST;
2943 }
2944
2945 int UtcDaliTypeInfoGetBaseNameNegative(void)
2946 {
2947   TestApplication application;
2948   Dali::TypeInfo instance;
2949   try
2950   {
2951     instance.GetBaseName();
2952     DALI_TEST_CHECK(false); // Should not get here
2953   }
2954   catch(...)
2955   {
2956     DALI_TEST_CHECK(true); // We expect an assert
2957   }
2958   END_TEST;
2959 }
2960
2961 int UtcDaliTypeInfoCreateInstanceNegative(void)
2962 {
2963   TestApplication application;
2964   Dali::TypeInfo instance;
2965   try
2966   {
2967     instance.CreateInstance();
2968     DALI_TEST_CHECK(false); // Should not get here
2969   }
2970   catch(...)
2971   {
2972     DALI_TEST_CHECK(true); // We expect an assert
2973   }
2974   END_TEST;
2975 }
2976
2977 int UtcDaliTypeInfoGetActionCountNegative(void)
2978 {
2979   TestApplication application;
2980   Dali::TypeInfo instance;
2981   try
2982   {
2983     instance.GetActionCount();
2984     DALI_TEST_CHECK(false); // Should not get here
2985   }
2986   catch(...)
2987   {
2988     DALI_TEST_CHECK(true); // We expect an assert
2989   }
2990   END_TEST;
2991 }
2992
2993 int UtcDaliTypeInfoGetSignalCountNegative(void)
2994 {
2995   TestApplication application;
2996   Dali::TypeInfo instance;
2997   try
2998   {
2999     instance.GetSignalCount();
3000     DALI_TEST_CHECK(false); // Should not get here
3001   }
3002   catch(...)
3003   {
3004     DALI_TEST_CHECK(true); // We expect an assert
3005   }
3006   END_TEST;
3007 }
3008
3009 int UtcDaliTypeInfoGetPropertyNameNegative(void)
3010 {
3011   TestApplication application;
3012   Dali::TypeInfo instance;
3013   try
3014   {
3015     int arg1(0);
3016     instance.GetPropertyName(arg1);
3017     DALI_TEST_CHECK(false); // Should not get here
3018   }
3019   catch(...)
3020   {
3021     DALI_TEST_CHECK(true); // We expect an assert
3022   }
3023   END_TEST;
3024 }
3025
3026 int UtcDaliTypeInfoGetPropertyCountNegative(void)
3027 {
3028   TestApplication application;
3029   Dali::TypeInfo instance;
3030   try
3031   {
3032     instance.GetPropertyCount();
3033     DALI_TEST_CHECK(false); // Should not get here
3034   }
3035   catch(...)
3036   {
3037     DALI_TEST_CHECK(true); // We expect an assert
3038   }
3039   END_TEST;
3040 }
3041
3042 int UtcDaliTypeInfoGetPropertyIndicesNegative(void)
3043 {
3044   TestApplication application;
3045   Dali::TypeInfo instance;
3046   try
3047   {
3048     Dali::Vector<int> arg1;
3049     instance.GetPropertyIndices(arg1);
3050     DALI_TEST_CHECK(false); // Should not get here
3051   }
3052   catch(...)
3053   {
3054     DALI_TEST_CHECK(true); // We expect an assert
3055   }
3056   END_TEST;
3057 }
3058
3059 int UtcDaliTypeInfoGetChildPropertyNameNegative(void)
3060 {
3061   TestApplication application;
3062   Dali::TypeInfo instance;
3063   try
3064   {
3065     int arg1(0);
3066     instance.GetChildPropertyName(arg1);
3067     DALI_TEST_CHECK(false); // Should not get here
3068   }
3069   catch(...)
3070   {
3071     DALI_TEST_CHECK(true); // We expect an assert
3072   }
3073   END_TEST;
3074 }
3075
3076 int UtcDaliTypeInfoGetChildPropertyTypeNegative(void)
3077 {
3078   TestApplication application;
3079   Dali::TypeInfo instance;
3080   try
3081   {
3082     int arg1(0);
3083     instance.GetChildPropertyType(arg1);
3084     DALI_TEST_CHECK(false); // Should not get here
3085   }
3086   catch(...)
3087   {
3088     DALI_TEST_CHECK(true); // We expect an assert
3089   }
3090   END_TEST;
3091 }
3092
3093 int UtcDaliTypeInfoGetChildPropertyIndexNegative(void)
3094 {
3095   TestApplication application;
3096   Dali::TypeInfo instance;
3097   try
3098   {
3099     std::string arg1;
3100     instance.GetChildPropertyIndex(arg1);
3101     DALI_TEST_CHECK(false); // Should not get here
3102   }
3103   catch(...)
3104   {
3105     DALI_TEST_CHECK(true); // We expect an assert
3106   }
3107   END_TEST;
3108 }
3109
3110 int UtcDaliTypeInfoGetChildPropertyIndicesNegative(void)
3111 {
3112   TestApplication application;
3113   Dali::TypeInfo instance;
3114   try
3115   {
3116     Dali::Vector<int> arg1;
3117     instance.GetChildPropertyIndices(arg1);
3118     DALI_TEST_CHECK(false); // Should not get here
3119   }
3120   catch(...)
3121   {
3122     DALI_TEST_CHECK(true); // We expect an assert
3123   }
3124   END_TEST;
3125 }
3126
3127 int UtcDaliTypeInfoGetNameNegative(void)
3128 {
3129   TestApplication application;
3130   Dali::TypeInfo instance;
3131   try
3132   {
3133     instance.GetName();
3134     DALI_TEST_CHECK(false); // Should not get here
3135   }
3136   catch(...)
3137   {
3138     DALI_TEST_CHECK(true); // We expect an assert
3139   }
3140   END_TEST;
3141 }
3142
3143 int UtcDaliTypeRegistryGetTypeInfoNegative01(void)
3144 {
3145   TestApplication application;
3146   Dali::TypeRegistry instance;
3147   try
3148   {
3149     std::string arg1;
3150     instance.GetTypeInfo(arg1);
3151     DALI_TEST_CHECK(false); // Should not get here
3152   }
3153   catch(...)
3154   {
3155     DALI_TEST_CHECK(true); // We expect an assert
3156   }
3157   END_TEST;
3158 }
3159
3160 int UtcDaliTypeRegistryGetTypeInfoNegative02(void)
3161 {
3162   TestApplication application;
3163   Dali::TypeRegistry instance;
3164   try
3165   {
3166     instance.GetTypeInfo(typeid(unsigned int));
3167     DALI_TEST_CHECK(false); // Should not get here
3168   }
3169   catch(...)
3170   {
3171     DALI_TEST_CHECK(true); // We expect an assert
3172   }
3173   END_TEST;
3174 }
3175
3176 int UtcDaliTypeRegistryGetTypeNameNegative(void)
3177 {
3178   TestApplication application;
3179   Dali::TypeRegistry instance;
3180   try
3181   {
3182     unsigned long arg1(0u);
3183     instance.GetTypeName(arg1);
3184     DALI_TEST_CHECK(false); // Should not get here
3185   }
3186   catch(...)
3187   {
3188     DALI_TEST_CHECK(true); // We expect an assert
3189   }
3190   END_TEST;
3191 }
3192
3193 int UtcDaliTypeRegistryGetTypeNameCountNegative(void)
3194 {
3195   TestApplication application;
3196   Dali::TypeRegistry instance;
3197   try
3198   {
3199     instance.GetTypeNameCount();
3200     DALI_TEST_CHECK(false); // Should not get here
3201   }
3202   catch(...)
3203   {
3204     DALI_TEST_CHECK(true); // We expect an assert
3205   }
3206   END_TEST;
3207 }