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 ) );
881 application.SendNotification();
882 application.Render( static_cast<unsigned int>( 1000.0f ) );
884 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
885 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
886 DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
887 DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
888 DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
892 int UtcDaliCustomActorSizeComponentAnimation(void)
894 TestApplication application;
895 tet_infoline("Testing Size component animation");
897 Test::TestCustomActor custom = Test::TestCustomActor::New();
898 float intialWidth( 10.0f );
900 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
901 custom.SetSize( intialWidth, 10.0f); // First method
903 Animation anim = Animation::New( 1.0f );
905 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
907 anim.AnimateTo( Property( custom, Actor::Property::SIZE_WIDTH ), 20.0f );
909 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
911 anim.Play(); // Triggers second method ( OnSizeAnimation )
913 application.SendNotification();
914 application.Render( static_cast<unsigned int>( 1000.0f ) );
916 DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
918 DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
924 int UtcDaliCustomActorOnTouchEvent(void)
926 TestApplication application;
927 tet_infoline("Testing Dali::CustomActor::OnTouchEvent()");
929 Test::TestCustomActor custom = Test::TestCustomActor::New();
930 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
932 // set size for custom actor
933 custom.SetSize( 100, 100 );
934 // add the custom actor to stage
935 Stage::GetCurrent().Add( custom );
936 custom.ResetCallStack();
938 // Render and notify a couple of times
939 application.SendNotification();
940 application.Render();
941 application.SendNotification();
942 application.Render();
944 // simulate a touch event
945 Dali::Integration::Point point;
946 point.SetState( PointState::DOWN );
947 point.SetScreenPosition( Vector2( 1, 1 ) );
948 Dali::Integration::TouchEvent event;
949 event.AddPoint( point );
950 application.ProcessEvent( event );
952 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
953 DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
957 int UtcDaliCustomActorOnHoverEvent(void)
959 TestApplication application;
960 tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
962 Test::TestCustomActor custom = Test::TestCustomActor::New();
963 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
965 // set size for custom actor
966 custom.SetSize( 100, 100 );
967 // add the custom actor to stage
968 Stage::GetCurrent().Add( custom );
969 custom.ResetCallStack();
971 // Render and notify a couple of times
972 application.SendNotification();
973 application.Render();
974 application.SendNotification();
975 application.Render();
977 // simulate a hover event
978 Dali::Integration::Point point;
979 point.SetState( PointState::MOTION );
980 point.SetScreenPosition( Vector2( 1, 1 ) );
981 Dali::Integration::HoverEvent event;
982 event.AddPoint( point );
983 application.ProcessEvent( event );
985 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
986 DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
990 int UtcDaliCustomActorOnWheelEvent(void)
992 TestApplication application;
993 tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
995 Test::TestCustomActor custom = Test::TestCustomActor::New();
996 DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
998 // set size for custom actor
999 custom.SetSize( 100, 100 );
1000 // add the custom actor to stage
1001 Stage::GetCurrent().Add( custom );
1002 custom.ResetCallStack();
1004 // Render and notify a couple of times
1005 application.SendNotification();
1006 application.Render();
1007 application.SendNotification();
1008 application.Render();
1010 // simulate a wheel event
1011 Vector2 screenCoordinates( 10.0f, 10.0f );
1012 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
1013 application.ProcessEvent( event );
1015 DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
1016 DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
1020 int UtcDaliCustomActorImplOnPropertySet(void)
1022 TestApplication application;
1023 CustomActorImpl* impl = new Test::Impl::SimpleTestCustomActor();
1024 CustomActor customActor( *impl ); // Will automatically unref at the end of this function
1026 impl->OnPropertySet( 0, 0 );
1028 DALI_TEST_CHECK( true );
1033 int UtcDaliCustomActorGetImplementation(void)
1035 TestApplication application;
1037 Test::TestCustomActor custom = Test::TestCustomActor::New();
1038 CustomActorImpl& impl = custom.GetImplementation();
1039 impl.GetOwner(); // Test
1041 const Test::TestCustomActor constCustom = Test::TestCustomActor::New();
1042 const CustomActorImpl& constImpl = constCustom.GetImplementation();
1043 constImpl.GetOwner(); // Test
1045 DALI_TEST_CHECK( true );
1049 int UtcDaliCustomActorDoAction(void)
1051 TestApplication application;
1052 tet_infoline("Testing Dali::CustomActor::DoAction()");
1054 Test::TestCustomActor custom = Test::TestCustomActor::New();
1056 BaseHandle customActorObject = custom;
1058 DALI_TEST_CHECK(customActorObject);
1060 Property::Map attributes;
1062 // Check that an invalid command is not performed
1063 DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
1065 // Check that the custom actor is visible
1066 custom.SetVisible(true);
1067 DALI_TEST_CHECK(custom.IsVisible() == true);
1069 // Check the custom actor performed an action to hide itself
1070 DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
1072 // flush the queue and render once
1073 application.SendNotification();
1074 application.Render();
1076 // Check that the custom actor is now invisible
1077 DALI_TEST_CHECK(custom.IsVisible() == false);
1079 // Check the custom actor performed an action to show itself
1080 DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
1082 // flush the queue and render once
1083 application.SendNotification();
1084 application.Render();
1086 // Check that the custom actor is now visible
1087 DALI_TEST_CHECK(custom.IsVisible() == true);
1091 int UtcDaliCustomActorCustomActor(void)
1093 Dali::CustomActor customA;
1094 Dali::CustomActor customB( customA );
1096 DALI_TEST_CHECK( customA == customB );
1101 int UtcDaliCustomActorImplRelayoutRequest(void)
1103 TestApplication application;
1105 DALI_TEST_CHECK( gOnRelayout == false );
1107 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1108 Stage::GetCurrent().Add(custom);
1110 application.SendNotification();
1111 application.Render();
1113 DALI_TEST_CHECK( gOnRelayout == true );
1114 gOnRelayout = false;
1116 custom.TestRelayoutRequest();
1117 application.SendNotification();
1118 application.Render();
1120 DALI_TEST_CHECK( gOnRelayout == true );
1125 int UtcDaliCustomActorImplGetHeightForWidthBase(void)
1127 TestApplication application;
1128 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1130 float width = 300.0f;
1132 application.SendNotification();
1133 application.Render();
1135 float v = custom.TestGetHeightForWidthBase( width );
1137 DALI_TEST_CHECK( v == width );
1142 int UtcDaliCustomActorImplGetWidthForHeightBase(void)
1144 TestApplication application;
1145 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1147 float height = 300.0f;
1149 application.SendNotification();
1150 application.Render();
1152 float v = custom.TestGetWidthForHeightBase( height );
1154 DALI_TEST_CHECK( v == height );
1159 int UtcDaliCustomActorImplCalculateChildSizeBase(void)
1161 TestApplication application;
1162 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1164 Actor child = Actor::New();
1165 child.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1166 child.SetSize(150, 150);
1168 application.SendNotification();
1169 application.Render();
1171 float v = custom.TestCalculateChildSizeBase( child, Dali::Dimension::ALL_DIMENSIONS );
1172 DALI_TEST_CHECK( v == 0.0f );
1177 int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
1179 TestApplication application;
1180 Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
1181 custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
1183 bool v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::ALL_DIMENSIONS );
1184 DALI_TEST_CHECK( v == true );
1186 application.SendNotification();
1187 application.Render();
1189 custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
1190 v = custom.TestRelayoutDependentOnChildrenBase( Dali::Dimension::WIDTH );
1191 DALI_TEST_CHECK( v == false );
1193 // why is this here?
1194 application.SendNotification();
1195 application.Render();
1200 int UtcDaliCustomActorTypeRegistry(void)
1202 TestApplication application;
1206 type = TypeRegistry::Get().GetTypeInfo( "CustomActor" );
1207 DALI_TEST_CHECK( type );
1208 BaseHandle handle = type.CreateInstance();
1211 std::string exception;
1215 name = handle.GetTypeName();
1216 tet_result(TET_FAIL);
1218 catch( DaliException& e )
1220 exception = e.condition;
1221 DALI_TEST_EQUALS( exception, "handle && \"BaseObject handle is empty\"", TEST_LOCATION );
1228 int UtcDaliCustomActorGetExtensionP(void)
1230 TestApplication application;
1232 Test::TestCustomActor custom = Test::TestCustomActor::NewVariant5();
1234 DALI_TEST_CHECK( NULL == custom.GetImplementation().GetExtension() );
1239 int UtcDaliCustomActorOnConnectionDepth(void)
1241 TestApplication application;
1242 tet_infoline("Testing Dali::CustomActor::OnStageConnection() hierarchy depth");
1244 Stage stage = Stage::GetCurrent();
1246 /* Build tree of actors:
1256 * OnStageConnection should return 1 for A, 2 for B and C, and 3 for D, E and F.
1259 Test::TestCustomActor actorA = Test::TestCustomActor::New();
1260 stage.Add( actorA );
1262 Test::TestCustomActor actorB = Test::TestCustomActor::New();
1263 actorA.Add( actorB );
1265 Test::TestCustomActor actorC = Test::TestCustomActor::New();
1266 actorA.Add( actorC );
1268 Test::TestCustomActor actorD = Test::TestCustomActor::New();
1269 actorB.Add( actorD );
1271 Test::TestCustomActor actorE = Test::TestCustomActor::New();
1272 actorB.Add( actorE );
1274 Test::TestCustomActor actorF = Test::TestCustomActor::New();
1275 actorC.Add( actorF );
1277 // Excercise the message passing to Update thread
1278 application.SendNotification();
1279 application.Render();
1280 application.Render();
1282 DALI_TEST_EQUALS( 1u, actorA.GetDepth(), TEST_LOCATION );
1283 DALI_TEST_EQUALS( 2u, actorB.GetDepth(), TEST_LOCATION );
1284 DALI_TEST_EQUALS( 2u, actorC.GetDepth(), TEST_LOCATION );
1285 DALI_TEST_EQUALS( 3u, actorD.GetDepth(), TEST_LOCATION );
1286 DALI_TEST_EQUALS( 3u, actorE.GetDepth(), TEST_LOCATION );
1287 DALI_TEST_EQUALS( 3u, actorF.GetDepth(), TEST_LOCATION );
1293 int UtcDaliCustomActorSetGetProperty(void)
1295 TestApplication application; // Need the type registry
1297 Test::TestCustomActor actor = Test::TestCustomActor::New();
1298 Stage::GetCurrent().Add( actor );
1300 actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1, 0.5f );
1301 actor.SetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2, Color::WHITE );
1302 actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3, Color::BLUE );
1303 actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4, 20 );
1304 actor.SetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5, 40.0f );
1306 Property::Value value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY1 );
1307 DALI_TEST_EQUALS( value.Get<float>(), 0.5f, 0.001f, TEST_LOCATION );
1309 value = actor.GetProperty( Test::TestCustomActor::Property::TEST_PROPERTY2 );
1310 DALI_TEST_EQUALS( value.Get<Vector4>(), Color::WHITE, 0.001f, TEST_LOCATION );
1313 value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY3 );
1314 DALI_TEST_EQUALS( value.Get<Vector4>(), Color::BLUE, 0.001f, TEST_LOCATION );
1316 value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY4 );
1317 DALI_TEST_EQUALS( value.Get<int>(), 20, TEST_LOCATION );
1319 value = actor.GetProperty( Test::DevelTestCustomActor::Property::DEVEL_TEST_PROPERTY5 );
1320 DALI_TEST_EQUALS( value.Get<float>(), 40.0f, 0.001f, TEST_LOCATION );