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