2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 #include <dali/dali.h>
20 #include <dali/integration-api/events/touch-event-integ.h>
21 #include <dali-test-suite-utils.h>
29 void utc_dali_actor_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_actor_cleanup(void)
36 test_return_value = TET_PASS;
42 const char* vertexSource =
45 " gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
46 " vTexCoord = aTexCoord;\n"
49 const char* fragmentSource =
52 " gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n"
55 bool gTouchCallBackCalled=false;
56 bool gTouchCallBack2Called=false;
59 * Simulates a Down Touch at 25.0, 25.0.
60 * @param[in] app Test Application instance.
62 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
64 app.SendNotification();
66 app.SendNotification();
69 gTouchCallBackCalled = false;
70 gTouchCallBack2Called = false;
72 // simulate a touch event
73 Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
74 Dali::Integration::TouchEvent event;
75 event.AddPoint( point );
76 app.ProcessEvent( event );
78 app.SendNotification();
80 app.SendNotification();
86 static bool gTestConstraintCalled;
90 Vector4 operator()(const Vector4& color)
92 gTestConstraintCalled = true;
93 return Vector4(color.x, color.y, color.z, 0.1f);
98 * TestConstraint reference.
99 * When constraint is called, the resultRef is updated
100 * with the value supplied.
103 struct TestConstraintRef
105 TestConstraintRef(unsigned int& resultRef, unsigned int value)
106 : mResultRef(resultRef),
111 T operator()(const T& current)
117 unsigned int& mResultRef;
121 bool wasConstraintCallbackCalled1 = false;
122 void TestConstraintCallback1( ActiveConstraint& constraint )
124 wasConstraintCallbackCalled1 = true;
127 bool wasConstraintCallbackCalled2 = false;
128 void TestConstraintCallback2( ActiveConstraint& constraint )
130 wasConstraintCallbackCalled2 = true;
133 bool wasConstraintCallbackCalled3 = false;
134 void TestConstraintCallback3( ActiveConstraint& constraint )
136 wasConstraintCallbackCalled3 = true;
139 static bool TestCallback(Actor actor, const TouchEvent& event)
141 gTouchCallBackCalled = true;
146 static bool TestCallback2(Actor actor, const TouchEvent& event)
148 gTouchCallBack2Called = true;
153 static Vector3 gSetSize;
154 static bool gSetSizeCallBackCalled;
155 void SetSizeCallback( Actor actor, const Vector3& size )
157 gSetSizeCallBackCalled = true;
160 // validation stuff for onstage & offstage signals
161 static std::vector< std::string > gActorNamesOnOffStage;
162 static int gOnStageCallBackCalled;
163 void OnStageCallback( Actor actor )
165 ++gOnStageCallBackCalled;
166 gActorNamesOnOffStage.push_back( actor.GetName() );
167 DALI_TEST_CHECK( actor.OnStage() == true );
169 static int gOffStageCallBackCalled;
170 void OffStageCallback( Actor actor )
172 ++gOffStageCallBackCalled;
173 gActorNamesOnOffStage.push_back( actor.GetName() );
174 DALI_TEST_CHECK( actor.OnStage() == false );
177 struct PositionComponentConstraint
179 PositionComponentConstraint(){}
181 Vector3 operator()(const Vector3& current, const PropertyInput& property)
183 const Matrix& m = property.GetMatrix();
187 m.GetTransformComponents(pos, rot, scale);
194 } // anonymous namespace
197 //& purpose: Testing New API
198 int UtcDaliActorNew(void)
200 TestApplication application;
202 Actor actor = Actor::New();
204 DALI_TEST_CHECK(actor);
208 //& purpose: Testing Dali::Actor::DownCast()
209 int UtcDaliActorDownCast(void)
211 TestApplication application;
212 tet_infoline("Testing Dali::Actor::DownCast()");
214 Actor actor = Actor::New();
215 BaseHandle object(actor);
216 Actor actor2 = Actor::DownCast(object);
217 DALI_TEST_CHECK(actor2);
221 //& purpose: Testing Dali::Actor::DownCast()
222 int UtcDaliActorDownCast2(void)
224 TestApplication application;
225 tet_infoline("Testing Dali::Actor::DownCast()");
227 BaseHandle unInitializedObject;
228 Actor actor = Actor::DownCast(unInitializedObject);
229 DALI_TEST_CHECK(!actor);
233 //& purpose: Testing Dali::Actor::GetName()
234 int UtcDaliActorGetName(void)
236 TestApplication application;
238 Actor actor = Actor::New();
240 DALI_TEST_CHECK(actor.GetName().empty());
244 //& purpose: Testing Dali::Actor::SetName()
245 int UtcDaliActorSetName(void)
247 TestApplication application;
249 string str("ActorName");
250 Actor actor = Actor::New();
253 DALI_TEST_CHECK(actor.GetName() == str);
257 int UtcDaliActorGetId(void)
259 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
260 TestApplication application;
262 Actor first = Actor::New();
263 Actor second = Actor::New();
264 Actor third = Actor::New();
266 DALI_TEST_CHECK(first.GetId() != second.GetId());
267 DALI_TEST_CHECK(second.GetId() != third.GetId());
271 int UtcDaliActorIsRoot(void)
273 TestApplication application;
275 Actor actor = Actor::New();
276 DALI_TEST_CHECK(!actor.IsRoot());
278 // get the root layer
279 actor = Stage::GetCurrent().GetLayer( 0 );
280 DALI_TEST_CHECK( actor.IsRoot() );
284 int UtcDaliActorOnStage(void)
286 TestApplication application;
288 Actor actor = Actor::New();
289 DALI_TEST_CHECK( !actor.OnStage() );
291 // get the root layer
292 actor = Stage::GetCurrent().GetLayer( 0 );
293 DALI_TEST_CHECK( actor.OnStage() );
297 int UtcDaliActorIsLayer(void)
299 TestApplication application;
301 Actor actor = Actor::New();
302 DALI_TEST_CHECK( !actor.IsLayer() );
304 // get the root layer
305 actor = Stage::GetCurrent().GetLayer( 0 );
306 DALI_TEST_CHECK( actor.IsLayer() );
310 int UtcDaliActorGetLayer(void)
312 TestApplication application;
314 Actor actor = Actor::New();
315 Stage::GetCurrent().Add(actor);
316 Layer layer = actor.GetLayer();
318 DALI_TEST_CHECK(layer);
320 // get the root layers layer
321 actor = Stage::GetCurrent().GetLayer( 0 );
322 DALI_TEST_CHECK( actor.GetLayer() );
326 int UtcDaliActorAdd(void)
328 tet_infoline("Testing Actor::Add");
329 TestApplication application;
331 Actor parent = Actor::New();
332 Actor child = Actor::New();
334 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
338 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
340 Actor parent2 = Actor::New();
341 parent2.Add( child );
343 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
344 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
346 // try Adding to same parent again, works
347 parent2.Add( child );
348 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
350 // try reparenting an orphaned child
352 Actor temporaryParent = Actor::New();
353 temporaryParent.Add( child );
354 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
356 // temporaryParent has now died, reparent the orphaned child
357 parent2.Add( child );
358 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
363 parent2.Add( parent2 );
364 tet_printf("Assertion test failed - no Exception\n" );
365 tet_result(TET_FAIL);
367 catch(Dali::DaliException& e)
369 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
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 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
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 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
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);
420 int UtcDaliActorRemove01(void)
422 tet_infoline("Testing Actor::Remove");
423 TestApplication application;
425 Actor parent = Actor::New();
426 Actor child = Actor::New();
427 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
430 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
432 parent.Remove(child);
433 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
435 // remove again, no problem
436 parent.Remove(child);
437 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
441 // try illegal Remove
444 parent.Remove( parent );
445 tet_printf("Assertion test failed - no Exception\n" );
446 tet_result(TET_FAIL);
448 catch(Dali::DaliException& e)
450 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
451 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
452 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
456 tet_printf("Assertion test failed - wrong Exception\n" );
457 tet_result(TET_FAIL);
464 parent.Remove( empty );
465 tet_printf("Assertion test failed - no Exception\n" );
466 tet_result(TET_FAIL);
468 catch(Dali::DaliException& e)
470 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
471 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
472 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
476 tet_printf("Assertion test failed - wrong Exception\n" );
477 tet_result(TET_FAIL);
482 int UtcDaliActorRemove02(void)
484 TestApplication application;
486 Actor parent = Actor::New();
487 Actor child = Actor::New();
488 Actor random = Actor::New();
490 Stage::GetCurrent().Add( parent );
492 DALI_TEST_CHECK(parent.GetChildCount() == 0);
496 DALI_TEST_CHECK(parent.GetChildCount() == 1);
498 parent.Remove(random);
500 DALI_TEST_CHECK(parent.GetChildCount() == 1);
502 Stage::GetCurrent().Remove( parent );
504 DALI_TEST_CHECK(parent.GetChildCount() == 1);
508 int UtcDaliActorGetChildCount(void)
510 TestApplication application;
512 Actor parent = Actor::New();
513 Actor child = Actor::New();
515 DALI_TEST_CHECK(parent.GetChildCount() == 0);
519 DALI_TEST_CHECK(parent.GetChildCount() == 1);
523 int UtcDaliActorGetChildren01(void)
525 TestApplication application;
527 Actor parent = Actor::New();
528 Actor first = Actor::New();
529 Actor second = Actor::New();
530 Actor third = Actor::New();
536 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
537 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
538 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
542 int UtcDaliActorGetChildren02(void)
544 TestApplication application;
546 Actor parent = Actor::New();
547 Actor first = Actor::New();
548 Actor second = Actor::New();
549 Actor third = Actor::New();
555 const Actor& constParent = parent;
557 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
558 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
559 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
563 int UtcDaliActorGetParent01(void)
565 TestApplication application;
567 Actor parent = Actor::New();
568 Actor child = Actor::New();
572 DALI_TEST_CHECK(child.GetParent() == parent);
576 int UtcDaliActorGetParent02(void)
578 TestApplication application;
580 Actor actor = Actor::New();
582 DALI_TEST_CHECK(!actor.GetParent());
586 int UtcDaliActorSetParentOrigin(void)
588 TestApplication application;
590 Actor actor = Actor::New();
592 Vector3 vector(0.7f, 0.8f, 0.9f);
593 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
595 actor.SetParentOrigin(vector);
597 // flush the queue and render once
598 application.SendNotification();
599 application.Render();
601 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
603 Stage::GetCurrent().Add( actor );
605 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
607 // flush the queue and render once
608 application.SendNotification();
609 application.Render();
611 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
613 Stage::GetCurrent().Remove( actor );
617 int UtcDaliActorGetCurrentParentOrigin(void)
619 TestApplication application;
621 Actor actor = Actor::New();
623 Vector3 vector(0.7f, 0.8f, 0.9f);
624 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
626 actor.SetParentOrigin(vector);
628 // flush the queue and render once
629 application.SendNotification();
630 application.Render();
632 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
636 int UtcDaliActorSetAnchorPoint(void)
638 TestApplication application;
640 Actor actor = Actor::New();
642 Vector3 vector(0.7f, 0.8f, 0.9f);
643 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
645 actor.SetAnchorPoint(vector);
647 // flush the queue and render once
648 application.SendNotification();
649 application.Render();
651 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
653 Stage::GetCurrent().Add( actor );
655 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
656 // flush the queue and render once
657 application.SendNotification();
658 application.Render();
660 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
662 Stage::GetCurrent().Remove( actor );
666 int UtcDaliActorGetCurrentAnchorPoint(void)
668 TestApplication application;
670 Actor actor = Actor::New();
672 Vector3 vector(0.7f, 0.8f, 0.9f);
673 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
675 actor.SetAnchorPoint(vector);
677 // flush the queue and render once
678 application.SendNotification();
679 application.Render();
681 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
685 // SetSize(float width, float height)
686 int UtcDaliActorSetSize01(void)
688 TestApplication application;
690 Actor actor = Actor::New();
691 Vector3 vector(100.0f, 100.0f, 100.0f);
693 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
695 actor.SetSize(vector.x, vector.y);
697 // flush the queue and render once
698 application.SendNotification();
699 application.Render();
701 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
705 // SetSize(float width, float height, float depth)
706 int UtcDaliActorSetSize02(void)
708 TestApplication application;
710 Actor actor = Actor::New();
711 Vector3 vector(100.0f, 100.0f, 100.0f);
713 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
715 actor.SetSize(vector.x, vector.y, vector.z);
717 // flush the queue and render once
718 application.SendNotification();
719 application.Render();
721 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
725 // SetSize(Vector2 size)
726 int UtcDaliActorSetSize03(void)
728 TestApplication application;
730 Actor actor = Actor::New();
731 Vector3 vector(100.0f, 100.0f, 100.0f);
733 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
735 actor.SetSize(Vector2(vector.x, vector.y));
737 // flush the queue and render once
738 application.SendNotification();
739 application.Render();
741 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
745 // SetSize(Vector3 size)
746 int UtcDaliActorSetSize04(void)
748 TestApplication application;
750 Actor actor = Actor::New();
751 Vector3 vector(100.0f, 100.0f, 100.0f);
753 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
755 actor.SetSize(vector);
757 // flush the queue and render once
758 application.SendNotification();
759 application.Render();
761 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
763 Stage::GetCurrent().Add( actor );
764 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
766 // flush the queue and render once
767 application.SendNotification();
768 application.Render();
770 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
771 Stage::GetCurrent().Remove( actor );
775 int UtcDaliActorGetCurrentSize(void)
777 TestApplication application;
779 Actor actor = Actor::New();
780 Vector3 vector(100.0f, 100.0f, 20.0f);
782 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
784 actor.SetSize(vector);
786 // flush the queue and render once
787 application.SendNotification();
788 application.Render();
790 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
794 // SetPosition(float x, float y)
795 int UtcDaliActorSetPosition01(void)
797 TestApplication application;
799 Actor actor = Actor::New();
801 // Set to random to start off with
802 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
804 Vector3 vector(100.0f, 100.0f, 0.0f);
806 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
808 actor.SetPosition(vector.x, vector.y);
809 // flush the queue and render once
810 application.SendNotification();
811 application.Render();
812 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
814 Stage::GetCurrent().Add( actor );
815 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
816 // flush the queue and render once
817 application.SendNotification();
818 application.Render();
819 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
824 // flush the queue and render once
825 application.SendNotification();
826 application.Render();
827 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
829 actor.MoveBy( Vector3( 0.1f, 0.1f, 0.1f ) );
830 // flush the queue and render once
831 application.SendNotification();
832 application.Render();
833 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
835 Stage::GetCurrent().Remove( actor );
839 // SetPosition(float x, float y, float z)
840 int UtcDaliActorSetPosition02(void)
842 TestApplication application;
844 Actor actor = Actor::New();
846 // Set to random to start off with
847 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
849 Vector3 vector(100.0f, 100.0f, 100.0f);
851 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
853 actor.SetPosition(vector.x, vector.y, vector.z);
855 // flush the queue and render once
856 application.SendNotification();
857 application.Render();
859 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
863 // SetPosition(Vector3 position)
864 int UtcDaliActorSetPosition03(void)
866 TestApplication application;
868 Actor actor = Actor::New();
870 // Set to random to start off with
871 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
873 Vector3 vector(100.0f, 100.0f, 100.0f);
875 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
877 actor.SetPosition(vector);
879 // flush the queue and render once
880 application.SendNotification();
881 application.Render();
883 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
887 int UtcDaliActorSetX(void)
889 TestApplication application;
891 Actor actor = Actor::New();
893 Vector3 vector(100.0f, 0.0f, 0.0f);
895 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
899 // flush the queue and render once
900 application.SendNotification();
901 application.Render();
903 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
907 int UtcDaliActorSetY(void)
909 TestApplication application;
911 Actor actor = Actor::New();
913 Vector3 vector(0.0f, 100.0f, 0.0f);
915 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
919 // flush the queue and render once
920 application.SendNotification();
921 application.Render();
923 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
927 int UtcDaliActorSetZ(void)
929 TestApplication application;
931 Actor actor = Actor::New();
933 Vector3 vector(0.0f, 0.0f, 100.0f);
935 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
939 // flush the queue and render once
940 application.SendNotification();
941 application.Render();
943 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
947 int UtcDaliActorMoveBy(void)
949 TestApplication application;
951 Actor actor = Actor::New();
952 Vector3 vector(100.0f, 100.0f, 100.0f);
954 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
956 actor.SetPosition(vector);
958 // flush the queue and render once
959 application.SendNotification();
960 application.Render();
962 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
964 actor.MoveBy(vector);
966 // flush the queue and render once
967 application.SendNotification();
968 application.Render();
970 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
974 int UtcDaliActorGetCurrentPosition(void)
976 TestApplication application;
978 Actor actor = Actor::New();
979 Vector3 setVector(100.0f, 100.0f, 0.0f);
980 actor.SetPosition(setVector);
982 // flush the queue and render once
983 application.SendNotification();
984 application.Render();
986 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
990 int UtcDaliActorGetCurrentWorldPosition(void)
992 TestApplication application;
994 Actor parent = Actor::New();
995 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
996 parent.SetPosition( parentPosition );
997 parent.SetParentOrigin( ParentOrigin::CENTER );
998 parent.SetAnchorPoint( AnchorPoint::CENTER );
999 Stage::GetCurrent().Add( parent );
1001 Actor child = Actor::New();
1002 child.SetParentOrigin( ParentOrigin::CENTER );
1003 child.SetAnchorPoint( AnchorPoint::CENTER );
1004 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1005 child.SetPosition( childPosition );
1006 parent.Add( child );
1008 // The actors should not have a world position yet
1009 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1010 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1012 application.SendNotification();
1013 application.Render(0);
1015 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1016 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1018 // The actors should have a world position now
1019 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1020 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1024 int UtcDaliActorInheritPosition(void)
1026 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1027 TestApplication application;
1029 Actor parent = Actor::New();
1030 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1031 parent.SetPosition( parentPosition );
1032 parent.SetParentOrigin( ParentOrigin::CENTER );
1033 parent.SetAnchorPoint( AnchorPoint::CENTER );
1034 Stage::GetCurrent().Add( parent );
1036 Actor child = Actor::New();
1037 child.SetParentOrigin( ParentOrigin::CENTER );
1038 child.SetAnchorPoint( AnchorPoint::CENTER );
1039 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1040 child.SetPosition( childPosition );
1041 parent.Add( child );
1043 // The actors should not have a world position yet
1044 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1045 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1047 // first test default, which is INHERIT_PARENT_POSITION
1048 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1049 application.SendNotification();
1050 application.Render(0); // should only really call Update as Render is not required to update scene
1051 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1052 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1053 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1054 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1056 // Change inheritance mode to use parent
1057 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1058 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1059 application.SendNotification();
1060 application.Render(0); // should only really call Update as Render is not required to update scene
1061 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1062 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1063 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1064 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1066 // Change inheritance mode to use parent + offset
1067 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1068 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1069 child.SetPosition( childOffset );
1070 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1071 application.SendNotification();
1072 application.Render(0); // should only really call Update as Render is not required to update scene
1073 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1074 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1075 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1076 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1078 // Change inheritance mode to not inherit
1079 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1080 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1081 application.SendNotification();
1082 application.Render(0); // should only really call Update as Render is not required to update scene
1083 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1084 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1085 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1086 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1090 // SetRotation(float angleRadians, Vector3 axis)
1091 int UtcDaliActorSetRotation01(void)
1093 TestApplication application;
1095 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1096 Actor actor = Actor::New();
1098 actor.SetRotation(rotation);
1100 // flush the queue and render once
1101 application.SendNotification();
1102 application.Render();
1104 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1108 int UtcDaliActorSetRotation02(void)
1110 TestApplication application;
1112 Actor actor = Actor::New();
1114 float angle = 0.785f;
1115 Vector3 axis(1.0f, 1.0f, 0.0f);
1117 actor.SetRotation(Radian( angle ), axis);
1118 Quaternion rotation( angle, axis );
1119 // flush the queue and render once
1120 application.SendNotification();
1121 application.Render();
1122 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1124 Stage::GetCurrent().Add( actor );
1125 actor.RotateBy( Degree( 360 ), axis);
1126 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1128 actor.SetRotation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1129 Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
1130 // flush the queue and render once
1131 application.SendNotification();
1132 application.Render();
1133 DALI_TEST_EQUALS( result, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1135 actor.SetRotation(Radian( angle ), axis);
1136 // flush the queue and render once
1137 application.SendNotification();
1138 application.Render();
1139 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1141 Stage::GetCurrent().Remove( actor );
1145 // RotateBy(float angleRadians, Vector3 axis)
1146 int UtcDaliActorRotateBy01(void)
1148 TestApplication application;
1150 Actor actor = Actor::New();
1152 float angle = M_PI * 0.25f;
1153 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1154 // flush the queue and render once
1155 application.SendNotification();
1156 application.Render();
1157 DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1159 Stage::GetCurrent().Add( actor );
1161 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1162 // flush the queue and render once
1163 application.SendNotification();
1164 application.Render();
1165 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1167 Stage::GetCurrent().Remove( actor );
1171 // RotateBy(Quaternion relativeRotation)
1172 int UtcDaliActorRotateBy02(void)
1174 TestApplication application;
1176 Actor actor = Actor::New();
1178 Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1179 actor.RotateBy(rotation);
1180 // flush the queue and render once
1181 application.SendNotification();
1182 application.Render();
1183 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1185 actor.RotateBy(rotation);
1186 // flush the queue and render once
1187 application.SendNotification();
1188 application.Render();
1189 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1193 int UtcDaliActorGetCurrentRotation(void)
1195 TestApplication application;
1196 Actor actor = Actor::New();
1198 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1199 actor.SetRotation(rotation);
1200 // flush the queue and render once
1201 application.SendNotification();
1202 application.Render();
1203 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1207 int UtcDaliActorGetCurrentWorldRotation(void)
1209 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1210 TestApplication application;
1212 Actor parent = Actor::New();
1213 Radian rotationAngle( Degree(90.0f) );
1214 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1215 parent.SetRotation( rotation );
1216 Stage::GetCurrent().Add( parent );
1218 Actor child = Actor::New();
1219 child.SetRotation( rotation );
1220 parent.Add( child );
1222 // The actors should not have a world rotation yet
1223 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1224 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1226 application.SendNotification();
1227 application.Render(0);
1229 DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1230 DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1232 // The actors should have a world rotation now
1233 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1234 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1236 // turn off child rotation inheritance
1237 child.SetInheritRotation( false );
1238 DALI_TEST_EQUALS( child.IsRotationInherited(), false, TEST_LOCATION );
1239 application.SendNotification();
1240 application.Render(0);
1242 // The actors should have a world rotation now
1243 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1244 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), rotation, 0.001, TEST_LOCATION );
1248 // SetScale(float scale)
1249 int UtcDaliActorSetScale01(void)
1251 TestApplication application;
1253 Actor actor = Actor::New();
1255 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1256 actor.SetScale(0.25f);
1258 Vector3 scale(10.0f, 10.0f, 10.0f);
1259 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1261 actor.SetScale(scale.x);
1263 // flush the queue and render once
1264 application.SendNotification();
1265 application.Render();
1267 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1271 // SetScale(float scaleX, float scaleY, float scaleZ)
1272 int UtcDaliActorSetScale02(void)
1274 TestApplication application;
1275 Vector3 scale(10.0f, 10.0f, 10.0f);
1277 Actor actor = Actor::New();
1279 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1280 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1282 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1284 actor.SetScale(scale.x, scale.y, scale.z);
1285 // flush the queue and render once
1286 application.SendNotification();
1287 application.Render();
1288 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1290 // add to stage and test
1291 Stage::GetCurrent().Add( actor );
1292 actor.SetScale( 2.0f, 2.0f, 2.0f );
1293 // flush the queue and render once
1294 application.SendNotification();
1295 application.Render();
1296 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1298 Stage::GetCurrent().Remove( actor );
1303 // SetScale(Vector3 scale)
1304 int UtcDaliActorSetScale03(void)
1306 TestApplication application;
1307 Vector3 scale(10.0f, 10.0f, 10.0f);
1309 Actor actor = Actor::New();
1311 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1312 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1314 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1316 actor.SetScale(scale);
1318 // flush the queue and render once
1319 application.SendNotification();
1320 application.Render();
1322 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1326 int UtcDaliActorScaleBy(void)
1328 TestApplication application;
1329 Actor actor = Actor::New();
1330 Vector3 vector(100.0f, 100.0f, 100.0f);
1332 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1334 actor.SetScale(vector);
1336 // flush the queue and render once
1337 application.SendNotification();
1338 application.Render();
1340 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1342 actor.ScaleBy(vector);
1344 // flush the queue and render once
1345 application.SendNotification();
1346 application.Render();
1348 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1352 int UtcDaliActorGetCurrentScale(void)
1354 TestApplication application;
1355 Vector3 scale(12.0f, 1.0f, 2.0f);
1357 Actor actor = Actor::New();
1359 actor.SetScale(scale);
1361 // flush the queue and render once
1362 application.SendNotification();
1363 application.Render();
1365 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1369 int UtcDaliActorGetCurrentWorldScale(void)
1371 TestApplication application;
1373 Actor parent = Actor::New();
1374 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1375 parent.SetScale( parentScale );
1376 Stage::GetCurrent().Add( parent );
1378 Actor child = Actor::New();
1379 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1380 child.SetScale( childScale );
1381 parent.Add( child );
1383 // The actors should not have a scale yet
1384 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1385 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1387 // The actors should not have a world scale yet
1388 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1389 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1391 application.SendNotification();
1392 application.Render(0);
1394 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1395 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1397 // The actors should have a world scale now
1398 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1399 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1403 int UtcDaliActorInheritScale(void)
1405 tet_infoline("Testing Actor::SetInheritScale");
1406 TestApplication application;
1408 Actor parent = Actor::New();
1409 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1410 parent.SetScale( parentScale );
1411 Stage::GetCurrent().Add( parent );
1413 Actor child = Actor::New();
1414 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1415 child.SetScale( childScale );
1416 parent.Add( child );
1418 application.SendNotification();
1419 application.Render(0);
1421 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1422 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1424 child.SetInheritScale( false );
1425 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1427 application.SendNotification();
1428 application.Render(0);
1430 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1434 int UtcDaliActorSetVisible(void)
1436 TestApplication application;
1438 Actor actor = Actor::New();
1439 actor.SetVisible(false);
1440 // flush the queue and render once
1441 application.SendNotification();
1442 application.Render();
1443 DALI_TEST_CHECK(actor.IsVisible() == false);
1445 actor.SetVisible(true);
1446 // flush the queue and render once
1447 application.SendNotification();
1448 application.Render();
1449 DALI_TEST_CHECK(actor.IsVisible() == true);
1451 // put actor on stage
1452 Stage::GetCurrent().Add( actor );
1453 actor.SetVisible(false);
1454 // flush the queue and render once
1455 application.SendNotification();
1456 application.Render();
1457 DALI_TEST_CHECK(actor.IsVisible() == false);
1461 int UtcDaliActorIsVisible(void)
1463 TestApplication application;
1465 Actor actor = Actor::New();
1467 DALI_TEST_CHECK(actor.IsVisible() == true);
1471 int UtcDaliActorSetOpacity(void)
1473 TestApplication application;
1475 Actor actor = Actor::New();
1476 // initial opacity is 1
1477 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1479 actor.SetOpacity( 0.4f);
1480 // flush the queue and render once
1481 application.SendNotification();
1482 application.Render();
1483 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1485 // change opacity, actor is on stage to change is not immediate
1486 actor.OpacityBy( 0.1f );
1487 // flush the queue and render once
1488 application.SendNotification();
1489 application.Render();
1490 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1492 // put actor on stage
1493 Stage::GetCurrent().Add( actor );
1495 // change opacity, actor is on stage to change is not immediate
1496 actor.SetOpacity( 0.9f );
1497 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1498 // flush the queue and render once
1499 application.SendNotification();
1500 application.Render();
1501 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1503 // change opacity, actor is on stage to change is not immediate
1504 actor.OpacityBy( -0.9f );
1505 // flush the queue and render once
1506 application.SendNotification();
1507 application.Render();
1508 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1512 int UtcDaliActorGetCurrentOpacity(void)
1514 TestApplication application;
1516 Actor actor = Actor::New();
1517 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1519 actor.SetOpacity(0.5f);
1520 // flush the queue and render once
1521 application.SendNotification();
1522 application.Render();
1523 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1527 int UtcDaliActorSetSensitive(void)
1529 TestApplication application;
1530 Actor actor = Actor::New();
1532 bool sensitive = !actor.IsSensitive();
1534 actor.SetSensitive(sensitive);
1536 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1540 int UtcDaliActorIsSensitive(void)
1542 TestApplication application;
1543 Actor actor = Actor::New();
1544 actor.SetSensitive(false);
1546 DALI_TEST_CHECK(false == actor.IsSensitive());
1550 int UtcDaliActorSetInheritShaderEffect(void)
1552 TestApplication application;
1554 Actor actor = Actor::New();
1556 actor.SetInheritShaderEffect(false);
1557 // flush the queue and render once
1558 application.SendNotification();
1559 application.Render();
1560 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == false);
1562 actor.SetInheritShaderEffect(true);
1563 // flush the queue and render once
1564 application.SendNotification();
1565 application.Render();
1566 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true);
1570 int UtcDaliActorGetInheritShaderEffect(void)
1572 TestApplication application;
1574 Actor actor = Actor::New();
1576 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true);
1580 int UtcDaliActorSetShaderEffect(void)
1582 TestApplication application;
1583 Actor actor = Actor::New();
1585 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1587 DALI_TEST_CHECK(effect != actor.GetShaderEffect());
1589 actor.SetShaderEffect(effect);
1591 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1595 int UtcDaliActorGetShaderEffect(void)
1597 TestApplication application;
1598 Actor actor = Actor::New();
1600 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1601 actor.SetShaderEffect(effect);
1603 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1607 int UtcDaliActorRemoveShaderEffect01(void)
1609 TestApplication application;
1610 Actor actor = Actor::New();
1612 ShaderEffect defaultEffect = actor.GetShaderEffect();
1614 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1615 actor.SetShaderEffect(effect);
1617 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1619 actor.RemoveShaderEffect();
1621 DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect());
1625 int UtcDaliActorRemoveShaderEffect02(void)
1627 TestApplication application;
1628 Actor actor = Actor::New();
1630 ShaderEffect defaultEffect = actor.GetShaderEffect();
1632 actor.RemoveShaderEffect();
1634 DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect());
1638 int UtcDaliActorSetColor(void)
1640 TestApplication application;
1641 Actor actor = Actor::New();
1642 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1644 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1646 actor.SetColor(color);
1647 // flush the queue and render once
1648 application.SendNotification();
1649 application.Render();
1650 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1652 actor.ColorBy( Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1653 // flush the queue and render once
1654 application.SendNotification();
1655 application.Render();
1656 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1658 Stage::GetCurrent().Add( actor );
1659 actor.SetColor( color );
1660 // flush the queue and render once
1661 application.SendNotification();
1662 application.Render();
1663 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1665 actor.ColorBy( Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1666 // flush the queue and render once
1667 application.SendNotification();
1668 application.Render();
1669 // Actor color is not clamped
1670 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1671 // world color is clamped
1672 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1674 Stage::GetCurrent().Remove( actor );
1678 int UtcDaliActorGetCurrentColor(void)
1680 TestApplication application;
1681 Actor actor = Actor::New();
1682 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1684 actor.SetColor(color);
1685 // flush the queue and render once
1686 application.SendNotification();
1687 application.Render();
1688 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1692 int UtcDaliActorGetCurrentWorldColor(void)
1694 tet_infoline("Actor::GetCurrentWorldColor");
1695 TestApplication application;
1697 Actor parent = Actor::New();
1698 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1699 parent.SetColor( parentColor );
1700 Stage::GetCurrent().Add( parent );
1702 Actor child = Actor::New();
1703 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1704 child.SetColor( childColor );
1705 parent.Add( child );
1707 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1708 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1710 // verify the default color mode
1711 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1713 // The actors should not have a world color yet
1714 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1715 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1717 application.SendNotification();
1718 application.Render(0);
1720 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1721 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1723 // The actors should have a world color now
1724 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1725 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1728 child.SetColorMode( USE_OWN_COLOR );
1729 application.SendNotification();
1730 application.Render(0);
1731 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1734 child.SetColorMode( USE_PARENT_COLOR );
1735 application.SendNotification();
1736 application.Render(0);
1737 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1738 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1741 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1742 application.SendNotification();
1743 application.Render(0);
1744 Vector4 expectedColor( childColor );
1745 expectedColor.a *= parentColor.a;
1746 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1747 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1751 int UtcDaliActorSetColorMode(void)
1753 tet_infoline("Actor::SetColorMode");
1754 TestApplication application;
1755 Actor actor = Actor::New();
1756 Actor child = Actor::New();
1759 actor.SetColorMode( USE_OWN_COLOR );
1760 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1762 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1763 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1765 actor.SetColorMode( USE_PARENT_COLOR );
1766 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1768 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1769 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1773 int UtcDaliActorScreenToLocal(void)
1775 TestApplication application;
1776 Actor actor = Actor::New();
1777 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1778 actor.SetSize(100.0f, 100.0f);
1779 actor.SetPosition(10.0f, 10.0f);
1780 Stage::GetCurrent().Add(actor);
1782 // flush the queue and render once
1783 application.SendNotification();
1784 application.Render();
1789 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1791 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1792 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1796 int UtcDaliActorSetLeaveRequired(void)
1798 TestApplication application;
1800 Actor actor = Actor::New();
1802 actor.SetLeaveRequired(false);
1803 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1805 actor.SetLeaveRequired(true);
1806 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1810 int UtcDaliActorGetLeaveRequired(void)
1812 TestApplication application;
1814 Actor actor = Actor::New();
1816 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1820 int UtcDaliActorSetKeyboardFocusable(void)
1822 TestApplication application;
1824 Actor actor = Actor::New();
1826 actor.SetKeyboardFocusable(true);
1827 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1829 actor.SetKeyboardFocusable(false);
1830 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1834 int UtcDaliActorIsKeyboardFocusable(void)
1836 TestApplication application;
1838 Actor actor = Actor::New();
1840 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1845 int UtcDaliActorApplyConstraint(void)
1847 TestApplication application;
1849 gTestConstraintCalled = false;
1851 Actor actor = Actor::New();
1853 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1854 actor.ApplyConstraint(constraint);
1856 DALI_TEST_CHECK( gTestConstraintCalled == false );
1858 Stage::GetCurrent().Add( actor );
1860 // flush the queue and render once
1861 application.SendNotification();
1862 application.Render();
1864 DALI_TEST_CHECK( gTestConstraintCalled == true );
1869 int UtcDaliActorApplyConstraintAppliedCallback(void)
1871 TestApplication application;
1873 // Build a reusable constraint
1875 Actor parent = Actor::New();
1876 Vector3 parentSize( 100.0f, 100.0f, 100.0f );
1877 parent.SetSize( parentSize );
1878 Stage::GetCurrent().Add( parent );
1880 Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
1881 Source( parent, Actor::SIZE ),
1882 EqualToConstraint() );
1884 // Create some child actors
1886 Actor child1 = Actor::New();
1887 parent.Add( child1 );
1889 Actor child2 = Actor::New();
1890 parent.Add( child2 );
1892 Actor child3 = Actor::New();
1893 parent.Add( child3 );
1895 // Apply constraint with different timings - everything should be finished after 10 seconds
1897 wasConstraintCallbackCalled1 = false;
1898 wasConstraintCallbackCalled2 = false;
1899 wasConstraintCallbackCalled3 = false;
1901 constraint.SetApplyTime( 5.0f );
1902 ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
1903 activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
1905 constraint.SetApplyTime( 10.0f );
1906 ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
1907 activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
1909 constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
1910 ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
1911 activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
1913 DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1914 DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1915 DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1917 application.SendNotification();
1919 application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
1920 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
1921 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
1922 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1924 // Check signals have not fired
1925 application.SendNotification();
1926 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1927 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1928 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1930 application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
1931 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40%
1932 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
1933 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1935 // Check signals have not fired
1936 application.SendNotification();
1937 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1938 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1939 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1941 application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
1942 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60%
1943 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
1944 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
1946 // Check signals have not fired
1947 application.SendNotification();
1948 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1949 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1950 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1952 application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
1953 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80%
1954 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
1955 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
1957 // Check signals have not fired
1958 application.SendNotification();
1959 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1960 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1961 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1963 application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
1964 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100%
1965 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
1966 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
1968 // Check signals have not fired
1969 application.SendNotification();
1970 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1971 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1972 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1974 application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
1975 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire)
1976 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
1977 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
1979 // 1st signal should have fired
1980 application.SendNotification();
1981 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
1982 wasConstraintCallbackCalled1 = false;
1983 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1984 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1986 application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
1987 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1988 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
1989 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
1991 // Check signals have not fired
1992 application.SendNotification();
1993 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1994 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1995 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1997 application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
1998 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1999 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
2000 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire)
2002 // 3rd signal should have fired
2003 application.SendNotification();
2005 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2006 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2007 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
2008 wasConstraintCallbackCalled3 = false;
2010 application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
2011 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2012 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
2013 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2015 // Check signals have not fired
2016 application.SendNotification();
2017 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2018 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2019 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2021 application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
2022 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2023 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire)
2024 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2026 // 2nd signal should have fired
2027 application.SendNotification();
2028 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2029 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
2030 wasConstraintCallbackCalled2 = false;
2031 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2033 // Check that nothing has changed after a couple of buffer swaps
2035 application.Render(0);
2036 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2037 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2038 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2040 application.SendNotification();
2041 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2042 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2043 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2045 application.Render(0);
2046 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2047 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2048 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2050 application.SendNotification();
2051 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2052 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2053 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2057 int UtcDaliActorRemoveConstraints(void)
2059 tet_infoline(" UtcDaliActorRemoveConstraints");
2060 TestApplication application;
2062 gTestConstraintCalled = false;
2064 Actor actor = Actor::New();
2066 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
2067 actor.ApplyConstraint(constraint);
2068 actor.RemoveConstraints();
2070 DALI_TEST_CHECK( gTestConstraintCalled == false );
2072 Stage::GetCurrent().Add( actor );
2073 actor.ApplyConstraint(constraint);
2075 // flush the queue and render once
2076 application.SendNotification();
2077 application.Render();
2079 actor.RemoveConstraints();
2081 DALI_TEST_CHECK( gTestConstraintCalled == true );
2085 int UtcDaliActorRemoveConstraint(void)
2087 tet_infoline(" UtcDaliActorRemoveConstraint");
2088 TestApplication application;
2090 Actor actor = Actor::New();
2092 // 1. Apply Constraint1 and Constraint2, and test...
2093 unsigned int result1 = 0u;
2094 unsigned int result2 = 0u;
2095 ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2096 ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) ) );
2098 Stage::GetCurrent().Add( actor );
2099 // flush the queue and render once
2100 application.SendNotification();
2101 application.Render();
2103 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2104 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2106 // 2. Remove Constraint1 and test...
2109 actor.RemoveConstraint(activeConstraint1);
2110 // make color property dirty, which will trigger constraints to be reapplied.
2111 actor.SetColor( Color::WHITE );
2112 // flush the queue and render once
2113 application.SendNotification();
2114 application.Render();
2116 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2117 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2119 // 3. Re-Apply Constraint1 and test...
2122 activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2123 // make color property dirty, which will trigger constraints to be reapplied.
2124 actor.SetColor( Color::WHITE );
2125 // flush the queue and render once
2126 application.SendNotification();
2127 application.Render();
2129 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2130 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2132 // 2. Remove Constraint2 and test...
2135 actor.RemoveConstraint(activeConstraint2);
2136 // make color property dirty, which will trigger constraints to be reapplied.
2137 actor.SetColor( Color::WHITE );
2138 // flush the queue and render once
2139 application.SendNotification();
2140 application.Render();
2142 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2143 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2145 // 2. Remove Constraint1 as well and test...
2148 actor.RemoveConstraint(activeConstraint1);
2149 // make color property dirty, which will trigger constraints to be reapplied.
2150 actor.SetColor( Color::WHITE );
2151 // flush the queue and render once
2152 application.SendNotification();
2153 application.Render();
2155 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2156 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2161 int UtcDaliActorTouchedSignal(void)
2163 TestApplication application;
2165 gTouchCallBackCalled = false;
2167 // get the root layer
2168 Actor actor = Stage::GetCurrent().GetRootLayer();
2169 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2171 application.SendNotification();
2172 application.Render();
2174 // connect to its touch signal
2175 actor.TouchedSignal().Connect( TestCallback );
2177 // simulate a touch event in the middle of the screen
2178 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2179 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
2180 Dali::Integration::TouchEvent event;
2181 event.AddPoint( point );
2182 application.ProcessEvent( event );
2184 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2189 int UtcDaliActorSetSizeSignal(void)
2191 TestApplication application;
2193 Actor actor = Actor::New();
2194 actor.SetSizeSignal().Connect( SetSizeCallback );
2196 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2197 gSetSizeCallBackCalled = false;
2198 Vector2 size2d( 1.0f, 2.0f );
2199 actor.SetSize( size2d );
2200 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2201 // SetSize with Vector2 sets depth to be the minimum of width & height
2202 DALI_TEST_EQUALS( Vector3( 1.0f, 2.0f, 1.0f ), gSetSize, TEST_LOCATION );
2204 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2205 gSetSizeCallBackCalled = false;
2206 actor.SetSize( 22.0f, 11.0f );
2207 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2208 // SetSize with Vector2 sets depth to be the minimum of width & height
2209 DALI_TEST_EQUALS( Vector3( 22.0f, 11.0f, 11.0f ), gSetSize, TEST_LOCATION );
2211 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2212 gSetSizeCallBackCalled = false;
2213 Vector3 size( 3.0f, 4.0f, 5.0f );
2214 actor.SetSize( size );
2215 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2216 DALI_TEST_EQUALS( size, gSetSize, TEST_LOCATION );
2218 // add actor to stage to see that signal still works
2219 Stage::GetCurrent().Add( actor );
2221 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2222 gSetSizeCallBackCalled = false;
2223 actor.SetSize( -1.0f, -2.0f, -3.0f );
2224 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2225 DALI_TEST_EQUALS( Vector3( -1.0f, -2.0f, -3.0f ), gSetSize, TEST_LOCATION );
2229 int UtcDaliActorOnOffStageSignal(void)
2231 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2233 TestApplication application;
2236 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2237 gActorNamesOnOffStage.clear();
2239 Actor parent = Actor::New();
2240 parent.SetName( "parent" );
2241 parent.OnStageSignal().Connect( OnStageCallback );
2242 parent.OffStageSignal().Connect( OffStageCallback );
2244 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2245 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2247 // add parent to stage
2248 Stage::GetCurrent().Add( parent );
2249 // onstage emitted, offstage not
2250 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2251 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2252 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2254 // test adding a child, should get onstage emitted
2256 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2257 gActorNamesOnOffStage.clear();
2259 Actor child = Actor::New();
2260 child.SetName( "child" );
2261 child.OnStageSignal().Connect( OnStageCallback );
2262 child.OffStageSignal().Connect( OffStageCallback );
2263 parent.Add( child ); // add child
2264 // onstage emitted, offstage not
2265 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2266 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2267 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2269 // test removing parent from stage
2271 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2272 gActorNamesOnOffStage.clear();
2274 Stage::GetCurrent().Remove( parent );
2275 // onstage not emitted, offstage is
2276 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2277 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2278 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2279 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2281 // test adding parent back to stage
2283 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2284 gActorNamesOnOffStage.clear();
2286 Stage::GetCurrent().Add( parent );
2287 // onstage emitted, offstage not
2288 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2289 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2290 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2291 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2293 // test removing child
2295 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2296 gActorNamesOnOffStage.clear();
2298 parent.Remove( child );
2299 // onstage not emitted, offstage is
2300 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2301 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2302 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2304 // test removing parent
2306 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2307 gActorNamesOnOffStage.clear();
2309 Stage::GetCurrent().Remove( parent );
2310 // onstage not emitted, offstage is
2311 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2312 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2313 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2317 int UtcDaliActorFindChildByName(void)
2319 tet_infoline("Testing Dali::Actor::FindChildByName()");
2320 TestApplication application;
2322 Actor parent = Actor::New();
2323 parent.SetName( "parent" );
2324 Actor first = Actor::New();
2325 first .SetName( "first" );
2326 Actor second = Actor::New();
2327 second.SetName( "second" );
2332 Actor found = parent.FindChildByName( "foo" );
2333 DALI_TEST_CHECK( !found );
2335 found = parent.FindChildByName( "parent" );
2336 DALI_TEST_CHECK( found == parent );
2338 found = parent.FindChildByName( "first" );
2339 DALI_TEST_CHECK( found == first );
2341 found = parent.FindChildByName( "second" );
2342 DALI_TEST_CHECK( found == second );
2346 int UtcDaliActorFindChildByAlias(void)
2348 tet_infoline("Testing Dali::Actor::FindChildByAlias()");
2349 TestApplication application;
2351 Actor parent = Actor::New();
2352 parent.SetName( "parent" );
2353 Actor first = Actor::New();
2354 first .SetName( "first" );
2355 Actor second = Actor::New();
2356 second.SetName( "second" );
2361 Actor found = parent.FindChildByAlias( "foo" );
2362 DALI_TEST_CHECK( !found );
2364 found = parent.FindChildByAlias( "parent" );
2365 DALI_TEST_CHECK( found == parent );
2367 found = parent.FindChildByAlias( "first" );
2368 DALI_TEST_CHECK( found == first );
2370 found = parent.FindChildByAlias( "second" );
2371 DALI_TEST_CHECK( found == second );
2375 int UtcDaliActorFindChildById(void)
2377 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2378 TestApplication application;
2380 Actor parent = Actor::New();
2381 Actor first = Actor::New();
2382 Actor second = Actor::New();
2387 Actor found = parent.FindChildById( 100000 );
2388 DALI_TEST_CHECK( !found );
2390 found = parent.FindChildById( parent.GetId() );
2391 DALI_TEST_CHECK( found == parent );
2393 found = parent.FindChildById( first.GetId() );
2394 DALI_TEST_CHECK( found == first );
2396 found = parent.FindChildById( second.GetId() );
2397 DALI_TEST_CHECK( found == second );
2401 int UtcDaliActorHitTest(void)
2406 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2408 mTouchPoint( touchPoint ),
2413 Vector2 mTouchPoint;
2417 TestApplication application;
2418 tet_infoline(" UtcDaliActorHitTest");
2420 // Fill a vector with different hit tests.
2421 struct HitTestData* hitTestData[] = {
2422 // scale touch point result
2423 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2424 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2425 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.
2426 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2427 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.
2431 // get the root layer
2432 Actor actor = Actor::New();
2433 actor.SetAnchorPoint( AnchorPoint::CENTER );
2434 actor.SetParentOrigin( ParentOrigin::CENTER );
2436 Stage::GetCurrent().Add( actor );
2438 gTouchCallBackCalled = false;
2440 unsigned int index = 0;
2441 while( NULL != hitTestData[index] )
2443 actor.SetSize( 1.f, 1.f );
2444 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2446 // flush the queue and render once
2447 application.SendNotification();
2448 application.Render();
2450 DALI_TEST_CHECK( !gTouchCallBackCalled );
2452 // connect to its touch signal
2453 actor.TouchedSignal().Connect(TestCallback);
2455 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2456 Dali::Integration::TouchEvent event;
2457 event.AddPoint( point );
2459 // flush the queue and render once
2460 application.SendNotification();
2461 application.Render();
2462 application.ProcessEvent( event );
2464 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2466 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2467 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2468 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2469 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2470 hitTestData[index]->mResult );
2472 gTouchCallBackCalled = false;
2478 int UtcDaliActorSetDrawMode(void)
2480 TestApplication app;
2481 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2483 Actor a = Actor::New();
2485 Stage::GetCurrent().Add(a);
2486 app.SendNotification();
2488 app.SendNotification();
2491 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2493 a.SetDrawMode( DrawMode::OVERLAY );
2494 app.SendNotification();
2497 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2499 a.SetDrawMode( DrawMode::STENCIL );
2500 app.SendNotification();
2503 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2505 a.SetDrawMode( DrawMode::NORMAL );
2506 app.SendNotification();
2509 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2513 int UtcDaliActorSetDrawModeOverlayRender(void)
2515 TestApplication app;
2516 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2518 app.SendNotification();
2521 std::vector<GLuint> ids;
2522 ids.push_back( 8 ); // first rendered actor
2523 ids.push_back( 9 ); // second rendered actor
2524 ids.push_back( 10 ); // third rendered actor
2525 app.GetGlAbstraction().SetNextTextureIds( ids );
2527 BitmapImage imageA = BitmapImage::New(16, 16);
2528 BitmapImage imageB = BitmapImage::New(16, 16);
2529 BitmapImage imageC = BitmapImage::New(16, 16);
2530 ImageActor a = ImageActor::New( imageA );
2531 ImageActor b = ImageActor::New( imageB );
2532 ImageActor c = ImageActor::New( imageC );
2534 // Render a,b,c as regular non-overlays. so order will be:
2538 Stage::GetCurrent().Add(a);
2539 Stage::GetCurrent().Add(b);
2540 Stage::GetCurrent().Add(c);
2542 app.SendNotification();
2545 // Should be 3 textures changes.
2546 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2547 typedef std::vector<GLuint>::size_type TextureSize;
2548 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2549 if( boundTextures.size() == 3 )
2551 DALI_TEST_CHECK( boundTextures[0] == 8u );
2552 DALI_TEST_CHECK( boundTextures[1] == 9u );
2553 DALI_TEST_CHECK( boundTextures[2] == 10u );
2556 // Now texture ids have been set, we can monitor their render order.
2557 // render a as an overlay (last), so order will be:
2561 a.SetDrawMode( DrawMode::OVERLAY );
2562 app.GetGlAbstraction().ClearBoundTextures();
2564 app.SendNotification();
2567 // Should be 3 texture changes.
2568 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2569 if( boundTextures.size() == 3 )
2571 DALI_TEST_CHECK( boundTextures[0] == 9u );
2572 DALI_TEST_CHECK( boundTextures[1] == 10u );
2573 DALI_TEST_CHECK( boundTextures[2] == 8u );
2579 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2581 TestApplication app;
2582 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2584 BitmapImage imageA = BitmapImage::New(16, 16);
2585 BitmapImage imageB = BitmapImage::New(16, 16);
2586 ImageActor a = ImageActor::New( imageA );
2587 ImageActor b = ImageActor::New( imageB );
2589 // Render a,b as regular non-overlays. so order will be:
2590 Stage::GetCurrent().Add(a);
2591 Stage::GetCurrent().Add(b);
2593 a.SetSize(Vector2(100.0f, 100.0f));
2594 b.SetSize(Vector2(100.0f, 100.0f));
2596 // position b overlapping a. (regular non-overlays)
2597 // hit test at point 'x'
2608 // note: b is on top, because it's Z position is higher.
2609 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2610 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2612 // connect to their touch signals
2613 a.TouchedSignal().Connect(TestCallback);
2614 b.TouchedSignal().Connect(TestCallback2);
2616 a.SetDrawMode( DrawMode::NORMAL );
2617 b.SetDrawMode( DrawMode::NORMAL );
2618 SimulateTouchForSetOverlayHitTest(app);
2620 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2621 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2622 // Make Actor a an overlay.
2633 // note: a is on top, because it is an overlay.
2634 a.SetDrawMode( DrawMode::OVERLAY );
2635 b.SetDrawMode( DrawMode::NORMAL );
2636 SimulateTouchForSetOverlayHitTest(app);
2638 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2639 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2640 // Make both Actors as overlays
2651 // note: b is on top, because it is the 2nd child in the hierarchy.
2652 a.SetDrawMode( DrawMode::OVERLAY );
2653 b.SetDrawMode( DrawMode::OVERLAY );
2654 SimulateTouchForSetOverlayHitTest(app);
2656 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2657 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2661 int UtcDaliActorGetCurrentWorldMatrix(void)
2663 TestApplication app;
2664 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2666 Actor parent = Actor::New();
2667 parent.SetParentOrigin(ParentOrigin::CENTER);
2668 parent.SetAnchorPoint(AnchorPoint::CENTER);
2669 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2670 Radian rotationAngle(Degree(85.0f));
2671 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2672 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2673 parent.SetPosition( parentPosition );
2674 parent.SetRotation( parentRotation );
2675 parent.SetScale( parentScale );
2676 Stage::GetCurrent().Add( parent );
2678 Actor child = Actor::New();
2679 child.SetParentOrigin(ParentOrigin::CENTER);
2680 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2681 Radian childRotationAngle(Degree(23.0f));
2682 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2683 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2684 child.SetPosition( childPosition );
2685 child.SetRotation( childRotation );
2686 child.SetScale( childScale );
2687 parent.Add( child );
2689 // The actors should not have a world matrix yet
2690 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2691 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2693 app.SendNotification();
2696 app.SendNotification();
2698 Matrix parentMatrix(false);
2699 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2701 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2702 Quaternion childWorldRotation = parentRotation * childRotation;
2703 Vector3 childWorldScale = parentScale * childScale;
2705 Matrix childWorldMatrix(false);
2706 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2708 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2709 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2715 int UtcDaliActorConstrainedToWorldMatrix(void)
2717 TestApplication app;
2718 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2720 Actor parent = Actor::New();
2721 parent.SetParentOrigin(ParentOrigin::CENTER);
2722 parent.SetAnchorPoint(AnchorPoint::CENTER);
2723 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2724 Radian rotationAngle(Degree(85.0f));
2725 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2726 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2727 parent.SetPosition( parentPosition );
2728 parent.SetRotation( parentRotation );
2729 parent.SetScale( parentScale );
2730 Stage::GetCurrent().Add( parent );
2732 Actor child = Actor::New();
2733 child.SetParentOrigin(ParentOrigin::CENTER);
2734 Constraint posConstraint = Constraint::New<Vector3>( Actor::POSITION, Source( parent, Actor::WORLD_MATRIX), PositionComponentConstraint() );
2735 child.ApplyConstraint(posConstraint);
2737 Stage::GetCurrent().Add( child );
2739 // The actors should not have a world matrix yet
2740 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2741 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2743 app.SendNotification();
2746 app.SendNotification();
2748 Matrix parentMatrix(false);
2749 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2751 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2752 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2756 int UtcDaliActorUnparent(void)
2758 TestApplication app;
2759 tet_infoline(" UtcDaliActorUnparent");
2761 Actor parent = Actor::New();
2762 Stage::GetCurrent().Add( parent );
2764 Actor child = Actor::New();
2766 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2767 DALI_TEST_CHECK( !child.GetParent() );
2769 // Test that calling Unparent with no parent is a NOOP
2772 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2773 DALI_TEST_CHECK( !child.GetParent() );
2775 // Test that Unparent works
2776 parent.Add( child );
2778 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2779 DALI_TEST_CHECK( parent == child.GetParent() );
2783 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2784 DALI_TEST_CHECK( !child.GetParent() );
2786 // Test that UnparentAndReset works
2787 parent.Add( child );
2789 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2790 DALI_TEST_CHECK( parent == child.GetParent() );
2792 UnparentAndReset( child );
2794 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2795 DALI_TEST_CHECK( !child );
2797 // Test that UnparentAndReset is a NOOP with empty handle
2798 UnparentAndReset( child );
2800 DALI_TEST_CHECK( !child );
2804 int UtcDaliActorGetChildAt(void)
2806 TestApplication app;
2807 tet_infoline(" UtcDaliActorGetChildAt");
2809 Actor parent = Actor::New();
2810 Stage::GetCurrent().Add( parent );
2812 Actor child0 = Actor::New();
2813 parent.Add( child0 );
2815 Actor child1 = Actor::New();
2816 parent.Add( child1 );
2818 Actor child2 = Actor::New();
2819 parent.Add( child2 );
2821 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2822 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2823 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2827 int UtcDaliActorSetGetOverlay(void)
2829 TestApplication app;
2830 tet_infoline(" UtcDaliActorSetGetOverlay");
2832 Actor parent = Actor::New();
2833 parent.SetDrawMode(DrawMode::OVERLAY );
2834 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2839 // Current Dynamics functions are crashing, so testing these sections are futile
2841 int UtcDaliActorDynamics(void)
2843 DALI_TEST_CHECK( true );
2847 int UtcDaliActorCreateDestroy(void)
2849 Actor* actor = new Actor;
2850 DALI_TEST_CHECK( actor );