2 * Copyright (c) 2014 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 <dali/integration-api/events/touch-event-integ.h>
22 #include <dali-test-suite-utils.h>
30 void utc_dali_actor_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_actor_cleanup(void)
37 test_return_value = TET_PASS;
43 bool gTouchCallBackCalled=false;
44 bool gTouchCallBack2Called=false;
47 * Simulates a Down Touch at 25.0, 25.0.
48 * @param[in] app Test Application instance.
50 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
52 app.SendNotification();
54 app.SendNotification();
57 gTouchCallBackCalled = false;
58 gTouchCallBack2Called = 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 Vector4 operator()(const Vector4& color)
80 gTestConstraintCalled = true;
81 return Vector4(color.x, color.y, color.z, 0.1f);
86 * TestConstraint reference.
87 * When constraint is called, the resultRef is updated
88 * with the value supplied.
91 struct TestConstraintRef
93 TestConstraintRef(unsigned int& resultRef, unsigned int value)
94 : mResultRef(resultRef),
99 T operator()(const T& current)
105 unsigned int& mResultRef;
109 bool wasConstraintCallbackCalled1 = false;
110 void TestConstraintCallback1( ActiveConstraint& constraint )
112 wasConstraintCallbackCalled1 = true;
115 bool wasConstraintCallbackCalled2 = false;
116 void TestConstraintCallback2( ActiveConstraint& constraint )
118 wasConstraintCallbackCalled2 = true;
121 bool wasConstraintCallbackCalled3 = false;
122 void TestConstraintCallback3( ActiveConstraint& constraint )
124 wasConstraintCallbackCalled3 = true;
127 static bool TestCallback(Actor actor, const TouchEvent& event)
129 gTouchCallBackCalled = true;
134 static bool TestCallback2(Actor actor, const TouchEvent& event)
136 gTouchCallBack2Called = true;
141 static Vector3 gSetSize;
142 static bool gSetSizeCallBackCalled;
143 void SetSizeCallback( Actor actor, const Vector3& size )
145 gSetSizeCallBackCalled = true;
148 // validation stuff for onstage & offstage signals
149 static std::vector< std::string > gActorNamesOnOffStage;
150 static int gOnStageCallBackCalled;
151 void OnStageCallback( Actor actor )
153 ++gOnStageCallBackCalled;
154 gActorNamesOnOffStage.push_back( actor.GetName() );
155 DALI_TEST_CHECK( actor.OnStage() == true );
157 static int gOffStageCallBackCalled;
158 void OffStageCallback( Actor actor )
160 ++gOffStageCallBackCalled;
161 gActorNamesOnOffStage.push_back( actor.GetName() );
162 DALI_TEST_CHECK( actor.OnStage() == false );
165 struct PositionComponentConstraint
167 PositionComponentConstraint(){}
169 Vector3 operator()(const Vector3& current, const PropertyInput& property)
171 const Matrix& m = property.GetMatrix();
175 m.GetTransformComponents(pos, rot, scale);
182 } // anonymous namespace
185 //& purpose: Testing New API
186 int UtcDaliActorNew(void)
188 TestApplication application;
190 Actor actor = Actor::New();
192 DALI_TEST_CHECK(actor);
196 //& purpose: Testing Dali::Actor::DownCast()
197 int UtcDaliActorDownCast(void)
199 TestApplication application;
200 tet_infoline("Testing Dali::Actor::DownCast()");
202 Actor actor = Actor::New();
203 BaseHandle object(actor);
204 Actor actor2 = Actor::DownCast(object);
205 DALI_TEST_CHECK(actor2);
209 //& purpose: Testing Dali::Actor::DownCast()
210 int UtcDaliActorDownCast2(void)
212 TestApplication application;
213 tet_infoline("Testing Dali::Actor::DownCast()");
215 BaseHandle unInitializedObject;
216 Actor actor = Actor::DownCast(unInitializedObject);
217 DALI_TEST_CHECK(!actor);
221 //& purpose: Testing Dali::Actor::GetName()
222 int UtcDaliActorGetName(void)
224 TestApplication application;
226 Actor actor = Actor::New();
228 DALI_TEST_CHECK(actor.GetName().empty());
232 //& purpose: Testing Dali::Actor::SetName()
233 int UtcDaliActorSetName(void)
235 TestApplication application;
237 string str("ActorName");
238 Actor actor = Actor::New();
241 DALI_TEST_CHECK(actor.GetName() == str);
245 int UtcDaliActorGetId(void)
247 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
248 TestApplication application;
250 Actor first = Actor::New();
251 Actor second = Actor::New();
252 Actor third = Actor::New();
254 DALI_TEST_CHECK(first.GetId() != second.GetId());
255 DALI_TEST_CHECK(second.GetId() != third.GetId());
259 int UtcDaliActorIsRoot(void)
261 TestApplication application;
263 Actor actor = Actor::New();
264 DALI_TEST_CHECK(!actor.IsRoot());
266 // get the root layer
267 actor = Stage::GetCurrent().GetLayer( 0 );
268 DALI_TEST_CHECK( actor.IsRoot() );
272 int UtcDaliActorOnStage(void)
274 TestApplication application;
276 Actor actor = Actor::New();
277 DALI_TEST_CHECK( !actor.OnStage() );
279 // get the root layer
280 actor = Stage::GetCurrent().GetLayer( 0 );
281 DALI_TEST_CHECK( actor.OnStage() );
285 int UtcDaliActorIsLayer(void)
287 TestApplication application;
289 Actor actor = Actor::New();
290 DALI_TEST_CHECK( !actor.IsLayer() );
292 // get the root layer
293 actor = Stage::GetCurrent().GetLayer( 0 );
294 DALI_TEST_CHECK( actor.IsLayer() );
298 int UtcDaliActorGetLayer(void)
300 TestApplication application;
302 Actor actor = Actor::New();
303 Stage::GetCurrent().Add(actor);
304 Layer layer = actor.GetLayer();
306 DALI_TEST_CHECK(layer);
308 // get the root layers layer
309 actor = Stage::GetCurrent().GetLayer( 0 );
310 DALI_TEST_CHECK( actor.GetLayer() );
314 int UtcDaliActorAdd(void)
316 tet_infoline("Testing Actor::Add");
317 TestApplication application;
319 Actor parent = Actor::New();
320 Actor child = Actor::New();
322 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
326 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
328 Actor parent2 = Actor::New();
329 parent2.Add( child );
331 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
332 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
334 // try Adding to same parent again, works
335 parent2.Add( child );
336 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
338 // try reparenting an orphaned child
340 Actor temporaryParent = Actor::New();
341 temporaryParent.Add( child );
342 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
344 // temporaryParent has now died, reparent the orphaned child
345 parent2.Add( child );
346 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
351 parent2.Add( parent2 );
352 tet_printf("Assertion test failed - no Exception\n" );
353 tet_result(TET_FAIL);
355 catch(Dali::DaliException& e)
357 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
358 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
359 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
363 tet_printf("Assertion test failed - wrong Exception\n" );
364 tet_result(TET_FAIL);
367 // try reparenting root
370 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
371 tet_printf("Assertion test failed - no Exception\n" );
372 tet_result(TET_FAIL);
374 catch(Dali::DaliException& e)
376 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
377 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
378 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
382 tet_printf("Assertion test failed - wrong Exception\n" );
383 tet_result(TET_FAIL);
390 parent2.Add( empty );
391 tet_printf("Assertion test failed - no Exception\n" );
392 tet_result(TET_FAIL);
394 catch(Dali::DaliException& e)
396 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
397 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
398 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
402 tet_printf("Assertion test failed - wrong Exception\n" );
403 tet_result(TET_FAIL);
408 int UtcDaliActorInsert(void)
410 tet_infoline("Testing Actor::Insert");
411 TestApplication application;
413 Actor parent = Actor::New();
414 Stage::GetCurrent().Add( parent );
415 Actor first = Actor::New();
416 Actor second = Actor::New();
417 Actor third = Actor::New();
419 parent.Insert(1, first); // test insert beyond range
420 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
421 parent.Insert(0, second);
422 DALI_TEST_EQUALS( parent.GetChildCount(), 2u, TEST_LOCATION );
423 parent.Insert(1, third);
425 DALI_TEST_EQUALS( parent.GetChildCount(), 3u, TEST_LOCATION );
427 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
428 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
429 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
435 int UtcDaliActorRemove01(void)
437 tet_infoline("Testing Actor::Remove");
438 TestApplication application;
440 Actor parent = Actor::New();
441 Actor child = Actor::New();
442 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
445 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
447 parent.Remove(child);
448 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
450 // remove again, no problem
451 parent.Remove(child);
452 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
456 // try illegal Remove
459 parent.Remove( parent );
460 tet_printf("Assertion test failed - no Exception\n" );
461 tet_result(TET_FAIL);
463 catch(Dali::DaliException& e)
465 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
466 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
467 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
471 tet_printf("Assertion test failed - wrong Exception\n" );
472 tet_result(TET_FAIL);
479 parent.Remove( empty );
480 tet_printf("Assertion test failed - no Exception\n" );
481 tet_result(TET_FAIL);
483 catch(Dali::DaliException& e)
485 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
486 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
487 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
491 tet_printf("Assertion test failed - wrong Exception\n" );
492 tet_result(TET_FAIL);
497 int UtcDaliActorRemove02(void)
499 TestApplication application;
501 Actor parent = Actor::New();
502 Actor child = Actor::New();
503 Actor random = Actor::New();
505 Stage::GetCurrent().Add( parent );
507 DALI_TEST_CHECK(parent.GetChildCount() == 0);
511 DALI_TEST_CHECK(parent.GetChildCount() == 1);
513 parent.Remove(random);
515 DALI_TEST_CHECK(parent.GetChildCount() == 1);
517 Stage::GetCurrent().Remove( parent );
519 DALI_TEST_CHECK(parent.GetChildCount() == 1);
523 int UtcDaliActorGetChildCount(void)
525 TestApplication application;
527 Actor parent = Actor::New();
528 Actor child = Actor::New();
530 DALI_TEST_CHECK(parent.GetChildCount() == 0);
534 DALI_TEST_CHECK(parent.GetChildCount() == 1);
538 int UtcDaliActorGetChildren01(void)
540 TestApplication application;
542 Actor parent = Actor::New();
543 Actor first = Actor::New();
544 Actor second = Actor::New();
545 Actor third = Actor::New();
551 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
552 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
553 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
557 int UtcDaliActorGetChildren02(void)
559 TestApplication application;
561 Actor parent = Actor::New();
562 Actor first = Actor::New();
563 Actor second = Actor::New();
564 Actor third = Actor::New();
570 const Actor& constParent = parent;
572 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
573 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
574 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
578 int UtcDaliActorGetParent01(void)
580 TestApplication application;
582 Actor parent = Actor::New();
583 Actor child = Actor::New();
587 DALI_TEST_CHECK(child.GetParent() == parent);
591 int UtcDaliActorGetParent02(void)
593 TestApplication application;
595 Actor actor = Actor::New();
597 DALI_TEST_CHECK(!actor.GetParent());
601 int UtcDaliActorSetParentOrigin(void)
603 TestApplication application;
605 Actor actor = Actor::New();
607 Vector3 vector(0.7f, 0.8f, 0.9f);
608 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
610 actor.SetParentOrigin(vector);
612 // flush the queue and render once
613 application.SendNotification();
614 application.Render();
616 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
618 Stage::GetCurrent().Add( actor );
620 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
622 // flush the queue and render once
623 application.SendNotification();
624 application.Render();
626 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
628 Stage::GetCurrent().Remove( actor );
632 int UtcDaliActorGetCurrentParentOrigin(void)
634 TestApplication application;
636 Actor actor = Actor::New();
638 Vector3 vector(0.7f, 0.8f, 0.9f);
639 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
641 actor.SetParentOrigin(vector);
643 // flush the queue and render once
644 application.SendNotification();
645 application.Render();
647 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
651 int UtcDaliActorSetAnchorPoint(void)
653 TestApplication application;
655 Actor actor = Actor::New();
657 Vector3 vector(0.7f, 0.8f, 0.9f);
658 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
660 actor.SetAnchorPoint(vector);
662 // flush the queue and render once
663 application.SendNotification();
664 application.Render();
666 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
668 Stage::GetCurrent().Add( actor );
670 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
671 // flush the queue and render once
672 application.SendNotification();
673 application.Render();
675 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
677 Stage::GetCurrent().Remove( actor );
681 int UtcDaliActorGetCurrentAnchorPoint(void)
683 TestApplication application;
685 Actor actor = Actor::New();
687 Vector3 vector(0.7f, 0.8f, 0.9f);
688 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
690 actor.SetAnchorPoint(vector);
692 // flush the queue and render once
693 application.SendNotification();
694 application.Render();
696 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
700 // SetSize(float width, float height)
701 int UtcDaliActorSetSize01(void)
703 TestApplication application;
705 Actor actor = Actor::New();
706 Vector3 vector(100.0f, 100.0f, 100.0f);
708 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
710 actor.SetSize(vector.x, vector.y);
712 // flush the queue and render once
713 application.SendNotification();
714 application.Render();
716 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
720 // SetSize(float width, float height, float depth)
721 int UtcDaliActorSetSize02(void)
723 TestApplication application;
725 Actor actor = Actor::New();
726 Vector3 vector(100.0f, 100.0f, 100.0f);
728 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
730 actor.SetSize(vector.x, vector.y, vector.z);
732 // flush the queue and render once
733 application.SendNotification();
734 application.Render();
736 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
740 // SetSize(Vector2 size)
741 int UtcDaliActorSetSize03(void)
743 TestApplication application;
745 Actor actor = Actor::New();
746 Vector3 vector(100.0f, 100.0f, 100.0f);
748 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
750 actor.SetSize(Vector2(vector.x, vector.y));
752 // flush the queue and render once
753 application.SendNotification();
754 application.Render();
756 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
760 // SetSize(Vector3 size)
761 int UtcDaliActorSetSize04(void)
763 TestApplication application;
765 Actor actor = Actor::New();
766 Vector3 vector(100.0f, 100.0f, 100.0f);
768 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
770 actor.SetSize(vector);
772 // flush the queue and render once
773 application.SendNotification();
774 application.Render();
776 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
778 Stage::GetCurrent().Add( actor );
779 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
781 // flush the queue and render once
782 application.SendNotification();
783 application.Render();
785 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
786 Stage::GetCurrent().Remove( actor );
790 int UtcDaliActorGetCurrentSize(void)
792 TestApplication application;
794 Actor actor = Actor::New();
795 Vector3 vector(100.0f, 100.0f, 20.0f);
797 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
799 actor.SetSize(vector);
801 // flush the queue and render once
802 application.SendNotification();
803 application.Render();
805 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
809 // SetPosition(float x, float y)
810 int UtcDaliActorSetPosition01(void)
812 TestApplication application;
814 Actor actor = Actor::New();
816 // Set to random to start off with
817 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
819 Vector3 vector(100.0f, 100.0f, 0.0f);
821 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
823 actor.SetPosition(vector.x, vector.y);
824 // flush the queue and render once
825 application.SendNotification();
826 application.Render();
827 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
829 Stage::GetCurrent().Add( actor );
830 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
831 // flush the queue and render once
832 application.SendNotification();
833 application.Render();
834 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
839 // flush the queue and render once
840 application.SendNotification();
841 application.Render();
842 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
844 actor.MoveBy( Vector3( 0.1f, 0.1f, 0.1f ) );
845 // flush the queue and render once
846 application.SendNotification();
847 application.Render();
848 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
850 Stage::GetCurrent().Remove( actor );
854 // SetPosition(float x, float y, float z)
855 int UtcDaliActorSetPosition02(void)
857 TestApplication application;
859 Actor actor = Actor::New();
861 // Set to random to start off with
862 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
864 Vector3 vector(100.0f, 100.0f, 100.0f);
866 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
868 actor.SetPosition(vector.x, vector.y, vector.z);
870 // flush the queue and render once
871 application.SendNotification();
872 application.Render();
874 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
878 // SetPosition(Vector3 position)
879 int UtcDaliActorSetPosition03(void)
881 TestApplication application;
883 Actor actor = Actor::New();
885 // Set to random to start off with
886 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
888 Vector3 vector(100.0f, 100.0f, 100.0f);
890 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
892 actor.SetPosition(vector);
894 // flush the queue and render once
895 application.SendNotification();
896 application.Render();
898 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
902 int UtcDaliActorSetX(void)
904 TestApplication application;
906 Actor actor = Actor::New();
908 Vector3 vector(100.0f, 0.0f, 0.0f);
910 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
914 // flush the queue and render once
915 application.SendNotification();
916 application.Render();
918 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
922 int UtcDaliActorSetY(void)
924 TestApplication application;
926 Actor actor = Actor::New();
928 Vector3 vector(0.0f, 100.0f, 0.0f);
930 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
934 // flush the queue and render once
935 application.SendNotification();
936 application.Render();
938 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
942 int UtcDaliActorSetZ(void)
944 TestApplication application;
946 Actor actor = Actor::New();
948 Vector3 vector(0.0f, 0.0f, 100.0f);
950 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
954 // flush the queue and render once
955 application.SendNotification();
956 application.Render();
958 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
962 int UtcDaliActorMoveBy(void)
964 TestApplication application;
966 Actor actor = Actor::New();
967 Vector3 vector(100.0f, 100.0f, 100.0f);
969 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
971 actor.SetPosition(vector);
973 // flush the queue and render once
974 application.SendNotification();
975 application.Render();
977 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
979 actor.MoveBy(vector);
981 // flush the queue and render once
982 application.SendNotification();
983 application.Render();
985 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
989 int UtcDaliActorGetCurrentPosition(void)
991 TestApplication application;
993 Actor actor = Actor::New();
994 Vector3 setVector(100.0f, 100.0f, 0.0f);
995 actor.SetPosition(setVector);
997 // flush the queue and render once
998 application.SendNotification();
999 application.Render();
1001 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1005 int UtcDaliActorGetCurrentWorldPosition(void)
1007 TestApplication application;
1009 Actor parent = Actor::New();
1010 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1011 parent.SetPosition( parentPosition );
1012 parent.SetParentOrigin( ParentOrigin::CENTER );
1013 parent.SetAnchorPoint( AnchorPoint::CENTER );
1014 Stage::GetCurrent().Add( parent );
1016 Actor child = Actor::New();
1017 child.SetParentOrigin( ParentOrigin::CENTER );
1018 child.SetAnchorPoint( AnchorPoint::CENTER );
1019 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1020 child.SetPosition( childPosition );
1021 parent.Add( child );
1023 // The actors should not have a world position yet
1024 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1025 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1027 application.SendNotification();
1028 application.Render(0);
1030 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1031 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1033 // The actors should have a world position now
1034 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1035 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1039 int UtcDaliActorInheritPosition(void)
1041 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1042 TestApplication application;
1044 Actor parent = Actor::New();
1045 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1046 parent.SetPosition( parentPosition );
1047 parent.SetParentOrigin( ParentOrigin::CENTER );
1048 parent.SetAnchorPoint( AnchorPoint::CENTER );
1049 Stage::GetCurrent().Add( parent );
1051 Actor child = Actor::New();
1052 child.SetParentOrigin( ParentOrigin::CENTER );
1053 child.SetAnchorPoint( AnchorPoint::CENTER );
1054 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1055 child.SetPosition( childPosition );
1056 parent.Add( child );
1058 // The actors should not have a world position yet
1059 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1060 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1062 // first test default, which is INHERIT_PARENT_POSITION
1063 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1064 application.SendNotification();
1065 application.Render(0); // should only really call Update as Render is not required to update scene
1066 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1067 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1068 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1069 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1071 // Change inheritance mode to use parent
1072 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1073 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1074 application.SendNotification();
1075 application.Render(0); // should only really call Update as Render is not required to update scene
1076 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1077 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1078 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1079 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1081 // Change inheritance mode to use parent + offset
1082 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1083 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1084 child.SetPosition( childOffset );
1085 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1086 application.SendNotification();
1087 application.Render(0); // should only really call Update as Render is not required to update scene
1088 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1089 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1090 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1091 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1093 // Change inheritance mode to not inherit
1094 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1095 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1096 application.SendNotification();
1097 application.Render(0); // should only really call Update as Render is not required to update scene
1098 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1099 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1100 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1101 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1105 // SetRotation(float angleRadians, Vector3 axis)
1106 int UtcDaliActorSetRotation01(void)
1108 TestApplication application;
1110 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1111 Actor actor = Actor::New();
1113 actor.SetRotation(rotation);
1115 // flush the queue and render once
1116 application.SendNotification();
1117 application.Render();
1119 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1123 int UtcDaliActorSetRotation02(void)
1125 TestApplication application;
1127 Actor actor = Actor::New();
1129 float angle = 0.785f;
1130 Vector3 axis(1.0f, 1.0f, 0.0f);
1132 actor.SetRotation(Radian( angle ), axis);
1133 Quaternion rotation( angle, axis );
1134 // flush the queue and render once
1135 application.SendNotification();
1136 application.Render();
1137 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1139 Stage::GetCurrent().Add( actor );
1140 actor.RotateBy( Degree( 360 ), axis);
1141 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1143 actor.SetRotation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1144 Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
1145 // flush the queue and render once
1146 application.SendNotification();
1147 application.Render();
1148 DALI_TEST_EQUALS( result, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1150 actor.SetRotation(Radian( angle ), axis);
1151 // flush the queue and render once
1152 application.SendNotification();
1153 application.Render();
1154 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1156 Stage::GetCurrent().Remove( actor );
1160 // RotateBy(float angleRadians, Vector3 axis)
1161 int UtcDaliActorRotateBy01(void)
1163 TestApplication application;
1165 Actor actor = Actor::New();
1167 float angle = M_PI * 0.25f;
1168 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1169 // flush the queue and render once
1170 application.SendNotification();
1171 application.Render();
1172 DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1174 Stage::GetCurrent().Add( actor );
1176 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1177 // flush the queue and render once
1178 application.SendNotification();
1179 application.Render();
1180 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1182 Stage::GetCurrent().Remove( actor );
1186 // RotateBy(Quaternion relativeRotation)
1187 int UtcDaliActorRotateBy02(void)
1189 TestApplication application;
1191 Actor actor = Actor::New();
1193 Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1194 actor.RotateBy(rotation);
1195 // flush the queue and render once
1196 application.SendNotification();
1197 application.Render();
1198 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1200 actor.RotateBy(rotation);
1201 // flush the queue and render once
1202 application.SendNotification();
1203 application.Render();
1204 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1208 int UtcDaliActorGetCurrentRotation(void)
1210 TestApplication application;
1211 Actor actor = Actor::New();
1213 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1214 actor.SetRotation(rotation);
1215 // flush the queue and render once
1216 application.SendNotification();
1217 application.Render();
1218 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1222 int UtcDaliActorGetCurrentWorldRotation(void)
1224 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1225 TestApplication application;
1227 Actor parent = Actor::New();
1228 Radian rotationAngle( Degree(90.0f) );
1229 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1230 parent.SetRotation( rotation );
1231 Stage::GetCurrent().Add( parent );
1233 Actor child = Actor::New();
1234 child.SetRotation( rotation );
1235 parent.Add( child );
1237 // The actors should not have a world rotation yet
1238 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1239 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1241 application.SendNotification();
1242 application.Render(0);
1244 DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1245 DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1247 // The actors should have a world rotation now
1248 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1249 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1251 // turn off child rotation inheritance
1252 child.SetInheritRotation( false );
1253 DALI_TEST_EQUALS( child.IsRotationInherited(), false, TEST_LOCATION );
1254 application.SendNotification();
1255 application.Render(0);
1257 // The actors should have a world rotation now
1258 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1259 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), rotation, 0.001, TEST_LOCATION );
1263 // SetScale(float scale)
1264 int UtcDaliActorSetScale01(void)
1266 TestApplication application;
1268 Actor actor = Actor::New();
1270 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1271 actor.SetScale(0.25f);
1273 Vector3 scale(10.0f, 10.0f, 10.0f);
1274 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1276 actor.SetScale(scale.x);
1278 // flush the queue and render once
1279 application.SendNotification();
1280 application.Render();
1282 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1286 // SetScale(float scaleX, float scaleY, float scaleZ)
1287 int UtcDaliActorSetScale02(void)
1289 TestApplication application;
1290 Vector3 scale(10.0f, 10.0f, 10.0f);
1292 Actor actor = Actor::New();
1294 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1295 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1297 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1299 actor.SetScale(scale.x, scale.y, scale.z);
1300 // flush the queue and render once
1301 application.SendNotification();
1302 application.Render();
1303 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1305 // add to stage and test
1306 Stage::GetCurrent().Add( actor );
1307 actor.SetScale( 2.0f, 2.0f, 2.0f );
1308 // flush the queue and render once
1309 application.SendNotification();
1310 application.Render();
1311 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1313 Stage::GetCurrent().Remove( actor );
1318 // SetScale(Vector3 scale)
1319 int UtcDaliActorSetScale03(void)
1321 TestApplication application;
1322 Vector3 scale(10.0f, 10.0f, 10.0f);
1324 Actor actor = Actor::New();
1326 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1327 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1329 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1331 actor.SetScale(scale);
1333 // flush the queue and render once
1334 application.SendNotification();
1335 application.Render();
1337 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1341 int UtcDaliActorScaleBy(void)
1343 TestApplication application;
1344 Actor actor = Actor::New();
1345 Vector3 vector(100.0f, 100.0f, 100.0f);
1347 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1349 actor.SetScale(vector);
1351 // flush the queue and render once
1352 application.SendNotification();
1353 application.Render();
1355 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1357 actor.ScaleBy(vector);
1359 // flush the queue and render once
1360 application.SendNotification();
1361 application.Render();
1363 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1367 int UtcDaliActorGetCurrentScale(void)
1369 TestApplication application;
1370 Vector3 scale(12.0f, 1.0f, 2.0f);
1372 Actor actor = Actor::New();
1374 actor.SetScale(scale);
1376 // flush the queue and render once
1377 application.SendNotification();
1378 application.Render();
1380 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1384 int UtcDaliActorGetCurrentWorldScale(void)
1386 TestApplication application;
1388 Actor parent = Actor::New();
1389 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1390 parent.SetScale( parentScale );
1391 Stage::GetCurrent().Add( parent );
1393 Actor child = Actor::New();
1394 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1395 child.SetScale( childScale );
1396 parent.Add( child );
1398 // The actors should not have a scale yet
1399 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1400 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1402 // The actors should not have a world scale yet
1403 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1404 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1406 application.SendNotification();
1407 application.Render(0);
1409 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1410 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1412 // The actors should have a world scale now
1413 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1414 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1418 int UtcDaliActorInheritScale(void)
1420 tet_infoline("Testing Actor::SetInheritScale");
1421 TestApplication application;
1423 Actor parent = Actor::New();
1424 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1425 parent.SetScale( parentScale );
1426 Stage::GetCurrent().Add( parent );
1428 Actor child = Actor::New();
1429 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1430 child.SetScale( childScale );
1431 parent.Add( child );
1433 application.SendNotification();
1434 application.Render(0);
1436 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1437 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1439 child.SetInheritScale( false );
1440 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1442 application.SendNotification();
1443 application.Render(0);
1445 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1449 int UtcDaliActorSetVisible(void)
1451 TestApplication application;
1453 Actor actor = Actor::New();
1454 actor.SetVisible(false);
1455 // flush the queue and render once
1456 application.SendNotification();
1457 application.Render();
1458 DALI_TEST_CHECK(actor.IsVisible() == false);
1460 actor.SetVisible(true);
1461 // flush the queue and render once
1462 application.SendNotification();
1463 application.Render();
1464 DALI_TEST_CHECK(actor.IsVisible() == true);
1466 // put actor on stage
1467 Stage::GetCurrent().Add( actor );
1468 actor.SetVisible(false);
1469 // flush the queue and render once
1470 application.SendNotification();
1471 application.Render();
1472 DALI_TEST_CHECK(actor.IsVisible() == false);
1476 int UtcDaliActorIsVisible(void)
1478 TestApplication application;
1480 Actor actor = Actor::New();
1482 DALI_TEST_CHECK(actor.IsVisible() == true);
1486 int UtcDaliActorSetOpacity(void)
1488 TestApplication application;
1490 Actor actor = Actor::New();
1491 // initial opacity is 1
1492 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1494 actor.SetOpacity( 0.4f);
1495 // flush the queue and render once
1496 application.SendNotification();
1497 application.Render();
1498 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1500 // change opacity, actor is on stage to change is not immediate
1501 actor.OpacityBy( 0.1f );
1502 // flush the queue and render once
1503 application.SendNotification();
1504 application.Render();
1505 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1507 // put actor on stage
1508 Stage::GetCurrent().Add( actor );
1510 // change opacity, actor is on stage to change is not immediate
1511 actor.SetOpacity( 0.9f );
1512 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1513 // flush the queue and render once
1514 application.SendNotification();
1515 application.Render();
1516 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1518 // change opacity, actor is on stage to change is not immediate
1519 actor.OpacityBy( -0.9f );
1520 // flush the queue and render once
1521 application.SendNotification();
1522 application.Render();
1523 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1527 int UtcDaliActorGetCurrentOpacity(void)
1529 TestApplication application;
1531 Actor actor = Actor::New();
1532 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1534 actor.SetOpacity(0.5f);
1535 // flush the queue and render once
1536 application.SendNotification();
1537 application.Render();
1538 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1542 int UtcDaliActorSetSensitive(void)
1544 TestApplication application;
1545 Actor actor = Actor::New();
1547 bool sensitive = !actor.IsSensitive();
1549 actor.SetSensitive(sensitive);
1551 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1555 int UtcDaliActorIsSensitive(void)
1557 TestApplication application;
1558 Actor actor = Actor::New();
1559 actor.SetSensitive(false);
1561 DALI_TEST_CHECK(false == actor.IsSensitive());
1565 int UtcDaliActorSetColor(void)
1567 TestApplication application;
1568 Actor actor = Actor::New();
1569 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1571 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1573 actor.SetColor(color);
1574 // flush the queue and render once
1575 application.SendNotification();
1576 application.Render();
1577 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1579 actor.ColorBy( Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1580 // flush the queue and render once
1581 application.SendNotification();
1582 application.Render();
1583 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1585 Stage::GetCurrent().Add( actor );
1586 actor.SetColor( color );
1587 // flush the queue and render once
1588 application.SendNotification();
1589 application.Render();
1590 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1592 actor.ColorBy( Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1593 // flush the queue and render once
1594 application.SendNotification();
1595 application.Render();
1596 // Actor color is not clamped
1597 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1598 // world color is clamped
1599 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1601 Stage::GetCurrent().Remove( actor );
1605 int UtcDaliActorGetCurrentColor(void)
1607 TestApplication application;
1608 Actor actor = Actor::New();
1609 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1611 actor.SetColor(color);
1612 // flush the queue and render once
1613 application.SendNotification();
1614 application.Render();
1615 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1619 int UtcDaliActorGetCurrentWorldColor(void)
1621 tet_infoline("Actor::GetCurrentWorldColor");
1622 TestApplication application;
1624 Actor parent = Actor::New();
1625 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1626 parent.SetColor( parentColor );
1627 Stage::GetCurrent().Add( parent );
1629 Actor child = Actor::New();
1630 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1631 child.SetColor( childColor );
1632 parent.Add( child );
1634 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1635 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1637 // verify the default color mode
1638 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1640 // The actors should not have a world color yet
1641 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1642 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1644 application.SendNotification();
1645 application.Render(0);
1647 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1648 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1650 // The actors should have a world color now
1651 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1652 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1655 child.SetColorMode( USE_OWN_COLOR );
1656 application.SendNotification();
1657 application.Render(0);
1658 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1661 child.SetColorMode( USE_PARENT_COLOR );
1662 application.SendNotification();
1663 application.Render(0);
1664 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1665 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1668 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1669 application.SendNotification();
1670 application.Render(0);
1671 Vector4 expectedColor( childColor );
1672 expectedColor.a *= parentColor.a;
1673 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1674 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1678 int UtcDaliActorSetColorMode(void)
1680 tet_infoline("Actor::SetColorMode");
1681 TestApplication application;
1682 Actor actor = Actor::New();
1683 Actor child = Actor::New();
1686 actor.SetColorMode( USE_OWN_COLOR );
1687 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1689 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1690 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1692 actor.SetColorMode( USE_PARENT_COLOR );
1693 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1695 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1696 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1700 int UtcDaliActorScreenToLocal(void)
1702 TestApplication application;
1703 Actor actor = Actor::New();
1704 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1705 actor.SetSize(100.0f, 100.0f);
1706 actor.SetPosition(10.0f, 10.0f);
1707 Stage::GetCurrent().Add(actor);
1709 // flush the queue and render once
1710 application.SendNotification();
1711 application.Render();
1716 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1718 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1719 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1723 int UtcDaliActorSetLeaveRequired(void)
1725 TestApplication application;
1727 Actor actor = Actor::New();
1729 actor.SetLeaveRequired(false);
1730 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1732 actor.SetLeaveRequired(true);
1733 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1737 int UtcDaliActorGetLeaveRequired(void)
1739 TestApplication application;
1741 Actor actor = Actor::New();
1743 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1747 int UtcDaliActorSetKeyboardFocusable(void)
1749 TestApplication application;
1751 Actor actor = Actor::New();
1753 actor.SetKeyboardFocusable(true);
1754 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1756 actor.SetKeyboardFocusable(false);
1757 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1761 int UtcDaliActorIsKeyboardFocusable(void)
1763 TestApplication application;
1765 Actor actor = Actor::New();
1767 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1772 int UtcDaliActorApplyConstraint(void)
1774 TestApplication application;
1776 gTestConstraintCalled = false;
1778 Actor actor = Actor::New();
1780 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1781 actor.ApplyConstraint(constraint);
1783 DALI_TEST_CHECK( gTestConstraintCalled == false );
1785 Stage::GetCurrent().Add( actor );
1787 // flush the queue and render once
1788 application.SendNotification();
1789 application.Render();
1791 DALI_TEST_CHECK( gTestConstraintCalled == true );
1796 int UtcDaliActorApplyConstraintAppliedCallback(void)
1798 TestApplication application;
1800 // Build a reusable constraint
1802 Actor parent = Actor::New();
1803 Vector3 parentSize( 100.0f, 100.0f, 100.0f );
1804 parent.SetSize( parentSize );
1805 Stage::GetCurrent().Add( parent );
1807 Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
1808 Source( parent, Actor::SIZE ),
1809 EqualToConstraint() );
1811 // Create some child actors
1813 Actor child1 = Actor::New();
1814 parent.Add( child1 );
1816 Actor child2 = Actor::New();
1817 parent.Add( child2 );
1819 Actor child3 = Actor::New();
1820 parent.Add( child3 );
1822 // Apply constraint with different timings - everything should be finished after 10 seconds
1824 wasConstraintCallbackCalled1 = false;
1825 wasConstraintCallbackCalled2 = false;
1826 wasConstraintCallbackCalled3 = false;
1828 constraint.SetApplyTime( 5.0f );
1829 ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
1830 activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
1832 constraint.SetApplyTime( 10.0f );
1833 ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
1834 activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
1836 constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
1837 ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
1838 activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
1840 DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1841 DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1842 DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1844 application.SendNotification();
1846 application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
1847 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
1848 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
1849 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1851 // Check signals have not fired
1852 application.SendNotification();
1853 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1854 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1855 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1857 application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
1858 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40%
1859 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
1860 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1862 // Check signals have not fired
1863 application.SendNotification();
1864 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1865 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1866 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1868 application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
1869 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60%
1870 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
1871 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
1873 // Check signals have not fired
1874 application.SendNotification();
1875 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1876 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1877 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1879 application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
1880 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80%
1881 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
1882 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
1884 // Check signals have not fired
1885 application.SendNotification();
1886 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1887 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1888 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1890 application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
1891 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100%
1892 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
1893 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
1895 // Check signals have not fired
1896 application.SendNotification();
1897 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1898 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1899 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1901 application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
1902 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire)
1903 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
1904 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
1906 // 1st signal should have fired
1907 application.SendNotification();
1908 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
1909 wasConstraintCallbackCalled1 = false;
1910 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1911 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1913 application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
1914 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1915 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
1916 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
1918 // Check signals have not fired
1919 application.SendNotification();
1920 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1921 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1922 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1924 application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
1925 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1926 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
1927 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire)
1929 // 3rd signal should have fired
1930 application.SendNotification();
1932 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1933 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1934 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
1935 wasConstraintCallbackCalled3 = false;
1937 application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
1938 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1939 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
1940 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1942 // Check signals have not fired
1943 application.SendNotification();
1944 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1945 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1946 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1948 application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
1949 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1950 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire)
1951 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1953 // 2nd signal should have fired
1954 application.SendNotification();
1955 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1956 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
1957 wasConstraintCallbackCalled2 = false;
1958 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1960 // Check that nothing has changed after a couple of buffer swaps
1962 application.Render(0);
1963 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
1964 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
1965 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
1967 application.SendNotification();
1968 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1969 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1970 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1972 application.Render(0);
1973 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
1974 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
1975 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
1977 application.SendNotification();
1978 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1979 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1980 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1984 int UtcDaliActorRemoveConstraints(void)
1986 tet_infoline(" UtcDaliActorRemoveConstraints");
1987 TestApplication application;
1989 gTestConstraintCalled = false;
1991 Actor actor = Actor::New();
1993 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1994 actor.ApplyConstraint(constraint);
1995 actor.RemoveConstraints();
1997 DALI_TEST_CHECK( gTestConstraintCalled == false );
1999 Stage::GetCurrent().Add( actor );
2000 actor.ApplyConstraint(constraint);
2002 // flush the queue and render once
2003 application.SendNotification();
2004 application.Render();
2006 actor.RemoveConstraints();
2008 DALI_TEST_CHECK( gTestConstraintCalled == true );
2012 int UtcDaliActorRemoveConstraint(void)
2014 tet_infoline(" UtcDaliActorRemoveConstraint");
2015 TestApplication application;
2017 Actor actor = Actor::New();
2019 // 1. Apply Constraint1 and Constraint2, and test...
2020 unsigned int result1 = 0u;
2021 unsigned int result2 = 0u;
2022 ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2023 ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) ) );
2025 Stage::GetCurrent().Add( actor );
2026 // flush the queue and render once
2027 application.SendNotification();
2028 application.Render();
2030 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2031 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2033 // 2. Remove Constraint1 and test...
2036 actor.RemoveConstraint(activeConstraint1);
2037 // make color property dirty, which will trigger constraints to be reapplied.
2038 actor.SetColor( Color::WHITE );
2039 // flush the queue and render once
2040 application.SendNotification();
2041 application.Render();
2043 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2044 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2046 // 3. Re-Apply Constraint1 and test...
2049 activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2050 // make color property dirty, which will trigger constraints to be reapplied.
2051 actor.SetColor( Color::WHITE );
2052 // flush the queue and render once
2053 application.SendNotification();
2054 application.Render();
2056 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2057 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2059 // 2. Remove Constraint2 and test...
2062 actor.RemoveConstraint(activeConstraint2);
2063 // make color property dirty, which will trigger constraints to be reapplied.
2064 actor.SetColor( Color::WHITE );
2065 // flush the queue and render once
2066 application.SendNotification();
2067 application.Render();
2069 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2070 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2072 // 2. Remove Constraint1 as well and test...
2075 actor.RemoveConstraint(activeConstraint1);
2076 // make color property dirty, which will trigger constraints to be reapplied.
2077 actor.SetColor( Color::WHITE );
2078 // flush the queue and render once
2079 application.SendNotification();
2080 application.Render();
2082 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2083 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2087 int UtcDaliActorRemoveConstraintTag(void)
2089 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2090 TestApplication application;
2092 Actor actor = Actor::New();
2094 // 1. Apply Constraint1 and Constraint2, and test...
2095 unsigned int result1 = 0u;
2096 unsigned int result2 = 0u;
2098 unsigned constraint1Tag = 1u;
2099 Constraint constraint1 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2100 constraint1.SetTag( constraint1Tag );
2101 actor.ApplyConstraint( constraint1 );
2103 unsigned constraint2Tag = 2u;
2104 Constraint constraint2 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2105 constraint2.SetTag( constraint2Tag );
2106 actor.ApplyConstraint( constraint2 );
2108 Stage::GetCurrent().Add( actor );
2109 // flush the queue and render once
2110 application.SendNotification();
2111 application.Render();
2113 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2114 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2116 // 2. Remove Constraint1 and test...
2119 actor.RemoveConstraints(constraint1Tag);
2120 // make color property dirty, which will trigger constraints to be reapplied.
2121 actor.SetColor( Color::WHITE );
2122 // flush the queue and render once
2123 application.SendNotification();
2124 application.Render();
2126 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2127 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2129 // 3. Re-Apply Constraint1 and test...
2132 actor.ApplyConstraint( constraint1 );
2133 // make color property dirty, which will trigger constraints to be reapplied.
2134 actor.SetColor( Color::WHITE );
2135 // flush the queue and render once
2136 application.SendNotification();
2137 application.Render();
2139 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2140 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2142 // 2. Remove Constraint2 and test...
2145 actor.RemoveConstraints(constraint2Tag);
2146 // make color property dirty, which will trigger constraints to be reapplied.
2147 actor.SetColor( Color::WHITE );
2148 // flush the queue and render once
2149 application.SendNotification();
2150 application.Render();
2152 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2153 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2155 // 2. Remove Constraint1 as well and test...
2158 actor.RemoveConstraints(constraint1Tag);
2159 // make color property dirty, which will trigger constraints to be reapplied.
2160 actor.SetColor( Color::WHITE );
2161 // flush the queue and render once
2162 application.SendNotification();
2163 application.Render();
2165 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2166 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2170 int UtcDaliActorTouchedSignal(void)
2172 TestApplication application;
2174 gTouchCallBackCalled = false;
2176 // get the root layer
2177 Actor actor = Stage::GetCurrent().GetRootLayer();
2178 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2180 application.SendNotification();
2181 application.Render();
2183 // connect to its touch signal
2184 actor.TouchedSignal().Connect( TestCallback );
2186 // simulate a touch event in the middle of the screen
2187 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2188 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
2189 Dali::Integration::TouchEvent event;
2190 event.AddPoint( point );
2191 application.ProcessEvent( event );
2193 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2198 int UtcDaliActorSetSizeSignal(void)
2200 TestApplication application;
2202 Actor actor = Actor::New();
2203 actor.SetSizeSignal().Connect( SetSizeCallback );
2205 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2206 gSetSizeCallBackCalled = false;
2207 Vector2 size2d( 1.0f, 2.0f );
2208 actor.SetSize( size2d );
2209 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2210 // SetSize with Vector2 sets depth to be the minimum of width & height
2211 DALI_TEST_EQUALS( Vector3( 1.0f, 2.0f, 1.0f ), gSetSize, TEST_LOCATION );
2213 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2214 gSetSizeCallBackCalled = false;
2215 actor.SetSize( 22.0f, 11.0f );
2216 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2217 // SetSize with Vector2 sets depth to be the minimum of width & height
2218 DALI_TEST_EQUALS( Vector3( 22.0f, 11.0f, 11.0f ), gSetSize, TEST_LOCATION );
2220 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2221 gSetSizeCallBackCalled = false;
2222 Vector3 size( 3.0f, 4.0f, 5.0f );
2223 actor.SetSize( size );
2224 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2225 DALI_TEST_EQUALS( size, gSetSize, TEST_LOCATION );
2227 // add actor to stage to see that signal still works
2228 Stage::GetCurrent().Add( actor );
2230 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2231 gSetSizeCallBackCalled = false;
2232 actor.SetSize( -1.0f, -2.0f, -3.0f );
2233 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2234 DALI_TEST_EQUALS( Vector3( -1.0f, -2.0f, -3.0f ), gSetSize, TEST_LOCATION );
2238 int UtcDaliActorOnOffStageSignal(void)
2240 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2242 TestApplication application;
2245 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2246 gActorNamesOnOffStage.clear();
2248 Actor parent = Actor::New();
2249 parent.SetName( "parent" );
2250 parent.OnStageSignal().Connect( OnStageCallback );
2251 parent.OffStageSignal().Connect( OffStageCallback );
2253 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2254 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2256 // add parent to stage
2257 Stage::GetCurrent().Add( parent );
2258 // onstage emitted, offstage not
2259 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2260 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2261 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2263 // test adding a child, should get onstage emitted
2265 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2266 gActorNamesOnOffStage.clear();
2268 Actor child = Actor::New();
2269 child.SetName( "child" );
2270 child.OnStageSignal().Connect( OnStageCallback );
2271 child.OffStageSignal().Connect( OffStageCallback );
2272 parent.Add( child ); // add child
2273 // onstage emitted, offstage not
2274 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2275 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2276 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2278 // test removing parent from stage
2280 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2281 gActorNamesOnOffStage.clear();
2283 Stage::GetCurrent().Remove( parent );
2284 // onstage not emitted, offstage is
2285 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2286 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2287 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2288 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2290 // test adding parent back to stage
2292 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2293 gActorNamesOnOffStage.clear();
2295 Stage::GetCurrent().Add( parent );
2296 // onstage emitted, offstage not
2297 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2298 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2299 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2300 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2302 // test removing child
2304 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2305 gActorNamesOnOffStage.clear();
2307 parent.Remove( child );
2308 // onstage not emitted, offstage is
2309 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2310 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2311 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2313 // test removing parent
2315 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2316 gActorNamesOnOffStage.clear();
2318 Stage::GetCurrent().Remove( parent );
2319 // onstage not emitted, offstage is
2320 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2321 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2322 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2326 int UtcDaliActorFindChildByName(void)
2328 tet_infoline("Testing Dali::Actor::FindChildByName()");
2329 TestApplication application;
2331 Actor parent = Actor::New();
2332 parent.SetName( "parent" );
2333 Actor first = Actor::New();
2334 first .SetName( "first" );
2335 Actor second = Actor::New();
2336 second.SetName( "second" );
2341 Actor found = parent.FindChildByName( "foo" );
2342 DALI_TEST_CHECK( !found );
2344 found = parent.FindChildByName( "parent" );
2345 DALI_TEST_CHECK( found == parent );
2347 found = parent.FindChildByName( "first" );
2348 DALI_TEST_CHECK( found == first );
2350 found = parent.FindChildByName( "second" );
2351 DALI_TEST_CHECK( found == second );
2355 int UtcDaliActorFindChildByAlias(void)
2357 tet_infoline("Testing Dali::Actor::FindChildByAlias()");
2358 TestApplication application;
2360 Actor parent = Actor::New();
2361 parent.SetName( "parent" );
2362 Actor first = Actor::New();
2363 first .SetName( "first" );
2364 Actor second = Actor::New();
2365 second.SetName( "second" );
2370 Actor found = parent.FindChildByAlias( "foo" );
2371 DALI_TEST_CHECK( !found );
2373 found = parent.FindChildByAlias( "parent" );
2374 DALI_TEST_CHECK( found == parent );
2376 found = parent.FindChildByAlias( "first" );
2377 DALI_TEST_CHECK( found == first );
2379 found = parent.FindChildByAlias( "second" );
2380 DALI_TEST_CHECK( found == second );
2384 int UtcDaliActorFindChildById(void)
2386 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2387 TestApplication application;
2389 Actor parent = Actor::New();
2390 Actor first = Actor::New();
2391 Actor second = Actor::New();
2396 Actor found = parent.FindChildById( 100000 );
2397 DALI_TEST_CHECK( !found );
2399 found = parent.FindChildById( parent.GetId() );
2400 DALI_TEST_CHECK( found == parent );
2402 found = parent.FindChildById( first.GetId() );
2403 DALI_TEST_CHECK( found == first );
2405 found = parent.FindChildById( second.GetId() );
2406 DALI_TEST_CHECK( found == second );
2410 int UtcDaliActorHitTest(void)
2415 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2417 mTouchPoint( touchPoint ),
2422 Vector2 mTouchPoint;
2426 TestApplication application;
2427 tet_infoline(" UtcDaliActorHitTest");
2429 // Fill a vector with different hit tests.
2430 struct HitTestData* hitTestData[] = {
2431 // scale touch point result
2432 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2433 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2434 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.
2435 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2436 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.
2440 // get the root layer
2441 Actor actor = Actor::New();
2442 actor.SetAnchorPoint( AnchorPoint::CENTER );
2443 actor.SetParentOrigin( ParentOrigin::CENTER );
2445 Stage::GetCurrent().Add( actor );
2447 gTouchCallBackCalled = false;
2449 unsigned int index = 0;
2450 while( NULL != hitTestData[index] )
2452 actor.SetSize( 1.f, 1.f );
2453 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2455 // flush the queue and render once
2456 application.SendNotification();
2457 application.Render();
2459 DALI_TEST_CHECK( !gTouchCallBackCalled );
2461 // connect to its touch signal
2462 actor.TouchedSignal().Connect(TestCallback);
2464 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2465 Dali::Integration::TouchEvent event;
2466 event.AddPoint( point );
2468 // flush the queue and render once
2469 application.SendNotification();
2470 application.Render();
2471 application.ProcessEvent( event );
2473 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2475 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2476 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2477 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2478 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2479 hitTestData[index]->mResult );
2481 gTouchCallBackCalled = false;
2487 int UtcDaliActorSetDrawMode(void)
2489 TestApplication app;
2490 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2492 Actor a = Actor::New();
2494 Stage::GetCurrent().Add(a);
2495 app.SendNotification();
2497 app.SendNotification();
2500 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2502 a.SetDrawMode( DrawMode::OVERLAY );
2503 app.SendNotification();
2506 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2508 a.SetDrawMode( DrawMode::STENCIL );
2509 app.SendNotification();
2512 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2514 a.SetDrawMode( DrawMode::NORMAL );
2515 app.SendNotification();
2518 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2522 int UtcDaliActorSetDrawModeOverlayRender(void)
2524 TestApplication app;
2525 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2527 app.SendNotification();
2530 std::vector<GLuint> ids;
2531 ids.push_back( 8 ); // first rendered actor
2532 ids.push_back( 9 ); // second rendered actor
2533 ids.push_back( 10 ); // third rendered actor
2534 app.GetGlAbstraction().SetNextTextureIds( ids );
2536 BitmapImage imageA = BitmapImage::New(16, 16);
2537 BitmapImage imageB = BitmapImage::New(16, 16);
2538 BitmapImage imageC = BitmapImage::New(16, 16);
2539 ImageActor a = ImageActor::New( imageA );
2540 ImageActor b = ImageActor::New( imageB );
2541 ImageActor c = ImageActor::New( imageC );
2543 // Render a,b,c as regular non-overlays. so order will be:
2547 Stage::GetCurrent().Add(a);
2548 Stage::GetCurrent().Add(b);
2549 Stage::GetCurrent().Add(c);
2551 app.SendNotification();
2554 // Should be 3 textures changes.
2555 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2556 typedef std::vector<GLuint>::size_type TextureSize;
2557 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2558 if( boundTextures.size() == 3 )
2560 DALI_TEST_CHECK( boundTextures[0] == 8u );
2561 DALI_TEST_CHECK( boundTextures[1] == 9u );
2562 DALI_TEST_CHECK( boundTextures[2] == 10u );
2565 // Now texture ids have been set, we can monitor their render order.
2566 // render a as an overlay (last), so order will be:
2570 a.SetDrawMode( DrawMode::OVERLAY );
2571 app.GetGlAbstraction().ClearBoundTextures();
2573 app.SendNotification();
2576 // Should be 3 texture changes.
2577 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2578 if( boundTextures.size() == 3 )
2580 DALI_TEST_CHECK( boundTextures[0] == 9u );
2581 DALI_TEST_CHECK( boundTextures[1] == 10u );
2582 DALI_TEST_CHECK( boundTextures[2] == 8u );
2588 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2590 TestApplication app;
2591 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2593 BitmapImage imageA = BitmapImage::New(16, 16);
2594 BitmapImage imageB = BitmapImage::New(16, 16);
2595 ImageActor a = ImageActor::New( imageA );
2596 ImageActor b = ImageActor::New( imageB );
2598 // Render a,b as regular non-overlays. so order will be:
2599 Stage::GetCurrent().Add(a);
2600 Stage::GetCurrent().Add(b);
2602 a.SetSize(Vector2(100.0f, 100.0f));
2603 b.SetSize(Vector2(100.0f, 100.0f));
2605 // position b overlapping a. (regular non-overlays)
2606 // hit test at point 'x'
2617 // note: b is on top, because it's Z position is higher.
2618 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2619 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2621 // connect to their touch signals
2622 a.TouchedSignal().Connect(TestCallback);
2623 b.TouchedSignal().Connect(TestCallback2);
2625 a.SetDrawMode( DrawMode::NORMAL );
2626 b.SetDrawMode( DrawMode::NORMAL );
2627 SimulateTouchForSetOverlayHitTest(app);
2629 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2630 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2631 // Make Actor a an overlay.
2642 // note: a is on top, because it is an overlay.
2643 a.SetDrawMode( DrawMode::OVERLAY );
2644 b.SetDrawMode( DrawMode::NORMAL );
2645 SimulateTouchForSetOverlayHitTest(app);
2647 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2648 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2649 // Make both Actors as overlays
2660 // note: b is on top, because it is the 2nd child in the hierarchy.
2661 a.SetDrawMode( DrawMode::OVERLAY );
2662 b.SetDrawMode( DrawMode::OVERLAY );
2663 SimulateTouchForSetOverlayHitTest(app);
2665 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2666 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2670 int UtcDaliActorGetCurrentWorldMatrix(void)
2672 TestApplication app;
2673 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2675 Actor parent = Actor::New();
2676 parent.SetParentOrigin(ParentOrigin::CENTER);
2677 parent.SetAnchorPoint(AnchorPoint::CENTER);
2678 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2679 Radian rotationAngle(Degree(85.0f));
2680 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2681 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2682 parent.SetPosition( parentPosition );
2683 parent.SetRotation( parentRotation );
2684 parent.SetScale( parentScale );
2685 Stage::GetCurrent().Add( parent );
2687 Actor child = Actor::New();
2688 child.SetParentOrigin(ParentOrigin::CENTER);
2689 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2690 Radian childRotationAngle(Degree(23.0f));
2691 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2692 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2693 child.SetPosition( childPosition );
2694 child.SetRotation( childRotation );
2695 child.SetScale( childScale );
2696 parent.Add( child );
2698 // The actors should not have a world matrix yet
2699 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2700 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2702 app.SendNotification();
2705 app.SendNotification();
2707 Matrix parentMatrix(false);
2708 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2710 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2711 Quaternion childWorldRotation = parentRotation * childRotation;
2712 Vector3 childWorldScale = parentScale * childScale;
2714 Matrix childWorldMatrix(false);
2715 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2717 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2718 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2724 int UtcDaliActorConstrainedToWorldMatrix(void)
2726 TestApplication app;
2727 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2729 Actor parent = Actor::New();
2730 parent.SetParentOrigin(ParentOrigin::CENTER);
2731 parent.SetAnchorPoint(AnchorPoint::CENTER);
2732 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2733 Radian rotationAngle(Degree(85.0f));
2734 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2735 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2736 parent.SetPosition( parentPosition );
2737 parent.SetRotation( parentRotation );
2738 parent.SetScale( parentScale );
2739 Stage::GetCurrent().Add( parent );
2741 Actor child = Actor::New();
2742 child.SetParentOrigin(ParentOrigin::CENTER);
2743 Constraint posConstraint = Constraint::New<Vector3>( Actor::POSITION, Source( parent, Actor::WORLD_MATRIX), PositionComponentConstraint() );
2744 child.ApplyConstraint(posConstraint);
2746 Stage::GetCurrent().Add( child );
2748 // The actors should not have a world matrix yet
2749 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2750 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2752 app.SendNotification();
2755 app.SendNotification();
2757 Matrix parentMatrix(false);
2758 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2760 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2761 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2765 int UtcDaliActorUnparent(void)
2767 TestApplication app;
2768 tet_infoline(" UtcDaliActorUnparent");
2770 Actor parent = Actor::New();
2771 Stage::GetCurrent().Add( parent );
2773 Actor child = Actor::New();
2775 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2776 DALI_TEST_CHECK( !child.GetParent() );
2778 // Test that calling Unparent with no parent is a NOOP
2781 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2782 DALI_TEST_CHECK( !child.GetParent() );
2784 // Test that Unparent works
2785 parent.Add( child );
2787 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2788 DALI_TEST_CHECK( parent == child.GetParent() );
2792 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2793 DALI_TEST_CHECK( !child.GetParent() );
2795 // Test that UnparentAndReset works
2796 parent.Add( child );
2798 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2799 DALI_TEST_CHECK( parent == child.GetParent() );
2801 UnparentAndReset( child );
2803 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2804 DALI_TEST_CHECK( !child );
2806 // Test that UnparentAndReset is a NOOP with empty handle
2807 UnparentAndReset( child );
2809 DALI_TEST_CHECK( !child );
2813 int UtcDaliActorGetChildAt(void)
2815 TestApplication app;
2816 tet_infoline(" UtcDaliActorGetChildAt");
2818 Actor parent = Actor::New();
2819 Stage::GetCurrent().Add( parent );
2821 Actor child0 = Actor::New();
2822 parent.Add( child0 );
2824 Actor child1 = Actor::New();
2825 parent.Add( child1 );
2827 Actor child2 = Actor::New();
2828 parent.Add( child2 );
2830 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2831 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2832 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2836 int UtcDaliActorSetGetOverlay(void)
2838 TestApplication app;
2839 tet_infoline(" UtcDaliActorSetGetOverlay");
2841 Actor parent = Actor::New();
2842 parent.SetDrawMode(DrawMode::OVERLAY );
2843 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2848 // Current Dynamics functions are crashing, so testing these sections are futile
2850 int UtcDaliActorDynamics(void)
2852 DALI_TEST_CHECK( true );
2856 int UtcDaliActorCreateDestroy(void)
2858 Actor* actor = new Actor;
2859 DALI_TEST_CHECK( actor );
2866 struct PropertyStringIndex
2868 const char * const name;
2869 const Property::Index index;
2870 const Property::Type type;
2873 const PropertyStringIndex PROPERTY_TABLE[] =
2875 { "parent-origin", Actor::PARENT_ORIGIN, Property::VECTOR3 },
2876 { "parent-origin-x", Actor::PARENT_ORIGIN_X, Property::FLOAT },
2877 { "parent-origin-y", Actor::PARENT_ORIGIN_Y, Property::FLOAT },
2878 { "parent-origin-z", Actor::PARENT_ORIGIN_Z, Property::FLOAT },
2879 { "anchor-point", Actor::ANCHOR_POINT, Property::VECTOR3 },
2880 { "anchor-point-x", Actor::ANCHOR_POINT_X, Property::FLOAT },
2881 { "anchor-point-y", Actor::ANCHOR_POINT_Y, Property::FLOAT },
2882 { "anchor-point-z", Actor::ANCHOR_POINT_Z, Property::FLOAT },
2883 { "size", Actor::SIZE, Property::VECTOR3 },
2884 { "size-width", Actor::SIZE_WIDTH, Property::FLOAT },
2885 { "size-height", Actor::SIZE_HEIGHT, Property::FLOAT },
2886 { "size-depth", Actor::SIZE_DEPTH, Property::FLOAT },
2887 { "position", Actor::POSITION, Property::VECTOR3 },
2888 { "position-x", Actor::POSITION_X, Property::FLOAT },
2889 { "position-y", Actor::POSITION_Y, Property::FLOAT },
2890 { "position-z", Actor::POSITION_Z, Property::FLOAT },
2891 { "world-position", Actor::WORLD_POSITION, Property::VECTOR3 },
2892 { "world-position-x", Actor::WORLD_POSITION_X, Property::FLOAT },
2893 { "world-position-y", Actor::WORLD_POSITION_Y, Property::FLOAT },
2894 { "world-position-z", Actor::WORLD_POSITION_Z, Property::FLOAT },
2895 { "rotation", Actor::ROTATION, Property::ROTATION },
2896 { "world-rotation", Actor::WORLD_ROTATION, Property::ROTATION },
2897 { "scale", Actor::SCALE, Property::VECTOR3 },
2898 { "scale-x", Actor::SCALE_X, Property::FLOAT },
2899 { "scale-y", Actor::SCALE_Y, Property::FLOAT },
2900 { "scale-z", Actor::SCALE_Z, Property::FLOAT },
2901 { "world-scale", Actor::WORLD_SCALE, Property::VECTOR3 },
2902 { "visible", Actor::VISIBLE, Property::BOOLEAN },
2903 { "color", Actor::COLOR, Property::VECTOR4 },
2904 { "color-red", Actor::COLOR_RED, Property::FLOAT },
2905 { "color-green", Actor::COLOR_GREEN, Property::FLOAT },
2906 { "color-blue", Actor::COLOR_BLUE, Property::FLOAT },
2907 { "color-alpha", Actor::COLOR_ALPHA, Property::FLOAT },
2908 { "world-color", Actor::WORLD_COLOR, Property::VECTOR4 },
2909 { "world-matrix", Actor::WORLD_MATRIX, Property::MATRIX },
2910 { "name", Actor::NAME, Property::STRING },
2911 { "sensitive", Actor::SENSITIVE, Property::BOOLEAN },
2912 { "leave-required", Actor::LEAVE_REQUIRED, Property::BOOLEAN },
2913 { "inherit-rotation", Actor::INHERIT_ROTATION, Property::BOOLEAN },
2914 { "inherit-scale", Actor::INHERIT_SCALE, Property::BOOLEAN },
2915 { "color-mode", Actor::COLOR_MODE, Property::STRING },
2916 { "position-inheritance", Actor::POSITION_INHERITANCE, Property::STRING },
2917 { "draw-mode", Actor::DRAW_MODE, Property::STRING },
2919 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2920 } // unnamed namespace
2922 int UtcDaliActorProperties(void)
2924 TestApplication app;
2926 Actor actor = Actor::New();
2928 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2930 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2931 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2932 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2933 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );