2 * Copyright (c) 2015 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.
19 #include <dali/public-api/dali-core.h>
21 #include <cfloat> // For FLT_MAX
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/hover-event-integ.h>
24 #include <dali-test-suite-utils.h>
32 void utc_dali_actor_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_actor_cleanup(void)
39 test_return_value = TET_PASS;
44 bool gTouchCallBackCalled=false;
45 bool gHoverCallBackCalled=false;
48 * Simulates a Down Touch at 25.0, 25.0.
49 * @param[in] app Test Application instance.
51 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
53 app.SendNotification();
55 app.SendNotification();
58 gTouchCallBackCalled = false;
60 // simulate a touch event
61 Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
62 Dali::Integration::TouchEvent event;
63 event.AddPoint( point );
64 app.ProcessEvent( event );
66 app.SendNotification();
68 app.SendNotification();
74 static bool gTestConstraintCalled;
78 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
80 gTestConstraintCalled = true;
85 * TestConstraint reference.
86 * When constraint is called, the resultRef is updated
87 * with the value supplied.
90 struct TestConstraintRef
92 TestConstraintRef(unsigned int& resultRef, unsigned int value)
93 : mResultRef(resultRef),
98 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
103 unsigned int& mResultRef;
107 static bool TestCallback(Actor actor, const TouchEvent& event)
109 gTouchCallBackCalled = true;
114 static bool TestCallback3(Actor actor, const HoverEvent& event)
116 gHoverCallBackCalled = true;
121 static Vector3 gSetSize;
122 static bool gSetSizeCallBackCalled;
123 void SetSizeCallback( Actor actor, const Vector3& size )
125 gSetSizeCallBackCalled = true;
128 // validation stuff for onstage & offstage signals
129 static std::vector< std::string > gActorNamesOnOffStage;
130 static int gOnStageCallBackCalled;
131 void OnStageCallback( Actor actor )
133 ++gOnStageCallBackCalled;
134 gActorNamesOnOffStage.push_back( actor.GetName() );
135 DALI_TEST_CHECK( actor.OnStage() == true );
137 static int gOffStageCallBackCalled;
138 void OffStageCallback( Actor actor )
140 ++gOffStageCallBackCalled;
141 gActorNamesOnOffStage.push_back( actor.GetName() );
142 DALI_TEST_CHECK( actor.OnStage() == false );
145 struct PositionComponentConstraint
147 PositionComponentConstraint(){}
149 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
151 const Matrix& m = inputs[0]->GetMatrix();
154 m.GetTransformComponents(pos, rot, scale);
158 struct OrientationComponentConstraint
160 OrientationComponentConstraint(){}
162 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
164 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
167 orientation = parentOrientation;
172 static bool gOnRelayoutCallBackCalled = false;
173 static std::vector< std::string > gActorNamesRelayout;
175 void OnRelayoutCallback( Actor actor )
177 gOnRelayoutCallBackCalled = true;
178 gActorNamesRelayout.push_back( actor.GetName() );
181 } // anonymous namespace
184 //& purpose: Testing New API
185 int UtcDaliActorNew(void)
187 TestApplication application;
189 Actor actor = Actor::New();
191 DALI_TEST_CHECK(actor);
195 //& purpose: Testing Dali::Actor::DownCast()
196 int UtcDaliActorDownCastP(void)
198 TestApplication application;
199 tet_infoline("Testing Dali::Actor::DownCast()");
201 Actor actor = Actor::New();
202 BaseHandle object(actor);
203 Actor actor2 = Actor::DownCast(object);
204 DALI_TEST_CHECK(actor2);
208 //& purpose: Testing Dali::Actor::DownCast()
209 int UtcDaliActorDownCastN(void)
211 TestApplication application;
212 tet_infoline("Testing Dali::Actor::DownCast()");
214 BaseHandle unInitializedObject;
215 Actor actor = Actor::DownCast(unInitializedObject);
216 DALI_TEST_CHECK(!actor);
220 //& purpose: Testing Dali::Actor::GetName()
221 int UtcDaliActorGetName(void)
223 TestApplication application;
225 Actor actor = Actor::New();
227 DALI_TEST_CHECK(actor.GetName().empty());
231 //& purpose: Testing Dali::Actor::SetName()
232 int UtcDaliActorSetName(void)
234 TestApplication application;
236 string str("ActorName");
237 Actor actor = Actor::New();
240 DALI_TEST_CHECK(actor.GetName() == str);
244 int UtcDaliActorGetId(void)
246 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
247 TestApplication application;
249 Actor first = Actor::New();
250 Actor second = Actor::New();
251 Actor third = Actor::New();
253 DALI_TEST_CHECK(first.GetId() != second.GetId());
254 DALI_TEST_CHECK(second.GetId() != third.GetId());
258 int UtcDaliActorIsRoot(void)
260 TestApplication application;
262 Actor actor = Actor::New();
263 DALI_TEST_CHECK(!actor.IsRoot());
265 // get the root layer
266 actor = Stage::GetCurrent().GetLayer( 0 );
267 DALI_TEST_CHECK( actor.IsRoot() );
271 int UtcDaliActorOnStage(void)
273 TestApplication application;
275 Actor actor = Actor::New();
276 DALI_TEST_CHECK( !actor.OnStage() );
278 // get the root layer
279 actor = Stage::GetCurrent().GetLayer( 0 );
280 DALI_TEST_CHECK( actor.OnStage() );
284 int UtcDaliActorIsLayer(void)
286 TestApplication application;
288 Actor actor = Actor::New();
289 DALI_TEST_CHECK( !actor.IsLayer() );
291 // get the root layer
292 actor = Stage::GetCurrent().GetLayer( 0 );
293 DALI_TEST_CHECK( actor.IsLayer() );
297 int UtcDaliActorGetLayer(void)
299 TestApplication application;
301 Actor actor = Actor::New();
302 Stage::GetCurrent().Add(actor);
303 Layer layer = actor.GetLayer();
305 DALI_TEST_CHECK(layer);
307 // get the root layers layer
308 actor = Stage::GetCurrent().GetLayer( 0 );
309 DALI_TEST_CHECK( actor.GetLayer() );
313 int UtcDaliActorAddP(void)
315 tet_infoline("Testing Actor::Add");
316 TestApplication application;
318 Actor parent = Actor::New();
319 Actor child = Actor::New();
321 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
325 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
327 Actor parent2 = Actor::New();
328 parent2.Add( child );
330 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
331 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
333 // try Adding to same parent again, works
334 parent2.Add( child );
335 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
337 // try reparenting an orphaned child
339 Actor temporaryParent = Actor::New();
340 temporaryParent.Add( child );
341 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
343 // temporaryParent has now died, reparent the orphaned child
344 parent2.Add( child );
345 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
350 int UtcDaliActorAddN(void)
352 tet_infoline("Testing Actor::Add");
353 TestApplication application;
355 Actor child = Actor::New();
357 Actor parent2 = Actor::New();
358 parent2.Add( child );
363 parent2.Add( parent2 );
364 tet_printf("Assertion test failed - no Exception\n" );
365 tet_result(TET_FAIL);
367 catch(Dali::DaliException& e)
369 DALI_TEST_PRINT_ASSERT( e );
370 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
371 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
375 tet_printf("Assertion test failed - wrong Exception\n" );
376 tet_result(TET_FAIL);
379 // try reparenting root
382 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
383 tet_printf("Assertion test failed - no Exception\n" );
384 tet_result(TET_FAIL);
386 catch(Dali::DaliException& e)
388 DALI_TEST_PRINT_ASSERT( e );
389 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
390 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
394 tet_printf("Assertion test failed - wrong Exception\n" );
395 tet_result(TET_FAIL);
402 parent2.Add( empty );
403 tet_printf("Assertion test failed - no Exception\n" );
404 tet_result(TET_FAIL);
406 catch(Dali::DaliException& e)
408 DALI_TEST_PRINT_ASSERT( e );
409 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
410 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
414 tet_printf("Assertion test failed - wrong Exception\n" );
415 tet_result(TET_FAIL);
421 int UtcDaliActorRemoveN(void)
423 tet_infoline("Testing Actor::Remove");
424 TestApplication application;
426 Actor parent = Actor::New();
427 Actor child = Actor::New();
428 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
431 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
433 parent.Remove(child);
434 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
436 // remove again, no problem
437 parent.Remove(child);
438 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
442 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
443 // try Remove self, its a no-op
444 parent.Remove( parent );
445 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
451 parent.Remove( empty );
452 tet_printf("Assertion test failed - no Exception\n" );
453 tet_result(TET_FAIL);
455 catch(Dali::DaliException& e)
457 DALI_TEST_PRINT_ASSERT( e );
458 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
459 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
463 tet_printf("Assertion test failed - wrong Exception\n" );
464 tet_result(TET_FAIL);
469 int UtcDaliActorRemoveP(void)
471 TestApplication application;
473 Actor parent = Actor::New();
474 Actor child = Actor::New();
475 Actor random = Actor::New();
477 Stage::GetCurrent().Add( parent );
479 DALI_TEST_CHECK(parent.GetChildCount() == 0);
483 DALI_TEST_CHECK(parent.GetChildCount() == 1);
485 parent.Remove(random);
487 DALI_TEST_CHECK(parent.GetChildCount() == 1);
489 Stage::GetCurrent().Remove( parent );
491 DALI_TEST_CHECK(parent.GetChildCount() == 1);
495 int UtcDaliActorGetChildCount(void)
497 TestApplication application;
499 Actor parent = Actor::New();
500 Actor child = Actor::New();
502 DALI_TEST_CHECK(parent.GetChildCount() == 0);
506 DALI_TEST_CHECK(parent.GetChildCount() == 1);
510 int UtcDaliActorGetChildren01(void)
512 TestApplication application;
514 Actor parent = Actor::New();
515 Actor first = Actor::New();
516 Actor second = Actor::New();
517 Actor third = Actor::New();
523 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
524 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
525 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
529 int UtcDaliActorGetChildren02(void)
531 TestApplication application;
533 Actor parent = Actor::New();
534 Actor first = Actor::New();
535 Actor second = Actor::New();
536 Actor third = Actor::New();
542 const Actor& constParent = parent;
544 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
545 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
546 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
550 int UtcDaliActorGetParent01(void)
552 TestApplication application;
554 Actor parent = Actor::New();
555 Actor child = Actor::New();
559 DALI_TEST_CHECK(child.GetParent() == parent);
563 int UtcDaliActorGetParent02(void)
565 TestApplication application;
567 Actor actor = Actor::New();
569 DALI_TEST_CHECK(!actor.GetParent());
573 int UtcDaliActorSetParentOrigin(void)
575 TestApplication application;
577 Actor actor = Actor::New();
579 Vector3 vector(0.7f, 0.8f, 0.9f);
580 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
582 actor.SetParentOrigin(vector);
584 // flush the queue and render once
585 application.SendNotification();
586 application.Render();
588 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
590 Stage::GetCurrent().Add( actor );
592 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
594 // flush the queue and render once
595 application.SendNotification();
596 application.Render();
598 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
600 Stage::GetCurrent().Remove( actor );
604 int UtcDaliActorGetCurrentParentOrigin(void)
606 TestApplication application;
608 Actor actor = Actor::New();
610 Vector3 vector(0.7f, 0.8f, 0.9f);
611 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
613 actor.SetParentOrigin(vector);
615 // flush the queue and render once
616 application.SendNotification();
617 application.Render();
619 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
623 int UtcDaliActorSetAnchorPoint(void)
625 TestApplication application;
627 Actor actor = Actor::New();
629 Vector3 vector(0.7f, 0.8f, 0.9f);
630 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
632 actor.SetAnchorPoint(vector);
634 // flush the queue and render once
635 application.SendNotification();
636 application.Render();
638 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
640 Stage::GetCurrent().Add( actor );
642 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
643 // flush the queue and render once
644 application.SendNotification();
645 application.Render();
647 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
649 Stage::GetCurrent().Remove( actor );
653 int UtcDaliActorGetCurrentAnchorPoint(void)
655 TestApplication application;
657 Actor actor = Actor::New();
659 Vector3 vector(0.7f, 0.8f, 0.9f);
660 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
662 actor.SetAnchorPoint(vector);
664 // flush the queue and render once
665 application.SendNotification();
666 application.Render();
668 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
672 // SetSize(float width, float height)
673 int UtcDaliActorSetSize01(void)
675 TestApplication application;
677 Actor actor = Actor::New();
678 Vector3 vector(100.0f, 100.0f, 0.0f);
680 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
682 actor.SetSize(vector.x, vector.y);
684 // flush the queue and render once
685 application.SendNotification();
686 application.Render();
688 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
692 // SetSize(float width, float height, float depth)
693 int UtcDaliActorSetSize02(void)
695 TestApplication application;
697 Actor actor = Actor::New();
698 Vector3 vector(100.0f, 100.0f, 100.0f);
700 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
702 actor.SetSize(vector.x, vector.y, vector.z);
704 // flush the queue and render once
705 application.SendNotification();
706 application.Render();
708 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
712 // SetSize(Vector2 size)
713 int UtcDaliActorSetSize03(void)
715 TestApplication application;
717 Actor actor = Actor::New();
718 Vector3 vector(100.0f, 100.0f, 0.0f);
720 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
722 actor.SetSize(Vector2(vector.x, vector.y));
724 // flush the queue and render once
725 application.SendNotification();
726 application.Render();
728 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
732 // SetSize(Vector3 size)
733 int UtcDaliActorSetSize04(void)
735 TestApplication application;
737 Actor actor = Actor::New();
738 Vector3 vector(100.0f, 100.0f, 100.0f);
740 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
742 actor.SetSize(vector);
744 // flush the queue and render once
745 application.SendNotification();
746 application.Render();
748 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
750 Stage::GetCurrent().Add( actor );
751 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
753 // flush the queue and render once
754 application.SendNotification();
755 application.Render();
757 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
758 Stage::GetCurrent().Remove( actor );
762 int UtcDaliActorGetCurrentSize(void)
764 TestApplication application;
766 Actor actor = Actor::New();
767 Vector3 vector(100.0f, 100.0f, 20.0f);
769 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
771 actor.SetSize(vector);
773 // flush the queue and render once
774 application.SendNotification();
775 application.Render();
777 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
781 int UtcDaliActorGetNaturalSize(void)
783 TestApplication application;
785 Actor actor = Actor::New();
786 Vector3 vector( 0.0f, 0.0f, 0.0f );
788 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
793 int UtcDaliActorGetCurrentSizeImmediate(void)
795 TestApplication application;
797 Actor actor = Actor::New();
798 Vector3 vector(100.0f, 100.0f, 20.0f);
800 DALI_TEST_CHECK(vector != actor.GetTargetSize());
801 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
803 actor.SetSize(vector);
805 DALI_TEST_CHECK(vector == actor.GetTargetSize());
806 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
808 // flush the queue and render once
809 application.SendNotification();
810 application.Render();
812 DALI_TEST_CHECK(vector == actor.GetTargetSize());
813 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
816 // Build the animation
817 const float durationSeconds = 2.0f;
818 Animation animation = Animation::New( durationSeconds );
819 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
820 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
822 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
824 // Start the animation
827 application.SendNotification();
828 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
830 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
835 // SetPosition(float x, float y)
836 int UtcDaliActorSetPosition01(void)
838 TestApplication application;
840 Actor actor = Actor::New();
842 // Set to random to start off with
843 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
845 Vector3 vector(100.0f, 100.0f, 0.0f);
847 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
849 actor.SetPosition(vector.x, vector.y);
850 // flush the queue and render once
851 application.SendNotification();
852 application.Render();
853 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
855 Stage::GetCurrent().Add( actor );
856 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
857 // flush the queue and render once
858 application.SendNotification();
859 application.Render();
860 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
865 // flush the queue and render once
866 application.SendNotification();
867 application.Render();
868 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
870 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
871 // flush the queue and render once
872 application.SendNotification();
873 application.Render();
874 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
876 Stage::GetCurrent().Remove( actor );
880 // SetPosition(float x, float y, float z)
881 int UtcDaliActorSetPosition02(void)
883 TestApplication application;
885 Actor actor = Actor::New();
887 // Set to random to start off with
888 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
890 Vector3 vector(100.0f, 100.0f, 100.0f);
892 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
894 actor.SetPosition(vector.x, vector.y, vector.z);
896 // flush the queue and render once
897 application.SendNotification();
898 application.Render();
900 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
904 // SetPosition(Vector3 position)
905 int UtcDaliActorSetPosition03(void)
907 TestApplication application;
909 Actor actor = Actor::New();
911 // Set to random to start off with
912 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
914 Vector3 vector(100.0f, 100.0f, 100.0f);
916 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
918 actor.SetPosition(vector);
920 // flush the queue and render once
921 application.SendNotification();
922 application.Render();
924 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
928 int UtcDaliActorSetX(void)
930 TestApplication application;
932 Actor actor = Actor::New();
934 Vector3 vector(100.0f, 0.0f, 0.0f);
936 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
940 // flush the queue and render once
941 application.SendNotification();
942 application.Render();
944 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
948 int UtcDaliActorSetY(void)
950 TestApplication application;
952 Actor actor = Actor::New();
954 Vector3 vector(0.0f, 100.0f, 0.0f);
956 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
960 // flush the queue and render once
961 application.SendNotification();
962 application.Render();
964 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
968 int UtcDaliActorSetZ(void)
970 TestApplication application;
972 Actor actor = Actor::New();
974 Vector3 vector(0.0f, 0.0f, 100.0f);
976 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
980 // flush the queue and render once
981 application.SendNotification();
982 application.Render();
984 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
988 int UtcDaliActorTranslateBy(void)
990 TestApplication application;
992 Actor actor = Actor::New();
993 Vector3 vector(100.0f, 100.0f, 100.0f);
995 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
997 actor.SetPosition(vector);
999 // flush the queue and render once
1000 application.SendNotification();
1001 application.Render();
1003 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1005 actor.TranslateBy(vector);
1007 // flush the queue and render once
1008 application.SendNotification();
1009 application.Render();
1011 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1015 int UtcDaliActorGetCurrentPosition(void)
1017 TestApplication application;
1019 Actor actor = Actor::New();
1020 Vector3 setVector(100.0f, 100.0f, 0.0f);
1021 actor.SetPosition(setVector);
1023 // flush the queue and render once
1024 application.SendNotification();
1025 application.Render();
1027 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1031 int UtcDaliActorGetCurrentWorldPosition(void)
1033 TestApplication application;
1035 Actor parent = Actor::New();
1036 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1037 parent.SetPosition( parentPosition );
1038 parent.SetParentOrigin( ParentOrigin::CENTER );
1039 parent.SetAnchorPoint( AnchorPoint::CENTER );
1040 Stage::GetCurrent().Add( parent );
1042 Actor child = Actor::New();
1043 child.SetParentOrigin( ParentOrigin::CENTER );
1044 child.SetAnchorPoint( AnchorPoint::CENTER );
1045 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1046 child.SetPosition( childPosition );
1047 parent.Add( child );
1049 // The actors should not have a world position yet
1050 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1051 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1053 application.SendNotification();
1054 application.Render(0);
1056 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1057 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1059 // The actors should have a world position now
1060 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1061 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1065 int UtcDaliActorInheritPosition(void)
1067 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1068 TestApplication application;
1070 Actor parent = Actor::New();
1071 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1072 parent.SetPosition( parentPosition );
1073 parent.SetParentOrigin( ParentOrigin::CENTER );
1074 parent.SetAnchorPoint( AnchorPoint::CENTER );
1075 Stage::GetCurrent().Add( parent );
1077 Actor child = Actor::New();
1078 child.SetParentOrigin( ParentOrigin::CENTER );
1079 child.SetAnchorPoint( AnchorPoint::CENTER );
1080 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1081 child.SetPosition( childPosition );
1082 parent.Add( child );
1084 // The actors should not have a world position yet
1085 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1086 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1088 // first test default, which is to inherit position
1089 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1090 application.SendNotification();
1091 application.Render(0); // should only really call Update as Render is not required to update scene
1092 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1093 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1094 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1095 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1098 //Change child position
1099 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1100 child.SetPosition( childOffset );
1102 // Change inheritance mode to not inherit
1103 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1104 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1105 application.SendNotification();
1106 application.Render(0); // should only really call Update as Render is not required to update scene
1107 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1108 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1109 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1110 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1114 // SetOrientation(float angleRadians, Vector3 axis)
1115 int UtcDaliActorSetOrientation01(void)
1117 TestApplication application;
1119 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1120 Actor actor = Actor::New();
1122 actor.SetOrientation(rotation);
1124 // flush the queue and render once
1125 application.SendNotification();
1126 application.Render();
1128 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1132 int UtcDaliActorSetOrientation02(void)
1134 TestApplication application;
1136 Actor actor = Actor::New();
1138 Radian angle( 0.785f );
1139 Vector3 axis(1.0f, 1.0f, 0.0f);
1141 actor.SetOrientation( angle, axis);
1142 Quaternion rotation( angle, axis );
1143 // flush the queue and render once
1144 application.SendNotification();
1145 application.Render();
1146 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1148 Stage::GetCurrent().Add( actor );
1149 actor.RotateBy( Degree( 360 ), axis);
1150 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1152 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1153 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1154 // flush the queue and render once
1155 application.SendNotification();
1156 application.Render();
1157 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1159 actor.SetOrientation( angle, axis);
1160 // flush the queue and render once
1161 application.SendNotification();
1162 application.Render();
1163 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1165 Stage::GetCurrent().Remove( actor );
1169 // RotateBy(float angleRadians, Vector3 axis)
1170 int UtcDaliActorRotateBy01(void)
1172 TestApplication application;
1174 Actor actor = Actor::New();
1176 Radian angle( M_PI * 0.25f );
1177 actor.RotateBy(( angle ), Vector3::ZAXIS);
1178 // flush the queue and render once
1179 application.SendNotification();
1180 application.Render();
1181 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1183 Stage::GetCurrent().Add( actor );
1185 actor.RotateBy( angle, Vector3::ZAXIS);
1186 // flush the queue and render once
1187 application.SendNotification();
1188 application.Render();
1189 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1191 Stage::GetCurrent().Remove( actor );
1195 // RotateBy(Quaternion relativeRotation)
1196 int UtcDaliActorRotateBy02(void)
1198 TestApplication application;
1200 Actor actor = Actor::New();
1202 Radian angle( M_PI * 0.25f );
1203 Quaternion rotation(angle, Vector3::ZAXIS);
1204 actor.RotateBy(rotation);
1205 // flush the queue and render once
1206 application.SendNotification();
1207 application.Render();
1208 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1210 actor.RotateBy(rotation);
1211 // flush the queue and render once
1212 application.SendNotification();
1213 application.Render();
1214 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1218 int UtcDaliActorGetCurrentOrientation(void)
1220 TestApplication application;
1221 Actor actor = Actor::New();
1223 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1224 actor.SetOrientation(rotation);
1225 // flush the queue and render once
1226 application.SendNotification();
1227 application.Render();
1228 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1232 int UtcDaliActorGetCurrentWorldOrientation(void)
1234 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1235 TestApplication application;
1237 Actor parent = Actor::New();
1238 Radian rotationAngle( Degree(90.0f) );
1239 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1240 parent.SetOrientation( rotation );
1241 Stage::GetCurrent().Add( parent );
1243 Actor child = Actor::New();
1244 child.SetOrientation( rotation );
1245 parent.Add( child );
1247 // The actors should not have a world rotation yet
1248 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1249 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1251 application.SendNotification();
1252 application.Render(0);
1254 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1255 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1257 // The actors should have a world rotation now
1258 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1259 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1261 // turn off child rotation inheritance
1262 child.SetInheritOrientation( false );
1263 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1264 application.SendNotification();
1265 application.Render(0);
1267 // The actors should have a world rotation now
1268 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1269 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1273 // SetScale(float scale)
1274 int UtcDaliActorSetScale01(void)
1276 TestApplication application;
1278 Actor actor = Actor::New();
1280 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1281 actor.SetScale(0.25f);
1283 Vector3 scale(10.0f, 10.0f, 10.0f);
1284 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1286 actor.SetScale(scale.x);
1288 // flush the queue and render once
1289 application.SendNotification();
1290 application.Render();
1292 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1296 // SetScale(float scaleX, float scaleY, float scaleZ)
1297 int UtcDaliActorSetScale02(void)
1299 TestApplication application;
1300 Vector3 scale(10.0f, 10.0f, 10.0f);
1302 Actor actor = Actor::New();
1304 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1305 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1307 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1309 actor.SetScale(scale.x, scale.y, scale.z);
1310 // flush the queue and render once
1311 application.SendNotification();
1312 application.Render();
1313 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1315 // add to stage and test
1316 Stage::GetCurrent().Add( actor );
1317 actor.SetScale( 2.0f, 2.0f, 2.0f );
1318 // flush the queue and render once
1319 application.SendNotification();
1320 application.Render();
1321 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1323 Stage::GetCurrent().Remove( actor );
1328 // SetScale(Vector3 scale)
1329 int UtcDaliActorSetScale03(void)
1331 TestApplication application;
1332 Vector3 scale(10.0f, 10.0f, 10.0f);
1334 Actor actor = Actor::New();
1336 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1337 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1339 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1341 actor.SetScale(scale);
1343 // flush the queue and render once
1344 application.SendNotification();
1345 application.Render();
1347 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1351 int UtcDaliActorScaleBy(void)
1353 TestApplication application;
1354 Actor actor = Actor::New();
1355 Vector3 vector(100.0f, 100.0f, 100.0f);
1357 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1359 actor.SetScale(vector);
1361 // flush the queue and render once
1362 application.SendNotification();
1363 application.Render();
1365 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1367 actor.ScaleBy(vector);
1369 // flush the queue and render once
1370 application.SendNotification();
1371 application.Render();
1373 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1377 int UtcDaliActorGetCurrentScale(void)
1379 TestApplication application;
1380 Vector3 scale(12.0f, 1.0f, 2.0f);
1382 Actor actor = Actor::New();
1384 actor.SetScale(scale);
1386 // flush the queue and render once
1387 application.SendNotification();
1388 application.Render();
1390 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1394 int UtcDaliActorGetCurrentWorldScale(void)
1396 TestApplication application;
1398 Actor parent = Actor::New();
1399 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1400 parent.SetScale( parentScale );
1401 Stage::GetCurrent().Add( parent );
1403 Actor child = Actor::New();
1404 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1405 child.SetScale( childScale );
1406 parent.Add( child );
1408 // The actors should not have a scale yet
1409 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1410 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1412 // The actors should not have a world scale yet
1413 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1414 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1416 application.SendNotification();
1417 application.Render(0);
1419 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1420 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1422 // The actors should have a world scale now
1423 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1424 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1428 int UtcDaliActorInheritScale(void)
1430 tet_infoline("Testing Actor::SetInheritScale");
1431 TestApplication application;
1433 Actor parent = Actor::New();
1434 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1435 parent.SetScale( parentScale );
1436 Stage::GetCurrent().Add( parent );
1438 Actor child = Actor::New();
1439 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1440 child.SetScale( childScale );
1441 parent.Add( child );
1443 application.SendNotification();
1444 application.Render(0);
1446 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1447 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1449 child.SetInheritScale( false );
1450 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1452 application.SendNotification();
1453 application.Render(0);
1455 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1459 int UtcDaliActorSetVisible(void)
1461 TestApplication application;
1463 Actor actor = Actor::New();
1464 actor.SetVisible(false);
1465 // flush the queue and render once
1466 application.SendNotification();
1467 application.Render();
1468 DALI_TEST_CHECK(actor.IsVisible() == false);
1470 actor.SetVisible(true);
1471 // flush the queue and render once
1472 application.SendNotification();
1473 application.Render();
1474 DALI_TEST_CHECK(actor.IsVisible() == true);
1476 // put actor on stage
1477 Stage::GetCurrent().Add( actor );
1478 actor.SetVisible(false);
1479 // flush the queue and render once
1480 application.SendNotification();
1481 application.Render();
1482 DALI_TEST_CHECK(actor.IsVisible() == false);
1486 int UtcDaliActorIsVisible(void)
1488 TestApplication application;
1490 Actor actor = Actor::New();
1492 DALI_TEST_CHECK(actor.IsVisible() == true);
1496 int UtcDaliActorSetOpacity(void)
1498 TestApplication application;
1500 Actor actor = Actor::New();
1501 // initial opacity is 1
1502 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1504 actor.SetOpacity( 0.4f);
1505 // flush the queue and render once
1506 application.SendNotification();
1507 application.Render();
1508 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1510 // change opacity, actor is on stage to change is not immediate
1511 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1512 // flush the queue and render once
1513 application.SendNotification();
1514 application.Render();
1515 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1517 // put actor on stage
1518 Stage::GetCurrent().Add( actor );
1520 // change opacity, actor is on stage to change is not immediate
1521 actor.SetOpacity( 0.9f );
1522 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1523 // flush the queue and render once
1524 application.SendNotification();
1525 application.Render();
1526 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1528 // change opacity, actor is on stage to change is not immediate
1529 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1530 // flush the queue and render once
1531 application.SendNotification();
1532 application.Render();
1533 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1537 int UtcDaliActorGetCurrentOpacity(void)
1539 TestApplication application;
1541 Actor actor = Actor::New();
1542 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1544 actor.SetOpacity(0.5f);
1545 // flush the queue and render once
1546 application.SendNotification();
1547 application.Render();
1548 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1552 int UtcDaliActorSetSensitive(void)
1554 TestApplication application;
1555 Actor actor = Actor::New();
1557 bool sensitive = !actor.IsSensitive();
1559 actor.SetSensitive(sensitive);
1561 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1565 int UtcDaliActorIsSensitive(void)
1567 TestApplication application;
1568 Actor actor = Actor::New();
1569 actor.SetSensitive(false);
1571 DALI_TEST_CHECK(false == actor.IsSensitive());
1575 int UtcDaliActorSetColor(void)
1577 TestApplication application;
1578 Actor actor = Actor::New();
1579 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1581 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1583 actor.SetColor(color);
1584 // flush the queue and render once
1585 application.SendNotification();
1586 application.Render();
1587 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1589 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1590 // flush the queue and render once
1591 application.SendNotification();
1592 application.Render();
1593 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1595 Stage::GetCurrent().Add( actor );
1596 actor.SetColor( color );
1597 // flush the queue and render once
1598 application.SendNotification();
1599 application.Render();
1600 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1602 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1603 // flush the queue and render once
1604 application.SendNotification();
1605 application.Render();
1606 // Actor color is not clamped
1607 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1608 // world color is clamped
1609 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1611 Stage::GetCurrent().Remove( actor );
1615 int UtcDaliActorGetCurrentColor(void)
1617 TestApplication application;
1618 Actor actor = Actor::New();
1619 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1621 actor.SetColor(color);
1622 // flush the queue and render once
1623 application.SendNotification();
1624 application.Render();
1625 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1629 int UtcDaliActorGetCurrentWorldColor(void)
1631 tet_infoline("Actor::GetCurrentWorldColor");
1632 TestApplication application;
1634 Actor parent = Actor::New();
1635 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1636 parent.SetColor( parentColor );
1637 Stage::GetCurrent().Add( parent );
1639 Actor child = Actor::New();
1640 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1641 child.SetColor( childColor );
1642 parent.Add( child );
1644 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1645 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1647 // verify the default color mode
1648 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1650 // The actors should not have a world color yet
1651 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1652 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1654 application.SendNotification();
1655 application.Render(0);
1657 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1658 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1660 // The actors should have a world color now
1661 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1662 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1665 child.SetColorMode( USE_OWN_COLOR );
1666 application.SendNotification();
1667 application.Render(0);
1668 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1671 child.SetColorMode( USE_PARENT_COLOR );
1672 application.SendNotification();
1673 application.Render(0);
1674 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1675 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1678 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1679 application.SendNotification();
1680 application.Render(0);
1681 Vector4 expectedColor( childColor );
1682 expectedColor.a *= parentColor.a;
1683 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1684 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1688 int UtcDaliActorSetColorMode(void)
1690 tet_infoline("Actor::SetColorMode");
1691 TestApplication application;
1692 Actor actor = Actor::New();
1693 Actor child = Actor::New();
1696 actor.SetColorMode( USE_OWN_COLOR );
1697 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1699 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1700 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1702 actor.SetColorMode( USE_PARENT_COLOR );
1703 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1705 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1706 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1710 int UtcDaliActorScreenToLocal(void)
1712 TestApplication application;
1713 Actor actor = Actor::New();
1714 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1715 actor.SetSize(100.0f, 100.0f);
1716 actor.SetPosition(10.0f, 10.0f);
1717 Stage::GetCurrent().Add(actor);
1719 // flush the queue and render once
1720 application.SendNotification();
1721 application.Render();
1726 application.SendNotification();
1727 application.Render();
1729 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1731 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1732 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1736 int UtcDaliActorSetLeaveRequired(void)
1738 TestApplication application;
1740 Actor actor = Actor::New();
1742 actor.SetLeaveRequired(false);
1743 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1745 actor.SetLeaveRequired(true);
1746 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1750 int UtcDaliActorGetLeaveRequired(void)
1752 TestApplication application;
1754 Actor actor = Actor::New();
1756 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1760 int UtcDaliActorSetKeyboardFocusable(void)
1762 TestApplication application;
1764 Actor actor = Actor::New();
1766 actor.SetKeyboardFocusable(true);
1767 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1769 actor.SetKeyboardFocusable(false);
1770 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1774 int UtcDaliActorIsKeyboardFocusable(void)
1776 TestApplication application;
1778 Actor actor = Actor::New();
1780 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1784 int UtcDaliActorRemoveConstraints(void)
1786 tet_infoline(" UtcDaliActorRemoveConstraints");
1787 TestApplication application;
1789 gTestConstraintCalled = false;
1791 Actor actor = Actor::New();
1793 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1795 actor.RemoveConstraints();
1797 DALI_TEST_CHECK( gTestConstraintCalled == false );
1799 Stage::GetCurrent().Add( actor );
1802 // flush the queue and render once
1803 application.SendNotification();
1804 application.Render();
1806 actor.RemoveConstraints();
1808 DALI_TEST_CHECK( gTestConstraintCalled == true );
1812 int UtcDaliActorRemoveConstraintTag(void)
1814 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1815 TestApplication application;
1817 Actor actor = Actor::New();
1819 // 1. Apply Constraint1 and Constraint2, and test...
1820 unsigned int result1 = 0u;
1821 unsigned int result2 = 0u;
1823 unsigned constraint1Tag = 1u;
1824 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1825 constraint1.SetTag( constraint1Tag );
1826 constraint1.Apply();
1828 unsigned constraint2Tag = 2u;
1829 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1830 constraint2.SetTag( constraint2Tag );
1831 constraint2.Apply();
1833 Stage::GetCurrent().Add( actor );
1834 // flush the queue and render once
1835 application.SendNotification();
1836 application.Render();
1838 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1839 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1841 // 2. Remove Constraint1 and test...
1844 actor.RemoveConstraints(constraint1Tag);
1845 // make color property dirty, which will trigger constraints to be reapplied.
1846 actor.SetColor( Color::WHITE );
1847 // flush the queue and render once
1848 application.SendNotification();
1849 application.Render();
1851 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1852 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1854 // 3. Re-Apply Constraint1 and test...
1857 constraint1.Apply();
1858 // make color property dirty, which will trigger constraints to be reapplied.
1859 actor.SetColor( Color::WHITE );
1860 // flush the queue and render once
1861 application.SendNotification();
1862 application.Render();
1864 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1865 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1867 // 2. Remove Constraint2 and test...
1870 actor.RemoveConstraints(constraint2Tag);
1871 // make color property dirty, which will trigger constraints to be reapplied.
1872 actor.SetColor( Color::WHITE );
1873 // flush the queue and render once
1874 application.SendNotification();
1875 application.Render();
1877 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1878 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1880 // 2. Remove Constraint1 as well and test...
1883 actor.RemoveConstraints(constraint1Tag);
1884 // make color property dirty, which will trigger constraints to be reapplied.
1885 actor.SetColor( Color::WHITE );
1886 // flush the queue and render once
1887 application.SendNotification();
1888 application.Render();
1890 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1891 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1895 int UtcDaliActorTouchedSignal(void)
1897 TestApplication application;
1899 gTouchCallBackCalled = false;
1901 // get the root layer
1902 Actor actor = Stage::GetCurrent().GetRootLayer();
1903 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1905 application.SendNotification();
1906 application.Render();
1908 // connect to its touch signal
1909 actor.TouchedSignal().Connect( TestCallback );
1911 // simulate a touch event in the middle of the screen
1912 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1913 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
1914 Dali::Integration::TouchEvent event;
1915 event.AddPoint( point );
1916 application.ProcessEvent( event );
1918 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1922 int UtcDaliActorHoveredSignal(void)
1924 TestApplication application;
1926 gHoverCallBackCalled = false;
1928 // get the root layer
1929 Actor actor = Stage::GetCurrent().GetRootLayer();
1930 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1932 application.SendNotification();
1933 application.Render();
1935 // connect to its hover signal
1936 actor.HoveredSignal().Connect( TestCallback3 );
1938 // simulate a hover event in the middle of the screen
1939 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1940 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
1941 Dali::Integration::HoverEvent event;
1942 event.AddPoint( point );
1943 application.ProcessEvent( event );
1945 DALI_TEST_CHECK( gHoverCallBackCalled == true );
1949 int UtcDaliActorOnOffStageSignal(void)
1951 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
1953 TestApplication application;
1956 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1957 gActorNamesOnOffStage.clear();
1959 Actor parent = Actor::New();
1960 parent.SetName( "parent" );
1961 parent.OnStageSignal().Connect( OnStageCallback );
1962 parent.OffStageSignal().Connect( OffStageCallback );
1964 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
1965 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
1967 // add parent to stage
1968 Stage::GetCurrent().Add( parent );
1969 // onstage emitted, offstage not
1970 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
1971 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
1972 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
1974 // test adding a child, should get onstage emitted
1976 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1977 gActorNamesOnOffStage.clear();
1979 Actor child = Actor::New();
1980 child.SetName( "child" );
1981 child.OnStageSignal().Connect( OnStageCallback );
1982 child.OffStageSignal().Connect( OffStageCallback );
1983 parent.Add( child ); // add child
1984 // onstage emitted, offstage not
1985 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
1986 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
1987 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
1989 // test removing parent from stage
1991 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1992 gActorNamesOnOffStage.clear();
1994 Stage::GetCurrent().Remove( parent );
1995 // onstage not emitted, offstage is
1996 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
1997 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
1998 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
1999 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2001 // test adding parent back to stage
2003 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2004 gActorNamesOnOffStage.clear();
2006 Stage::GetCurrent().Add( parent );
2007 // onstage emitted, offstage not
2008 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2009 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2010 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2011 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2013 // test removing child
2015 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2016 gActorNamesOnOffStage.clear();
2018 parent.Remove( child );
2019 // onstage not emitted, offstage is
2020 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2021 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2022 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2024 // test removing parent
2026 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2027 gActorNamesOnOffStage.clear();
2029 Stage::GetCurrent().Remove( parent );
2030 // onstage not emitted, offstage is
2031 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2032 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2033 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2037 int UtcDaliActorFindChildByName(void)
2039 tet_infoline("Testing Dali::Actor::FindChildByName()");
2040 TestApplication application;
2042 Actor parent = Actor::New();
2043 parent.SetName( "parent" );
2044 Actor first = Actor::New();
2045 first .SetName( "first" );
2046 Actor second = Actor::New();
2047 second.SetName( "second" );
2052 Actor found = parent.FindChildByName( "foo" );
2053 DALI_TEST_CHECK( !found );
2055 found = parent.FindChildByName( "parent" );
2056 DALI_TEST_CHECK( found == parent );
2058 found = parent.FindChildByName( "first" );
2059 DALI_TEST_CHECK( found == first );
2061 found = parent.FindChildByName( "second" );
2062 DALI_TEST_CHECK( found == second );
2066 int UtcDaliActorFindChildById(void)
2068 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2069 TestApplication application;
2071 Actor parent = Actor::New();
2072 Actor first = Actor::New();
2073 Actor second = Actor::New();
2078 Actor found = parent.FindChildById( 100000 );
2079 DALI_TEST_CHECK( !found );
2081 found = parent.FindChildById( parent.GetId() );
2082 DALI_TEST_CHECK( found == parent );
2084 found = parent.FindChildById( first.GetId() );
2085 DALI_TEST_CHECK( found == first );
2087 found = parent.FindChildById( second.GetId() );
2088 DALI_TEST_CHECK( found == second );
2092 int UtcDaliActorHitTest(void)
2097 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2099 mTouchPoint( touchPoint ),
2104 Vector2 mTouchPoint;
2108 TestApplication application;
2109 tet_infoline(" UtcDaliActorHitTest");
2111 // Fill a vector with different hit tests.
2112 struct HitTestData* hitTestData[] = {
2113 // scale touch point result
2114 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2115 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2116 new HitTestData( Vector3( 110.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), true ), // same point as above with a wider scale. Should be inside.
2117 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2118 new HitTestData( Vector3( 100.f, 110.f, 1.f ), Vector2( 200.f, 451.f ), true ), // same point as above with a wider scale. Should be inside.
2122 // get the root layer
2123 Actor actor = Actor::New();
2124 actor.SetAnchorPoint( AnchorPoint::CENTER );
2125 actor.SetParentOrigin( ParentOrigin::CENTER );
2127 Stage::GetCurrent().Add( actor );
2129 gTouchCallBackCalled = false;
2131 unsigned int index = 0;
2132 while( NULL != hitTestData[index] )
2134 actor.SetSize( 1.f, 1.f );
2135 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2137 // flush the queue and render once
2138 application.SendNotification();
2139 application.Render();
2141 DALI_TEST_CHECK( !gTouchCallBackCalled );
2143 // connect to its touch signal
2144 actor.TouchedSignal().Connect(TestCallback);
2146 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2147 Dali::Integration::TouchEvent event;
2148 event.AddPoint( point );
2150 // flush the queue and render once
2151 application.SendNotification();
2152 application.Render();
2153 application.ProcessEvent( event );
2155 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2157 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2158 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2159 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2160 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2161 hitTestData[index]->mResult );
2163 gTouchCallBackCalled = false;
2169 int UtcDaliActorSetDrawMode(void)
2171 TestApplication app;
2172 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2174 Actor a = Actor::New();
2176 Stage::GetCurrent().Add(a);
2177 app.SendNotification();
2179 app.SendNotification();
2182 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2184 a.SetDrawMode( DrawMode::OVERLAY_2D );
2185 app.SendNotification();
2188 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2190 a.SetDrawMode( DrawMode::STENCIL );
2191 app.SendNotification();
2194 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2196 a.SetDrawMode( DrawMode::NORMAL );
2197 app.SendNotification();
2200 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2204 int UtcDaliActorSetDrawModeOverlayRender(void)
2206 TestApplication app;
2207 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2209 app.SendNotification();
2212 std::vector<GLuint> ids;
2213 ids.push_back( 8 ); // first rendered actor
2214 ids.push_back( 9 ); // second rendered actor
2215 ids.push_back( 10 ); // third rendered actor
2216 app.GetGlAbstraction().SetNextTextureIds( ids );
2218 BufferImage imageA = BufferImage::New(16, 16);
2219 BufferImage imageB = BufferImage::New(16, 16);
2220 BufferImage imageC = BufferImage::New(16, 16);
2221 ImageActor a = ImageActor::New( imageA );
2222 ImageActor b = ImageActor::New( imageB );
2223 ImageActor c = ImageActor::New( imageC );
2225 // Render a,b,c as regular non-overlays. so order will be:
2229 Stage::GetCurrent().Add(a);
2230 Stage::GetCurrent().Add(b);
2231 Stage::GetCurrent().Add(c);
2233 app.SendNotification();
2236 // Should be 3 textures changes.
2237 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2238 typedef std::vector<GLuint>::size_type TextureSize;
2239 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2240 if( boundTextures.size() == 3 )
2242 DALI_TEST_CHECK( boundTextures[0] == 8u );
2243 DALI_TEST_CHECK( boundTextures[1] == 9u );
2244 DALI_TEST_CHECK( boundTextures[2] == 10u );
2247 // Now texture ids have been set, we can monitor their render order.
2248 // render a as an overlay (last), so order will be:
2252 a.SetDrawMode( DrawMode::OVERLAY_2D );
2253 app.GetGlAbstraction().ClearBoundTextures();
2255 app.SendNotification();
2258 // Should be 3 texture changes.
2259 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2260 if( boundTextures.size() == 3 )
2262 DALI_TEST_CHECK( boundTextures[0] == 9u );
2263 DALI_TEST_CHECK( boundTextures[1] == 10u );
2264 DALI_TEST_CHECK( boundTextures[2] == 8u );
2269 int UtcDaliActorGetCurrentWorldMatrix(void)
2271 TestApplication app;
2272 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2274 Actor parent = Actor::New();
2275 parent.SetParentOrigin(ParentOrigin::CENTER);
2276 parent.SetAnchorPoint(AnchorPoint::CENTER);
2277 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2278 Radian rotationAngle(Degree(85.0f));
2279 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2280 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2281 parent.SetPosition( parentPosition );
2282 parent.SetOrientation( parentRotation );
2283 parent.SetScale( parentScale );
2284 Stage::GetCurrent().Add( parent );
2286 Actor child = Actor::New();
2287 child.SetParentOrigin(ParentOrigin::CENTER);
2288 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2289 Radian childRotationAngle(Degree(23.0f));
2290 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2291 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2292 child.SetPosition( childPosition );
2293 child.SetOrientation( childRotation );
2294 child.SetScale( childScale );
2295 parent.Add( child );
2297 app.SendNotification();
2300 app.SendNotification();
2302 Matrix parentMatrix(false);
2303 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2305 Matrix childMatrix(false);
2306 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2308 //Child matrix should be the composition of child and parent
2309 Matrix childWorldMatrix(false);
2310 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2312 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2313 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2319 int UtcDaliActorConstrainedToWorldMatrix(void)
2321 TestApplication app;
2322 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2324 Actor parent = Actor::New();
2325 parent.SetParentOrigin(ParentOrigin::CENTER);
2326 parent.SetAnchorPoint(AnchorPoint::CENTER);
2327 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2328 Radian rotationAngle(Degree(85.0f));
2329 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2330 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2331 parent.SetPosition( parentPosition );
2332 parent.SetOrientation( parentRotation );
2333 parent.SetScale( parentScale );
2334 Stage::GetCurrent().Add( parent );
2336 Actor child = Actor::New();
2337 child.SetParentOrigin(ParentOrigin::CENTER);
2338 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2339 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2340 posConstraint.Apply();
2342 Stage::GetCurrent().Add( child );
2344 app.SendNotification();
2347 app.SendNotification();
2349 Matrix parentMatrix(false);
2350 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2352 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2353 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2357 int UtcDaliActorConstrainedToOrientation(void)
2359 TestApplication app;
2360 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2362 Actor parent = Actor::New();
2363 parent.SetParentOrigin(ParentOrigin::CENTER);
2364 parent.SetAnchorPoint(AnchorPoint::CENTER);
2365 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2366 Radian rotationAngle(Degree(85.0f));
2367 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2368 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2369 parent.SetPosition( parentPosition );
2370 parent.SetOrientation( parentRotation );
2371 parent.SetScale( parentScale );
2372 Stage::GetCurrent().Add( parent );
2374 Actor child = Actor::New();
2375 child.SetParentOrigin(ParentOrigin::CENTER);
2376 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2377 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2378 posConstraint.Apply();
2380 Stage::GetCurrent().Add( child );
2382 app.SendNotification();
2385 app.SendNotification();
2387 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2391 int UtcDaliActorUnparent(void)
2393 TestApplication app;
2394 tet_infoline(" UtcDaliActorUnparent");
2396 Actor parent = Actor::New();
2397 Stage::GetCurrent().Add( parent );
2399 Actor child = Actor::New();
2401 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2402 DALI_TEST_CHECK( !child.GetParent() );
2404 // Test that calling Unparent with no parent is a NOOP
2407 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2408 DALI_TEST_CHECK( !child.GetParent() );
2410 // Test that Unparent works
2411 parent.Add( child );
2413 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2414 DALI_TEST_CHECK( parent == child.GetParent() );
2418 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2419 DALI_TEST_CHECK( !child.GetParent() );
2421 // Test that UnparentAndReset works
2422 parent.Add( child );
2424 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2425 DALI_TEST_CHECK( parent == child.GetParent() );
2427 UnparentAndReset( child );
2429 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2430 DALI_TEST_CHECK( !child );
2432 // Test that UnparentAndReset is a NOOP with empty handle
2433 UnparentAndReset( child );
2435 DALI_TEST_CHECK( !child );
2439 int UtcDaliActorGetChildAt(void)
2441 TestApplication app;
2442 tet_infoline(" UtcDaliActorGetChildAt");
2444 Actor parent = Actor::New();
2445 Stage::GetCurrent().Add( parent );
2447 Actor child0 = Actor::New();
2448 parent.Add( child0 );
2450 Actor child1 = Actor::New();
2451 parent.Add( child1 );
2453 Actor child2 = Actor::New();
2454 parent.Add( child2 );
2456 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2457 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2458 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2462 int UtcDaliActorSetGetOverlay(void)
2464 TestApplication app;
2465 tet_infoline(" UtcDaliActorSetGetOverlay");
2467 Actor parent = Actor::New();
2468 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2469 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2474 int UtcDaliActorCreateDestroy(void)
2476 Actor* actor = new Actor;
2477 DALI_TEST_CHECK( actor );
2484 struct PropertyStringIndex
2486 const char * const name;
2487 const Property::Index index;
2488 const Property::Type type;
2491 const PropertyStringIndex PROPERTY_TABLE[] =
2493 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2494 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2495 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2496 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2497 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2498 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2499 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2500 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2501 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2502 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2503 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2504 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2505 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2506 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2507 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2508 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2509 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2510 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2511 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2512 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2513 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2514 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2515 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2516 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2517 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2518 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2519 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2520 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2521 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2522 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2523 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2524 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2525 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2526 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2527 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2528 { "name", Actor::Property::NAME, Property::STRING },
2529 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2530 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2531 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2532 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2533 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2534 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2535 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
2536 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2537 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2538 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2539 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2540 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2541 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2542 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2543 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2544 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2546 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2547 } // unnamed namespace
2549 int UtcDaliActorProperties(void)
2551 TestApplication app;
2553 Actor actor = Actor::New();
2555 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2557 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2558 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2559 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2560 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2565 int UtcDaliRelayoutProperties_ResizePolicies(void)
2567 TestApplication app;
2569 Actor actor = Actor::New();
2572 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2573 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2575 // Set resize policy for all dimensions
2576 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2577 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2579 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2582 // Set individual dimensions
2583 const char* const widthPolicy = "FILL_TO_PARENT";
2584 const char* const heightPolicy = "FIXED";
2586 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2587 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2589 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2590 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2595 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2597 TestApplication app;
2599 Actor actor = Actor::New();
2602 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2603 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2605 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2606 actor.SetSizeScalePolicy( policy );
2607 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2610 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2611 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2613 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2614 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2616 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2617 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2622 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2624 TestApplication app;
2626 Actor actor = Actor::New();
2629 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2630 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2632 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2633 actor.SetSizeModeFactor( sizeMode );
2634 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2637 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2639 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2640 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2645 int UtcDaliRelayoutProperties_DimensionDependency(void)
2647 TestApplication app;
2649 Actor actor = Actor::New();
2652 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2653 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2656 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2657 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2659 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2660 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2662 // Test setting another resize policy
2663 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2664 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2669 int UtcDaliRelayoutProperties_Padding(void)
2671 TestApplication app;
2673 Actor actor = Actor::New();
2676 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2679 actor.SetProperty( Actor::Property::PADDING, padding );
2680 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2682 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2687 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2689 TestApplication app;
2691 Actor actor = Actor::New();
2694 Vector2 minSize( 1.0f, 2.0f );
2696 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2697 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2699 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2701 Vector2 maxSize( 3.0f, 4.0f );
2703 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2704 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2706 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2711 int UtcDaliActorGetHeightForWidth(void)
2713 TestApplication app;
2715 Actor actor = Actor::New();
2717 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
2722 int UtcDaliActorGetWidthForHeight(void)
2724 TestApplication app;
2726 Actor actor = Actor::New();
2728 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
2733 int UtcDaliActorGetRelayoutSize(void)
2735 TestApplication app;
2737 Actor actor = Actor::New();
2739 // Add actor to stage
2740 Stage::GetCurrent().Add( actor );
2742 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
2744 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
2745 actor.SetSize( Vector2( 1.0f, 0.0f ) );
2747 // Flush the queue and render once
2748 app.SendNotification();
2751 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
2756 int UtcDaliActorSetPadding(void)
2758 TestApplication app;
2760 Actor actor = Actor::New();
2763 actor.GetPadding( padding );
2765 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
2766 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
2767 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
2768 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
2770 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
2771 actor.SetPadding( padding2 );
2773 actor.GetPadding( padding );
2775 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
2776 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
2777 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
2778 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
2783 int UtcDaliActorSetMinimumSize(void)
2785 TestApplication app;
2787 Actor actor = Actor::New();
2789 Vector2 size = actor.GetMinimumSize();
2791 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
2792 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
2794 Vector2 size2( 1.0f, 2.0f );
2795 actor.SetMinimumSize( size2 );
2797 size = actor.GetMinimumSize();
2799 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2800 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2805 int UtcDaliActorSetMaximumSize(void)
2807 TestApplication app;
2809 Actor actor = Actor::New();
2811 Vector2 size = actor.GetMaximumSize();
2813 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
2814 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
2816 Vector2 size2( 1.0f, 2.0f );
2817 actor.SetMaximumSize( size2 );
2819 size = actor.GetMaximumSize();
2821 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2822 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2827 int UtcDaliActorOnRelayoutSignal(void)
2829 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
2831 TestApplication application;
2834 gOnRelayoutCallBackCalled = false;
2835 gActorNamesRelayout.clear();
2837 Actor actor = Actor::New();
2838 actor.SetName( "actor" );
2839 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
2842 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
2844 // Add actor to stage
2845 Stage::GetCurrent().Add( actor );
2847 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2848 actor.SetSize( Vector2( 1.0f, 2.0 ) );
2850 // Flush the queue and render once
2851 application.SendNotification();
2852 application.Render();
2854 // OnRelayout emitted
2855 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
2856 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
2861 int UtcDaliActorGetHierachyDepth(void)
2863 TestApplication application;
2864 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
2867 /* Build tree of actors:
2877 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
2879 Stage stage( Stage::GetCurrent() );
2881 Actor actorA = Actor::New();
2882 Actor actorB = Actor::New();
2883 Actor actorC = Actor::New();
2884 Actor actorD = Actor::New();
2885 Actor actorE = Actor::New();
2886 Actor actorF = Actor::New();
2888 //Test that root actor has depth equal 0
2889 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
2891 //Test actors return depth -1 when not connected to the tree
2892 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2893 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2894 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
2895 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2896 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2897 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
2899 //Create the hierarchy
2900 stage.Add( actorA );
2901 actorA.Add( actorB );
2902 actorA.Add( actorC );
2903 actorB.Add( actorD );
2904 actorB.Add( actorE );
2905 actorC.Add( actorF );
2907 //Test actors return correct depth
2908 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2909 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
2910 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
2911 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
2912 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
2913 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
2915 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
2916 actorA.Remove( actorB );
2918 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2919 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2920 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2922 //Removing actorA from the stage. All actors should have depth equal -1
2923 stage.Remove( actorA );
2925 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2926 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2927 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
2928 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2929 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2930 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );