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 const char* vertexSource =
46 " gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
47 " vTexCoord = aTexCoord;\n"
50 const char* fragmentSource =
53 " gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n"
56 bool gTouchCallBackCalled=false;
57 bool gTouchCallBack2Called=false;
60 * Simulates a Down Touch at 25.0, 25.0.
61 * @param[in] app Test Application instance.
63 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
65 app.SendNotification();
67 app.SendNotification();
70 gTouchCallBackCalled = false;
71 gTouchCallBack2Called = false;
73 // simulate a touch event
74 Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
75 Dali::Integration::TouchEvent event;
76 event.AddPoint( point );
77 app.ProcessEvent( event );
79 app.SendNotification();
81 app.SendNotification();
87 static bool gTestConstraintCalled;
91 Vector4 operator()(const Vector4& color)
93 gTestConstraintCalled = true;
94 return Vector4(color.x, color.y, color.z, 0.1f);
99 * TestConstraint reference.
100 * When constraint is called, the resultRef is updated
101 * with the value supplied.
104 struct TestConstraintRef
106 TestConstraintRef(unsigned int& resultRef, unsigned int value)
107 : mResultRef(resultRef),
112 T operator()(const T& current)
118 unsigned int& mResultRef;
122 bool wasConstraintCallbackCalled1 = false;
123 void TestConstraintCallback1( ActiveConstraint& constraint )
125 wasConstraintCallbackCalled1 = true;
128 bool wasConstraintCallbackCalled2 = false;
129 void TestConstraintCallback2( ActiveConstraint& constraint )
131 wasConstraintCallbackCalled2 = true;
134 bool wasConstraintCallbackCalled3 = false;
135 void TestConstraintCallback3( ActiveConstraint& constraint )
137 wasConstraintCallbackCalled3 = true;
140 static bool TestCallback(Actor actor, const TouchEvent& event)
142 gTouchCallBackCalled = true;
147 static bool TestCallback2(Actor actor, const TouchEvent& event)
149 gTouchCallBack2Called = true;
154 static Vector3 gSetSize;
155 static bool gSetSizeCallBackCalled;
156 void SetSizeCallback( Actor actor, const Vector3& size )
158 gSetSizeCallBackCalled = true;
161 // validation stuff for onstage & offstage signals
162 static std::vector< std::string > gActorNamesOnOffStage;
163 static int gOnStageCallBackCalled;
164 void OnStageCallback( Actor actor )
166 ++gOnStageCallBackCalled;
167 gActorNamesOnOffStage.push_back( actor.GetName() );
168 DALI_TEST_CHECK( actor.OnStage() == true );
170 static int gOffStageCallBackCalled;
171 void OffStageCallback( Actor actor )
173 ++gOffStageCallBackCalled;
174 gActorNamesOnOffStage.push_back( actor.GetName() );
175 DALI_TEST_CHECK( actor.OnStage() == false );
178 struct PositionComponentConstraint
180 PositionComponentConstraint(){}
182 Vector3 operator()(const Vector3& current, const PropertyInput& property)
184 const Matrix& m = property.GetMatrix();
188 m.GetTransformComponents(pos, rot, scale);
195 } // anonymous namespace
198 //& purpose: Testing New API
199 int UtcDaliActorNew(void)
201 TestApplication application;
203 Actor actor = Actor::New();
205 DALI_TEST_CHECK(actor);
209 //& purpose: Testing Dali::Actor::DownCast()
210 int UtcDaliActorDownCast(void)
212 TestApplication application;
213 tet_infoline("Testing Dali::Actor::DownCast()");
215 Actor actor = Actor::New();
216 BaseHandle object(actor);
217 Actor actor2 = Actor::DownCast(object);
218 DALI_TEST_CHECK(actor2);
222 //& purpose: Testing Dali::Actor::DownCast()
223 int UtcDaliActorDownCast2(void)
225 TestApplication application;
226 tet_infoline("Testing Dali::Actor::DownCast()");
228 BaseHandle unInitializedObject;
229 Actor actor = Actor::DownCast(unInitializedObject);
230 DALI_TEST_CHECK(!actor);
234 //& purpose: Testing Dali::Actor::GetName()
235 int UtcDaliActorGetName(void)
237 TestApplication application;
239 Actor actor = Actor::New();
241 DALI_TEST_CHECK(actor.GetName().empty());
245 //& purpose: Testing Dali::Actor::SetName()
246 int UtcDaliActorSetName(void)
248 TestApplication application;
250 string str("ActorName");
251 Actor actor = Actor::New();
254 DALI_TEST_CHECK(actor.GetName() == str);
258 int UtcDaliActorGetId(void)
260 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
261 TestApplication application;
263 Actor first = Actor::New();
264 Actor second = Actor::New();
265 Actor third = Actor::New();
267 DALI_TEST_CHECK(first.GetId() != second.GetId());
268 DALI_TEST_CHECK(second.GetId() != third.GetId());
272 int UtcDaliActorIsRoot(void)
274 TestApplication application;
276 Actor actor = Actor::New();
277 DALI_TEST_CHECK(!actor.IsRoot());
279 // get the root layer
280 actor = Stage::GetCurrent().GetLayer( 0 );
281 DALI_TEST_CHECK( actor.IsRoot() );
285 int UtcDaliActorOnStage(void)
287 TestApplication application;
289 Actor actor = Actor::New();
290 DALI_TEST_CHECK( !actor.OnStage() );
292 // get the root layer
293 actor = Stage::GetCurrent().GetLayer( 0 );
294 DALI_TEST_CHECK( actor.OnStage() );
298 int UtcDaliActorIsLayer(void)
300 TestApplication application;
302 Actor actor = Actor::New();
303 DALI_TEST_CHECK( !actor.IsLayer() );
305 // get the root layer
306 actor = Stage::GetCurrent().GetLayer( 0 );
307 DALI_TEST_CHECK( actor.IsLayer() );
311 int UtcDaliActorGetLayer(void)
313 TestApplication application;
315 Actor actor = Actor::New();
316 Stage::GetCurrent().Add(actor);
317 Layer layer = actor.GetLayer();
319 DALI_TEST_CHECK(layer);
321 // get the root layers layer
322 actor = Stage::GetCurrent().GetLayer( 0 );
323 DALI_TEST_CHECK( actor.GetLayer() );
327 int UtcDaliActorAdd(void)
329 tet_infoline("Testing Actor::Add");
330 TestApplication application;
332 Actor parent = Actor::New();
333 Actor child = Actor::New();
335 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
339 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
341 Actor parent2 = Actor::New();
342 parent2.Add( child );
344 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
345 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
347 // try Adding to same parent again, works
348 parent2.Add( child );
349 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
351 // try reparenting an orphaned child
353 Actor temporaryParent = Actor::New();
354 temporaryParent.Add( child );
355 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
357 // temporaryParent has now died, reparent the orphaned child
358 parent2.Add( child );
359 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
364 parent2.Add( parent2 );
365 tet_printf("Assertion test failed - no Exception\n" );
366 tet_result(TET_FAIL);
368 catch(Dali::DaliException& e)
370 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
371 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
372 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
376 tet_printf("Assertion test failed - wrong Exception\n" );
377 tet_result(TET_FAIL);
380 // try reparenting root
383 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
384 tet_printf("Assertion test failed - no Exception\n" );
385 tet_result(TET_FAIL);
387 catch(Dali::DaliException& e)
389 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
390 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
391 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
395 tet_printf("Assertion test failed - wrong Exception\n" );
396 tet_result(TET_FAIL);
403 parent2.Add( empty );
404 tet_printf("Assertion test failed - no Exception\n" );
405 tet_result(TET_FAIL);
407 catch(Dali::DaliException& e)
409 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
410 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
411 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
415 tet_printf("Assertion test failed - wrong Exception\n" );
416 tet_result(TET_FAIL);
421 int UtcDaliActorRemove01(void)
423 tet_infoline("Testing Actor::Remove");
424 TestApplication application;
426 Actor parent = Actor::New();
427 Actor child = Actor::New();
428 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
431 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
433 parent.Remove(child);
434 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
436 // remove again, no problem
437 parent.Remove(child);
438 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
442 // try illegal Remove
445 parent.Remove( parent );
446 tet_printf("Assertion test failed - no Exception\n" );
447 tet_result(TET_FAIL);
449 catch(Dali::DaliException& e)
451 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
452 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
453 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
457 tet_printf("Assertion test failed - wrong Exception\n" );
458 tet_result(TET_FAIL);
465 parent.Remove( empty );
466 tet_printf("Assertion test failed - no Exception\n" );
467 tet_result(TET_FAIL);
469 catch(Dali::DaliException& e)
471 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
472 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
473 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
477 tet_printf("Assertion test failed - wrong Exception\n" );
478 tet_result(TET_FAIL);
483 int UtcDaliActorRemove02(void)
485 TestApplication application;
487 Actor parent = Actor::New();
488 Actor child = Actor::New();
489 Actor random = Actor::New();
491 Stage::GetCurrent().Add( parent );
493 DALI_TEST_CHECK(parent.GetChildCount() == 0);
497 DALI_TEST_CHECK(parent.GetChildCount() == 1);
499 parent.Remove(random);
501 DALI_TEST_CHECK(parent.GetChildCount() == 1);
503 Stage::GetCurrent().Remove( parent );
505 DALI_TEST_CHECK(parent.GetChildCount() == 1);
509 int UtcDaliActorGetChildCount(void)
511 TestApplication application;
513 Actor parent = Actor::New();
514 Actor child = Actor::New();
516 DALI_TEST_CHECK(parent.GetChildCount() == 0);
520 DALI_TEST_CHECK(parent.GetChildCount() == 1);
524 int UtcDaliActorGetChildren01(void)
526 TestApplication application;
528 Actor parent = Actor::New();
529 Actor first = Actor::New();
530 Actor second = Actor::New();
531 Actor third = Actor::New();
537 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
538 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
539 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
543 int UtcDaliActorGetChildren02(void)
545 TestApplication application;
547 Actor parent = Actor::New();
548 Actor first = Actor::New();
549 Actor second = Actor::New();
550 Actor third = Actor::New();
556 const Actor& constParent = parent;
558 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
559 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
560 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
564 int UtcDaliActorGetParent01(void)
566 TestApplication application;
568 Actor parent = Actor::New();
569 Actor child = Actor::New();
573 DALI_TEST_CHECK(child.GetParent() == parent);
577 int UtcDaliActorGetParent02(void)
579 TestApplication application;
581 Actor actor = Actor::New();
583 DALI_TEST_CHECK(!actor.GetParent());
587 int UtcDaliActorSetParentOrigin(void)
589 TestApplication application;
591 Actor actor = Actor::New();
593 Vector3 vector(0.7f, 0.8f, 0.9f);
594 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
596 actor.SetParentOrigin(vector);
598 // flush the queue and render once
599 application.SendNotification();
600 application.Render();
602 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
604 Stage::GetCurrent().Add( actor );
606 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
608 // flush the queue and render once
609 application.SendNotification();
610 application.Render();
612 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
614 Stage::GetCurrent().Remove( actor );
618 int UtcDaliActorGetCurrentParentOrigin(void)
620 TestApplication application;
622 Actor actor = Actor::New();
624 Vector3 vector(0.7f, 0.8f, 0.9f);
625 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
627 actor.SetParentOrigin(vector);
629 // flush the queue and render once
630 application.SendNotification();
631 application.Render();
633 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
637 int UtcDaliActorSetAnchorPoint(void)
639 TestApplication application;
641 Actor actor = Actor::New();
643 Vector3 vector(0.7f, 0.8f, 0.9f);
644 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
646 actor.SetAnchorPoint(vector);
648 // flush the queue and render once
649 application.SendNotification();
650 application.Render();
652 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
654 Stage::GetCurrent().Add( actor );
656 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
657 // flush the queue and render once
658 application.SendNotification();
659 application.Render();
661 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
663 Stage::GetCurrent().Remove( actor );
667 int UtcDaliActorGetCurrentAnchorPoint(void)
669 TestApplication application;
671 Actor actor = Actor::New();
673 Vector3 vector(0.7f, 0.8f, 0.9f);
674 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
676 actor.SetAnchorPoint(vector);
678 // flush the queue and render once
679 application.SendNotification();
680 application.Render();
682 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
686 // SetSize(float width, float height)
687 int UtcDaliActorSetSize01(void)
689 TestApplication application;
691 Actor actor = Actor::New();
692 Vector3 vector(100.0f, 100.0f, 100.0f);
694 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
696 actor.SetSize(vector.x, vector.y);
698 // flush the queue and render once
699 application.SendNotification();
700 application.Render();
702 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
706 // SetSize(float width, float height, float depth)
707 int UtcDaliActorSetSize02(void)
709 TestApplication application;
711 Actor actor = Actor::New();
712 Vector3 vector(100.0f, 100.0f, 100.0f);
714 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
716 actor.SetSize(vector.x, vector.y, vector.z);
718 // flush the queue and render once
719 application.SendNotification();
720 application.Render();
722 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
726 // SetSize(Vector2 size)
727 int UtcDaliActorSetSize03(void)
729 TestApplication application;
731 Actor actor = Actor::New();
732 Vector3 vector(100.0f, 100.0f, 100.0f);
734 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
736 actor.SetSize(Vector2(vector.x, vector.y));
738 // flush the queue and render once
739 application.SendNotification();
740 application.Render();
742 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
746 // SetSize(Vector3 size)
747 int UtcDaliActorSetSize04(void)
749 TestApplication application;
751 Actor actor = Actor::New();
752 Vector3 vector(100.0f, 100.0f, 100.0f);
754 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
756 actor.SetSize(vector);
758 // flush the queue and render once
759 application.SendNotification();
760 application.Render();
762 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
764 Stage::GetCurrent().Add( actor );
765 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
767 // flush the queue and render once
768 application.SendNotification();
769 application.Render();
771 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
772 Stage::GetCurrent().Remove( actor );
776 int UtcDaliActorGetCurrentSize(void)
778 TestApplication application;
780 Actor actor = Actor::New();
781 Vector3 vector(100.0f, 100.0f, 20.0f);
783 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
785 actor.SetSize(vector);
787 // flush the queue and render once
788 application.SendNotification();
789 application.Render();
791 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
795 // SetPosition(float x, float y)
796 int UtcDaliActorSetPosition01(void)
798 TestApplication application;
800 Actor actor = Actor::New();
802 // Set to random to start off with
803 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
805 Vector3 vector(100.0f, 100.0f, 0.0f);
807 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
809 actor.SetPosition(vector.x, vector.y);
810 // flush the queue and render once
811 application.SendNotification();
812 application.Render();
813 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
815 Stage::GetCurrent().Add( actor );
816 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
817 // flush the queue and render once
818 application.SendNotification();
819 application.Render();
820 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
825 // flush the queue and render once
826 application.SendNotification();
827 application.Render();
828 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
830 actor.MoveBy( Vector3( 0.1f, 0.1f, 0.1f ) );
831 // flush the queue and render once
832 application.SendNotification();
833 application.Render();
834 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
836 Stage::GetCurrent().Remove( actor );
840 // SetPosition(float x, float y, float z)
841 int UtcDaliActorSetPosition02(void)
843 TestApplication application;
845 Actor actor = Actor::New();
847 // Set to random to start off with
848 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
850 Vector3 vector(100.0f, 100.0f, 100.0f);
852 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
854 actor.SetPosition(vector.x, vector.y, vector.z);
856 // flush the queue and render once
857 application.SendNotification();
858 application.Render();
860 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
864 // SetPosition(Vector3 position)
865 int UtcDaliActorSetPosition03(void)
867 TestApplication application;
869 Actor actor = Actor::New();
871 // Set to random to start off with
872 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
874 Vector3 vector(100.0f, 100.0f, 100.0f);
876 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
878 actor.SetPosition(vector);
880 // flush the queue and render once
881 application.SendNotification();
882 application.Render();
884 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
888 int UtcDaliActorSetX(void)
890 TestApplication application;
892 Actor actor = Actor::New();
894 Vector3 vector(100.0f, 0.0f, 0.0f);
896 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
900 // flush the queue and render once
901 application.SendNotification();
902 application.Render();
904 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
908 int UtcDaliActorSetY(void)
910 TestApplication application;
912 Actor actor = Actor::New();
914 Vector3 vector(0.0f, 100.0f, 0.0f);
916 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
920 // flush the queue and render once
921 application.SendNotification();
922 application.Render();
924 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
928 int UtcDaliActorSetZ(void)
930 TestApplication application;
932 Actor actor = Actor::New();
934 Vector3 vector(0.0f, 0.0f, 100.0f);
936 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
940 // flush the queue and render once
941 application.SendNotification();
942 application.Render();
944 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
948 int UtcDaliActorMoveBy(void)
950 TestApplication application;
952 Actor actor = Actor::New();
953 Vector3 vector(100.0f, 100.0f, 100.0f);
955 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
957 actor.SetPosition(vector);
959 // flush the queue and render once
960 application.SendNotification();
961 application.Render();
963 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
965 actor.MoveBy(vector);
967 // flush the queue and render once
968 application.SendNotification();
969 application.Render();
971 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
975 int UtcDaliActorGetCurrentPosition(void)
977 TestApplication application;
979 Actor actor = Actor::New();
980 Vector3 setVector(100.0f, 100.0f, 0.0f);
981 actor.SetPosition(setVector);
983 // flush the queue and render once
984 application.SendNotification();
985 application.Render();
987 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
991 int UtcDaliActorGetCurrentWorldPosition(void)
993 TestApplication application;
995 Actor parent = Actor::New();
996 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
997 parent.SetPosition( parentPosition );
998 parent.SetParentOrigin( ParentOrigin::CENTER );
999 parent.SetAnchorPoint( AnchorPoint::CENTER );
1000 Stage::GetCurrent().Add( parent );
1002 Actor child = Actor::New();
1003 child.SetParentOrigin( ParentOrigin::CENTER );
1004 child.SetAnchorPoint( AnchorPoint::CENTER );
1005 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1006 child.SetPosition( childPosition );
1007 parent.Add( child );
1009 // The actors should not have a world position yet
1010 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1011 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1013 application.SendNotification();
1014 application.Render(0);
1016 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1017 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1019 // The actors should have a world position now
1020 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1021 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1025 int UtcDaliActorInheritPosition(void)
1027 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1028 TestApplication application;
1030 Actor parent = Actor::New();
1031 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1032 parent.SetPosition( parentPosition );
1033 parent.SetParentOrigin( ParentOrigin::CENTER );
1034 parent.SetAnchorPoint( AnchorPoint::CENTER );
1035 Stage::GetCurrent().Add( parent );
1037 Actor child = Actor::New();
1038 child.SetParentOrigin( ParentOrigin::CENTER );
1039 child.SetAnchorPoint( AnchorPoint::CENTER );
1040 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1041 child.SetPosition( childPosition );
1042 parent.Add( child );
1044 // The actors should not have a world position yet
1045 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1046 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1048 // first test default, which is INHERIT_PARENT_POSITION
1049 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1050 application.SendNotification();
1051 application.Render(0); // should only really call Update as Render is not required to update scene
1052 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1053 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1054 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1055 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1057 // Change inheritance mode to use parent
1058 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1059 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1060 application.SendNotification();
1061 application.Render(0); // should only really call Update as Render is not required to update scene
1062 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1063 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1064 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1065 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1067 // Change inheritance mode to use parent + offset
1068 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1069 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1070 child.SetPosition( childOffset );
1071 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1072 application.SendNotification();
1073 application.Render(0); // should only really call Update as Render is not required to update scene
1074 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1075 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1076 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1077 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1079 // Change inheritance mode to not inherit
1080 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1081 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1082 application.SendNotification();
1083 application.Render(0); // should only really call Update as Render is not required to update scene
1084 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1085 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1086 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1087 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1091 // SetRotation(float angleRadians, Vector3 axis)
1092 int UtcDaliActorSetRotation01(void)
1094 TestApplication application;
1096 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1097 Actor actor = Actor::New();
1099 actor.SetRotation(rotation);
1101 // flush the queue and render once
1102 application.SendNotification();
1103 application.Render();
1105 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1109 int UtcDaliActorSetRotation02(void)
1111 TestApplication application;
1113 Actor actor = Actor::New();
1115 float angle = 0.785f;
1116 Vector3 axis(1.0f, 1.0f, 0.0f);
1118 actor.SetRotation(Radian( angle ), axis);
1119 Quaternion rotation( angle, axis );
1120 // flush the queue and render once
1121 application.SendNotification();
1122 application.Render();
1123 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1125 Stage::GetCurrent().Add( actor );
1126 actor.RotateBy( Degree( 360 ), axis);
1127 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1129 actor.SetRotation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1130 Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
1131 // flush the queue and render once
1132 application.SendNotification();
1133 application.Render();
1134 DALI_TEST_EQUALS( result, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1136 actor.SetRotation(Radian( angle ), axis);
1137 // flush the queue and render once
1138 application.SendNotification();
1139 application.Render();
1140 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1142 Stage::GetCurrent().Remove( actor );
1146 // RotateBy(float angleRadians, Vector3 axis)
1147 int UtcDaliActorRotateBy01(void)
1149 TestApplication application;
1151 Actor actor = Actor::New();
1153 float angle = M_PI * 0.25f;
1154 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1155 // flush the queue and render once
1156 application.SendNotification();
1157 application.Render();
1158 DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1160 Stage::GetCurrent().Add( actor );
1162 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1163 // flush the queue and render once
1164 application.SendNotification();
1165 application.Render();
1166 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1168 Stage::GetCurrent().Remove( actor );
1172 // RotateBy(Quaternion relativeRotation)
1173 int UtcDaliActorRotateBy02(void)
1175 TestApplication application;
1177 Actor actor = Actor::New();
1179 Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1180 actor.RotateBy(rotation);
1181 // flush the queue and render once
1182 application.SendNotification();
1183 application.Render();
1184 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1186 actor.RotateBy(rotation);
1187 // flush the queue and render once
1188 application.SendNotification();
1189 application.Render();
1190 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1194 int UtcDaliActorGetCurrentRotation(void)
1196 TestApplication application;
1197 Actor actor = Actor::New();
1199 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1200 actor.SetRotation(rotation);
1201 // flush the queue and render once
1202 application.SendNotification();
1203 application.Render();
1204 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1208 int UtcDaliActorGetCurrentWorldRotation(void)
1210 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1211 TestApplication application;
1213 Actor parent = Actor::New();
1214 Radian rotationAngle( Degree(90.0f) );
1215 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1216 parent.SetRotation( rotation );
1217 Stage::GetCurrent().Add( parent );
1219 Actor child = Actor::New();
1220 child.SetRotation( rotation );
1221 parent.Add( child );
1223 // The actors should not have a world rotation yet
1224 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1225 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1227 application.SendNotification();
1228 application.Render(0);
1230 DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1231 DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1233 // The actors should have a world rotation now
1234 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1235 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1237 // turn off child rotation inheritance
1238 child.SetInheritRotation( false );
1239 DALI_TEST_EQUALS( child.IsRotationInherited(), false, TEST_LOCATION );
1240 application.SendNotification();
1241 application.Render(0);
1243 // The actors should have a world rotation now
1244 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1245 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), rotation, 0.001, TEST_LOCATION );
1249 // SetScale(float scale)
1250 int UtcDaliActorSetScale01(void)
1252 TestApplication application;
1254 Actor actor = Actor::New();
1256 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1257 actor.SetScale(0.25f);
1259 Vector3 scale(10.0f, 10.0f, 10.0f);
1260 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1262 actor.SetScale(scale.x);
1264 // flush the queue and render once
1265 application.SendNotification();
1266 application.Render();
1268 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1272 // SetScale(float scaleX, float scaleY, float scaleZ)
1273 int UtcDaliActorSetScale02(void)
1275 TestApplication application;
1276 Vector3 scale(10.0f, 10.0f, 10.0f);
1278 Actor actor = Actor::New();
1280 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1281 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1283 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1285 actor.SetScale(scale.x, scale.y, scale.z);
1286 // flush the queue and render once
1287 application.SendNotification();
1288 application.Render();
1289 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1291 // add to stage and test
1292 Stage::GetCurrent().Add( actor );
1293 actor.SetScale( 2.0f, 2.0f, 2.0f );
1294 // flush the queue and render once
1295 application.SendNotification();
1296 application.Render();
1297 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1299 Stage::GetCurrent().Remove( actor );
1304 // SetScale(Vector3 scale)
1305 int UtcDaliActorSetScale03(void)
1307 TestApplication application;
1308 Vector3 scale(10.0f, 10.0f, 10.0f);
1310 Actor actor = Actor::New();
1312 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1313 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1315 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1317 actor.SetScale(scale);
1319 // flush the queue and render once
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1327 int UtcDaliActorScaleBy(void)
1329 TestApplication application;
1330 Actor actor = Actor::New();
1331 Vector3 vector(100.0f, 100.0f, 100.0f);
1333 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1335 actor.SetScale(vector);
1337 // flush the queue and render once
1338 application.SendNotification();
1339 application.Render();
1341 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1343 actor.ScaleBy(vector);
1345 // flush the queue and render once
1346 application.SendNotification();
1347 application.Render();
1349 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1353 int UtcDaliActorGetCurrentScale(void)
1355 TestApplication application;
1356 Vector3 scale(12.0f, 1.0f, 2.0f);
1358 Actor actor = Actor::New();
1360 actor.SetScale(scale);
1362 // flush the queue and render once
1363 application.SendNotification();
1364 application.Render();
1366 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1370 int UtcDaliActorGetCurrentWorldScale(void)
1372 TestApplication application;
1374 Actor parent = Actor::New();
1375 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1376 parent.SetScale( parentScale );
1377 Stage::GetCurrent().Add( parent );
1379 Actor child = Actor::New();
1380 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1381 child.SetScale( childScale );
1382 parent.Add( child );
1384 // The actors should not have a scale yet
1385 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1386 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1388 // The actors should not have a world scale yet
1389 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1390 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1392 application.SendNotification();
1393 application.Render(0);
1395 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1396 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1398 // The actors should have a world scale now
1399 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1400 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1404 int UtcDaliActorInheritScale(void)
1406 tet_infoline("Testing Actor::SetInheritScale");
1407 TestApplication application;
1409 Actor parent = Actor::New();
1410 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1411 parent.SetScale( parentScale );
1412 Stage::GetCurrent().Add( parent );
1414 Actor child = Actor::New();
1415 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1416 child.SetScale( childScale );
1417 parent.Add( child );
1419 application.SendNotification();
1420 application.Render(0);
1422 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1423 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1425 child.SetInheritScale( false );
1426 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1428 application.SendNotification();
1429 application.Render(0);
1431 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1435 int UtcDaliActorSetVisible(void)
1437 TestApplication application;
1439 Actor actor = Actor::New();
1440 actor.SetVisible(false);
1441 // flush the queue and render once
1442 application.SendNotification();
1443 application.Render();
1444 DALI_TEST_CHECK(actor.IsVisible() == false);
1446 actor.SetVisible(true);
1447 // flush the queue and render once
1448 application.SendNotification();
1449 application.Render();
1450 DALI_TEST_CHECK(actor.IsVisible() == true);
1452 // put actor on stage
1453 Stage::GetCurrent().Add( actor );
1454 actor.SetVisible(false);
1455 // flush the queue and render once
1456 application.SendNotification();
1457 application.Render();
1458 DALI_TEST_CHECK(actor.IsVisible() == false);
1462 int UtcDaliActorIsVisible(void)
1464 TestApplication application;
1466 Actor actor = Actor::New();
1468 DALI_TEST_CHECK(actor.IsVisible() == true);
1472 int UtcDaliActorSetOpacity(void)
1474 TestApplication application;
1476 Actor actor = Actor::New();
1477 // initial opacity is 1
1478 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1480 actor.SetOpacity( 0.4f);
1481 // flush the queue and render once
1482 application.SendNotification();
1483 application.Render();
1484 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1486 // change opacity, actor is on stage to change is not immediate
1487 actor.OpacityBy( 0.1f );
1488 // flush the queue and render once
1489 application.SendNotification();
1490 application.Render();
1491 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1493 // put actor on stage
1494 Stage::GetCurrent().Add( actor );
1496 // change opacity, actor is on stage to change is not immediate
1497 actor.SetOpacity( 0.9f );
1498 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1499 // flush the queue and render once
1500 application.SendNotification();
1501 application.Render();
1502 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1504 // change opacity, actor is on stage to change is not immediate
1505 actor.OpacityBy( -0.9f );
1506 // flush the queue and render once
1507 application.SendNotification();
1508 application.Render();
1509 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1513 int UtcDaliActorGetCurrentOpacity(void)
1515 TestApplication application;
1517 Actor actor = Actor::New();
1518 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1520 actor.SetOpacity(0.5f);
1521 // flush the queue and render once
1522 application.SendNotification();
1523 application.Render();
1524 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1528 int UtcDaliActorSetSensitive(void)
1530 TestApplication application;
1531 Actor actor = Actor::New();
1533 bool sensitive = !actor.IsSensitive();
1535 actor.SetSensitive(sensitive);
1537 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1541 int UtcDaliActorIsSensitive(void)
1543 TestApplication application;
1544 Actor actor = Actor::New();
1545 actor.SetSensitive(false);
1547 DALI_TEST_CHECK(false == actor.IsSensitive());
1551 int UtcDaliActorSetInheritShaderEffect(void)
1553 TestApplication application;
1555 Actor actor = Actor::New();
1557 actor.SetInheritShaderEffect(false);
1558 // flush the queue and render once
1559 application.SendNotification();
1560 application.Render();
1561 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == false);
1563 actor.SetInheritShaderEffect(true);
1564 // flush the queue and render once
1565 application.SendNotification();
1566 application.Render();
1567 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true);
1571 int UtcDaliActorGetInheritShaderEffect(void)
1573 TestApplication application;
1575 Actor actor = Actor::New();
1577 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true);
1581 int UtcDaliActorSetShaderEffect(void)
1583 TestApplication application;
1584 Actor actor = Actor::New();
1586 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1588 DALI_TEST_CHECK(effect != actor.GetShaderEffect());
1590 actor.SetShaderEffect(effect);
1592 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1596 int UtcDaliActorGetShaderEffect(void)
1598 TestApplication application;
1599 Actor actor = Actor::New();
1601 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1602 actor.SetShaderEffect(effect);
1604 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1608 int UtcDaliActorRemoveShaderEffect01(void)
1610 TestApplication application;
1611 Actor actor = Actor::New();
1613 ShaderEffect defaultEffect = actor.GetShaderEffect();
1615 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1616 actor.SetShaderEffect(effect);
1618 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1620 actor.RemoveShaderEffect();
1622 DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect());
1626 int UtcDaliActorRemoveShaderEffect02(void)
1628 TestApplication application;
1629 Actor actor = Actor::New();
1631 ShaderEffect defaultEffect = actor.GetShaderEffect();
1633 actor.RemoveShaderEffect();
1635 DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect());
1639 int UtcDaliActorSetColor(void)
1641 TestApplication application;
1642 Actor actor = Actor::New();
1643 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1645 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1647 actor.SetColor(color);
1648 // flush the queue and render once
1649 application.SendNotification();
1650 application.Render();
1651 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1653 actor.ColorBy( Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1654 // flush the queue and render once
1655 application.SendNotification();
1656 application.Render();
1657 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1659 Stage::GetCurrent().Add( actor );
1660 actor.SetColor( color );
1661 // flush the queue and render once
1662 application.SendNotification();
1663 application.Render();
1664 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1666 actor.ColorBy( Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1667 // flush the queue and render once
1668 application.SendNotification();
1669 application.Render();
1670 // Actor color is not clamped
1671 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1672 // world color is clamped
1673 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1675 Stage::GetCurrent().Remove( actor );
1679 int UtcDaliActorGetCurrentColor(void)
1681 TestApplication application;
1682 Actor actor = Actor::New();
1683 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1685 actor.SetColor(color);
1686 // flush the queue and render once
1687 application.SendNotification();
1688 application.Render();
1689 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1693 int UtcDaliActorGetCurrentWorldColor(void)
1695 tet_infoline("Actor::GetCurrentWorldColor");
1696 TestApplication application;
1698 Actor parent = Actor::New();
1699 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1700 parent.SetColor( parentColor );
1701 Stage::GetCurrent().Add( parent );
1703 Actor child = Actor::New();
1704 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1705 child.SetColor( childColor );
1706 parent.Add( child );
1708 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1709 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1711 // verify the default color mode
1712 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1714 // The actors should not have a world color yet
1715 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1716 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1718 application.SendNotification();
1719 application.Render(0);
1721 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1722 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1724 // The actors should have a world color now
1725 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1726 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1729 child.SetColorMode( USE_OWN_COLOR );
1730 application.SendNotification();
1731 application.Render(0);
1732 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1735 child.SetColorMode( USE_PARENT_COLOR );
1736 application.SendNotification();
1737 application.Render(0);
1738 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1739 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1742 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1743 application.SendNotification();
1744 application.Render(0);
1745 Vector4 expectedColor( childColor );
1746 expectedColor.a *= parentColor.a;
1747 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1748 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1752 int UtcDaliActorSetColorMode(void)
1754 tet_infoline("Actor::SetColorMode");
1755 TestApplication application;
1756 Actor actor = Actor::New();
1757 Actor child = Actor::New();
1760 actor.SetColorMode( USE_OWN_COLOR );
1761 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1763 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1764 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1766 actor.SetColorMode( USE_PARENT_COLOR );
1767 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1769 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1770 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1774 int UtcDaliActorScreenToLocal(void)
1776 TestApplication application;
1777 Actor actor = Actor::New();
1778 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1779 actor.SetSize(100.0f, 100.0f);
1780 actor.SetPosition(10.0f, 10.0f);
1781 Stage::GetCurrent().Add(actor);
1783 // flush the queue and render once
1784 application.SendNotification();
1785 application.Render();
1790 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1792 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1793 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1797 int UtcDaliActorSetLeaveRequired(void)
1799 TestApplication application;
1801 Actor actor = Actor::New();
1803 actor.SetLeaveRequired(false);
1804 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1806 actor.SetLeaveRequired(true);
1807 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1811 int UtcDaliActorGetLeaveRequired(void)
1813 TestApplication application;
1815 Actor actor = Actor::New();
1817 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1821 int UtcDaliActorSetKeyboardFocusable(void)
1823 TestApplication application;
1825 Actor actor = Actor::New();
1827 actor.SetKeyboardFocusable(true);
1828 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1830 actor.SetKeyboardFocusable(false);
1831 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1835 int UtcDaliActorIsKeyboardFocusable(void)
1837 TestApplication application;
1839 Actor actor = Actor::New();
1841 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1846 int UtcDaliActorApplyConstraint(void)
1848 TestApplication application;
1850 gTestConstraintCalled = false;
1852 Actor actor = Actor::New();
1854 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1855 actor.ApplyConstraint(constraint);
1857 DALI_TEST_CHECK( gTestConstraintCalled == false );
1859 Stage::GetCurrent().Add( actor );
1861 // flush the queue and render once
1862 application.SendNotification();
1863 application.Render();
1865 DALI_TEST_CHECK( gTestConstraintCalled == true );
1870 int UtcDaliActorApplyConstraintAppliedCallback(void)
1872 TestApplication application;
1874 // Build a reusable constraint
1876 Actor parent = Actor::New();
1877 Vector3 parentSize( 100.0f, 100.0f, 100.0f );
1878 parent.SetSize( parentSize );
1879 Stage::GetCurrent().Add( parent );
1881 Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
1882 Source( parent, Actor::SIZE ),
1883 EqualToConstraint() );
1885 // Create some child actors
1887 Actor child1 = Actor::New();
1888 parent.Add( child1 );
1890 Actor child2 = Actor::New();
1891 parent.Add( child2 );
1893 Actor child3 = Actor::New();
1894 parent.Add( child3 );
1896 // Apply constraint with different timings - everything should be finished after 10 seconds
1898 wasConstraintCallbackCalled1 = false;
1899 wasConstraintCallbackCalled2 = false;
1900 wasConstraintCallbackCalled3 = false;
1902 constraint.SetApplyTime( 5.0f );
1903 ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
1904 activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
1906 constraint.SetApplyTime( 10.0f );
1907 ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
1908 activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
1910 constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
1911 ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
1912 activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
1914 DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1915 DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1916 DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1918 application.SendNotification();
1920 application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
1921 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
1922 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
1923 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1925 // Check signals have not fired
1926 application.SendNotification();
1927 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1928 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1929 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1931 application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
1932 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40%
1933 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
1934 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1936 // Check signals have not fired
1937 application.SendNotification();
1938 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1939 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1940 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1942 application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
1943 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60%
1944 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
1945 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
1947 // Check signals have not fired
1948 application.SendNotification();
1949 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1950 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1951 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1953 application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
1954 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80%
1955 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
1956 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
1958 // Check signals have not fired
1959 application.SendNotification();
1960 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1961 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1962 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1964 application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
1965 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100%
1966 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
1967 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
1969 // Check signals have not fired
1970 application.SendNotification();
1971 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1972 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1973 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1975 application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
1976 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire)
1977 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
1978 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
1980 // 1st signal should have fired
1981 application.SendNotification();
1982 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
1983 wasConstraintCallbackCalled1 = false;
1984 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1985 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1987 application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
1988 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1989 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
1990 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
1992 // Check signals have not fired
1993 application.SendNotification();
1994 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1995 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1996 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1998 application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
1999 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2000 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
2001 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire)
2003 // 3rd signal should have fired
2004 application.SendNotification();
2006 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2007 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2008 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
2009 wasConstraintCallbackCalled3 = false;
2011 application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
2012 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2013 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
2014 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2016 // Check signals have not fired
2017 application.SendNotification();
2018 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2019 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2020 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2022 application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
2023 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2024 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire)
2025 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2027 // 2nd signal should have fired
2028 application.SendNotification();
2029 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2030 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
2031 wasConstraintCallbackCalled2 = false;
2032 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2034 // Check that nothing has changed after a couple of buffer swaps
2036 application.Render(0);
2037 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2038 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2039 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2041 application.SendNotification();
2042 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2043 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2044 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2046 application.Render(0);
2047 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2048 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2049 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2051 application.SendNotification();
2052 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2053 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2054 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2058 int UtcDaliActorRemoveConstraints(void)
2060 tet_infoline(" UtcDaliActorRemoveConstraints");
2061 TestApplication application;
2063 gTestConstraintCalled = false;
2065 Actor actor = Actor::New();
2067 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
2068 actor.ApplyConstraint(constraint);
2069 actor.RemoveConstraints();
2071 DALI_TEST_CHECK( gTestConstraintCalled == false );
2073 Stage::GetCurrent().Add( actor );
2074 actor.ApplyConstraint(constraint);
2076 // flush the queue and render once
2077 application.SendNotification();
2078 application.Render();
2080 actor.RemoveConstraints();
2082 DALI_TEST_CHECK( gTestConstraintCalled == true );
2086 int UtcDaliActorRemoveConstraint(void)
2088 tet_infoline(" UtcDaliActorRemoveConstraint");
2089 TestApplication application;
2091 Actor actor = Actor::New();
2093 // 1. Apply Constraint1 and Constraint2, and test...
2094 unsigned int result1 = 0u;
2095 unsigned int result2 = 0u;
2096 ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2097 ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) ) );
2099 Stage::GetCurrent().Add( actor );
2100 // flush the queue and render once
2101 application.SendNotification();
2102 application.Render();
2104 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2105 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2107 // 2. Remove Constraint1 and test...
2110 actor.RemoveConstraint(activeConstraint1);
2111 // make color property dirty, which will trigger constraints to be reapplied.
2112 actor.SetColor( Color::WHITE );
2113 // flush the queue and render once
2114 application.SendNotification();
2115 application.Render();
2117 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2118 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2120 // 3. Re-Apply Constraint1 and test...
2123 activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2124 // make color property dirty, which will trigger constraints to be reapplied.
2125 actor.SetColor( Color::WHITE );
2126 // flush the queue and render once
2127 application.SendNotification();
2128 application.Render();
2130 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2131 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2133 // 2. Remove Constraint2 and test...
2136 actor.RemoveConstraint(activeConstraint2);
2137 // make color property dirty, which will trigger constraints to be reapplied.
2138 actor.SetColor( Color::WHITE );
2139 // flush the queue and render once
2140 application.SendNotification();
2141 application.Render();
2143 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2144 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2146 // 2. Remove Constraint1 as well and test...
2149 actor.RemoveConstraint(activeConstraint1);
2150 // make color property dirty, which will trigger constraints to be reapplied.
2151 actor.SetColor( Color::WHITE );
2152 // flush the queue and render once
2153 application.SendNotification();
2154 application.Render();
2156 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2157 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2161 int UtcDaliActorRemoveConstraintTag(void)
2163 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2164 TestApplication application;
2166 Actor actor = Actor::New();
2168 // 1. Apply Constraint1 and Constraint2, and test...
2169 unsigned int result1 = 0u;
2170 unsigned int result2 = 0u;
2172 unsigned constraint1Tag = 1u;
2173 Constraint constraint1 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2174 constraint1.SetTag( constraint1Tag );
2175 actor.ApplyConstraint( constraint1 );
2177 unsigned constraint2Tag = 2u;
2178 Constraint constraint2 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2179 constraint2.SetTag( constraint2Tag );
2180 actor.ApplyConstraint( constraint2 );
2182 Stage::GetCurrent().Add( actor );
2183 // flush the queue and render once
2184 application.SendNotification();
2185 application.Render();
2187 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2188 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2190 // 2. Remove Constraint1 and test...
2193 actor.RemoveConstraints(constraint1Tag);
2194 // make color property dirty, which will trigger constraints to be reapplied.
2195 actor.SetColor( Color::WHITE );
2196 // flush the queue and render once
2197 application.SendNotification();
2198 application.Render();
2200 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2201 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2203 // 3. Re-Apply Constraint1 and test...
2206 actor.ApplyConstraint( constraint1 );
2207 // make color property dirty, which will trigger constraints to be reapplied.
2208 actor.SetColor( Color::WHITE );
2209 // flush the queue and render once
2210 application.SendNotification();
2211 application.Render();
2213 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2214 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2216 // 2. Remove Constraint2 and test...
2219 actor.RemoveConstraints(constraint2Tag);
2220 // make color property dirty, which will trigger constraints to be reapplied.
2221 actor.SetColor( Color::WHITE );
2222 // flush the queue and render once
2223 application.SendNotification();
2224 application.Render();
2226 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2227 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2229 // 2. Remove Constraint1 as well and test...
2232 actor.RemoveConstraints(constraint1Tag);
2233 // make color property dirty, which will trigger constraints to be reapplied.
2234 actor.SetColor( Color::WHITE );
2235 // flush the queue and render once
2236 application.SendNotification();
2237 application.Render();
2239 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2240 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2244 int UtcDaliActorTouchedSignal(void)
2246 TestApplication application;
2248 gTouchCallBackCalled = false;
2250 // get the root layer
2251 Actor actor = Stage::GetCurrent().GetRootLayer();
2252 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2254 application.SendNotification();
2255 application.Render();
2257 // connect to its touch signal
2258 actor.TouchedSignal().Connect( TestCallback );
2260 // simulate a touch event in the middle of the screen
2261 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2262 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
2263 Dali::Integration::TouchEvent event;
2264 event.AddPoint( point );
2265 application.ProcessEvent( event );
2267 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2272 int UtcDaliActorSetSizeSignal(void)
2274 TestApplication application;
2276 Actor actor = Actor::New();
2277 actor.SetSizeSignal().Connect( SetSizeCallback );
2279 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2280 gSetSizeCallBackCalled = false;
2281 Vector2 size2d( 1.0f, 2.0f );
2282 actor.SetSize( size2d );
2283 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2284 // SetSize with Vector2 sets depth to be the minimum of width & height
2285 DALI_TEST_EQUALS( Vector3( 1.0f, 2.0f, 1.0f ), gSetSize, TEST_LOCATION );
2287 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2288 gSetSizeCallBackCalled = false;
2289 actor.SetSize( 22.0f, 11.0f );
2290 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2291 // SetSize with Vector2 sets depth to be the minimum of width & height
2292 DALI_TEST_EQUALS( Vector3( 22.0f, 11.0f, 11.0f ), gSetSize, TEST_LOCATION );
2294 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2295 gSetSizeCallBackCalled = false;
2296 Vector3 size( 3.0f, 4.0f, 5.0f );
2297 actor.SetSize( size );
2298 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2299 DALI_TEST_EQUALS( size, gSetSize, TEST_LOCATION );
2301 // add actor to stage to see that signal still works
2302 Stage::GetCurrent().Add( actor );
2304 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2305 gSetSizeCallBackCalled = false;
2306 actor.SetSize( -1.0f, -2.0f, -3.0f );
2307 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2308 DALI_TEST_EQUALS( Vector3( -1.0f, -2.0f, -3.0f ), gSetSize, TEST_LOCATION );
2312 int UtcDaliActorOnOffStageSignal(void)
2314 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2316 TestApplication application;
2319 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2320 gActorNamesOnOffStage.clear();
2322 Actor parent = Actor::New();
2323 parent.SetName( "parent" );
2324 parent.OnStageSignal().Connect( OnStageCallback );
2325 parent.OffStageSignal().Connect( OffStageCallback );
2327 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2328 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2330 // add parent to stage
2331 Stage::GetCurrent().Add( parent );
2332 // onstage emitted, offstage not
2333 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2334 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2335 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2337 // test adding a child, should get onstage emitted
2339 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2340 gActorNamesOnOffStage.clear();
2342 Actor child = Actor::New();
2343 child.SetName( "child" );
2344 child.OnStageSignal().Connect( OnStageCallback );
2345 child.OffStageSignal().Connect( OffStageCallback );
2346 parent.Add( child ); // add child
2347 // onstage emitted, offstage not
2348 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2349 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2350 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2352 // test removing parent from stage
2354 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2355 gActorNamesOnOffStage.clear();
2357 Stage::GetCurrent().Remove( parent );
2358 // onstage not emitted, offstage is
2359 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2360 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2361 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2362 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2364 // test adding parent back to stage
2366 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2367 gActorNamesOnOffStage.clear();
2369 Stage::GetCurrent().Add( parent );
2370 // onstage emitted, offstage not
2371 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2372 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2373 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2374 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2376 // test removing child
2378 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2379 gActorNamesOnOffStage.clear();
2381 parent.Remove( child );
2382 // onstage not emitted, offstage is
2383 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2384 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2385 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2387 // test removing parent
2389 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2390 gActorNamesOnOffStage.clear();
2392 Stage::GetCurrent().Remove( parent );
2393 // onstage not emitted, offstage is
2394 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2395 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2396 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2400 int UtcDaliActorFindChildByName(void)
2402 tet_infoline("Testing Dali::Actor::FindChildByName()");
2403 TestApplication application;
2405 Actor parent = Actor::New();
2406 parent.SetName( "parent" );
2407 Actor first = Actor::New();
2408 first .SetName( "first" );
2409 Actor second = Actor::New();
2410 second.SetName( "second" );
2415 Actor found = parent.FindChildByName( "foo" );
2416 DALI_TEST_CHECK( !found );
2418 found = parent.FindChildByName( "parent" );
2419 DALI_TEST_CHECK( found == parent );
2421 found = parent.FindChildByName( "first" );
2422 DALI_TEST_CHECK( found == first );
2424 found = parent.FindChildByName( "second" );
2425 DALI_TEST_CHECK( found == second );
2429 int UtcDaliActorFindChildByAlias(void)
2431 tet_infoline("Testing Dali::Actor::FindChildByAlias()");
2432 TestApplication application;
2434 Actor parent = Actor::New();
2435 parent.SetName( "parent" );
2436 Actor first = Actor::New();
2437 first .SetName( "first" );
2438 Actor second = Actor::New();
2439 second.SetName( "second" );
2444 Actor found = parent.FindChildByAlias( "foo" );
2445 DALI_TEST_CHECK( !found );
2447 found = parent.FindChildByAlias( "parent" );
2448 DALI_TEST_CHECK( found == parent );
2450 found = parent.FindChildByAlias( "first" );
2451 DALI_TEST_CHECK( found == first );
2453 found = parent.FindChildByAlias( "second" );
2454 DALI_TEST_CHECK( found == second );
2458 int UtcDaliActorFindChildById(void)
2460 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2461 TestApplication application;
2463 Actor parent = Actor::New();
2464 Actor first = Actor::New();
2465 Actor second = Actor::New();
2470 Actor found = parent.FindChildById( 100000 );
2471 DALI_TEST_CHECK( !found );
2473 found = parent.FindChildById( parent.GetId() );
2474 DALI_TEST_CHECK( found == parent );
2476 found = parent.FindChildById( first.GetId() );
2477 DALI_TEST_CHECK( found == first );
2479 found = parent.FindChildById( second.GetId() );
2480 DALI_TEST_CHECK( found == second );
2484 int UtcDaliActorHitTest(void)
2489 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2491 mTouchPoint( touchPoint ),
2496 Vector2 mTouchPoint;
2500 TestApplication application;
2501 tet_infoline(" UtcDaliActorHitTest");
2503 // Fill a vector with different hit tests.
2504 struct HitTestData* hitTestData[] = {
2505 // scale touch point result
2506 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2507 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2508 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.
2509 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2510 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.
2514 // get the root layer
2515 Actor actor = Actor::New();
2516 actor.SetAnchorPoint( AnchorPoint::CENTER );
2517 actor.SetParentOrigin( ParentOrigin::CENTER );
2519 Stage::GetCurrent().Add( actor );
2521 gTouchCallBackCalled = false;
2523 unsigned int index = 0;
2524 while( NULL != hitTestData[index] )
2526 actor.SetSize( 1.f, 1.f );
2527 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2529 // flush the queue and render once
2530 application.SendNotification();
2531 application.Render();
2533 DALI_TEST_CHECK( !gTouchCallBackCalled );
2535 // connect to its touch signal
2536 actor.TouchedSignal().Connect(TestCallback);
2538 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2539 Dali::Integration::TouchEvent event;
2540 event.AddPoint( point );
2542 // flush the queue and render once
2543 application.SendNotification();
2544 application.Render();
2545 application.ProcessEvent( event );
2547 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2549 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2550 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2551 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2552 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2553 hitTestData[index]->mResult );
2555 gTouchCallBackCalled = false;
2561 int UtcDaliActorSetDrawMode(void)
2563 TestApplication app;
2564 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2566 Actor a = Actor::New();
2568 Stage::GetCurrent().Add(a);
2569 app.SendNotification();
2571 app.SendNotification();
2574 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2576 a.SetDrawMode( DrawMode::OVERLAY );
2577 app.SendNotification();
2580 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2582 a.SetDrawMode( DrawMode::STENCIL );
2583 app.SendNotification();
2586 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2588 a.SetDrawMode( DrawMode::NORMAL );
2589 app.SendNotification();
2592 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2596 int UtcDaliActorSetDrawModeOverlayRender(void)
2598 TestApplication app;
2599 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2601 app.SendNotification();
2604 std::vector<GLuint> ids;
2605 ids.push_back( 8 ); // first rendered actor
2606 ids.push_back( 9 ); // second rendered actor
2607 ids.push_back( 10 ); // third rendered actor
2608 app.GetGlAbstraction().SetNextTextureIds( ids );
2610 BitmapImage imageA = BitmapImage::New(16, 16);
2611 BitmapImage imageB = BitmapImage::New(16, 16);
2612 BitmapImage imageC = BitmapImage::New(16, 16);
2613 ImageActor a = ImageActor::New( imageA );
2614 ImageActor b = ImageActor::New( imageB );
2615 ImageActor c = ImageActor::New( imageC );
2617 // Render a,b,c as regular non-overlays. so order will be:
2621 Stage::GetCurrent().Add(a);
2622 Stage::GetCurrent().Add(b);
2623 Stage::GetCurrent().Add(c);
2625 app.SendNotification();
2628 // Should be 3 textures changes.
2629 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2630 typedef std::vector<GLuint>::size_type TextureSize;
2631 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2632 if( boundTextures.size() == 3 )
2634 DALI_TEST_CHECK( boundTextures[0] == 8u );
2635 DALI_TEST_CHECK( boundTextures[1] == 9u );
2636 DALI_TEST_CHECK( boundTextures[2] == 10u );
2639 // Now texture ids have been set, we can monitor their render order.
2640 // render a as an overlay (last), so order will be:
2644 a.SetDrawMode( DrawMode::OVERLAY );
2645 app.GetGlAbstraction().ClearBoundTextures();
2647 app.SendNotification();
2650 // Should be 3 texture changes.
2651 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2652 if( boundTextures.size() == 3 )
2654 DALI_TEST_CHECK( boundTextures[0] == 9u );
2655 DALI_TEST_CHECK( boundTextures[1] == 10u );
2656 DALI_TEST_CHECK( boundTextures[2] == 8u );
2662 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2664 TestApplication app;
2665 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2667 BitmapImage imageA = BitmapImage::New(16, 16);
2668 BitmapImage imageB = BitmapImage::New(16, 16);
2669 ImageActor a = ImageActor::New( imageA );
2670 ImageActor b = ImageActor::New( imageB );
2672 // Render a,b as regular non-overlays. so order will be:
2673 Stage::GetCurrent().Add(a);
2674 Stage::GetCurrent().Add(b);
2676 a.SetSize(Vector2(100.0f, 100.0f));
2677 b.SetSize(Vector2(100.0f, 100.0f));
2679 // position b overlapping a. (regular non-overlays)
2680 // hit test at point 'x'
2691 // note: b is on top, because it's Z position is higher.
2692 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2693 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2695 // connect to their touch signals
2696 a.TouchedSignal().Connect(TestCallback);
2697 b.TouchedSignal().Connect(TestCallback2);
2699 a.SetDrawMode( DrawMode::NORMAL );
2700 b.SetDrawMode( DrawMode::NORMAL );
2701 SimulateTouchForSetOverlayHitTest(app);
2703 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2704 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2705 // Make Actor a an overlay.
2716 // note: a is on top, because it is an overlay.
2717 a.SetDrawMode( DrawMode::OVERLAY );
2718 b.SetDrawMode( DrawMode::NORMAL );
2719 SimulateTouchForSetOverlayHitTest(app);
2721 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2722 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2723 // Make both Actors as overlays
2734 // note: b is on top, because it is the 2nd child in the hierarchy.
2735 a.SetDrawMode( DrawMode::OVERLAY );
2736 b.SetDrawMode( DrawMode::OVERLAY );
2737 SimulateTouchForSetOverlayHitTest(app);
2739 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2740 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2744 int UtcDaliActorGetCurrentWorldMatrix(void)
2746 TestApplication app;
2747 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2749 Actor parent = Actor::New();
2750 parent.SetParentOrigin(ParentOrigin::CENTER);
2751 parent.SetAnchorPoint(AnchorPoint::CENTER);
2752 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2753 Radian rotationAngle(Degree(85.0f));
2754 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2755 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2756 parent.SetPosition( parentPosition );
2757 parent.SetRotation( parentRotation );
2758 parent.SetScale( parentScale );
2759 Stage::GetCurrent().Add( parent );
2761 Actor child = Actor::New();
2762 child.SetParentOrigin(ParentOrigin::CENTER);
2763 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2764 Radian childRotationAngle(Degree(23.0f));
2765 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2766 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2767 child.SetPosition( childPosition );
2768 child.SetRotation( childRotation );
2769 child.SetScale( childScale );
2770 parent.Add( child );
2772 // The actors should not have a world matrix yet
2773 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2774 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2776 app.SendNotification();
2779 app.SendNotification();
2781 Matrix parentMatrix(false);
2782 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2784 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2785 Quaternion childWorldRotation = parentRotation * childRotation;
2786 Vector3 childWorldScale = parentScale * childScale;
2788 Matrix childWorldMatrix(false);
2789 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2791 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2792 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2798 int UtcDaliActorConstrainedToWorldMatrix(void)
2800 TestApplication app;
2801 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2803 Actor parent = Actor::New();
2804 parent.SetParentOrigin(ParentOrigin::CENTER);
2805 parent.SetAnchorPoint(AnchorPoint::CENTER);
2806 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2807 Radian rotationAngle(Degree(85.0f));
2808 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2809 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2810 parent.SetPosition( parentPosition );
2811 parent.SetRotation( parentRotation );
2812 parent.SetScale( parentScale );
2813 Stage::GetCurrent().Add( parent );
2815 Actor child = Actor::New();
2816 child.SetParentOrigin(ParentOrigin::CENTER);
2817 Constraint posConstraint = Constraint::New<Vector3>( Actor::POSITION, Source( parent, Actor::WORLD_MATRIX), PositionComponentConstraint() );
2818 child.ApplyConstraint(posConstraint);
2820 Stage::GetCurrent().Add( child );
2822 // The actors should not have a world matrix yet
2823 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2824 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2826 app.SendNotification();
2829 app.SendNotification();
2831 Matrix parentMatrix(false);
2832 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2834 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2835 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2839 int UtcDaliActorUnparent(void)
2841 TestApplication app;
2842 tet_infoline(" UtcDaliActorUnparent");
2844 Actor parent = Actor::New();
2845 Stage::GetCurrent().Add( parent );
2847 Actor child = Actor::New();
2849 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2850 DALI_TEST_CHECK( !child.GetParent() );
2852 // Test that calling Unparent with no parent is a NOOP
2855 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2856 DALI_TEST_CHECK( !child.GetParent() );
2858 // Test that Unparent works
2859 parent.Add( child );
2861 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2862 DALI_TEST_CHECK( parent == child.GetParent() );
2866 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2867 DALI_TEST_CHECK( !child.GetParent() );
2869 // Test that UnparentAndReset works
2870 parent.Add( child );
2872 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2873 DALI_TEST_CHECK( parent == child.GetParent() );
2875 UnparentAndReset( child );
2877 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2878 DALI_TEST_CHECK( !child );
2880 // Test that UnparentAndReset is a NOOP with empty handle
2881 UnparentAndReset( child );
2883 DALI_TEST_CHECK( !child );
2887 int UtcDaliActorGetChildAt(void)
2889 TestApplication app;
2890 tet_infoline(" UtcDaliActorGetChildAt");
2892 Actor parent = Actor::New();
2893 Stage::GetCurrent().Add( parent );
2895 Actor child0 = Actor::New();
2896 parent.Add( child0 );
2898 Actor child1 = Actor::New();
2899 parent.Add( child1 );
2901 Actor child2 = Actor::New();
2902 parent.Add( child2 );
2904 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2905 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2906 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2910 int UtcDaliActorSetGetOverlay(void)
2912 TestApplication app;
2913 tet_infoline(" UtcDaliActorSetGetOverlay");
2915 Actor parent = Actor::New();
2916 parent.SetDrawMode(DrawMode::OVERLAY );
2917 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2922 // Current Dynamics functions are crashing, so testing these sections are futile
2924 int UtcDaliActorDynamics(void)
2926 DALI_TEST_CHECK( true );
2930 int UtcDaliActorCreateDestroy(void)
2932 Actor* actor = new Actor;
2933 DALI_TEST_CHECK( actor );
2940 struct PropertyStringIndex
2942 const char * const name;
2943 const Property::Index index;
2944 const Property::Type type;
2947 const PropertyStringIndex PROPERTY_TABLE[] =
2949 { "parent-origin", Actor::PARENT_ORIGIN, Property::VECTOR3 },
2950 { "parent-origin-x", Actor::PARENT_ORIGIN_X, Property::FLOAT },
2951 { "parent-origin-y", Actor::PARENT_ORIGIN_Y, Property::FLOAT },
2952 { "parent-origin-z", Actor::PARENT_ORIGIN_Z, Property::FLOAT },
2953 { "anchor-point", Actor::ANCHOR_POINT, Property::VECTOR3 },
2954 { "anchor-point-x", Actor::ANCHOR_POINT_X, Property::FLOAT },
2955 { "anchor-point-y", Actor::ANCHOR_POINT_Y, Property::FLOAT },
2956 { "anchor-point-z", Actor::ANCHOR_POINT_Z, Property::FLOAT },
2957 { "size", Actor::SIZE, Property::VECTOR3 },
2958 { "size-width", Actor::SIZE_WIDTH, Property::FLOAT },
2959 { "size-height", Actor::SIZE_HEIGHT, Property::FLOAT },
2960 { "size-depth", Actor::SIZE_DEPTH, Property::FLOAT },
2961 { "position", Actor::POSITION, Property::VECTOR3 },
2962 { "position-x", Actor::POSITION_X, Property::FLOAT },
2963 { "position-y", Actor::POSITION_Y, Property::FLOAT },
2964 { "position-z", Actor::POSITION_Z, Property::FLOAT },
2965 { "world-position", Actor::WORLD_POSITION, Property::VECTOR3 },
2966 { "world-position-x", Actor::WORLD_POSITION_X, Property::FLOAT },
2967 { "world-position-y", Actor::WORLD_POSITION_Y, Property::FLOAT },
2968 { "world-position-z", Actor::WORLD_POSITION_Z, Property::FLOAT },
2969 { "rotation", Actor::ROTATION, Property::ROTATION },
2970 { "world-rotation", Actor::WORLD_ROTATION, Property::ROTATION },
2971 { "scale", Actor::SCALE, Property::VECTOR3 },
2972 { "scale-x", Actor::SCALE_X, Property::FLOAT },
2973 { "scale-y", Actor::SCALE_Y, Property::FLOAT },
2974 { "scale-z", Actor::SCALE_Z, Property::FLOAT },
2975 { "world-scale", Actor::WORLD_SCALE, Property::VECTOR3 },
2976 { "visible", Actor::VISIBLE, Property::BOOLEAN },
2977 { "color", Actor::COLOR, Property::VECTOR4 },
2978 { "color-red", Actor::COLOR_RED, Property::FLOAT },
2979 { "color-green", Actor::COLOR_GREEN, Property::FLOAT },
2980 { "color-blue", Actor::COLOR_BLUE, Property::FLOAT },
2981 { "color-alpha", Actor::COLOR_ALPHA, Property::FLOAT },
2982 { "world-color", Actor::WORLD_COLOR, Property::VECTOR4 },
2983 { "world-matrix", Actor::WORLD_MATRIX, Property::MATRIX },
2984 { "name", Actor::NAME, Property::STRING },
2985 { "sensitive", Actor::SENSITIVE, Property::BOOLEAN },
2986 { "leave-required", Actor::LEAVE_REQUIRED, Property::BOOLEAN },
2987 { "inherit-shader-effect", Actor::INHERIT_SHADER_EFFECT, Property::BOOLEAN },
2988 { "inherit-rotation", Actor::INHERIT_ROTATION, Property::BOOLEAN },
2989 { "inherit-scale", Actor::INHERIT_SCALE, Property::BOOLEAN },
2990 { "color-mode", Actor::COLOR_MODE, Property::STRING },
2991 { "position-inheritance", Actor::POSITION_INHERITANCE, Property::STRING },
2992 { "draw-mode", Actor::DRAW_MODE, Property::STRING },
2994 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2995 } // unnamed namespace
2997 int UtcDaliActorProperties(void)
2999 TestApplication app;
3001 Actor actor = Actor::New();
3003 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3005 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3006 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3007 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3008 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );