change Object::OnPropertySet() interface signature.
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-CustomActor.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <dali/public-api/dali-core.h>
21
22 #include <dali/devel-api/actors/custom-actor-devel.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali/integration-api/events/wheel-event-integ.h>
26 #include <dali/integration-api/events/key-event-integ.h>
27 #include <dali/public-api/object/type-registry-helper.h>
28 #include "dali-test-suite-utils/dali-test-suite-utils.h"
29 #include "test-custom-actor.h"
30
31 using namespace Dali;
32
33
34 void custom_actor_test_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void custom_actor_test_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44
45
46 using namespace Dali;
47
48
49 int UtcDaliCustomActorDestructor(void)
50 {
51   TestApplication application;
52
53   CustomActor* actor = new CustomActor();
54   delete actor;
55
56   DALI_TEST_CHECK( true );
57   END_TEST;
58 }
59
60 int UtcDaliCustomActorImplDestructor(void)
61 {
62   TestApplication application;
63   CustomActorImpl* actor = new Test::Impl::TestCustomActor();
64   CustomActor customActor( *actor ); // Will automatically unref at the end of this function
65
66   DALI_TEST_CHECK( true );
67   END_TEST;
68 }
69
70 // Positive test case for a method
71 int UtcDaliCustomActorDownCast(void)
72 {
73   TestApplication application;
74   tet_infoline("Testing Dali::CustomActor::DownCast()");
75
76   Test::TestCustomActor custom = Test::TestCustomActor::New();
77
78   Actor anActor = Actor::New();
79   anActor.Add( custom );
80
81   Actor child = anActor.GetChildAt(0);
82   CustomActor customActor = CustomActor::DownCast( child );
83   DALI_TEST_CHECK( customActor );
84
85   customActor = NULL;
86   DALI_TEST_CHECK( !customActor );
87
88   customActor = DownCast< CustomActor >( child );
89   DALI_TEST_CHECK( customActor );
90   END_TEST;
91 }
92
93 // Negative test case for a method
94 int UtcDaliCustomActorDownCastNegative(void)
95 {
96   TestApplication application;
97   tet_infoline("Testing Dali::CustomActor::DownCast()");
98
99   Actor actor1 = Actor::New();
100   Actor anActor = Actor::New();
101   anActor.Add(actor1);
102
103   Actor child = anActor.GetChildAt(0);
104   CustomActor customActor = CustomActor::DownCast( child );
105   DALI_TEST_CHECK( !customActor );
106
107   Actor unInitialzedActor;
108   customActor = CustomActor::DownCast( unInitialzedActor );
109   DALI_TEST_CHECK( !customActor );
110
111   customActor = DownCast< CustomActor >( unInitialzedActor );
112   DALI_TEST_CHECK( !customActor );
113   END_TEST;
114 }
115
116 int UtcDaliCustomActorMoveConstructor(void)
117 {
118   TestApplication application;
119
120   Test::TestCustomActor custom = Test::TestCustomActor::New();
121   DALI_TEST_CHECK( custom );
122   DALI_TEST_EQUALS( 1, custom.GetBaseObject().ReferenceCount(), TEST_LOCATION );
123
124   int id = custom.GetProperty< int >( Actor::Property::ID );
125
126   Test::TestCustomActor moved = std::move( custom );
127   DALI_TEST_CHECK( moved );
128   DALI_TEST_EQUALS( id, moved.GetProperty< int >( Actor::Property::ID ), TEST_LOCATION );
129   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
130   DALI_TEST_CHECK( !custom );
131
132   END_TEST;
133 }
134
135 int UtcDaliCustomActorMoveAssignment(void)
136 {
137   TestApplication application;
138
139   Test::TestCustomActor custom = Test::TestCustomActor::New();
140   DALI_TEST_CHECK( custom );
141   DALI_TEST_EQUALS( 1, custom.GetBaseObject().ReferenceCount(), TEST_LOCATION );
142
143   int id = custom.GetProperty< int >( Actor::Property::ID );
144
145   Test::TestCustomActor moved;
146   moved = std::move( custom );
147   DALI_TEST_CHECK( moved );
148   DALI_TEST_EQUALS( id, moved.GetProperty< int >( Actor::Property::ID ), TEST_LOCATION );
149   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
150   DALI_TEST_CHECK( !custom );
151
152   END_TEST;
153 }
154
155 int UtcDaliCustomActorOnSceneConnectionDisconnection(void)
156 {
157   TestApplication application;
158   tet_infoline("Testing Dali::CustomActor::OnSceneConnection() & OnSceneDisconnection");
159
160   Test::TestCustomActor custom = Test::TestCustomActor::New();
161   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
162
163   // add the custom actor to stage
164   application.GetScene().Add( custom );
165
166   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
167   DALI_TEST_EQUALS( "OnSceneConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
168
169   application.GetScene().Remove( custom );
170
171   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
172   DALI_TEST_EQUALS( "OnSceneDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
173
174   // Excercise the message passing to Update thread
175
176   application.SendNotification();
177   application.Render();
178   application.Render();
179   END_TEST;
180 }
181
182 int UtcDaliCustomActorOnSceneConnectionOrder(void)
183 {
184   TestApplication application;
185   tet_infoline("Testing Dali::CustomActor::OnSceneConnection() order");
186
187   MasterCallStack.clear();
188
189   /* Build tree of actors:
190    *
191    *       A (parent)
192    *      / \
193    *     B   C
194    *    / \   \
195    *   D   E   F
196    *
197    * OnSceneConnection should be received for A, B, D, E, C, and finally F
198    */
199
200   Test::TestCustomActor actorA = Test::TestCustomActor::New();
201   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
202
203   Test::TestCustomActor actorB = Test::TestCustomActor::New();
204   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
205   actorA.Add( actorB );
206
207   Test::TestCustomActor actorC = Test::TestCustomActor::New();
208   actorC.SetProperty( Actor::Property::NAME, "ActorC" );
209   actorA.Add( actorC );
210
211   Test::TestCustomActor actorD = Test::TestCustomActor::New();
212   actorD.SetProperty( Actor::Property::NAME, "ActorD" );
213   actorB.Add( actorD );
214
215   Test::TestCustomActor actorE = Test::TestCustomActor::New();
216   actorE.SetProperty( Actor::Property::NAME, "ActorE" );
217   actorB.Add( actorE );
218
219   Test::TestCustomActor actorF = Test::TestCustomActor::New();
220   actorF.SetProperty( Actor::Property::NAME, "ActorF" );
221   actorC.Add( actorF );
222
223   // add the custom actor to stage
224   application.GetScene().Add( actorA );
225
226   DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
227   DALI_TEST_EQUALS( "OnPropertySet",     actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
228   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
229   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
230   DALI_TEST_EQUALS( "OnSceneConnection", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
231
232   DALI_TEST_EQUALS( 4, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
233   DALI_TEST_EQUALS( "OnPropertySet",     actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
234   DALI_TEST_EQUALS( "OnChildAdd",        actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
235   DALI_TEST_EQUALS( "OnChildAdd",        actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
236   DALI_TEST_EQUALS( "OnSceneConnection", actorB.GetMethodsCalled()[ 3 ], TEST_LOCATION );
237
238   DALI_TEST_EQUALS( 3, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
239   DALI_TEST_EQUALS( "OnPropertySet",     actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
240   DALI_TEST_EQUALS( "OnChildAdd",        actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
241   DALI_TEST_EQUALS( "OnSceneConnection", actorC.GetMethodsCalled()[ 2 ], TEST_LOCATION );
242
243   DALI_TEST_EQUALS( 2, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
244   DALI_TEST_EQUALS( "OnPropertySet",     actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
245   DALI_TEST_EQUALS( "OnSceneConnection", actorD.GetMethodsCalled()[ 1 ], TEST_LOCATION );
246
247   DALI_TEST_EQUALS( 2, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
248   DALI_TEST_EQUALS( "OnPropertySet",     actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
249   DALI_TEST_EQUALS( "OnSceneConnection", actorE.GetMethodsCalled()[ 1 ], TEST_LOCATION );
250
251   DALI_TEST_EQUALS( 2, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
252   DALI_TEST_EQUALS( "OnPropertySet",     actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
253   DALI_TEST_EQUALS( "OnSceneConnection", actorF.GetMethodsCalled()[ 1 ], TEST_LOCATION );
254
255   // Check sequence is correct in MasterCallStack
256
257   DALI_TEST_EQUALS( 4+4+3+2+2+2, (int)(MasterCallStack.size()), TEST_LOCATION );
258
259   DALI_TEST_EQUALS( "ActorA: OnPropertySet", MasterCallStack[ 0 ], TEST_LOCATION );
260   DALI_TEST_EQUALS( "ActorB: OnPropertySet", MasterCallStack[ 1 ], TEST_LOCATION );
261   DALI_TEST_EQUALS( "ActorA: OnChildAdd",    MasterCallStack[ 2 ], TEST_LOCATION );
262   DALI_TEST_EQUALS( "ActorC: OnPropertySet", MasterCallStack[ 3 ], TEST_LOCATION );
263   DALI_TEST_EQUALS( "ActorA: OnChildAdd",    MasterCallStack[ 4 ], TEST_LOCATION );
264   DALI_TEST_EQUALS( "ActorD: OnPropertySet", MasterCallStack[ 5 ], TEST_LOCATION );
265
266   DALI_TEST_EQUALS( "ActorB: OnChildAdd",    MasterCallStack[ 6 ], TEST_LOCATION );
267   DALI_TEST_EQUALS( "ActorE: OnPropertySet", MasterCallStack[ 7 ], TEST_LOCATION );
268   DALI_TEST_EQUALS( "ActorB: OnChildAdd",    MasterCallStack[ 8 ], TEST_LOCATION );
269   DALI_TEST_EQUALS( "ActorF: OnPropertySet", MasterCallStack[ 9 ], TEST_LOCATION );
270   DALI_TEST_EQUALS( "ActorC: OnChildAdd",    MasterCallStack[ 10 ], TEST_LOCATION );
271
272   DALI_TEST_EQUALS( "ActorA: OnSceneConnection", MasterCallStack[ 11 ], TEST_LOCATION );
273   DALI_TEST_EQUALS( "ActorB: OnSceneConnection", MasterCallStack[ 12 ], TEST_LOCATION );
274   DALI_TEST_EQUALS( "ActorD: OnSceneConnection", MasterCallStack[ 13 ], TEST_LOCATION );
275   DALI_TEST_EQUALS( "ActorE: OnSceneConnection", MasterCallStack[ 14 ], TEST_LOCATION );
276   DALI_TEST_EQUALS( "ActorC: OnSceneConnection", MasterCallStack[ 15 ], TEST_LOCATION );
277   DALI_TEST_EQUALS( "ActorF: OnSceneConnection", MasterCallStack[ 16 ], TEST_LOCATION );
278
279   // Excercise the message passing to Update thread
280
281   application.SendNotification();
282   application.Render();
283   application.Render();
284   END_TEST;
285 }
286
287 int UtcDaliCustomActorOnSceneDisconnectionOrder(void)
288 {
289   TestApplication application;
290   tet_infoline("Testing Dali::CustomActor::OnSceneDisconnection() order");
291
292   Integration::Scene stage = application.GetScene();
293
294   /* Build tree of actors:
295    *
296    *       A (parent)
297    *      / \
298    *     B   C
299    *    / \   \
300    *   D   E   F
301    *
302    * OnSceneDisconnection should be received for D, E, B, F, C, and finally A.
303    */
304
305   Test::TestCustomActor actorA = Test::TestCustomActor::New();
306   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
307   stage.Add( actorA );
308
309   Test::TestCustomActor actorB = Test::TestCustomActor::New();
310   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
311   actorA.Add( actorB );
312
313   Test::TestCustomActor actorC = Test::TestCustomActor::New();
314   actorC.SetProperty( Actor::Property::NAME, "ActorC" );
315   actorA.Add( actorC );
316
317   Test::TestCustomActor actorD = Test::TestCustomActor::New();
318   actorD.SetProperty( Actor::Property::NAME, "ActorD" );
319   actorB.Add( actorD );
320
321   Test::TestCustomActor actorE = Test::TestCustomActor::New();
322   actorE.SetProperty( Actor::Property::NAME, "ActorE" );
323   actorB.Add( actorE );
324
325   Test::TestCustomActor actorF = Test::TestCustomActor::New();
326   actorF.SetProperty( Actor::Property::NAME, "ActorF" );
327   actorC.Add( actorF );
328
329   // Excercise the message passing to Update thread
330
331   application.SendNotification();
332   application.Render();
333   application.Render();
334
335   // Clear call stacks before disconnection
336   actorA.ResetCallStack();
337   actorB.ResetCallStack();
338   actorC.ResetCallStack();
339   actorD.ResetCallStack();
340   actorE.ResetCallStack();
341   actorF.ResetCallStack();
342   MasterCallStack.clear();
343
344   stage.Remove( actorA );
345
346   DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
347   DALI_TEST_EQUALS( "OnSceneDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
348
349   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
350   DALI_TEST_EQUALS( "OnSceneDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
351
352   DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
353   DALI_TEST_EQUALS( "OnSceneDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
354
355   DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
356   DALI_TEST_EQUALS( "OnSceneDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
357
358   DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
359   DALI_TEST_EQUALS( "OnSceneDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
360
361   DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
362   DALI_TEST_EQUALS( "OnSceneDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
363
364   // Check sequence is correct in MasterCallStack
365
366   DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
367
368   DALI_TEST_EQUALS( "ActorD: OnSceneDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
369   DALI_TEST_EQUALS( "ActorE: OnSceneDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
370   DALI_TEST_EQUALS( "ActorB: OnSceneDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
371   DALI_TEST_EQUALS( "ActorF: OnSceneDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
372   DALI_TEST_EQUALS( "ActorC: OnSceneDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
373   DALI_TEST_EQUALS( "ActorA: OnSceneDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
374
375   // Excercise the message passing to Update thread
376
377   application.SendNotification();
378   application.Render();
379   application.Render();
380   END_TEST;
381 }
382
383 int UtcDaliCustomActorAddDuringOnSceneConnection(void)
384 {
385   TestApplication application;
386   tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnSceneConnection() callback");
387
388   Integration::Scene stage = application.GetScene();
389
390   MasterCallStack.clear();
391
392   /* The actorA is a special variant which adds a child to itself during OnSceneConnection()
393    * The actorB is provided as the child
394    */
395
396   Test::TestCustomActor actorB = Test::TestCustomActor::New();
397   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
398
399   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant1( actorB );
400   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
401   stage.Add( actorA );
402
403   // Check callback sequence
404
405   DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
406   DALI_TEST_EQUALS( "OnPropertySet",     actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
407   DALI_TEST_EQUALS( "OnSceneConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
408   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // Called from within OnSceneConnection()
409
410   DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
411   DALI_TEST_EQUALS( "OnPropertySet",     actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
412   DALI_TEST_EQUALS( "OnSceneConnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
413
414   DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
415
416   DALI_TEST_EQUALS( "ActorB: OnPropertySet",     MasterCallStack[ 0 ], TEST_LOCATION );
417   DALI_TEST_EQUALS( "ActorA: OnPropertySet",     MasterCallStack[ 1 ], TEST_LOCATION );
418   DALI_TEST_EQUALS( "ActorA: OnSceneConnection", MasterCallStack[ 2 ], TEST_LOCATION );
419   DALI_TEST_EQUALS( "ActorB: OnSceneConnection", MasterCallStack[ 3 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnSceneConnection()
420   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 4 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnSceneConnection()
421
422   // Excercise the message passing to Update thread
423
424   application.SendNotification();
425   application.Render();
426   application.Render();
427
428   // Check everything is ok after Actors are removed
429
430   stage.Remove( actorA );
431   application.SendNotification();
432   application.Render();
433   application.Render();
434   END_TEST;
435 }
436
437 int UtcDaliCustomActorRemoveDuringOnSceneConnection(void)
438 {
439   TestApplication application;
440   tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnSceneConnection() callback");
441
442   Integration::Scene stage = application.GetScene();
443
444   MasterCallStack.clear();
445
446   /* The actorA is a special variant which removes its children during OnSceneConnection()
447    * Actors B & C are provided as the children
448    */
449
450   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant2();
451   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
452
453   Test::TestCustomActor actorB = Test::TestCustomActor::New();
454   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
455   actorA.Add( actorB );
456
457   Test::TestCustomActor actorC = Test::TestCustomActor::New();
458   actorC.SetProperty( Actor::Property::NAME, "ActorC" );
459   actorA.Add( actorC );
460
461   stage.Add( actorA );
462
463   // Check callback sequence
464
465   DALI_TEST_EQUALS( 6, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
466   DALI_TEST_EQUALS( "OnPropertySet",     actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
467   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
468   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
469   DALI_TEST_EQUALS( "OnSceneConnection", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
470   DALI_TEST_EQUALS( "OnChildRemove",     actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnSceneConnection()
471   DALI_TEST_EQUALS( "OnChildRemove",     actorA.GetMethodsCalled()[ 5 ], TEST_LOCATION ); // Called from within OnSceneConnection()
472
473   DALI_TEST_EQUALS( 8, (int)(MasterCallStack.size()), TEST_LOCATION );
474
475   DALI_TEST_EQUALS( "ActorA: OnPropertySet",     MasterCallStack[ 0 ], TEST_LOCATION );
476   DALI_TEST_EQUALS( "ActorB: OnPropertySet",     MasterCallStack[ 1 ], TEST_LOCATION );
477   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 2 ], TEST_LOCATION );
478   DALI_TEST_EQUALS( "ActorC: OnPropertySet",     MasterCallStack[ 3 ], TEST_LOCATION );
479   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 4 ], TEST_LOCATION );
480   DALI_TEST_EQUALS( "ActorA: OnSceneConnection", MasterCallStack[ 5 ], TEST_LOCATION );
481   DALI_TEST_EQUALS( "ActorA: OnChildRemove",     MasterCallStack[ 6 ], TEST_LOCATION );
482   DALI_TEST_EQUALS( "ActorA: OnChildRemove",     MasterCallStack[ 7 ], TEST_LOCATION );
483
484   /* Actors B & C should be removed before the point where they could receive an OnSceneConnection callback
485    * Therefore they shouldn't receive either OnSceneConnection or OnSceneDisconnection
486    */
487   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
488   DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
489
490   // Excercise the message passing to Update thread
491
492   application.SendNotification();
493   application.Render();
494   application.Render();
495
496   // Check everything is ok after last actor is removed
497
498   stage.Remove( actorA );
499   application.SendNotification();
500   application.Render();
501   application.Render();
502   END_TEST;
503 }
504
505 int UtcDaliCustomActorAddDuringOnSceneDisconnection(void)
506 {
507   TestApplication application;
508   tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnSceneDisonnection() callback");
509
510   Integration::Scene stage = application.GetScene();
511
512   /* The actorA is a special variant which adds a child to itself during OnSceneDisconnection()
513    * The actorB is provided as the child
514    */
515
516   Test::TestCustomActor actorB = Test::TestCustomActor::New();
517   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
518
519   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant3( actorB );
520   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
521   stage.Add( actorA );
522
523   // Excercise the message passing to Update thread
524
525   application.SendNotification();
526   application.Render();
527   application.Render();
528
529   // Clear call stacks before disconnection
530   actorA.ResetCallStack();
531   actorB.ResetCallStack();
532   MasterCallStack.clear();
533
534   stage.Remove( actorA );
535
536   // Check callback sequence
537
538   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
539   DALI_TEST_EQUALS( "OnSceneDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
540   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
541
542   // Child was added after parent disconnection, so should not receive OnSceneConnection()
543   DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
544
545   DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
546
547   DALI_TEST_EQUALS( "ActorA: OnSceneDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
548   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 1 ], TEST_LOCATION );
549
550   // Excercise the message passing to Update thread
551
552   application.SendNotification();
553   application.Render();
554   application.Render();
555   END_TEST;
556 }
557
558 int UtcDaliCustomActorRemoveDuringOnSceneDisconnection(void)
559 {
560   TestApplication application;
561   tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnSceneDisconnection() callback");
562
563   Integration::Scene stage = application.GetScene();
564
565   /* The actorA is a special variant which removes its children during OnSceneDisconnection()
566    * The actorB is provided as the child
567    */
568
569   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant4();
570   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
571   stage.Add( actorA );
572
573   Test::TestCustomActor actorB = Test::TestCustomActor::New();
574   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
575   actorA.Add( actorB );
576
577   // Excercise the message passing to Update thread
578
579   application.SendNotification();
580   application.Render();
581   application.Render();
582
583   // Clear call stacks before disconnection
584   actorA.ResetCallStack();
585   actorB.ResetCallStack();
586   MasterCallStack.clear();
587
588   stage.Remove( actorA );
589
590   // Check callback sequence
591
592   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
593   DALI_TEST_EQUALS( "OnSceneDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
594   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
595
596   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
597   DALI_TEST_EQUALS( "OnSceneDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
598
599   DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
600
601   DALI_TEST_EQUALS( "ActorB: OnSceneDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
602   DALI_TEST_EQUALS( "ActorA: OnSceneDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
603   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 2 ], TEST_LOCATION );
604
605   // Excercise the message passing to Update thread
606
607   application.SendNotification();
608   application.Render();
609   application.Render();
610   END_TEST;
611 }
612
613 int UtcDaliCustomActorRemoveParentDuringOnSceneConnection(void)
614 {
615   TestApplication application;
616   tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnSceneConnection() callback");
617
618   Integration::Scene scene = application.GetScene();
619
620   MasterCallStack.clear();
621
622   /* The actorA is the parent of actorB
623    * The actorB is a special variant which removes its own parent during OnSceneConnection()
624    * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnSceneDisconnection()
625    */
626
627   Test::TestCustomActor actorA = Test::TestCustomActor::New();
628   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
629
630   Test::TestCustomActor actorB = Test::TestCustomActor::NewVariant5(scene);
631   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
632   actorA.Add( actorB );
633
634   scene.Add( actorA );
635
636   // Check callback sequence
637
638   DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
639   DALI_TEST_EQUALS( "OnPropertySet",        actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
640   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
641   DALI_TEST_EQUALS( "OnSceneConnection",    actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
642   DALI_TEST_EQUALS( "OnSceneDisconnection", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
643
644   DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
645   DALI_TEST_EQUALS( "OnPropertySet",     actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
646   DALI_TEST_EQUALS( "OnSceneConnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
647
648   DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
649
650   DALI_TEST_EQUALS( "ActorA: OnPropertySet",        MasterCallStack[ 0 ], TEST_LOCATION );
651   DALI_TEST_EQUALS( "ActorB: OnPropertySet",        MasterCallStack[ 1 ], TEST_LOCATION );
652   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 2 ], TEST_LOCATION );
653   DALI_TEST_EQUALS( "ActorA: OnSceneConnection",    MasterCallStack[ 3 ], TEST_LOCATION );
654   DALI_TEST_EQUALS( "ActorB: OnSceneConnection",    MasterCallStack[ 4 ], TEST_LOCATION );
655   DALI_TEST_EQUALS( "ActorA: OnSceneDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
656
657   // Excercise the message passing to Update thread
658
659   application.SendNotification();
660   application.Render();
661   application.Render();
662   END_TEST;
663 }
664
665 int UtcDaliCustomActorAddParentDuringOnSceneDisconnection(void)
666 {
667   TestApplication application;
668   tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnSceneDisconnection() callback");
669
670   Integration::Scene scene = application.GetScene();
671
672   MasterCallStack.clear();
673
674   /* The actorA is the parent of actorB
675    * The actorB is a special variant which (weirdly) adds its own parent during OnSceneDisconnection()
676    * The child actor is interrupting the disconnection, such that parent should not get a OnSceneDisconnection()
677    */
678
679   Test::TestCustomActor actorA = Test::TestCustomActor::New();
680   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
681   scene.Add( actorA );
682
683   Test::TestCustomActor actorB = Test::TestCustomActor::NewVariant6(scene);
684   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
685   actorA.Add( actorB );
686
687   scene.Remove( actorA );
688
689   // Check callback sequence
690
691   DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
692   DALI_TEST_EQUALS( "OnPropertySet",        actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
693   DALI_TEST_EQUALS( "OnSceneConnection",    actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
694   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
695
696   DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
697   DALI_TEST_EQUALS( "OnPropertySet",        actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
698   DALI_TEST_EQUALS( "OnSceneConnection",    actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
699   DALI_TEST_EQUALS( "OnSceneDisconnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
700   // Disconnect was interrupted, so we should only get one OnSceneConnection() for actorB
701
702   DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
703
704   DALI_TEST_EQUALS( "ActorA: OnPropertySet",        MasterCallStack[ 0 ], TEST_LOCATION );
705   DALI_TEST_EQUALS( "ActorA: OnSceneConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
706   DALI_TEST_EQUALS( "ActorB: OnPropertySet",        MasterCallStack[ 2 ], TEST_LOCATION );
707   DALI_TEST_EQUALS( "ActorB: OnSceneConnection",    MasterCallStack[ 3 ], TEST_LOCATION );
708   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 4 ], TEST_LOCATION );
709   DALI_TEST_EQUALS( "ActorB: OnSceneDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
710
711   // Excercise the message passing to Update thread
712
713   application.SendNotification();
714   application.Render();
715   application.Render();
716   END_TEST;
717 }
718
719 int UtcDaliCustomActorOnChildAddRemove(void)
720 {
721   TestApplication application;
722   tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
723
724   Test::TestCustomActor custom = Test::TestCustomActor::New();
725   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
726
727   Actor aChild = Actor::New();
728   custom.Add( aChild );
729
730   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
731   DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
732
733   custom.Remove( aChild );
734
735   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
736   DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
737   END_TEST;
738 }
739
740 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
741 {
742   TestApplication application;
743   tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
744
745   Integration::Scene stage = application.GetScene();
746
747   MasterCallStack.clear();
748
749   /* The actorA is a special variant which reparents children added into a separate container child
750    * The actorB is the child of actorA
751    */
752
753   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant7( "ActorA" );
754   stage.Add( actorA );
755
756   Test::TestCustomActor actorB = Test::TestCustomActor::New();
757   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
758   actorA.Add( actorB );
759
760   // Check hierarchy is as follows:
761   //  A
762   //  |
763   //  Container
764   //  |
765   //  B
766
767   DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
768
769   Actor container = actorA.GetChildAt(0);
770   Actor containerChild;
771
772   DALI_TEST_CHECK( container );
773   if ( container )
774   {
775     DALI_TEST_EQUALS( "Container", container.GetProperty< std::string >( Actor::Property::NAME ), TEST_LOCATION );
776     DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
777     containerChild = container.GetChildAt(0);
778   }
779
780   DALI_TEST_CHECK( containerChild );
781   if ( containerChild )
782   {
783     DALI_TEST_EQUALS( "ActorB", containerChild.GetProperty< std::string >( Actor::Property::NAME ), TEST_LOCATION );
784     DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
785   }
786
787   // Check callback sequence
788
789   DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
790   DALI_TEST_EQUALS( "OnPropertySet",        actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
791   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // The mContainer added to actorA
792   DALI_TEST_EQUALS( "OnSceneConnection",    actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
793   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // The actorB added to actorA
794   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION );
795   // mContainer will then receive OnChildAdd
796
797   DALI_TEST_EQUALS( 4, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
798   DALI_TEST_EQUALS( "OnPropertySet",        actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
799   DALI_TEST_EQUALS( "OnSceneConnection",    actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
800   DALI_TEST_EQUALS( "OnSceneDisconnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
801   DALI_TEST_EQUALS( "OnSceneConnection",    actorB.GetMethodsCalled()[ 3 ], TEST_LOCATION );
802
803   DALI_TEST_EQUALS( 9, (int)(MasterCallStack.size()), TEST_LOCATION );
804
805   DALI_TEST_EQUALS( "ActorA: OnPropertySet",        MasterCallStack[ 0 ], TEST_LOCATION );
806   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 1 ], TEST_LOCATION );
807   DALI_TEST_EQUALS( "ActorA: OnSceneConnection",    MasterCallStack[ 2 ], TEST_LOCATION );
808   DALI_TEST_EQUALS( "ActorB: OnPropertySet",        MasterCallStack[ 3 ], TEST_LOCATION );
809   DALI_TEST_EQUALS( "ActorB: OnSceneConnection",    MasterCallStack[ 4 ], TEST_LOCATION );
810   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 5 ], TEST_LOCATION );
811   DALI_TEST_EQUALS( "ActorB: OnSceneDisconnection", MasterCallStack[ 6 ], TEST_LOCATION );
812   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 7 ], TEST_LOCATION );
813   DALI_TEST_EQUALS( "ActorB: OnSceneConnection",    MasterCallStack[ 8 ], TEST_LOCATION );
814
815   // Excercise the message passing to Update thread
816
817   application.SendNotification();
818   application.Render();
819   application.Render();
820   END_TEST;
821 }
822
823 /**
824  * Test that Remove can be called (a NOOP) during the OnChildRemove
825  * triggered when reparenting an actor
826  */
827 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
828 {
829   TestApplication application;
830   tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
831
832   Integration::Scene stage = application.GetScene();
833
834   MasterCallStack.clear();
835
836   /* The childActor will be reparented from actorA to actorB
837    * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
838    * This should be a NOOP since the reparenting has not occured yet
839    */
840
841   Test::TestCustomActor actorB = Test::TestCustomActor::New();
842   actorB.SetProperty( Actor::Property::NAME, "ActorB" );
843   stage.Add( actorB );
844
845   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant8( actorB );
846   actorA.SetProperty( Actor::Property::NAME, "ActorA" );
847   stage.Add( actorA );
848
849   Actor childActor = Actor::New();
850   childActor.SetProperty( Actor::Property::NAME, "Child" );
851   // Reparent from actorA to actorB
852   actorA.Add( childActor );
853   actorB.Add( childActor );
854
855   // Check hierarchy is as follows:
856   //  A    B
857   //       |
858   //       Child
859
860   DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
861   DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
862   DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
863
864   Actor child = actorB.GetChildAt(0);
865
866   DALI_TEST_CHECK( child );
867   if ( child )
868   {
869     DALI_TEST_EQUALS( "Child", child.GetProperty< std::string >( Actor::Property::NAME ), TEST_LOCATION );
870   }
871
872   // Check callback sequence
873
874   DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
875   DALI_TEST_EQUALS( "OnPropertySet",        actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
876   DALI_TEST_EQUALS( "OnSceneConnection",    actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // The mContainer added to actorA
877   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
878   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // The actorB added to actorA
879   // mContainer will then receive OnChildAdd
880
881   DALI_TEST_EQUALS( 4, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
882   DALI_TEST_EQUALS( "OnPropertySet",        actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
883   DALI_TEST_EQUALS( "OnSceneConnection",    actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
884   // The derived class are always notified, no matter the child is successfully removed or not
885   DALI_TEST_EQUALS( "OnChildRemove",        actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
886   DALI_TEST_EQUALS( "OnChildAdd",           actorB.GetMethodsCalled()[ 3 ], TEST_LOCATION );
887
888   DALI_TEST_EQUALS( 8, (int)(MasterCallStack.size()), TEST_LOCATION );
889
890   DALI_TEST_EQUALS( "ActorB: OnPropertySet",        MasterCallStack[ 0 ], TEST_LOCATION );
891   DALI_TEST_EQUALS( "ActorB: OnSceneConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
892   DALI_TEST_EQUALS( "ActorA: OnPropertySet",        MasterCallStack[ 2 ], TEST_LOCATION );
893   DALI_TEST_EQUALS( "ActorA: OnSceneConnection",    MasterCallStack[ 3 ], TEST_LOCATION );
894   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 4 ], TEST_LOCATION );
895   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 5 ], TEST_LOCATION );
896   // The derived class are always notified, no matter the child is successfully removed or not
897   DALI_TEST_EQUALS( "ActorB: OnChildRemove",        MasterCallStack[ 6 ], TEST_LOCATION );
898   DALI_TEST_EQUALS( "ActorB: OnChildAdd",           MasterCallStack[ 7 ], TEST_LOCATION );
899
900   // Excercise the message passing to Update thread
901
902   application.SendNotification();
903   application.Render();
904   application.Render();
905   END_TEST;
906 }
907
908 int UtcDaliCustomActorOnPropertySet(void)
909 {
910   TestApplication application;
911   tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
912
913   Test::TestCustomActor custom = Test::TestCustomActor::New();
914   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
915
916   custom.SetDaliProperty("yes");
917
918   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
919   DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
920   END_TEST;
921 }
922
923 int UtcDaliCustomActorOnSizeSet(void)
924 {
925   TestApplication application;
926   tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
927
928   Test::TestCustomActor custom = Test::TestCustomActor::New();
929   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
930
931   custom.SetProperty( Actor::Property::SIZE, Vector2( 9.0f, 10.0f ) );
932   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
933   DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
934   DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
935   DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
936   DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
937
938   custom.SetProperty( Actor::Property::SIZE, Vector3( 4.0f, 5.0f, 6.0f ) );
939   DALI_TEST_EQUALS( 4, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
940   DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 2 ], TEST_LOCATION );
941   DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 3 ], TEST_LOCATION );
942   DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
943   DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
944   DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
945   END_TEST;
946 }
947
948 int UtcDaliCustomActorOnSizeAnimation(void)
949 {
950   TestApplication application;
951   tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
952
953   Test::TestCustomActor custom = Test::TestCustomActor::New();
954   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
955
956   Animation anim = Animation::New( 1.0f );
957   anim.AnimateTo( Property( custom, Actor::Property::SIZE ), Vector3( 8.0f, 9.0f, 10.0f ) );
958   anim.Play();
959
960   application.SendNotification();
961   application.Render( static_cast<unsigned int>( 1000.0f ) );
962
963   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
964   DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
965   DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
966   DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
967   DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
968   END_TEST;
969 }
970
971 int UtcDaliCustomActorSizeComponentAnimation(void)
972 {
973   TestApplication application;
974   tet_infoline("Testing Size component animation");
975
976   Test::TestCustomActor custom = Test::TestCustomActor::New();
977   float intialWidth( 10.0f );
978
979   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
980   custom.SetProperty( Actor::Property::SIZE, Vector2( intialWidth, 10.0f) ); // First method
981
982   Animation anim = Animation::New( 1.0f );
983
984   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
985
986   anim.AnimateTo( Property( custom, Actor::Property::SIZE_WIDTH ), 20.0f );
987
988   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
989
990   anim.Play();   // Triggers second method ( OnSizeAnimation )
991
992   application.SendNotification();
993   application.Render( static_cast<unsigned int>( 1000.0f ) );
994
995   DALI_TEST_EQUALS( 3, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
996
997   DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 2 ], TEST_LOCATION );
998
999   END_TEST;
1000 }
1001
1002 int UtcDaliCustomActorOnHoverEvent(void)
1003 {
1004   TestApplication application;
1005   tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1006
1007   Test::TestCustomActor custom = Test::TestCustomActor::New();
1008   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1009
1010   // set size for custom actor
1011   custom.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
1012   // add the custom actor to stage
1013   application.GetScene().Add( custom );
1014   custom.ResetCallStack();
1015
1016   // Render and notify a couple of times
1017   application.SendNotification();
1018   application.Render();
1019   application.SendNotification();
1020   application.Render();
1021
1022   // simulate a hover event
1023   Dali::Integration::Point point;
1024   point.SetState( PointState::MOTION );
1025   point.SetScreenPosition( Vector2( 1, 1 ) );
1026   Dali::Integration::HoverEvent event;
1027   event.AddPoint( point );
1028   application.ProcessEvent( event );
1029
1030   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1031   DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1032   END_TEST;
1033 }
1034
1035 int UtcDaliCustomActorOnWheelEvent(void)
1036 {
1037   TestApplication application;
1038   tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
1039
1040   Test::TestCustomActor custom = Test::TestCustomActor::New();
1041   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1042
1043   // set size for custom actor
1044   custom.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
1045   // add the custom actor to stage
1046   application.GetScene().Add( custom );
1047   custom.ResetCallStack();
1048
1049   // Render and notify a couple of times
1050   application.SendNotification();
1051   application.Render();
1052   application.SendNotification();
1053   application.Render();
1054
1055   // simulate a wheel event
1056   Vector2 screenCoordinates( 10.0f, 10.0f );
1057   Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
1058   application.ProcessEvent( event );
1059
1060   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1061   DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1062   END_TEST;
1063 }
1064
1065 int UtcDaliCustomActorImplOnPropertySet(void)
1066 {
1067   TestApplication application;
1068   CustomActorImpl* impl = new Test::Impl::SimpleTestCustomActor();
1069   CustomActor customActor( *impl ); // Will automatically unref at the end of this function
1070
1071   impl->OnPropertySet( 0, 0 );
1072
1073   DALI_TEST_CHECK( true );
1074
1075   END_TEST;
1076 }
1077
1078 int UtcDaliCustomActorGetImplementation(void)
1079 {
1080   TestApplication application;
1081
1082   Test::TestCustomActor custom = Test::TestCustomActor::New();
1083   CustomActorImpl& impl = custom.GetImplementation();
1084   impl.GetOwner();  // Test
1085
1086   const Test::TestCustomActor constCustom = Test::TestCustomActor::New();
1087   const CustomActorImpl& constImpl = constCustom.GetImplementation();
1088   constImpl.GetOwner();  // Test
1089
1090   DALI_TEST_CHECK( true );
1091   END_TEST;
1092 }
1093
1094 int UtcDaliCustomActorDoAction(void)
1095 {
1096   TestApplication application;
1097   tet_infoline("Testing Dali::CustomActor::DoAction()");
1098
1099   Test::TestCustomActor custom = Test::TestCustomActor::New();
1100
1101   BaseHandle customActorObject = custom;
1102
1103   DALI_TEST_CHECK(customActorObject);
1104
1105   Property::Map attributes;
1106
1107   // Check that an invalid command is not performed
1108   DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1109
1110   // Check that the custom actor is visible
1111   custom.SetProperty( Actor::Property::VISIBLE,true);
1112   DALI_TEST_CHECK(custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
1113
1114   // Check the custom actor performed an action to hide itself
1115   DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1116
1117   // flush the queue and render once
1118   application.SendNotification();
1119   application.Render();
1120
1121   // Check that the custom actor is now invisible
1122   DALI_TEST_CHECK(custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
1123
1124   // Check the custom actor performed an action to show itself
1125   DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1126
1127   // flush the queue and render once
1128   application.SendNotification();
1129   application.Render();
1130
1131   // Check that the custom actor is now visible
1132   DALI_TEST_CHECK(custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
1133   END_TEST;
1134 }
1135
1136 int UtcDaliCustomActorCustomActor(void)
1137 {
1138   Dali::CustomActor customA;
1139   Dali::CustomActor customB( customA );
1140
1141   DALI_TEST_CHECK( customA == customB );
1142
1143   END_TEST;
1144 }
1145
1146 int UtcDaliCustomActorImplRelayoutRequest(void)
1147 {
1148   TestApplication application;
1149
1150   DALI_TEST_CHECK( gOnRelayout == false );
1151
1152   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1153   application.GetScene().Add(custom);
1154
1155   application.SendNotification();
1156   application.Render();
1157
1158   DALI_TEST_CHECK( gOnRelayout == true );
1159   gOnRelayout = false;
1160
1161   custom.TestRelayoutRequest();
1162   application.SendNotification();
1163   application.Render();
1164
1165   DALI_TEST_CHECK( gOnRelayout == true );
1166
1167   END_TEST;
1168 }
1169
1170 int UtcDaliCustomActorImplGetHeightForWidthBase(void)
1171 {
1172   TestApplication application;
1173   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1174
1175   float width = 300.0f;
1176
1177   application.SendNotification();
1178   application.Render();
1179
1180   float v = custom.TestGetHeightForWidthBase( width );
1181
1182   DALI_TEST_CHECK( v == width );
1183
1184   END_TEST;
1185 }
1186
1187 int UtcDaliCustomActorImplGetWidthForHeightBase(void)
1188 {
1189   TestApplication application;
1190   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1191
1192   float height = 300.0f;
1193
1194   application.SendNotification();
1195   application.Render();
1196
1197   float v = custom.TestGetWidthForHeightBase( height );
1198
1199   DALI_TEST_CHECK( v == height );
1200
1201   END_TEST;
1202 }
1203
1204 int UtcDaliCustomActorImplCalculateChildSizeBase(void)
1205 {
1206   TestApplication application;
1207   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1208
1209   Actor child = Actor::New();
1210   child.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1211   child.SetProperty( Actor::Property::SIZE, Vector2( 150, 150 ) );
1212
1213   application.SendNotification();
1214   application.Render();
1215
1216   float v = custom.TestCalculateChildSizeBase( child, Dali::Dimension::ALL_DIMENSIONS );
1217   DALI_TEST_CHECK( v == 0.0f );
1218
1219   END_TEST;
1220 }
1221
1222 int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
1223 {
1224   TestApplication application;
1225   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1226   custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
1227
1228   bool v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::ALL_DIMENSIONS );
1229   DALI_TEST_CHECK( v == true );
1230
1231   application.SendNotification();
1232   application.Render();
1233
1234   custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1235   v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::WIDTH );
1236   DALI_TEST_CHECK( v == false );
1237
1238   // why is this here?
1239   application.SendNotification();
1240   application.Render();
1241
1242   END_TEST;
1243 }
1244
1245 int UtcDaliCustomActorTypeRegistry(void)
1246 {
1247   TestApplication application;
1248
1249   // Register Type
1250   TypeInfo type;
1251   type = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
1252   DALI_TEST_CHECK( type );
1253   BaseHandle handle = type.CreateInstance();
1254
1255   std::string name;
1256   std::string exception;
1257
1258   try
1259   {
1260     name = handle.GetTypeName();
1261     tet_result(TET_FAIL);
1262   }
1263   catch( DaliException& e )
1264   {
1265     exception = e.condition;
1266     DALI_TEST_EQUALS( exception, "handle && \"BaseObject handle is empty\"", TEST_LOCATION );
1267   }
1268
1269   END_TEST;
1270 }
1271
1272
1273 int UtcDaliCustomActorGetExtensionP(void)
1274 {
1275   TestApplication application;
1276
1277   Test::TestCustomActor custom = Test::TestCustomActor::NewVariant5(application.GetScene());
1278
1279   DALI_TEST_CHECK( NULL == custom.GetImplementation().GetExtension() );
1280
1281   END_TEST;
1282 }
1283
1284 int UtcDaliCustomActorOnConnectionDepth(void)
1285 {
1286   TestApplication application;
1287   tet_infoline("Testing Dali::CustomActor::OnSceneConnection() hierarchy depth");
1288
1289   Integration::Scene stage = application.GetScene();
1290
1291   /* Build tree of actors:
1292    *
1293    *                      Depth
1294    *
1295    *       A (parent)       1
1296    *      / \
1297    *     B   C              2
1298    *    / \   \
1299    *   D   E   F            3
1300    *
1301    * OnSceneConnection should return 1 for A, 2 for B and C, and 3 for D, E and F.
1302    */
1303
1304   Test::TestCustomActor actorA = Test::TestCustomActor::New();
1305   stage.Add( actorA );
1306
1307   Test::TestCustomActor actorB = Test::TestCustomActor::New();
1308   actorA.Add( actorB );
1309
1310   Test::TestCustomActor actorC = Test::TestCustomActor::New();
1311   actorA.Add( actorC );
1312
1313   Test::TestCustomActor actorD = Test::TestCustomActor::New();
1314   actorB.Add( actorD );
1315
1316   Test::TestCustomActor actorE = Test::TestCustomActor::New();
1317   actorB.Add( actorE );
1318
1319   Test::TestCustomActor actorF = Test::TestCustomActor::New();
1320   actorC.Add( actorF );
1321
1322   // Excercise the message passing to Update thread
1323   application.SendNotification();
1324   application.Render();
1325   application.Render();
1326
1327   DALI_TEST_EQUALS( 1u, actorA.GetDepth(), TEST_LOCATION );
1328   DALI_TEST_EQUALS( 2u, actorB.GetDepth(), TEST_LOCATION );
1329   DALI_TEST_EQUALS( 2u, actorC.GetDepth(), TEST_LOCATION );
1330   DALI_TEST_EQUALS( 3u, actorD.GetDepth(), TEST_LOCATION );
1331   DALI_TEST_EQUALS( 3u, actorE.GetDepth(), TEST_LOCATION );
1332   DALI_TEST_EQUALS( 3u, actorF.GetDepth(), TEST_LOCATION );
1333
1334   END_TEST;
1335 }
1336
1337
1338 int UtcDaliCustomActorSetGetProperty(void)
1339 {
1340   TestApplication application; // Need the type registry
1341
1342   Test::TestCustomActor actor = Test::TestCustomActor::New();
1343   application.GetScene().Add( actor );
1344
1345   actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1, 0.5f );
1346   actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2, Color::WHITE );
1347   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3, Color::BLUE );
1348   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4, 20 );
1349   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5, 40.0f );
1350
1351   Property::Value value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1 );
1352   DALI_TEST_EQUALS( value.Get<float>(), 0.5f, 0.001f, TEST_LOCATION );
1353
1354   value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2 );
1355   DALI_TEST_EQUALS( value.Get<Vector4>(), Color::WHITE, 0.001f, TEST_LOCATION );
1356
1357
1358   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3 );
1359   DALI_TEST_EQUALS( value.Get<Vector4>(), Color::BLUE, 0.001f, TEST_LOCATION );
1360
1361   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4 );
1362   DALI_TEST_EQUALS( value.Get<int>(), 20, TEST_LOCATION );
1363
1364   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5 );
1365   DALI_TEST_EQUALS( value.Get<float>(), 40.0f, 0.001f, TEST_LOCATION );
1366
1367   // Get read-only property
1368   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY6 );
1369   DALI_TEST_EQUALS( value.Get<float>(), 10.0f, 0.001f, TEST_LOCATION );
1370
1371   // Attempt to set read-only property and then ensure value hasn't changed
1372   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY6, 40.0f );
1373   DALI_TEST_EQUALS( value.Get<float>(), 10.0f, 0.001f, TEST_LOCATION );
1374
1375   END_TEST;
1376 }
1377
1378 int utcDaliActorGetTypeInfo(void)
1379 {
1380   TestApplication application;
1381   tet_infoline( "Get the type info of a derived actor" );
1382
1383   Test::TestCustomActor customActor = Test::TestCustomActor::New();
1384
1385   Dali::TypeInfo typeInfo = Dali::DevelCustomActor::GetTypeInfo( customActor );
1386
1387   DALI_TEST_EQUALS( typeInfo.GetName(), std::string("TestCustomActor"), TEST_LOCATION );
1388
1389   END_TEST;
1390 }
1391
1392 namespace Impl
1393 {
1394 /**
1395  * A custom actor that is not type registered on purpose
1396  */
1397 struct UnregisteredCustomActor : public Dali::CustomActorImpl
1398 {
1399   UnregisteredCustomActor() : CustomActorImpl( ACTOR_BEHAVIOUR_DEFAULT )
1400   { }
1401   virtual ~UnregisteredCustomActor()
1402   { }
1403   virtual void OnSceneConnection( int32_t depth )
1404   { }
1405   virtual void OnSceneDisconnection()
1406   { }
1407   virtual void OnChildAdd(Actor& child)
1408   { }
1409   virtual void OnChildRemove(Actor& child)
1410   { }
1411   virtual void OnPropertySet( Property::Index index, const Property::Value& propertyValue )
1412   { }
1413   virtual void OnSizeSet(const Vector3& targetSize)
1414   { }
1415   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
1416   { }
1417   virtual bool OnHoverEvent(const HoverEvent& event)
1418   { return false; }
1419   virtual bool OnKeyEvent(const KeyEvent& event)
1420   { return false; }
1421   virtual bool OnWheelEvent(const WheelEvent& event)
1422   { return false; }
1423   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
1424   { }
1425   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
1426   { }
1427   virtual Vector3 GetNaturalSize()
1428   { return Vector3(); }
1429   virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
1430   { return 0.f; }
1431   virtual float GetHeightForWidth( float width )
1432   { return 0.f; }
1433   virtual float GetWidthForHeight( float height )
1434   { return 0.f; }
1435   virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
1436   { return false; }
1437   virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
1438   { }
1439   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
1440   { }
1441 };
1442 }
1443 struct UnregisteredCustomActor : public Dali::CustomActor
1444 {
1445   static UnregisteredCustomActor New()
1446   {
1447     Impl::UnregisteredCustomActor* impl = new Impl::UnregisteredCustomActor;
1448     UnregisteredCustomActor custom( *impl ); // takes ownership
1449     return custom;
1450   }
1451   UnregisteredCustomActor()
1452   { }
1453   ~UnregisteredCustomActor()
1454   { }
1455   UnregisteredCustomActor( Internal::CustomActor* impl )
1456   : CustomActor( impl )
1457   { }
1458   UnregisteredCustomActor( Impl::UnregisteredCustomActor& impl )
1459   : CustomActor( impl )
1460   { }
1461   static UnregisteredCustomActor DownCast( BaseHandle handle )
1462   {
1463     UnregisteredCustomActor hndl;
1464     CustomActor custom = Dali::CustomActor::DownCast( handle );
1465     if( custom )
1466     {
1467       CustomActorImpl& customImpl = custom.GetImplementation();
1468
1469       Impl::UnregisteredCustomActor* impl = dynamic_cast<Impl::UnregisteredCustomActor*>( &customImpl );
1470
1471       if( impl )
1472       {
1473         hndl = UnregisteredCustomActor( customImpl.GetOwner() );
1474       }
1475     }
1476     return hndl;
1477   }
1478 };
1479
1480 int UtcDaliCustomActorSetGetActorPropertyActionSignal(void)
1481 {
1482   TestApplication application; // Need the type registry
1483
1484   auto custom = UnregisteredCustomActor::New();
1485   application.GetScene().Add( custom );
1486
1487   // should have all actor properties
1488   DALI_TEST_EQUALS( custom.GetPropertyType( Actor::Property::COLOR ), Property::VECTOR4, TEST_LOCATION );
1489   auto actorHandle = Actor::New();
1490   DALI_TEST_EQUALS( custom.GetPropertyCount(), actorHandle.GetPropertyCount(), TEST_LOCATION );
1491
1492   DALI_TEST_EQUALS( custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
1493   custom.SetProperty( Actor::Property::VISIBLE, false );
1494   application.SendNotification();
1495   application.Render(); // IsVisible returns scene value
1496   DALI_TEST_EQUALS( custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
1497
1498   // should have custom actor typename (as it has not registered itself)
1499   DALI_TEST_EQUALS( "CustomActor", custom.GetTypeName(), TEST_LOCATION );
1500
1501   // should have actor actions
1502   custom.DoAction( "show",  Property::Map() );
1503   DALI_TEST_EQUALS( custom.GetProperty( Actor::Property::VISIBLE ).Get<bool>(), true, TEST_LOCATION );
1504
1505   Animation animation = Animation::New(0.01f); // very short animation
1506   // should be able to animate actor property
1507   animation.AnimateTo( Property( custom, Actor::Property::POSITION ), Vector3( 100.0f, 150.0f, 200.0f ) );
1508   animation.Play();
1509
1510   application.SendNotification();
1511   application.Render(1000.f);
1512
1513   DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetProperty( Actor::Property::POSITION ).Get<Vector3>(), TEST_LOCATION );
1514   DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1515
1516   Dali::WeakHandle<UnregisteredCustomActor> weakRef( custom );
1517   // should have actor signals
1518   custom.ConnectSignal( &application, "offScene",
1519     [weakRef]()
1520       {
1521         DALI_TEST_EQUALS( weakRef.GetHandle().GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ), false, TEST_LOCATION );
1522       } );
1523
1524   application.GetScene().Remove( custom );
1525   application.GetScene().Add( custom );
1526
1527   END_TEST;
1528 }
1529
1530 namespace Impl
1531 {
1532 struct DerivedCustomActor : public UnregisteredCustomActor
1533 { };
1534 }
1535
1536 struct DerivedCustomActor : public UnregisteredCustomActor
1537 {
1538   static DerivedCustomActor New()
1539   {
1540     Impl::DerivedCustomActor* impl = new Impl::DerivedCustomActor;
1541     DerivedCustomActor custom( *impl ); // takes ownership
1542     return custom;
1543   }
1544   DerivedCustomActor()
1545   { }
1546   ~DerivedCustomActor()
1547   { }
1548   DerivedCustomActor( Internal::CustomActor* impl )
1549   : UnregisteredCustomActor( impl )
1550   { }
1551   DerivedCustomActor( Impl::UnregisteredCustomActor& impl )
1552   : UnregisteredCustomActor( impl )
1553   { }
1554 };
1555
1556 // register custom
1557 DALI_TYPE_REGISTRATION_BEGIN( DerivedCustomActor, UnregisteredCustomActor, nullptr );
1558 DALI_TYPE_REGISTRATION_END()
1559
1560 int UtcDaliCustomActorPropertyRegistrationDefaultValue(void)
1561 {
1562   TestApplication application; // Need the type registry
1563
1564   // register our base and add a property with default value for it
1565   Dali::TypeRegistration typeRegistration( typeid( UnregisteredCustomActor ), typeid( Dali::CustomActor ), nullptr );
1566
1567   auto derived = DerivedCustomActor::New();
1568   application.GetScene().Add( derived );
1569
1570   // should have all actor properties
1571   DALI_TEST_EQUALS( derived.GetPropertyType( Actor::Property::WORLD_MATRIX ), Property::MATRIX, TEST_LOCATION );
1572   auto actorHandle = Actor::New();
1573   DALI_TEST_EQUALS( derived.GetPropertyCount(), actorHandle.GetPropertyCount(), TEST_LOCATION );
1574
1575   // add a property in base class
1576   AnimatablePropertyRegistration( typeRegistration, "Foobar", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, 10.f );
1577
1578   // should be one more property now
1579   DALI_TEST_EQUALS( derived.GetPropertyCount(), actorHandle.GetPropertyCount() + 1, TEST_LOCATION );
1580   // check that the default value is set for base class
1581   DALI_TEST_EQUALS( UnregisteredCustomActor::New().GetProperty(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX).Get<float>(), 10.f, TEST_LOCATION );
1582   // check that the default value is set for the derived instance as well
1583   DALI_TEST_EQUALS( derived.GetProperty(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX).Get<float>(), 10.f, TEST_LOCATION );
1584
1585   END_TEST;
1586 }