2 * Copyright (c) 2015 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 <cfloat> // For FLT_MAX
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
34 void utc_dali_actor_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_actor_cleanup(void)
41 test_return_value = TET_PASS;
46 bool gTouchCallBackCalled=false;
47 bool gHoverCallBackCalled=false;
50 * Simulates a Down Touch at 25.0, 25.0.
51 * @param[in] app Test Application instance.
53 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
55 app.SendNotification();
57 app.SendNotification();
60 gTouchCallBackCalled = false;
62 // simulate a touch event
63 Dali::Integration::Point point;
64 point.SetState( PointState::DOWN );
65 point.SetScreenPosition( Vector2( 25.0f, 25.0f ) );
66 Dali::Integration::TouchEvent event;
67 event.AddPoint( point );
68 app.ProcessEvent( event );
70 app.SendNotification();
72 app.SendNotification();
78 static bool gTestConstraintCalled;
82 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
84 gTestConstraintCalled = true;
89 * TestConstraint reference.
90 * When constraint is called, the resultRef is updated
91 * with the value supplied.
94 struct TestConstraintRef
96 TestConstraintRef(unsigned int& resultRef, unsigned int value)
97 : mResultRef(resultRef),
102 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
107 unsigned int& mResultRef;
111 static bool TestCallback(Actor actor, const TouchEvent& event)
113 gTouchCallBackCalled = true;
118 static bool TestCallback3(Actor actor, const HoverEvent& event)
120 gHoverCallBackCalled = true;
125 static Vector3 gSetSize;
126 static bool gSetSizeCallBackCalled;
127 void SetSizeCallback( Actor actor, const Vector3& size )
129 gSetSizeCallBackCalled = true;
132 // validation stuff for onstage & offstage signals
133 static std::vector< std::string > gActorNamesOnOffStage;
134 static int gOnStageCallBackCalled;
135 void OnStageCallback( Actor actor )
137 ++gOnStageCallBackCalled;
138 gActorNamesOnOffStage.push_back( actor.GetName() );
139 DALI_TEST_CHECK( actor.OnStage() == true );
141 static int gOffStageCallBackCalled;
142 void OffStageCallback( Actor actor )
144 ++gOffStageCallBackCalled;
145 gActorNamesOnOffStage.push_back( actor.GetName() );
146 DALI_TEST_CHECK( actor.OnStage() == false );
149 struct PositionComponentConstraint
151 PositionComponentConstraint(){}
153 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
155 const Matrix& m = inputs[0]->GetMatrix();
158 m.GetTransformComponents(pos, rot, scale);
162 struct OrientationComponentConstraint
164 OrientationComponentConstraint(){}
166 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
168 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
171 orientation = parentOrientation;
176 static bool gOnRelayoutCallBackCalled = false;
177 static std::vector< std::string > gActorNamesRelayout;
179 void OnRelayoutCallback( Actor actor )
181 gOnRelayoutCallBackCalled = true;
182 gActorNamesRelayout.push_back( actor.GetName() );
185 } // anonymous namespace
188 //& purpose: Testing New API
189 int UtcDaliActorNew(void)
191 TestApplication application;
193 Actor actor = Actor::New();
195 DALI_TEST_CHECK(actor);
199 //& purpose: Testing Dali::Actor::DownCast()
200 int UtcDaliActorDownCastP(void)
202 TestApplication application;
203 tet_infoline("Testing Dali::Actor::DownCast()");
205 Actor actor = Actor::New();
206 BaseHandle object(actor);
207 Actor actor2 = Actor::DownCast(object);
208 DALI_TEST_CHECK(actor2);
212 //& purpose: Testing Dali::Actor::DownCast()
213 int UtcDaliActorDownCastN(void)
215 TestApplication application;
216 tet_infoline("Testing Dali::Actor::DownCast()");
218 BaseHandle unInitializedObject;
219 Actor actor = Actor::DownCast(unInitializedObject);
220 DALI_TEST_CHECK(!actor);
224 //& purpose: Testing Dali::Actor::GetName()
225 int UtcDaliActorGetName(void)
227 TestApplication application;
229 Actor actor = Actor::New();
231 DALI_TEST_CHECK(actor.GetName().empty());
235 //& purpose: Testing Dali::Actor::SetName()
236 int UtcDaliActorSetName(void)
238 TestApplication application;
240 string str("ActorName");
241 Actor actor = Actor::New();
244 DALI_TEST_CHECK(actor.GetName() == str);
248 int UtcDaliActorGetId(void)
250 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
251 TestApplication application;
253 Actor first = Actor::New();
254 Actor second = Actor::New();
255 Actor third = Actor::New();
257 DALI_TEST_CHECK(first.GetId() != second.GetId());
258 DALI_TEST_CHECK(second.GetId() != third.GetId());
262 int UtcDaliActorIsRoot(void)
264 TestApplication application;
266 Actor actor = Actor::New();
267 DALI_TEST_CHECK(!actor.IsRoot());
269 // get the root layer
270 actor = Stage::GetCurrent().GetLayer( 0 );
271 DALI_TEST_CHECK( actor.IsRoot() );
275 int UtcDaliActorOnStage(void)
277 TestApplication application;
279 Actor actor = Actor::New();
280 DALI_TEST_CHECK( !actor.OnStage() );
282 // get the root layer
283 actor = Stage::GetCurrent().GetLayer( 0 );
284 DALI_TEST_CHECK( actor.OnStage() );
288 int UtcDaliActorIsLayer(void)
290 TestApplication application;
292 Actor actor = Actor::New();
293 DALI_TEST_CHECK( !actor.IsLayer() );
295 // get the root layer
296 actor = Stage::GetCurrent().GetLayer( 0 );
297 DALI_TEST_CHECK( actor.IsLayer() );
301 int UtcDaliActorGetLayer(void)
303 TestApplication application;
305 Actor actor = Actor::New();
306 Stage::GetCurrent().Add(actor);
307 Layer layer = actor.GetLayer();
309 DALI_TEST_CHECK(layer);
311 // get the root layers layer
312 actor = Stage::GetCurrent().GetLayer( 0 );
313 DALI_TEST_CHECK( actor.GetLayer() );
317 int UtcDaliActorAddP(void)
319 tet_infoline("Testing Actor::Add");
320 TestApplication application;
322 Actor parent = Actor::New();
323 Actor child = Actor::New();
325 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
329 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
331 Actor parent2 = Actor::New();
332 parent2.Add( child );
334 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
335 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
337 // try Adding to same parent again, works
338 parent2.Add( child );
339 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
341 // try reparenting an orphaned child
343 Actor temporaryParent = Actor::New();
344 temporaryParent.Add( child );
345 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
347 // temporaryParent has now died, reparent the orphaned child
348 parent2.Add( child );
349 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
354 int UtcDaliActorAddN(void)
356 tet_infoline("Testing Actor::Add");
357 TestApplication application;
359 Actor child = Actor::New();
361 Actor parent2 = Actor::New();
362 parent2.Add( child );
367 parent2.Add( parent2 );
368 tet_printf("Assertion test failed - no Exception\n" );
369 tet_result(TET_FAIL);
371 catch(Dali::DaliException& e)
373 DALI_TEST_PRINT_ASSERT( e );
374 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
375 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
379 tet_printf("Assertion test failed - wrong Exception\n" );
380 tet_result(TET_FAIL);
383 // try reparenting root
386 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
387 tet_printf("Assertion test failed - no Exception\n" );
388 tet_result(TET_FAIL);
390 catch(Dali::DaliException& e)
392 DALI_TEST_PRINT_ASSERT( e );
393 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
394 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
398 tet_printf("Assertion test failed - wrong Exception\n" );
399 tet_result(TET_FAIL);
406 parent2.Add( empty );
407 tet_printf("Assertion test failed - no Exception\n" );
408 tet_result(TET_FAIL);
410 catch(Dali::DaliException& e)
412 DALI_TEST_PRINT_ASSERT( e );
413 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
414 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
418 tet_printf("Assertion test failed - wrong Exception\n" );
419 tet_result(TET_FAIL);
425 int UtcDaliActorRemoveN(void)
427 tet_infoline("Testing Actor::Remove");
428 TestApplication application;
430 Actor parent = Actor::New();
431 Actor child = Actor::New();
432 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
435 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
437 parent.Remove(child);
438 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
440 // remove again, no problem
441 parent.Remove(child);
442 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
446 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
447 // try Remove self, its a no-op
448 parent.Remove( parent );
449 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
455 parent.Remove( empty );
456 tet_printf("Assertion test failed - no Exception\n" );
457 tet_result(TET_FAIL);
459 catch(Dali::DaliException& e)
461 DALI_TEST_PRINT_ASSERT( e );
462 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
463 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
467 tet_printf("Assertion test failed - wrong Exception\n" );
468 tet_result(TET_FAIL);
473 int UtcDaliActorRemoveP(void)
475 TestApplication application;
477 Actor parent = Actor::New();
478 Actor child = Actor::New();
479 Actor random = Actor::New();
481 Stage::GetCurrent().Add( parent );
483 DALI_TEST_CHECK(parent.GetChildCount() == 0);
487 DALI_TEST_CHECK(parent.GetChildCount() == 1);
489 parent.Remove(random);
491 DALI_TEST_CHECK(parent.GetChildCount() == 1);
493 Stage::GetCurrent().Remove( parent );
495 DALI_TEST_CHECK(parent.GetChildCount() == 1);
499 int UtcDaliActorGetChildCount(void)
501 TestApplication application;
503 Actor parent = Actor::New();
504 Actor child = Actor::New();
506 DALI_TEST_CHECK(parent.GetChildCount() == 0);
510 DALI_TEST_CHECK(parent.GetChildCount() == 1);
514 int UtcDaliActorGetChildren01(void)
516 TestApplication application;
518 Actor parent = Actor::New();
519 Actor first = Actor::New();
520 Actor second = Actor::New();
521 Actor third = Actor::New();
527 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
528 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
529 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
533 int UtcDaliActorGetChildren02(void)
535 TestApplication application;
537 Actor parent = Actor::New();
538 Actor first = Actor::New();
539 Actor second = Actor::New();
540 Actor third = Actor::New();
546 const Actor& constParent = parent;
548 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
549 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
550 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
554 int UtcDaliActorGetParent01(void)
556 TestApplication application;
558 Actor parent = Actor::New();
559 Actor child = Actor::New();
563 DALI_TEST_CHECK(child.GetParent() == parent);
567 int UtcDaliActorGetParent02(void)
569 TestApplication application;
571 Actor actor = Actor::New();
573 DALI_TEST_CHECK(!actor.GetParent());
577 int UtcDaliActorSetParentOrigin(void)
579 TestApplication application;
581 Actor actor = Actor::New();
583 Vector3 vector(0.7f, 0.8f, 0.9f);
584 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
586 actor.SetParentOrigin(vector);
588 // flush the queue and render once
589 application.SendNotification();
590 application.Render();
592 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
594 Stage::GetCurrent().Add( actor );
596 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
598 // flush the queue and render once
599 application.SendNotification();
600 application.Render();
602 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
604 Stage::GetCurrent().Remove( actor );
608 int UtcDaliActorSetParentOriginIndividual(void)
610 TestApplication application;
612 Actor actor = Actor::New();
614 Vector3 vector(0.7f, 0.8f, 0.9f);
615 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
617 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
619 // flush the queue and render once
620 application.SendNotification();
621 application.Render();
623 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
625 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
627 // flush the queue and render once
628 application.SendNotification();
629 application.Render();
631 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
633 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
635 // flush the queue and render once
636 application.SendNotification();
637 application.Render();
639 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
644 int UtcDaliActorGetCurrentParentOrigin(void)
646 TestApplication application;
648 Actor actor = Actor::New();
650 Vector3 vector(0.7f, 0.8f, 0.9f);
651 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
653 actor.SetParentOrigin(vector);
655 // flush the queue and render once
656 application.SendNotification();
657 application.Render();
659 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
663 int UtcDaliActorSetAnchorPoint(void)
665 TestApplication application;
667 Actor actor = Actor::New();
669 Vector3 vector(0.7f, 0.8f, 0.9f);
670 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
672 actor.SetAnchorPoint(vector);
674 // flush the queue and render once
675 application.SendNotification();
676 application.Render();
678 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
680 Stage::GetCurrent().Add( actor );
682 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
683 // flush the queue and render once
684 application.SendNotification();
685 application.Render();
687 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
689 Stage::GetCurrent().Remove( actor );
693 int UtcDaliActorSetAnchorPointIndividual(void)
695 TestApplication application;
697 Actor actor = Actor::New();
699 Vector3 vector(0.7f, 0.8f, 0.9f);
700 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
702 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
704 // flush the queue and render once
705 application.SendNotification();
706 application.Render();
708 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
710 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
712 // flush the queue and render once
713 application.SendNotification();
714 application.Render();
716 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
718 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
720 // flush the queue and render once
721 application.SendNotification();
722 application.Render();
724 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
729 int UtcDaliActorGetCurrentAnchorPoint(void)
731 TestApplication application;
733 Actor actor = Actor::New();
735 Vector3 vector(0.7f, 0.8f, 0.9f);
736 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
738 actor.SetAnchorPoint(vector);
740 // flush the queue and render once
741 application.SendNotification();
742 application.Render();
744 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
748 // SetSize(float width, float height)
749 int UtcDaliActorSetSize01(void)
751 TestApplication application;
753 Actor actor = Actor::New();
754 Vector3 vector(100.0f, 100.0f, 0.0f);
756 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
758 actor.SetSize(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(float width, float height, float depth)
769 int UtcDaliActorSetSize02(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.x, vector.y, vector.z);
780 // flush the queue and render once
781 application.SendNotification();
782 application.Render();
784 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
788 // SetSize(Vector2 size)
789 int UtcDaliActorSetSize03(void)
791 TestApplication application;
793 Actor actor = Actor::New();
794 Vector3 vector(100.0f, 100.0f, 0.0f);
796 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
798 actor.SetSize(Vector2(vector.x, vector.y));
800 // flush the queue and render once
801 application.SendNotification();
802 application.Render();
804 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
808 // SetSize(Vector3 size)
809 int UtcDaliActorSetSize04(void)
811 TestApplication application;
813 Actor actor = Actor::New();
814 Vector3 vector(100.0f, 100.0f, 100.0f);
816 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
818 actor.SetSize(vector);
820 // flush the queue and render once
821 application.SendNotification();
822 application.Render();
824 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
826 Stage::GetCurrent().Add( actor );
827 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
829 // flush the queue and render once
830 application.SendNotification();
831 application.Render();
833 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
834 Stage::GetCurrent().Remove( actor );
838 int UtcDaliActorSetSizeIndividual(void)
840 TestApplication application;
842 Actor actor = Actor::New();
844 Vector3 vector(0.7f, 0.8f, 0.9f);
845 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
847 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
849 // flush the queue and render once
850 application.SendNotification();
851 application.Render();
853 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
855 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
857 // flush the queue and render once
858 application.SendNotification();
859 application.Render();
861 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
863 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
865 // flush the queue and render once
866 application.SendNotification();
867 application.Render();
869 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
875 int UtcDaliActorGetCurrentSize(void)
877 TestApplication application;
879 Actor actor = Actor::New();
880 Vector3 vector(100.0f, 100.0f, 20.0f);
882 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
884 actor.SetSize(vector);
886 // flush the queue and render once
887 application.SendNotification();
888 application.Render();
890 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
894 int UtcDaliActorGetNaturalSize(void)
896 TestApplication application;
898 Actor actor = Actor::New();
899 Vector3 vector( 0.0f, 0.0f, 0.0f );
901 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
906 int UtcDaliActorGetCurrentSizeImmediate(void)
908 TestApplication application;
910 Actor actor = Actor::New();
911 Vector3 vector(100.0f, 100.0f, 20.0f);
913 DALI_TEST_CHECK(vector != actor.GetTargetSize());
914 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
916 actor.SetSize(vector);
918 DALI_TEST_CHECK(vector == actor.GetTargetSize());
919 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
921 // flush the queue and render once
922 application.SendNotification();
923 application.Render();
925 DALI_TEST_CHECK(vector == actor.GetTargetSize());
926 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
929 // Build the animation
930 const float durationSeconds = 2.0f;
931 Animation animation = Animation::New( durationSeconds );
932 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
933 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
935 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
937 // Start the animation
940 application.SendNotification();
941 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
943 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
948 // SetPosition(float x, float y)
949 int UtcDaliActorSetPosition01(void)
951 TestApplication application;
953 Actor actor = Actor::New();
955 // Set to random to start off with
956 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
958 Vector3 vector(100.0f, 100.0f, 0.0f);
960 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
962 actor.SetPosition(vector.x, vector.y);
963 // flush the queue and render once
964 application.SendNotification();
965 application.Render();
966 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
968 Stage::GetCurrent().Add( actor );
969 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
970 // flush the queue and render once
971 application.SendNotification();
972 application.Render();
973 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
978 // flush the queue and render once
979 application.SendNotification();
980 application.Render();
981 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
983 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
984 // flush the queue and render once
985 application.SendNotification();
986 application.Render();
987 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
989 Stage::GetCurrent().Remove( actor );
993 // SetPosition(float x, float y, float z)
994 int UtcDaliActorSetPosition02(void)
996 TestApplication application;
998 Actor actor = Actor::New();
1000 // Set to random to start off with
1001 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1003 Vector3 vector(100.0f, 100.0f, 100.0f);
1005 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1007 actor.SetPosition(vector.x, vector.y, vector.z);
1009 // flush the queue and render once
1010 application.SendNotification();
1011 application.Render();
1013 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1017 // SetPosition(Vector3 position)
1018 int UtcDaliActorSetPosition03(void)
1020 TestApplication application;
1022 Actor actor = Actor::New();
1024 // Set to random to start off with
1025 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1027 Vector3 vector(100.0f, 100.0f, 100.0f);
1029 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1031 actor.SetPosition(vector);
1033 // flush the queue and render once
1034 application.SendNotification();
1035 application.Render();
1037 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1041 int UtcDaliActorSetX(void)
1043 TestApplication application;
1045 Actor actor = Actor::New();
1047 Vector3 vector(100.0f, 0.0f, 0.0f);
1049 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1053 // flush the queue and render once
1054 application.SendNotification();
1055 application.Render();
1057 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1061 int UtcDaliActorSetY(void)
1063 TestApplication application;
1065 Actor actor = Actor::New();
1067 Vector3 vector(0.0f, 100.0f, 0.0f);
1069 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1073 // flush the queue and render once
1074 application.SendNotification();
1075 application.Render();
1077 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1081 int UtcDaliActorSetZ(void)
1083 TestApplication application;
1085 Actor actor = Actor::New();
1087 Vector3 vector(0.0f, 0.0f, 100.0f);
1089 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1093 // flush the queue and render once
1094 application.SendNotification();
1095 application.Render();
1097 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1101 int UtcDaliActorSetPositionProperties(void)
1103 TestApplication application;
1105 Actor actor = Actor::New();
1107 Vector3 vector(0.7f, 0.8f, 0.9f);
1108 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1110 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1112 // flush the queue and render once
1113 application.SendNotification();
1114 application.Render();
1116 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1118 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1120 // flush the queue and render once
1121 application.SendNotification();
1122 application.Render();
1124 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1126 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1128 // flush the queue and render once
1129 application.SendNotification();
1130 application.Render();
1132 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1137 int UtcDaliActorTranslateBy(void)
1139 TestApplication application;
1141 Actor actor = Actor::New();
1142 Vector3 vector(100.0f, 100.0f, 100.0f);
1144 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1146 actor.SetPosition(vector);
1148 // flush the queue and render once
1149 application.SendNotification();
1150 application.Render();
1152 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1154 actor.TranslateBy(vector);
1156 // flush the queue and render once
1157 application.SendNotification();
1158 application.Render();
1160 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1164 int UtcDaliActorGetCurrentPosition(void)
1166 TestApplication application;
1168 Actor actor = Actor::New();
1169 Vector3 setVector(100.0f, 100.0f, 0.0f);
1170 actor.SetPosition(setVector);
1172 // flush the queue and render once
1173 application.SendNotification();
1174 application.Render();
1176 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1180 int UtcDaliActorGetCurrentWorldPosition(void)
1182 TestApplication application;
1184 Actor parent = Actor::New();
1185 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1186 parent.SetPosition( parentPosition );
1187 parent.SetParentOrigin( ParentOrigin::CENTER );
1188 parent.SetAnchorPoint( AnchorPoint::CENTER );
1189 Stage::GetCurrent().Add( parent );
1191 Actor child = Actor::New();
1192 child.SetParentOrigin( ParentOrigin::CENTER );
1193 child.SetAnchorPoint( AnchorPoint::CENTER );
1194 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1195 child.SetPosition( childPosition );
1196 parent.Add( child );
1198 // The actors should not have a world position yet
1199 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1200 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1202 application.SendNotification();
1203 application.Render(0);
1205 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1206 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1208 // The actors should have a world position now
1209 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1210 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1214 int UtcDaliActorInheritPosition(void)
1216 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1217 TestApplication application;
1219 Actor parent = Actor::New();
1220 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1221 parent.SetPosition( parentPosition );
1222 parent.SetParentOrigin( ParentOrigin::CENTER );
1223 parent.SetAnchorPoint( AnchorPoint::CENTER );
1224 Stage::GetCurrent().Add( parent );
1226 Actor child = Actor::New();
1227 child.SetParentOrigin( ParentOrigin::CENTER );
1228 child.SetAnchorPoint( AnchorPoint::CENTER );
1229 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1230 child.SetPosition( childPosition );
1231 parent.Add( child );
1233 // The actors should not have a world position yet
1234 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1235 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1237 // first test default, which is to inherit position
1238 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1239 application.SendNotification();
1240 application.Render(0); // should only really call Update as Render is not required to update scene
1241 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1242 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1243 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1244 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1247 //Change child position
1248 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1249 child.SetPosition( childOffset );
1251 // Change inheritance mode to not inherit
1252 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1253 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1254 application.SendNotification();
1255 application.Render(0); // should only really call Update as Render is not required to update scene
1256 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1257 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1258 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1259 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1263 int UtcDaliActorSetInheritPosition(void)
1265 tet_infoline("Testing Actor::SetInheritPosition");
1266 TestApplication application;
1268 Actor parent = Actor::New();
1269 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1270 parent.SetPosition( parentPosition );
1271 parent.SetParentOrigin( ParentOrigin::CENTER );
1272 parent.SetAnchorPoint( AnchorPoint::CENTER );
1273 Stage::GetCurrent().Add( parent );
1275 Actor child = Actor::New();
1276 child.SetParentOrigin( ParentOrigin::CENTER );
1277 child.SetAnchorPoint( AnchorPoint::CENTER );
1278 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1279 child.SetPosition( childPosition );
1280 parent.Add( child );
1282 // The actors should not have a world position yet
1283 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1284 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1286 // first test default, which is to inherit position
1287 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1288 application.SendNotification();
1289 application.Render(0); // should only really call Update as Render is not required to update scene
1290 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1291 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1292 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1293 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1295 //Change child position
1296 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1297 child.SetPosition( childOffset );
1299 // Use local position as world postion
1300 child.SetInheritPosition( false );
1301 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1302 application.SendNotification();
1303 application.Render(0); // should only really call Update as Render is not required to update scene
1304 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1305 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1306 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1307 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1309 //Change back to inherit position from parent
1310 child.SetInheritPosition( true );
1311 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1312 application.SendNotification();
1313 application.Render(0); // should only really call Update as Render is not required to update scene
1314 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1315 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1316 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1317 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1321 // SetOrientation(float angleRadians, Vector3 axis)
1322 int UtcDaliActorSetOrientation01(void)
1324 TestApplication application;
1326 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1327 Actor actor = Actor::New();
1329 actor.SetOrientation(rotation);
1331 // flush the queue and render once
1332 application.SendNotification();
1333 application.Render();
1335 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1339 int UtcDaliActorSetOrientation02(void)
1341 TestApplication application;
1343 Actor actor = Actor::New();
1345 Radian angle( 0.785f );
1346 Vector3 axis(1.0f, 1.0f, 0.0f);
1348 actor.SetOrientation( angle, axis);
1349 Quaternion rotation( angle, axis );
1350 // flush the queue and render once
1351 application.SendNotification();
1352 application.Render();
1353 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1355 Stage::GetCurrent().Add( actor );
1356 actor.RotateBy( Degree( 360 ), axis);
1357 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1359 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1360 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1361 // flush the queue and render once
1362 application.SendNotification();
1363 application.Render();
1364 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1366 actor.SetOrientation( angle, axis);
1367 // flush the queue and render once
1368 application.SendNotification();
1369 application.Render();
1370 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1372 Stage::GetCurrent().Remove( actor );
1376 // SetOrientation(float angleRadians, Vector3 axis)
1377 int UtcDaliActorSetOrientationProperty(void)
1379 TestApplication application;
1381 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1382 Actor actor = Actor::New();
1384 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1386 // flush the queue and render once
1387 application.SendNotification();
1388 application.Render();
1390 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1394 // RotateBy(float angleRadians, Vector3 axis)
1395 int UtcDaliActorRotateBy01(void)
1397 TestApplication application;
1399 Actor actor = Actor::New();
1401 Radian angle( M_PI * 0.25f );
1402 actor.RotateBy(( angle ), Vector3::ZAXIS);
1403 // flush the queue and render once
1404 application.SendNotification();
1405 application.Render();
1406 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1408 Stage::GetCurrent().Add( actor );
1410 actor.RotateBy( angle, Vector3::ZAXIS);
1411 // flush the queue and render once
1412 application.SendNotification();
1413 application.Render();
1414 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1416 Stage::GetCurrent().Remove( actor );
1420 // RotateBy(Quaternion relativeRotation)
1421 int UtcDaliActorRotateBy02(void)
1423 TestApplication application;
1425 Actor actor = Actor::New();
1427 Radian angle( M_PI * 0.25f );
1428 Quaternion rotation(angle, Vector3::ZAXIS);
1429 actor.RotateBy(rotation);
1430 // flush the queue and render once
1431 application.SendNotification();
1432 application.Render();
1433 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1435 actor.RotateBy(rotation);
1436 // flush the queue and render once
1437 application.SendNotification();
1438 application.Render();
1439 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1443 int UtcDaliActorGetCurrentOrientation(void)
1445 TestApplication application;
1446 Actor actor = Actor::New();
1448 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1449 actor.SetOrientation(rotation);
1450 // flush the queue and render once
1451 application.SendNotification();
1452 application.Render();
1453 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1457 int UtcDaliActorGetCurrentWorldOrientation(void)
1459 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1460 TestApplication application;
1462 Actor parent = Actor::New();
1463 Radian rotationAngle( Degree(90.0f) );
1464 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1465 parent.SetOrientation( rotation );
1466 Stage::GetCurrent().Add( parent );
1468 Actor child = Actor::New();
1469 child.SetOrientation( rotation );
1470 parent.Add( child );
1472 // The actors should not have a world rotation yet
1473 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1474 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1476 application.SendNotification();
1477 application.Render(0);
1479 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1480 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1482 // The actors should have a world rotation now
1483 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1484 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1486 // turn off child rotation inheritance
1487 child.SetInheritOrientation( false );
1488 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1489 application.SendNotification();
1490 application.Render(0);
1492 // The actors should have a world rotation now
1493 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1494 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1498 // SetScale(float scale)
1499 int UtcDaliActorSetScale01(void)
1501 TestApplication application;
1503 Actor actor = Actor::New();
1505 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1506 actor.SetScale(0.25f);
1508 Vector3 scale(10.0f, 10.0f, 10.0f);
1509 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1511 actor.SetScale(scale.x);
1513 // flush the queue and render once
1514 application.SendNotification();
1515 application.Render();
1517 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1521 // SetScale(float scaleX, float scaleY, float scaleZ)
1522 int UtcDaliActorSetScale02(void)
1524 TestApplication application;
1525 Vector3 scale(10.0f, 10.0f, 10.0f);
1527 Actor actor = Actor::New();
1529 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1530 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1532 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1534 actor.SetScale(scale.x, scale.y, scale.z);
1535 // flush the queue and render once
1536 application.SendNotification();
1537 application.Render();
1538 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1540 // add to stage and test
1541 Stage::GetCurrent().Add( actor );
1542 actor.SetScale( 2.0f, 2.0f, 2.0f );
1543 // flush the queue and render once
1544 application.SendNotification();
1545 application.Render();
1546 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1548 Stage::GetCurrent().Remove( actor );
1553 // SetScale(Vector3 scale)
1554 int UtcDaliActorSetScale03(void)
1556 TestApplication application;
1557 Vector3 scale(10.0f, 10.0f, 10.0f);
1559 Actor actor = Actor::New();
1561 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1562 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1564 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1566 actor.SetScale(scale);
1568 // flush the queue and render once
1569 application.SendNotification();
1570 application.Render();
1572 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1576 int UtcDaliActorSetScaleIndividual(void)
1578 TestApplication application;
1580 Actor actor = Actor::New();
1582 Vector3 vector(0.7f, 0.8f, 0.9f);
1583 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1585 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1587 // flush the queue and render once
1588 application.SendNotification();
1589 application.Render();
1591 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1593 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1595 // flush the queue and render once
1596 application.SendNotification();
1597 application.Render();
1599 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1601 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1603 // flush the queue and render once
1604 application.SendNotification();
1605 application.Render();
1607 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1612 int UtcDaliActorScaleBy(void)
1614 TestApplication application;
1615 Actor actor = Actor::New();
1616 Vector3 vector(100.0f, 100.0f, 100.0f);
1618 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1620 actor.SetScale(vector);
1622 // flush the queue and render once
1623 application.SendNotification();
1624 application.Render();
1626 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1628 actor.ScaleBy(vector);
1630 // flush the queue and render once
1631 application.SendNotification();
1632 application.Render();
1634 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1638 int UtcDaliActorGetCurrentScale(void)
1640 TestApplication application;
1641 Vector3 scale(12.0f, 1.0f, 2.0f);
1643 Actor actor = Actor::New();
1645 actor.SetScale(scale);
1647 // flush the queue and render once
1648 application.SendNotification();
1649 application.Render();
1651 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1655 int UtcDaliActorGetCurrentWorldScale(void)
1657 TestApplication application;
1659 Actor parent = Actor::New();
1660 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1661 parent.SetScale( parentScale );
1662 Stage::GetCurrent().Add( parent );
1664 Actor child = Actor::New();
1665 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1666 child.SetScale( childScale );
1667 parent.Add( child );
1669 // The actors should not have a scale yet
1670 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1671 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1673 // The actors should not have a world scale yet
1674 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1675 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1677 application.SendNotification();
1678 application.Render(0);
1680 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1681 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1683 // The actors should have a world scale now
1684 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1685 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1689 int UtcDaliActorInheritScale(void)
1691 tet_infoline("Testing Actor::SetInheritScale");
1692 TestApplication application;
1694 Actor parent = Actor::New();
1695 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1696 parent.SetScale( parentScale );
1697 Stage::GetCurrent().Add( parent );
1699 Actor child = Actor::New();
1700 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1701 child.SetScale( childScale );
1702 parent.Add( child );
1704 application.SendNotification();
1705 application.Render(0);
1707 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1708 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1710 child.SetInheritScale( false );
1711 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1713 application.SendNotification();
1714 application.Render(0);
1716 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1720 int UtcDaliActorSetVisible(void)
1722 TestApplication application;
1724 Actor actor = Actor::New();
1725 actor.SetVisible(false);
1726 // flush the queue and render once
1727 application.SendNotification();
1728 application.Render();
1729 DALI_TEST_CHECK(actor.IsVisible() == false);
1731 actor.SetVisible(true);
1732 // flush the queue and render once
1733 application.SendNotification();
1734 application.Render();
1735 DALI_TEST_CHECK(actor.IsVisible() == true);
1737 // put actor on stage
1738 Stage::GetCurrent().Add( actor );
1739 actor.SetVisible(false);
1740 // flush the queue and render once
1741 application.SendNotification();
1742 application.Render();
1743 DALI_TEST_CHECK(actor.IsVisible() == false);
1747 int UtcDaliActorIsVisible(void)
1749 TestApplication application;
1751 Actor actor = Actor::New();
1753 DALI_TEST_CHECK(actor.IsVisible() == true);
1757 int UtcDaliActorSetOpacity(void)
1759 TestApplication application;
1761 Actor actor = Actor::New();
1762 // initial opacity is 1
1763 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1765 actor.SetOpacity( 0.4f);
1766 // flush the queue and render once
1767 application.SendNotification();
1768 application.Render();
1769 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1771 // change opacity, actor is on stage to change is not immediate
1772 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1773 // flush the queue and render once
1774 application.SendNotification();
1775 application.Render();
1776 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1778 // put actor on stage
1779 Stage::GetCurrent().Add( actor );
1781 // change opacity, actor is on stage to change is not immediate
1782 actor.SetOpacity( 0.9f );
1783 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1784 // flush the queue and render once
1785 application.SendNotification();
1786 application.Render();
1787 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1789 // change opacity, actor is on stage to change is not immediate
1790 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1791 // flush the queue and render once
1792 application.SendNotification();
1793 application.Render();
1794 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1798 int UtcDaliActorGetCurrentOpacity(void)
1800 TestApplication application;
1802 Actor actor = Actor::New();
1803 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1805 actor.SetOpacity(0.5f);
1806 // flush the queue and render once
1807 application.SendNotification();
1808 application.Render();
1809 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1813 int UtcDaliActorSetSensitive(void)
1815 TestApplication application;
1816 Actor actor = Actor::New();
1818 bool sensitive = !actor.IsSensitive();
1820 actor.SetSensitive(sensitive);
1822 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1826 int UtcDaliActorIsSensitive(void)
1828 TestApplication application;
1829 Actor actor = Actor::New();
1830 actor.SetSensitive(false);
1832 DALI_TEST_CHECK(false == actor.IsSensitive());
1836 int UtcDaliActorSetColor(void)
1838 TestApplication application;
1839 Actor actor = Actor::New();
1840 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1842 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1844 actor.SetColor(color);
1845 // flush the queue and render once
1846 application.SendNotification();
1847 application.Render();
1848 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1850 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1851 // flush the queue and render once
1852 application.SendNotification();
1853 application.Render();
1854 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1856 Stage::GetCurrent().Add( actor );
1857 actor.SetColor( color );
1858 // flush the queue and render once
1859 application.SendNotification();
1860 application.Render();
1861 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1863 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1864 // flush the queue and render once
1865 application.SendNotification();
1866 application.Render();
1867 // Actor color is not clamped
1868 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1869 // world color is clamped
1870 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1872 Stage::GetCurrent().Remove( actor );
1876 int UtcDaliActorSetColorIndividual(void)
1878 TestApplication application;
1880 Actor actor = Actor::New();
1882 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1883 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1885 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1887 // flush the queue and render once
1888 application.SendNotification();
1889 application.Render();
1891 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
1893 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
1895 // flush the queue and render once
1896 application.SendNotification();
1897 application.Render();
1899 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
1901 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
1903 // flush the queue and render once
1904 application.SendNotification();
1905 application.Render();
1907 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
1909 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
1911 // flush the queue and render once
1912 application.SendNotification();
1913 application.Render();
1915 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
1921 int UtcDaliActorGetCurrentColor(void)
1923 TestApplication application;
1924 Actor actor = Actor::New();
1925 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1927 actor.SetColor(color);
1928 // flush the queue and render once
1929 application.SendNotification();
1930 application.Render();
1931 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1935 int UtcDaliActorGetCurrentWorldColor(void)
1937 tet_infoline("Actor::GetCurrentWorldColor");
1938 TestApplication application;
1940 Actor parent = Actor::New();
1941 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1942 parent.SetColor( parentColor );
1943 Stage::GetCurrent().Add( parent );
1945 Actor child = Actor::New();
1946 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1947 child.SetColor( childColor );
1948 parent.Add( child );
1950 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1951 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1953 // verify the default color mode
1954 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1956 // The actors should not have a world color yet
1957 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1958 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1960 application.SendNotification();
1961 application.Render(0);
1963 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1964 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1966 // The actors should have a world color now
1967 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1968 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1971 child.SetColorMode( USE_OWN_COLOR );
1972 application.SendNotification();
1973 application.Render(0);
1974 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1977 child.SetColorMode( USE_PARENT_COLOR );
1978 application.SendNotification();
1979 application.Render(0);
1980 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1981 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1984 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1985 application.SendNotification();
1986 application.Render(0);
1987 Vector4 expectedColor( childColor );
1988 expectedColor.a *= parentColor.a;
1989 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1990 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1994 int UtcDaliActorSetColorMode(void)
1996 tet_infoline("Actor::SetColorMode");
1997 TestApplication application;
1998 Actor actor = Actor::New();
1999 Actor child = Actor::New();
2002 actor.SetColorMode( USE_OWN_COLOR );
2003 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2005 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2006 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2008 actor.SetColorMode( USE_PARENT_COLOR );
2009 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2011 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2012 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2016 int UtcDaliActorScreenToLocal(void)
2018 TestApplication application;
2019 Actor actor = Actor::New();
2020 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2021 actor.SetSize(100.0f, 100.0f);
2022 actor.SetPosition(10.0f, 10.0f);
2023 Stage::GetCurrent().Add(actor);
2025 // flush the queue and render once
2026 application.SendNotification();
2027 application.Render();
2032 application.SendNotification();
2033 application.Render();
2035 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2037 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2038 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2042 int UtcDaliActorSetLeaveRequired(void)
2044 TestApplication application;
2046 Actor actor = Actor::New();
2048 actor.SetLeaveRequired(false);
2049 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2051 actor.SetLeaveRequired(true);
2052 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2056 int UtcDaliActorGetLeaveRequired(void)
2058 TestApplication application;
2060 Actor actor = Actor::New();
2062 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2066 int UtcDaliActorSetKeyboardFocusable(void)
2068 TestApplication application;
2070 Actor actor = Actor::New();
2072 actor.SetKeyboardFocusable(true);
2073 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2075 actor.SetKeyboardFocusable(false);
2076 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2080 int UtcDaliActorIsKeyboardFocusable(void)
2082 TestApplication application;
2084 Actor actor = Actor::New();
2086 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2090 int UtcDaliActorRemoveConstraints(void)
2092 tet_infoline(" UtcDaliActorRemoveConstraints");
2093 TestApplication application;
2095 gTestConstraintCalled = false;
2097 Actor actor = Actor::New();
2099 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2101 actor.RemoveConstraints();
2103 DALI_TEST_CHECK( gTestConstraintCalled == false );
2105 Stage::GetCurrent().Add( actor );
2108 // flush the queue and render once
2109 application.SendNotification();
2110 application.Render();
2112 actor.RemoveConstraints();
2114 DALI_TEST_CHECK( gTestConstraintCalled == true );
2118 int UtcDaliActorRemoveConstraintTag(void)
2120 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2121 TestApplication application;
2123 Actor actor = Actor::New();
2125 // 1. Apply Constraint1 and Constraint2, and test...
2126 unsigned int result1 = 0u;
2127 unsigned int result2 = 0u;
2129 unsigned constraint1Tag = 1u;
2130 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2131 constraint1.SetTag( constraint1Tag );
2132 constraint1.Apply();
2134 unsigned constraint2Tag = 2u;
2135 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2136 constraint2.SetTag( constraint2Tag );
2137 constraint2.Apply();
2139 Stage::GetCurrent().Add( actor );
2140 // flush the queue and render once
2141 application.SendNotification();
2142 application.Render();
2144 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2145 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2147 // 2. Remove Constraint1 and test...
2150 actor.RemoveConstraints(constraint1Tag);
2151 // make color property dirty, which will trigger constraints to be reapplied.
2152 actor.SetColor( Color::WHITE );
2153 // flush the queue and render once
2154 application.SendNotification();
2155 application.Render();
2157 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2158 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2160 // 3. Re-Apply Constraint1 and test...
2163 constraint1.Apply();
2164 // make color property dirty, which will trigger constraints to be reapplied.
2165 actor.SetColor( Color::WHITE );
2166 // flush the queue and render once
2167 application.SendNotification();
2168 application.Render();
2170 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2171 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2173 // 2. Remove Constraint2 and test...
2176 actor.RemoveConstraints(constraint2Tag);
2177 // make color property dirty, which will trigger constraints to be reapplied.
2178 actor.SetColor( Color::WHITE );
2179 // flush the queue and render once
2180 application.SendNotification();
2181 application.Render();
2183 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2184 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2186 // 2. Remove Constraint1 as well and test...
2189 actor.RemoveConstraints(constraint1Tag);
2190 // make color property dirty, which will trigger constraints to be reapplied.
2191 actor.SetColor( Color::WHITE );
2192 // flush the queue and render once
2193 application.SendNotification();
2194 application.Render();
2196 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2197 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2201 int UtcDaliActorTouchedSignal(void)
2203 TestApplication application;
2205 gTouchCallBackCalled = false;
2207 // get the root layer
2208 Actor actor = Stage::GetCurrent().GetRootLayer();
2209 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2211 application.SendNotification();
2212 application.Render();
2214 // connect to its touch signal
2215 actor.TouchedSignal().Connect( TestCallback );
2217 // simulate a touch event in the middle of the screen
2218 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2219 Dali::Integration::Point point;
2220 point.SetDeviceId( 1 );
2221 point.SetState( PointState::DOWN );
2222 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2223 Dali::Integration::TouchEvent event;
2224 event.AddPoint( point );
2225 application.ProcessEvent( event );
2227 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2231 int UtcDaliActorHoveredSignal(void)
2233 TestApplication application;
2235 gHoverCallBackCalled = false;
2237 // get the root layer
2238 Actor actor = Stage::GetCurrent().GetRootLayer();
2239 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2241 application.SendNotification();
2242 application.Render();
2244 // connect to its hover signal
2245 actor.HoveredSignal().Connect( TestCallback3 );
2247 // simulate a hover event in the middle of the screen
2248 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2249 Dali::Integration::Point point;
2250 point.SetDeviceId( 1 );
2251 point.SetState( PointState::MOTION );
2252 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2253 Dali::Integration::HoverEvent event;
2254 event.AddPoint( point );
2255 application.ProcessEvent( event );
2257 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2261 int UtcDaliActorOnOffStageSignal(void)
2263 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2265 TestApplication application;
2268 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2269 gActorNamesOnOffStage.clear();
2271 Actor parent = Actor::New();
2272 parent.SetName( "parent" );
2273 parent.OnStageSignal().Connect( OnStageCallback );
2274 parent.OffStageSignal().Connect( OffStageCallback );
2276 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2277 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2279 // add parent to stage
2280 Stage::GetCurrent().Add( parent );
2281 // onstage emitted, offstage not
2282 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2283 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2284 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2286 // test adding a child, should get onstage emitted
2288 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2289 gActorNamesOnOffStage.clear();
2291 Actor child = Actor::New();
2292 child.SetName( "child" );
2293 child.OnStageSignal().Connect( OnStageCallback );
2294 child.OffStageSignal().Connect( OffStageCallback );
2295 parent.Add( child ); // add child
2296 // onstage emitted, offstage not
2297 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2298 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2299 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2301 // test removing parent from stage
2303 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2304 gActorNamesOnOffStage.clear();
2306 Stage::GetCurrent().Remove( parent );
2307 // onstage not emitted, offstage is
2308 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2309 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2310 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2311 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2313 // test adding parent back to stage
2315 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2316 gActorNamesOnOffStage.clear();
2318 Stage::GetCurrent().Add( parent );
2319 // onstage emitted, offstage not
2320 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2321 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2322 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2323 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2325 // test removing child
2327 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2328 gActorNamesOnOffStage.clear();
2330 parent.Remove( child );
2331 // onstage not emitted, offstage is
2332 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2333 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2334 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2336 // test removing parent
2338 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2339 gActorNamesOnOffStage.clear();
2341 Stage::GetCurrent().Remove( parent );
2342 // onstage not emitted, offstage is
2343 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2344 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2345 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2349 int UtcDaliActorFindChildByName(void)
2351 tet_infoline("Testing Dali::Actor::FindChildByName()");
2352 TestApplication application;
2354 Actor parent = Actor::New();
2355 parent.SetName( "parent" );
2356 Actor first = Actor::New();
2357 first .SetName( "first" );
2358 Actor second = Actor::New();
2359 second.SetName( "second" );
2364 Actor found = parent.FindChildByName( "foo" );
2365 DALI_TEST_CHECK( !found );
2367 found = parent.FindChildByName( "parent" );
2368 DALI_TEST_CHECK( found == parent );
2370 found = parent.FindChildByName( "first" );
2371 DALI_TEST_CHECK( found == first );
2373 found = parent.FindChildByName( "second" );
2374 DALI_TEST_CHECK( found == second );
2378 int UtcDaliActorFindChildById(void)
2380 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2381 TestApplication application;
2383 Actor parent = Actor::New();
2384 Actor first = Actor::New();
2385 Actor second = Actor::New();
2390 Actor found = parent.FindChildById( 100000 );
2391 DALI_TEST_CHECK( !found );
2393 found = parent.FindChildById( parent.GetId() );
2394 DALI_TEST_CHECK( found == parent );
2396 found = parent.FindChildById( first.GetId() );
2397 DALI_TEST_CHECK( found == first );
2399 found = parent.FindChildById( second.GetId() );
2400 DALI_TEST_CHECK( found == second );
2404 int UtcDaliActorHitTest(void)
2409 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2411 mTouchPoint( touchPoint ),
2416 Vector2 mTouchPoint;
2420 TestApplication application;
2421 tet_infoline(" UtcDaliActorHitTest");
2423 // Fill a vector with different hit tests.
2424 struct HitTestData* hitTestData[] = {
2425 // scale touch point result
2426 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2427 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2428 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.
2429 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2430 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.
2434 // get the root layer
2435 Actor actor = Actor::New();
2436 actor.SetAnchorPoint( AnchorPoint::CENTER );
2437 actor.SetParentOrigin( ParentOrigin::CENTER );
2439 Stage::GetCurrent().Add( actor );
2441 gTouchCallBackCalled = false;
2443 unsigned int index = 0;
2444 while( NULL != hitTestData[index] )
2446 actor.SetSize( 1.f, 1.f );
2447 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2449 // flush the queue and render once
2450 application.SendNotification();
2451 application.Render();
2453 DALI_TEST_CHECK( !gTouchCallBackCalled );
2455 // connect to its touch signal
2456 actor.TouchedSignal().Connect(TestCallback);
2458 Dali::Integration::Point point;
2459 point.SetState( PointState::DOWN );
2460 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2461 Dali::Integration::TouchEvent event;
2462 event.AddPoint( point );
2464 // flush the queue and render once
2465 application.SendNotification();
2466 application.Render();
2467 application.ProcessEvent( event );
2469 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2471 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2472 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2473 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2474 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2475 hitTestData[index]->mResult );
2477 gTouchCallBackCalled = false;
2483 int UtcDaliActorSetDrawMode(void)
2485 TestApplication app;
2486 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2488 Actor a = Actor::New();
2490 Stage::GetCurrent().Add(a);
2491 app.SendNotification();
2493 app.SendNotification();
2496 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2498 a.SetDrawMode( DrawMode::OVERLAY_2D );
2499 app.SendNotification();
2502 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2504 a.SetDrawMode( DrawMode::NORMAL );
2505 app.SendNotification();
2508 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2512 int UtcDaliActorSetDrawModeOverlayRender(void)
2514 TestApplication app;
2515 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2517 app.SendNotification();
2520 std::vector<GLuint> ids;
2521 ids.push_back( 8 ); // first rendered actor
2522 ids.push_back( 9 ); // second rendered actor
2523 ids.push_back( 10 ); // third rendered actor
2524 app.GetGlAbstraction().SetNextTextureIds( ids );
2526 BufferImage imageA = BufferImage::New(16, 16);
2527 BufferImage imageB = BufferImage::New(16, 16);
2528 BufferImage imageC = BufferImage::New(16, 16);
2529 Actor a = CreateRenderableActor( imageA );
2530 Actor b = CreateRenderableActor( imageB );
2531 Actor c = CreateRenderableActor( imageC );
2533 // Render a,b,c as regular non-overlays. so order will be:
2537 Stage::GetCurrent().Add(a);
2538 Stage::GetCurrent().Add(b);
2539 Stage::GetCurrent().Add(c);
2541 app.SendNotification();
2544 // Should be 3 textures changes.
2545 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2546 typedef std::vector<GLuint>::size_type TextureSize;
2547 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2548 if( boundTextures.size() == 3 )
2550 DALI_TEST_CHECK( boundTextures[0] == 8u );
2551 DALI_TEST_CHECK( boundTextures[1] == 9u );
2552 DALI_TEST_CHECK( boundTextures[2] == 10u );
2555 // Now texture ids have been set, we can monitor their render order.
2556 // render a as an overlay (last), so order will be:
2560 a.SetDrawMode( DrawMode::OVERLAY_2D );
2561 app.GetGlAbstraction().ClearBoundTextures();
2563 app.SendNotification();
2566 // Should be 3 texture changes.
2567 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2568 if( boundTextures.size() == 3 )
2570 DALI_TEST_CHECK( boundTextures[0] == 9u );
2571 DALI_TEST_CHECK( boundTextures[1] == 10u );
2572 DALI_TEST_CHECK( boundTextures[2] == 8u );
2577 int UtcDaliActorGetCurrentWorldMatrix(void)
2579 TestApplication app;
2580 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2582 Actor parent = Actor::New();
2583 parent.SetParentOrigin(ParentOrigin::CENTER);
2584 parent.SetAnchorPoint(AnchorPoint::CENTER);
2585 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2586 Radian rotationAngle(Degree(85.0f));
2587 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2588 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2589 parent.SetPosition( parentPosition );
2590 parent.SetOrientation( parentRotation );
2591 parent.SetScale( parentScale );
2592 Stage::GetCurrent().Add( parent );
2594 Actor child = Actor::New();
2595 child.SetParentOrigin(ParentOrigin::CENTER);
2596 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2597 Radian childRotationAngle(Degree(23.0f));
2598 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2599 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2600 child.SetPosition( childPosition );
2601 child.SetOrientation( childRotation );
2602 child.SetScale( childScale );
2603 parent.Add( child );
2605 app.SendNotification();
2608 app.SendNotification();
2610 Matrix parentMatrix(false);
2611 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2613 Matrix childMatrix(false);
2614 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2616 //Child matrix should be the composition of child and parent
2617 Matrix childWorldMatrix(false);
2618 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2620 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2621 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2627 int UtcDaliActorConstrainedToWorldMatrix(void)
2629 TestApplication app;
2630 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2632 Actor parent = Actor::New();
2633 parent.SetParentOrigin(ParentOrigin::CENTER);
2634 parent.SetAnchorPoint(AnchorPoint::CENTER);
2635 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2636 Radian rotationAngle(Degree(85.0f));
2637 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2638 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2639 parent.SetPosition( parentPosition );
2640 parent.SetOrientation( parentRotation );
2641 parent.SetScale( parentScale );
2642 Stage::GetCurrent().Add( parent );
2644 Actor child = Actor::New();
2645 child.SetParentOrigin(ParentOrigin::CENTER);
2646 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2647 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2648 posConstraint.Apply();
2650 Stage::GetCurrent().Add( child );
2652 app.SendNotification();
2655 app.SendNotification();
2657 Matrix parentMatrix(false);
2658 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2660 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2661 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2665 int UtcDaliActorConstrainedToOrientation(void)
2667 TestApplication app;
2668 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2670 Actor parent = Actor::New();
2671 parent.SetParentOrigin(ParentOrigin::CENTER);
2672 parent.SetAnchorPoint(AnchorPoint::CENTER);
2673 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2674 Radian rotationAngle(Degree(85.0f));
2675 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2676 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2677 parent.SetPosition( parentPosition );
2678 parent.SetOrientation( parentRotation );
2679 parent.SetScale( parentScale );
2680 Stage::GetCurrent().Add( parent );
2682 Actor child = Actor::New();
2683 child.SetParentOrigin(ParentOrigin::CENTER);
2684 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2685 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2686 posConstraint.Apply();
2688 Stage::GetCurrent().Add( child );
2690 app.SendNotification();
2693 app.SendNotification();
2695 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2699 int UtcDaliActorUnparent(void)
2701 TestApplication app;
2702 tet_infoline(" UtcDaliActorUnparent");
2704 Actor parent = Actor::New();
2705 Stage::GetCurrent().Add( parent );
2707 Actor child = Actor::New();
2709 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2710 DALI_TEST_CHECK( !child.GetParent() );
2712 // Test that calling Unparent with no parent is a NOOP
2715 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2716 DALI_TEST_CHECK( !child.GetParent() );
2718 // Test that Unparent works
2719 parent.Add( child );
2721 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2722 DALI_TEST_CHECK( parent == child.GetParent() );
2726 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2727 DALI_TEST_CHECK( !child.GetParent() );
2729 // Test that UnparentAndReset works
2730 parent.Add( child );
2732 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2733 DALI_TEST_CHECK( parent == child.GetParent() );
2735 UnparentAndReset( child );
2737 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2738 DALI_TEST_CHECK( !child );
2740 // Test that UnparentAndReset is a NOOP with empty handle
2741 UnparentAndReset( child );
2743 DALI_TEST_CHECK( !child );
2747 int UtcDaliActorGetChildAt(void)
2749 TestApplication app;
2750 tet_infoline(" UtcDaliActorGetChildAt");
2752 Actor parent = Actor::New();
2753 Stage::GetCurrent().Add( parent );
2755 Actor child0 = Actor::New();
2756 parent.Add( child0 );
2758 Actor child1 = Actor::New();
2759 parent.Add( child1 );
2761 Actor child2 = Actor::New();
2762 parent.Add( child2 );
2764 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2765 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2766 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2770 int UtcDaliActorSetGetOverlay(void)
2772 TestApplication app;
2773 tet_infoline(" UtcDaliActorSetGetOverlay");
2775 Actor parent = Actor::New();
2776 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2777 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2782 int UtcDaliActorCreateDestroy(void)
2784 Actor* actor = new Actor;
2785 DALI_TEST_CHECK( actor );
2792 struct PropertyStringIndex
2794 const char * const name;
2795 const Property::Index index;
2796 const Property::Type type;
2799 const PropertyStringIndex PROPERTY_TABLE[] =
2801 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2802 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2803 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2804 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2805 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2806 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2807 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2808 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2809 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2810 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2811 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2812 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2813 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2814 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2815 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2816 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2817 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2818 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2819 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2820 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2821 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2822 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2823 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2824 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2825 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2826 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2827 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2828 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2829 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2830 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2831 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2832 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2833 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2834 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2835 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2836 { "name", Actor::Property::NAME, Property::STRING },
2837 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2838 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2839 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2840 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2841 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2842 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2843 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
2844 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2845 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2846 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2847 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2848 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2849 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2850 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2851 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2852 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2853 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
2854 { "batchParent", DevelActor::Property::BATCH_PARENT, Property::BOOLEAN },
2855 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
2857 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2858 } // unnamed namespace
2860 int UtcDaliActorProperties(void)
2862 TestApplication app;
2864 Actor actor = Actor::New();
2866 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2868 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2869 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2870 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2871 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2876 int UtcDaliRelayoutProperties_ResizePolicies(void)
2878 TestApplication app;
2880 Actor actor = Actor::New();
2883 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2884 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2886 // Set resize policy for all dimensions
2887 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2888 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2890 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2893 // Set individual dimensions
2894 const char* const widthPolicy = "FILL_TO_PARENT";
2895 const char* const heightPolicy = "FIXED";
2897 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2898 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2900 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2901 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2906 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2908 TestApplication app;
2910 Actor actor = Actor::New();
2913 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2914 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2916 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2917 actor.SetSizeScalePolicy( policy );
2918 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2921 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2922 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2924 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2925 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2927 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2928 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2933 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2935 TestApplication app;
2937 Actor actor = Actor::New();
2940 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2941 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2943 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2944 actor.SetSizeModeFactor( sizeMode );
2945 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2948 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2950 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2951 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2956 int UtcDaliRelayoutProperties_DimensionDependency(void)
2958 TestApplication app;
2960 Actor actor = Actor::New();
2963 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2964 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2967 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2968 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2970 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2971 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2973 // Test setting another resize policy
2974 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2975 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2980 int UtcDaliRelayoutProperties_Padding(void)
2982 TestApplication app;
2984 Actor actor = Actor::New();
2987 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2990 actor.SetProperty( Actor::Property::PADDING, padding );
2991 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2993 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2998 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3000 TestApplication app;
3002 Actor actor = Actor::New();
3005 Vector2 minSize( 1.0f, 2.0f );
3007 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3008 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3010 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3012 Vector2 maxSize( 3.0f, 4.0f );
3014 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3015 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3017 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3022 int UtcDaliActorGetHeightForWidth(void)
3024 TestApplication app;
3026 Actor actor = Actor::New();
3028 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3033 int UtcDaliActorGetWidthForHeight(void)
3035 TestApplication app;
3037 Actor actor = Actor::New();
3039 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3044 int UtcDaliActorGetRelayoutSize(void)
3046 TestApplication app;
3048 Actor actor = Actor::New();
3050 // Add actor to stage
3051 Stage::GetCurrent().Add( actor );
3053 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3055 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3056 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3058 // Flush the queue and render once
3059 app.SendNotification();
3062 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3067 int UtcDaliActorSetPadding(void)
3069 TestApplication app;
3071 Actor actor = Actor::New();
3074 actor.GetPadding( padding );
3076 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3077 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3078 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3079 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3081 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3082 actor.SetPadding( padding2 );
3084 actor.GetPadding( padding );
3086 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3087 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3088 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3089 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3094 int UtcDaliActorSetMinimumSize(void)
3096 TestApplication app;
3098 Actor actor = Actor::New();
3100 Vector2 size = actor.GetMinimumSize();
3102 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3103 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3105 Vector2 size2( 1.0f, 2.0f );
3106 actor.SetMinimumSize( size2 );
3108 size = actor.GetMinimumSize();
3110 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3111 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3116 int UtcDaliActorSetMaximumSize(void)
3118 TestApplication app;
3120 Actor actor = Actor::New();
3122 Vector2 size = actor.GetMaximumSize();
3124 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3125 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3127 Vector2 size2( 1.0f, 2.0f );
3128 actor.SetMaximumSize( size2 );
3130 size = actor.GetMaximumSize();
3132 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3133 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3138 int UtcDaliActorOnRelayoutSignal(void)
3140 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3142 TestApplication application;
3145 gOnRelayoutCallBackCalled = false;
3146 gActorNamesRelayout.clear();
3148 Actor actor = Actor::New();
3149 actor.SetName( "actor" );
3150 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3153 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3155 // Add actor to stage
3156 Stage::GetCurrent().Add( actor );
3158 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3159 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3161 // Flush the queue and render once
3162 application.SendNotification();
3163 application.Render();
3165 // OnRelayout emitted
3166 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3167 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3172 int UtcDaliActorGetHierachyDepth(void)
3174 TestApplication application;
3175 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3178 /* Build tree of actors:
3188 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3190 Stage stage( Stage::GetCurrent() );
3192 Actor actorA = Actor::New();
3193 Actor actorB = Actor::New();
3194 Actor actorC = Actor::New();
3195 Actor actorD = Actor::New();
3196 Actor actorE = Actor::New();
3197 Actor actorF = Actor::New();
3199 //Test that root actor has depth equal 0
3200 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3202 //Test actors return depth -1 when not connected to the tree
3203 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3204 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3205 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3206 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3207 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3208 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3210 //Create the hierarchy
3211 stage.Add( actorA );
3212 actorA.Add( actorB );
3213 actorA.Add( actorC );
3214 actorB.Add( actorD );
3215 actorB.Add( actorE );
3216 actorC.Add( actorF );
3218 //Test actors return correct depth
3219 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3220 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3221 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3222 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3223 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3224 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3226 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3227 actorA.Remove( actorB );
3229 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3230 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3231 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3233 //Removing actorA from the stage. All actors should have depth equal -1
3234 stage.Remove( actorA );
3236 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3237 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3238 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3239 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3240 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3241 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3246 int UtcDaliActorAnchorPointPropertyAsString(void)
3248 TestApplication application;
3250 Actor actor = Actor::New();
3252 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3253 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3255 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3256 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3258 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3259 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3261 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3262 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3264 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3265 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3267 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3268 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3270 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3271 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3273 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3274 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3276 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3277 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3279 // Invalid should not change anything
3280 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3281 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3286 int UtcDaliActorParentOriginPropertyAsString(void)
3288 TestApplication application;
3290 Actor actor = Actor::New();
3292 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3293 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3295 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3296 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3298 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3299 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3301 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3302 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3304 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3305 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3307 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3308 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3310 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3311 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3313 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3314 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3316 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3317 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3319 // Invalid should not change anything
3320 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3321 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3326 int UtcDaliActorColorModePropertyAsString(void)
3328 TestApplication application;
3330 Actor actor = Actor::New();
3332 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3333 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3335 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3336 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3338 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3339 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3341 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3342 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3344 // Invalid should not change anything
3345 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3346 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3351 int UtcDaliActorPositionInheritancePropertyAsString(void)
3353 TestApplication application;
3355 Actor actor = Actor::New();
3357 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3358 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3360 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3361 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3363 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3364 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3366 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3367 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3369 // Invalid should not change anything
3370 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3371 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3376 int UtcDaliActorDrawModePropertyAsString(void)
3378 TestApplication application;
3380 Actor actor = Actor::New();
3382 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3383 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3385 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3386 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3388 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3389 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3391 // Invalid should not change anything
3392 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3393 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3398 int UtcDaliActorAddRendererP(void)
3400 tet_infoline("Testing Actor::AddRenderer");
3401 TestApplication application;
3403 Actor actor = Actor::New();
3405 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3407 Geometry geometry = CreateQuadGeometry();
3408 Shader shader = CreateShader();
3409 Renderer renderer = Renderer::New(geometry, shader);
3411 actor.AddRenderer( renderer );
3412 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3413 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3418 int UtcDaliActorAddRendererN(void)
3420 tet_infoline("Testing Actor::AddRenderer");
3421 TestApplication application;
3423 Actor actor = Actor::New();
3429 actor.AddRenderer( renderer );
3430 tet_printf("Assertion test failed - no Exception\n" );
3431 tet_result(TET_FAIL);
3433 catch(Dali::DaliException& e)
3435 DALI_TEST_PRINT_ASSERT( e );
3436 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3437 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3441 tet_printf("Assertion test failed - wrong Exception\n" );
3442 tet_result(TET_FAIL);
3448 int UtcDaliActorAddRendererOnStage(void)
3450 tet_infoline("Testing Actor::AddRenderer");
3451 TestApplication application;
3453 Actor actor = Actor::New();
3454 Stage::GetCurrent().Add(actor);
3456 application.SendNotification();
3457 application.Render(0);
3459 Geometry geometry = CreateQuadGeometry();
3460 Shader shader = CreateShader();
3461 Renderer renderer = Renderer::New(geometry, shader);
3463 application.SendNotification();
3464 application.Render(0);
3468 actor.AddRenderer( renderer );
3469 tet_result(TET_PASS);
3473 tet_result(TET_FAIL);
3479 int UtcDaliActorRemoveRendererP1(void)
3481 tet_infoline("Testing Actor::RemoveRenderer");
3482 TestApplication application;
3484 Actor actor = Actor::New();
3486 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3488 Geometry geometry = CreateQuadGeometry();
3489 Shader shader = CreateShader();
3490 Renderer renderer = Renderer::New(geometry, shader);
3492 actor.AddRenderer( renderer );
3493 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3494 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3496 actor.RemoveRenderer(renderer);
3497 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3503 int UtcDaliActorRemoveRendererP2(void)
3505 tet_infoline("Testing Actor::RemoveRenderer");
3506 TestApplication application;
3508 Actor actor = Actor::New();
3510 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3512 Geometry geometry = CreateQuadGeometry();
3513 Shader shader = CreateShader();
3514 Renderer renderer = Renderer::New(geometry, shader);
3516 actor.AddRenderer( renderer );
3517 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3518 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3520 actor.RemoveRenderer(0);
3521 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3528 int UtcDaliActorRemoveRendererN(void)
3530 tet_infoline("Testing Actor::RemoveRenderer");
3531 TestApplication application;
3533 Actor actor = Actor::New();
3535 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3537 Geometry geometry = CreateQuadGeometry();
3538 Shader shader = CreateShader();
3539 Renderer renderer = Renderer::New(geometry, shader);
3541 actor.AddRenderer( renderer );
3542 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3543 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3545 actor.RemoveRenderer(10);
3546 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3547 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3552 // Clipping test helper functions:
3553 Actor CreateActorWithContent()
3555 BufferImage image = BufferImage::New( 16u, 16u );
3556 Actor actor = CreateRenderableActor( image );
3558 // Setup dimensions and position so actor is not skipped by culling.
3559 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3560 actor.SetSize( 16.0f, 16.0f );
3561 actor.SetParentOrigin( ParentOrigin::CENTER );
3562 actor.SetAnchorPoint( AnchorPoint::CENTER );
3567 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3569 enabledDisableTrace.Reset();
3570 stencilTrace.Reset();
3571 enabledDisableTrace.Enable( true );
3572 stencilTrace.Enable( true );
3574 application.SendNotification();
3575 application.Render();
3577 enabledDisableTrace.Enable( false );
3578 stencilTrace.Enable( false );
3581 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3583 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3585 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3586 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3587 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3588 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3591 int UtcDaliActorPropertyClippingP(void)
3593 // This test checks the clippingMode property.
3594 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3595 TestApplication application;
3597 Actor actor = Actor::New();
3599 // Check default clippingEnabled value.
3600 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3603 bool getValueResult = getValue.Get( value );
3604 DALI_TEST_CHECK( getValueResult );
3606 if( getValueResult )
3608 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3611 // Check setting the property.
3612 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3614 // Check the new value was set.
3615 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3616 getValueResult = getValue.Get( value );
3617 DALI_TEST_CHECK( getValueResult );
3619 if( getValueResult )
3621 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3627 int UtcDaliActorPropertyClippingN(void)
3629 // Negative test case for Clipping.
3630 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3631 TestApplication application;
3633 Actor actor = Actor::New();
3635 // Check default clippingEnabled value.
3636 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3639 bool getValueResult = getValue.Get( value );
3640 DALI_TEST_CHECK( getValueResult );
3642 if( getValueResult )
3644 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3647 // Check setting an invalid property value won't change the current property value.
3648 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3650 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3651 getValueResult = getValue.Get( value );
3652 DALI_TEST_CHECK( getValueResult );
3654 if( getValueResult )
3656 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3662 int UtcDaliActorPropertyClippingActor(void)
3664 // This test checks that an actor is correctly setup for clipping.
3665 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3666 TestApplication application;
3668 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3669 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3670 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3671 size_t startIndex = 0u;
3673 // Create a clipping actor.
3674 Actor actorDepth1Clip = CreateActorWithContent();
3675 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3676 Stage::GetCurrent().Add( actorDepth1Clip );
3678 // Gather the call trace.
3679 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3681 // Check we are writing to the color buffer.
3682 CheckColorMask( glAbstraction, true );
3684 // Check the stencil buffer was enabled.
3685 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3687 // Check the stencil buffer was cleared.
3688 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3690 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3691 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3692 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3693 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3698 int UtcDaliActorPropertyClippingNestedChildren(void)
3700 // This test checks that a hierarchy of actors are clipped correctly by
3701 // writing to and reading from the correct bit-planes of the stencil buffer.
3702 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3703 TestApplication application;
3704 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3705 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3706 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3708 // Create a clipping actor.
3709 Actor actorDepth1Clip = CreateActorWithContent();
3710 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3711 Stage::GetCurrent().Add( actorDepth1Clip );
3713 // Create a child actor.
3714 Actor childDepth2 = CreateActorWithContent();
3715 actorDepth1Clip.Add( childDepth2 );
3717 // Create another clipping actor.
3718 Actor childDepth2Clip = CreateActorWithContent();
3719 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3720 childDepth2.Add( childDepth2Clip );
3722 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
3723 // This tests the sort algorithm.
3724 Actor childDepth3 = CreateActorWithContent();
3725 childDepth2Clip.Add( childDepth3 );
3726 Actor childDepth4 = CreateActorWithContent();
3727 childDepth3.Add( childDepth4 );
3729 // Gather the call trace.
3730 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3732 // Check we are writing to the color buffer.
3733 CheckColorMask( glAbstraction, true );
3735 // Check the stencil buffer was enabled.
3736 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3738 // Perform the test twice, once for 2D layer, and once for 3D.
3739 for( unsigned int i = 0u ; i < 2u; ++i )
3741 size_t startIndex = 0u;
3743 // Check the stencil buffer was cleared.
3744 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3746 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3747 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3748 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
3749 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3751 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
3752 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
3753 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3755 // Check we are set up to write to the second bitplane of the stencil buffer (only).
3756 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3757 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
3758 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3760 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
3761 // (Both must be set to pass the check).
3762 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3763 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3765 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
3768 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
3769 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3776 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
3778 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
3779 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
3780 TestApplication application;
3782 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3783 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3784 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3786 // Create a clipping actor.
3787 Actor actorDepth1Clip = CreateActorWithContent();
3788 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3789 Stage::GetCurrent().Add( actorDepth1Clip );
3791 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
3792 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
3794 // Gather the call trace.
3795 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3797 // Check we are writing to the color buffer.
3798 CheckColorMask( glAbstraction, true );
3800 // Check the stencil buffer was not enabled.
3801 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3803 // Check stencil functions are not called.
3804 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
3805 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
3806 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );