2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali/public-api/dali-core.h>
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"
33 void custom_actor_test_startup(void)
35 test_return_value = TET_UNDEF;
38 void custom_actor_test_cleanup(void)
40 test_return_value = TET_PASS;
48 int UtcDaliCustomActorDestructor(void)
50 TestApplication application;
52 CustomActor* actor = new CustomActor();
55 DALI_TEST_CHECK( true );
59 int UtcDaliCustomActorImplDestructor(void)
61 TestApplication application;
62 CustomActorImpl* actor = new Test::Impl::TestCustomActor();
63 CustomActor customActor( *actor ); // Will automatically unref at the end of this function
65 DALI_TEST_CHECK( true );
69 // Positive test case for a method
70 int UtcDaliCustomActorDownCast(void)
72 TestApplication application;
73 tet_infoline("Testing Dali::CustomActor::DownCast()");
75 Test::TestCustomActor custom = Test::TestCustomActor::New();
77 Actor anActor = Actor::New();
78 anActor.Add( custom );
80 Actor child = anActor.GetChildAt(0);
81 CustomActor customActor = CustomActor::DownCast( child );
82 DALI_TEST_CHECK( customActor );
85 DALI_TEST_CHECK( !customActor );
87 customActor = DownCast< CustomActor >( child );
88 DALI_TEST_CHECK( customActor );
92 // Negative test case for a method
93 int UtcDaliCustomActorDownCastNegative(void)
95 TestApplication application;
96 tet_infoline("Testing Dali::CustomActor::DownCast()");
98 Actor actor1 = Actor::New();
99 Actor anActor = Actor::New();
102 Actor child = anActor.GetChildAt(0);
103 CustomActor customActor = CustomActor::DownCast( child );
104 DALI_TEST_CHECK( !customActor );
106 Actor unInitialzedActor;
107 customActor = CustomActor::DownCast( unInitialzedActor );
108 DALI_TEST_CHECK( !customActor );
110 customActor = DownCast< CustomActor >( unInitialzedActor );
111 DALI_TEST_CHECK( !customActor );
115 int UtcDaliCustomActorOnStageConnectionDisconnection(void)
117 TestApplication application;
118 tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection");
120 Test::TestCustomActor custom = Test::TestCustomActor::New();
121 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
123 // add the custom actor to stage
124 Stage::GetCurrent().Add( custom );
126 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
127 DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
129 Stage::GetCurrent().Remove( custom );
131 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
132 DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
134 // Excercise the message passing to Update thread
136 application.SendNotification();
137 application.Render();
138 application.Render();
142 int UtcDaliCustomActorOnStageConnectionOrder(void)
144 TestApplication application;
145 tet_infoline("Testing Dali::CustomActor::OnStageConnection() order");
147 MasterCallStack.clear();
149 /* Build tree of actors:
157 * OnStageConnection should be received for A, B, D, E, C, and finally F
160 Test::TestCustomActor actorA = Test::TestCustomActor::New();
161 actorA.SetName( "ActorA" );
163 Test::TestCustomActor actorB = Test::TestCustomActor::New();
164 actorB.SetName( "ActorB" );
165 actorA.Add( actorB );
167 Test::TestCustomActor actorC = Test::TestCustomActor::New();
168 actorC.SetName( "ActorC" );
169 actorA.Add( actorC );
171 Test::TestCustomActor actorD = Test::TestCustomActor::New();
172 actorD.SetName( "ActorD" );
173 actorB.Add( actorD );
175 Test::TestCustomActor actorE = Test::TestCustomActor::New();
176 actorE.SetName( "ActorE" );
177 actorB.Add( actorE );
179 Test::TestCustomActor actorF = Test::TestCustomActor::New();
180 actorF.SetName( "ActorF" );
181 actorC.Add( actorF );
183 // add the custom actor to stage
184 Stage::GetCurrent().Add( actorA );
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 );
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 );
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 );
200 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
201 DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
203 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
204 DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
206 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
207 DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
209 // Check sequence is correct in MasterCallStack
211 DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION );
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 );
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 );
226 // Excercise the message passing to Update thread
228 application.SendNotification();
229 application.Render();
230 application.Render();
234 int UtcDaliCustomActorOnStageDisconnectionOrder(void)
236 TestApplication application;
237 tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order");
239 Stage stage = Stage::GetCurrent();
241 /* Build tree of actors:
249 * OnStageDisconnection should be received for D, E, B, F, C, and finally A.
252 Test::TestCustomActor actorA = Test::TestCustomActor::New();
253 actorA.SetName( "ActorA" );
256 Test::TestCustomActor actorB = Test::TestCustomActor::New();
257 actorB.SetName( "ActorB" );
258 actorA.Add( actorB );
260 Test::TestCustomActor actorC = Test::TestCustomActor::New();
261 actorC.SetName( "ActorC" );
262 actorA.Add( actorC );
264 Test::TestCustomActor actorD = Test::TestCustomActor::New();
265 actorD.SetName( "ActorD" );
266 actorB.Add( actorD );
268 Test::TestCustomActor actorE = Test::TestCustomActor::New();
269 actorE.SetName( "ActorE" );
270 actorB.Add( actorE );
272 Test::TestCustomActor actorF = Test::TestCustomActor::New();
273 actorF.SetName( "ActorF" );
274 actorC.Add( actorF );
276 // Excercise the message passing to Update thread
278 application.SendNotification();
279 application.Render();
280 application.Render();
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();
291 stage.Remove( actorA );
293 DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
294 DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
296 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
297 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
299 DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
300 DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION );
302 DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION );
303 DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION );
305 DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION );
306 DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION );
308 DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION );
309 DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION );
311 // Check sequence is correct in MasterCallStack
313 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
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 );
322 // Excercise the message passing to Update thread
324 application.SendNotification();
325 application.Render();
326 application.Render();
330 int UtcDaliCustomActorAddDuringOnStageConnection(void)
332 TestApplication application;
333 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback");
335 Stage stage = Stage::GetCurrent();
337 MasterCallStack.clear();
339 /* The actorA is a special variant which adds a child to itself during OnStageConnection()
340 * The actorB is provided as the child
343 Test::TestCustomActor actorB = Test::TestCustomActor::New();
344 actorB.SetName( "ActorB" );
346 Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant1( actorB );
347 actorA.SetName( "ActorA" );
350 // Check callback sequence
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()
356 DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION );
357 DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION );
359 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
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()
365 // Excercise the message passing to Update thread
367 application.SendNotification();
368 application.Render();
369 application.Render();
371 // Check everything is ok after Actors are removed
373 stage.Remove( actorA );
374 application.SendNotification();
375 application.Render();
376 application.Render();
380 int UtcDaliCustomActorRemoveDuringOnStageConnection(void)
382 TestApplication application;
383 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback");
385 Stage stage = Stage::GetCurrent();
387 MasterCallStack.clear();
389 /* The actorA is a special variant which removes its children during OnStageConnection()
390 * Actors B & C are provided as the children
393 Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant2();
394 actorA.SetName( "ActorA" );
396 Test::TestCustomActor actorB = Test::TestCustomActor::New();
397 actorB.SetName( "ActorB" );
398 actorA.Add( actorB );
400 Test::TestCustomActor actorC = Test::TestCustomActor::New();
401 actorC.SetName( "ActorC" );
402 actorA.Add( actorC );
406 // Check callback sequence
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()
415 DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION );
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 );
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
426 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
427 DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION );
429 // Excercise the message passing to Update thread
431 application.SendNotification();
432 application.Render();
433 application.Render();
435 // Check everything is ok after last actor is removed
437 stage.Remove( actorA );
438 application.SendNotification();
439 application.Render();
440 application.Render();
444 int UtcDaliCustomActorAddDuringOnStageDisconnection(void)
446 TestApplication application;
447 tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback");
449 Stage stage = Stage::GetCurrent();
451 /* The actorA is a special variant which adds a child to itself during OnStageDisconnection()
452 * The actorB is provided as the child
455 Test::TestCustomActor actorB = Test::TestCustomActor::New();
456 actorB.SetName( "ActorB" );
458 Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant3( actorB );
459 actorA.SetName( "ActorA" );
462 // Excercise the message passing to Update thread
464 application.SendNotification();
465 application.Render();
466 application.Render();
468 // Clear call stacks before disconnection
469 actorA.ResetCallStack();
470 actorB.ResetCallStack();
471 MasterCallStack.clear();
473 stage.Remove( actorA );
475 // Check callback sequence
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 );
481 // Child was added after parent disconnection, so should not receive OnStageConnection()
482 DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
484 DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION );
486 DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION );
487 DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION );
489 // Excercise the message passing to Update thread
491 application.SendNotification();
492 application.Render();
493 application.Render();
497 int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void)
499 TestApplication application;
500 tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback");
502 Stage stage = Stage::GetCurrent();
504 /* The actorA is a special variant which removes its children during OnStageDisconnection()
505 * The actorB is provided as the child
508 Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant4();
509 actorA.SetName( "ActorA" );
512 Test::TestCustomActor actorB = Test::TestCustomActor::New();
513 actorB.SetName( "ActorB" );
514 actorA.Add( actorB );
516 // Excercise the message passing to Update thread
518 application.SendNotification();
519 application.Render();
520 application.Render();
522 // Clear call stacks before disconnection
523 actorA.ResetCallStack();
524 actorB.ResetCallStack();
525 MasterCallStack.clear();
527 stage.Remove( actorA );
529 // Check callback sequence
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 );
535 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
536 DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
538 DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION );
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 );
544 // Excercise the message passing to Update thread
546 application.SendNotification();
547 application.Render();
548 application.Render();
552 int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void)
554 TestApplication application;
555 tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback");
557 Stage stage = Stage::GetCurrent();
559 MasterCallStack.clear();
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()
566 Test::TestCustomActor actorA = Test::TestCustomActor::New();
567 actorA.SetName( "ActorA" );
569 Test::TestCustomActor actorB = Test::TestCustomActor::NewVariant5();
570 actorB.SetName( "ActorB" );
571 actorA.Add( actorB );
575 // Check callback sequence
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 );
582 DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION );
583 DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION );
585 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
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 );
592 // Excercise the message passing to Update thread
594 application.SendNotification();
595 application.Render();
596 application.Render();
600 int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void)
602 TestApplication application;
603 tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback");
605 Stage stage = Stage::GetCurrent();
607 MasterCallStack.clear();
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()
614 Test::TestCustomActor actorA = Test::TestCustomActor::New();
615 actorA.SetName( "ActorA" );
618 Test::TestCustomActor actorB = Test::TestCustomActor::NewVariant6();
619 actorB.SetName( "ActorB" );
620 actorA.Add( actorB );
622 stage.Remove( actorA );
624 // Check callback sequence
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 );
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
635 DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION );
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 );
642 // Excercise the message passing to Update thread
644 application.SendNotification();
645 application.Render();
646 application.Render();
650 int UtcDaliCustomActorOnChildAddRemove(void)
652 TestApplication application;
653 tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()");
655 Test::TestCustomActor custom = Test::TestCustomActor::New();
656 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
658 Actor aChild = Actor::New();
659 custom.Add( aChild );
661 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
662 DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
664 custom.Remove( aChild );
666 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
667 DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
671 int UtcDaliCustomActorReparentDuringOnChildAdd(void)
673 TestApplication application;
674 tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback");
676 Stage stage = Stage::GetCurrent();
678 MasterCallStack.clear();
680 /* The actorA is a special variant which reparents children added into a separate container child
681 * The actorB is the child of actorA
684 Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant7( "ActorA" );
687 Test::TestCustomActor actorB = Test::TestCustomActor::New();
688 actorB.SetName( "ActorB" );
689 actorA.Add( actorB );
691 // Check hierarchy is as follows:
698 DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION );
700 Actor container = actorA.GetChildAt(0);
701 Actor containerChild;
703 DALI_TEST_CHECK( container );
706 DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION );
707 DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION );
708 containerChild = container.GetChildAt(0);
711 DALI_TEST_CHECK( containerChild );
712 if ( containerChild )
714 DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION );
715 DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION );
718 // Check callback sequence
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
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 );
732 DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION );
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 );
742 // Excercise the message passing to Update thread
744 application.SendNotification();
745 application.Render();
746 application.Render();
751 * Test that Remove can be called (a NOOP) during the OnChildRemove
752 * triggered when reparenting an actor
754 int UtcDaliCustomActorRemoveDuringOnChildRemove(void)
756 TestApplication application;
757 tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting");
759 Stage stage = Stage::GetCurrent();
761 MasterCallStack.clear();
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
768 Test::TestCustomActor actorB = Test::TestCustomActor::New();
769 actorB.SetName( "ActorB" );
772 Test::TestCustomActor actorA = Test::TestCustomActor::NewVariant8( actorB );
773 actorA.SetName( "ActorA" );
776 Actor childActor = Actor::New();
777 childActor.SetName( "Child" );
778 // Reparent from actorA to actorB
779 actorA.Add( childActor );
780 actorB.Add( childActor );
782 // Check hierarchy is as follows:
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 );
791 Actor child = actorB.GetChildAt(0);
793 DALI_TEST_CHECK( child );
796 DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION );
799 // Check callback sequence
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
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 );
813 DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION );
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 );
823 // Excercise the message passing to Update thread
825 application.SendNotification();
826 application.Render();
827 application.Render();
831 int UtcDaliCustomActorOnPropertySet(void)
833 TestApplication application;
834 tet_infoline("Testing Dali::CustomActor::OnPropertySet()");
836 Test::TestCustomActor custom = Test::TestCustomActor::New();
837 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
839 custom.SetDaliProperty("yes");
841 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
842 DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
846 int UtcDaliCustomActorOnSizeSet(void)
848 TestApplication application;
849 tet_infoline("Testing Dali::CustomActor::OnSizeSet()");
851 Test::TestCustomActor custom = Test::TestCustomActor::New();
852 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
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 );
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 );
869 int UtcDaliCustomActorOnSizeAnimation(void)
871 TestApplication application;
872 tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()");
874 Test::TestCustomActor custom = Test::TestCustomActor::New();
875 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
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 );
887 int UtcDaliCustomActorOnTouchEvent(void)
889 TestApplication application;
890 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
892 Test::TestCustomActor custom = Test::TestCustomActor::New();
893 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
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();
901 // Render and notify a couple of times
902 application.SendNotification();
903 application.Render();
904 application.SendNotification();
905 application.Render();
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 );
915 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
916 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
920 int UtcDaliCustomActorOnHoverEvent(void)
922 TestApplication application;
923 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
925 Test::TestCustomActor custom = Test::TestCustomActor::New();
926 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
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();
934 // Render and notify a couple of times
935 application.SendNotification();
936 application.Render();
937 application.SendNotification();
938 application.Render();
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 );
948 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
949 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
953 int UtcDaliCustomActorOnWheelEvent(void)
955 TestApplication application;
956 tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
958 Test::TestCustomActor custom = Test::TestCustomActor::New();
959 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
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();
967 // Render and notify a couple of times
968 application.SendNotification();
969 application.Render();
970 application.SendNotification();
971 application.Render();
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 );
978 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
979 DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
983 int UtcDaliCustomActorImplOnPropertySet(void)
985 TestApplication application;
986 CustomActorImpl* impl = new Test::Impl::SimpleTestCustomActor();
987 CustomActor customActor( *impl ); // Will automatically unref at the end of this function
989 impl->OnPropertySet( 0, 0 );
991 DALI_TEST_CHECK( true );
996 int UtcDaliCustomActorGetImplementation(void)
998 TestApplication application;
1000 Test::TestCustomActor custom = Test::TestCustomActor::New();
1001 CustomActorImpl& impl = custom.GetImplementation();
1002 impl.GetOwner(); // Test
1004 const Test::TestCustomActor constCustom = Test::TestCustomActor::New();
1005 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1006 constImpl.GetOwner(); // Test
1008 DALI_TEST_CHECK( true );
1012 int UtcDaliCustomActorDoAction(void)
1014 TestApplication application;
1015 tet_infoline("Testing Dali::CustomActor::DoAction()");
1017 Test::TestCustomActor custom = Test::TestCustomActor::New();
1019 BaseHandle customActorObject = custom;
1021 DALI_TEST_CHECK(customActorObject);
1023 Property::Map attributes;
1025 // Check that an invalid command is not performed
1026 DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1028 // Check that the custom actor is visible
1029 custom.SetVisible(true);
1030 DALI_TEST_CHECK(custom.IsVisible() == true);
1032 // Check the custom actor performed an action to hide itself
1033 DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1035 // flush the queue and render once
1036 application.SendNotification();
1037 application.Render();
1039 // Check that the custom actor is now invisible
1040 DALI_TEST_CHECK(custom.IsVisible() == false);
1042 // Check the custom actor performed an action to show itself
1043 DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1045 // flush the queue and render once
1046 application.SendNotification();
1047 application.Render();
1049 // Check that the custom actor is now visible
1050 DALI_TEST_CHECK(custom.IsVisible() == true);
1054 int UtcDaliCustomActorCustomActor(void)
1056 Dali::CustomActor customA;
1057 Dali::CustomActor customB( customA );
1059 DALI_TEST_CHECK( customA == customB );
1064 int UtcDaliCustomActorImplRelayoutRequest(void)
1066 TestApplication application;
1068 DALI_TEST_CHECK( gOnRelayout == false );
1070 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1071 Stage::GetCurrent().Add(custom);
1073 application.SendNotification();
1074 application.Render();
1076 DALI_TEST_CHECK( gOnRelayout == true );
1077 gOnRelayout = false;
1079 custom.TestRelayoutRequest();
1080 application.SendNotification();
1081 application.Render();
1083 DALI_TEST_CHECK( gOnRelayout == true );
1088 int UtcDaliCustomActorImplGetHeightForWidthBase(void)
1090 TestApplication application;
1091 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1093 float width = 300.0f;
1095 application.SendNotification();
1096 application.Render();
1098 float v = custom.TestGetHeightForWidthBase( width );
1100 DALI_TEST_CHECK( v == width );
1105 int UtcDaliCustomActorImplGetWidthForHeightBase(void)
1107 TestApplication application;
1108 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1110 float height = 300.0f;
1112 application.SendNotification();
1113 application.Render();
1115 float v = custom.TestGetWidthForHeightBase( height );
1117 DALI_TEST_CHECK( v == height );
1122 int UtcDaliCustomActorImplCalculateChildSizeBase(void)
1124 TestApplication application;
1125 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1127 Actor child = Actor::New();
1128 child.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1129 child.SetSize(150, 150);
1131 application.SendNotification();
1132 application.Render();
1134 float v = custom.TestCalculateChildSizeBase( child, Dali::Dimension::ALL_DIMENSIONS );
1135 DALI_TEST_CHECK( v == 0.0f );
1140 int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
1142 TestApplication application;
1143 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1144 custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
1146 bool v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::ALL_DIMENSIONS );
1147 DALI_TEST_CHECK( v == true );
1149 application.SendNotification();
1150 application.Render();
1152 custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1153 v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::WIDTH );
1154 DALI_TEST_CHECK( v == false );
1156 // why is this here?
1157 application.SendNotification();
1158 application.Render();
1163 int UtcDaliCustomActorTypeRegistry(void)
1165 TestApplication application;
1169 type = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
1170 DALI_TEST_CHECK( type );
1171 BaseHandle handle = type.CreateInstance();
1174 std::string exception;
1178 name = handle.GetTypeName();
1179 tet_result(TET_FAIL);
1181 catch( DaliException& e )
1183 exception = e.condition;
1184 DALI_TEST_EQUALS( exception, "handle && \"BaseObject handle is empty\"", TEST_LOCATION );
1191 int UtcDaliCustomActorGetExtensionP(void)
1193 TestApplication application;
1195 Test::TestCustomActor custom = Test::TestCustomActor::NewVariant5();
1197 DALI_TEST_CHECK( NULL == custom.GetImplementation().GetExtension() );
1202 int UtcDaliCustomActorOnConnectionDepth(void)
1204 TestApplication application;
1205 tet_infoline("Testing Dali::CustomActor::OnStageConnection() hierarchy depth");
1207 Stage stage = Stage::GetCurrent();
1209 /* Build tree of actors:
1219 * OnStageConnection should return 1 for A, 2 for B and C, and 3 for D, E and F.
1222 Test::TestCustomActor actorA = Test::TestCustomActor::New();
1223 stage.Add( actorA );
1225 Test::TestCustomActor actorB = Test::TestCustomActor::New();
1226 actorA.Add( actorB );
1228 Test::TestCustomActor actorC = Test::TestCustomActor::New();
1229 actorA.Add( actorC );
1231 Test::TestCustomActor actorD = Test::TestCustomActor::New();
1232 actorB.Add( actorD );
1234 Test::TestCustomActor actorE = Test::TestCustomActor::New();
1235 actorB.Add( actorE );
1237 Test::TestCustomActor actorF = Test::TestCustomActor::New();
1238 actorC.Add( actorF );
1240 // Excercise the message passing to Update thread
1241 application.SendNotification();
1242 application.Render();
1243 application.Render();
1245 DALI_TEST_EQUALS( 1u, actorA.GetDepth(), TEST_LOCATION );
1246 DALI_TEST_EQUALS( 2u, actorB.GetDepth(), TEST_LOCATION );
1247 DALI_TEST_EQUALS( 2u, actorC.GetDepth(), TEST_LOCATION );
1248 DALI_TEST_EQUALS( 3u, actorD.GetDepth(), TEST_LOCATION );
1249 DALI_TEST_EQUALS( 3u, actorE.GetDepth(), TEST_LOCATION );
1250 DALI_TEST_EQUALS( 3u, actorF.GetDepth(), TEST_LOCATION );
1256 int UtcDaliCustomActorSetGetProperty(void)
1258 TestApplication application; // Need the type registry
1260 Test::TestCustomActor actor = Test::TestCustomActor::New();
1261 Stage::GetCurrent().Add( actor );
1263 actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1, 0.5f );
1264 actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2, Color::WHITE );
1265 actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3, Color::BLUE );
1266 actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4, 20 );
1267 actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5, 40.0f );
1269 Property::Value value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1 );
1270 DALI_TEST_EQUALS( value.Get<float>(), 0.5f, 0.001f, TEST_LOCATION );
1272 value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2 );
1273 DALI_TEST_EQUALS( value.Get<Vector4>(), Color::WHITE, 0.001f, TEST_LOCATION );
1276 value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3 );
1277 DALI_TEST_EQUALS( value.Get<Vector4>(), Color::BLUE, 0.001f, TEST_LOCATION );
1279 value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4 );
1280 DALI_TEST_EQUALS( value.Get<int>(), 20, TEST_LOCATION );
1282 value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5 );
1283 DALI_TEST_EQUALS( value.Get<float>(), 40.0f, 0.001f, TEST_LOCATION );