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