Revert "Revert "HoverEvent class pimpling""
[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
1003 int UtcDaliCustomActorOnTouchEvent(void)
1004 {
1005   TestApplication application;
1006   tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
1007
1008   Test::TestCustomActor custom = Test::TestCustomActor::New();
1009   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1010
1011   // set size for custom actor
1012   custom.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
1013   // add the custom actor to stage
1014   application.GetScene().Add( custom );
1015   custom.ResetCallStack();
1016
1017   // Render and notify a couple of times
1018   application.SendNotification();
1019   application.Render();
1020   application.SendNotification();
1021   application.Render();
1022
1023   // simulate a touch event
1024   Dali::Integration::Point point;
1025   point.SetState( PointState::DOWN );
1026   point.SetScreenPosition( Vector2( 1, 1 ) );
1027   Dali::Integration::TouchEvent event;
1028   event.AddPoint( point );
1029   application.ProcessEvent( event );
1030
1031   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1032   DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1033   END_TEST;
1034 }
1035
1036 int UtcDaliCustomActorOnHoverEvent(void)
1037 {
1038   TestApplication application;
1039   tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
1040
1041   Test::TestCustomActor custom = Test::TestCustomActor::New();
1042   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1043
1044   // set size for custom actor
1045   custom.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
1046   // add the custom actor to stage
1047   application.GetScene().Add( custom );
1048   custom.ResetCallStack();
1049
1050   // Render and notify a couple of times
1051   application.SendNotification();
1052   application.Render();
1053   application.SendNotification();
1054   application.Render();
1055
1056   // simulate a hover event
1057   Dali::Integration::Point point;
1058   point.SetState( PointState::MOTION );
1059   point.SetScreenPosition( Vector2( 1, 1 ) );
1060   Dali::Integration::HoverEvent event;
1061   event.AddPoint( point );
1062   application.ProcessEvent( event );
1063
1064   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1065   DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1066   END_TEST;
1067 }
1068
1069 int UtcDaliCustomActorOnWheelEvent(void)
1070 {
1071   TestApplication application;
1072   tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
1073
1074   Test::TestCustomActor custom = Test::TestCustomActor::New();
1075   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1076
1077   // set size for custom actor
1078   custom.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
1079   // add the custom actor to stage
1080   application.GetScene().Add( custom );
1081   custom.ResetCallStack();
1082
1083   // Render and notify a couple of times
1084   application.SendNotification();
1085   application.Render();
1086   application.SendNotification();
1087   application.Render();
1088
1089   // simulate a wheel event
1090   Vector2 screenCoordinates( 10.0f, 10.0f );
1091   Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
1092   application.ProcessEvent( event );
1093
1094   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1095   DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1096   END_TEST;
1097 }
1098
1099 int UtcDaliCustomActorImplOnPropertySet(void)
1100 {
1101   TestApplication application;
1102   CustomActorImpl* impl = new Test::Impl::SimpleTestCustomActor();
1103   CustomActor customActor( *impl ); // Will automatically unref at the end of this function
1104
1105   impl->OnPropertySet( 0, 0 );
1106
1107   DALI_TEST_CHECK( true );
1108
1109   END_TEST;
1110 }
1111
1112 int UtcDaliCustomActorGetImplementation(void)
1113 {
1114   TestApplication application;
1115
1116   Test::TestCustomActor custom = Test::TestCustomActor::New();
1117   CustomActorImpl& impl = custom.GetImplementation();
1118   impl.GetOwner();  // Test
1119
1120   const Test::TestCustomActor constCustom = Test::TestCustomActor::New();
1121   const CustomActorImpl& constImpl = constCustom.GetImplementation();
1122   constImpl.GetOwner();  // Test
1123
1124   DALI_TEST_CHECK( true );
1125   END_TEST;
1126 }
1127
1128 int UtcDaliCustomActorDoAction(void)
1129 {
1130   TestApplication application;
1131   tet_infoline("Testing Dali::CustomActor::DoAction()");
1132
1133   Test::TestCustomActor custom = Test::TestCustomActor::New();
1134
1135   BaseHandle customActorObject = custom;
1136
1137   DALI_TEST_CHECK(customActorObject);
1138
1139   Property::Map attributes;
1140
1141   // Check that an invalid command is not performed
1142   DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1143
1144   // Check that the custom actor is visible
1145   custom.SetProperty( Actor::Property::VISIBLE,true);
1146   DALI_TEST_CHECK(custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
1147
1148   // Check the custom actor performed an action to hide itself
1149   DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1150
1151   // flush the queue and render once
1152   application.SendNotification();
1153   application.Render();
1154
1155   // Check that the custom actor is now invisible
1156   DALI_TEST_CHECK(custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
1157
1158   // Check the custom actor performed an action to show itself
1159   DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1160
1161   // flush the queue and render once
1162   application.SendNotification();
1163   application.Render();
1164
1165   // Check that the custom actor is now visible
1166   DALI_TEST_CHECK(custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
1167   END_TEST;
1168 }
1169
1170 int UtcDaliCustomActorCustomActor(void)
1171 {
1172   Dali::CustomActor customA;
1173   Dali::CustomActor customB( customA );
1174
1175   DALI_TEST_CHECK( customA == customB );
1176
1177   END_TEST;
1178 }
1179
1180 int UtcDaliCustomActorImplRelayoutRequest(void)
1181 {
1182   TestApplication application;
1183
1184   DALI_TEST_CHECK( gOnRelayout == false );
1185
1186   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1187   application.GetScene().Add(custom);
1188
1189   application.SendNotification();
1190   application.Render();
1191
1192   DALI_TEST_CHECK( gOnRelayout == true );
1193   gOnRelayout = false;
1194
1195   custom.TestRelayoutRequest();
1196   application.SendNotification();
1197   application.Render();
1198
1199   DALI_TEST_CHECK( gOnRelayout == true );
1200
1201   END_TEST;
1202 }
1203
1204 int UtcDaliCustomActorImplGetHeightForWidthBase(void)
1205 {
1206   TestApplication application;
1207   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1208
1209   float width = 300.0f;
1210
1211   application.SendNotification();
1212   application.Render();
1213
1214   float v = custom.TestGetHeightForWidthBase( width );
1215
1216   DALI_TEST_CHECK( v == width );
1217
1218   END_TEST;
1219 }
1220
1221 int UtcDaliCustomActorImplGetWidthForHeightBase(void)
1222 {
1223   TestApplication application;
1224   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1225
1226   float height = 300.0f;
1227
1228   application.SendNotification();
1229   application.Render();
1230
1231   float v = custom.TestGetWidthForHeightBase( height );
1232
1233   DALI_TEST_CHECK( v == height );
1234
1235   END_TEST;
1236 }
1237
1238 int UtcDaliCustomActorImplCalculateChildSizeBase(void)
1239 {
1240   TestApplication application;
1241   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1242
1243   Actor child = Actor::New();
1244   child.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1245   child.SetProperty( Actor::Property::SIZE, Vector2( 150, 150 ) );
1246
1247   application.SendNotification();
1248   application.Render();
1249
1250   float v = custom.TestCalculateChildSizeBase( child, Dali::Dimension::ALL_DIMENSIONS );
1251   DALI_TEST_CHECK( v == 0.0f );
1252
1253   END_TEST;
1254 }
1255
1256 int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
1257 {
1258   TestApplication application;
1259   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1260   custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
1261
1262   bool v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::ALL_DIMENSIONS );
1263   DALI_TEST_CHECK( v == true );
1264
1265   application.SendNotification();
1266   application.Render();
1267
1268   custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1269   v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::WIDTH );
1270   DALI_TEST_CHECK( v == false );
1271
1272   // why is this here?
1273   application.SendNotification();
1274   application.Render();
1275
1276   END_TEST;
1277 }
1278
1279 int UtcDaliCustomActorTypeRegistry(void)
1280 {
1281   TestApplication application;
1282
1283   // Register Type
1284   TypeInfo type;
1285   type = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
1286   DALI_TEST_CHECK( type );
1287   BaseHandle handle = type.CreateInstance();
1288
1289   std::string name;
1290   std::string exception;
1291
1292   try
1293   {
1294     name = handle.GetTypeName();
1295     tet_result(TET_FAIL);
1296   }
1297   catch( DaliException& e )
1298   {
1299     exception = e.condition;
1300     DALI_TEST_EQUALS( exception, "handle && \"BaseObject handle is empty\"", TEST_LOCATION );
1301   }
1302
1303   END_TEST;
1304 }
1305
1306
1307 int UtcDaliCustomActorGetExtensionP(void)
1308 {
1309   TestApplication application;
1310
1311   Test::TestCustomActor custom = Test::TestCustomActor::NewVariant5(application.GetScene());
1312
1313   DALI_TEST_CHECK( NULL == custom.GetImplementation().GetExtension() );
1314
1315   END_TEST;
1316 }
1317
1318 int UtcDaliCustomActorOnConnectionDepth(void)
1319 {
1320   TestApplication application;
1321   tet_infoline("Testing Dali::CustomActor::OnSceneConnection() hierarchy depth");
1322
1323   Integration::Scene stage = application.GetScene();
1324
1325   /* Build tree of actors:
1326    *
1327    *                      Depth
1328    *
1329    *       A (parent)       1
1330    *      / \
1331    *     B   C              2
1332    *    / \   \
1333    *   D   E   F            3
1334    *
1335    * OnSceneConnection should return 1 for A, 2 for B and C, and 3 for D, E and F.
1336    */
1337
1338   Test::TestCustomActor actorA = Test::TestCustomActor::New();
1339   stage.Add( actorA );
1340
1341   Test::TestCustomActor actorB = Test::TestCustomActor::New();
1342   actorA.Add( actorB );
1343
1344   Test::TestCustomActor actorC = Test::TestCustomActor::New();
1345   actorA.Add( actorC );
1346
1347   Test::TestCustomActor actorD = Test::TestCustomActor::New();
1348   actorB.Add( actorD );
1349
1350   Test::TestCustomActor actorE = Test::TestCustomActor::New();
1351   actorB.Add( actorE );
1352
1353   Test::TestCustomActor actorF = Test::TestCustomActor::New();
1354   actorC.Add( actorF );
1355
1356   // Excercise the message passing to Update thread
1357   application.SendNotification();
1358   application.Render();
1359   application.Render();
1360
1361   DALI_TEST_EQUALS( 1u, actorA.GetDepth(), TEST_LOCATION );
1362   DALI_TEST_EQUALS( 2u, actorB.GetDepth(), TEST_LOCATION );
1363   DALI_TEST_EQUALS( 2u, actorC.GetDepth(), TEST_LOCATION );
1364   DALI_TEST_EQUALS( 3u, actorD.GetDepth(), TEST_LOCATION );
1365   DALI_TEST_EQUALS( 3u, actorE.GetDepth(), TEST_LOCATION );
1366   DALI_TEST_EQUALS( 3u, actorF.GetDepth(), TEST_LOCATION );
1367
1368   END_TEST;
1369 }
1370
1371
1372 int UtcDaliCustomActorSetGetProperty(void)
1373 {
1374   TestApplication application; // Need the type registry
1375
1376   Test::TestCustomActor actor = Test::TestCustomActor::New();
1377   application.GetScene().Add( actor );
1378
1379   actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1, 0.5f );
1380   actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2, Color::WHITE );
1381   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3, Color::BLUE );
1382   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4, 20 );
1383   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5, 40.0f );
1384
1385   Property::Value value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1 );
1386   DALI_TEST_EQUALS( value.Get<float>(), 0.5f, 0.001f, TEST_LOCATION );
1387
1388   value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2 );
1389   DALI_TEST_EQUALS( value.Get<Vector4>(), Color::WHITE, 0.001f, TEST_LOCATION );
1390
1391
1392   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3 );
1393   DALI_TEST_EQUALS( value.Get<Vector4>(), Color::BLUE, 0.001f, TEST_LOCATION );
1394
1395   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4 );
1396   DALI_TEST_EQUALS( value.Get<int>(), 20, TEST_LOCATION );
1397
1398   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5 );
1399   DALI_TEST_EQUALS( value.Get<float>(), 40.0f, 0.001f, TEST_LOCATION );
1400
1401   // Get read-only property
1402   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY6 );
1403   DALI_TEST_EQUALS( value.Get<float>(), 10.0f, 0.001f, TEST_LOCATION );
1404
1405   // Attempt to set read-only property and then ensure value hasn't changed
1406   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY6, 40.0f );
1407   DALI_TEST_EQUALS( value.Get<float>(), 10.0f, 0.001f, TEST_LOCATION );
1408
1409   END_TEST;
1410 }
1411
1412 int utcDaliActorGetTypeInfo(void)
1413 {
1414   TestApplication application;
1415   tet_infoline( "Get the type info of a derived actor" );
1416
1417   Test::TestCustomActor customActor = Test::TestCustomActor::New();
1418
1419   Dali::TypeInfo typeInfo = Dali::DevelCustomActor::GetTypeInfo( customActor );
1420
1421   DALI_TEST_EQUALS( typeInfo.GetName(), std::string("TestCustomActor"), TEST_LOCATION );
1422
1423   END_TEST;
1424 }
1425
1426 namespace Impl
1427 {
1428 /**
1429  * A custom actor that is not type registered on purpose
1430  */
1431 struct UnregisteredCustomActor : public Dali::CustomActorImpl
1432 {
1433   UnregisteredCustomActor() : CustomActorImpl( ACTOR_BEHAVIOUR_DEFAULT )
1434   { }
1435   virtual ~UnregisteredCustomActor()
1436   { }
1437   virtual void OnSceneConnection( int32_t depth )
1438   { }
1439   virtual void OnSceneDisconnection()
1440   { }
1441   virtual void OnChildAdd(Actor& child)
1442   { }
1443   virtual void OnChildRemove(Actor& child)
1444   { }
1445   virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
1446   { }
1447   virtual void OnSizeSet(const Vector3& targetSize)
1448   { }
1449   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
1450   { }
1451   virtual bool OnTouchEvent(const TouchEvent& event) DALI_DEPRECATED_API
1452   { return false; }
1453   virtual bool OnHoverEvent(const HoverEvent& event)
1454   { return false; }
1455   virtual bool OnKeyEvent(const KeyEvent& event)
1456   { return false; }
1457   virtual bool OnWheelEvent(const WheelEvent& event)
1458   { return false; }
1459   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
1460   { }
1461   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
1462   { }
1463   virtual Vector3 GetNaturalSize()
1464   { return Vector3(); }
1465   virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
1466   { return 0.f; }
1467   virtual float GetHeightForWidth( float width )
1468   { return 0.f; }
1469   virtual float GetWidthForHeight( float height )
1470   { return 0.f; }
1471   virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
1472   { return false; }
1473   virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
1474   { }
1475   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
1476   { }
1477 };
1478 }
1479 struct UnregisteredCustomActor : public Dali::CustomActor
1480 {
1481   static UnregisteredCustomActor New()
1482   {
1483     Impl::UnregisteredCustomActor* impl = new Impl::UnregisteredCustomActor;
1484     UnregisteredCustomActor custom( *impl ); // takes ownership
1485     return custom;
1486   }
1487   UnregisteredCustomActor()
1488   { }
1489   ~UnregisteredCustomActor()
1490   { }
1491   UnregisteredCustomActor( Internal::CustomActor* impl )
1492   : CustomActor( impl )
1493   { }
1494   UnregisteredCustomActor( Impl::UnregisteredCustomActor& impl )
1495   : CustomActor( impl )
1496   { }
1497   static UnregisteredCustomActor DownCast( BaseHandle handle )
1498   {
1499     UnregisteredCustomActor hndl;
1500     CustomActor custom = Dali::CustomActor::DownCast( handle );
1501     if( custom )
1502     {
1503       CustomActorImpl& customImpl = custom.GetImplementation();
1504
1505       Impl::UnregisteredCustomActor* impl = dynamic_cast<Impl::UnregisteredCustomActor*>( &customImpl );
1506
1507       if( impl )
1508       {
1509         hndl = UnregisteredCustomActor( customImpl.GetOwner() );
1510       }
1511     }
1512     return hndl;
1513   }
1514 };
1515
1516 int UtcDaliCustomActorSetGetActorPropertyActionSignal(void)
1517 {
1518   TestApplication application; // Need the type registry
1519
1520   auto custom = UnregisteredCustomActor::New();
1521   application.GetScene().Add( custom );
1522
1523   // should have all actor properties
1524   DALI_TEST_EQUALS( custom.GetPropertyType( Actor::Property::COLOR ), Property::VECTOR4, TEST_LOCATION );
1525   auto actorHandle = Actor::New();
1526   DALI_TEST_EQUALS( custom.GetPropertyCount(), actorHandle.GetPropertyCount(), TEST_LOCATION );
1527
1528   DALI_TEST_EQUALS( custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
1529   custom.SetProperty( Actor::Property::VISIBLE, false );
1530   application.SendNotification();
1531   application.Render(); // IsVisible returns scene value
1532   DALI_TEST_EQUALS( custom.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
1533
1534   // should have custom actor typename (as it has not registered itself)
1535   DALI_TEST_EQUALS( "CustomActor", custom.GetTypeName(), TEST_LOCATION );
1536
1537   // should have actor actions
1538   custom.DoAction( "show",  Property::Map() );
1539   DALI_TEST_EQUALS( custom.GetProperty( Actor::Property::VISIBLE ).Get<bool>(), true, TEST_LOCATION );
1540
1541   Animation animation = Animation::New(0.01f); // very short animation
1542   // should be able to animate actor property
1543   animation.AnimateTo( Property( custom, Actor::Property::POSITION ), Vector3( 100.0f, 150.0f, 200.0f ) );
1544   animation.Play();
1545
1546   application.SendNotification();
1547   application.Render(1000.f);
1548
1549   DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetProperty( Actor::Property::POSITION ).Get<Vector3>(), TEST_LOCATION );
1550   DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1551
1552   Dali::WeakHandle<UnregisteredCustomActor> weakRef( custom );
1553   // should have actor signals
1554   custom.ConnectSignal( &application, "offScene",
1555     [weakRef]()
1556       {
1557         DALI_TEST_EQUALS( weakRef.GetHandle().GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ), false, TEST_LOCATION );
1558       } );
1559
1560   application.GetScene().Remove( custom );
1561   application.GetScene().Add( custom );
1562
1563   END_TEST;
1564 }
1565
1566 namespace Impl
1567 {
1568 struct DerivedCustomActor : public UnregisteredCustomActor
1569 { };
1570 }
1571
1572 struct DerivedCustomActor : public UnregisteredCustomActor
1573 {
1574   static DerivedCustomActor New()
1575   {
1576     Impl::DerivedCustomActor* impl = new Impl::DerivedCustomActor;
1577     DerivedCustomActor custom( *impl ); // takes ownership
1578     return custom;
1579   }
1580   DerivedCustomActor()
1581   { }
1582   ~DerivedCustomActor()
1583   { }
1584   DerivedCustomActor( Internal::CustomActor* impl )
1585   : UnregisteredCustomActor( impl )
1586   { }
1587   DerivedCustomActor( Impl::UnregisteredCustomActor& impl )
1588   : UnregisteredCustomActor( impl )
1589   { }
1590 };
1591
1592 // register custom
1593 DALI_TYPE_REGISTRATION_BEGIN( DerivedCustomActor, UnregisteredCustomActor, nullptr );
1594 DALI_TYPE_REGISTRATION_END()
1595
1596 int UtcDaliCustomActorPropertyRegistrationDefaultValue(void)
1597 {
1598   TestApplication application; // Need the type registry
1599
1600   // register our base and add a property with default value for it
1601   Dali::TypeRegistration typeRegistration( typeid( UnregisteredCustomActor ), typeid( Dali::CustomActor ), nullptr );
1602
1603   auto derived = DerivedCustomActor::New();
1604   application.GetScene().Add( derived );
1605
1606   // should have all actor properties
1607   DALI_TEST_EQUALS( derived.GetPropertyType( Actor::Property::WORLD_MATRIX ), Property::MATRIX, TEST_LOCATION );
1608   auto actorHandle = Actor::New();
1609   DALI_TEST_EQUALS( derived.GetPropertyCount(), actorHandle.GetPropertyCount(), TEST_LOCATION );
1610
1611   // add a property in base class
1612   AnimatablePropertyRegistration( typeRegistration, "Foobar", ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, 10.f );
1613
1614   // should be one more property now
1615   DALI_TEST_EQUALS( derived.GetPropertyCount(), actorHandle.GetPropertyCount() + 1, TEST_LOCATION );
1616   // check that the default value is set for base class
1617   DALI_TEST_EQUALS( UnregisteredCustomActor::New().GetProperty(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX).Get<float>(), 10.f, TEST_LOCATION );
1618   // check that the default value is set for the derived instance as well
1619   DALI_TEST_EQUALS( derived.GetProperty(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX).Get<float>(), 10.f, TEST_LOCATION );
1620
1621   END_TEST;
1622 }
1623