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