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/integration-api/events/hover-event-integ.h>
23 #include <dali-test-suite-utils.h>
31 void utc_dali_actor_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_actor_cleanup(void)
38 test_return_value = TET_PASS;
43 bool gTouchCallBackCalled=false;
44 bool gTouchCallBack2Called=false;
45 bool gHoverCallBackCalled=false;
48 * Simulates a Down Touch at 25.0, 25.0.
49 * @param[in] app Test Application instance.
51 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
53 app.SendNotification();
55 app.SendNotification();
58 gTouchCallBackCalled = false;
59 gTouchCallBack2Called = false;
61 // simulate a touch event
62 Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
63 Dali::Integration::TouchEvent event;
64 event.AddPoint( point );
65 app.ProcessEvent( event );
67 app.SendNotification();
69 app.SendNotification();
75 static bool gTestConstraintCalled;
79 Vector4 operator()(const Vector4& color)
81 gTestConstraintCalled = true;
82 return Vector4(color.x, color.y, color.z, 0.1f);
87 * TestConstraint reference.
88 * When constraint is called, the resultRef is updated
89 * with the value supplied.
92 struct TestConstraintRef
94 TestConstraintRef(unsigned int& resultRef, unsigned int value)
95 : mResultRef(resultRef),
100 T operator()(const T& current)
106 unsigned int& mResultRef;
110 bool wasConstraintCallbackCalled1 = false;
111 void TestConstraintCallback1( ActiveConstraint& constraint )
113 wasConstraintCallbackCalled1 = true;
116 bool wasConstraintCallbackCalled2 = false;
117 void TestConstraintCallback2( ActiveConstraint& constraint )
119 wasConstraintCallbackCalled2 = true;
122 bool wasConstraintCallbackCalled3 = false;
123 void TestConstraintCallback3( ActiveConstraint& constraint )
125 wasConstraintCallbackCalled3 = true;
128 static bool TestCallback(Actor actor, const TouchEvent& event)
130 gTouchCallBackCalled = true;
135 static bool TestCallback2(Actor actor, const TouchEvent& event)
137 gTouchCallBack2Called = true;
142 static bool TestCallback3(Actor actor, const HoverEvent& event)
144 gHoverCallBackCalled = true;
149 static Vector3 gSetSize;
150 static bool gSetSizeCallBackCalled;
151 void SetSizeCallback( Actor actor, const Vector3& size )
153 gSetSizeCallBackCalled = true;
156 // validation stuff for onstage & offstage signals
157 static std::vector< std::string > gActorNamesOnOffStage;
158 static int gOnStageCallBackCalled;
159 void OnStageCallback( Actor actor )
161 ++gOnStageCallBackCalled;
162 gActorNamesOnOffStage.push_back( actor.GetName() );
163 DALI_TEST_CHECK( actor.OnStage() == true );
165 static int gOffStageCallBackCalled;
166 void OffStageCallback( Actor actor )
168 ++gOffStageCallBackCalled;
169 gActorNamesOnOffStage.push_back( actor.GetName() );
170 DALI_TEST_CHECK( actor.OnStage() == false );
173 struct PositionComponentConstraint
175 PositionComponentConstraint(){}
177 Vector3 operator()(const Vector3& current, const PropertyInput& property)
179 const Matrix& m = property.GetMatrix();
183 m.GetTransformComponents(pos, rot, scale);
190 } // anonymous namespace
193 //& purpose: Testing New API
194 int UtcDaliActorNew(void)
196 TestApplication application;
198 Actor actor = Actor::New();
200 DALI_TEST_CHECK(actor);
204 //& purpose: Testing Dali::Actor::DownCast()
205 int UtcDaliActorDownCast(void)
207 TestApplication application;
208 tet_infoline("Testing Dali::Actor::DownCast()");
210 Actor actor = Actor::New();
211 BaseHandle object(actor);
212 Actor actor2 = Actor::DownCast(object);
213 DALI_TEST_CHECK(actor2);
217 //& purpose: Testing Dali::Actor::DownCast()
218 int UtcDaliActorDownCast2(void)
220 TestApplication application;
221 tet_infoline("Testing Dali::Actor::DownCast()");
223 BaseHandle unInitializedObject;
224 Actor actor = Actor::DownCast(unInitializedObject);
225 DALI_TEST_CHECK(!actor);
229 //& purpose: Testing Dali::Actor::GetName()
230 int UtcDaliActorGetName(void)
232 TestApplication application;
234 Actor actor = Actor::New();
236 DALI_TEST_CHECK(actor.GetName().empty());
240 //& purpose: Testing Dali::Actor::SetName()
241 int UtcDaliActorSetName(void)
243 TestApplication application;
245 string str("ActorName");
246 Actor actor = Actor::New();
249 DALI_TEST_CHECK(actor.GetName() == str);
253 int UtcDaliActorGetId(void)
255 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
256 TestApplication application;
258 Actor first = Actor::New();
259 Actor second = Actor::New();
260 Actor third = Actor::New();
262 DALI_TEST_CHECK(first.GetId() != second.GetId());
263 DALI_TEST_CHECK(second.GetId() != third.GetId());
267 int UtcDaliActorIsRoot(void)
269 TestApplication application;
271 Actor actor = Actor::New();
272 DALI_TEST_CHECK(!actor.IsRoot());
274 // get the root layer
275 actor = Stage::GetCurrent().GetLayer( 0 );
276 DALI_TEST_CHECK( actor.IsRoot() );
280 int UtcDaliActorOnStage(void)
282 TestApplication application;
284 Actor actor = Actor::New();
285 DALI_TEST_CHECK( !actor.OnStage() );
287 // get the root layer
288 actor = Stage::GetCurrent().GetLayer( 0 );
289 DALI_TEST_CHECK( actor.OnStage() );
293 int UtcDaliActorIsLayer(void)
295 TestApplication application;
297 Actor actor = Actor::New();
298 DALI_TEST_CHECK( !actor.IsLayer() );
300 // get the root layer
301 actor = Stage::GetCurrent().GetLayer( 0 );
302 DALI_TEST_CHECK( actor.IsLayer() );
306 int UtcDaliActorGetLayer(void)
308 TestApplication application;
310 Actor actor = Actor::New();
311 Stage::GetCurrent().Add(actor);
312 Layer layer = actor.GetLayer();
314 DALI_TEST_CHECK(layer);
316 // get the root layers layer
317 actor = Stage::GetCurrent().GetLayer( 0 );
318 DALI_TEST_CHECK( actor.GetLayer() );
322 int UtcDaliActorAdd(void)
324 tet_infoline("Testing Actor::Add");
325 TestApplication application;
327 Actor parent = Actor::New();
328 Actor child = Actor::New();
330 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
334 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
336 Actor parent2 = Actor::New();
337 parent2.Add( child );
339 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
340 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
342 // try Adding to same parent again, works
343 parent2.Add( child );
344 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
346 // try reparenting an orphaned child
348 Actor temporaryParent = Actor::New();
349 temporaryParent.Add( child );
350 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
352 // temporaryParent has now died, reparent the orphaned child
353 parent2.Add( child );
354 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
359 parent2.Add( parent2 );
360 tet_printf("Assertion test failed - no Exception\n" );
361 tet_result(TET_FAIL);
363 catch(Dali::DaliException& e)
365 DALI_TEST_PRINT_ASSERT( e );
366 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
367 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
371 tet_printf("Assertion test failed - wrong Exception\n" );
372 tet_result(TET_FAIL);
375 // try reparenting root
378 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
379 tet_printf("Assertion test failed - no Exception\n" );
380 tet_result(TET_FAIL);
382 catch(Dali::DaliException& e)
384 DALI_TEST_PRINT_ASSERT( e );
385 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
386 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
390 tet_printf("Assertion test failed - wrong Exception\n" );
391 tet_result(TET_FAIL);
398 parent2.Add( empty );
399 tet_printf("Assertion test failed - no Exception\n" );
400 tet_result(TET_FAIL);
402 catch(Dali::DaliException& e)
404 DALI_TEST_PRINT_ASSERT( e );
405 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
406 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
410 tet_printf("Assertion test failed - wrong Exception\n" );
411 tet_result(TET_FAIL);
416 int UtcDaliActorInsert(void)
418 tet_infoline("Testing Actor::Insert");
419 TestApplication application;
421 Actor parent = Actor::New();
422 Stage::GetCurrent().Add( parent );
423 Actor first = Actor::New();
424 Actor second = Actor::New();
425 Actor third = Actor::New();
427 parent.Insert(1, first); // test insert beyond range
428 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
429 parent.Insert(0, second);
430 DALI_TEST_EQUALS( parent.GetChildCount(), 2u, TEST_LOCATION );
431 parent.Insert(1, third);
433 DALI_TEST_EQUALS( parent.GetChildCount(), 3u, TEST_LOCATION );
435 DALI_TEST_CHECK(parent.GetChildAt(0) == second);
436 DALI_TEST_CHECK(parent.GetChildAt(1) == third);
437 DALI_TEST_CHECK(parent.GetChildAt(2) == first);
443 int UtcDaliActorRemove01(void)
445 tet_infoline("Testing Actor::Remove");
446 TestApplication application;
448 Actor parent = Actor::New();
449 Actor child = Actor::New();
450 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
453 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
455 parent.Remove(child);
456 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
458 // remove again, no problem
459 parent.Remove(child);
460 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
464 // try illegal Remove
467 parent.Remove( parent );
468 tet_printf("Assertion test failed - no Exception\n" );
469 tet_result(TET_FAIL);
471 catch(Dali::DaliException& e)
473 DALI_TEST_PRINT_ASSERT( e );
474 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
475 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
479 tet_printf("Assertion test failed - wrong Exception\n" );
480 tet_result(TET_FAIL);
487 parent.Remove( empty );
488 tet_printf("Assertion test failed - no Exception\n" );
489 tet_result(TET_FAIL);
491 catch(Dali::DaliException& e)
493 DALI_TEST_PRINT_ASSERT( e );
494 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
495 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
499 tet_printf("Assertion test failed - wrong Exception\n" );
500 tet_result(TET_FAIL);
505 int UtcDaliActorRemove02(void)
507 TestApplication application;
509 Actor parent = Actor::New();
510 Actor child = Actor::New();
511 Actor random = Actor::New();
513 Stage::GetCurrent().Add( parent );
515 DALI_TEST_CHECK(parent.GetChildCount() == 0);
519 DALI_TEST_CHECK(parent.GetChildCount() == 1);
521 parent.Remove(random);
523 DALI_TEST_CHECK(parent.GetChildCount() == 1);
525 Stage::GetCurrent().Remove( parent );
527 DALI_TEST_CHECK(parent.GetChildCount() == 1);
531 int UtcDaliActorGetChildCount(void)
533 TestApplication application;
535 Actor parent = Actor::New();
536 Actor child = Actor::New();
538 DALI_TEST_CHECK(parent.GetChildCount() == 0);
542 DALI_TEST_CHECK(parent.GetChildCount() == 1);
546 int UtcDaliActorGetChildren01(void)
548 TestApplication application;
550 Actor parent = Actor::New();
551 Actor first = Actor::New();
552 Actor second = Actor::New();
553 Actor third = Actor::New();
559 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
560 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
561 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
565 int UtcDaliActorGetChildren02(void)
567 TestApplication application;
569 Actor parent = Actor::New();
570 Actor first = Actor::New();
571 Actor second = Actor::New();
572 Actor third = Actor::New();
578 const Actor& constParent = parent;
580 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
581 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
582 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
586 int UtcDaliActorGetParent01(void)
588 TestApplication application;
590 Actor parent = Actor::New();
591 Actor child = Actor::New();
595 DALI_TEST_CHECK(child.GetParent() == parent);
599 int UtcDaliActorGetParent02(void)
601 TestApplication application;
603 Actor actor = Actor::New();
605 DALI_TEST_CHECK(!actor.GetParent());
609 int UtcDaliActorSetParentOrigin(void)
611 TestApplication application;
613 Actor actor = Actor::New();
615 Vector3 vector(0.7f, 0.8f, 0.9f);
616 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
618 actor.SetParentOrigin(vector);
620 // flush the queue and render once
621 application.SendNotification();
622 application.Render();
624 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
626 Stage::GetCurrent().Add( actor );
628 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
630 // flush the queue and render once
631 application.SendNotification();
632 application.Render();
634 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
636 Stage::GetCurrent().Remove( actor );
640 int UtcDaliActorGetCurrentParentOrigin(void)
642 TestApplication application;
644 Actor actor = Actor::New();
646 Vector3 vector(0.7f, 0.8f, 0.9f);
647 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
649 actor.SetParentOrigin(vector);
651 // flush the queue and render once
652 application.SendNotification();
653 application.Render();
655 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
659 int UtcDaliActorSetAnchorPoint(void)
661 TestApplication application;
663 Actor actor = Actor::New();
665 Vector3 vector(0.7f, 0.8f, 0.9f);
666 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
668 actor.SetAnchorPoint(vector);
670 // flush the queue and render once
671 application.SendNotification();
672 application.Render();
674 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
676 Stage::GetCurrent().Add( actor );
678 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
679 // flush the queue and render once
680 application.SendNotification();
681 application.Render();
683 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
685 Stage::GetCurrent().Remove( actor );
689 int UtcDaliActorGetCurrentAnchorPoint(void)
691 TestApplication application;
693 Actor actor = Actor::New();
695 Vector3 vector(0.7f, 0.8f, 0.9f);
696 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
698 actor.SetAnchorPoint(vector);
700 // flush the queue and render once
701 application.SendNotification();
702 application.Render();
704 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
708 // SetSize(float width, float height)
709 int UtcDaliActorSetSize01(void)
711 TestApplication application;
713 Actor actor = Actor::New();
714 Vector3 vector(100.0f, 100.0f, 100.0f);
716 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
718 actor.SetSize(vector.x, vector.y);
720 // flush the queue and render once
721 application.SendNotification();
722 application.Render();
724 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
728 // SetSize(float width, float height, float depth)
729 int UtcDaliActorSetSize02(void)
731 TestApplication application;
733 Actor actor = Actor::New();
734 Vector3 vector(100.0f, 100.0f, 100.0f);
736 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
738 actor.SetSize(vector.x, vector.y, vector.z);
740 // flush the queue and render once
741 application.SendNotification();
742 application.Render();
744 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
748 // SetSize(Vector2 size)
749 int UtcDaliActorSetSize03(void)
751 TestApplication application;
753 Actor actor = Actor::New();
754 Vector3 vector(100.0f, 100.0f, 100.0f);
756 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
758 actor.SetSize(Vector2(vector.x, vector.y));
760 // flush the queue and render once
761 application.SendNotification();
762 application.Render();
764 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
768 // SetSize(Vector3 size)
769 int UtcDaliActorSetSize04(void)
771 TestApplication application;
773 Actor actor = Actor::New();
774 Vector3 vector(100.0f, 100.0f, 100.0f);
776 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
778 actor.SetSize(vector);
780 // flush the queue and render once
781 application.SendNotification();
782 application.Render();
784 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
786 Stage::GetCurrent().Add( actor );
787 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
789 // flush the queue and render once
790 application.SendNotification();
791 application.Render();
793 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
794 Stage::GetCurrent().Remove( actor );
798 int UtcDaliActorGetCurrentSize(void)
800 TestApplication application;
802 Actor actor = Actor::New();
803 Vector3 vector(100.0f, 100.0f, 20.0f);
805 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
807 actor.SetSize(vector);
809 // flush the queue and render once
810 application.SendNotification();
811 application.Render();
813 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
817 int UtcDaliActorGetNaturalSize(void)
819 TestApplication application;
821 Actor actor = Actor::New();
822 Vector3 vector( 0.0f, 0.0f, 0.0f );
824 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
829 int UtcDaliActorGetCurrentSizeImmediate(void)
831 TestApplication application;
833 Actor actor = Actor::New();
834 Vector3 vector(100.0f, 100.0f, 20.0f);
836 DALI_TEST_CHECK(vector != actor.GetTargetSize());
837 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
839 actor.SetSize(vector);
841 DALI_TEST_CHECK(vector == actor.GetTargetSize());
842 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
844 // flush the queue and render once
845 application.SendNotification();
846 application.Render();
848 DALI_TEST_CHECK(vector == actor.GetTargetSize());
849 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
852 // Build the animation
853 const float durationSeconds = 2.0f;
854 Animation animation = Animation::New( durationSeconds );
855 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
856 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
858 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
860 // Start the animation
863 application.SendNotification();
864 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
866 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
871 // SetPosition(float x, float y)
872 int UtcDaliActorSetPosition01(void)
874 TestApplication application;
876 Actor actor = Actor::New();
878 // Set to random to start off with
879 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
881 Vector3 vector(100.0f, 100.0f, 0.0f);
883 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
885 actor.SetPosition(vector.x, vector.y);
886 // flush the queue and render once
887 application.SendNotification();
888 application.Render();
889 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
891 Stage::GetCurrent().Add( actor );
892 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
893 // flush the queue and render once
894 application.SendNotification();
895 application.Render();
896 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
901 // flush the queue and render once
902 application.SendNotification();
903 application.Render();
904 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
906 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
907 // flush the queue and render once
908 application.SendNotification();
909 application.Render();
910 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
912 Stage::GetCurrent().Remove( actor );
916 // SetPosition(float x, float y, float z)
917 int UtcDaliActorSetPosition02(void)
919 TestApplication application;
921 Actor actor = Actor::New();
923 // Set to random to start off with
924 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
926 Vector3 vector(100.0f, 100.0f, 100.0f);
928 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
930 actor.SetPosition(vector.x, vector.y, vector.z);
932 // flush the queue and render once
933 application.SendNotification();
934 application.Render();
936 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
940 // SetPosition(Vector3 position)
941 int UtcDaliActorSetPosition03(void)
943 TestApplication application;
945 Actor actor = Actor::New();
947 // Set to random to start off with
948 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
950 Vector3 vector(100.0f, 100.0f, 100.0f);
952 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
954 actor.SetPosition(vector);
956 // flush the queue and render once
957 application.SendNotification();
958 application.Render();
960 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
964 int UtcDaliActorSetX(void)
966 TestApplication application;
968 Actor actor = Actor::New();
970 Vector3 vector(100.0f, 0.0f, 0.0f);
972 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
976 // flush the queue and render once
977 application.SendNotification();
978 application.Render();
980 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
984 int UtcDaliActorSetY(void)
986 TestApplication application;
988 Actor actor = Actor::New();
990 Vector3 vector(0.0f, 100.0f, 0.0f);
992 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
996 // flush the queue and render once
997 application.SendNotification();
998 application.Render();
1000 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1004 int UtcDaliActorSetZ(void)
1006 TestApplication application;
1008 Actor actor = Actor::New();
1010 Vector3 vector(0.0f, 0.0f, 100.0f);
1012 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1016 // flush the queue and render once
1017 application.SendNotification();
1018 application.Render();
1020 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1024 int UtcDaliActorTranslateBy(void)
1026 TestApplication application;
1028 Actor actor = Actor::New();
1029 Vector3 vector(100.0f, 100.0f, 100.0f);
1031 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1033 actor.SetPosition(vector);
1035 // flush the queue and render once
1036 application.SendNotification();
1037 application.Render();
1039 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1041 actor.TranslateBy(vector);
1043 // flush the queue and render once
1044 application.SendNotification();
1045 application.Render();
1047 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1051 int UtcDaliActorGetCurrentPosition(void)
1053 TestApplication application;
1055 Actor actor = Actor::New();
1056 Vector3 setVector(100.0f, 100.0f, 0.0f);
1057 actor.SetPosition(setVector);
1059 // flush the queue and render once
1060 application.SendNotification();
1061 application.Render();
1063 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1067 int UtcDaliActorGetCurrentWorldPosition(void)
1069 TestApplication application;
1071 Actor parent = Actor::New();
1072 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1073 parent.SetPosition( parentPosition );
1074 parent.SetParentOrigin( ParentOrigin::CENTER );
1075 parent.SetAnchorPoint( AnchorPoint::CENTER );
1076 Stage::GetCurrent().Add( parent );
1078 Actor child = Actor::New();
1079 child.SetParentOrigin( ParentOrigin::CENTER );
1080 child.SetAnchorPoint( AnchorPoint::CENTER );
1081 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1082 child.SetPosition( childPosition );
1083 parent.Add( child );
1085 // The actors should not have a world position yet
1086 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1087 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1089 application.SendNotification();
1090 application.Render(0);
1092 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1093 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1095 // The actors should have a world position now
1096 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1097 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1101 int UtcDaliActorInheritPosition(void)
1103 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1104 TestApplication application;
1106 Actor parent = Actor::New();
1107 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1108 parent.SetPosition( parentPosition );
1109 parent.SetParentOrigin( ParentOrigin::CENTER );
1110 parent.SetAnchorPoint( AnchorPoint::CENTER );
1111 Stage::GetCurrent().Add( parent );
1113 Actor child = Actor::New();
1114 child.SetParentOrigin( ParentOrigin::CENTER );
1115 child.SetAnchorPoint( AnchorPoint::CENTER );
1116 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1117 child.SetPosition( childPosition );
1118 parent.Add( child );
1120 // The actors should not have a world position yet
1121 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1122 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1124 // first test default, which is INHERIT_PARENT_POSITION
1125 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1126 application.SendNotification();
1127 application.Render(0); // should only really call Update as Render is not required to update scene
1128 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1129 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1130 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1131 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1133 // Change inheritance mode to use parent
1134 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1135 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1136 application.SendNotification();
1137 application.Render(0); // should only really call Update as Render is not required to update scene
1138 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1139 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1140 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1141 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1143 // Change inheritance mode to use parent + offset
1144 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1145 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1146 child.SetPosition( childOffset );
1147 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1148 application.SendNotification();
1149 application.Render(0); // should only really call Update as Render is not required to update scene
1150 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1151 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1152 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1153 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1155 // Change inheritance mode to not inherit
1156 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1157 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1158 application.SendNotification();
1159 application.Render(0); // should only really call Update as Render is not required to update scene
1160 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1161 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1162 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1163 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1167 // SetOrientation(float angleRadians, Vector3 axis)
1168 int UtcDaliActorSetOrientation01(void)
1170 TestApplication application;
1172 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1173 Actor actor = Actor::New();
1175 actor.SetOrientation(rotation);
1177 // flush the queue and render once
1178 application.SendNotification();
1179 application.Render();
1181 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1185 int UtcDaliActorSetOrientation02(void)
1187 TestApplication application;
1189 Actor actor = Actor::New();
1191 float angle = 0.785f;
1192 Vector3 axis(1.0f, 1.0f, 0.0f);
1194 actor.SetOrientation(Radian( angle ), axis);
1195 Quaternion rotation( angle, axis );
1196 // flush the queue and render once
1197 application.SendNotification();
1198 application.Render();
1199 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1201 Stage::GetCurrent().Add( actor );
1202 actor.RotateBy( Degree( 360 ), axis);
1203 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1205 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1206 Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
1207 // flush the queue and render once
1208 application.SendNotification();
1209 application.Render();
1210 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1212 actor.SetOrientation(Radian( angle ), axis);
1213 // flush the queue and render once
1214 application.SendNotification();
1215 application.Render();
1216 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1218 Stage::GetCurrent().Remove( actor );
1222 // RotateBy(float angleRadians, Vector3 axis)
1223 int UtcDaliActorRotateBy01(void)
1225 TestApplication application;
1227 Actor actor = Actor::New();
1229 float angle = M_PI * 0.25f;
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.25f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1236 Stage::GetCurrent().Add( actor );
1238 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1239 // flush the queue and render once
1240 application.SendNotification();
1241 application.Render();
1242 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1244 Stage::GetCurrent().Remove( actor );
1248 // RotateBy(Quaternion relativeRotation)
1249 int UtcDaliActorRotateBy02(void)
1251 TestApplication application;
1253 Actor actor = Actor::New();
1255 Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1256 actor.RotateBy(rotation);
1257 // flush the queue and render once
1258 application.SendNotification();
1259 application.Render();
1260 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1262 actor.RotateBy(rotation);
1263 // flush the queue and render once
1264 application.SendNotification();
1265 application.Render();
1266 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1270 int UtcDaliActorGetCurrentOrientation(void)
1272 TestApplication application;
1273 Actor actor = Actor::New();
1275 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1276 actor.SetOrientation(rotation);
1277 // flush the queue and render once
1278 application.SendNotification();
1279 application.Render();
1280 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1284 int UtcDaliActorGetCurrentWorldOrientation(void)
1286 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1287 TestApplication application;
1289 Actor parent = Actor::New();
1290 Radian rotationAngle( Degree(90.0f) );
1291 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1292 parent.SetOrientation( rotation );
1293 Stage::GetCurrent().Add( parent );
1295 Actor child = Actor::New();
1296 child.SetOrientation( rotation );
1297 parent.Add( child );
1299 // The actors should not have a world rotation yet
1300 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1301 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1303 application.SendNotification();
1304 application.Render(0);
1306 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1307 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1309 // The actors should have a world rotation now
1310 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1311 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1313 // turn off child rotation inheritance
1314 child.SetInheritOrientation( false );
1315 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1316 application.SendNotification();
1317 application.Render(0);
1319 // The actors should have a world rotation now
1320 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1321 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1325 // SetScale(float scale)
1326 int UtcDaliActorSetScale01(void)
1328 TestApplication application;
1330 Actor actor = Actor::New();
1332 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1333 actor.SetScale(0.25f);
1335 Vector3 scale(10.0f, 10.0f, 10.0f);
1336 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1338 actor.SetScale(scale.x);
1340 // flush the queue and render once
1341 application.SendNotification();
1342 application.Render();
1344 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1348 // SetScale(float scaleX, float scaleY, float scaleZ)
1349 int UtcDaliActorSetScale02(void)
1351 TestApplication application;
1352 Vector3 scale(10.0f, 10.0f, 10.0f);
1354 Actor actor = Actor::New();
1356 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1357 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1359 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1361 actor.SetScale(scale.x, scale.y, scale.z);
1362 // flush the queue and render once
1363 application.SendNotification();
1364 application.Render();
1365 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1367 // add to stage and test
1368 Stage::GetCurrent().Add( actor );
1369 actor.SetScale( 2.0f, 2.0f, 2.0f );
1370 // flush the queue and render once
1371 application.SendNotification();
1372 application.Render();
1373 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1375 Stage::GetCurrent().Remove( actor );
1380 // SetScale(Vector3 scale)
1381 int UtcDaliActorSetScale03(void)
1383 TestApplication application;
1384 Vector3 scale(10.0f, 10.0f, 10.0f);
1386 Actor actor = Actor::New();
1388 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1389 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1391 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1393 actor.SetScale(scale);
1395 // flush the queue and render once
1396 application.SendNotification();
1397 application.Render();
1399 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1403 int UtcDaliActorScaleBy(void)
1405 TestApplication application;
1406 Actor actor = Actor::New();
1407 Vector3 vector(100.0f, 100.0f, 100.0f);
1409 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1411 actor.SetScale(vector);
1413 // flush the queue and render once
1414 application.SendNotification();
1415 application.Render();
1417 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1419 actor.ScaleBy(vector);
1421 // flush the queue and render once
1422 application.SendNotification();
1423 application.Render();
1425 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1429 int UtcDaliActorGetCurrentScale(void)
1431 TestApplication application;
1432 Vector3 scale(12.0f, 1.0f, 2.0f);
1434 Actor actor = Actor::New();
1436 actor.SetScale(scale);
1438 // flush the queue and render once
1439 application.SendNotification();
1440 application.Render();
1442 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1446 int UtcDaliActorGetCurrentWorldScale(void)
1448 TestApplication application;
1450 Actor parent = Actor::New();
1451 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1452 parent.SetScale( parentScale );
1453 Stage::GetCurrent().Add( parent );
1455 Actor child = Actor::New();
1456 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1457 child.SetScale( childScale );
1458 parent.Add( child );
1460 // The actors should not have a scale yet
1461 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1462 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1464 // The actors should not have a world scale yet
1465 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1466 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1468 application.SendNotification();
1469 application.Render(0);
1471 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1472 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1474 // The actors should have a world scale now
1475 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1476 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1480 int UtcDaliActorInheritScale(void)
1482 tet_infoline("Testing Actor::SetInheritScale");
1483 TestApplication application;
1485 Actor parent = Actor::New();
1486 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1487 parent.SetScale( parentScale );
1488 Stage::GetCurrent().Add( parent );
1490 Actor child = Actor::New();
1491 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1492 child.SetScale( childScale );
1493 parent.Add( child );
1495 application.SendNotification();
1496 application.Render(0);
1498 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1499 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1501 child.SetInheritScale( false );
1502 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1504 application.SendNotification();
1505 application.Render(0);
1507 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1511 int UtcDaliActorSetVisible(void)
1513 TestApplication application;
1515 Actor actor = Actor::New();
1516 actor.SetVisible(false);
1517 // flush the queue and render once
1518 application.SendNotification();
1519 application.Render();
1520 DALI_TEST_CHECK(actor.IsVisible() == false);
1522 actor.SetVisible(true);
1523 // flush the queue and render once
1524 application.SendNotification();
1525 application.Render();
1526 DALI_TEST_CHECK(actor.IsVisible() == true);
1528 // put actor on stage
1529 Stage::GetCurrent().Add( actor );
1530 actor.SetVisible(false);
1531 // flush the queue and render once
1532 application.SendNotification();
1533 application.Render();
1534 DALI_TEST_CHECK(actor.IsVisible() == false);
1538 int UtcDaliActorIsVisible(void)
1540 TestApplication application;
1542 Actor actor = Actor::New();
1544 DALI_TEST_CHECK(actor.IsVisible() == true);
1548 int UtcDaliActorSetOpacity(void)
1550 TestApplication application;
1552 Actor actor = Actor::New();
1553 // initial opacity is 1
1554 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1556 actor.SetOpacity( 0.4f);
1557 // flush the queue and render once
1558 application.SendNotification();
1559 application.Render();
1560 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1562 // change opacity, actor is on stage to change is not immediate
1563 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1564 // flush the queue and render once
1565 application.SendNotification();
1566 application.Render();
1567 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1569 // put actor on stage
1570 Stage::GetCurrent().Add( actor );
1572 // change opacity, actor is on stage to change is not immediate
1573 actor.SetOpacity( 0.9f );
1574 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1575 // flush the queue and render once
1576 application.SendNotification();
1577 application.Render();
1578 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1580 // change opacity, actor is on stage to change is not immediate
1581 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1582 // flush the queue and render once
1583 application.SendNotification();
1584 application.Render();
1585 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1589 int UtcDaliActorGetCurrentOpacity(void)
1591 TestApplication application;
1593 Actor actor = Actor::New();
1594 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1596 actor.SetOpacity(0.5f);
1597 // flush the queue and render once
1598 application.SendNotification();
1599 application.Render();
1600 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1604 int UtcDaliActorSetSensitive(void)
1606 TestApplication application;
1607 Actor actor = Actor::New();
1609 bool sensitive = !actor.IsSensitive();
1611 actor.SetSensitive(sensitive);
1613 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1617 int UtcDaliActorIsSensitive(void)
1619 TestApplication application;
1620 Actor actor = Actor::New();
1621 actor.SetSensitive(false);
1623 DALI_TEST_CHECK(false == actor.IsSensitive());
1627 int UtcDaliActorSetColor(void)
1629 TestApplication application;
1630 Actor actor = Actor::New();
1631 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1633 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1635 actor.SetColor(color);
1636 // flush the queue and render once
1637 application.SendNotification();
1638 application.Render();
1639 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1641 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1642 // flush the queue and render once
1643 application.SendNotification();
1644 application.Render();
1645 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1647 Stage::GetCurrent().Add( actor );
1648 actor.SetColor( color );
1649 // flush the queue and render once
1650 application.SendNotification();
1651 application.Render();
1652 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1654 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1655 // flush the queue and render once
1656 application.SendNotification();
1657 application.Render();
1658 // Actor color is not clamped
1659 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1660 // world color is clamped
1661 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1663 Stage::GetCurrent().Remove( actor );
1667 int UtcDaliActorGetCurrentColor(void)
1669 TestApplication application;
1670 Actor actor = Actor::New();
1671 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1673 actor.SetColor(color);
1674 // flush the queue and render once
1675 application.SendNotification();
1676 application.Render();
1677 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1681 int UtcDaliActorGetCurrentWorldColor(void)
1683 tet_infoline("Actor::GetCurrentWorldColor");
1684 TestApplication application;
1686 Actor parent = Actor::New();
1687 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1688 parent.SetColor( parentColor );
1689 Stage::GetCurrent().Add( parent );
1691 Actor child = Actor::New();
1692 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1693 child.SetColor( childColor );
1694 parent.Add( child );
1696 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1697 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1699 // verify the default color mode
1700 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1702 // The actors should not have a world color yet
1703 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1704 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1706 application.SendNotification();
1707 application.Render(0);
1709 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1710 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1712 // The actors should have a world color now
1713 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1714 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1717 child.SetColorMode( USE_OWN_COLOR );
1718 application.SendNotification();
1719 application.Render(0);
1720 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1723 child.SetColorMode( USE_PARENT_COLOR );
1724 application.SendNotification();
1725 application.Render(0);
1726 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1727 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1730 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1731 application.SendNotification();
1732 application.Render(0);
1733 Vector4 expectedColor( childColor );
1734 expectedColor.a *= parentColor.a;
1735 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1736 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1740 int UtcDaliActorSetColorMode(void)
1742 tet_infoline("Actor::SetColorMode");
1743 TestApplication application;
1744 Actor actor = Actor::New();
1745 Actor child = Actor::New();
1748 actor.SetColorMode( USE_OWN_COLOR );
1749 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1751 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1752 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1754 actor.SetColorMode( USE_PARENT_COLOR );
1755 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1757 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1758 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1762 int UtcDaliActorScreenToLocal(void)
1764 TestApplication application;
1765 Actor actor = Actor::New();
1766 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1767 actor.SetSize(100.0f, 100.0f);
1768 actor.SetPosition(10.0f, 10.0f);
1769 Stage::GetCurrent().Add(actor);
1771 // flush the queue and render once
1772 application.SendNotification();
1773 application.Render();
1778 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1780 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1781 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1785 int UtcDaliActorSetLeaveRequired(void)
1787 TestApplication application;
1789 Actor actor = Actor::New();
1791 actor.SetLeaveRequired(false);
1792 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1794 actor.SetLeaveRequired(true);
1795 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1799 int UtcDaliActorGetLeaveRequired(void)
1801 TestApplication application;
1803 Actor actor = Actor::New();
1805 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1809 int UtcDaliActorSetKeyboardFocusable(void)
1811 TestApplication application;
1813 Actor actor = Actor::New();
1815 actor.SetKeyboardFocusable(true);
1816 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1818 actor.SetKeyboardFocusable(false);
1819 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1823 int UtcDaliActorIsKeyboardFocusable(void)
1825 TestApplication application;
1827 Actor actor = Actor::New();
1829 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1834 int UtcDaliActorApplyConstraint(void)
1836 TestApplication application;
1838 gTestConstraintCalled = false;
1840 Actor actor = Actor::New();
1842 Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraint() );
1843 actor.ApplyConstraint(constraint);
1845 DALI_TEST_CHECK( gTestConstraintCalled == false );
1847 Stage::GetCurrent().Add( actor );
1849 // flush the queue and render once
1850 application.SendNotification();
1851 application.Render();
1853 DALI_TEST_CHECK( gTestConstraintCalled == true );
1858 int UtcDaliActorApplyConstraintAppliedCallback(void)
1860 TestApplication application;
1862 // Build a reusable constraint
1864 Actor parent = Actor::New();
1865 Vector3 parentSize( 100.0f, 100.0f, 100.0f );
1866 parent.SetSize( parentSize );
1867 Stage::GetCurrent().Add( parent );
1869 Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
1870 Source( parent, Actor::Property::SIZE ),
1871 EqualToConstraint() );
1873 // Create some child actors
1875 Actor child1 = Actor::New();
1876 parent.Add( child1 );
1878 Actor child2 = Actor::New();
1879 parent.Add( child2 );
1881 Actor child3 = Actor::New();
1882 parent.Add( child3 );
1884 // Apply constraint with different timings - everything should be finished after 10 seconds
1886 wasConstraintCallbackCalled1 = false;
1887 wasConstraintCallbackCalled2 = false;
1888 wasConstraintCallbackCalled3 = false;
1890 constraint.SetApplyTime( 5.0f );
1891 ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
1892 activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
1894 constraint.SetApplyTime( 10.0f );
1895 ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
1896 activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
1898 constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
1899 ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
1900 activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
1902 // Check event-side size
1903 DALI_TEST_EQUALS( child1.GetTargetSize(), Vector3::ZERO, TEST_LOCATION );
1904 DALI_TEST_EQUALS( child2.GetTargetSize(), Vector3::ZERO, TEST_LOCATION );
1905 DALI_TEST_EQUALS( child3.GetTargetSize(), Vector3::ZERO, TEST_LOCATION );
1907 DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1908 DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1909 DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1911 application.SendNotification();
1913 application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
1915 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
1916 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
1917 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1919 // Check signals have not fired
1920 application.SendNotification();
1921 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1922 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1923 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1925 application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
1926 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40%
1927 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
1928 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1930 // Check signals have not fired
1931 application.SendNotification();
1932 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1933 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1934 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1936 application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
1937 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60%
1938 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
1939 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
1941 // Check signals have not fired
1942 application.SendNotification();
1943 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1944 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1945 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1947 application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
1948 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80%
1949 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
1950 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
1952 // Check signals have not fired
1953 application.SendNotification();
1954 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1955 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1956 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1958 application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
1959 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100%
1960 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
1961 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
1963 // Check signals have not fired
1964 application.SendNotification();
1965 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1966 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1967 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1969 application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
1970 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire)
1971 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
1972 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
1974 // 1st signal should have fired
1975 application.SendNotification();
1976 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
1977 wasConstraintCallbackCalled1 = false;
1978 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1979 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1981 application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
1982 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1983 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
1984 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
1986 // Check signals have not fired
1987 application.SendNotification();
1988 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1989 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1990 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1992 application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
1993 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1994 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
1995 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire)
1997 // 3rd signal should have fired
1998 application.SendNotification();
2000 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2001 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2002 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
2003 wasConstraintCallbackCalled3 = false;
2005 application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
2006 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2007 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
2008 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2010 // Check signals have not fired
2011 application.SendNotification();
2012 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2013 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2014 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2016 application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
2017 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2018 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire)
2019 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2021 // 2nd signal should have fired
2022 application.SendNotification();
2023 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2024 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
2025 wasConstraintCallbackCalled2 = false;
2026 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2028 // Check that nothing has changed after a couple of buffer swaps
2030 application.Render(0);
2031 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2032 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2033 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2035 application.SendNotification();
2036 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2037 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2038 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2040 application.Render(0);
2041 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2042 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2043 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2045 application.SendNotification();
2046 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2047 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2048 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2052 int UtcDaliActorRemoveConstraints(void)
2054 tet_infoline(" UtcDaliActorRemoveConstraints");
2055 TestApplication application;
2057 gTestConstraintCalled = false;
2059 Actor actor = Actor::New();
2061 Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraint() );
2062 actor.ApplyConstraint(constraint);
2063 actor.RemoveConstraints();
2065 DALI_TEST_CHECK( gTestConstraintCalled == false );
2067 Stage::GetCurrent().Add( actor );
2068 actor.ApplyConstraint(constraint);
2070 // flush the queue and render once
2071 application.SendNotification();
2072 application.Render();
2074 actor.RemoveConstraints();
2076 DALI_TEST_CHECK( gTestConstraintCalled == true );
2080 int UtcDaliActorRemoveConstraint(void)
2082 tet_infoline(" UtcDaliActorRemoveConstraint");
2083 TestApplication application;
2085 Actor actor = Actor::New();
2087 // 1. Apply Constraint1 and Constraint2, and test...
2088 unsigned int result1 = 0u;
2089 unsigned int result2 = 0u;
2090 ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2091 ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) ) );
2093 Stage::GetCurrent().Add( actor );
2094 // flush the queue and render once
2095 application.SendNotification();
2096 application.Render();
2098 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2099 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2101 // 2. Remove Constraint1 and test...
2104 actor.RemoveConstraint(activeConstraint1);
2105 // make color property dirty, which will trigger constraints to be reapplied.
2106 actor.SetColor( Color::WHITE );
2107 // flush the queue and render once
2108 application.SendNotification();
2109 application.Render();
2111 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2112 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2114 // 3. Re-Apply Constraint1 and test...
2117 activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2118 // make color property dirty, which will trigger constraints to be reapplied.
2119 actor.SetColor( Color::WHITE );
2120 // flush the queue and render once
2121 application.SendNotification();
2122 application.Render();
2124 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2125 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2127 // 2. Remove Constraint2 and test...
2130 actor.RemoveConstraint(activeConstraint2);
2131 // make color property dirty, which will trigger constraints to be reapplied.
2132 actor.SetColor( Color::WHITE );
2133 // flush the queue and render once
2134 application.SendNotification();
2135 application.Render();
2137 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2138 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2140 // 2. Remove Constraint1 as well and test...
2143 actor.RemoveConstraint(activeConstraint1);
2144 // make color property dirty, which will trigger constraints to be reapplied.
2145 actor.SetColor( Color::WHITE );
2146 // flush the queue and render once
2147 application.SendNotification();
2148 application.Render();
2150 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2151 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2155 int UtcDaliActorRemoveConstraintTag(void)
2157 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2158 TestApplication application;
2160 Actor actor = Actor::New();
2162 // 1. Apply Constraint1 and Constraint2, and test...
2163 unsigned int result1 = 0u;
2164 unsigned int result2 = 0u;
2166 unsigned constraint1Tag = 1u;
2167 Constraint constraint1 = Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2168 constraint1.SetTag( constraint1Tag );
2169 actor.ApplyConstraint( constraint1 );
2171 unsigned constraint2Tag = 2u;
2172 Constraint constraint2 = Constraint::New<Vector4>( Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2173 constraint2.SetTag( constraint2Tag );
2174 actor.ApplyConstraint( constraint2 );
2176 Stage::GetCurrent().Add( actor );
2177 // flush the queue and render once
2178 application.SendNotification();
2179 application.Render();
2181 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2182 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2184 // 2. Remove Constraint1 and test...
2187 actor.RemoveConstraints(constraint1Tag);
2188 // make color property dirty, which will trigger constraints to be reapplied.
2189 actor.SetColor( Color::WHITE );
2190 // flush the queue and render once
2191 application.SendNotification();
2192 application.Render();
2194 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2195 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2197 // 3. Re-Apply Constraint1 and test...
2200 actor.ApplyConstraint( constraint1 );
2201 // make color property dirty, which will trigger constraints to be reapplied.
2202 actor.SetColor( Color::WHITE );
2203 // flush the queue and render once
2204 application.SendNotification();
2205 application.Render();
2207 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2208 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2210 // 2. Remove Constraint2 and test...
2213 actor.RemoveConstraints(constraint2Tag);
2214 // make color property dirty, which will trigger constraints to be reapplied.
2215 actor.SetColor( Color::WHITE );
2216 // flush the queue and render once
2217 application.SendNotification();
2218 application.Render();
2220 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2221 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2223 // 2. Remove Constraint1 as well and test...
2226 actor.RemoveConstraints(constraint1Tag);
2227 // make color property dirty, which will trigger constraints to be reapplied.
2228 actor.SetColor( Color::WHITE );
2229 // flush the queue and render once
2230 application.SendNotification();
2231 application.Render();
2233 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2234 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2238 int UtcDaliActorTouchedSignal(void)
2240 TestApplication application;
2242 gTouchCallBackCalled = false;
2244 // get the root layer
2245 Actor actor = Stage::GetCurrent().GetRootLayer();
2246 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2248 application.SendNotification();
2249 application.Render();
2251 // connect to its touch signal
2252 actor.TouchedSignal().Connect( TestCallback );
2254 // simulate a touch event in the middle of the screen
2255 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2256 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
2257 Dali::Integration::TouchEvent event;
2258 event.AddPoint( point );
2259 application.ProcessEvent( event );
2261 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2265 int UtcDaliActorHoveredSignal(void)
2267 TestApplication application;
2269 gHoverCallBackCalled = false;
2271 // get the root layer
2272 Actor actor = Stage::GetCurrent().GetRootLayer();
2273 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2275 application.SendNotification();
2276 application.Render();
2278 // connect to its hover signal
2279 actor.HoveredSignal().Connect( TestCallback3 );
2281 // simulate a hover event in the middle of the screen
2282 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2283 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
2284 Dali::Integration::HoverEvent event;
2285 event.AddPoint( point );
2286 application.ProcessEvent( event );
2288 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2292 int UtcDaliActorOnOffStageSignal(void)
2294 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2296 TestApplication application;
2299 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2300 gActorNamesOnOffStage.clear();
2302 Actor parent = Actor::New();
2303 parent.SetName( "parent" );
2304 parent.OnStageSignal().Connect( OnStageCallback );
2305 parent.OffStageSignal().Connect( OffStageCallback );
2307 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2308 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2310 // add parent to stage
2311 Stage::GetCurrent().Add( parent );
2312 // onstage emitted, offstage not
2313 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2314 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2315 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2317 // test adding a child, should get onstage emitted
2319 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2320 gActorNamesOnOffStage.clear();
2322 Actor child = Actor::New();
2323 child.SetName( "child" );
2324 child.OnStageSignal().Connect( OnStageCallback );
2325 child.OffStageSignal().Connect( OffStageCallback );
2326 parent.Add( child ); // add child
2327 // onstage emitted, offstage not
2328 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2329 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2330 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2332 // test removing parent from stage
2334 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2335 gActorNamesOnOffStage.clear();
2337 Stage::GetCurrent().Remove( parent );
2338 // onstage not emitted, offstage is
2339 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2340 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2341 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2342 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2344 // test adding parent back to stage
2346 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2347 gActorNamesOnOffStage.clear();
2349 Stage::GetCurrent().Add( parent );
2350 // onstage emitted, offstage not
2351 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2352 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2353 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2354 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2356 // test removing child
2358 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2359 gActorNamesOnOffStage.clear();
2361 parent.Remove( child );
2362 // onstage not emitted, offstage is
2363 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2364 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2365 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2367 // test removing parent
2369 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2370 gActorNamesOnOffStage.clear();
2372 Stage::GetCurrent().Remove( parent );
2373 // onstage not emitted, offstage is
2374 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2375 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2376 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2380 int UtcDaliActorFindChildByName(void)
2382 tet_infoline("Testing Dali::Actor::FindChildByName()");
2383 TestApplication application;
2385 Actor parent = Actor::New();
2386 parent.SetName( "parent" );
2387 Actor first = Actor::New();
2388 first .SetName( "first" );
2389 Actor second = Actor::New();
2390 second.SetName( "second" );
2395 Actor found = parent.FindChildByName( "foo" );
2396 DALI_TEST_CHECK( !found );
2398 found = parent.FindChildByName( "parent" );
2399 DALI_TEST_CHECK( found == parent );
2401 found = parent.FindChildByName( "first" );
2402 DALI_TEST_CHECK( found == first );
2404 found = parent.FindChildByName( "second" );
2405 DALI_TEST_CHECK( found == second );
2409 int UtcDaliActorFindChildById(void)
2411 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2412 TestApplication application;
2414 Actor parent = Actor::New();
2415 Actor first = Actor::New();
2416 Actor second = Actor::New();
2421 Actor found = parent.FindChildById( 100000 );
2422 DALI_TEST_CHECK( !found );
2424 found = parent.FindChildById( parent.GetId() );
2425 DALI_TEST_CHECK( found == parent );
2427 found = parent.FindChildById( first.GetId() );
2428 DALI_TEST_CHECK( found == first );
2430 found = parent.FindChildById( second.GetId() );
2431 DALI_TEST_CHECK( found == second );
2435 int UtcDaliActorHitTest(void)
2440 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2442 mTouchPoint( touchPoint ),
2447 Vector2 mTouchPoint;
2451 TestApplication application;
2452 tet_infoline(" UtcDaliActorHitTest");
2454 // Fill a vector with different hit tests.
2455 struct HitTestData* hitTestData[] = {
2456 // scale touch point result
2457 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2458 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2459 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.
2460 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2461 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.
2465 // get the root layer
2466 Actor actor = Actor::New();
2467 actor.SetAnchorPoint( AnchorPoint::CENTER );
2468 actor.SetParentOrigin( ParentOrigin::CENTER );
2470 Stage::GetCurrent().Add( actor );
2472 gTouchCallBackCalled = false;
2474 unsigned int index = 0;
2475 while( NULL != hitTestData[index] )
2477 actor.SetSize( 1.f, 1.f );
2478 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2480 // flush the queue and render once
2481 application.SendNotification();
2482 application.Render();
2484 DALI_TEST_CHECK( !gTouchCallBackCalled );
2486 // connect to its touch signal
2487 actor.TouchedSignal().Connect(TestCallback);
2489 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2490 Dali::Integration::TouchEvent event;
2491 event.AddPoint( point );
2493 // flush the queue and render once
2494 application.SendNotification();
2495 application.Render();
2496 application.ProcessEvent( event );
2498 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2500 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2501 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2502 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2503 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2504 hitTestData[index]->mResult );
2506 gTouchCallBackCalled = false;
2512 int UtcDaliActorSetDrawMode(void)
2514 TestApplication app;
2515 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2517 Actor a = Actor::New();
2519 Stage::GetCurrent().Add(a);
2520 app.SendNotification();
2522 app.SendNotification();
2525 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2527 a.SetDrawMode( DrawMode::OVERLAY );
2528 app.SendNotification();
2531 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2533 a.SetDrawMode( DrawMode::STENCIL );
2534 app.SendNotification();
2537 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2539 a.SetDrawMode( DrawMode::NORMAL );
2540 app.SendNotification();
2543 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2547 int UtcDaliActorSetDrawModeOverlayRender(void)
2549 TestApplication app;
2550 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2552 app.SendNotification();
2555 std::vector<GLuint> ids;
2556 ids.push_back( 8 ); // first rendered actor
2557 ids.push_back( 9 ); // second rendered actor
2558 ids.push_back( 10 ); // third rendered actor
2559 app.GetGlAbstraction().SetNextTextureIds( ids );
2561 BufferImage imageA = BufferImage::New(16, 16);
2562 BufferImage imageB = BufferImage::New(16, 16);
2563 BufferImage imageC = BufferImage::New(16, 16);
2564 ImageActor a = ImageActor::New( imageA );
2565 ImageActor b = ImageActor::New( imageB );
2566 ImageActor c = ImageActor::New( imageC );
2568 // Render a,b,c as regular non-overlays. so order will be:
2572 Stage::GetCurrent().Add(a);
2573 Stage::GetCurrent().Add(b);
2574 Stage::GetCurrent().Add(c);
2576 app.SendNotification();
2579 // Should be 3 textures changes.
2580 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2581 typedef std::vector<GLuint>::size_type TextureSize;
2582 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2583 if( boundTextures.size() == 3 )
2585 DALI_TEST_CHECK( boundTextures[0] == 8u );
2586 DALI_TEST_CHECK( boundTextures[1] == 9u );
2587 DALI_TEST_CHECK( boundTextures[2] == 10u );
2590 // Now texture ids have been set, we can monitor their render order.
2591 // render a as an overlay (last), so order will be:
2595 a.SetDrawMode( DrawMode::OVERLAY );
2596 app.GetGlAbstraction().ClearBoundTextures();
2598 app.SendNotification();
2601 // Should be 3 texture changes.
2602 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2603 if( boundTextures.size() == 3 )
2605 DALI_TEST_CHECK( boundTextures[0] == 9u );
2606 DALI_TEST_CHECK( boundTextures[1] == 10u );
2607 DALI_TEST_CHECK( boundTextures[2] == 8u );
2613 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2615 TestApplication app;
2616 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2618 BufferImage imageA = BufferImage::New(16, 16);
2619 BufferImage imageB = BufferImage::New(16, 16);
2620 ImageActor a = ImageActor::New( imageA );
2621 ImageActor b = ImageActor::New( imageB );
2623 // Render a,b as regular non-overlays. so order will be:
2624 Stage::GetCurrent().Add(a);
2625 Stage::GetCurrent().Add(b);
2627 a.SetSize( 100.0f, 100.0f );
2628 b.SetSize( 100.0f, 100.0f );
2630 // position b overlapping a. (regular non-overlays)
2631 // hit test at point 'x'
2642 // note: b is on top, because it's Z position is higher.
2643 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2644 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2646 // connect to their touch signals
2647 a.TouchedSignal().Connect(TestCallback);
2648 b.TouchedSignal().Connect(TestCallback2);
2650 a.SetDrawMode( DrawMode::NORMAL );
2651 b.SetDrawMode( DrawMode::NORMAL );
2652 SimulateTouchForSetOverlayHitTest(app);
2654 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2655 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2656 // Make Actor a an overlay.
2667 // note: a is on top, because it is an overlay.
2668 a.SetDrawMode( DrawMode::OVERLAY );
2669 b.SetDrawMode( DrawMode::NORMAL );
2670 SimulateTouchForSetOverlayHitTest(app);
2672 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2673 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2674 // Make both Actors as overlays
2685 // note: b is on top, because it is the 2nd child in the hierarchy.
2686 a.SetDrawMode( DrawMode::OVERLAY );
2687 b.SetDrawMode( DrawMode::OVERLAY );
2688 SimulateTouchForSetOverlayHitTest(app);
2690 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2691 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2695 int UtcDaliActorGetCurrentWorldMatrix(void)
2697 TestApplication app;
2698 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2700 Actor parent = Actor::New();
2701 parent.SetParentOrigin(ParentOrigin::CENTER);
2702 parent.SetAnchorPoint(AnchorPoint::CENTER);
2703 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2704 Radian rotationAngle(Degree(85.0f));
2705 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2706 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2707 parent.SetPosition( parentPosition );
2708 parent.SetOrientation( parentRotation );
2709 parent.SetScale( parentScale );
2710 Stage::GetCurrent().Add( parent );
2712 Actor child = Actor::New();
2713 child.SetParentOrigin(ParentOrigin::CENTER);
2714 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2715 Radian childRotationAngle(Degree(23.0f));
2716 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2717 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2718 child.SetPosition( childPosition );
2719 child.SetOrientation( childRotation );
2720 child.SetScale( childScale );
2721 parent.Add( child );
2723 // The actors should not have a world matrix yet
2724 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2725 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2727 app.SendNotification();
2730 app.SendNotification();
2732 Matrix parentMatrix(false);
2733 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2735 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2736 Quaternion childWorldRotation = parentRotation * childRotation;
2737 Vector3 childWorldScale = parentScale * childScale;
2739 Matrix childWorldMatrix(false);
2740 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2742 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2743 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2749 int UtcDaliActorConstrainedToWorldMatrix(void)
2751 TestApplication app;
2752 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2754 Actor parent = Actor::New();
2755 parent.SetParentOrigin(ParentOrigin::CENTER);
2756 parent.SetAnchorPoint(AnchorPoint::CENTER);
2757 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2758 Radian rotationAngle(Degree(85.0f));
2759 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2760 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2761 parent.SetPosition( parentPosition );
2762 parent.SetOrientation( parentRotation );
2763 parent.SetScale( parentScale );
2764 Stage::GetCurrent().Add( parent );
2766 Actor child = Actor::New();
2767 child.SetParentOrigin(ParentOrigin::CENTER);
2768 Constraint posConstraint = Constraint::New<Vector3>( Actor::Property::POSITION, Source( parent, Actor::Property::WORLD_MATRIX), PositionComponentConstraint() );
2769 child.ApplyConstraint(posConstraint);
2771 Stage::GetCurrent().Add( child );
2773 // The actors should not have a world matrix yet
2774 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2775 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2777 app.SendNotification();
2780 app.SendNotification();
2782 Matrix parentMatrix(false);
2783 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2785 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2786 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2790 int UtcDaliActorUnparent(void)
2792 TestApplication app;
2793 tet_infoline(" UtcDaliActorUnparent");
2795 Actor parent = Actor::New();
2796 Stage::GetCurrent().Add( parent );
2798 Actor child = Actor::New();
2800 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2801 DALI_TEST_CHECK( !child.GetParent() );
2803 // Test that calling Unparent with no parent is a NOOP
2806 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2807 DALI_TEST_CHECK( !child.GetParent() );
2809 // Test that Unparent works
2810 parent.Add( child );
2812 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2813 DALI_TEST_CHECK( parent == child.GetParent() );
2817 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2818 DALI_TEST_CHECK( !child.GetParent() );
2820 // Test that UnparentAndReset works
2821 parent.Add( child );
2823 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2824 DALI_TEST_CHECK( parent == child.GetParent() );
2826 UnparentAndReset( child );
2828 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2829 DALI_TEST_CHECK( !child );
2831 // Test that UnparentAndReset is a NOOP with empty handle
2832 UnparentAndReset( child );
2834 DALI_TEST_CHECK( !child );
2838 int UtcDaliActorGetChildAt(void)
2840 TestApplication app;
2841 tet_infoline(" UtcDaliActorGetChildAt");
2843 Actor parent = Actor::New();
2844 Stage::GetCurrent().Add( parent );
2846 Actor child0 = Actor::New();
2847 parent.Add( child0 );
2849 Actor child1 = Actor::New();
2850 parent.Add( child1 );
2852 Actor child2 = Actor::New();
2853 parent.Add( child2 );
2855 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2856 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2857 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2861 int UtcDaliActorSetGetOverlay(void)
2863 TestApplication app;
2864 tet_infoline(" UtcDaliActorSetGetOverlay");
2866 Actor parent = Actor::New();
2867 parent.SetDrawMode(DrawMode::OVERLAY );
2868 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2873 // Current Dynamics functions are crashing, so testing these sections are futile
2875 int UtcDaliActorDynamics(void)
2877 DALI_TEST_CHECK( true );
2881 int UtcDaliActorCreateDestroy(void)
2883 Actor* actor = new Actor;
2884 DALI_TEST_CHECK( actor );
2891 struct PropertyStringIndex
2893 const char * const name;
2894 const Property::Index index;
2895 const Property::Type type;
2898 const PropertyStringIndex PROPERTY_TABLE[] =
2900 { "parent-origin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2901 { "parent-origin-x", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2902 { "parent-origin-y", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2903 { "parent-origin-z", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2904 { "anchor-point", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2905 { "anchor-point-x", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2906 { "anchor-point-y", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2907 { "anchor-point-z", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2908 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2909 { "size-width", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2910 { "size-height", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2911 { "size-depth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2912 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2913 { "position-x", Actor::Property::POSITION_X, Property::FLOAT },
2914 { "position-y", Actor::Property::POSITION_Y, Property::FLOAT },
2915 { "position-z", Actor::Property::POSITION_Z, Property::FLOAT },
2916 { "world-position", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2917 { "world-position-x", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2918 { "world-position-y", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2919 { "world-position-z", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2920 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2921 { "world-orientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2922 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2923 { "scale-x", Actor::Property::SCALE_X, Property::FLOAT },
2924 { "scale-y", Actor::Property::SCALE_Y, Property::FLOAT },
2925 { "scale-z", Actor::Property::SCALE_Z, Property::FLOAT },
2926 { "world-scale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2927 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2928 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2929 { "color-red", Actor::Property::COLOR_RED, Property::FLOAT },
2930 { "color-green", Actor::Property::COLOR_GREEN, Property::FLOAT },
2931 { "color-blue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2932 { "color-alpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2933 { "world-color", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2934 { "world-matrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2935 { "name", Actor::Property::NAME, Property::STRING },
2936 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2937 { "leave-required", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2938 { "inherit-orientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2939 { "inherit-scale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2940 { "color-mode", Actor::Property::COLOR_MODE, Property::STRING },
2941 { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2942 { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
2943 { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2944 { "relayout-enabled", Actor::Property::RELAYOUT_ENABLED, Property::BOOLEAN },
2945 { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2946 { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2947 { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2948 { "width-for-height", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2949 { "height-for-width", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2950 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2951 { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2952 { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2954 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2955 } // unnamed namespace
2957 int UtcDaliActorProperties(void)
2959 TestApplication app;
2961 Actor actor = Actor::New();
2963 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2965 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2966 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2967 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2968 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2973 int UtcDaliRelayoutProperties_RelayoutEnabled(void)
2975 TestApplication app;
2977 Actor actor = Actor::New();
2980 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION );
2982 // Set relayout disabled
2983 actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, false );
2985 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION );
2987 // Set relayout enabled
2988 actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, true );
2990 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), true, TEST_LOCATION );
2995 int UtcDaliRelayoutProperties_ResizePolicies(void)
2997 TestApplication app;
2999 Actor actor = Actor::New();
3002 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
3003 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
3005 // Set resize policy for all dimensions
3006 actor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
3007 for( unsigned int i = 0; i < DIMENSION_COUNT; ++i)
3009 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension >( 1 << i ) ), USE_NATURAL_SIZE, TEST_LOCATION );
3012 // Set individual dimensions
3013 const char* const widthPolicy = "FILL_TO_PARENT";
3014 const char* const heightPolicy = "FIXED";
3016 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3017 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3019 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3020 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3025 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3027 TestApplication app;
3029 Actor actor = Actor::New();
3032 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3035 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3036 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3038 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3039 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3041 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3042 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3047 int UtcDaliRelayoutProperties_DimensionDependency(void)
3049 TestApplication app;
3051 Actor actor = Actor::New();
3054 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3055 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3058 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3059 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3061 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3062 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3064 // Test setting another resize policy
3065 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3066 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3071 int UtcDaliRelayoutProperties_Padding(void)
3073 TestApplication app;
3075 Actor actor = Actor::New();
3078 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3081 actor.SetProperty( Actor::Property::PADDING, padding );
3082 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3084 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3089 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3091 TestApplication app;
3093 Actor actor = Actor::New();
3096 Vector2 minSize( 1.0f, 2.0f );
3098 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3099 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3101 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3103 Vector2 maxSize( 3.0f, 4.0f );
3105 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3106 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3108 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );