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