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 int UtcDaliActorGetNaturalSize(void)
811 TestApplication application;
813 Actor actor = Actor::New();
814 Vector3 vector( 0.0f, 0.0f, 0.0f );
816 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
821 int UtcDaliActorGetCurrentSizeImmediate(void)
823 TestApplication application;
825 Actor actor = Actor::New();
826 Vector3 vector(100.0f, 100.0f, 20.0f);
828 DALI_TEST_CHECK(vector != actor.GetSize());
829 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
831 actor.SetSize(vector);
833 DALI_TEST_CHECK(vector == actor.GetSize());
834 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
836 // flush the queue and render once
837 application.SendNotification();
838 application.Render();
840 DALI_TEST_CHECK(vector == actor.GetSize());
841 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
844 // Build the animation
845 const float durationSeconds = 2.0f;
846 Animation animation = Animation::New( durationSeconds );
847 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
848 animation.AnimateTo( Property( actor, Actor::SIZE ), targetValue );
850 DALI_TEST_CHECK( actor.GetSize() == targetValue );
852 // Start the animation
855 application.SendNotification();
856 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
858 DALI_TEST_CHECK( actor.GetSize() == targetValue );
863 // SetPosition(float x, float y)
864 int UtcDaliActorSetPosition01(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, 0.0f));
873 Vector3 vector(100.0f, 100.0f, 0.0f);
875 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
877 actor.SetPosition(vector.x, vector.y);
878 // flush the queue and render once
879 application.SendNotification();
880 application.Render();
881 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
883 Stage::GetCurrent().Add( actor );
884 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
885 // flush the queue and render once
886 application.SendNotification();
887 application.Render();
888 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
893 // flush the queue and render once
894 application.SendNotification();
895 application.Render();
896 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
898 actor.MoveBy( Vector3( 0.1f, 0.1f, 0.1f ) );
899 // flush the queue and render once
900 application.SendNotification();
901 application.Render();
902 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
904 Stage::GetCurrent().Remove( actor );
908 // SetPosition(float x, float y, float z)
909 int UtcDaliActorSetPosition02(void)
911 TestApplication application;
913 Actor actor = Actor::New();
915 // Set to random to start off with
916 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
918 Vector3 vector(100.0f, 100.0f, 100.0f);
920 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
922 actor.SetPosition(vector.x, vector.y, vector.z);
924 // flush the queue and render once
925 application.SendNotification();
926 application.Render();
928 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
932 // SetPosition(Vector3 position)
933 int UtcDaliActorSetPosition03(void)
935 TestApplication application;
937 Actor actor = Actor::New();
939 // Set to random to start off with
940 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
942 Vector3 vector(100.0f, 100.0f, 100.0f);
944 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
946 actor.SetPosition(vector);
948 // flush the queue and render once
949 application.SendNotification();
950 application.Render();
952 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
956 int UtcDaliActorSetX(void)
958 TestApplication application;
960 Actor actor = Actor::New();
962 Vector3 vector(100.0f, 0.0f, 0.0f);
964 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
968 // flush the queue and render once
969 application.SendNotification();
970 application.Render();
972 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
976 int UtcDaliActorSetY(void)
978 TestApplication application;
980 Actor actor = Actor::New();
982 Vector3 vector(0.0f, 100.0f, 0.0f);
984 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
988 // flush the queue and render once
989 application.SendNotification();
990 application.Render();
992 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
996 int UtcDaliActorSetZ(void)
998 TestApplication application;
1000 Actor actor = Actor::New();
1002 Vector3 vector(0.0f, 0.0f, 100.0f);
1004 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1008 // flush the queue and render once
1009 application.SendNotification();
1010 application.Render();
1012 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1016 int UtcDaliActorMoveBy(void)
1018 TestApplication application;
1020 Actor actor = Actor::New();
1021 Vector3 vector(100.0f, 100.0f, 100.0f);
1023 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1025 actor.SetPosition(vector);
1027 // flush the queue and render once
1028 application.SendNotification();
1029 application.Render();
1031 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1033 actor.MoveBy(vector);
1035 // flush the queue and render once
1036 application.SendNotification();
1037 application.Render();
1039 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1043 int UtcDaliActorGetCurrentPosition(void)
1045 TestApplication application;
1047 Actor actor = Actor::New();
1048 Vector3 setVector(100.0f, 100.0f, 0.0f);
1049 actor.SetPosition(setVector);
1051 // flush the queue and render once
1052 application.SendNotification();
1053 application.Render();
1055 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1059 int UtcDaliActorGetCurrentWorldPosition(void)
1061 TestApplication application;
1063 Actor parent = Actor::New();
1064 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1065 parent.SetPosition( parentPosition );
1066 parent.SetParentOrigin( ParentOrigin::CENTER );
1067 parent.SetAnchorPoint( AnchorPoint::CENTER );
1068 Stage::GetCurrent().Add( parent );
1070 Actor child = Actor::New();
1071 child.SetParentOrigin( ParentOrigin::CENTER );
1072 child.SetAnchorPoint( AnchorPoint::CENTER );
1073 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1074 child.SetPosition( childPosition );
1075 parent.Add( child );
1077 // The actors should not have a world position yet
1078 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1079 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1081 application.SendNotification();
1082 application.Render(0);
1084 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1085 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1087 // The actors should have a world position now
1088 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1089 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1093 int UtcDaliActorInheritPosition(void)
1095 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1096 TestApplication application;
1098 Actor parent = Actor::New();
1099 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1100 parent.SetPosition( parentPosition );
1101 parent.SetParentOrigin( ParentOrigin::CENTER );
1102 parent.SetAnchorPoint( AnchorPoint::CENTER );
1103 Stage::GetCurrent().Add( parent );
1105 Actor child = Actor::New();
1106 child.SetParentOrigin( ParentOrigin::CENTER );
1107 child.SetAnchorPoint( AnchorPoint::CENTER );
1108 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1109 child.SetPosition( childPosition );
1110 parent.Add( child );
1112 // The actors should not have a world position yet
1113 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1114 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1116 // first test default, which is INHERIT_PARENT_POSITION
1117 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1118 application.SendNotification();
1119 application.Render(0); // should only really call Update as Render is not required to update scene
1120 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1121 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1122 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1123 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1125 // Change inheritance mode to use parent
1126 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1127 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1128 application.SendNotification();
1129 application.Render(0); // should only really call Update as Render is not required to update scene
1130 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1131 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1132 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1133 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1135 // Change inheritance mode to use parent + offset
1136 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1137 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1138 child.SetPosition( childOffset );
1139 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1140 application.SendNotification();
1141 application.Render(0); // should only really call Update as Render is not required to update scene
1142 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1143 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1144 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1145 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1147 // Change inheritance mode to not inherit
1148 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1149 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1150 application.SendNotification();
1151 application.Render(0); // should only really call Update as Render is not required to update scene
1152 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1153 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1154 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1155 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1159 // SetRotation(float angleRadians, Vector3 axis)
1160 int UtcDaliActorSetRotation01(void)
1162 TestApplication application;
1164 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1165 Actor actor = Actor::New();
1167 actor.SetRotation(rotation);
1169 // flush the queue and render once
1170 application.SendNotification();
1171 application.Render();
1173 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1177 int UtcDaliActorSetRotation02(void)
1179 TestApplication application;
1181 Actor actor = Actor::New();
1183 float angle = 0.785f;
1184 Vector3 axis(1.0f, 1.0f, 0.0f);
1186 actor.SetRotation(Radian( angle ), axis);
1187 Quaternion rotation( angle, axis );
1188 // flush the queue and render once
1189 application.SendNotification();
1190 application.Render();
1191 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1193 Stage::GetCurrent().Add( actor );
1194 actor.RotateBy( Degree( 360 ), axis);
1195 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1197 actor.SetRotation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1198 Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
1199 // flush the queue and render once
1200 application.SendNotification();
1201 application.Render();
1202 DALI_TEST_EQUALS( result, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1204 actor.SetRotation(Radian( angle ), axis);
1205 // flush the queue and render once
1206 application.SendNotification();
1207 application.Render();
1208 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1210 Stage::GetCurrent().Remove( actor );
1214 // RotateBy(float angleRadians, Vector3 axis)
1215 int UtcDaliActorRotateBy01(void)
1217 TestApplication application;
1219 Actor actor = Actor::New();
1221 float angle = M_PI * 0.25f;
1222 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1223 // flush the queue and render once
1224 application.SendNotification();
1225 application.Render();
1226 DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1228 Stage::GetCurrent().Add( actor );
1230 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1231 // flush the queue and render once
1232 application.SendNotification();
1233 application.Render();
1234 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1236 Stage::GetCurrent().Remove( actor );
1240 // RotateBy(Quaternion relativeRotation)
1241 int UtcDaliActorRotateBy02(void)
1243 TestApplication application;
1245 Actor actor = Actor::New();
1247 Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1248 actor.RotateBy(rotation);
1249 // flush the queue and render once
1250 application.SendNotification();
1251 application.Render();
1252 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1254 actor.RotateBy(rotation);
1255 // flush the queue and render once
1256 application.SendNotification();
1257 application.Render();
1258 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1262 int UtcDaliActorGetCurrentRotation(void)
1264 TestApplication application;
1265 Actor actor = Actor::New();
1267 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1268 actor.SetRotation(rotation);
1269 // flush the queue and render once
1270 application.SendNotification();
1271 application.Render();
1272 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1276 int UtcDaliActorGetCurrentWorldRotation(void)
1278 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1279 TestApplication application;
1281 Actor parent = Actor::New();
1282 Radian rotationAngle( Degree(90.0f) );
1283 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1284 parent.SetRotation( rotation );
1285 Stage::GetCurrent().Add( parent );
1287 Actor child = Actor::New();
1288 child.SetRotation( rotation );
1289 parent.Add( child );
1291 // The actors should not have a world rotation yet
1292 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1293 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1295 application.SendNotification();
1296 application.Render(0);
1298 DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1299 DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1301 // The actors should have a world rotation now
1302 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1303 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1305 // turn off child rotation inheritance
1306 child.SetInheritRotation( false );
1307 DALI_TEST_EQUALS( child.IsRotationInherited(), false, TEST_LOCATION );
1308 application.SendNotification();
1309 application.Render(0);
1311 // The actors should have a world rotation now
1312 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1313 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), rotation, 0.001, TEST_LOCATION );
1317 // SetScale(float scale)
1318 int UtcDaliActorSetScale01(void)
1320 TestApplication application;
1322 Actor actor = Actor::New();
1324 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1325 actor.SetScale(0.25f);
1327 Vector3 scale(10.0f, 10.0f, 10.0f);
1328 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1330 actor.SetScale(scale.x);
1332 // flush the queue and render once
1333 application.SendNotification();
1334 application.Render();
1336 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1340 // SetScale(float scaleX, float scaleY, float scaleZ)
1341 int UtcDaliActorSetScale02(void)
1343 TestApplication application;
1344 Vector3 scale(10.0f, 10.0f, 10.0f);
1346 Actor actor = Actor::New();
1348 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1349 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1351 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1353 actor.SetScale(scale.x, scale.y, scale.z);
1354 // flush the queue and render once
1355 application.SendNotification();
1356 application.Render();
1357 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1359 // add to stage and test
1360 Stage::GetCurrent().Add( actor );
1361 actor.SetScale( 2.0f, 2.0f, 2.0f );
1362 // flush the queue and render once
1363 application.SendNotification();
1364 application.Render();
1365 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1367 Stage::GetCurrent().Remove( actor );
1372 // SetScale(Vector3 scale)
1373 int UtcDaliActorSetScale03(void)
1375 TestApplication application;
1376 Vector3 scale(10.0f, 10.0f, 10.0f);
1378 Actor actor = Actor::New();
1380 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1381 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1383 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1385 actor.SetScale(scale);
1387 // flush the queue and render once
1388 application.SendNotification();
1389 application.Render();
1391 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1395 int UtcDaliActorScaleBy(void)
1397 TestApplication application;
1398 Actor actor = Actor::New();
1399 Vector3 vector(100.0f, 100.0f, 100.0f);
1401 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1403 actor.SetScale(vector);
1405 // flush the queue and render once
1406 application.SendNotification();
1407 application.Render();
1409 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1411 actor.ScaleBy(vector);
1413 // flush the queue and render once
1414 application.SendNotification();
1415 application.Render();
1417 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1421 int UtcDaliActorGetCurrentScale(void)
1423 TestApplication application;
1424 Vector3 scale(12.0f, 1.0f, 2.0f);
1426 Actor actor = Actor::New();
1428 actor.SetScale(scale);
1430 // flush the queue and render once
1431 application.SendNotification();
1432 application.Render();
1434 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1438 int UtcDaliActorGetCurrentWorldScale(void)
1440 TestApplication application;
1442 Actor parent = Actor::New();
1443 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1444 parent.SetScale( parentScale );
1445 Stage::GetCurrent().Add( parent );
1447 Actor child = Actor::New();
1448 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1449 child.SetScale( childScale );
1450 parent.Add( child );
1452 // The actors should not have a scale yet
1453 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1454 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1456 // The actors should not have a world scale yet
1457 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1458 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1460 application.SendNotification();
1461 application.Render(0);
1463 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1464 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1466 // The actors should have a world scale now
1467 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1468 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1472 int UtcDaliActorInheritScale(void)
1474 tet_infoline("Testing Actor::SetInheritScale");
1475 TestApplication application;
1477 Actor parent = Actor::New();
1478 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1479 parent.SetScale( parentScale );
1480 Stage::GetCurrent().Add( parent );
1482 Actor child = Actor::New();
1483 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1484 child.SetScale( childScale );
1485 parent.Add( child );
1487 application.SendNotification();
1488 application.Render(0);
1490 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1491 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1493 child.SetInheritScale( false );
1494 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1496 application.SendNotification();
1497 application.Render(0);
1499 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1503 int UtcDaliActorSetVisible(void)
1505 TestApplication application;
1507 Actor actor = Actor::New();
1508 actor.SetVisible(false);
1509 // flush the queue and render once
1510 application.SendNotification();
1511 application.Render();
1512 DALI_TEST_CHECK(actor.IsVisible() == false);
1514 actor.SetVisible(true);
1515 // flush the queue and render once
1516 application.SendNotification();
1517 application.Render();
1518 DALI_TEST_CHECK(actor.IsVisible() == true);
1520 // put actor on stage
1521 Stage::GetCurrent().Add( actor );
1522 actor.SetVisible(false);
1523 // flush the queue and render once
1524 application.SendNotification();
1525 application.Render();
1526 DALI_TEST_CHECK(actor.IsVisible() == false);
1530 int UtcDaliActorIsVisible(void)
1532 TestApplication application;
1534 Actor actor = Actor::New();
1536 DALI_TEST_CHECK(actor.IsVisible() == true);
1540 int UtcDaliActorSetOpacity(void)
1542 TestApplication application;
1544 Actor actor = Actor::New();
1545 // initial opacity is 1
1546 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1548 actor.SetOpacity( 0.4f);
1549 // flush the queue and render once
1550 application.SendNotification();
1551 application.Render();
1552 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1554 // change opacity, actor is on stage to change is not immediate
1555 actor.OpacityBy( 0.1f );
1556 // flush the queue and render once
1557 application.SendNotification();
1558 application.Render();
1559 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1561 // put actor on stage
1562 Stage::GetCurrent().Add( actor );
1564 // change opacity, actor is on stage to change is not immediate
1565 actor.SetOpacity( 0.9f );
1566 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1567 // flush the queue and render once
1568 application.SendNotification();
1569 application.Render();
1570 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1572 // change opacity, actor is on stage to change is not immediate
1573 actor.OpacityBy( -0.9f );
1574 // flush the queue and render once
1575 application.SendNotification();
1576 application.Render();
1577 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1581 int UtcDaliActorGetCurrentOpacity(void)
1583 TestApplication application;
1585 Actor actor = Actor::New();
1586 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1588 actor.SetOpacity(0.5f);
1589 // flush the queue and render once
1590 application.SendNotification();
1591 application.Render();
1592 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1596 int UtcDaliActorSetSensitive(void)
1598 TestApplication application;
1599 Actor actor = Actor::New();
1601 bool sensitive = !actor.IsSensitive();
1603 actor.SetSensitive(sensitive);
1605 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1609 int UtcDaliActorIsSensitive(void)
1611 TestApplication application;
1612 Actor actor = Actor::New();
1613 actor.SetSensitive(false);
1615 DALI_TEST_CHECK(false == actor.IsSensitive());
1619 int UtcDaliActorSetColor(void)
1621 TestApplication application;
1622 Actor actor = Actor::New();
1623 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1625 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1627 actor.SetColor(color);
1628 // flush the queue and render once
1629 application.SendNotification();
1630 application.Render();
1631 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1633 actor.ColorBy( Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1634 // flush the queue and render once
1635 application.SendNotification();
1636 application.Render();
1637 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1639 Stage::GetCurrent().Add( actor );
1640 actor.SetColor( color );
1641 // flush the queue and render once
1642 application.SendNotification();
1643 application.Render();
1644 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1646 actor.ColorBy( Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1647 // flush the queue and render once
1648 application.SendNotification();
1649 application.Render();
1650 // Actor color is not clamped
1651 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1652 // world color is clamped
1653 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1655 Stage::GetCurrent().Remove( actor );
1659 int UtcDaliActorGetCurrentColor(void)
1661 TestApplication application;
1662 Actor actor = Actor::New();
1663 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1665 actor.SetColor(color);
1666 // flush the queue and render once
1667 application.SendNotification();
1668 application.Render();
1669 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1673 int UtcDaliActorGetCurrentWorldColor(void)
1675 tet_infoline("Actor::GetCurrentWorldColor");
1676 TestApplication application;
1678 Actor parent = Actor::New();
1679 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1680 parent.SetColor( parentColor );
1681 Stage::GetCurrent().Add( parent );
1683 Actor child = Actor::New();
1684 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1685 child.SetColor( childColor );
1686 parent.Add( child );
1688 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1689 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1691 // verify the default color mode
1692 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1694 // The actors should not have a world color yet
1695 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1696 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1698 application.SendNotification();
1699 application.Render(0);
1701 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1702 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1704 // The actors should have a world color now
1705 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1706 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1709 child.SetColorMode( USE_OWN_COLOR );
1710 application.SendNotification();
1711 application.Render(0);
1712 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1715 child.SetColorMode( USE_PARENT_COLOR );
1716 application.SendNotification();
1717 application.Render(0);
1718 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1719 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1722 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1723 application.SendNotification();
1724 application.Render(0);
1725 Vector4 expectedColor( childColor );
1726 expectedColor.a *= parentColor.a;
1727 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1728 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1732 int UtcDaliActorSetColorMode(void)
1734 tet_infoline("Actor::SetColorMode");
1735 TestApplication application;
1736 Actor actor = Actor::New();
1737 Actor child = Actor::New();
1740 actor.SetColorMode( USE_OWN_COLOR );
1741 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1743 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1744 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1746 actor.SetColorMode( USE_PARENT_COLOR );
1747 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1749 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1750 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1754 int UtcDaliActorScreenToLocal(void)
1756 TestApplication application;
1757 Actor actor = Actor::New();
1758 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1759 actor.SetSize(100.0f, 100.0f);
1760 actor.SetPosition(10.0f, 10.0f);
1761 Stage::GetCurrent().Add(actor);
1763 // flush the queue and render once
1764 application.SendNotification();
1765 application.Render();
1770 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1772 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1773 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1777 int UtcDaliActorSetLeaveRequired(void)
1779 TestApplication application;
1781 Actor actor = Actor::New();
1783 actor.SetLeaveRequired(false);
1784 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1786 actor.SetLeaveRequired(true);
1787 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1791 int UtcDaliActorGetLeaveRequired(void)
1793 TestApplication application;
1795 Actor actor = Actor::New();
1797 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1801 int UtcDaliActorSetKeyboardFocusable(void)
1803 TestApplication application;
1805 Actor actor = Actor::New();
1807 actor.SetKeyboardFocusable(true);
1808 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1810 actor.SetKeyboardFocusable(false);
1811 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1815 int UtcDaliActorIsKeyboardFocusable(void)
1817 TestApplication application;
1819 Actor actor = Actor::New();
1821 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1826 int UtcDaliActorApplyConstraint(void)
1828 TestApplication application;
1830 gTestConstraintCalled = false;
1832 Actor actor = Actor::New();
1834 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1835 actor.ApplyConstraint(constraint);
1837 DALI_TEST_CHECK( gTestConstraintCalled == false );
1839 Stage::GetCurrent().Add( actor );
1841 // flush the queue and render once
1842 application.SendNotification();
1843 application.Render();
1845 DALI_TEST_CHECK( gTestConstraintCalled == true );
1850 int UtcDaliActorApplyConstraintAppliedCallback(void)
1852 TestApplication application;
1854 // Build a reusable constraint
1856 Actor parent = Actor::New();
1857 Vector3 parentSize( 100.0f, 100.0f, 100.0f );
1858 parent.SetSize( parentSize );
1859 Stage::GetCurrent().Add( parent );
1861 Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
1862 Source( parent, Actor::SIZE ),
1863 EqualToConstraint() );
1865 // Create some child actors
1867 Actor child1 = Actor::New();
1868 parent.Add( child1 );
1870 Actor child2 = Actor::New();
1871 parent.Add( child2 );
1873 Actor child3 = Actor::New();
1874 parent.Add( child3 );
1876 // Apply constraint with different timings - everything should be finished after 10 seconds
1878 wasConstraintCallbackCalled1 = false;
1879 wasConstraintCallbackCalled2 = false;
1880 wasConstraintCallbackCalled3 = false;
1882 constraint.SetApplyTime( 5.0f );
1883 ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
1884 activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
1886 constraint.SetApplyTime( 10.0f );
1887 ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
1888 activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
1890 constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
1891 ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
1892 activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
1894 // Check event-side size
1895 DALI_TEST_EQUALS( child1.GetSize(), Vector3::ZERO, TEST_LOCATION );
1896 DALI_TEST_EQUALS( child2.GetSize(), Vector3::ZERO, TEST_LOCATION );
1897 DALI_TEST_EQUALS( child3.GetSize(), Vector3::ZERO, TEST_LOCATION );
1899 DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1900 DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1901 DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1903 application.SendNotification();
1905 application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
1907 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
1908 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
1909 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1911 // Check signals have not fired
1912 application.SendNotification();
1913 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1914 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1915 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1917 application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
1918 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40%
1919 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
1920 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1922 // Check signals have not fired
1923 application.SendNotification();
1924 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1925 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1926 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1928 application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
1929 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60%
1930 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
1931 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
1933 // Check signals have not fired
1934 application.SendNotification();
1935 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1936 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1937 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1939 application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
1940 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80%
1941 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
1942 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
1944 // Check signals have not fired
1945 application.SendNotification();
1946 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1947 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1948 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1950 application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
1951 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100%
1952 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
1953 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
1955 // Check signals have not fired
1956 application.SendNotification();
1957 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1958 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1959 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1961 application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
1962 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire)
1963 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
1964 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
1966 // 1st signal should have fired
1967 application.SendNotification();
1968 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
1969 wasConstraintCallbackCalled1 = false;
1970 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1971 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1973 application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
1974 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1975 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
1976 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
1978 // Check signals have not fired
1979 application.SendNotification();
1980 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1981 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1982 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1984 application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
1985 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1986 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
1987 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire)
1989 // 3rd signal should have fired
1990 application.SendNotification();
1992 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1993 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1994 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
1995 wasConstraintCallbackCalled3 = false;
1997 application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
1998 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1999 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
2000 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2002 // Check signals have not fired
2003 application.SendNotification();
2004 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2005 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2006 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2008 application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
2009 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2010 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire)
2011 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2013 // 2nd signal should have fired
2014 application.SendNotification();
2015 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2016 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
2017 wasConstraintCallbackCalled2 = false;
2018 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2020 // Check that nothing has changed after a couple of buffer swaps
2022 application.Render(0);
2023 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2024 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2025 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2027 application.SendNotification();
2028 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2029 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2030 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2032 application.Render(0);
2033 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2034 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2035 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2037 application.SendNotification();
2038 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2039 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2040 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2044 int UtcDaliActorRemoveConstraints(void)
2046 tet_infoline(" UtcDaliActorRemoveConstraints");
2047 TestApplication application;
2049 gTestConstraintCalled = false;
2051 Actor actor = Actor::New();
2053 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
2054 actor.ApplyConstraint(constraint);
2055 actor.RemoveConstraints();
2057 DALI_TEST_CHECK( gTestConstraintCalled == false );
2059 Stage::GetCurrent().Add( actor );
2060 actor.ApplyConstraint(constraint);
2062 // flush the queue and render once
2063 application.SendNotification();
2064 application.Render();
2066 actor.RemoveConstraints();
2068 DALI_TEST_CHECK( gTestConstraintCalled == true );
2072 int UtcDaliActorRemoveConstraint(void)
2074 tet_infoline(" UtcDaliActorRemoveConstraint");
2075 TestApplication application;
2077 Actor actor = Actor::New();
2079 // 1. Apply Constraint1 and Constraint2, and test...
2080 unsigned int result1 = 0u;
2081 unsigned int result2 = 0u;
2082 ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2083 ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) ) );
2085 Stage::GetCurrent().Add( actor );
2086 // flush the queue and render once
2087 application.SendNotification();
2088 application.Render();
2090 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2091 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2093 // 2. Remove Constraint1 and test...
2096 actor.RemoveConstraint(activeConstraint1);
2097 // make color property dirty, which will trigger constraints to be reapplied.
2098 actor.SetColor( Color::WHITE );
2099 // flush the queue and render once
2100 application.SendNotification();
2101 application.Render();
2103 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2104 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2106 // 3. Re-Apply Constraint1 and test...
2109 activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
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, 1u, TEST_LOCATION );
2117 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2119 // 2. Remove Constraint2 and test...
2122 actor.RemoveConstraint(activeConstraint2);
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, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2132 // 2. Remove Constraint1 as well and test...
2135 actor.RemoveConstraint(activeConstraint1);
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, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2143 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2147 int UtcDaliActorRemoveConstraintTag(void)
2149 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2150 TestApplication application;
2152 Actor actor = Actor::New();
2154 // 1. Apply Constraint1 and Constraint2, and test...
2155 unsigned int result1 = 0u;
2156 unsigned int result2 = 0u;
2158 unsigned constraint1Tag = 1u;
2159 Constraint constraint1 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2160 constraint1.SetTag( constraint1Tag );
2161 actor.ApplyConstraint( constraint1 );
2163 unsigned constraint2Tag = 2u;
2164 Constraint constraint2 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2165 constraint2.SetTag( constraint2Tag );
2166 actor.ApplyConstraint( constraint2 );
2168 Stage::GetCurrent().Add( actor );
2169 // flush the queue and render once
2170 application.SendNotification();
2171 application.Render();
2173 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2174 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2176 // 2. Remove Constraint1 and test...
2179 actor.RemoveConstraints(constraint1Tag);
2180 // make color property dirty, which will trigger constraints to be reapplied.
2181 actor.SetColor( Color::WHITE );
2182 // flush the queue and render once
2183 application.SendNotification();
2184 application.Render();
2186 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2187 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2189 // 3. Re-Apply Constraint1 and test...
2192 actor.ApplyConstraint( constraint1 );
2193 // make color property dirty, which will trigger constraints to be reapplied.
2194 actor.SetColor( Color::WHITE );
2195 // flush the queue and render once
2196 application.SendNotification();
2197 application.Render();
2199 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2200 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2202 // 2. Remove Constraint2 and test...
2205 actor.RemoveConstraints(constraint2Tag);
2206 // make color property dirty, which will trigger constraints to be reapplied.
2207 actor.SetColor( Color::WHITE );
2208 // flush the queue and render once
2209 application.SendNotification();
2210 application.Render();
2212 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2213 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2215 // 2. Remove Constraint1 as well and test...
2218 actor.RemoveConstraints(constraint1Tag);
2219 // make color property dirty, which will trigger constraints to be reapplied.
2220 actor.SetColor( Color::WHITE );
2221 // flush the queue and render once
2222 application.SendNotification();
2223 application.Render();
2225 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2226 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2230 int UtcDaliActorTouchedSignal(void)
2232 TestApplication application;
2234 gTouchCallBackCalled = false;
2236 // get the root layer
2237 Actor actor = Stage::GetCurrent().GetRootLayer();
2238 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2240 application.SendNotification();
2241 application.Render();
2243 // connect to its touch signal
2244 actor.TouchedSignal().Connect( TestCallback );
2246 // simulate a touch event in the middle of the screen
2247 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2248 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
2249 Dali::Integration::TouchEvent event;
2250 event.AddPoint( point );
2251 application.ProcessEvent( event );
2253 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2258 int UtcDaliActorSetSizeSignal(void)
2260 TestApplication application;
2262 Actor actor = Actor::New();
2263 actor.SetSizeSignal().Connect( SetSizeCallback );
2265 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2266 gSetSizeCallBackCalled = false;
2267 Vector2 size2d( 1.0f, 2.0f );
2268 actor.SetSize( size2d );
2269 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2270 // SetSize with Vector2 sets depth to be the minimum of width & height
2271 DALI_TEST_EQUALS( Vector3( 1.0f, 2.0f, 1.0f ), gSetSize, TEST_LOCATION );
2273 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2274 gSetSizeCallBackCalled = false;
2275 actor.SetSize( 22.0f, 11.0f );
2276 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2277 // SetSize with Vector2 sets depth to be the minimum of width & height
2278 DALI_TEST_EQUALS( Vector3( 22.0f, 11.0f, 11.0f ), gSetSize, TEST_LOCATION );
2280 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2281 gSetSizeCallBackCalled = false;
2282 Vector3 size( 3.0f, 4.0f, 5.0f );
2283 actor.SetSize( size );
2284 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2285 DALI_TEST_EQUALS( size, gSetSize, TEST_LOCATION );
2287 // add actor to stage to see that signal still works
2288 Stage::GetCurrent().Add( actor );
2290 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2291 gSetSizeCallBackCalled = false;
2292 actor.SetSize( -1.0f, -2.0f, -3.0f );
2293 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2294 DALI_TEST_EQUALS( Vector3( -1.0f, -2.0f, -3.0f ), gSetSize, TEST_LOCATION );
2298 int UtcDaliActorOnOffStageSignal(void)
2300 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2302 TestApplication application;
2305 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2306 gActorNamesOnOffStage.clear();
2308 Actor parent = Actor::New();
2309 parent.SetName( "parent" );
2310 parent.OnStageSignal().Connect( OnStageCallback );
2311 parent.OffStageSignal().Connect( OffStageCallback );
2313 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2314 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2316 // add parent to stage
2317 Stage::GetCurrent().Add( parent );
2318 // onstage emitted, offstage not
2319 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2320 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2321 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2323 // test adding a child, should get onstage emitted
2325 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2326 gActorNamesOnOffStage.clear();
2328 Actor child = Actor::New();
2329 child.SetName( "child" );
2330 child.OnStageSignal().Connect( OnStageCallback );
2331 child.OffStageSignal().Connect( OffStageCallback );
2332 parent.Add( child ); // add child
2333 // onstage emitted, offstage not
2334 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2335 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2336 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2338 // test removing parent from stage
2340 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2341 gActorNamesOnOffStage.clear();
2343 Stage::GetCurrent().Remove( parent );
2344 // onstage not emitted, offstage is
2345 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2346 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2347 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2348 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2350 // test adding parent back to stage
2352 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2353 gActorNamesOnOffStage.clear();
2355 Stage::GetCurrent().Add( parent );
2356 // onstage emitted, offstage not
2357 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2358 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2359 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2360 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2362 // test removing child
2364 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2365 gActorNamesOnOffStage.clear();
2367 parent.Remove( child );
2368 // onstage not emitted, offstage is
2369 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2370 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2371 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2373 // test removing parent
2375 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2376 gActorNamesOnOffStage.clear();
2378 Stage::GetCurrent().Remove( parent );
2379 // onstage not emitted, offstage is
2380 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2381 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2382 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2386 int UtcDaliActorFindChildByName(void)
2388 tet_infoline("Testing Dali::Actor::FindChildByName()");
2389 TestApplication application;
2391 Actor parent = Actor::New();
2392 parent.SetName( "parent" );
2393 Actor first = Actor::New();
2394 first .SetName( "first" );
2395 Actor second = Actor::New();
2396 second.SetName( "second" );
2401 Actor found = parent.FindChildByName( "foo" );
2402 DALI_TEST_CHECK( !found );
2404 found = parent.FindChildByName( "parent" );
2405 DALI_TEST_CHECK( found == parent );
2407 found = parent.FindChildByName( "first" );
2408 DALI_TEST_CHECK( found == first );
2410 found = parent.FindChildByName( "second" );
2411 DALI_TEST_CHECK( found == second );
2415 int UtcDaliActorFindChildByAlias(void)
2417 tet_infoline("Testing Dali::Actor::FindChildByAlias()");
2418 TestApplication application;
2420 Actor parent = Actor::New();
2421 parent.SetName( "parent" );
2422 Actor first = Actor::New();
2423 first .SetName( "first" );
2424 Actor second = Actor::New();
2425 second.SetName( "second" );
2430 Actor found = parent.FindChildByAlias( "foo" );
2431 DALI_TEST_CHECK( !found );
2433 found = parent.FindChildByAlias( "parent" );
2434 DALI_TEST_CHECK( found == parent );
2436 found = parent.FindChildByAlias( "first" );
2437 DALI_TEST_CHECK( found == first );
2439 found = parent.FindChildByAlias( "second" );
2440 DALI_TEST_CHECK( found == second );
2444 int UtcDaliActorFindChildById(void)
2446 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2447 TestApplication application;
2449 Actor parent = Actor::New();
2450 Actor first = Actor::New();
2451 Actor second = Actor::New();
2456 Actor found = parent.FindChildById( 100000 );
2457 DALI_TEST_CHECK( !found );
2459 found = parent.FindChildById( parent.GetId() );
2460 DALI_TEST_CHECK( found == parent );
2462 found = parent.FindChildById( first.GetId() );
2463 DALI_TEST_CHECK( found == first );
2465 found = parent.FindChildById( second.GetId() );
2466 DALI_TEST_CHECK( found == second );
2470 int UtcDaliActorHitTest(void)
2475 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2477 mTouchPoint( touchPoint ),
2482 Vector2 mTouchPoint;
2486 TestApplication application;
2487 tet_infoline(" UtcDaliActorHitTest");
2489 // Fill a vector with different hit tests.
2490 struct HitTestData* hitTestData[] = {
2491 // scale touch point result
2492 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2493 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2494 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.
2495 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2496 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.
2500 // get the root layer
2501 Actor actor = Actor::New();
2502 actor.SetAnchorPoint( AnchorPoint::CENTER );
2503 actor.SetParentOrigin( ParentOrigin::CENTER );
2505 Stage::GetCurrent().Add( actor );
2507 gTouchCallBackCalled = false;
2509 unsigned int index = 0;
2510 while( NULL != hitTestData[index] )
2512 actor.SetSize( 1.f, 1.f );
2513 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2515 // flush the queue and render once
2516 application.SendNotification();
2517 application.Render();
2519 DALI_TEST_CHECK( !gTouchCallBackCalled );
2521 // connect to its touch signal
2522 actor.TouchedSignal().Connect(TestCallback);
2524 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2525 Dali::Integration::TouchEvent event;
2526 event.AddPoint( point );
2528 // flush the queue and render once
2529 application.SendNotification();
2530 application.Render();
2531 application.ProcessEvent( event );
2533 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2535 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2536 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2537 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2538 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2539 hitTestData[index]->mResult );
2541 gTouchCallBackCalled = false;
2547 int UtcDaliActorSetDrawMode(void)
2549 TestApplication app;
2550 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2552 Actor a = Actor::New();
2554 Stage::GetCurrent().Add(a);
2555 app.SendNotification();
2557 app.SendNotification();
2560 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2562 a.SetDrawMode( DrawMode::OVERLAY );
2563 app.SendNotification();
2566 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2568 a.SetDrawMode( DrawMode::STENCIL );
2569 app.SendNotification();
2572 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2574 a.SetDrawMode( DrawMode::NORMAL );
2575 app.SendNotification();
2578 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2582 int UtcDaliActorSetDrawModeOverlayRender(void)
2584 TestApplication app;
2585 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2587 app.SendNotification();
2590 std::vector<GLuint> ids;
2591 ids.push_back( 8 ); // first rendered actor
2592 ids.push_back( 9 ); // second rendered actor
2593 ids.push_back( 10 ); // third rendered actor
2594 app.GetGlAbstraction().SetNextTextureIds( ids );
2596 BitmapImage imageA = BitmapImage::New(16, 16);
2597 BitmapImage imageB = BitmapImage::New(16, 16);
2598 BitmapImage imageC = BitmapImage::New(16, 16);
2599 ImageActor a = ImageActor::New( imageA );
2600 ImageActor b = ImageActor::New( imageB );
2601 ImageActor c = ImageActor::New( imageC );
2603 // Render a,b,c as regular non-overlays. so order will be:
2607 Stage::GetCurrent().Add(a);
2608 Stage::GetCurrent().Add(b);
2609 Stage::GetCurrent().Add(c);
2611 app.SendNotification();
2614 // Should be 3 textures changes.
2615 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2616 typedef std::vector<GLuint>::size_type TextureSize;
2617 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2618 if( boundTextures.size() == 3 )
2620 DALI_TEST_CHECK( boundTextures[0] == 8u );
2621 DALI_TEST_CHECK( boundTextures[1] == 9u );
2622 DALI_TEST_CHECK( boundTextures[2] == 10u );
2625 // Now texture ids have been set, we can monitor their render order.
2626 // render a as an overlay (last), so order will be:
2630 a.SetDrawMode( DrawMode::OVERLAY );
2631 app.GetGlAbstraction().ClearBoundTextures();
2633 app.SendNotification();
2636 // Should be 3 texture changes.
2637 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2638 if( boundTextures.size() == 3 )
2640 DALI_TEST_CHECK( boundTextures[0] == 9u );
2641 DALI_TEST_CHECK( boundTextures[1] == 10u );
2642 DALI_TEST_CHECK( boundTextures[2] == 8u );
2648 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2650 TestApplication app;
2651 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2653 BitmapImage imageA = BitmapImage::New(16, 16);
2654 BitmapImage imageB = BitmapImage::New(16, 16);
2655 ImageActor a = ImageActor::New( imageA );
2656 ImageActor b = ImageActor::New( imageB );
2658 // Render a,b as regular non-overlays. so order will be:
2659 Stage::GetCurrent().Add(a);
2660 Stage::GetCurrent().Add(b);
2662 a.SetSize(Vector2(100.0f, 100.0f));
2663 b.SetSize(Vector2(100.0f, 100.0f));
2665 // position b overlapping a. (regular non-overlays)
2666 // hit test at point 'x'
2677 // note: b is on top, because it's Z position is higher.
2678 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2679 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2681 // connect to their touch signals
2682 a.TouchedSignal().Connect(TestCallback);
2683 b.TouchedSignal().Connect(TestCallback2);
2685 a.SetDrawMode( DrawMode::NORMAL );
2686 b.SetDrawMode( DrawMode::NORMAL );
2687 SimulateTouchForSetOverlayHitTest(app);
2689 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2690 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2691 // Make Actor a an overlay.
2702 // note: a is on top, because it is an overlay.
2703 a.SetDrawMode( DrawMode::OVERLAY );
2704 b.SetDrawMode( DrawMode::NORMAL );
2705 SimulateTouchForSetOverlayHitTest(app);
2707 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2708 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2709 // Make both Actors as overlays
2720 // note: b is on top, because it is the 2nd child in the hierarchy.
2721 a.SetDrawMode( DrawMode::OVERLAY );
2722 b.SetDrawMode( DrawMode::OVERLAY );
2723 SimulateTouchForSetOverlayHitTest(app);
2725 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2726 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2730 int UtcDaliActorGetCurrentWorldMatrix(void)
2732 TestApplication app;
2733 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2735 Actor parent = Actor::New();
2736 parent.SetParentOrigin(ParentOrigin::CENTER);
2737 parent.SetAnchorPoint(AnchorPoint::CENTER);
2738 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2739 Radian rotationAngle(Degree(85.0f));
2740 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2741 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2742 parent.SetPosition( parentPosition );
2743 parent.SetRotation( parentRotation );
2744 parent.SetScale( parentScale );
2745 Stage::GetCurrent().Add( parent );
2747 Actor child = Actor::New();
2748 child.SetParentOrigin(ParentOrigin::CENTER);
2749 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2750 Radian childRotationAngle(Degree(23.0f));
2751 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2752 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2753 child.SetPosition( childPosition );
2754 child.SetRotation( childRotation );
2755 child.SetScale( childScale );
2756 parent.Add( child );
2758 // The actors should not have a world matrix yet
2759 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2760 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2762 app.SendNotification();
2765 app.SendNotification();
2767 Matrix parentMatrix(false);
2768 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2770 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2771 Quaternion childWorldRotation = parentRotation * childRotation;
2772 Vector3 childWorldScale = parentScale * childScale;
2774 Matrix childWorldMatrix(false);
2775 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2777 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2778 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2784 int UtcDaliActorConstrainedToWorldMatrix(void)
2786 TestApplication app;
2787 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2789 Actor parent = Actor::New();
2790 parent.SetParentOrigin(ParentOrigin::CENTER);
2791 parent.SetAnchorPoint(AnchorPoint::CENTER);
2792 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2793 Radian rotationAngle(Degree(85.0f));
2794 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2795 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2796 parent.SetPosition( parentPosition );
2797 parent.SetRotation( parentRotation );
2798 parent.SetScale( parentScale );
2799 Stage::GetCurrent().Add( parent );
2801 Actor child = Actor::New();
2802 child.SetParentOrigin(ParentOrigin::CENTER);
2803 Constraint posConstraint = Constraint::New<Vector3>( Actor::POSITION, Source( parent, Actor::WORLD_MATRIX), PositionComponentConstraint() );
2804 child.ApplyConstraint(posConstraint);
2806 Stage::GetCurrent().Add( child );
2808 // The actors should not have a world matrix yet
2809 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2810 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2812 app.SendNotification();
2815 app.SendNotification();
2817 Matrix parentMatrix(false);
2818 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2820 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2821 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2825 int UtcDaliActorUnparent(void)
2827 TestApplication app;
2828 tet_infoline(" UtcDaliActorUnparent");
2830 Actor parent = Actor::New();
2831 Stage::GetCurrent().Add( parent );
2833 Actor child = Actor::New();
2835 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2836 DALI_TEST_CHECK( !child.GetParent() );
2838 // Test that calling Unparent with no parent is a NOOP
2841 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2842 DALI_TEST_CHECK( !child.GetParent() );
2844 // Test that Unparent works
2845 parent.Add( child );
2847 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2848 DALI_TEST_CHECK( parent == child.GetParent() );
2852 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2853 DALI_TEST_CHECK( !child.GetParent() );
2855 // Test that UnparentAndReset works
2856 parent.Add( child );
2858 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2859 DALI_TEST_CHECK( parent == child.GetParent() );
2861 UnparentAndReset( child );
2863 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2864 DALI_TEST_CHECK( !child );
2866 // Test that UnparentAndReset is a NOOP with empty handle
2867 UnparentAndReset( child );
2869 DALI_TEST_CHECK( !child );
2873 int UtcDaliActorGetChildAt(void)
2875 TestApplication app;
2876 tet_infoline(" UtcDaliActorGetChildAt");
2878 Actor parent = Actor::New();
2879 Stage::GetCurrent().Add( parent );
2881 Actor child0 = Actor::New();
2882 parent.Add( child0 );
2884 Actor child1 = Actor::New();
2885 parent.Add( child1 );
2887 Actor child2 = Actor::New();
2888 parent.Add( child2 );
2890 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2891 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2892 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2896 int UtcDaliActorSetGetOverlay(void)
2898 TestApplication app;
2899 tet_infoline(" UtcDaliActorSetGetOverlay");
2901 Actor parent = Actor::New();
2902 parent.SetDrawMode(DrawMode::OVERLAY );
2903 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2908 // Current Dynamics functions are crashing, so testing these sections are futile
2910 int UtcDaliActorDynamics(void)
2912 DALI_TEST_CHECK( true );
2916 int UtcDaliActorCreateDestroy(void)
2918 Actor* actor = new Actor;
2919 DALI_TEST_CHECK( actor );
2926 struct PropertyStringIndex
2928 const char * const name;
2929 const Property::Index index;
2930 const Property::Type type;
2933 const PropertyStringIndex PROPERTY_TABLE[] =
2935 { "parent-origin", Actor::PARENT_ORIGIN, Property::VECTOR3 },
2936 { "parent-origin-x", Actor::PARENT_ORIGIN_X, Property::FLOAT },
2937 { "parent-origin-y", Actor::PARENT_ORIGIN_Y, Property::FLOAT },
2938 { "parent-origin-z", Actor::PARENT_ORIGIN_Z, Property::FLOAT },
2939 { "anchor-point", Actor::ANCHOR_POINT, Property::VECTOR3 },
2940 { "anchor-point-x", Actor::ANCHOR_POINT_X, Property::FLOAT },
2941 { "anchor-point-y", Actor::ANCHOR_POINT_Y, Property::FLOAT },
2942 { "anchor-point-z", Actor::ANCHOR_POINT_Z, Property::FLOAT },
2943 { "size", Actor::SIZE, Property::VECTOR3 },
2944 { "size-width", Actor::SIZE_WIDTH, Property::FLOAT },
2945 { "size-height", Actor::SIZE_HEIGHT, Property::FLOAT },
2946 { "size-depth", Actor::SIZE_DEPTH, Property::FLOAT },
2947 { "position", Actor::POSITION, Property::VECTOR3 },
2948 { "position-x", Actor::POSITION_X, Property::FLOAT },
2949 { "position-y", Actor::POSITION_Y, Property::FLOAT },
2950 { "position-z", Actor::POSITION_Z, Property::FLOAT },
2951 { "world-position", Actor::WORLD_POSITION, Property::VECTOR3 },
2952 { "world-position-x", Actor::WORLD_POSITION_X, Property::FLOAT },
2953 { "world-position-y", Actor::WORLD_POSITION_Y, Property::FLOAT },
2954 { "world-position-z", Actor::WORLD_POSITION_Z, Property::FLOAT },
2955 { "rotation", Actor::ROTATION, Property::ROTATION },
2956 { "world-rotation", Actor::WORLD_ROTATION, Property::ROTATION },
2957 { "scale", Actor::SCALE, Property::VECTOR3 },
2958 { "scale-x", Actor::SCALE_X, Property::FLOAT },
2959 { "scale-y", Actor::SCALE_Y, Property::FLOAT },
2960 { "scale-z", Actor::SCALE_Z, Property::FLOAT },
2961 { "world-scale", Actor::WORLD_SCALE, Property::VECTOR3 },
2962 { "visible", Actor::VISIBLE, Property::BOOLEAN },
2963 { "color", Actor::COLOR, Property::VECTOR4 },
2964 { "color-red", Actor::COLOR_RED, Property::FLOAT },
2965 { "color-green", Actor::COLOR_GREEN, Property::FLOAT },
2966 { "color-blue", Actor::COLOR_BLUE, Property::FLOAT },
2967 { "color-alpha", Actor::COLOR_ALPHA, Property::FLOAT },
2968 { "world-color", Actor::WORLD_COLOR, Property::VECTOR4 },
2969 { "world-matrix", Actor::WORLD_MATRIX, Property::MATRIX },
2970 { "name", Actor::NAME, Property::STRING },
2971 { "sensitive", Actor::SENSITIVE, Property::BOOLEAN },
2972 { "leave-required", Actor::LEAVE_REQUIRED, Property::BOOLEAN },
2973 { "inherit-rotation", Actor::INHERIT_ROTATION, Property::BOOLEAN },
2974 { "inherit-scale", Actor::INHERIT_SCALE, Property::BOOLEAN },
2975 { "color-mode", Actor::COLOR_MODE, Property::STRING },
2976 { "position-inheritance", Actor::POSITION_INHERITANCE, Property::STRING },
2977 { "draw-mode", Actor::DRAW_MODE, Property::STRING },
2979 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2980 } // unnamed namespace
2982 int UtcDaliActorProperties(void)
2984 TestApplication app;
2986 Actor actor = Actor::New();
2988 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2990 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2991 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2992 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2993 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );