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