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