Adding Devel Property Registration macro
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-CustomActor.cpp
1 /*
2  * Copyright (c) 2016 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/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/hover-event-integ.h>
24 #include <dali/integration-api/events/wheel-event-integ.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/public-api/object/type-registry-helper.h>
27 #include "dali-test-suite-utils/dali-test-suite-utils.h"
28 #include "test-custom-actor.h"
29
30 using namespace Dali;
31
32
33 void custom_actor_test_startup(void)
34 {
35   test_return_value = TET_UNDEF;
36 }
37
38 void custom_actor_test_cleanup(void)
39 {
40   test_return_value = TET_PASS;
41 }
42
43
44
45 using namespace Dali;
46
47
48 int UtcDaliCustomActorDestructor(void)
49 {
50   TestApplication application;
51
52   CustomActor* actor = new CustomActor();
53   delete actor;
54
55   DALI_TEST_CHECK( true );
56   END_TEST;
57 }
58
59 int UtcDaliCustomActorImplDestructor(void)
60 {
61   TestApplication application;
62   CustomActorImpl* actor = new Test::Impl::TestCustomActor();
63   CustomActor customActor( *actor ); // Will automatically unref at the end of this function
64
65   DALI_TEST_CHECK( true );
66   END_TEST;
67 }
68
69 // Positive test case for a method
70 int UtcDaliCustomActorDownCast(void)
71 {
72   TestApplication application;
73   tet_infoline("Testing Dali::CustomActor::DownCast()");
74
75   Test::TestCustomActor custom = Test::TestCustomActor::New();
76
77   Actor anActor = Actor::New();
78   anActor.Add( custom );
79
80   Actor child = anActor.GetChildAt(0);
81   CustomActor customActor = CustomActor::DownCast( child );
82   DALI_TEST_CHECK( customActor );
83
84   customActor = NULL;
85   DALI_TEST_CHECK( !customActor );
86
87   customActor = DownCast< CustomActor >( child );
88   DALI_TEST_CHECK( customActor );
89   END_TEST;
90 }
91
92 // Negative test case for a method
93 int UtcDaliCustomActorDownCastNegative(void)
94 {
95   TestApplication application;
96   tet_infoline("Testing Dali::CustomActor::DownCast()");
97
98   Actor actor1 = Actor::New();
99   Actor anActor = Actor::New();
100   anActor.Add(actor1);
101
102   Actor child = anActor.GetChildAt(0);
103   CustomActor customActor = CustomActor::DownCast( child );
104   DALI_TEST_CHECK( !customActor );
105
106   Actor unInitialzedActor;
107   customActor = CustomActor::DownCast( unInitialzedActor );
108   DALI_TEST_CHECK( !customActor );
109
110   customActor = DownCast< CustomActor >( unInitialzedActor );
111   DALI_TEST_CHECK( !customActor );
112   END_TEST;
113 }
114
115 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
116 {
117   TestApplication application;
118   tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
119
120   Test::TestCustomActor custom = Test::TestCustomActor::New();
121   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
122
123   // add the custom actor to stage
124   Stage::GetCurrent().Add( custom );
125
126   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
127   DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
128
129   Stage::GetCurrent().Remove( custom );
130
131   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
132   DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
133
134   // Excercise the message passing to Update thread
135
136   application.SendNotification();
137   application.Render();
138   application.Render();
139   END_TEST;
140 }
141
142 int UtcDaliCustomActorOnStageConnectionOrder(void)
143 {
144   TestApplication application;
145   tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
146
147   MasterCallStack.clear();
148
149   /* Build tree of actors:
150    *
151    *       A (parent)
152    *      / \
153    *     B   C
154    *    / \   \
155    *   D   E   F
156    *
157    * OnStageConnection should be received for A, B, D, E, C, and finally F
158    */
159
160   Test::TestCustomActor actorA = Test::TestCustomActor::New();
161   actorA.SetName( "ActorA" );
162
163   Test::TestCustomActor actorB = Test::TestCustomActor::New();
164   actorB.SetName( "ActorB" );
165   actorA.Add( actorB );
166
167   Test::TestCustomActor actorC = Test::TestCustomActor::New();
168   actorC.SetName( "ActorC" );
169   actorA.Add( actorC );
170
171   Test::TestCustomActor actorD = Test::TestCustomActor::New();
172   actorD.SetName( "ActorD" );
173   actorB.Add( actorD );
174
175   Test::TestCustomActor actorE = Test::TestCustomActor::New();
176   actorE.SetName( "ActorE" );
177   actorB.Add( actorE );
178
179   Test::TestCustomActor actorF = Test::TestCustomActor::New();
180   actorF.SetName( "ActorF" );
181   actorC.Add( actorF );
182
183   // add the custom actor to stage
184   Stage::GetCurrent().Add( actorA );
185
186   DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
187   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
188   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
189   DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
190
191   DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
192   DALI_TEST_EQUALS( "OnChildAdd",        actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
193   DALI_TEST_EQUALS( "OnChildAdd",        actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
194   DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
195
196   DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
197   DALI_TEST_EQUALS( "OnChildAdd",        actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
198   DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION );
199
200   DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
201   DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
202
203   DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
204   DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
205
206   DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
207   DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
208
209   // Check sequence is correct in MasterCallStack
210
211   DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
212
213   DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION );
214   DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
215   DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION );
216   DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION );
217   DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION );
218
219   DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION );
220   DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION );
221   DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION );
222   DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION );
223   DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION );
224   DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION );
225
226   // Excercise the message passing to Update thread
227
228   application.SendNotification();
229   application.Render();
230   application.Render();
231   END_TEST;
232 }
233
234 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
235 {
236   TestApplication application;
237   tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
238
239   Stage stage = Stage::GetCurrent();
240
241   /* Build tree of actors:
242    *
243    *       A (parent)
244    *      / \
245    *     B   C
246    *    / \   \
247    *   D   E   F
248    *
249    * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
250    */
251
252   Test::TestCustomActor actorA = Test::TestCustomActor::New();
253   actorA.SetName( "ActorA" );
254   stage.Add( actorA );
255
256   Test::TestCustomActor actorB = Test::TestCustomActor::New();
257   actorB.SetName( "ActorB" );
258   actorA.Add( actorB );
259
260   Test::TestCustomActor actorC = Test::TestCustomActor::New();
261   actorC.SetName( "ActorC" );
262   actorA.Add( actorC );
263
264   Test::TestCustomActor actorD = Test::TestCustomActor::New();
265   actorD.SetName( "ActorD" );
266   actorB.Add( actorD );
267
268   Test::TestCustomActor actorE = Test::TestCustomActor::New();
269   actorE.SetName( "ActorE" );
270   actorB.Add( actorE );
271
272   Test::TestCustomActor actorF = Test::TestCustomActor::New();
273   actorF.SetName( "ActorF" );
274   actorC.Add( actorF );
275
276   // Excercise the message passing to Update thread
277
278   application.SendNotification();
279   application.Render();
280   application.Render();
281
282   // Clear call stacks before disconnection
283   actorA.ResetCallStack();
284   actorB.ResetCallStack();
285   actorC.ResetCallStack();
286   actorD.ResetCallStack();
287   actorE.ResetCallStack();
288   actorF.ResetCallStack();
289   MasterCallStack.clear();
290
291   stage.Remove( actorA );
292
293   DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
294   DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
295
296   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
297   DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
298
299   DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
300   DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
301
302   DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
303   DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
304
305   DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
306   DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
307
308   DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
309   DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
310
311   // Check sequence is correct in MasterCallStack
312
313   DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
314
315   DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
316   DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
317   DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION );
318   DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
319   DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
320   DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION );
321
322   // Excercise the message passing to Update thread
323
324   application.SendNotification();
325   application.Render();
326   application.Render();
327   END_TEST;
328 }
329
330 int UtcDaliCustomActorAddDuringOnStageConnection(void)
331 {
332   TestApplication application;
333   tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
334
335   Stage stage = Stage::GetCurrent();
336
337   MasterCallStack.clear();
338
339   /* The actorA is a special variant which adds a child to itself during OnStageConnection()
340    * The actorB is provided as the child
341    */
342
343   Test::TestCustomActor actorB = Test::TestCustomActor::New();
344   actorB.SetName( "ActorB" );
345
346   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant1( actorB );
347   actorA.SetName( "ActorA" );
348   stage.Add( actorA );
349
350   // Check callback sequence
351
352   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
353   DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
354   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection()
355
356   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
357   DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
358
359   DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
360
361   DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION );
362   DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection()
363   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection()
364
365   // Excercise the message passing to Update thread
366
367   application.SendNotification();
368   application.Render();
369   application.Render();
370
371   // Check everything is ok after Actors are removed
372
373   stage.Remove( actorA );
374   application.SendNotification();
375   application.Render();
376   application.Render();
377   END_TEST;
378 }
379
380 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
381 {
382   TestApplication application;
383   tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
384
385   Stage stage = Stage::GetCurrent();
386
387   MasterCallStack.clear();
388
389   /* The actorA is a special variant which removes its children during OnStageConnection()
390    * Actors B & C are provided as the children
391    */
392
393   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant2();
394   actorA.SetName( "ActorA" );
395
396   Test::TestCustomActor actorB = Test::TestCustomActor::New();
397   actorB.SetName( "ActorB" );
398   actorA.Add( actorB );
399
400   Test::TestCustomActor actorC = Test::TestCustomActor::New();
401   actorC.SetName( "ActorC" );
402   actorA.Add( actorC );
403
404   stage.Add( actorA );
405
406   // Check callback sequence
407
408   DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
409   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
410   DALI_TEST_EQUALS( "OnChildAdd",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
411   DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
412   DALI_TEST_EQUALS( "OnChildRemove",     actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection()
413   DALI_TEST_EQUALS( "OnChildRemove",     actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection()
414
415   DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
416
417   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 0 ], TEST_LOCATION );
418   DALI_TEST_EQUALS( "ActorA: OnChildAdd",        MasterCallStack[ 1 ], TEST_LOCATION );
419   DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION );
420   DALI_TEST_EQUALS( "ActorA: OnChildRemove",     MasterCallStack[ 3 ], TEST_LOCATION );
421   DALI_TEST_EQUALS( "ActorA: OnChildRemove",     MasterCallStack[ 4 ], TEST_LOCATION );
422
423   /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback
424    * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection
425    */
426   DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
427   DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
428
429   // Excercise the message passing to Update thread
430
431   application.SendNotification();
432   application.Render();
433   application.Render();
434
435   // Check everything is ok after last actor is removed
436
437   stage.Remove( actorA );
438   application.SendNotification();
439   application.Render();
440   application.Render();
441   END_TEST;
442 }
443
444 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
445 {
446   TestApplication application;
447   tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
448
449   Stage stage = Stage::GetCurrent();
450
451   /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
452    * The actorB is provided as the child
453    */
454
455   Test::TestCustomActor actorB = Test::TestCustomActor::New();
456   actorB.SetName( "ActorB" );
457
458   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant3( actorB );
459   actorA.SetName( "ActorA" );
460   stage.Add( actorA );
461
462   // Excercise the message passing to Update thread
463
464   application.SendNotification();
465   application.Render();
466   application.Render();
467
468   // Clear call stacks before disconnection
469   actorA.ResetCallStack();
470   actorB.ResetCallStack();
471   MasterCallStack.clear();
472
473   stage.Remove( actorA );
474
475   // Check callback sequence
476
477   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
478   DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
479   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
480
481   // Child was added after parent disconnection, so should not receive OnStageConnection()
482   DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
483
484   DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
485
486   DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
487   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 1 ], TEST_LOCATION );
488
489   // Excercise the message passing to Update thread
490
491   application.SendNotification();
492   application.Render();
493   application.Render();
494   END_TEST;
495 }
496
497 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
498 {
499   TestApplication application;
500   tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
501
502   Stage stage = Stage::GetCurrent();
503
504   /* The actorA is a special variant which removes its children during OnStageDisconnection()
505    * The actorB is provided as the child
506    */
507
508   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant4();
509   actorA.SetName( "ActorA" );
510   stage.Add( actorA );
511
512   Test::TestCustomActor actorB = Test::TestCustomActor::New();
513   actorB.SetName( "ActorB" );
514   actorA.Add( actorB );
515
516   // Excercise the message passing to Update thread
517
518   application.SendNotification();
519   application.Render();
520   application.Render();
521
522   // Clear call stacks before disconnection
523   actorA.ResetCallStack();
524   actorB.ResetCallStack();
525   MasterCallStack.clear();
526
527   stage.Remove( actorA );
528
529   // Check callback sequence
530
531   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
532   DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
533   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
534
535   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
536   DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
537
538   DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
539
540   DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
541   DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION );
542   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 2 ], TEST_LOCATION );
543
544   // Excercise the message passing to Update thread
545
546   application.SendNotification();
547   application.Render();
548   application.Render();
549   END_TEST;
550 }
551
552 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
553 {
554   TestApplication application;
555   tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
556
557   Stage stage = Stage::GetCurrent();
558
559   MasterCallStack.clear();
560
561   /* The actorA is the parent of actorB
562    * The actorB is a special variant which removes its own parent during OnStageConnection()
563    * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection()
564    */
565
566   Test::TestCustomActor actorA = Test::TestCustomActor::New();
567   actorA.SetName( "ActorA" );
568
569   Test::TestCustomActor actorB = Test::TestCustomActor::NewVariant5();
570   actorB.SetName( "ActorB" );
571   actorA.Add( actorB );
572
573   stage.Add( actorA );
574
575   // Check callback sequence
576
577   DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
578   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
579   DALI_TEST_EQUALS( "OnStageConnection",    actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
580   DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION );
581
582   DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
583   DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
584
585   DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
586
587   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 0 ], TEST_LOCATION );
588   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
589   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 2 ], TEST_LOCATION );
590   DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
591
592   // Excercise the message passing to Update thread
593
594   application.SendNotification();
595   application.Render();
596   application.Render();
597   END_TEST;
598 }
599
600 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
601 {
602   TestApplication application;
603   tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
604
605   Stage stage = Stage::GetCurrent();
606
607   MasterCallStack.clear();
608
609   /* The actorA is the parent of actorB
610    * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection()
611    * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection()
612    */
613
614   Test::TestCustomActor actorA = Test::TestCustomActor::New();
615   actorA.SetName( "ActorA" );
616   stage.Add( actorA );
617
618   Test::TestCustomActor actorB = Test::TestCustomActor::NewVariant6();
619   actorB.SetName( "ActorB" );
620   actorA.Add( actorB );
621
622   stage.Remove( actorA );
623
624   // Check callback sequence
625
626   DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
627   DALI_TEST_EQUALS( "OnStageConnection",    actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
628   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
629
630   DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
631   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
632   DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
633   // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB
634
635   DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
636
637   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 0 ], TEST_LOCATION );
638   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
639   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 2 ], TEST_LOCATION );
640   DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION );
641
642   // Excercise the message passing to Update thread
643
644   application.SendNotification();
645   application.Render();
646   application.Render();
647   END_TEST;
648 }
649
650 int UtcDaliCustomActorOnChildAddRemove(void)
651 {
652   TestApplication application;
653   tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
654
655   Test::TestCustomActor custom = Test::TestCustomActor::New();
656   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
657
658   Actor aChild = Actor::New();
659   custom.Add( aChild );
660
661   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
662   DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
663
664   custom.Remove( aChild );
665
666   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
667   DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
668   END_TEST;
669 }
670
671 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
672 {
673   TestApplication application;
674   tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
675
676   Stage stage = Stage::GetCurrent();
677
678   MasterCallStack.clear();
679
680   /* The actorA is a special variant which reparents children added into a separate container child
681    * The actorB is the child of actorA
682    */
683
684   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant7( "ActorA" );
685   stage.Add( actorA );
686
687   Test::TestCustomActor actorB = Test::TestCustomActor::New();
688   actorB.SetName( "ActorB" );
689   actorA.Add( actorB );
690
691   // Check hierarchy is as follows:
692   //  A
693   //  |
694   //  Container
695   //  |
696   //  B
697
698   DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
699
700   Actor container = actorA.GetChildAt(0);
701   Actor containerChild;
702
703   DALI_TEST_CHECK( container );
704   if ( container )
705   {
706     DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
707     DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
708     containerChild = container.GetChildAt(0);
709   }
710
711   DALI_TEST_CHECK( containerChild );
712   if ( containerChild )
713   {
714     DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
715     DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
716   }
717
718   // Check callback sequence
719
720   DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
721   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
722   DALI_TEST_EQUALS( "OnStageConnection",    actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
723   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
724   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION );
725   // mContainer will then receive OnChildAdd
726
727   DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
728   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
729   DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
730   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
731
732   DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
733
734   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 0 ], TEST_LOCATION );
735   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
736   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 2 ], TEST_LOCATION );
737   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 3 ], TEST_LOCATION );
738   DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION );
739   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 5 ], TEST_LOCATION );
740   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 6 ], TEST_LOCATION );
741
742   // Excercise the message passing to Update thread
743
744   application.SendNotification();
745   application.Render();
746   application.Render();
747   END_TEST;
748 }
749
750 /**
751  * Test that Remove can be called (a NOOP) during the OnChildRemove
752  * triggered when reparenting an actor
753  */
754 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
755 {
756   TestApplication application;
757   tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
758
759   Stage stage = Stage::GetCurrent();
760
761   MasterCallStack.clear();
762
763   /* The childActor will be reparented from actorA to actorB
764    * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback()
765    * This should be a NOOP since the reparenting has not occured yet
766    */
767
768   Test::TestCustomActor actorB = Test::TestCustomActor::New();
769   actorB.SetName( "ActorB" );
770   stage.Add( actorB );
771
772   Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant8( actorB );
773   actorA.SetName( "ActorA" );
774   stage.Add( actorA );
775
776   Actor childActor = Actor::New();
777   childActor.SetName( "Child" );
778   // Reparent from actorA to actorB
779   actorA.Add( childActor );
780   actorB.Add( childActor );
781
782   // Check hierarchy is as follows:
783   //  A    B
784   //       |
785   //       Child
786
787   DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION );
788   DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION );
789   DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION );
790
791   Actor child = actorB.GetChildAt(0);
792
793   DALI_TEST_CHECK( child );
794   if ( child )
795   {
796     DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
797   }
798
799   // Check callback sequence
800
801   DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
802   DALI_TEST_EQUALS( "OnStageConnection",    actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA
803   DALI_TEST_EQUALS( "OnChildAdd",           actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION );
804   DALI_TEST_EQUALS( "OnChildRemove",        actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA
805   // mContainer will then receive OnChildAdd
806
807   DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
808   DALI_TEST_EQUALS( "OnStageConnection",    actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
809   // The derived class are always notified, no matter the child is successfully removed or not
810   DALI_TEST_EQUALS( "OnChildRemove",        actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION );
811   DALI_TEST_EQUALS( "OnChildAdd",           actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION );
812
813   DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
814
815   DALI_TEST_EQUALS( "ActorB: OnStageConnection",    MasterCallStack[ 0 ], TEST_LOCATION );
816   DALI_TEST_EQUALS( "ActorA: OnStageConnection",    MasterCallStack[ 1 ], TEST_LOCATION );
817   DALI_TEST_EQUALS( "ActorA: OnChildAdd",           MasterCallStack[ 2 ], TEST_LOCATION );
818   DALI_TEST_EQUALS( "ActorA: OnChildRemove",        MasterCallStack[ 3 ], TEST_LOCATION );
819   // The derived class are always notified, no matter the child is successfully removed or not
820   DALI_TEST_EQUALS( "ActorB: OnChildRemove",        MasterCallStack[ 4 ], TEST_LOCATION );
821   DALI_TEST_EQUALS( "ActorB: OnChildAdd",           MasterCallStack[ 5 ], TEST_LOCATION );
822
823   // Excercise the message passing to Update thread
824
825   application.SendNotification();
826   application.Render();
827   application.Render();
828   END_TEST;
829 }
830
831 int UtcDaliCustomActorOnPropertySet(void)
832 {
833   TestApplication application;
834   tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
835
836   Test::TestCustomActor custom = Test::TestCustomActor::New();
837   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
838
839   custom.SetDaliProperty("yes");
840
841   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
842   DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
843   END_TEST;
844 }
845
846 int UtcDaliCustomActorOnSizeSet(void)
847 {
848   TestApplication application;
849   tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
850
851   Test::TestCustomActor custom = Test::TestCustomActor::New();
852   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
853
854   custom.SetSize( Vector2( 9.0f, 10.0f ) );
855   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
856   DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
857   DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION );
858   DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION );
859
860   custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) );
861   DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
862   DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
863   DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION );
864   DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION );
865   DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION );
866   END_TEST;
867 }
868
869 int UtcDaliCustomActorOnSizeAnimation(void)
870 {
871   TestApplication application;
872   tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
873
874   Test::TestCustomActor custom = Test::TestCustomActor::New();
875   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
876
877   Animation anim = Animation::New( 1.0f );
878   anim.AnimateTo( Property( custom, Actor::Property::SIZE ), Vector3( 8.0f, 9.0f, 10.0f ) );
879   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
880   DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
881   DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
882   DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
883   DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
884   END_TEST;
885 }
886
887 int UtcDaliCustomActorOnTouchEvent(void)
888 {
889   TestApplication application;
890   tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
891
892   Test::TestCustomActor custom = Test::TestCustomActor::New();
893   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
894
895   // set size for custom actor
896   custom.SetSize( 100, 100 );
897   // add the custom actor to stage
898   Stage::GetCurrent().Add( custom );
899   custom.ResetCallStack();
900
901   // Render and notify a couple of times
902   application.SendNotification();
903   application.Render();
904   application.SendNotification();
905   application.Render();
906
907   // simulate a touch event
908   Dali::Integration::Point point;
909   point.SetState( PointState::DOWN );
910   point.SetScreenPosition( Vector2( 1, 1 ) );
911   Dali::Integration::TouchEvent event;
912   event.AddPoint( point );
913   application.ProcessEvent( event );
914
915   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
916   DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
917   END_TEST;
918 }
919
920 int UtcDaliCustomActorOnHoverEvent(void)
921 {
922   TestApplication application;
923   tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
924
925   Test::TestCustomActor custom = Test::TestCustomActor::New();
926   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
927
928   // set size for custom actor
929   custom.SetSize( 100, 100 );
930   // add the custom actor to stage
931   Stage::GetCurrent().Add( custom );
932   custom.ResetCallStack();
933
934   // Render and notify a couple of times
935   application.SendNotification();
936   application.Render();
937   application.SendNotification();
938   application.Render();
939
940   // simulate a hover event
941   Dali::Integration::Point point;
942   point.SetState( PointState::MOTION );
943   point.SetScreenPosition( Vector2( 1, 1 ) );
944   Dali::Integration::HoverEvent event;
945   event.AddPoint( point );
946   application.ProcessEvent( event );
947
948   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
949   DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
950   END_TEST;
951 }
952
953 int UtcDaliCustomActorOnWheelEvent(void)
954 {
955   TestApplication application;
956   tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
957
958   Test::TestCustomActor custom = Test::TestCustomActor::New();
959   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
960
961   // set size for custom actor
962   custom.SetSize( 100, 100 );
963   // add the custom actor to stage
964   Stage::GetCurrent().Add( custom );
965   custom.ResetCallStack();
966
967   // Render and notify a couple of times
968   application.SendNotification();
969   application.Render();
970   application.SendNotification();
971   application.Render();
972
973   // simulate a wheel event
974   Vector2 screenCoordinates( 10.0f, 10.0f );
975   Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
976   application.ProcessEvent( event );
977
978   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
979   DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
980   END_TEST;
981 }
982
983 int UtcDaliCustomActorImplOnPropertySet(void)
984 {
985   TestApplication application;
986   CustomActorImpl* impl = new Test::Impl::SimpleTestCustomActor();
987   CustomActor customActor( *impl ); // Will automatically unref at the end of this function
988
989   impl->OnPropertySet( 0, 0 );
990
991   DALI_TEST_CHECK( true );
992
993   END_TEST;
994 }
995
996 int UtcDaliCustomActorGetImplementation(void)
997 {
998   TestApplication application;
999
1000   Test::TestCustomActor custom = Test::TestCustomActor::New();
1001   CustomActorImpl& impl = custom.GetImplementation();
1002   impl.GetOwner();  // Test
1003
1004   const Test::TestCustomActor constCustom = Test::TestCustomActor::New();
1005   const CustomActorImpl& constImpl = constCustom.GetImplementation();
1006   constImpl.GetOwner();  // Test
1007
1008   DALI_TEST_CHECK( true );
1009   END_TEST;
1010 }
1011
1012 int UtcDaliCustomActorDoAction(void)
1013 {
1014   TestApplication application;
1015   tet_infoline("Testing Dali::CustomActor::DoAction()");
1016
1017   Test::TestCustomActor custom = Test::TestCustomActor::New();
1018
1019   BaseHandle customActorObject = custom;
1020
1021   DALI_TEST_CHECK(customActorObject);
1022
1023   Property::Map attributes;
1024
1025   // Check that an invalid command is not performed
1026   DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1027
1028   // Check that the custom actor is visible
1029   custom.SetVisible(true);
1030   DALI_TEST_CHECK(custom.IsVisible() == true);
1031
1032   // Check the custom actor performed an action to hide itself
1033   DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1034
1035   // flush the queue and render once
1036   application.SendNotification();
1037   application.Render();
1038
1039   // Check that the custom actor is now invisible
1040   DALI_TEST_CHECK(custom.IsVisible() == false);
1041
1042   // Check the custom actor performed an action to show itself
1043   DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1044
1045   // flush the queue and render once
1046   application.SendNotification();
1047   application.Render();
1048
1049   // Check that the custom actor is now visible
1050   DALI_TEST_CHECK(custom.IsVisible() == true);
1051   END_TEST;
1052 }
1053
1054 int UtcDaliCustomActorCustomActor(void)
1055 {
1056   Dali::CustomActor customA;
1057   Dali::CustomActor customB( customA );
1058
1059   DALI_TEST_CHECK( customA == customB );
1060
1061   END_TEST;
1062 }
1063
1064 int UtcDaliCustomActorImplRelayoutRequest(void)
1065 {
1066   TestApplication application;
1067
1068   DALI_TEST_CHECK( gOnRelayout == false );
1069
1070   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1071   Stage::GetCurrent().Add(custom);
1072
1073   application.SendNotification();
1074   application.Render();
1075
1076   DALI_TEST_CHECK( gOnRelayout == true );
1077   gOnRelayout = false;
1078
1079   custom.TestRelayoutRequest();
1080   application.SendNotification();
1081   application.Render();
1082
1083   DALI_TEST_CHECK( gOnRelayout == true );
1084
1085   END_TEST;
1086 }
1087
1088 int UtcDaliCustomActorImplGetHeightForWidthBase(void)
1089 {
1090   TestApplication application;
1091   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1092
1093   float width = 300.0f;
1094   float v = 0.0f;
1095
1096   application.SendNotification();
1097   application.Render();
1098
1099   v = custom.TestGetHeightForWidthBase( width );
1100
1101   DALI_TEST_CHECK( v == width );
1102
1103   END_TEST;
1104 }
1105
1106 int UtcDaliCustomActorImplGetWidthForHeightBase(void)
1107 {
1108   TestApplication application;
1109   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1110
1111   float height = 300.0f;
1112   float v = 0.0f;
1113
1114   application.SendNotification();
1115   application.Render();
1116
1117   v = custom.TestGetWidthForHeightBase( height );
1118
1119   DALI_TEST_CHECK( v == height );
1120
1121   END_TEST;
1122 }
1123
1124 int UtcDaliCustomActorImplCalculateChildSizeBase(void)
1125 {
1126   TestApplication application;
1127   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1128
1129   Actor child = Actor::New();
1130   child.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1131   child.SetSize(150, 150);
1132
1133   application.SendNotification();
1134   application.Render();
1135
1136   float v = 9.99f;
1137   v = custom.TestCalculateChildSizeBase( child, Dali::Dimension::ALL_DIMENSIONS );
1138   DALI_TEST_CHECK( v == 0.0f );
1139
1140   END_TEST;
1141 }
1142
1143 int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
1144 {
1145   TestApplication application;
1146   Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1147   custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
1148
1149   bool v = false;
1150
1151   v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::ALL_DIMENSIONS );
1152   application.SendNotification();
1153   application.Render();
1154
1155   DALI_TEST_CHECK( v == true );
1156
1157   custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1158   v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::WIDTH );
1159   application.SendNotification();
1160   application.Render();
1161   DALI_TEST_CHECK( v == false );
1162
1163   END_TEST;
1164 }
1165
1166 int UtcDaliCustomActorTypeRegistry(void)
1167 {
1168   TestApplication application;
1169
1170   // Register Type
1171   TypeInfo type;
1172   type = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
1173   DALI_TEST_CHECK( type );
1174   BaseHandle handle = type.CreateInstance();
1175
1176   std::string name;
1177   std::string exception;
1178
1179   try
1180   {
1181     name = handle.GetTypeName();
1182     tet_result(TET_FAIL);
1183   }
1184   catch( DaliException& e )
1185   {
1186     exception = e.condition;
1187     DALI_TEST_EQUALS( exception, "handle && \"BaseObject handle is empty\"", TEST_LOCATION );
1188   }
1189
1190   END_TEST;
1191 }
1192
1193
1194 int UtcDaliCustomActorGetExtensionP(void)
1195 {
1196   TestApplication application;
1197
1198   Test::TestCustomActor custom = Test::TestCustomActor::NewVariant5();
1199
1200   DALI_TEST_CHECK( NULL == custom.GetImplementation().GetExtension() );
1201
1202   END_TEST;
1203 }
1204
1205 int UtcDaliCustomActorOnConnectionDepth(void)
1206 {
1207   TestApplication application;
1208   tet_infoline("Testing Dali::CustomActor::OnStageConnection() hierarchy depth");
1209
1210   Stage stage = Stage::GetCurrent();
1211
1212   /* Build tree of actors:
1213    *
1214    *                      Depth
1215    *
1216    *       A (parent)       1
1217    *      / \
1218    *     B   C              2
1219    *    / \   \
1220    *   D   E   F            3
1221    *
1222    * OnStageConnection should return 1 for A, 2 for B and C, and 3 for D, E and F.
1223    */
1224
1225   Test::TestCustomActor actorA = Test::TestCustomActor::New();
1226   stage.Add( actorA );
1227
1228   Test::TestCustomActor actorB = Test::TestCustomActor::New();
1229   actorA.Add( actorB );
1230
1231   Test::TestCustomActor actorC = Test::TestCustomActor::New();
1232   actorA.Add( actorC );
1233
1234   Test::TestCustomActor actorD = Test::TestCustomActor::New();
1235   actorB.Add( actorD );
1236
1237   Test::TestCustomActor actorE = Test::TestCustomActor::New();
1238   actorB.Add( actorE );
1239
1240   Test::TestCustomActor actorF = Test::TestCustomActor::New();
1241   actorC.Add( actorF );
1242
1243   // Excercise the message passing to Update thread
1244   application.SendNotification();
1245   application.Render();
1246   application.Render();
1247
1248   DALI_TEST_EQUALS( 1u, actorA.GetDepth(), TEST_LOCATION );
1249   DALI_TEST_EQUALS( 2u, actorB.GetDepth(), TEST_LOCATION );
1250   DALI_TEST_EQUALS( 2u, actorC.GetDepth(), TEST_LOCATION );
1251   DALI_TEST_EQUALS( 3u, actorD.GetDepth(), TEST_LOCATION );
1252   DALI_TEST_EQUALS( 3u, actorE.GetDepth(), TEST_LOCATION );
1253   DALI_TEST_EQUALS( 3u, actorF.GetDepth(), TEST_LOCATION );
1254
1255   END_TEST;
1256 }
1257
1258
1259 int UtcDaliCustomActorSetGetProperty(void)
1260 {
1261   TestApplication application; // Need the type registry
1262
1263   Test::TestCustomActor actor = Test::TestCustomActor::New();
1264   Stage::GetCurrent().Add( actor );
1265
1266   actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1, 0.5f );
1267   actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2, Color::WHITE );
1268   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3, Color::BLUE );
1269   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4, 20 );
1270   actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5, 40.0f );
1271
1272   Property::Value value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1 );
1273   DALI_TEST_EQUALS( value.Get<float>(), 0.5f, 0.001f, TEST_LOCATION );
1274
1275   value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2 );
1276   DALI_TEST_EQUALS( value.Get<Vector4>(), Color::WHITE, 0.001f, TEST_LOCATION );
1277
1278
1279   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3 );
1280   DALI_TEST_EQUALS( value.Get<Vector4>(), Color::BLUE, 0.001f, TEST_LOCATION );
1281
1282   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4 );
1283   DALI_TEST_EQUALS( value.Get<int>(), 20, TEST_LOCATION );
1284
1285   value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5 );
1286   DALI_TEST_EQUALS( value.Get<float>(), 40.0f, 0.001f, TEST_LOCATION );
1287
1288   END_TEST;
1289 }