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/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/hover-event-integ.h>
24 #include <dali-test-suite-utils.h>
32 void utc_dali_actor_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_actor_cleanup(void)
39 test_return_value = TET_PASS;
44 bool gTouchCallBackCalled=false;
45 bool gHoverCallBackCalled=false;
48 * Simulates a Down Touch at 25.0, 25.0.
49 * @param[in] app Test Application instance.
51 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
53 app.SendNotification();
55 app.SendNotification();
58 gTouchCallBackCalled = false;
60 // simulate a touch event
61 Dali::Integration::Point point;
62 point.SetState( PointState::DOWN );
63 point.SetScreenPosition( Vector2( 25.0f, 25.0f ) );
64 Dali::Integration::TouchEvent event;
65 event.AddPoint( point );
66 app.ProcessEvent( event );
68 app.SendNotification();
70 app.SendNotification();
76 static bool gTestConstraintCalled;
80 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
82 gTestConstraintCalled = true;
87 * TestConstraint reference.
88 * When constraint is called, the resultRef is updated
89 * with the value supplied.
92 struct TestConstraintRef
94 TestConstraintRef(unsigned int& resultRef, unsigned int value)
95 : mResultRef(resultRef),
100 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
105 unsigned int& mResultRef;
109 static bool TestCallback(Actor actor, const TouchEvent& event)
111 gTouchCallBackCalled = true;
116 static bool TestCallback3(Actor actor, const HoverEvent& event)
118 gHoverCallBackCalled = true;
123 static Vector3 gSetSize;
124 static bool gSetSizeCallBackCalled;
125 void SetSizeCallback( Actor actor, const Vector3& size )
127 gSetSizeCallBackCalled = true;
130 // validation stuff for onstage & offstage signals
131 static std::vector< std::string > gActorNamesOnOffStage;
132 static int gOnStageCallBackCalled;
133 void OnStageCallback( Actor actor )
135 ++gOnStageCallBackCalled;
136 gActorNamesOnOffStage.push_back( actor.GetName() );
137 DALI_TEST_CHECK( actor.OnStage() == true );
139 static int gOffStageCallBackCalled;
140 void OffStageCallback( Actor actor )
142 ++gOffStageCallBackCalled;
143 gActorNamesOnOffStage.push_back( actor.GetName() );
144 DALI_TEST_CHECK( actor.OnStage() == false );
147 struct PositionComponentConstraint
149 PositionComponentConstraint(){}
151 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
153 const Matrix& m = inputs[0]->GetMatrix();
156 m.GetTransformComponents(pos, rot, scale);
160 struct OrientationComponentConstraint
162 OrientationComponentConstraint(){}
164 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
166 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
169 orientation = parentOrientation;
174 static bool gOnRelayoutCallBackCalled = false;
175 static std::vector< std::string > gActorNamesRelayout;
177 void OnRelayoutCallback( Actor actor )
179 gOnRelayoutCallBackCalled = true;
180 gActorNamesRelayout.push_back( actor.GetName() );
183 } // anonymous namespace
186 //& purpose: Testing New API
187 int UtcDaliActorNew(void)
189 TestApplication application;
191 Actor actor = Actor::New();
193 DALI_TEST_CHECK(actor);
197 //& purpose: Testing Dali::Actor::DownCast()
198 int UtcDaliActorDownCastP(void)
200 TestApplication application;
201 tet_infoline("Testing Dali::Actor::DownCast()");
203 Actor actor = Actor::New();
204 BaseHandle object(actor);
205 Actor actor2 = Actor::DownCast(object);
206 DALI_TEST_CHECK(actor2);
210 //& purpose: Testing Dali::Actor::DownCast()
211 int UtcDaliActorDownCastN(void)
213 TestApplication application;
214 tet_infoline("Testing Dali::Actor::DownCast()");
216 BaseHandle unInitializedObject;
217 Actor actor = Actor::DownCast(unInitializedObject);
218 DALI_TEST_CHECK(!actor);
222 //& purpose: Testing Dali::Actor::GetName()
223 int UtcDaliActorGetName(void)
225 TestApplication application;
227 Actor actor = Actor::New();
229 DALI_TEST_CHECK(actor.GetName().empty());
233 //& purpose: Testing Dali::Actor::SetName()
234 int UtcDaliActorSetName(void)
236 TestApplication application;
238 string str("ActorName");
239 Actor actor = Actor::New();
242 DALI_TEST_CHECK(actor.GetName() == str);
246 int UtcDaliActorGetId(void)
248 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
249 TestApplication application;
251 Actor first = Actor::New();
252 Actor second = Actor::New();
253 Actor third = Actor::New();
255 DALI_TEST_CHECK(first.GetId() != second.GetId());
256 DALI_TEST_CHECK(second.GetId() != third.GetId());
260 int UtcDaliActorIsRoot(void)
262 TestApplication application;
264 Actor actor = Actor::New();
265 DALI_TEST_CHECK(!actor.IsRoot());
267 // get the root layer
268 actor = Stage::GetCurrent().GetLayer( 0 );
269 DALI_TEST_CHECK( actor.IsRoot() );
273 int UtcDaliActorOnStage(void)
275 TestApplication application;
277 Actor actor = Actor::New();
278 DALI_TEST_CHECK( !actor.OnStage() );
280 // get the root layer
281 actor = Stage::GetCurrent().GetLayer( 0 );
282 DALI_TEST_CHECK( actor.OnStage() );
286 int UtcDaliActorIsLayer(void)
288 TestApplication application;
290 Actor actor = Actor::New();
291 DALI_TEST_CHECK( !actor.IsLayer() );
293 // get the root layer
294 actor = Stage::GetCurrent().GetLayer( 0 );
295 DALI_TEST_CHECK( actor.IsLayer() );
299 int UtcDaliActorGetLayer(void)
301 TestApplication application;
303 Actor actor = Actor::New();
304 Stage::GetCurrent().Add(actor);
305 Layer layer = actor.GetLayer();
307 DALI_TEST_CHECK(layer);
309 // get the root layers layer
310 actor = Stage::GetCurrent().GetLayer( 0 );
311 DALI_TEST_CHECK( actor.GetLayer() );
315 int UtcDaliActorAddP(void)
317 tet_infoline("Testing Actor::Add");
318 TestApplication application;
320 Actor parent = Actor::New();
321 Actor child = Actor::New();
323 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
327 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
329 Actor parent2 = Actor::New();
330 parent2.Add( child );
332 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
333 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
335 // try Adding to same parent again, works
336 parent2.Add( child );
337 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
339 // try reparenting an orphaned child
341 Actor temporaryParent = Actor::New();
342 temporaryParent.Add( child );
343 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
345 // temporaryParent has now died, reparent the orphaned child
346 parent2.Add( child );
347 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
352 int UtcDaliActorAddN(void)
354 tet_infoline("Testing Actor::Add");
355 TestApplication application;
357 Actor child = Actor::New();
359 Actor parent2 = Actor::New();
360 parent2.Add( child );
365 parent2.Add( parent2 );
366 tet_printf("Assertion test failed - no Exception\n" );
367 tet_result(TET_FAIL);
369 catch(Dali::DaliException& e)
371 DALI_TEST_PRINT_ASSERT( e );
372 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
373 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
377 tet_printf("Assertion test failed - wrong Exception\n" );
378 tet_result(TET_FAIL);
381 // try reparenting root
384 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
385 tet_printf("Assertion test failed - no Exception\n" );
386 tet_result(TET_FAIL);
388 catch(Dali::DaliException& e)
390 DALI_TEST_PRINT_ASSERT( e );
391 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
392 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
396 tet_printf("Assertion test failed - wrong Exception\n" );
397 tet_result(TET_FAIL);
404 parent2.Add( empty );
405 tet_printf("Assertion test failed - no Exception\n" );
406 tet_result(TET_FAIL);
408 catch(Dali::DaliException& e)
410 DALI_TEST_PRINT_ASSERT( e );
411 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
412 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
416 tet_printf("Assertion test failed - wrong Exception\n" );
417 tet_result(TET_FAIL);
423 int UtcDaliActorRemoveN(void)
425 tet_infoline("Testing Actor::Remove");
426 TestApplication application;
428 Actor parent = Actor::New();
429 Actor child = Actor::New();
430 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
433 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
435 parent.Remove(child);
436 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
438 // remove again, no problem
439 parent.Remove(child);
440 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
444 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
445 // try Remove self, its a no-op
446 parent.Remove( parent );
447 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
453 parent.Remove( empty );
454 tet_printf("Assertion test failed - no Exception\n" );
455 tet_result(TET_FAIL);
457 catch(Dali::DaliException& e)
459 DALI_TEST_PRINT_ASSERT( e );
460 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
461 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
465 tet_printf("Assertion test failed - wrong Exception\n" );
466 tet_result(TET_FAIL);
471 int UtcDaliActorRemoveP(void)
473 TestApplication application;
475 Actor parent = Actor::New();
476 Actor child = Actor::New();
477 Actor random = Actor::New();
479 Stage::GetCurrent().Add( parent );
481 DALI_TEST_CHECK(parent.GetChildCount() == 0);
485 DALI_TEST_CHECK(parent.GetChildCount() == 1);
487 parent.Remove(random);
489 DALI_TEST_CHECK(parent.GetChildCount() == 1);
491 Stage::GetCurrent().Remove( parent );
493 DALI_TEST_CHECK(parent.GetChildCount() == 1);
497 int UtcDaliActorGetChildCount(void)
499 TestApplication application;
501 Actor parent = Actor::New();
502 Actor child = Actor::New();
504 DALI_TEST_CHECK(parent.GetChildCount() == 0);
508 DALI_TEST_CHECK(parent.GetChildCount() == 1);
512 int UtcDaliActorGetChildren01(void)
514 TestApplication application;
516 Actor parent = Actor::New();
517 Actor first = Actor::New();
518 Actor second = Actor::New();
519 Actor third = Actor::New();
525 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
526 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
527 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
531 int UtcDaliActorGetChildren02(void)
533 TestApplication application;
535 Actor parent = Actor::New();
536 Actor first = Actor::New();
537 Actor second = Actor::New();
538 Actor third = Actor::New();
544 const Actor& constParent = parent;
546 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
547 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
548 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
552 int UtcDaliActorGetParent01(void)
554 TestApplication application;
556 Actor parent = Actor::New();
557 Actor child = Actor::New();
561 DALI_TEST_CHECK(child.GetParent() == parent);
565 int UtcDaliActorGetParent02(void)
567 TestApplication application;
569 Actor actor = Actor::New();
571 DALI_TEST_CHECK(!actor.GetParent());
575 int UtcDaliActorSetParentOrigin(void)
577 TestApplication application;
579 Actor actor = Actor::New();
581 Vector3 vector(0.7f, 0.8f, 0.9f);
582 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
584 actor.SetParentOrigin(vector);
586 // flush the queue and render once
587 application.SendNotification();
588 application.Render();
590 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
592 Stage::GetCurrent().Add( actor );
594 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
596 // flush the queue and render once
597 application.SendNotification();
598 application.Render();
600 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
602 Stage::GetCurrent().Remove( actor );
606 int UtcDaliActorSetParentOriginIndividual(void)
608 TestApplication application;
610 Actor actor = Actor::New();
612 Vector3 vector(0.7f, 0.8f, 0.9f);
613 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
615 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
617 // flush the queue and render once
618 application.SendNotification();
619 application.Render();
621 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
623 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
625 // flush the queue and render once
626 application.SendNotification();
627 application.Render();
629 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
631 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
633 // flush the queue and render once
634 application.SendNotification();
635 application.Render();
637 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
642 int UtcDaliActorGetCurrentParentOrigin(void)
644 TestApplication application;
646 Actor actor = Actor::New();
648 Vector3 vector(0.7f, 0.8f, 0.9f);
649 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
651 actor.SetParentOrigin(vector);
653 // flush the queue and render once
654 application.SendNotification();
655 application.Render();
657 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
661 int UtcDaliActorSetAnchorPoint(void)
663 TestApplication application;
665 Actor actor = Actor::New();
667 Vector3 vector(0.7f, 0.8f, 0.9f);
668 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
670 actor.SetAnchorPoint(vector);
672 // flush the queue and render once
673 application.SendNotification();
674 application.Render();
676 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
678 Stage::GetCurrent().Add( actor );
680 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
681 // flush the queue and render once
682 application.SendNotification();
683 application.Render();
685 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
687 Stage::GetCurrent().Remove( actor );
691 int UtcDaliActorSetAnchorPointIndividual(void)
693 TestApplication application;
695 Actor actor = Actor::New();
697 Vector3 vector(0.7f, 0.8f, 0.9f);
698 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
700 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
702 // flush the queue and render once
703 application.SendNotification();
704 application.Render();
706 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
708 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
710 // flush the queue and render once
711 application.SendNotification();
712 application.Render();
714 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
716 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
718 // flush the queue and render once
719 application.SendNotification();
720 application.Render();
722 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
727 int UtcDaliActorGetCurrentAnchorPoint(void)
729 TestApplication application;
731 Actor actor = Actor::New();
733 Vector3 vector(0.7f, 0.8f, 0.9f);
734 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
736 actor.SetAnchorPoint(vector);
738 // flush the queue and render once
739 application.SendNotification();
740 application.Render();
742 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
746 // SetSize(float width, float height)
747 int UtcDaliActorSetSize01(void)
749 TestApplication application;
751 Actor actor = Actor::New();
752 Vector3 vector(100.0f, 100.0f, 0.0f);
754 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
756 actor.SetSize(vector.x, vector.y);
758 // flush the queue and render once
759 application.SendNotification();
760 application.Render();
762 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
766 // SetSize(float width, float height, float depth)
767 int UtcDaliActorSetSize02(void)
769 TestApplication application;
771 Actor actor = Actor::New();
772 Vector3 vector(100.0f, 100.0f, 100.0f);
774 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
776 actor.SetSize(vector.x, vector.y, vector.z);
778 // flush the queue and render once
779 application.SendNotification();
780 application.Render();
782 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
786 // SetSize(Vector2 size)
787 int UtcDaliActorSetSize03(void)
789 TestApplication application;
791 Actor actor = Actor::New();
792 Vector3 vector(100.0f, 100.0f, 0.0f);
794 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
796 actor.SetSize(Vector2(vector.x, vector.y));
798 // flush the queue and render once
799 application.SendNotification();
800 application.Render();
802 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
806 // SetSize(Vector3 size)
807 int UtcDaliActorSetSize04(void)
809 TestApplication application;
811 Actor actor = Actor::New();
812 Vector3 vector(100.0f, 100.0f, 100.0f);
814 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
816 actor.SetSize(vector);
818 // flush the queue and render once
819 application.SendNotification();
820 application.Render();
822 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
824 Stage::GetCurrent().Add( actor );
825 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
827 // flush the queue and render once
828 application.SendNotification();
829 application.Render();
831 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
832 Stage::GetCurrent().Remove( actor );
836 int UtcDaliActorSetSizeIndividual(void)
838 TestApplication application;
840 Actor actor = Actor::New();
842 Vector3 vector(0.7f, 0.8f, 0.9f);
843 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
845 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
847 // flush the queue and render once
848 application.SendNotification();
849 application.Render();
851 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
853 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
855 // flush the queue and render once
856 application.SendNotification();
857 application.Render();
859 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
861 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
863 // flush the queue and render once
864 application.SendNotification();
865 application.Render();
867 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
873 int UtcDaliActorGetCurrentSize(void)
875 TestApplication application;
877 Actor actor = Actor::New();
878 Vector3 vector(100.0f, 100.0f, 20.0f);
880 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
882 actor.SetSize(vector);
884 // flush the queue and render once
885 application.SendNotification();
886 application.Render();
888 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
892 int UtcDaliActorGetNaturalSize(void)
894 TestApplication application;
896 Actor actor = Actor::New();
897 Vector3 vector( 0.0f, 0.0f, 0.0f );
899 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
904 int UtcDaliActorGetCurrentSizeImmediate(void)
906 TestApplication application;
908 Actor actor = Actor::New();
909 Vector3 vector(100.0f, 100.0f, 20.0f);
911 DALI_TEST_CHECK(vector != actor.GetTargetSize());
912 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
914 actor.SetSize(vector);
916 DALI_TEST_CHECK(vector == actor.GetTargetSize());
917 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
919 // flush the queue and render once
920 application.SendNotification();
921 application.Render();
923 DALI_TEST_CHECK(vector == actor.GetTargetSize());
924 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
927 // Build the animation
928 const float durationSeconds = 2.0f;
929 Animation animation = Animation::New( durationSeconds );
930 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
931 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
933 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
935 // Start the animation
938 application.SendNotification();
939 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
941 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
946 // SetPosition(float x, float y)
947 int UtcDaliActorSetPosition01(void)
949 TestApplication application;
951 Actor actor = Actor::New();
953 // Set to random to start off with
954 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
956 Vector3 vector(100.0f, 100.0f, 0.0f);
958 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
960 actor.SetPosition(vector.x, vector.y);
961 // flush the queue and render once
962 application.SendNotification();
963 application.Render();
964 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
966 Stage::GetCurrent().Add( actor );
967 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
968 // flush the queue and render once
969 application.SendNotification();
970 application.Render();
971 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
976 // flush the queue and render once
977 application.SendNotification();
978 application.Render();
979 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
981 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
982 // flush the queue and render once
983 application.SendNotification();
984 application.Render();
985 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
987 Stage::GetCurrent().Remove( actor );
991 // SetPosition(float x, float y, float z)
992 int UtcDaliActorSetPosition02(void)
994 TestApplication application;
996 Actor actor = Actor::New();
998 // Set to random to start off with
999 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1001 Vector3 vector(100.0f, 100.0f, 100.0f);
1003 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1005 actor.SetPosition(vector.x, vector.y, vector.z);
1007 // flush the queue and render once
1008 application.SendNotification();
1009 application.Render();
1011 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1015 // SetPosition(Vector3 position)
1016 int UtcDaliActorSetPosition03(void)
1018 TestApplication application;
1020 Actor actor = Actor::New();
1022 // Set to random to start off with
1023 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1025 Vector3 vector(100.0f, 100.0f, 100.0f);
1027 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1029 actor.SetPosition(vector);
1031 // flush the queue and render once
1032 application.SendNotification();
1033 application.Render();
1035 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1039 int UtcDaliActorSetX(void)
1041 TestApplication application;
1043 Actor actor = Actor::New();
1045 Vector3 vector(100.0f, 0.0f, 0.0f);
1047 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1051 // flush the queue and render once
1052 application.SendNotification();
1053 application.Render();
1055 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1059 int UtcDaliActorSetY(void)
1061 TestApplication application;
1063 Actor actor = Actor::New();
1065 Vector3 vector(0.0f, 100.0f, 0.0f);
1067 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1071 // flush the queue and render once
1072 application.SendNotification();
1073 application.Render();
1075 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1079 int UtcDaliActorSetZ(void)
1081 TestApplication application;
1083 Actor actor = Actor::New();
1085 Vector3 vector(0.0f, 0.0f, 100.0f);
1087 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1091 // flush the queue and render once
1092 application.SendNotification();
1093 application.Render();
1095 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1099 int UtcDaliActorSetPositionProperties(void)
1101 TestApplication application;
1103 Actor actor = Actor::New();
1105 Vector3 vector(0.7f, 0.8f, 0.9f);
1106 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1108 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1110 // flush the queue and render once
1111 application.SendNotification();
1112 application.Render();
1114 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1116 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1118 // flush the queue and render once
1119 application.SendNotification();
1120 application.Render();
1122 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1124 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1126 // flush the queue and render once
1127 application.SendNotification();
1128 application.Render();
1130 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1135 int UtcDaliActorTranslateBy(void)
1137 TestApplication application;
1139 Actor actor = Actor::New();
1140 Vector3 vector(100.0f, 100.0f, 100.0f);
1142 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1144 actor.SetPosition(vector);
1146 // flush the queue and render once
1147 application.SendNotification();
1148 application.Render();
1150 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1152 actor.TranslateBy(vector);
1154 // flush the queue and render once
1155 application.SendNotification();
1156 application.Render();
1158 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1162 int UtcDaliActorGetCurrentPosition(void)
1164 TestApplication application;
1166 Actor actor = Actor::New();
1167 Vector3 setVector(100.0f, 100.0f, 0.0f);
1168 actor.SetPosition(setVector);
1170 // flush the queue and render once
1171 application.SendNotification();
1172 application.Render();
1174 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1178 int UtcDaliActorGetCurrentWorldPosition(void)
1180 TestApplication application;
1182 Actor parent = Actor::New();
1183 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1184 parent.SetPosition( parentPosition );
1185 parent.SetParentOrigin( ParentOrigin::CENTER );
1186 parent.SetAnchorPoint( AnchorPoint::CENTER );
1187 Stage::GetCurrent().Add( parent );
1189 Actor child = Actor::New();
1190 child.SetParentOrigin( ParentOrigin::CENTER );
1191 child.SetAnchorPoint( AnchorPoint::CENTER );
1192 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1193 child.SetPosition( childPosition );
1194 parent.Add( child );
1196 // The actors should not have a world position yet
1197 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1198 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1200 application.SendNotification();
1201 application.Render(0);
1203 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1204 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1206 // The actors should have a world position now
1207 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1208 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1212 int UtcDaliActorInheritPosition(void)
1214 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1215 TestApplication application;
1217 Actor parent = Actor::New();
1218 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1219 parent.SetPosition( parentPosition );
1220 parent.SetParentOrigin( ParentOrigin::CENTER );
1221 parent.SetAnchorPoint( AnchorPoint::CENTER );
1222 Stage::GetCurrent().Add( parent );
1224 Actor child = Actor::New();
1225 child.SetParentOrigin( ParentOrigin::CENTER );
1226 child.SetAnchorPoint( AnchorPoint::CENTER );
1227 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1228 child.SetPosition( childPosition );
1229 parent.Add( child );
1231 // The actors should not have a world position yet
1232 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1233 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1235 // first test default, which is to inherit position
1236 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1237 application.SendNotification();
1238 application.Render(0); // should only really call Update as Render is not required to update scene
1239 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1240 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1241 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1242 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1245 //Change child position
1246 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1247 child.SetPosition( childOffset );
1249 // Change inheritance mode to not inherit
1250 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1251 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1252 application.SendNotification();
1253 application.Render(0); // should only really call Update as Render is not required to update scene
1254 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1255 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1256 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1257 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1261 int UtcDaliActorSetInheritPosition(void)
1263 tet_infoline("Testing Actor::SetInheritPosition");
1264 TestApplication application;
1266 Actor parent = Actor::New();
1267 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1268 parent.SetPosition( parentPosition );
1269 parent.SetParentOrigin( ParentOrigin::CENTER );
1270 parent.SetAnchorPoint( AnchorPoint::CENTER );
1271 Stage::GetCurrent().Add( parent );
1273 Actor child = Actor::New();
1274 child.SetParentOrigin( ParentOrigin::CENTER );
1275 child.SetAnchorPoint( AnchorPoint::CENTER );
1276 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1277 child.SetPosition( childPosition );
1278 parent.Add( child );
1280 // The actors should not have a world position yet
1281 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1282 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1284 // first test default, which is to inherit position
1285 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1286 application.SendNotification();
1287 application.Render(0); // should only really call Update as Render is not required to update scene
1288 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1289 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1290 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1291 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1293 //Change child position
1294 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1295 child.SetPosition( childOffset );
1297 // Use local position as world postion
1298 child.SetInheritPosition( false );
1299 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1300 application.SendNotification();
1301 application.Render(0); // should only really call Update as Render is not required to update scene
1302 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1303 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1304 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1305 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1307 //Change back to inherit position from parent
1308 child.SetInheritPosition( true );
1309 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1310 application.SendNotification();
1311 application.Render(0); // should only really call Update as Render is not required to update scene
1312 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1313 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1314 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1315 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1319 // SetOrientation(float angleRadians, Vector3 axis)
1320 int UtcDaliActorSetOrientation01(void)
1322 TestApplication application;
1324 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1325 Actor actor = Actor::New();
1327 actor.SetOrientation(rotation);
1329 // flush the queue and render once
1330 application.SendNotification();
1331 application.Render();
1333 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1337 int UtcDaliActorSetOrientation02(void)
1339 TestApplication application;
1341 Actor actor = Actor::New();
1343 Radian angle( 0.785f );
1344 Vector3 axis(1.0f, 1.0f, 0.0f);
1346 actor.SetOrientation( angle, axis);
1347 Quaternion rotation( angle, axis );
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1351 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1353 Stage::GetCurrent().Add( actor );
1354 actor.RotateBy( Degree( 360 ), axis);
1355 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1357 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1358 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1359 // flush the queue and render once
1360 application.SendNotification();
1361 application.Render();
1362 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1364 actor.SetOrientation( angle, axis);
1365 // flush the queue and render once
1366 application.SendNotification();
1367 application.Render();
1368 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1370 Stage::GetCurrent().Remove( actor );
1374 // SetOrientation(float angleRadians, Vector3 axis)
1375 int UtcDaliActorSetOrientationProperty(void)
1377 TestApplication application;
1379 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1380 Actor actor = Actor::New();
1382 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1384 // flush the queue and render once
1385 application.SendNotification();
1386 application.Render();
1388 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1392 // RotateBy(float angleRadians, Vector3 axis)
1393 int UtcDaliActorRotateBy01(void)
1395 TestApplication application;
1397 Actor actor = Actor::New();
1399 Radian angle( M_PI * 0.25f );
1400 actor.RotateBy(( angle ), Vector3::ZAXIS);
1401 // flush the queue and render once
1402 application.SendNotification();
1403 application.Render();
1404 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1406 Stage::GetCurrent().Add( actor );
1408 actor.RotateBy( angle, Vector3::ZAXIS);
1409 // flush the queue and render once
1410 application.SendNotification();
1411 application.Render();
1412 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1414 Stage::GetCurrent().Remove( actor );
1418 // RotateBy(Quaternion relativeRotation)
1419 int UtcDaliActorRotateBy02(void)
1421 TestApplication application;
1423 Actor actor = Actor::New();
1425 Radian angle( M_PI * 0.25f );
1426 Quaternion rotation(angle, Vector3::ZAXIS);
1427 actor.RotateBy(rotation);
1428 // flush the queue and render once
1429 application.SendNotification();
1430 application.Render();
1431 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1433 actor.RotateBy(rotation);
1434 // flush the queue and render once
1435 application.SendNotification();
1436 application.Render();
1437 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1441 int UtcDaliActorGetCurrentOrientation(void)
1443 TestApplication application;
1444 Actor actor = Actor::New();
1446 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1447 actor.SetOrientation(rotation);
1448 // flush the queue and render once
1449 application.SendNotification();
1450 application.Render();
1451 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1455 int UtcDaliActorGetCurrentWorldOrientation(void)
1457 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1458 TestApplication application;
1460 Actor parent = Actor::New();
1461 Radian rotationAngle( Degree(90.0f) );
1462 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1463 parent.SetOrientation( rotation );
1464 Stage::GetCurrent().Add( parent );
1466 Actor child = Actor::New();
1467 child.SetOrientation( rotation );
1468 parent.Add( child );
1470 // The actors should not have a world rotation yet
1471 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1472 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1474 application.SendNotification();
1475 application.Render(0);
1477 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1478 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1480 // The actors should have a world rotation now
1481 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1482 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1484 // turn off child rotation inheritance
1485 child.SetInheritOrientation( false );
1486 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1487 application.SendNotification();
1488 application.Render(0);
1490 // The actors should have a world rotation now
1491 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1492 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1496 // SetScale(float scale)
1497 int UtcDaliActorSetScale01(void)
1499 TestApplication application;
1501 Actor actor = Actor::New();
1503 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1504 actor.SetScale(0.25f);
1506 Vector3 scale(10.0f, 10.0f, 10.0f);
1507 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1509 actor.SetScale(scale.x);
1511 // flush the queue and render once
1512 application.SendNotification();
1513 application.Render();
1515 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1519 // SetScale(float scaleX, float scaleY, float scaleZ)
1520 int UtcDaliActorSetScale02(void)
1522 TestApplication application;
1523 Vector3 scale(10.0f, 10.0f, 10.0f);
1525 Actor actor = Actor::New();
1527 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1528 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1530 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1532 actor.SetScale(scale.x, scale.y, scale.z);
1533 // flush the queue and render once
1534 application.SendNotification();
1535 application.Render();
1536 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1538 // add to stage and test
1539 Stage::GetCurrent().Add( actor );
1540 actor.SetScale( 2.0f, 2.0f, 2.0f );
1541 // flush the queue and render once
1542 application.SendNotification();
1543 application.Render();
1544 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1546 Stage::GetCurrent().Remove( actor );
1551 // SetScale(Vector3 scale)
1552 int UtcDaliActorSetScale03(void)
1554 TestApplication application;
1555 Vector3 scale(10.0f, 10.0f, 10.0f);
1557 Actor actor = Actor::New();
1559 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1560 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1562 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1564 actor.SetScale(scale);
1566 // flush the queue and render once
1567 application.SendNotification();
1568 application.Render();
1570 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1574 int UtcDaliActorSetScaleIndividual(void)
1576 TestApplication application;
1578 Actor actor = Actor::New();
1580 Vector3 vector(0.7f, 0.8f, 0.9f);
1581 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1583 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1585 // flush the queue and render once
1586 application.SendNotification();
1587 application.Render();
1589 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1591 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1593 // flush the queue and render once
1594 application.SendNotification();
1595 application.Render();
1597 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1599 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1601 // flush the queue and render once
1602 application.SendNotification();
1603 application.Render();
1605 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1610 int UtcDaliActorScaleBy(void)
1612 TestApplication application;
1613 Actor actor = Actor::New();
1614 Vector3 vector(100.0f, 100.0f, 100.0f);
1616 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1618 actor.SetScale(vector);
1620 // flush the queue and render once
1621 application.SendNotification();
1622 application.Render();
1624 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1626 actor.ScaleBy(vector);
1628 // flush the queue and render once
1629 application.SendNotification();
1630 application.Render();
1632 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1636 int UtcDaliActorGetCurrentScale(void)
1638 TestApplication application;
1639 Vector3 scale(12.0f, 1.0f, 2.0f);
1641 Actor actor = Actor::New();
1643 actor.SetScale(scale);
1645 // flush the queue and render once
1646 application.SendNotification();
1647 application.Render();
1649 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1653 int UtcDaliActorGetCurrentWorldScale(void)
1655 TestApplication application;
1657 Actor parent = Actor::New();
1658 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1659 parent.SetScale( parentScale );
1660 Stage::GetCurrent().Add( parent );
1662 Actor child = Actor::New();
1663 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1664 child.SetScale( childScale );
1665 parent.Add( child );
1667 // The actors should not have a scale yet
1668 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1669 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1671 // The actors should not have a world scale yet
1672 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1673 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1675 application.SendNotification();
1676 application.Render(0);
1678 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1679 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1681 // The actors should have a world scale now
1682 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1683 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1687 int UtcDaliActorInheritScale(void)
1689 tet_infoline("Testing Actor::SetInheritScale");
1690 TestApplication application;
1692 Actor parent = Actor::New();
1693 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1694 parent.SetScale( parentScale );
1695 Stage::GetCurrent().Add( parent );
1697 Actor child = Actor::New();
1698 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1699 child.SetScale( childScale );
1700 parent.Add( child );
1702 application.SendNotification();
1703 application.Render(0);
1705 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1706 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1708 child.SetInheritScale( false );
1709 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1711 application.SendNotification();
1712 application.Render(0);
1714 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1718 int UtcDaliActorSetVisible(void)
1720 TestApplication application;
1722 Actor actor = Actor::New();
1723 actor.SetVisible(false);
1724 // flush the queue and render once
1725 application.SendNotification();
1726 application.Render();
1727 DALI_TEST_CHECK(actor.IsVisible() == false);
1729 actor.SetVisible(true);
1730 // flush the queue and render once
1731 application.SendNotification();
1732 application.Render();
1733 DALI_TEST_CHECK(actor.IsVisible() == true);
1735 // put actor on stage
1736 Stage::GetCurrent().Add( actor );
1737 actor.SetVisible(false);
1738 // flush the queue and render once
1739 application.SendNotification();
1740 application.Render();
1741 DALI_TEST_CHECK(actor.IsVisible() == false);
1745 int UtcDaliActorIsVisible(void)
1747 TestApplication application;
1749 Actor actor = Actor::New();
1751 DALI_TEST_CHECK(actor.IsVisible() == true);
1755 int UtcDaliActorSetOpacity(void)
1757 TestApplication application;
1759 Actor actor = Actor::New();
1760 // initial opacity is 1
1761 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1763 actor.SetOpacity( 0.4f);
1764 // flush the queue and render once
1765 application.SendNotification();
1766 application.Render();
1767 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1769 // change opacity, actor is on stage to change is not immediate
1770 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1771 // flush the queue and render once
1772 application.SendNotification();
1773 application.Render();
1774 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1776 // put actor on stage
1777 Stage::GetCurrent().Add( actor );
1779 // change opacity, actor is on stage to change is not immediate
1780 actor.SetOpacity( 0.9f );
1781 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1782 // flush the queue and render once
1783 application.SendNotification();
1784 application.Render();
1785 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1787 // change opacity, actor is on stage to change is not immediate
1788 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1789 // flush the queue and render once
1790 application.SendNotification();
1791 application.Render();
1792 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1796 int UtcDaliActorGetCurrentOpacity(void)
1798 TestApplication application;
1800 Actor actor = Actor::New();
1801 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1803 actor.SetOpacity(0.5f);
1804 // flush the queue and render once
1805 application.SendNotification();
1806 application.Render();
1807 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1811 int UtcDaliActorSetSensitive(void)
1813 TestApplication application;
1814 Actor actor = Actor::New();
1816 bool sensitive = !actor.IsSensitive();
1818 actor.SetSensitive(sensitive);
1820 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1824 int UtcDaliActorIsSensitive(void)
1826 TestApplication application;
1827 Actor actor = Actor::New();
1828 actor.SetSensitive(false);
1830 DALI_TEST_CHECK(false == actor.IsSensitive());
1834 int UtcDaliActorSetColor(void)
1836 TestApplication application;
1837 Actor actor = Actor::New();
1838 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1840 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1842 actor.SetColor(color);
1843 // flush the queue and render once
1844 application.SendNotification();
1845 application.Render();
1846 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1848 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1849 // flush the queue and render once
1850 application.SendNotification();
1851 application.Render();
1852 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1854 Stage::GetCurrent().Add( actor );
1855 actor.SetColor( color );
1856 // flush the queue and render once
1857 application.SendNotification();
1858 application.Render();
1859 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1861 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1862 // flush the queue and render once
1863 application.SendNotification();
1864 application.Render();
1865 // Actor color is not clamped
1866 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1867 // world color is clamped
1868 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1870 Stage::GetCurrent().Remove( actor );
1874 int UtcDaliActorSetColorIndividual(void)
1876 TestApplication application;
1878 Actor actor = Actor::New();
1880 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1881 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1883 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1885 // flush the queue and render once
1886 application.SendNotification();
1887 application.Render();
1889 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
1891 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
1893 // flush the queue and render once
1894 application.SendNotification();
1895 application.Render();
1897 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
1899 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
1901 // flush the queue and render once
1902 application.SendNotification();
1903 application.Render();
1905 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
1907 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
1909 // flush the queue and render once
1910 application.SendNotification();
1911 application.Render();
1913 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
1919 int UtcDaliActorGetCurrentColor(void)
1921 TestApplication application;
1922 Actor actor = Actor::New();
1923 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1925 actor.SetColor(color);
1926 // flush the queue and render once
1927 application.SendNotification();
1928 application.Render();
1929 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1933 int UtcDaliActorGetCurrentWorldColor(void)
1935 tet_infoline("Actor::GetCurrentWorldColor");
1936 TestApplication application;
1938 Actor parent = Actor::New();
1939 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1940 parent.SetColor( parentColor );
1941 Stage::GetCurrent().Add( parent );
1943 Actor child = Actor::New();
1944 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1945 child.SetColor( childColor );
1946 parent.Add( child );
1948 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1949 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1951 // verify the default color mode
1952 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1954 // The actors should not have a world color yet
1955 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1956 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1958 application.SendNotification();
1959 application.Render(0);
1961 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1962 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1964 // The actors should have a world color now
1965 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1966 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1969 child.SetColorMode( USE_OWN_COLOR );
1970 application.SendNotification();
1971 application.Render(0);
1972 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1975 child.SetColorMode( USE_PARENT_COLOR );
1976 application.SendNotification();
1977 application.Render(0);
1978 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1979 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1982 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1983 application.SendNotification();
1984 application.Render(0);
1985 Vector4 expectedColor( childColor );
1986 expectedColor.a *= parentColor.a;
1987 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1988 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1992 int UtcDaliActorSetColorMode(void)
1994 tet_infoline("Actor::SetColorMode");
1995 TestApplication application;
1996 Actor actor = Actor::New();
1997 Actor child = Actor::New();
2000 actor.SetColorMode( USE_OWN_COLOR );
2001 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2003 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2004 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2006 actor.SetColorMode( USE_PARENT_COLOR );
2007 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2009 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2010 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2014 int UtcDaliActorScreenToLocal(void)
2016 TestApplication application;
2017 Actor actor = Actor::New();
2018 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2019 actor.SetSize(100.0f, 100.0f);
2020 actor.SetPosition(10.0f, 10.0f);
2021 Stage::GetCurrent().Add(actor);
2023 // flush the queue and render once
2024 application.SendNotification();
2025 application.Render();
2030 application.SendNotification();
2031 application.Render();
2033 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2035 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2036 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2040 int UtcDaliActorSetLeaveRequired(void)
2042 TestApplication application;
2044 Actor actor = Actor::New();
2046 actor.SetLeaveRequired(false);
2047 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2049 actor.SetLeaveRequired(true);
2050 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2054 int UtcDaliActorGetLeaveRequired(void)
2056 TestApplication application;
2058 Actor actor = Actor::New();
2060 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2064 int UtcDaliActorSetKeyboardFocusable(void)
2066 TestApplication application;
2068 Actor actor = Actor::New();
2070 actor.SetKeyboardFocusable(true);
2071 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2073 actor.SetKeyboardFocusable(false);
2074 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2078 int UtcDaliActorIsKeyboardFocusable(void)
2080 TestApplication application;
2082 Actor actor = Actor::New();
2084 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2088 int UtcDaliActorRemoveConstraints(void)
2090 tet_infoline(" UtcDaliActorRemoveConstraints");
2091 TestApplication application;
2093 gTestConstraintCalled = false;
2095 Actor actor = Actor::New();
2097 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2099 actor.RemoveConstraints();
2101 DALI_TEST_CHECK( gTestConstraintCalled == false );
2103 Stage::GetCurrent().Add( actor );
2106 // flush the queue and render once
2107 application.SendNotification();
2108 application.Render();
2110 actor.RemoveConstraints();
2112 DALI_TEST_CHECK( gTestConstraintCalled == true );
2116 int UtcDaliActorRemoveConstraintTag(void)
2118 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2119 TestApplication application;
2121 Actor actor = Actor::New();
2123 // 1. Apply Constraint1 and Constraint2, and test...
2124 unsigned int result1 = 0u;
2125 unsigned int result2 = 0u;
2127 unsigned constraint1Tag = 1u;
2128 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2129 constraint1.SetTag( constraint1Tag );
2130 constraint1.Apply();
2132 unsigned constraint2Tag = 2u;
2133 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2134 constraint2.SetTag( constraint2Tag );
2135 constraint2.Apply();
2137 Stage::GetCurrent().Add( actor );
2138 // flush the queue and render once
2139 application.SendNotification();
2140 application.Render();
2142 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2143 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2145 // 2. Remove Constraint1 and test...
2148 actor.RemoveConstraints(constraint1Tag);
2149 // make color property dirty, which will trigger constraints to be reapplied.
2150 actor.SetColor( Color::WHITE );
2151 // flush the queue and render once
2152 application.SendNotification();
2153 application.Render();
2155 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2156 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2158 // 3. Re-Apply Constraint1 and test...
2161 constraint1.Apply();
2162 // make color property dirty, which will trigger constraints to be reapplied.
2163 actor.SetColor( Color::WHITE );
2164 // flush the queue and render once
2165 application.SendNotification();
2166 application.Render();
2168 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2169 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2171 // 2. Remove Constraint2 and test...
2174 actor.RemoveConstraints(constraint2Tag);
2175 // make color property dirty, which will trigger constraints to be reapplied.
2176 actor.SetColor( Color::WHITE );
2177 // flush the queue and render once
2178 application.SendNotification();
2179 application.Render();
2181 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2182 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2184 // 2. Remove Constraint1 as well and test...
2187 actor.RemoveConstraints(constraint1Tag);
2188 // make color property dirty, which will trigger constraints to be reapplied.
2189 actor.SetColor( Color::WHITE );
2190 // flush the queue and render once
2191 application.SendNotification();
2192 application.Render();
2194 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2195 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2199 int UtcDaliActorTouchedSignal(void)
2201 TestApplication application;
2203 gTouchCallBackCalled = false;
2205 // get the root layer
2206 Actor actor = Stage::GetCurrent().GetRootLayer();
2207 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2209 application.SendNotification();
2210 application.Render();
2212 // connect to its touch signal
2213 actor.TouchedSignal().Connect( TestCallback );
2215 // simulate a touch event in the middle of the screen
2216 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2217 Dali::Integration::Point point;
2218 point.SetDeviceId( 1 );
2219 point.SetState( PointState::DOWN );
2220 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2221 Dali::Integration::TouchEvent event;
2222 event.AddPoint( point );
2223 application.ProcessEvent( event );
2225 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2229 int UtcDaliActorHoveredSignal(void)
2231 TestApplication application;
2233 gHoverCallBackCalled = false;
2235 // get the root layer
2236 Actor actor = Stage::GetCurrent().GetRootLayer();
2237 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2239 application.SendNotification();
2240 application.Render();
2242 // connect to its hover signal
2243 actor.HoveredSignal().Connect( TestCallback3 );
2245 // simulate a hover event in the middle of the screen
2246 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2247 Dali::Integration::Point point;
2248 point.SetDeviceId( 1 );
2249 point.SetState( PointState::MOTION );
2250 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2251 Dali::Integration::HoverEvent event;
2252 event.AddPoint( point );
2253 application.ProcessEvent( event );
2255 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2259 int UtcDaliActorOnOffStageSignal(void)
2261 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2263 TestApplication application;
2266 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2267 gActorNamesOnOffStage.clear();
2269 Actor parent = Actor::New();
2270 parent.SetName( "parent" );
2271 parent.OnStageSignal().Connect( OnStageCallback );
2272 parent.OffStageSignal().Connect( OffStageCallback );
2274 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2275 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2277 // add parent to stage
2278 Stage::GetCurrent().Add( parent );
2279 // onstage emitted, offstage not
2280 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2281 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2282 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2284 // test adding a child, should get onstage emitted
2286 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2287 gActorNamesOnOffStage.clear();
2289 Actor child = Actor::New();
2290 child.SetName( "child" );
2291 child.OnStageSignal().Connect( OnStageCallback );
2292 child.OffStageSignal().Connect( OffStageCallback );
2293 parent.Add( child ); // add child
2294 // onstage emitted, offstage not
2295 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2296 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2297 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2299 // test removing parent from stage
2301 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2302 gActorNamesOnOffStage.clear();
2304 Stage::GetCurrent().Remove( parent );
2305 // onstage not emitted, offstage is
2306 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2307 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2308 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2309 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2311 // test adding parent back to stage
2313 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2314 gActorNamesOnOffStage.clear();
2316 Stage::GetCurrent().Add( parent );
2317 // onstage emitted, offstage not
2318 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2319 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2320 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2321 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2323 // test removing child
2325 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2326 gActorNamesOnOffStage.clear();
2328 parent.Remove( child );
2329 // onstage not emitted, offstage is
2330 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2331 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2332 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2334 // test removing parent
2336 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2337 gActorNamesOnOffStage.clear();
2339 Stage::GetCurrent().Remove( parent );
2340 // onstage not emitted, offstage is
2341 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2342 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2343 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2347 int UtcDaliActorFindChildByName(void)
2349 tet_infoline("Testing Dali::Actor::FindChildByName()");
2350 TestApplication application;
2352 Actor parent = Actor::New();
2353 parent.SetName( "parent" );
2354 Actor first = Actor::New();
2355 first .SetName( "first" );
2356 Actor second = Actor::New();
2357 second.SetName( "second" );
2362 Actor found = parent.FindChildByName( "foo" );
2363 DALI_TEST_CHECK( !found );
2365 found = parent.FindChildByName( "parent" );
2366 DALI_TEST_CHECK( found == parent );
2368 found = parent.FindChildByName( "first" );
2369 DALI_TEST_CHECK( found == first );
2371 found = parent.FindChildByName( "second" );
2372 DALI_TEST_CHECK( found == second );
2376 int UtcDaliActorFindChildById(void)
2378 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2379 TestApplication application;
2381 Actor parent = Actor::New();
2382 Actor first = Actor::New();
2383 Actor second = Actor::New();
2388 Actor found = parent.FindChildById( 100000 );
2389 DALI_TEST_CHECK( !found );
2391 found = parent.FindChildById( parent.GetId() );
2392 DALI_TEST_CHECK( found == parent );
2394 found = parent.FindChildById( first.GetId() );
2395 DALI_TEST_CHECK( found == first );
2397 found = parent.FindChildById( second.GetId() );
2398 DALI_TEST_CHECK( found == second );
2402 int UtcDaliActorHitTest(void)
2407 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2409 mTouchPoint( touchPoint ),
2414 Vector2 mTouchPoint;
2418 TestApplication application;
2419 tet_infoline(" UtcDaliActorHitTest");
2421 // Fill a vector with different hit tests.
2422 struct HitTestData* hitTestData[] = {
2423 // scale touch point result
2424 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2425 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2426 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.
2427 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2428 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.
2432 // get the root layer
2433 Actor actor = Actor::New();
2434 actor.SetAnchorPoint( AnchorPoint::CENTER );
2435 actor.SetParentOrigin( ParentOrigin::CENTER );
2437 Stage::GetCurrent().Add( actor );
2439 gTouchCallBackCalled = false;
2441 unsigned int index = 0;
2442 while( NULL != hitTestData[index] )
2444 actor.SetSize( 1.f, 1.f );
2445 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2447 // flush the queue and render once
2448 application.SendNotification();
2449 application.Render();
2451 DALI_TEST_CHECK( !gTouchCallBackCalled );
2453 // connect to its touch signal
2454 actor.TouchedSignal().Connect(TestCallback);
2456 Dali::Integration::Point point;
2457 point.SetState( PointState::DOWN );
2458 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2459 Dali::Integration::TouchEvent event;
2460 event.AddPoint( point );
2462 // flush the queue and render once
2463 application.SendNotification();
2464 application.Render();
2465 application.ProcessEvent( event );
2467 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2469 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2470 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2471 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2472 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2473 hitTestData[index]->mResult );
2475 gTouchCallBackCalled = false;
2481 int UtcDaliActorSetDrawMode(void)
2483 TestApplication app;
2484 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2486 Actor a = Actor::New();
2488 Stage::GetCurrent().Add(a);
2489 app.SendNotification();
2491 app.SendNotification();
2494 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2496 a.SetDrawMode( DrawMode::OVERLAY_2D );
2497 app.SendNotification();
2500 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2502 a.SetDrawMode( DrawMode::STENCIL );
2503 app.SendNotification();
2506 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2508 a.SetDrawMode( DrawMode::NORMAL );
2509 app.SendNotification();
2512 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2516 int UtcDaliActorSetDrawModeOverlayRender(void)
2518 TestApplication app;
2519 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2521 app.SendNotification();
2524 std::vector<GLuint> ids;
2525 ids.push_back( 8 ); // first rendered actor
2526 ids.push_back( 9 ); // second rendered actor
2527 ids.push_back( 10 ); // third rendered actor
2528 app.GetGlAbstraction().SetNextTextureIds( ids );
2530 BufferImage imageA = BufferImage::New(16, 16);
2531 BufferImage imageB = BufferImage::New(16, 16);
2532 BufferImage imageC = BufferImage::New(16, 16);
2533 Actor a = CreateRenderableActor( imageA );
2534 Actor b = CreateRenderableActor( imageB );
2535 Actor c = CreateRenderableActor( imageC );
2537 // Render a,b,c as regular non-overlays. so order will be:
2541 Stage::GetCurrent().Add(a);
2542 Stage::GetCurrent().Add(b);
2543 Stage::GetCurrent().Add(c);
2545 app.SendNotification();
2548 // Should be 3 textures changes.
2549 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2550 typedef std::vector<GLuint>::size_type TextureSize;
2551 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2552 if( boundTextures.size() == 3 )
2554 DALI_TEST_CHECK( boundTextures[0] == 8u );
2555 DALI_TEST_CHECK( boundTextures[1] == 9u );
2556 DALI_TEST_CHECK( boundTextures[2] == 10u );
2559 // Now texture ids have been set, we can monitor their render order.
2560 // render a as an overlay (last), so order will be:
2564 a.SetDrawMode( DrawMode::OVERLAY_2D );
2565 app.GetGlAbstraction().ClearBoundTextures();
2567 app.SendNotification();
2570 // Should be 3 texture changes.
2571 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2572 if( boundTextures.size() == 3 )
2574 DALI_TEST_CHECK( boundTextures[0] == 9u );
2575 DALI_TEST_CHECK( boundTextures[1] == 10u );
2576 DALI_TEST_CHECK( boundTextures[2] == 8u );
2581 int UtcDaliActorGetCurrentWorldMatrix(void)
2583 TestApplication app;
2584 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2586 Actor parent = Actor::New();
2587 parent.SetParentOrigin(ParentOrigin::CENTER);
2588 parent.SetAnchorPoint(AnchorPoint::CENTER);
2589 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2590 Radian rotationAngle(Degree(85.0f));
2591 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2592 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2593 parent.SetPosition( parentPosition );
2594 parent.SetOrientation( parentRotation );
2595 parent.SetScale( parentScale );
2596 Stage::GetCurrent().Add( parent );
2598 Actor child = Actor::New();
2599 child.SetParentOrigin(ParentOrigin::CENTER);
2600 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2601 Radian childRotationAngle(Degree(23.0f));
2602 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2603 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2604 child.SetPosition( childPosition );
2605 child.SetOrientation( childRotation );
2606 child.SetScale( childScale );
2607 parent.Add( child );
2609 app.SendNotification();
2612 app.SendNotification();
2614 Matrix parentMatrix(false);
2615 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2617 Matrix childMatrix(false);
2618 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2620 //Child matrix should be the composition of child and parent
2621 Matrix childWorldMatrix(false);
2622 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2624 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2625 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2631 int UtcDaliActorConstrainedToWorldMatrix(void)
2633 TestApplication app;
2634 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2636 Actor parent = Actor::New();
2637 parent.SetParentOrigin(ParentOrigin::CENTER);
2638 parent.SetAnchorPoint(AnchorPoint::CENTER);
2639 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2640 Radian rotationAngle(Degree(85.0f));
2641 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2642 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2643 parent.SetPosition( parentPosition );
2644 parent.SetOrientation( parentRotation );
2645 parent.SetScale( parentScale );
2646 Stage::GetCurrent().Add( parent );
2648 Actor child = Actor::New();
2649 child.SetParentOrigin(ParentOrigin::CENTER);
2650 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2651 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2652 posConstraint.Apply();
2654 Stage::GetCurrent().Add( child );
2656 app.SendNotification();
2659 app.SendNotification();
2661 Matrix parentMatrix(false);
2662 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2664 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2665 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2669 int UtcDaliActorConstrainedToOrientation(void)
2671 TestApplication app;
2672 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2674 Actor parent = Actor::New();
2675 parent.SetParentOrigin(ParentOrigin::CENTER);
2676 parent.SetAnchorPoint(AnchorPoint::CENTER);
2677 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2678 Radian rotationAngle(Degree(85.0f));
2679 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2680 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2681 parent.SetPosition( parentPosition );
2682 parent.SetOrientation( parentRotation );
2683 parent.SetScale( parentScale );
2684 Stage::GetCurrent().Add( parent );
2686 Actor child = Actor::New();
2687 child.SetParentOrigin(ParentOrigin::CENTER);
2688 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2689 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2690 posConstraint.Apply();
2692 Stage::GetCurrent().Add( child );
2694 app.SendNotification();
2697 app.SendNotification();
2699 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2703 int UtcDaliActorUnparent(void)
2705 TestApplication app;
2706 tet_infoline(" UtcDaliActorUnparent");
2708 Actor parent = Actor::New();
2709 Stage::GetCurrent().Add( parent );
2711 Actor child = Actor::New();
2713 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2714 DALI_TEST_CHECK( !child.GetParent() );
2716 // Test that calling Unparent with no parent is a NOOP
2719 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2720 DALI_TEST_CHECK( !child.GetParent() );
2722 // Test that Unparent works
2723 parent.Add( child );
2725 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2726 DALI_TEST_CHECK( parent == child.GetParent() );
2730 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2731 DALI_TEST_CHECK( !child.GetParent() );
2733 // Test that UnparentAndReset works
2734 parent.Add( child );
2736 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2737 DALI_TEST_CHECK( parent == child.GetParent() );
2739 UnparentAndReset( child );
2741 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2742 DALI_TEST_CHECK( !child );
2744 // Test that UnparentAndReset is a NOOP with empty handle
2745 UnparentAndReset( child );
2747 DALI_TEST_CHECK( !child );
2751 int UtcDaliActorGetChildAt(void)
2753 TestApplication app;
2754 tet_infoline(" UtcDaliActorGetChildAt");
2756 Actor parent = Actor::New();
2757 Stage::GetCurrent().Add( parent );
2759 Actor child0 = Actor::New();
2760 parent.Add( child0 );
2762 Actor child1 = Actor::New();
2763 parent.Add( child1 );
2765 Actor child2 = Actor::New();
2766 parent.Add( child2 );
2768 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2769 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2770 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2774 int UtcDaliActorSetGetOverlay(void)
2776 TestApplication app;
2777 tet_infoline(" UtcDaliActorSetGetOverlay");
2779 Actor parent = Actor::New();
2780 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2781 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2786 int UtcDaliActorCreateDestroy(void)
2788 Actor* actor = new Actor;
2789 DALI_TEST_CHECK( actor );
2796 struct PropertyStringIndex
2798 const char * const name;
2799 const Property::Index index;
2800 const Property::Type type;
2803 const PropertyStringIndex PROPERTY_TABLE[] =
2805 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2806 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2807 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2808 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2809 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2810 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2811 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2812 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2813 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2814 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2815 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2816 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2817 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2818 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2819 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2820 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2821 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2822 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2823 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2824 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2825 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2826 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2827 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2828 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2829 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2830 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2831 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2832 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2833 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2834 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2835 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2836 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2837 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2838 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2839 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2840 { "name", Actor::Property::NAME, Property::STRING },
2841 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2842 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2843 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2844 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2845 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2846 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2847 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
2848 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2849 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2850 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2851 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2852 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2853 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2854 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2855 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2856 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2858 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2859 } // unnamed namespace
2861 int UtcDaliActorProperties(void)
2863 TestApplication app;
2865 Actor actor = Actor::New();
2867 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2869 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2870 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2871 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2872 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2877 int UtcDaliRelayoutProperties_ResizePolicies(void)
2879 TestApplication app;
2881 Actor actor = Actor::New();
2884 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2885 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2887 // Set resize policy for all dimensions
2888 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2889 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2891 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2894 // Set individual dimensions
2895 const char* const widthPolicy = "FILL_TO_PARENT";
2896 const char* const heightPolicy = "FIXED";
2898 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2899 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2901 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2902 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2907 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2909 TestApplication app;
2911 Actor actor = Actor::New();
2914 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2915 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2917 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2918 actor.SetSizeScalePolicy( policy );
2919 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2922 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2923 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2925 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2926 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2928 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2929 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2934 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2936 TestApplication app;
2938 Actor actor = Actor::New();
2941 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2942 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2944 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2945 actor.SetSizeModeFactor( sizeMode );
2946 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2949 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2951 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2952 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2957 int UtcDaliRelayoutProperties_DimensionDependency(void)
2959 TestApplication app;
2961 Actor actor = Actor::New();
2964 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2965 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2968 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2969 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2971 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2972 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2974 // Test setting another resize policy
2975 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2976 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2981 int UtcDaliRelayoutProperties_Padding(void)
2983 TestApplication app;
2985 Actor actor = Actor::New();
2988 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2991 actor.SetProperty( Actor::Property::PADDING, padding );
2992 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2994 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2999 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3001 TestApplication app;
3003 Actor actor = Actor::New();
3006 Vector2 minSize( 1.0f, 2.0f );
3008 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3009 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3011 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3013 Vector2 maxSize( 3.0f, 4.0f );
3015 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3016 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3018 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3023 int UtcDaliActorGetHeightForWidth(void)
3025 TestApplication app;
3027 Actor actor = Actor::New();
3029 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3034 int UtcDaliActorGetWidthForHeight(void)
3036 TestApplication app;
3038 Actor actor = Actor::New();
3040 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3045 int UtcDaliActorGetRelayoutSize(void)
3047 TestApplication app;
3049 Actor actor = Actor::New();
3051 // Add actor to stage
3052 Stage::GetCurrent().Add( actor );
3054 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3056 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3057 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3059 // Flush the queue and render once
3060 app.SendNotification();
3063 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3068 int UtcDaliActorSetPadding(void)
3070 TestApplication app;
3072 Actor actor = Actor::New();
3075 actor.GetPadding( padding );
3077 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3078 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3079 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3080 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3082 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3083 actor.SetPadding( padding2 );
3085 actor.GetPadding( padding );
3087 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3088 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3089 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3090 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3095 int UtcDaliActorSetMinimumSize(void)
3097 TestApplication app;
3099 Actor actor = Actor::New();
3101 Vector2 size = actor.GetMinimumSize();
3103 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3104 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3106 Vector2 size2( 1.0f, 2.0f );
3107 actor.SetMinimumSize( size2 );
3109 size = actor.GetMinimumSize();
3111 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3112 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3117 int UtcDaliActorSetMaximumSize(void)
3119 TestApplication app;
3121 Actor actor = Actor::New();
3123 Vector2 size = actor.GetMaximumSize();
3125 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3126 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3128 Vector2 size2( 1.0f, 2.0f );
3129 actor.SetMaximumSize( size2 );
3131 size = actor.GetMaximumSize();
3133 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3134 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3139 int UtcDaliActorOnRelayoutSignal(void)
3141 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3143 TestApplication application;
3146 gOnRelayoutCallBackCalled = false;
3147 gActorNamesRelayout.clear();
3149 Actor actor = Actor::New();
3150 actor.SetName( "actor" );
3151 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3154 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3156 // Add actor to stage
3157 Stage::GetCurrent().Add( actor );
3159 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3160 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3162 // Flush the queue and render once
3163 application.SendNotification();
3164 application.Render();
3166 // OnRelayout emitted
3167 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3168 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3173 int UtcDaliActorGetHierachyDepth(void)
3175 TestApplication application;
3176 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3179 /* Build tree of actors:
3189 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3191 Stage stage( Stage::GetCurrent() );
3193 Actor actorA = Actor::New();
3194 Actor actorB = Actor::New();
3195 Actor actorC = Actor::New();
3196 Actor actorD = Actor::New();
3197 Actor actorE = Actor::New();
3198 Actor actorF = Actor::New();
3200 //Test that root actor has depth equal 0
3201 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3203 //Test actors return depth -1 when not connected to the tree
3204 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3205 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3206 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3207 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3208 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3209 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3211 //Create the hierarchy
3212 stage.Add( actorA );
3213 actorA.Add( actorB );
3214 actorA.Add( actorC );
3215 actorB.Add( actorD );
3216 actorB.Add( actorE );
3217 actorC.Add( actorF );
3219 //Test actors return correct depth
3220 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3221 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3222 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3223 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3224 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3225 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3227 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3228 actorA.Remove( actorB );
3230 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3231 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3232 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3234 //Removing actorA from the stage. All actors should have depth equal -1
3235 stage.Remove( actorA );
3237 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3238 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3239 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3240 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3241 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3242 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3247 int UtcDaliActorAnchorPointPropertyAsString(void)
3249 TestApplication application;
3251 Actor actor = Actor::New();
3253 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3254 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3256 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3257 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3259 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3260 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3262 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3263 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3265 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3266 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3268 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3269 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3271 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3272 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3274 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3275 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3277 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3278 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3280 // Invalid should not change anything
3281 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3282 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3287 int UtcDaliActorParentOriginPropertyAsString(void)
3289 TestApplication application;
3291 Actor actor = Actor::New();
3293 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3294 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3296 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3297 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3299 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3300 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3302 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3303 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3305 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3306 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3308 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3309 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3311 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3312 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3314 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3315 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3317 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3318 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3320 // Invalid should not change anything
3321 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3322 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3327 int UtcDaliActorColorModePropertyAsString(void)
3329 TestApplication application;
3331 Actor actor = Actor::New();
3333 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3334 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3336 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3337 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3339 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3340 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3342 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3343 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3345 // Invalid should not change anything
3346 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3347 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3352 int UtcDaliActorPositionInheritancePropertyAsString(void)
3354 TestApplication application;
3356 Actor actor = Actor::New();
3358 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3359 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3361 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3362 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3364 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3365 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3367 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3368 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3370 // Invalid should not change anything
3371 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3372 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3377 int UtcDaliActorDrawModePropertyAsString(void)
3379 TestApplication application;
3381 Actor actor = Actor::New();
3383 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3384 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3386 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3387 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3389 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3390 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3392 // Invalid should not change anything
3393 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3394 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );