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 int UtcDaliActorSetInheritPosition(void)
1116 tet_infoline("Testing Actor::SetInheritPosition");
1117 TestApplication application;
1119 Actor parent = Actor::New();
1120 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1121 parent.SetPosition( parentPosition );
1122 parent.SetParentOrigin( ParentOrigin::CENTER );
1123 parent.SetAnchorPoint( AnchorPoint::CENTER );
1124 Stage::GetCurrent().Add( parent );
1126 Actor child = Actor::New();
1127 child.SetParentOrigin( ParentOrigin::CENTER );
1128 child.SetAnchorPoint( AnchorPoint::CENTER );
1129 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1130 child.SetPosition( childPosition );
1131 parent.Add( child );
1133 // The actors should not have a world position yet
1134 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1135 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1137 // first test default, which is to inherit position
1138 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1139 application.SendNotification();
1140 application.Render(0); // should only really call Update as Render is not required to update scene
1141 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1142 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1143 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1144 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1146 //Change child position
1147 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1148 child.SetPosition( childOffset );
1150 // Use local position as world postion
1151 child.SetInheritPosition( false );
1152 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1153 application.SendNotification();
1154 application.Render(0); // should only really call Update as Render is not required to update scene
1155 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1156 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1157 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1158 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1160 //Change back to inherit position from parent
1161 child.SetInheritPosition( true );
1162 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1163 application.SendNotification();
1164 application.Render(0); // should only really call Update as Render is not required to update scene
1165 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1166 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1167 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1168 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1172 // SetOrientation(float angleRadians, Vector3 axis)
1173 int UtcDaliActorSetOrientation01(void)
1175 TestApplication application;
1177 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1178 Actor actor = Actor::New();
1180 actor.SetOrientation(rotation);
1182 // flush the queue and render once
1183 application.SendNotification();
1184 application.Render();
1186 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1190 int UtcDaliActorSetOrientation02(void)
1192 TestApplication application;
1194 Actor actor = Actor::New();
1196 Radian angle( 0.785f );
1197 Vector3 axis(1.0f, 1.0f, 0.0f);
1199 actor.SetOrientation( angle, axis);
1200 Quaternion rotation( angle, axis );
1201 // flush the queue and render once
1202 application.SendNotification();
1203 application.Render();
1204 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1206 Stage::GetCurrent().Add( actor );
1207 actor.RotateBy( Degree( 360 ), axis);
1208 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1210 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1211 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1212 // flush the queue and render once
1213 application.SendNotification();
1214 application.Render();
1215 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1217 actor.SetOrientation( angle, axis);
1218 // flush the queue and render once
1219 application.SendNotification();
1220 application.Render();
1221 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1223 Stage::GetCurrent().Remove( actor );
1227 // RotateBy(float angleRadians, Vector3 axis)
1228 int UtcDaliActorRotateBy01(void)
1230 TestApplication application;
1232 Actor actor = Actor::New();
1234 Radian angle( M_PI * 0.25f );
1235 actor.RotateBy(( angle ), Vector3::ZAXIS);
1236 // flush the queue and render once
1237 application.SendNotification();
1238 application.Render();
1239 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1241 Stage::GetCurrent().Add( actor );
1243 actor.RotateBy( angle, Vector3::ZAXIS);
1244 // flush the queue and render once
1245 application.SendNotification();
1246 application.Render();
1247 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1249 Stage::GetCurrent().Remove( actor );
1253 // RotateBy(Quaternion relativeRotation)
1254 int UtcDaliActorRotateBy02(void)
1256 TestApplication application;
1258 Actor actor = Actor::New();
1260 Radian angle( M_PI * 0.25f );
1261 Quaternion rotation(angle, Vector3::ZAXIS);
1262 actor.RotateBy(rotation);
1263 // flush the queue and render once
1264 application.SendNotification();
1265 application.Render();
1266 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1268 actor.RotateBy(rotation);
1269 // flush the queue and render once
1270 application.SendNotification();
1271 application.Render();
1272 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1276 int UtcDaliActorGetCurrentOrientation(void)
1278 TestApplication application;
1279 Actor actor = Actor::New();
1281 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1282 actor.SetOrientation(rotation);
1283 // flush the queue and render once
1284 application.SendNotification();
1285 application.Render();
1286 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1290 int UtcDaliActorGetCurrentWorldOrientation(void)
1292 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1293 TestApplication application;
1295 Actor parent = Actor::New();
1296 Radian rotationAngle( Degree(90.0f) );
1297 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1298 parent.SetOrientation( rotation );
1299 Stage::GetCurrent().Add( parent );
1301 Actor child = Actor::New();
1302 child.SetOrientation( rotation );
1303 parent.Add( child );
1305 // The actors should not have a world rotation yet
1306 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1307 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1309 application.SendNotification();
1310 application.Render(0);
1312 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1313 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1315 // The actors should have a world rotation now
1316 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1317 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1319 // turn off child rotation inheritance
1320 child.SetInheritOrientation( false );
1321 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1322 application.SendNotification();
1323 application.Render(0);
1325 // The actors should have a world rotation now
1326 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1327 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1331 // SetScale(float scale)
1332 int UtcDaliActorSetScale01(void)
1334 TestApplication application;
1336 Actor actor = Actor::New();
1338 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1339 actor.SetScale(0.25f);
1341 Vector3 scale(10.0f, 10.0f, 10.0f);
1342 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1344 actor.SetScale(scale.x);
1346 // flush the queue and render once
1347 application.SendNotification();
1348 application.Render();
1350 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1354 // SetScale(float scaleX, float scaleY, float scaleZ)
1355 int UtcDaliActorSetScale02(void)
1357 TestApplication application;
1358 Vector3 scale(10.0f, 10.0f, 10.0f);
1360 Actor actor = Actor::New();
1362 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1363 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1365 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1367 actor.SetScale(scale.x, scale.y, scale.z);
1368 // flush the queue and render once
1369 application.SendNotification();
1370 application.Render();
1371 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1373 // add to stage and test
1374 Stage::GetCurrent().Add( actor );
1375 actor.SetScale( 2.0f, 2.0f, 2.0f );
1376 // flush the queue and render once
1377 application.SendNotification();
1378 application.Render();
1379 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1381 Stage::GetCurrent().Remove( actor );
1386 // SetScale(Vector3 scale)
1387 int UtcDaliActorSetScale03(void)
1389 TestApplication application;
1390 Vector3 scale(10.0f, 10.0f, 10.0f);
1392 Actor actor = Actor::New();
1394 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1395 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1397 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1399 actor.SetScale(scale);
1401 // flush the queue and render once
1402 application.SendNotification();
1403 application.Render();
1405 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1409 int UtcDaliActorScaleBy(void)
1411 TestApplication application;
1412 Actor actor = Actor::New();
1413 Vector3 vector(100.0f, 100.0f, 100.0f);
1415 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1417 actor.SetScale(vector);
1419 // flush the queue and render once
1420 application.SendNotification();
1421 application.Render();
1423 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1425 actor.ScaleBy(vector);
1427 // flush the queue and render once
1428 application.SendNotification();
1429 application.Render();
1431 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1435 int UtcDaliActorGetCurrentScale(void)
1437 TestApplication application;
1438 Vector3 scale(12.0f, 1.0f, 2.0f);
1440 Actor actor = Actor::New();
1442 actor.SetScale(scale);
1444 // flush the queue and render once
1445 application.SendNotification();
1446 application.Render();
1448 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1452 int UtcDaliActorGetCurrentWorldScale(void)
1454 TestApplication application;
1456 Actor parent = Actor::New();
1457 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1458 parent.SetScale( parentScale );
1459 Stage::GetCurrent().Add( parent );
1461 Actor child = Actor::New();
1462 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1463 child.SetScale( childScale );
1464 parent.Add( child );
1466 // The actors should not have a scale yet
1467 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1468 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1470 // The actors should not have a world scale yet
1471 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1472 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1474 application.SendNotification();
1475 application.Render(0);
1477 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1478 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1480 // The actors should have a world scale now
1481 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1482 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1486 int UtcDaliActorInheritScale(void)
1488 tet_infoline("Testing Actor::SetInheritScale");
1489 TestApplication application;
1491 Actor parent = Actor::New();
1492 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1493 parent.SetScale( parentScale );
1494 Stage::GetCurrent().Add( parent );
1496 Actor child = Actor::New();
1497 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1498 child.SetScale( childScale );
1499 parent.Add( child );
1501 application.SendNotification();
1502 application.Render(0);
1504 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1505 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1507 child.SetInheritScale( false );
1508 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1510 application.SendNotification();
1511 application.Render(0);
1513 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1517 int UtcDaliActorSetVisible(void)
1519 TestApplication application;
1521 Actor actor = Actor::New();
1522 actor.SetVisible(false);
1523 // flush the queue and render once
1524 application.SendNotification();
1525 application.Render();
1526 DALI_TEST_CHECK(actor.IsVisible() == false);
1528 actor.SetVisible(true);
1529 // flush the queue and render once
1530 application.SendNotification();
1531 application.Render();
1532 DALI_TEST_CHECK(actor.IsVisible() == true);
1534 // put actor on stage
1535 Stage::GetCurrent().Add( actor );
1536 actor.SetVisible(false);
1537 // flush the queue and render once
1538 application.SendNotification();
1539 application.Render();
1540 DALI_TEST_CHECK(actor.IsVisible() == false);
1544 int UtcDaliActorIsVisible(void)
1546 TestApplication application;
1548 Actor actor = Actor::New();
1550 DALI_TEST_CHECK(actor.IsVisible() == true);
1554 int UtcDaliActorSetOpacity(void)
1556 TestApplication application;
1558 Actor actor = Actor::New();
1559 // initial opacity is 1
1560 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1562 actor.SetOpacity( 0.4f);
1563 // flush the queue and render once
1564 application.SendNotification();
1565 application.Render();
1566 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1568 // change opacity, actor is on stage to change is not immediate
1569 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1570 // flush the queue and render once
1571 application.SendNotification();
1572 application.Render();
1573 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1575 // put actor on stage
1576 Stage::GetCurrent().Add( actor );
1578 // change opacity, actor is on stage to change is not immediate
1579 actor.SetOpacity( 0.9f );
1580 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1581 // flush the queue and render once
1582 application.SendNotification();
1583 application.Render();
1584 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1586 // change opacity, actor is on stage to change is not immediate
1587 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1588 // flush the queue and render once
1589 application.SendNotification();
1590 application.Render();
1591 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1595 int UtcDaliActorGetCurrentOpacity(void)
1597 TestApplication application;
1599 Actor actor = Actor::New();
1600 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1602 actor.SetOpacity(0.5f);
1603 // flush the queue and render once
1604 application.SendNotification();
1605 application.Render();
1606 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1610 int UtcDaliActorSetSensitive(void)
1612 TestApplication application;
1613 Actor actor = Actor::New();
1615 bool sensitive = !actor.IsSensitive();
1617 actor.SetSensitive(sensitive);
1619 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1623 int UtcDaliActorIsSensitive(void)
1625 TestApplication application;
1626 Actor actor = Actor::New();
1627 actor.SetSensitive(false);
1629 DALI_TEST_CHECK(false == actor.IsSensitive());
1633 int UtcDaliActorSetColor(void)
1635 TestApplication application;
1636 Actor actor = Actor::New();
1637 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1639 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1641 actor.SetColor(color);
1642 // flush the queue and render once
1643 application.SendNotification();
1644 application.Render();
1645 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1647 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1648 // flush the queue and render once
1649 application.SendNotification();
1650 application.Render();
1651 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1653 Stage::GetCurrent().Add( actor );
1654 actor.SetColor( color );
1655 // flush the queue and render once
1656 application.SendNotification();
1657 application.Render();
1658 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1660 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1661 // flush the queue and render once
1662 application.SendNotification();
1663 application.Render();
1664 // Actor color is not clamped
1665 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1666 // world color is clamped
1667 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1669 Stage::GetCurrent().Remove( actor );
1673 int UtcDaliActorGetCurrentColor(void)
1675 TestApplication application;
1676 Actor actor = Actor::New();
1677 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1679 actor.SetColor(color);
1680 // flush the queue and render once
1681 application.SendNotification();
1682 application.Render();
1683 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1687 int UtcDaliActorGetCurrentWorldColor(void)
1689 tet_infoline("Actor::GetCurrentWorldColor");
1690 TestApplication application;
1692 Actor parent = Actor::New();
1693 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1694 parent.SetColor( parentColor );
1695 Stage::GetCurrent().Add( parent );
1697 Actor child = Actor::New();
1698 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1699 child.SetColor( childColor );
1700 parent.Add( child );
1702 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1703 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1705 // verify the default color mode
1706 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1708 // The actors should not have a world color yet
1709 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1710 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1712 application.SendNotification();
1713 application.Render(0);
1715 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1716 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1718 // The actors should have a world color now
1719 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1720 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1723 child.SetColorMode( USE_OWN_COLOR );
1724 application.SendNotification();
1725 application.Render(0);
1726 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1729 child.SetColorMode( USE_PARENT_COLOR );
1730 application.SendNotification();
1731 application.Render(0);
1732 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1733 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1736 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1737 application.SendNotification();
1738 application.Render(0);
1739 Vector4 expectedColor( childColor );
1740 expectedColor.a *= parentColor.a;
1741 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1742 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1746 int UtcDaliActorSetColorMode(void)
1748 tet_infoline("Actor::SetColorMode");
1749 TestApplication application;
1750 Actor actor = Actor::New();
1751 Actor child = Actor::New();
1754 actor.SetColorMode( USE_OWN_COLOR );
1755 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1757 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1758 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1760 actor.SetColorMode( USE_PARENT_COLOR );
1761 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1763 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1764 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1768 int UtcDaliActorScreenToLocal(void)
1770 TestApplication application;
1771 Actor actor = Actor::New();
1772 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1773 actor.SetSize(100.0f, 100.0f);
1774 actor.SetPosition(10.0f, 10.0f);
1775 Stage::GetCurrent().Add(actor);
1777 // flush the queue and render once
1778 application.SendNotification();
1779 application.Render();
1784 application.SendNotification();
1785 application.Render();
1787 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1789 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1790 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1794 int UtcDaliActorSetLeaveRequired(void)
1796 TestApplication application;
1798 Actor actor = Actor::New();
1800 actor.SetLeaveRequired(false);
1801 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1803 actor.SetLeaveRequired(true);
1804 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1808 int UtcDaliActorGetLeaveRequired(void)
1810 TestApplication application;
1812 Actor actor = Actor::New();
1814 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1818 int UtcDaliActorSetKeyboardFocusable(void)
1820 TestApplication application;
1822 Actor actor = Actor::New();
1824 actor.SetKeyboardFocusable(true);
1825 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1827 actor.SetKeyboardFocusable(false);
1828 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1832 int UtcDaliActorIsKeyboardFocusable(void)
1834 TestApplication application;
1836 Actor actor = Actor::New();
1838 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1842 int UtcDaliActorRemoveConstraints(void)
1844 tet_infoline(" UtcDaliActorRemoveConstraints");
1845 TestApplication application;
1847 gTestConstraintCalled = false;
1849 Actor actor = Actor::New();
1851 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1853 actor.RemoveConstraints();
1855 DALI_TEST_CHECK( gTestConstraintCalled == false );
1857 Stage::GetCurrent().Add( actor );
1860 // flush the queue and render once
1861 application.SendNotification();
1862 application.Render();
1864 actor.RemoveConstraints();
1866 DALI_TEST_CHECK( gTestConstraintCalled == true );
1870 int UtcDaliActorRemoveConstraintTag(void)
1872 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1873 TestApplication application;
1875 Actor actor = Actor::New();
1877 // 1. Apply Constraint1 and Constraint2, and test...
1878 unsigned int result1 = 0u;
1879 unsigned int result2 = 0u;
1881 unsigned constraint1Tag = 1u;
1882 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1883 constraint1.SetTag( constraint1Tag );
1884 constraint1.Apply();
1886 unsigned constraint2Tag = 2u;
1887 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1888 constraint2.SetTag( constraint2Tag );
1889 constraint2.Apply();
1891 Stage::GetCurrent().Add( actor );
1892 // flush the queue and render once
1893 application.SendNotification();
1894 application.Render();
1896 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1897 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1899 // 2. Remove Constraint1 and test...
1902 actor.RemoveConstraints(constraint1Tag);
1903 // make color property dirty, which will trigger constraints to be reapplied.
1904 actor.SetColor( Color::WHITE );
1905 // flush the queue and render once
1906 application.SendNotification();
1907 application.Render();
1909 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1910 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1912 // 3. Re-Apply Constraint1 and test...
1915 constraint1.Apply();
1916 // make color property dirty, which will trigger constraints to be reapplied.
1917 actor.SetColor( Color::WHITE );
1918 // flush the queue and render once
1919 application.SendNotification();
1920 application.Render();
1922 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1923 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1925 // 2. Remove Constraint2 and test...
1928 actor.RemoveConstraints(constraint2Tag);
1929 // make color property dirty, which will trigger constraints to be reapplied.
1930 actor.SetColor( Color::WHITE );
1931 // flush the queue and render once
1932 application.SendNotification();
1933 application.Render();
1935 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1936 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1938 // 2. Remove Constraint1 as well and test...
1941 actor.RemoveConstraints(constraint1Tag);
1942 // make color property dirty, which will trigger constraints to be reapplied.
1943 actor.SetColor( Color::WHITE );
1944 // flush the queue and render once
1945 application.SendNotification();
1946 application.Render();
1948 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1949 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1953 int UtcDaliActorTouchedSignal(void)
1955 TestApplication application;
1957 gTouchCallBackCalled = false;
1959 // get the root layer
1960 Actor actor = Stage::GetCurrent().GetRootLayer();
1961 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1963 application.SendNotification();
1964 application.Render();
1966 // connect to its touch signal
1967 actor.TouchedSignal().Connect( TestCallback );
1969 // simulate a touch event in the middle of the screen
1970 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1971 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
1972 Dali::Integration::TouchEvent event;
1973 event.AddPoint( point );
1974 application.ProcessEvent( event );
1976 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1980 int UtcDaliActorHoveredSignal(void)
1982 TestApplication application;
1984 gHoverCallBackCalled = false;
1986 // get the root layer
1987 Actor actor = Stage::GetCurrent().GetRootLayer();
1988 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1990 application.SendNotification();
1991 application.Render();
1993 // connect to its hover signal
1994 actor.HoveredSignal().Connect( TestCallback3 );
1996 // simulate a hover event in the middle of the screen
1997 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1998 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
1999 Dali::Integration::HoverEvent event;
2000 event.AddPoint( point );
2001 application.ProcessEvent( event );
2003 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2007 int UtcDaliActorOnOffStageSignal(void)
2009 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2011 TestApplication application;
2014 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2015 gActorNamesOnOffStage.clear();
2017 Actor parent = Actor::New();
2018 parent.SetName( "parent" );
2019 parent.OnStageSignal().Connect( OnStageCallback );
2020 parent.OffStageSignal().Connect( OffStageCallback );
2022 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2023 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2025 // add parent to stage
2026 Stage::GetCurrent().Add( parent );
2027 // onstage emitted, offstage not
2028 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2029 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2030 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2032 // test adding a child, should get onstage emitted
2034 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2035 gActorNamesOnOffStage.clear();
2037 Actor child = Actor::New();
2038 child.SetName( "child" );
2039 child.OnStageSignal().Connect( OnStageCallback );
2040 child.OffStageSignal().Connect( OffStageCallback );
2041 parent.Add( child ); // add child
2042 // onstage emitted, offstage not
2043 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2044 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2045 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2047 // test removing parent from stage
2049 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2050 gActorNamesOnOffStage.clear();
2052 Stage::GetCurrent().Remove( parent );
2053 // onstage not emitted, offstage is
2054 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2055 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2056 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2057 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2059 // test adding parent back to stage
2061 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2062 gActorNamesOnOffStage.clear();
2064 Stage::GetCurrent().Add( parent );
2065 // onstage emitted, offstage not
2066 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2067 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2068 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2069 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2071 // test removing child
2073 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2074 gActorNamesOnOffStage.clear();
2076 parent.Remove( child );
2077 // onstage not emitted, offstage is
2078 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2079 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2080 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2082 // test removing parent
2084 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2085 gActorNamesOnOffStage.clear();
2087 Stage::GetCurrent().Remove( parent );
2088 // onstage not emitted, offstage is
2089 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2090 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2091 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2095 int UtcDaliActorFindChildByName(void)
2097 tet_infoline("Testing Dali::Actor::FindChildByName()");
2098 TestApplication application;
2100 Actor parent = Actor::New();
2101 parent.SetName( "parent" );
2102 Actor first = Actor::New();
2103 first .SetName( "first" );
2104 Actor second = Actor::New();
2105 second.SetName( "second" );
2110 Actor found = parent.FindChildByName( "foo" );
2111 DALI_TEST_CHECK( !found );
2113 found = parent.FindChildByName( "parent" );
2114 DALI_TEST_CHECK( found == parent );
2116 found = parent.FindChildByName( "first" );
2117 DALI_TEST_CHECK( found == first );
2119 found = parent.FindChildByName( "second" );
2120 DALI_TEST_CHECK( found == second );
2124 int UtcDaliActorFindChildById(void)
2126 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2127 TestApplication application;
2129 Actor parent = Actor::New();
2130 Actor first = Actor::New();
2131 Actor second = Actor::New();
2136 Actor found = parent.FindChildById( 100000 );
2137 DALI_TEST_CHECK( !found );
2139 found = parent.FindChildById( parent.GetId() );
2140 DALI_TEST_CHECK( found == parent );
2142 found = parent.FindChildById( first.GetId() );
2143 DALI_TEST_CHECK( found == first );
2145 found = parent.FindChildById( second.GetId() );
2146 DALI_TEST_CHECK( found == second );
2150 int UtcDaliActorHitTest(void)
2155 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2157 mTouchPoint( touchPoint ),
2162 Vector2 mTouchPoint;
2166 TestApplication application;
2167 tet_infoline(" UtcDaliActorHitTest");
2169 // Fill a vector with different hit tests.
2170 struct HitTestData* hitTestData[] = {
2171 // scale touch point result
2172 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2173 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2174 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.
2175 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2176 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.
2180 // get the root layer
2181 Actor actor = Actor::New();
2182 actor.SetAnchorPoint( AnchorPoint::CENTER );
2183 actor.SetParentOrigin( ParentOrigin::CENTER );
2185 Stage::GetCurrent().Add( actor );
2187 gTouchCallBackCalled = false;
2189 unsigned int index = 0;
2190 while( NULL != hitTestData[index] )
2192 actor.SetSize( 1.f, 1.f );
2193 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2195 // flush the queue and render once
2196 application.SendNotification();
2197 application.Render();
2199 DALI_TEST_CHECK( !gTouchCallBackCalled );
2201 // connect to its touch signal
2202 actor.TouchedSignal().Connect(TestCallback);
2204 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2205 Dali::Integration::TouchEvent event;
2206 event.AddPoint( point );
2208 // flush the queue and render once
2209 application.SendNotification();
2210 application.Render();
2211 application.ProcessEvent( event );
2213 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2215 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2216 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2217 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2218 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2219 hitTestData[index]->mResult );
2221 gTouchCallBackCalled = false;
2227 int UtcDaliActorSetDrawMode(void)
2229 TestApplication app;
2230 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2232 Actor a = Actor::New();
2234 Stage::GetCurrent().Add(a);
2235 app.SendNotification();
2237 app.SendNotification();
2240 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2242 a.SetDrawMode( DrawMode::OVERLAY_2D );
2243 app.SendNotification();
2246 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2248 a.SetDrawMode( DrawMode::STENCIL );
2249 app.SendNotification();
2252 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2254 a.SetDrawMode( DrawMode::NORMAL );
2255 app.SendNotification();
2258 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2262 int UtcDaliActorSetDrawModeOverlayRender(void)
2264 TestApplication app;
2265 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2267 app.SendNotification();
2270 std::vector<GLuint> ids;
2271 ids.push_back( 8 ); // first rendered actor
2272 ids.push_back( 9 ); // second rendered actor
2273 ids.push_back( 10 ); // third rendered actor
2274 app.GetGlAbstraction().SetNextTextureIds( ids );
2276 BufferImage imageA = BufferImage::New(16, 16);
2277 BufferImage imageB = BufferImage::New(16, 16);
2278 BufferImage imageC = BufferImage::New(16, 16);
2279 Actor a = CreateRenderableActor( imageA );
2280 Actor b = CreateRenderableActor( imageB );
2281 Actor c = CreateRenderableActor( imageC );
2283 // Render a,b,c as regular non-overlays. so order will be:
2287 Stage::GetCurrent().Add(a);
2288 Stage::GetCurrent().Add(b);
2289 Stage::GetCurrent().Add(c);
2291 app.SendNotification();
2294 // Should be 3 textures changes.
2295 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2296 typedef std::vector<GLuint>::size_type TextureSize;
2297 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2298 if( boundTextures.size() == 3 )
2300 DALI_TEST_CHECK( boundTextures[0] == 8u );
2301 DALI_TEST_CHECK( boundTextures[1] == 9u );
2302 DALI_TEST_CHECK( boundTextures[2] == 10u );
2305 // Now texture ids have been set, we can monitor their render order.
2306 // render a as an overlay (last), so order will be:
2310 a.SetDrawMode( DrawMode::OVERLAY_2D );
2311 app.GetGlAbstraction().ClearBoundTextures();
2313 app.SendNotification();
2316 // Should be 3 texture changes.
2317 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2318 if( boundTextures.size() == 3 )
2320 DALI_TEST_CHECK( boundTextures[0] == 9u );
2321 DALI_TEST_CHECK( boundTextures[1] == 10u );
2322 DALI_TEST_CHECK( boundTextures[2] == 8u );
2327 int UtcDaliActorGetCurrentWorldMatrix(void)
2329 TestApplication app;
2330 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2332 Actor parent = Actor::New();
2333 parent.SetParentOrigin(ParentOrigin::CENTER);
2334 parent.SetAnchorPoint(AnchorPoint::CENTER);
2335 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2336 Radian rotationAngle(Degree(85.0f));
2337 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2338 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2339 parent.SetPosition( parentPosition );
2340 parent.SetOrientation( parentRotation );
2341 parent.SetScale( parentScale );
2342 Stage::GetCurrent().Add( parent );
2344 Actor child = Actor::New();
2345 child.SetParentOrigin(ParentOrigin::CENTER);
2346 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2347 Radian childRotationAngle(Degree(23.0f));
2348 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2349 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2350 child.SetPosition( childPosition );
2351 child.SetOrientation( childRotation );
2352 child.SetScale( childScale );
2353 parent.Add( child );
2355 app.SendNotification();
2358 app.SendNotification();
2360 Matrix parentMatrix(false);
2361 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2363 Matrix childMatrix(false);
2364 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2366 //Child matrix should be the composition of child and parent
2367 Matrix childWorldMatrix(false);
2368 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2370 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2371 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2377 int UtcDaliActorConstrainedToWorldMatrix(void)
2379 TestApplication app;
2380 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2382 Actor parent = Actor::New();
2383 parent.SetParentOrigin(ParentOrigin::CENTER);
2384 parent.SetAnchorPoint(AnchorPoint::CENTER);
2385 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2386 Radian rotationAngle(Degree(85.0f));
2387 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2388 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2389 parent.SetPosition( parentPosition );
2390 parent.SetOrientation( parentRotation );
2391 parent.SetScale( parentScale );
2392 Stage::GetCurrent().Add( parent );
2394 Actor child = Actor::New();
2395 child.SetParentOrigin(ParentOrigin::CENTER);
2396 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2397 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2398 posConstraint.Apply();
2400 Stage::GetCurrent().Add( child );
2402 app.SendNotification();
2405 app.SendNotification();
2407 Matrix parentMatrix(false);
2408 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2410 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2411 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2415 int UtcDaliActorConstrainedToOrientation(void)
2417 TestApplication app;
2418 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2420 Actor parent = Actor::New();
2421 parent.SetParentOrigin(ParentOrigin::CENTER);
2422 parent.SetAnchorPoint(AnchorPoint::CENTER);
2423 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2424 Radian rotationAngle(Degree(85.0f));
2425 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2426 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2427 parent.SetPosition( parentPosition );
2428 parent.SetOrientation( parentRotation );
2429 parent.SetScale( parentScale );
2430 Stage::GetCurrent().Add( parent );
2432 Actor child = Actor::New();
2433 child.SetParentOrigin(ParentOrigin::CENTER);
2434 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2435 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2436 posConstraint.Apply();
2438 Stage::GetCurrent().Add( child );
2440 app.SendNotification();
2443 app.SendNotification();
2445 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2449 int UtcDaliActorUnparent(void)
2451 TestApplication app;
2452 tet_infoline(" UtcDaliActorUnparent");
2454 Actor parent = Actor::New();
2455 Stage::GetCurrent().Add( parent );
2457 Actor child = Actor::New();
2459 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2460 DALI_TEST_CHECK( !child.GetParent() );
2462 // Test that calling Unparent with no parent is a NOOP
2465 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2466 DALI_TEST_CHECK( !child.GetParent() );
2468 // Test that Unparent works
2469 parent.Add( child );
2471 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2472 DALI_TEST_CHECK( parent == child.GetParent() );
2476 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2477 DALI_TEST_CHECK( !child.GetParent() );
2479 // Test that UnparentAndReset works
2480 parent.Add( child );
2482 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2483 DALI_TEST_CHECK( parent == child.GetParent() );
2485 UnparentAndReset( child );
2487 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2488 DALI_TEST_CHECK( !child );
2490 // Test that UnparentAndReset is a NOOP with empty handle
2491 UnparentAndReset( child );
2493 DALI_TEST_CHECK( !child );
2497 int UtcDaliActorGetChildAt(void)
2499 TestApplication app;
2500 tet_infoline(" UtcDaliActorGetChildAt");
2502 Actor parent = Actor::New();
2503 Stage::GetCurrent().Add( parent );
2505 Actor child0 = Actor::New();
2506 parent.Add( child0 );
2508 Actor child1 = Actor::New();
2509 parent.Add( child1 );
2511 Actor child2 = Actor::New();
2512 parent.Add( child2 );
2514 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2515 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2516 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2520 int UtcDaliActorSetGetOverlay(void)
2522 TestApplication app;
2523 tet_infoline(" UtcDaliActorSetGetOverlay");
2525 Actor parent = Actor::New();
2526 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2527 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2532 int UtcDaliActorCreateDestroy(void)
2534 Actor* actor = new Actor;
2535 DALI_TEST_CHECK( actor );
2542 struct PropertyStringIndex
2544 const char * const name;
2545 const Property::Index index;
2546 const Property::Type type;
2549 const PropertyStringIndex PROPERTY_TABLE[] =
2551 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2552 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2553 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2554 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2555 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2556 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2557 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2558 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2559 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2560 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2561 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2562 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2563 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2564 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2565 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2566 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2567 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2568 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2569 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2570 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2571 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2572 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2573 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2574 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2575 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2576 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2577 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2578 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2579 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2580 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2581 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2582 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2583 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2584 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2585 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2586 { "name", Actor::Property::NAME, Property::STRING },
2587 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2588 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2589 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2590 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2591 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2592 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2593 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
2594 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2595 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2596 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2597 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2598 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2599 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2600 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2601 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2602 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2604 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2605 } // unnamed namespace
2607 int UtcDaliActorProperties(void)
2609 TestApplication app;
2611 Actor actor = Actor::New();
2613 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2615 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2616 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2617 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2618 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2623 int UtcDaliRelayoutProperties_ResizePolicies(void)
2625 TestApplication app;
2627 Actor actor = Actor::New();
2630 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2631 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2633 // Set resize policy for all dimensions
2634 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2635 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2637 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2640 // Set individual dimensions
2641 const char* const widthPolicy = "FILL_TO_PARENT";
2642 const char* const heightPolicy = "FIXED";
2644 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2645 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2647 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2648 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2653 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2655 TestApplication app;
2657 Actor actor = Actor::New();
2660 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2661 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2663 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2664 actor.SetSizeScalePolicy( policy );
2665 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2668 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2669 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2671 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2672 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2674 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2675 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2680 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2682 TestApplication app;
2684 Actor actor = Actor::New();
2687 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2688 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2690 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2691 actor.SetSizeModeFactor( sizeMode );
2692 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2695 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2697 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2698 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2703 int UtcDaliRelayoutProperties_DimensionDependency(void)
2705 TestApplication app;
2707 Actor actor = Actor::New();
2710 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2711 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2714 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2715 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2717 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2718 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2720 // Test setting another resize policy
2721 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2722 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2727 int UtcDaliRelayoutProperties_Padding(void)
2729 TestApplication app;
2731 Actor actor = Actor::New();
2734 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2737 actor.SetProperty( Actor::Property::PADDING, padding );
2738 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2740 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2745 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2747 TestApplication app;
2749 Actor actor = Actor::New();
2752 Vector2 minSize( 1.0f, 2.0f );
2754 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2755 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2757 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2759 Vector2 maxSize( 3.0f, 4.0f );
2761 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2762 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2764 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2769 int UtcDaliActorGetHeightForWidth(void)
2771 TestApplication app;
2773 Actor actor = Actor::New();
2775 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
2780 int UtcDaliActorGetWidthForHeight(void)
2782 TestApplication app;
2784 Actor actor = Actor::New();
2786 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
2791 int UtcDaliActorGetRelayoutSize(void)
2793 TestApplication app;
2795 Actor actor = Actor::New();
2797 // Add actor to stage
2798 Stage::GetCurrent().Add( actor );
2800 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
2802 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
2803 actor.SetSize( Vector2( 1.0f, 0.0f ) );
2805 // Flush the queue and render once
2806 app.SendNotification();
2809 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
2814 int UtcDaliActorSetPadding(void)
2816 TestApplication app;
2818 Actor actor = Actor::New();
2821 actor.GetPadding( padding );
2823 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
2824 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
2825 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
2826 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
2828 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
2829 actor.SetPadding( padding2 );
2831 actor.GetPadding( padding );
2833 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
2834 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
2835 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
2836 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
2841 int UtcDaliActorSetMinimumSize(void)
2843 TestApplication app;
2845 Actor actor = Actor::New();
2847 Vector2 size = actor.GetMinimumSize();
2849 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
2850 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
2852 Vector2 size2( 1.0f, 2.0f );
2853 actor.SetMinimumSize( size2 );
2855 size = actor.GetMinimumSize();
2857 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2858 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2863 int UtcDaliActorSetMaximumSize(void)
2865 TestApplication app;
2867 Actor actor = Actor::New();
2869 Vector2 size = actor.GetMaximumSize();
2871 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
2872 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
2874 Vector2 size2( 1.0f, 2.0f );
2875 actor.SetMaximumSize( size2 );
2877 size = actor.GetMaximumSize();
2879 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2880 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2885 int UtcDaliActorOnRelayoutSignal(void)
2887 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
2889 TestApplication application;
2892 gOnRelayoutCallBackCalled = false;
2893 gActorNamesRelayout.clear();
2895 Actor actor = Actor::New();
2896 actor.SetName( "actor" );
2897 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
2900 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
2902 // Add actor to stage
2903 Stage::GetCurrent().Add( actor );
2905 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2906 actor.SetSize( Vector2( 1.0f, 2.0 ) );
2908 // Flush the queue and render once
2909 application.SendNotification();
2910 application.Render();
2912 // OnRelayout emitted
2913 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
2914 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
2919 int UtcDaliActorGetHierachyDepth(void)
2921 TestApplication application;
2922 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
2925 /* Build tree of actors:
2935 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
2937 Stage stage( Stage::GetCurrent() );
2939 Actor actorA = Actor::New();
2940 Actor actorB = Actor::New();
2941 Actor actorC = Actor::New();
2942 Actor actorD = Actor::New();
2943 Actor actorE = Actor::New();
2944 Actor actorF = Actor::New();
2946 //Test that root actor has depth equal 0
2947 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
2949 //Test actors return depth -1 when not connected to the tree
2950 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2951 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2952 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
2953 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2954 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2955 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
2957 //Create the hierarchy
2958 stage.Add( actorA );
2959 actorA.Add( actorB );
2960 actorA.Add( actorC );
2961 actorB.Add( actorD );
2962 actorB.Add( actorE );
2963 actorC.Add( actorF );
2965 //Test actors return correct depth
2966 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2967 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
2968 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
2969 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
2970 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
2971 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
2973 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
2974 actorA.Remove( actorB );
2976 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2977 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2978 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2980 //Removing actorA from the stage. All actors should have depth equal -1
2981 stage.Remove( actorA );
2983 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2984 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2985 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
2986 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2987 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2988 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
2993 int UtcDaliActorAnchorPointPropertyAsString(void)
2995 TestApplication application;
2997 Actor actor = Actor::New();
2999 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3000 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3002 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3003 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3005 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3006 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3008 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3009 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3011 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3012 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3014 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3015 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3017 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3018 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3020 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3021 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3023 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3024 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3026 // Invalid should not change anything
3027 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3028 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3033 int UtcDaliActorParentOriginPropertyAsString(void)
3035 TestApplication application;
3037 Actor actor = Actor::New();
3039 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3040 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3042 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3043 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3045 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3046 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3048 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3049 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3051 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3052 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3054 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3055 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3057 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3058 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3060 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3061 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3063 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3064 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3066 // Invalid should not change anything
3067 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3068 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3073 int UtcDaliActorColorModePropertyAsString(void)
3075 TestApplication application;
3077 Actor actor = Actor::New();
3079 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3080 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3082 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3083 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3085 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3086 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3088 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3089 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3091 // Invalid should not change anything
3092 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3093 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3098 int UtcDaliActorPositionInheritancePropertyAsString(void)
3100 TestApplication application;
3102 Actor actor = Actor::New();
3104 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3105 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3107 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3108 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3110 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3111 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3113 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3114 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3116 // Invalid should not change anything
3117 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3118 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3123 int UtcDaliActorDrawModePropertyAsString(void)
3125 TestApplication application;
3127 Actor actor = Actor::New();
3129 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3130 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3132 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3133 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3135 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3136 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3138 // Invalid should not change anything
3139 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3140 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );