2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/dali-core.h>
21 #include <cfloat> // For FLT_MAX
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
34 void utc_dali_actor_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_actor_cleanup(void)
41 test_return_value = TET_PASS;
46 bool gTouchCallBackCalled=false;
47 bool gTouchCallBackCalled2=false;
48 bool gTouchCallBackCalled3=false;
50 bool gHoverCallBackCalled=false;
52 static bool gTestConstraintCalled;
54 LayoutDirection::Type gLayoutDirectionType;
58 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
60 gTestConstraintCalled = true;
65 * TestConstraint reference.
66 * When constraint is called, the resultRef is updated
67 * with the value supplied.
70 struct TestConstraintRef
72 TestConstraintRef(unsigned int& resultRef, unsigned int value)
73 : mResultRef(resultRef),
78 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
83 unsigned int& mResultRef;
87 static bool TestCallback(Actor actor, const TouchEvent& event)
89 gTouchCallBackCalled = true;
94 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
96 gTouchCallBackCalled = true;
101 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
103 gTouchCallBackCalled2 = true;
108 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
110 gTouchCallBackCalled3 = true;
115 static void ResetTouchCallbacks()
117 gTouchCallBackCalled = false;
118 gTouchCallBackCalled2 = false;
119 gTouchCallBackCalled3 = false;
122 static bool TestCallback3(Actor actor, const HoverEvent& event)
124 gHoverCallBackCalled = true;
129 // validation stuff for onstage & offstage signals
130 static std::vector< std::string > gActorNamesOnOffStage;
131 static int gOnStageCallBackCalled;
132 void OnStageCallback( Actor actor )
134 ++gOnStageCallBackCalled;
135 gActorNamesOnOffStage.push_back( actor.GetName() );
136 DALI_TEST_CHECK( actor.OnStage() == true );
138 static int gOffStageCallBackCalled;
139 void OffStageCallback( Actor actor )
141 ++gOffStageCallBackCalled;
142 gActorNamesOnOffStage.push_back( actor.GetName() );
143 DALI_TEST_CHECK( actor.OnStage() == false );
146 struct PositionComponentConstraint
148 PositionComponentConstraint(){}
150 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
152 const Matrix& m = inputs[0]->GetMatrix();
155 m.GetTransformComponents(pos, rot, scale);
159 struct OrientationComponentConstraint
161 OrientationComponentConstraint(){}
163 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
165 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
168 orientation = parentOrientation;
173 static bool gOnRelayoutCallBackCalled = false;
174 static std::vector< std::string > gActorNamesRelayout;
176 void OnRelayoutCallback( Actor actor )
178 gOnRelayoutCallBackCalled = true;
179 gActorNamesRelayout.push_back( actor.GetName() );
182 struct VisibilityChangedFunctorData
184 VisibilityChangedFunctorData()
187 type( DevelActor::VisibilityChange::SELF ),
196 type = DevelActor::VisibilityChange::SELF;
200 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
202 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
203 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
204 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
205 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
208 void Check( bool compareCalled, const std::string& location )
210 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
215 DevelActor::VisibilityChange::Type type;
219 struct VisibilityChangedFunctor
221 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
223 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
226 data.visible = visible;
231 VisibilityChangedFunctorData& data;
235 struct VisibilityChangedVoidFunctor
237 VisibilityChangedVoidFunctor(bool& signalCalled)
238 : mSignalCalled( signalCalled )
243 mSignalCalled = true;
249 struct ChildOrderChangedFunctor
251 ChildOrderChangedFunctor(bool& signalCalled)
252 : mSignalCalled( signalCalled )
257 mSignalCalled = true;
263 } // anonymous namespace
266 //& purpose: Testing New API
267 int UtcDaliActorNew(void)
269 TestApplication application;
271 Actor actor = Actor::New();
273 DALI_TEST_CHECK(actor);
277 //& purpose: Testing Dali::Actor::DownCast()
278 int UtcDaliActorDownCastP(void)
280 TestApplication application;
281 tet_infoline("Testing Dali::Actor::DownCast()");
283 Actor actor = Actor::New();
284 BaseHandle object(actor);
285 Actor actor2 = Actor::DownCast(object);
286 DALI_TEST_CHECK(actor2);
290 //& purpose: Testing Dali::Actor::DownCast()
291 int UtcDaliActorDownCastN(void)
293 TestApplication application;
294 tet_infoline("Testing Dali::Actor::DownCast()");
296 BaseHandle unInitializedObject;
297 Actor actor = Actor::DownCast(unInitializedObject);
298 DALI_TEST_CHECK(!actor);
302 //& purpose: Testing Dali::Actor::GetName()
303 int UtcDaliActorGetName(void)
305 TestApplication application;
307 Actor actor = Actor::New();
309 DALI_TEST_CHECK(actor.GetName().empty());
313 //& purpose: Testing Dali::Actor::SetName()
314 int UtcDaliActorSetName(void)
316 TestApplication application;
318 string str("ActorName");
319 Actor actor = Actor::New();
322 DALI_TEST_CHECK(actor.GetName() == str);
326 int UtcDaliActorGetId(void)
328 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
329 TestApplication application;
331 Actor first = Actor::New();
332 Actor second = Actor::New();
333 Actor third = Actor::New();
335 DALI_TEST_CHECK(first.GetId() != second.GetId());
336 DALI_TEST_CHECK(second.GetId() != third.GetId());
340 int UtcDaliActorIsRoot(void)
342 TestApplication application;
344 Actor actor = Actor::New();
345 DALI_TEST_CHECK(!actor.IsRoot());
347 // get the root layer
348 actor = Stage::GetCurrent().GetLayer( 0 );
349 DALI_TEST_CHECK( actor.IsRoot() );
353 int UtcDaliActorOnStage(void)
355 TestApplication application;
357 Actor actor = Actor::New();
358 DALI_TEST_CHECK( !actor.OnStage() );
360 // get the root layer
361 actor = Stage::GetCurrent().GetLayer( 0 );
362 DALI_TEST_CHECK( actor.OnStage() );
366 int UtcDaliActorIsLayer(void)
368 TestApplication application;
370 Actor actor = Actor::New();
371 DALI_TEST_CHECK( !actor.IsLayer() );
373 // get the root layer
374 actor = Stage::GetCurrent().GetLayer( 0 );
375 DALI_TEST_CHECK( actor.IsLayer() );
379 int UtcDaliActorGetLayer(void)
381 TestApplication application;
383 Actor actor = Actor::New();
384 Stage::GetCurrent().Add(actor);
385 Layer layer = actor.GetLayer();
387 DALI_TEST_CHECK(layer);
389 // get the root layers layer
390 actor = Stage::GetCurrent().GetLayer( 0 );
391 DALI_TEST_CHECK( actor.GetLayer() );
395 int UtcDaliActorAddP(void)
397 tet_infoline("Testing Actor::Add");
398 TestApplication application;
400 Actor parent = Actor::New();
401 Actor child = Actor::New();
403 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
407 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
409 Actor parent2 = Actor::New();
410 parent2.Add( child );
412 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
413 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
415 // try Adding to same parent again, works
416 parent2.Add( child );
417 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
419 // try reparenting an orphaned child
421 Actor temporaryParent = Actor::New();
422 temporaryParent.Add( child );
423 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
425 // temporaryParent has now died, reparent the orphaned child
426 parent2.Add( child );
427 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
432 int UtcDaliActorAddN(void)
434 tet_infoline("Testing Actor::Add");
435 TestApplication application;
437 Actor child = Actor::New();
439 Actor parent2 = Actor::New();
440 parent2.Add( child );
445 parent2.Add( parent2 );
446 tet_printf("Assertion test failed - no Exception\n" );
447 tet_result(TET_FAIL);
449 catch(Dali::DaliException& e)
451 DALI_TEST_PRINT_ASSERT( e );
452 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
453 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
457 tet_printf("Assertion test failed - wrong Exception\n" );
458 tet_result(TET_FAIL);
461 // try reparenting root
464 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
465 tet_printf("Assertion test failed - no Exception\n" );
466 tet_result(TET_FAIL);
468 catch(Dali::DaliException& e)
470 DALI_TEST_PRINT_ASSERT( e );
471 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
472 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
476 tet_printf("Assertion test failed - wrong Exception\n" );
477 tet_result(TET_FAIL);
484 parent2.Add( empty );
485 tet_printf("Assertion test failed - no Exception\n" );
486 tet_result(TET_FAIL);
488 catch(Dali::DaliException& e)
490 DALI_TEST_PRINT_ASSERT( e );
491 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
492 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
496 tet_printf("Assertion test failed - wrong Exception\n" );
497 tet_result(TET_FAIL);
503 int UtcDaliActorRemoveN(void)
505 tet_infoline("Testing Actor::Remove");
506 TestApplication application;
508 Actor parent = Actor::New();
509 Actor child = Actor::New();
510 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
513 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
515 parent.Remove(child);
516 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
518 // remove again, no problem
519 parent.Remove(child);
520 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
524 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
525 // try Remove self, its a no-op
526 parent.Remove( parent );
527 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
533 parent.Remove( empty );
534 tet_printf("Assertion test failed - no Exception\n" );
535 tet_result(TET_FAIL);
537 catch(Dali::DaliException& e)
539 DALI_TEST_PRINT_ASSERT( e );
540 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
541 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
545 tet_printf("Assertion test failed - wrong Exception\n" );
546 tet_result(TET_FAIL);
551 int UtcDaliActorRemoveP(void)
553 TestApplication application;
555 Actor parent = Actor::New();
556 Actor child = Actor::New();
557 Actor random = Actor::New();
559 Stage::GetCurrent().Add( parent );
561 DALI_TEST_CHECK(parent.GetChildCount() == 0);
565 DALI_TEST_CHECK(parent.GetChildCount() == 1);
567 parent.Remove(random);
569 DALI_TEST_CHECK(parent.GetChildCount() == 1);
571 Stage::GetCurrent().Remove( parent );
573 DALI_TEST_CHECK(parent.GetChildCount() == 1);
577 int UtcDaliActorGetChildCount(void)
579 TestApplication application;
581 Actor parent = Actor::New();
582 Actor child = Actor::New();
584 DALI_TEST_CHECK(parent.GetChildCount() == 0);
588 DALI_TEST_CHECK(parent.GetChildCount() == 1);
592 int UtcDaliActorGetChildren01(void)
594 TestApplication application;
596 Actor parent = Actor::New();
597 Actor first = Actor::New();
598 Actor second = Actor::New();
599 Actor third = Actor::New();
605 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
606 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
607 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
611 int UtcDaliActorGetChildren02(void)
613 TestApplication application;
615 Actor parent = Actor::New();
616 Actor first = Actor::New();
617 Actor second = Actor::New();
618 Actor third = Actor::New();
624 const Actor& constParent = parent;
626 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
627 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
628 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
632 int UtcDaliActorGetParent01(void)
634 TestApplication application;
636 Actor parent = Actor::New();
637 Actor child = Actor::New();
641 DALI_TEST_CHECK(child.GetParent() == parent);
645 int UtcDaliActorGetParent02(void)
647 TestApplication application;
649 Actor actor = Actor::New();
651 DALI_TEST_CHECK(!actor.GetParent());
655 int UtcDaliActorCustomProperty(void)
657 TestApplication application;
659 Actor actor = Actor::New();
660 Stage::GetCurrent().Add( actor );
662 float startValue(1.0f);
663 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
664 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
666 application.SendNotification();
667 application.Render(0);
668 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
670 actor.SetProperty( index, 5.0f );
672 application.SendNotification();
673 application.Render(0);
674 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
678 int UtcDaliActorCustomPropertyIntToFloat(void)
680 TestApplication application;
682 Actor actor = Actor::New();
683 Stage::GetCurrent().Add( actor );
685 float startValue(5.0f);
686 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
687 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
689 application.SendNotification();
690 application.Render(0);
691 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
693 actor.SetProperty( index, int(1) );
695 application.SendNotification();
696 application.Render(0);
697 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
701 int UtcDaliActorCustomPropertyFloatToInt(void)
703 TestApplication application;
705 Actor actor = Actor::New();
706 Stage::GetCurrent().Add( actor );
709 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
710 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
712 application.SendNotification();
713 application.Render(0);
714 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
716 actor.SetProperty( index, float(1.5) );
718 application.SendNotification();
719 application.Render(0);
720 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
724 int UtcDaliActorSetParentOrigin(void)
726 TestApplication application;
728 Actor actor = Actor::New();
730 Vector3 vector(0.7f, 0.8f, 0.9f);
731 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
733 actor.SetParentOrigin(vector);
735 // flush the queue and render once
736 application.SendNotification();
737 application.Render();
739 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
741 Stage::GetCurrent().Add( actor );
743 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
745 // flush the queue and render once
746 application.SendNotification();
747 application.Render();
749 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
751 Stage::GetCurrent().Remove( actor );
755 int UtcDaliActorSetParentOriginIndividual(void)
757 TestApplication application;
759 Actor actor = Actor::New();
761 Vector3 vector(0.7f, 0.8f, 0.9f);
762 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
764 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
766 // flush the queue and render once
767 application.SendNotification();
768 application.Render();
770 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
772 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
774 // flush the queue and render once
775 application.SendNotification();
776 application.Render();
778 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
780 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
782 // flush the queue and render once
783 application.SendNotification();
784 application.Render();
786 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
791 int UtcDaliActorGetCurrentParentOrigin(void)
793 TestApplication application;
795 Actor actor = Actor::New();
797 Vector3 vector(0.7f, 0.8f, 0.9f);
798 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
800 actor.SetParentOrigin(vector);
802 // flush the queue and render once
803 application.SendNotification();
804 application.Render();
806 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
810 int UtcDaliActorSetAnchorPoint(void)
812 TestApplication application;
814 Actor actor = Actor::New();
816 Vector3 vector(0.7f, 0.8f, 0.9f);
817 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
819 actor.SetAnchorPoint(vector);
821 // flush the queue and render once
822 application.SendNotification();
823 application.Render();
825 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
827 Stage::GetCurrent().Add( actor );
829 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
830 // flush the queue and render once
831 application.SendNotification();
832 application.Render();
834 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
836 Stage::GetCurrent().Remove( actor );
840 int UtcDaliActorSetAnchorPointIndividual(void)
842 TestApplication application;
844 Actor actor = Actor::New();
846 Vector3 vector(0.7f, 0.8f, 0.9f);
847 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
849 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
851 // flush the queue and render once
852 application.SendNotification();
853 application.Render();
855 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
857 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
859 // flush the queue and render once
860 application.SendNotification();
861 application.Render();
863 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
865 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
867 // flush the queue and render once
868 application.SendNotification();
869 application.Render();
871 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
876 int UtcDaliActorGetCurrentAnchorPoint(void)
878 TestApplication application;
880 Actor actor = Actor::New();
882 Vector3 vector(0.7f, 0.8f, 0.9f);
883 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
885 actor.SetAnchorPoint(vector);
887 // flush the queue and render once
888 application.SendNotification();
889 application.Render();
891 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
895 // SetSize(float width, float height)
896 int UtcDaliActorSetSize01(void)
898 TestApplication application;
900 Actor actor = Actor::New();
901 Vector3 vector(100.0f, 100.0f, 0.0f);
903 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
905 actor.SetSize(vector.x, vector.y);
907 // Immediately retrieve the size after setting
908 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
909 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
910 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
911 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
912 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
914 // Flush the queue and render once
915 application.SendNotification();
916 application.Render();
918 // Check the size in the new frame
919 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
921 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
922 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
923 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
924 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
925 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
927 // Check async behaviour
928 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
929 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
930 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
931 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
932 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
934 // Change the resize policy and check whether the size stays the same
935 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
937 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
938 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
940 // Set a new size after resize policy is changed and check the new size
941 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
943 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
944 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
946 // Change the resize policy again and check whether the new size stays the same
947 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
949 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
950 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
952 // Set another new size after resize policy is changed and check the new size
953 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
955 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
956 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
961 // SetSize(float width, float height, float depth)
962 int UtcDaliActorSetSize02(void)
964 TestApplication application;
966 Actor actor = Actor::New();
967 Vector3 vector(100.0f, 100.0f, 100.0f);
969 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
971 actor.SetSize(vector.x, vector.y, vector.z);
973 // Immediately check the size after setting
974 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
975 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
977 // flush the queue and render once
978 application.SendNotification();
979 application.Render();
981 // Check the size in the new frame
982 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
984 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
985 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
990 // SetSize(Vector2 size)
991 int UtcDaliActorSetSize03(void)
993 TestApplication application;
995 Actor actor = Actor::New();
996 Vector3 vector(100.0f, 100.0f, 0.0f);
998 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1000 actor.SetSize(Vector2(vector.x, vector.y));
1002 // Immediately check the size after setting
1003 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1004 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1006 // flush the queue and render once
1007 application.SendNotification();
1008 application.Render();
1010 // Check the size in the new frame
1011 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1013 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1014 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1019 // SetSize(Vector3 size)
1020 int UtcDaliActorSetSize04(void)
1022 TestApplication application;
1024 Actor actor = Actor::New();
1025 Vector3 vector(100.0f, 100.0f, 100.0f);
1027 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1029 actor.SetSize(vector);
1031 // Immediately check the size after setting
1032 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1033 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1035 // flush the queue and render once
1036 application.SendNotification();
1037 application.Render();
1039 // Check the size in the new frame
1040 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1042 Stage::GetCurrent().Add( actor );
1043 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
1045 // Immediately check the size after setting
1046 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1047 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1049 // flush the queue and render once
1050 application.SendNotification();
1051 application.Render();
1053 // Check the size in the new frame
1054 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
1056 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1057 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1059 Stage::GetCurrent().Remove( actor );
1063 int UtcDaliActorSetSizeIndividual(void)
1065 TestApplication application;
1067 Actor actor = Actor::New();
1069 Vector3 vector(0.7f, 0.8f, 0.9f);
1070 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1072 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1074 // Immediately check the width after setting
1075 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1076 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1078 // flush the queue and render once
1079 application.SendNotification();
1080 application.Render();
1082 // Check the width in the new frame
1083 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1085 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1086 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1088 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1090 // Immediately check the height after setting
1091 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1092 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1094 // flush the queue and render once
1095 application.SendNotification();
1096 application.Render();
1098 // Check the height in the new frame
1099 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1101 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1102 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1104 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1106 // Immediately check the depth after setting
1107 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1108 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1110 // flush the queue and render once
1111 application.SendNotification();
1112 application.Render();
1114 // Check the depth in the new frame
1115 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1117 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1118 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1120 // Change the resize policy and check whether the size stays the same
1121 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1123 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1124 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1126 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1127 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1129 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1130 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1132 // Change the resize policy again and check whether the size stays the same
1133 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1135 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1136 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1138 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1139 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1141 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1142 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1147 int UtcDaliActorSetSizeIndividual02(void)
1149 TestApplication application;
1151 Actor actor = Actor::New();
1152 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1153 Stage::GetCurrent().Add( actor );
1155 Vector3 vector( 100.0f, 200.0f, 400.0f );
1156 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1158 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1159 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1161 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1162 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1164 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1165 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1167 // flush the queue and render once
1168 application.SendNotification();
1169 application.Render();
1171 // Check the width in the new frame
1172 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1173 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1179 int UtcDaliActorGetCurrentSize(void)
1181 TestApplication application;
1183 Actor actor = Actor::New();
1184 Vector3 vector(100.0f, 100.0f, 20.0f);
1186 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1188 actor.SetSize(vector);
1190 // flush the queue and render once
1191 application.SendNotification();
1192 application.Render();
1194 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1198 int UtcDaliActorGetNaturalSize(void)
1200 TestApplication application;
1202 Actor actor = Actor::New();
1203 Vector3 vector( 0.0f, 0.0f, 0.0f );
1205 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1210 int UtcDaliActorGetCurrentSizeImmediate(void)
1212 TestApplication application;
1214 Actor actor = Actor::New();
1215 Vector3 vector(100.0f, 100.0f, 20.0f);
1217 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1218 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1220 actor.SetSize(vector);
1222 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1223 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1225 // flush the queue and render once
1226 application.SendNotification();
1227 application.Render();
1229 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1230 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1233 // Build the animation
1234 const float durationSeconds = 2.0f;
1235 Animation animation = Animation::New( durationSeconds );
1236 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1237 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1239 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1241 // Start the animation
1244 application.SendNotification();
1245 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1247 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1252 // SetPosition(float x, float y)
1253 int UtcDaliActorSetPosition01(void)
1255 TestApplication application;
1257 Actor actor = Actor::New();
1259 // Set to random to start off with
1260 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1262 Vector3 vector(100.0f, 100.0f, 0.0f);
1264 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1266 actor.SetPosition(vector.x, vector.y);
1267 // flush the queue and render once
1268 application.SendNotification();
1269 application.Render();
1270 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1272 Stage::GetCurrent().Add( actor );
1273 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1274 // flush the queue and render once
1275 application.SendNotification();
1276 application.Render();
1277 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1282 // flush the queue and render once
1283 application.SendNotification();
1284 application.Render();
1285 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1287 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1288 // flush the queue and render once
1289 application.SendNotification();
1290 application.Render();
1291 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1293 Stage::GetCurrent().Remove( actor );
1297 // SetPosition(float x, float y, float z)
1298 int UtcDaliActorSetPosition02(void)
1300 TestApplication application;
1302 Actor actor = Actor::New();
1304 // Set to random to start off with
1305 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1307 Vector3 vector(100.0f, 100.0f, 100.0f);
1309 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1311 actor.SetPosition(vector.x, vector.y, vector.z);
1313 // flush the queue and render once
1314 application.SendNotification();
1315 application.Render();
1317 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1321 // SetPosition(Vector3 position)
1322 int UtcDaliActorSetPosition03(void)
1324 TestApplication application;
1326 Actor actor = Actor::New();
1328 // Set to random to start off with
1329 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1331 Vector3 vector(100.0f, 100.0f, 100.0f);
1333 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1335 actor.SetPosition(vector);
1337 // flush the queue and render once
1338 application.SendNotification();
1339 application.Render();
1341 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1345 int UtcDaliActorSetX(void)
1347 TestApplication application;
1349 Actor actor = Actor::New();
1351 Vector3 vector(100.0f, 0.0f, 0.0f);
1353 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1357 // flush the queue and render once
1358 application.SendNotification();
1359 application.Render();
1361 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1365 int UtcDaliActorSetY(void)
1367 TestApplication application;
1369 Actor actor = Actor::New();
1371 Vector3 vector(0.0f, 100.0f, 0.0f);
1373 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1377 // flush the queue and render once
1378 application.SendNotification();
1379 application.Render();
1381 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1385 int UtcDaliActorSetZ(void)
1387 TestApplication application;
1389 Actor actor = Actor::New();
1391 Vector3 vector(0.0f, 0.0f, 100.0f);
1393 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1397 // flush the queue and render once
1398 application.SendNotification();
1399 application.Render();
1401 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1405 int UtcDaliActorSetPositionProperties(void)
1407 TestApplication application;
1409 Actor actor = Actor::New();
1411 Vector3 vector(0.7f, 0.8f, 0.9f);
1412 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1414 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1415 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1416 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1418 // flush the queue and render once
1419 application.SendNotification();
1420 application.Render();
1422 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1423 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1424 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1425 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1426 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1428 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1429 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1430 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1432 // flush the queue and render once
1433 application.SendNotification();
1434 application.Render();
1436 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1437 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1438 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1439 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1440 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1442 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1443 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1444 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1446 // flush the queue and render once
1447 application.SendNotification();
1448 application.Render();
1450 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1451 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1452 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1453 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1454 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1459 int UtcDaliActorTranslateBy(void)
1461 TestApplication application;
1463 Actor actor = Actor::New();
1464 Vector3 vector(100.0f, 100.0f, 100.0f);
1466 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1468 actor.SetPosition(vector);
1470 // flush the queue and render once
1471 application.SendNotification();
1472 application.Render();
1474 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1476 actor.TranslateBy(vector);
1478 // flush the queue and render once
1479 application.SendNotification();
1480 application.Render();
1482 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1486 int UtcDaliActorGetCurrentPosition(void)
1488 TestApplication application;
1490 Actor actor = Actor::New();
1491 Vector3 setVector(100.0f, 100.0f, 0.0f);
1492 actor.SetPosition(setVector);
1494 // flush the queue and render once
1495 application.SendNotification();
1496 application.Render();
1498 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1502 int UtcDaliActorGetCurrentWorldPosition(void)
1504 TestApplication application;
1506 Actor parent = Actor::New();
1507 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1508 parent.SetPosition( parentPosition );
1509 parent.SetParentOrigin( ParentOrigin::CENTER );
1510 parent.SetAnchorPoint( AnchorPoint::CENTER );
1511 Stage::GetCurrent().Add( parent );
1513 Actor child = Actor::New();
1514 child.SetParentOrigin( ParentOrigin::CENTER );
1515 child.SetAnchorPoint( AnchorPoint::CENTER );
1516 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1517 child.SetPosition( childPosition );
1518 parent.Add( child );
1520 // The actors should not have a world position yet
1521 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1522 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1524 application.SendNotification();
1525 application.Render(0);
1527 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1528 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1530 // The actors should have a world position now
1531 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1532 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1536 int UtcDaliActorInheritPosition(void)
1538 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1539 TestApplication application;
1541 Actor parent = Actor::New();
1542 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1543 parent.SetPosition( parentPosition );
1544 parent.SetParentOrigin( ParentOrigin::CENTER );
1545 parent.SetAnchorPoint( AnchorPoint::CENTER );
1546 Stage::GetCurrent().Add( parent );
1548 Actor child = Actor::New();
1549 child.SetParentOrigin( ParentOrigin::CENTER );
1550 child.SetAnchorPoint( AnchorPoint::CENTER );
1551 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1552 child.SetPosition( childPosition );
1553 parent.Add( child );
1555 // The actors should not have a world position yet
1556 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1557 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1559 // first test default, which is to inherit position
1560 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1561 application.SendNotification();
1562 application.Render(0); // should only really call Update as Render is not required to update scene
1563 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1564 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1565 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1566 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1569 //Change child position
1570 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1571 child.SetPosition( childOffset );
1573 // Change inheritance mode to not inherit
1574 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1575 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1576 application.SendNotification();
1577 application.Render(0); // should only really call Update as Render is not required to update scene
1578 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1579 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1580 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1581 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1585 int UtcDaliActorSetInheritPosition(void)
1587 tet_infoline("Testing Actor::SetInheritPosition");
1588 TestApplication application;
1590 Actor parent = Actor::New();
1591 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1592 parent.SetPosition( parentPosition );
1593 parent.SetParentOrigin( ParentOrigin::CENTER );
1594 parent.SetAnchorPoint( AnchorPoint::CENTER );
1595 Stage::GetCurrent().Add( parent );
1597 Actor child = Actor::New();
1598 child.SetParentOrigin( ParentOrigin::CENTER );
1599 child.SetAnchorPoint( AnchorPoint::CENTER );
1600 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1601 child.SetPosition( childPosition );
1602 parent.Add( child );
1604 // The actors should not have a world position yet
1605 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1606 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1608 // first test default, which is to inherit position
1609 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1610 application.SendNotification();
1611 application.Render(0); // should only really call Update as Render is not required to update scene
1612 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1613 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1614 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1615 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1617 //Change child position
1618 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1619 child.SetPosition( childOffset );
1621 // Use local position as world postion
1622 child.SetInheritPosition( false );
1623 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1624 application.SendNotification();
1625 application.Render(0); // should only really call Update as Render is not required to update scene
1626 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1627 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1628 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1629 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1631 //Change back to inherit position from parent
1632 child.SetInheritPosition( true );
1633 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1634 application.SendNotification();
1635 application.Render(0); // should only really call Update as Render is not required to update scene
1636 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1637 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1638 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1639 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1643 // SetOrientation(float angleRadians, Vector3 axis)
1644 int UtcDaliActorSetOrientation01(void)
1646 TestApplication application;
1648 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1649 Actor actor = Actor::New();
1651 actor.SetOrientation(rotation);
1653 // flush the queue and render once
1654 application.SendNotification();
1655 application.Render();
1657 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1661 int UtcDaliActorSetOrientation02(void)
1663 TestApplication application;
1665 Actor actor = Actor::New();
1667 Radian angle( 0.785f );
1668 Vector3 axis(1.0f, 1.0f, 0.0f);
1670 actor.SetOrientation( angle, axis);
1671 Quaternion rotation( angle, axis );
1672 // flush the queue and render once
1673 application.SendNotification();
1674 application.Render();
1675 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1677 Stage::GetCurrent().Add( actor );
1678 actor.RotateBy( Degree( 360 ), axis);
1679 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1681 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1682 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1683 // flush the queue and render once
1684 application.SendNotification();
1685 application.Render();
1686 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1688 actor.SetOrientation( angle, axis);
1689 // flush the queue and render once
1690 application.SendNotification();
1691 application.Render();
1692 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1694 Stage::GetCurrent().Remove( actor );
1698 // SetOrientation(float angleRadians, Vector3 axis)
1699 int UtcDaliActorSetOrientationProperty(void)
1701 TestApplication application;
1703 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1704 Actor actor = Actor::New();
1706 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1707 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1709 // flush the queue and render once
1710 application.SendNotification();
1711 application.Render();
1713 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1714 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1715 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1719 // RotateBy(float angleRadians, Vector3 axis)
1720 int UtcDaliActorRotateBy01(void)
1722 TestApplication application;
1724 Actor actor = Actor::New();
1726 Radian angle( M_PI * 0.25f );
1727 actor.RotateBy(( angle ), Vector3::ZAXIS);
1728 // flush the queue and render once
1729 application.SendNotification();
1730 application.Render();
1731 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1733 Stage::GetCurrent().Add( actor );
1735 actor.RotateBy( angle, Vector3::ZAXIS);
1736 // flush the queue and render once
1737 application.SendNotification();
1738 application.Render();
1739 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1741 Stage::GetCurrent().Remove( actor );
1745 // RotateBy(Quaternion relativeRotation)
1746 int UtcDaliActorRotateBy02(void)
1748 TestApplication application;
1750 Actor actor = Actor::New();
1752 Radian angle( M_PI * 0.25f );
1753 Quaternion rotation(angle, Vector3::ZAXIS);
1754 actor.RotateBy(rotation);
1755 // flush the queue and render once
1756 application.SendNotification();
1757 application.Render();
1758 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1760 actor.RotateBy(rotation);
1761 // flush the queue and render once
1762 application.SendNotification();
1763 application.Render();
1764 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1768 int UtcDaliActorGetCurrentOrientation(void)
1770 TestApplication application;
1771 Actor actor = Actor::New();
1773 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1774 actor.SetOrientation(rotation);
1775 // flush the queue and render once
1776 application.SendNotification();
1777 application.Render();
1778 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1782 int UtcDaliActorGetCurrentWorldOrientation(void)
1784 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1785 TestApplication application;
1787 Actor parent = Actor::New();
1788 Radian rotationAngle( Degree(90.0f) );
1789 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1790 parent.SetOrientation( rotation );
1791 Stage::GetCurrent().Add( parent );
1793 Actor child = Actor::New();
1794 child.SetOrientation( rotation );
1795 parent.Add( child );
1797 // The actors should not have a world rotation yet
1798 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1799 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1801 application.SendNotification();
1802 application.Render(0);
1804 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1805 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1807 // The actors should have a world rotation now
1808 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1809 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1811 // turn off child rotation inheritance
1812 child.SetInheritOrientation( false );
1813 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1814 application.SendNotification();
1815 application.Render(0);
1817 // The actors should have a world rotation now
1818 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1819 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1823 // SetScale(float scale)
1824 int UtcDaliActorSetScale01(void)
1826 TestApplication application;
1828 Actor actor = Actor::New();
1830 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1831 actor.SetScale(0.25f);
1833 Vector3 scale(10.0f, 10.0f, 10.0f);
1834 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1836 actor.SetScale(scale.x);
1838 // flush the queue and render once
1839 application.SendNotification();
1840 application.Render();
1842 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1846 // SetScale(float scaleX, float scaleY, float scaleZ)
1847 int UtcDaliActorSetScale02(void)
1849 TestApplication application;
1850 Vector3 scale(10.0f, 10.0f, 10.0f);
1852 Actor actor = Actor::New();
1854 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1855 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1857 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1859 actor.SetScale(scale.x, scale.y, scale.z);
1860 // flush the queue and render once
1861 application.SendNotification();
1862 application.Render();
1863 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1865 // add to stage and test
1866 Stage::GetCurrent().Add( actor );
1867 actor.SetScale( 2.0f, 2.0f, 2.0f );
1868 // flush the queue and render once
1869 application.SendNotification();
1870 application.Render();
1871 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1873 Stage::GetCurrent().Remove( actor );
1878 // SetScale(Vector3 scale)
1879 int UtcDaliActorSetScale03(void)
1881 TestApplication application;
1882 Vector3 scale(10.0f, 10.0f, 10.0f);
1884 Actor actor = Actor::New();
1886 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1887 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1889 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1891 actor.SetScale(scale);
1893 // flush the queue and render once
1894 application.SendNotification();
1895 application.Render();
1897 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1901 int UtcDaliActorSetScaleIndividual(void)
1903 TestApplication application;
1905 Actor actor = Actor::New();
1907 Vector3 vector(0.7f, 0.8f, 0.9f);
1908 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1910 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1911 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1913 // flush the queue and render once
1914 application.SendNotification();
1915 application.Render();
1917 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1918 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1919 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1921 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1922 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1924 // flush the queue and render once
1925 application.SendNotification();
1926 application.Render();
1928 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1929 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1930 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1932 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1933 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1935 // flush the queue and render once
1936 application.SendNotification();
1937 application.Render();
1939 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1940 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1941 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1943 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1944 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1949 int UtcDaliActorScaleBy(void)
1951 TestApplication application;
1952 Actor actor = Actor::New();
1953 Vector3 vector(100.0f, 100.0f, 100.0f);
1955 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1957 actor.SetScale(vector);
1959 // flush the queue and render once
1960 application.SendNotification();
1961 application.Render();
1963 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1965 actor.ScaleBy(vector);
1967 // flush the queue and render once
1968 application.SendNotification();
1969 application.Render();
1971 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1975 int UtcDaliActorGetCurrentScale(void)
1977 TestApplication application;
1978 Vector3 scale(12.0f, 1.0f, 2.0f);
1980 Actor actor = Actor::New();
1982 actor.SetScale(scale);
1984 // flush the queue and render once
1985 application.SendNotification();
1986 application.Render();
1988 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1992 int UtcDaliActorGetCurrentWorldScale(void)
1994 TestApplication application;
1996 Actor parent = Actor::New();
1997 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1998 parent.SetScale( parentScale );
1999 Stage::GetCurrent().Add( parent );
2001 Actor child = Actor::New();
2002 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2003 child.SetScale( childScale );
2004 parent.Add( child );
2006 // The actors should not have a scale yet
2007 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2008 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2010 // The actors should not have a world scale yet
2011 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2012 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2014 application.SendNotification();
2015 application.Render(0);
2017 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2018 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2020 // The actors should have a world scale now
2021 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2022 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2026 int UtcDaliActorInheritScale(void)
2028 tet_infoline("Testing Actor::SetInheritScale");
2029 TestApplication application;
2031 Actor parent = Actor::New();
2032 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2033 parent.SetScale( parentScale );
2034 Stage::GetCurrent().Add( parent );
2036 Actor child = Actor::New();
2037 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2038 child.SetScale( childScale );
2039 parent.Add( child );
2041 application.SendNotification();
2042 application.Render(0);
2044 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2045 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2047 child.SetInheritScale( false );
2048 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2050 application.SendNotification();
2051 application.Render(0);
2053 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2057 int UtcDaliActorSetVisible(void)
2059 TestApplication application;
2061 Actor actor = Actor::New();
2062 actor.SetVisible(false);
2063 // flush the queue and render once
2064 application.SendNotification();
2065 application.Render();
2066 DALI_TEST_CHECK(actor.IsVisible() == false);
2068 actor.SetVisible(true);
2069 // flush the queue and render once
2070 application.SendNotification();
2071 application.Render();
2072 DALI_TEST_CHECK(actor.IsVisible() == true);
2074 // put actor on stage
2075 Stage::GetCurrent().Add( actor );
2076 actor.SetVisible(false);
2077 // flush the queue and render once
2078 application.SendNotification();
2079 application.Render();
2080 DALI_TEST_CHECK(actor.IsVisible() == false);
2084 int UtcDaliActorIsVisible(void)
2086 TestApplication application;
2088 Actor actor = Actor::New();
2090 DALI_TEST_CHECK(actor.IsVisible() == true);
2094 int UtcDaliActorSetOpacity(void)
2096 TestApplication application;
2098 Actor actor = Actor::New();
2099 // initial opacity is 1
2100 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2102 actor.SetOpacity( 0.4f);
2103 // flush the queue and render once
2104 application.SendNotification();
2105 application.Render();
2106 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2108 // change opacity, actor is on stage to change is not immediate
2109 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2110 // flush the queue and render once
2111 application.SendNotification();
2112 application.Render();
2113 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2115 // put actor on stage
2116 Stage::GetCurrent().Add( actor );
2118 // change opacity, actor is on stage to change is not immediate
2119 actor.SetOpacity( 0.9f );
2120 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2121 // flush the queue and render once
2122 application.SendNotification();
2123 application.Render();
2124 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2126 // change opacity, actor is on stage to change is not immediate
2127 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2128 // flush the queue and render once
2129 application.SendNotification();
2130 application.Render();
2131 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2135 int UtcDaliActorGetCurrentOpacity(void)
2137 TestApplication application;
2139 Actor actor = Actor::New();
2140 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2142 actor.SetOpacity(0.5f);
2143 // flush the queue and render once
2144 application.SendNotification();
2145 application.Render();
2146 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2150 int UtcDaliActorSetSensitive(void)
2152 TestApplication application;
2153 Actor actor = Actor::New();
2155 bool sensitive = !actor.IsSensitive();
2157 actor.SetSensitive(sensitive);
2159 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2163 int UtcDaliActorIsSensitive(void)
2165 TestApplication application;
2166 Actor actor = Actor::New();
2167 actor.SetSensitive(false);
2169 DALI_TEST_CHECK(false == actor.IsSensitive());
2173 int UtcDaliActorSetColor(void)
2175 TestApplication application;
2176 Actor actor = Actor::New();
2177 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2179 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2181 actor.SetColor(color);
2182 // flush the queue and render once
2183 application.SendNotification();
2184 application.Render();
2185 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2187 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2188 // flush the queue and render once
2189 application.SendNotification();
2190 application.Render();
2191 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2193 Stage::GetCurrent().Add( actor );
2194 actor.SetColor( color );
2195 // flush the queue and render once
2196 application.SendNotification();
2197 application.Render();
2198 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2200 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2201 // flush the queue and render once
2202 application.SendNotification();
2203 application.Render();
2204 // Actor color is not clamped
2205 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2206 // world color is clamped
2207 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2209 Stage::GetCurrent().Remove( actor );
2213 int UtcDaliActorSetColorIndividual(void)
2215 TestApplication application;
2217 Actor actor = Actor::New();
2219 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2220 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2222 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2223 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2225 // flush the queue and render once
2226 application.SendNotification();
2227 application.Render();
2229 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2230 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2231 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2233 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2234 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2236 // flush the queue and render once
2237 application.SendNotification();
2238 application.Render();
2240 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2241 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2242 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2244 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2245 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2247 // flush the queue and render once
2248 application.SendNotification();
2249 application.Render();
2251 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2252 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2253 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2256 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2257 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2259 // flush the queue and render once
2260 application.SendNotification();
2261 application.Render();
2263 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2264 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2265 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2267 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2268 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2270 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2273 // flush the queue and render once
2274 application.SendNotification();
2275 application.Render();
2277 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2283 int UtcDaliActorGetCurrentColor(void)
2285 TestApplication application;
2286 Actor actor = Actor::New();
2287 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2289 actor.SetColor(color);
2290 // flush the queue and render once
2291 application.SendNotification();
2292 application.Render();
2293 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2297 int UtcDaliActorGetCurrentWorldColor(void)
2299 tet_infoline("Actor::GetCurrentWorldColor");
2300 TestApplication application;
2302 Actor parent = Actor::New();
2303 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2304 parent.SetColor( parentColor );
2305 Stage::GetCurrent().Add( parent );
2307 Actor child = Actor::New();
2308 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2309 child.SetColor( childColor );
2310 parent.Add( child );
2312 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2313 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2315 // verify the default color mode
2316 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2318 // The actors should not have a world color yet
2319 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2320 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2322 application.SendNotification();
2323 application.Render(0);
2325 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2326 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2328 // The actors should have a world color now
2329 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2330 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2333 child.SetColorMode( USE_OWN_COLOR );
2334 application.SendNotification();
2335 application.Render(0);
2336 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2339 child.SetColorMode( USE_PARENT_COLOR );
2340 application.SendNotification();
2341 application.Render(0);
2342 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2343 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2346 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2347 application.SendNotification();
2348 application.Render(0);
2349 Vector4 expectedColor( childColor );
2350 expectedColor.a *= parentColor.a;
2351 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2352 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2356 int UtcDaliActorSetColorMode(void)
2358 tet_infoline("Actor::SetColorMode");
2359 TestApplication application;
2360 Actor actor = Actor::New();
2361 Actor child = Actor::New();
2364 actor.SetColorMode( USE_OWN_COLOR );
2365 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2367 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2368 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2370 actor.SetColorMode( USE_PARENT_COLOR );
2371 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2373 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2374 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2378 int UtcDaliActorScreenToLocal(void)
2380 TestApplication application;
2381 Actor actor = Actor::New();
2382 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2383 actor.SetSize(100.0f, 100.0f);
2384 actor.SetPosition(10.0f, 10.0f);
2385 Stage::GetCurrent().Add(actor);
2387 // flush the queue and render once
2388 application.SendNotification();
2389 application.Render();
2394 application.SendNotification();
2395 application.Render();
2397 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2399 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2400 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2404 int UtcDaliActorSetLeaveRequired(void)
2406 TestApplication application;
2408 Actor actor = Actor::New();
2410 actor.SetLeaveRequired(false);
2411 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2413 actor.SetLeaveRequired(true);
2414 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2418 int UtcDaliActorGetLeaveRequired(void)
2420 TestApplication application;
2422 Actor actor = Actor::New();
2424 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2428 int UtcDaliActorSetKeyboardFocusable(void)
2430 TestApplication application;
2432 Actor actor = Actor::New();
2434 actor.SetKeyboardFocusable(true);
2435 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2437 actor.SetKeyboardFocusable(false);
2438 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2442 int UtcDaliActorIsKeyboardFocusable(void)
2444 TestApplication application;
2446 Actor actor = Actor::New();
2448 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2452 int UtcDaliActorRemoveConstraints(void)
2454 tet_infoline(" UtcDaliActorRemoveConstraints");
2455 TestApplication application;
2457 gTestConstraintCalled = false;
2459 Actor actor = Actor::New();
2461 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2463 actor.RemoveConstraints();
2465 DALI_TEST_CHECK( gTestConstraintCalled == false );
2467 Stage::GetCurrent().Add( actor );
2470 // flush the queue and render once
2471 application.SendNotification();
2472 application.Render();
2474 actor.RemoveConstraints();
2476 DALI_TEST_CHECK( gTestConstraintCalled == true );
2480 int UtcDaliActorRemoveConstraintTag(void)
2482 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2483 TestApplication application;
2485 Actor actor = Actor::New();
2487 // 1. Apply Constraint1 and Constraint2, and test...
2488 unsigned int result1 = 0u;
2489 unsigned int result2 = 0u;
2491 unsigned constraint1Tag = 1u;
2492 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2493 constraint1.SetTag( constraint1Tag );
2494 constraint1.Apply();
2496 unsigned constraint2Tag = 2u;
2497 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2498 constraint2.SetTag( constraint2Tag );
2499 constraint2.Apply();
2501 Stage::GetCurrent().Add( actor );
2502 // flush the queue and render once
2503 application.SendNotification();
2504 application.Render();
2506 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2507 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2509 // 2. Remove Constraint1 and test...
2512 actor.RemoveConstraints(constraint1Tag);
2513 // make color property dirty, which will trigger constraints to be reapplied.
2514 actor.SetColor( Color::WHITE );
2515 // flush the queue and render once
2516 application.SendNotification();
2517 application.Render();
2519 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2520 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2522 // 3. Re-Apply Constraint1 and test...
2525 constraint1.Apply();
2526 // make color property dirty, which will trigger constraints to be reapplied.
2527 actor.SetColor( Color::WHITE );
2528 // flush the queue and render once
2529 application.SendNotification();
2530 application.Render();
2532 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2533 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2535 // 2. Remove Constraint2 and test...
2538 actor.RemoveConstraints(constraint2Tag);
2539 // make color property dirty, which will trigger constraints to be reapplied.
2540 actor.SetColor( Color::WHITE );
2541 // flush the queue and render once
2542 application.SendNotification();
2543 application.Render();
2545 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2546 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2548 // 2. Remove Constraint1 as well and test...
2551 actor.RemoveConstraints(constraint1Tag);
2552 // make color property dirty, which will trigger constraints to be reapplied.
2553 actor.SetColor( Color::WHITE );
2554 // flush the queue and render once
2555 application.SendNotification();
2556 application.Render();
2558 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2559 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2563 int UtcDaliActorTouchedSignal(void)
2565 TestApplication application;
2567 ResetTouchCallbacks();
2569 // get the root layer
2570 Actor actor = Stage::GetCurrent().GetRootLayer();
2571 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2573 application.SendNotification();
2574 application.Render();
2576 // connect to its touch signal
2577 actor.TouchedSignal().Connect( TestCallback );
2579 // simulate a touch event in the middle of the screen
2580 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2581 Dali::Integration::Point point;
2582 point.SetDeviceId( 1 );
2583 point.SetState( PointState::DOWN );
2584 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2585 Dali::Integration::TouchEvent touchEvent;
2586 touchEvent.AddPoint( point );
2587 application.ProcessEvent( touchEvent );
2589 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2593 int UtcDaliActorHoveredSignal(void)
2595 TestApplication application;
2597 gHoverCallBackCalled = false;
2599 // get the root layer
2600 Actor actor = Stage::GetCurrent().GetRootLayer();
2601 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2603 application.SendNotification();
2604 application.Render();
2606 // connect to its hover signal
2607 actor.HoveredSignal().Connect( TestCallback3 );
2609 // simulate a hover event in the middle of the screen
2610 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2611 Dali::Integration::Point point;
2612 point.SetDeviceId( 1 );
2613 point.SetState( PointState::MOTION );
2614 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2615 Dali::Integration::HoverEvent hoverEvent;
2616 hoverEvent.AddPoint( point );
2617 application.ProcessEvent( hoverEvent );
2619 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2623 int UtcDaliActorOnOffStageSignal(void)
2625 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2627 TestApplication application;
2630 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2631 gActorNamesOnOffStage.clear();
2633 Actor parent = Actor::New();
2634 parent.SetName( "parent" );
2635 parent.OnStageSignal().Connect( OnStageCallback );
2636 parent.OffStageSignal().Connect( OffStageCallback );
2638 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2639 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2641 // add parent to stage
2642 Stage::GetCurrent().Add( parent );
2643 // onstage emitted, offstage not
2644 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2645 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2646 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2648 // test adding a child, should get onstage emitted
2650 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2651 gActorNamesOnOffStage.clear();
2653 Actor child = Actor::New();
2654 child.SetName( "child" );
2655 child.OnStageSignal().Connect( OnStageCallback );
2656 child.OffStageSignal().Connect( OffStageCallback );
2657 parent.Add( child ); // add child
2658 // onstage emitted, offstage not
2659 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2660 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2661 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2663 // test removing parent from stage
2665 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2666 gActorNamesOnOffStage.clear();
2668 Stage::GetCurrent().Remove( parent );
2669 // onstage not emitted, offstage is
2670 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2671 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2672 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2673 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2675 // test adding parent back to stage
2677 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2678 gActorNamesOnOffStage.clear();
2680 Stage::GetCurrent().Add( parent );
2681 // onstage emitted, offstage not
2682 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2683 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2684 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2685 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2687 // test removing child
2689 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2690 gActorNamesOnOffStage.clear();
2692 parent.Remove( child );
2693 // onstage not emitted, offstage is
2694 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2695 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2696 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2698 // test removing parent
2700 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2701 gActorNamesOnOffStage.clear();
2703 Stage::GetCurrent().Remove( parent );
2704 // onstage not emitted, offstage is
2705 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2706 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2707 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2711 int UtcDaliActorFindChildByName(void)
2713 tet_infoline("Testing Dali::Actor::FindChildByName()");
2714 TestApplication application;
2716 Actor parent = Actor::New();
2717 parent.SetName( "parent" );
2718 Actor first = Actor::New();
2719 first .SetName( "first" );
2720 Actor second = Actor::New();
2721 second.SetName( "second" );
2726 Actor found = parent.FindChildByName( "foo" );
2727 DALI_TEST_CHECK( !found );
2729 found = parent.FindChildByName( "parent" );
2730 DALI_TEST_CHECK( found == parent );
2732 found = parent.FindChildByName( "first" );
2733 DALI_TEST_CHECK( found == first );
2735 found = parent.FindChildByName( "second" );
2736 DALI_TEST_CHECK( found == second );
2740 int UtcDaliActorFindChildById(void)
2742 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2743 TestApplication application;
2745 Actor parent = Actor::New();
2746 Actor first = Actor::New();
2747 Actor second = Actor::New();
2752 Actor found = parent.FindChildById( 100000 );
2753 DALI_TEST_CHECK( !found );
2755 found = parent.FindChildById( parent.GetId() );
2756 DALI_TEST_CHECK( found == parent );
2758 found = parent.FindChildById( first.GetId() );
2759 DALI_TEST_CHECK( found == first );
2761 found = parent.FindChildById( second.GetId() );
2762 DALI_TEST_CHECK( found == second );
2766 int UtcDaliActorHitTest(void)
2771 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2773 mTouchPoint( touchPoint ),
2778 Vector2 mTouchPoint;
2782 TestApplication application;
2783 tet_infoline(" UtcDaliActorHitTest");
2785 // Fill a vector with different hit tests.
2786 struct HitTestData* hitTestData[] = {
2787 // scale touch point result
2788 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2789 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2790 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.
2791 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2792 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.
2796 // get the root layer
2797 Actor actor = Actor::New();
2798 actor.SetAnchorPoint( AnchorPoint::CENTER );
2799 actor.SetParentOrigin( ParentOrigin::CENTER );
2801 Stage::GetCurrent().Add( actor );
2803 ResetTouchCallbacks();
2805 unsigned int index = 0;
2806 while( NULL != hitTestData[index] )
2808 actor.SetSize( 1.f, 1.f );
2809 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2811 // flush the queue and render once
2812 application.SendNotification();
2813 application.Render();
2815 DALI_TEST_CHECK( !gTouchCallBackCalled );
2817 // connect to its touch signal
2818 actor.TouchedSignal().Connect(TestCallback);
2820 Dali::Integration::Point point;
2821 point.SetState( PointState::DOWN );
2822 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2823 Dali::Integration::TouchEvent event;
2824 event.AddPoint( point );
2826 // flush the queue and render once
2827 application.SendNotification();
2828 application.Render();
2829 application.ProcessEvent( event );
2831 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2833 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2834 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2835 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2836 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2837 hitTestData[index]->mResult );
2839 ResetTouchCallbacks();
2845 int UtcDaliActorSetDrawMode(void)
2847 TestApplication app;
2848 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2850 Actor a = Actor::New();
2852 Stage::GetCurrent().Add(a);
2853 app.SendNotification();
2855 app.SendNotification();
2858 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2860 a.SetDrawMode( DrawMode::OVERLAY_2D );
2861 app.SendNotification();
2864 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2866 a.SetDrawMode( DrawMode::NORMAL );
2867 app.SendNotification();
2870 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2874 int UtcDaliActorSetDrawModeOverlayRender(void)
2876 TestApplication app;
2877 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2879 app.SendNotification();
2882 std::vector<GLuint> ids;
2883 ids.push_back( 8 ); // first rendered actor
2884 ids.push_back( 9 ); // second rendered actor
2885 ids.push_back( 10 ); // third rendered actor
2886 app.GetGlAbstraction().SetNextTextureIds( ids );
2888 BufferImage imageA = BufferImage::New(16, 16);
2889 BufferImage imageB = BufferImage::New(16, 16);
2890 BufferImage imageC = BufferImage::New(16, 16);
2891 Actor a = CreateRenderableActor( imageA );
2892 Actor b = CreateRenderableActor( imageB );
2893 Actor c = CreateRenderableActor( imageC );
2895 app.SendNotification();
2898 //Textures are bound when first created. Clear bound textures vector
2899 app.GetGlAbstraction().ClearBoundTextures();
2901 // Render a,b,c as regular non-overlays. so order will be:
2905 Stage::GetCurrent().Add(a);
2906 Stage::GetCurrent().Add(b);
2907 Stage::GetCurrent().Add(c);
2909 app.SendNotification();
2912 // Should be 3 textures changes.
2913 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2914 typedef std::vector<GLuint>::size_type TextureSize;
2915 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2916 if( boundTextures.size() == 3 )
2918 DALI_TEST_CHECK( boundTextures[0] == 8u );
2919 DALI_TEST_CHECK( boundTextures[1] == 9u );
2920 DALI_TEST_CHECK( boundTextures[2] == 10u );
2923 // Now texture ids have been set, we can monitor their render order.
2924 // render a as an overlay (last), so order will be:
2928 a.SetDrawMode( DrawMode::OVERLAY_2D );
2929 app.GetGlAbstraction().ClearBoundTextures();
2931 app.SendNotification();
2934 // Should be 3 texture changes.
2935 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2936 if( boundTextures.size() == 3 )
2938 DALI_TEST_CHECK( boundTextures[0] == 9u );
2939 DALI_TEST_CHECK( boundTextures[1] == 10u );
2940 DALI_TEST_CHECK( boundTextures[2] == 8u );
2945 int UtcDaliActorGetCurrentWorldMatrix(void)
2947 TestApplication app;
2948 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2950 Actor parent = Actor::New();
2951 parent.SetParentOrigin(ParentOrigin::CENTER);
2952 parent.SetAnchorPoint(AnchorPoint::CENTER);
2953 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2954 Radian rotationAngle(Degree(85.0f));
2955 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2956 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2957 parent.SetPosition( parentPosition );
2958 parent.SetOrientation( parentRotation );
2959 parent.SetScale( parentScale );
2960 Stage::GetCurrent().Add( parent );
2962 Actor child = Actor::New();
2963 child.SetParentOrigin(ParentOrigin::CENTER);
2964 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2965 Radian childRotationAngle(Degree(23.0f));
2966 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2967 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2968 child.SetPosition( childPosition );
2969 child.SetOrientation( childRotation );
2970 child.SetScale( childScale );
2971 parent.Add( child );
2973 app.SendNotification();
2976 app.SendNotification();
2978 Matrix parentMatrix(false);
2979 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2981 Matrix childMatrix(false);
2982 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2984 //Child matrix should be the composition of child and parent
2985 Matrix childWorldMatrix(false);
2986 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2988 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2989 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2995 int UtcDaliActorConstrainedToWorldMatrix(void)
2997 TestApplication app;
2998 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3000 Actor parent = Actor::New();
3001 parent.SetParentOrigin(ParentOrigin::CENTER);
3002 parent.SetAnchorPoint(AnchorPoint::CENTER);
3003 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3004 Radian rotationAngle(Degree(85.0f));
3005 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3006 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3007 parent.SetPosition( parentPosition );
3008 parent.SetOrientation( parentRotation );
3009 parent.SetScale( parentScale );
3010 Stage::GetCurrent().Add( parent );
3012 Actor child = Actor::New();
3013 child.SetParentOrigin(ParentOrigin::CENTER);
3014 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3015 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3016 posConstraint.Apply();
3018 Stage::GetCurrent().Add( child );
3020 app.SendNotification();
3023 app.SendNotification();
3025 Matrix parentMatrix(false);
3026 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3028 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3029 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3033 int UtcDaliActorConstrainedToOrientation(void)
3035 TestApplication app;
3036 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3038 Actor parent = Actor::New();
3039 parent.SetParentOrigin(ParentOrigin::CENTER);
3040 parent.SetAnchorPoint(AnchorPoint::CENTER);
3041 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3042 Radian rotationAngle(Degree(85.0f));
3043 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3044 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3045 parent.SetPosition( parentPosition );
3046 parent.SetOrientation( parentRotation );
3047 parent.SetScale( parentScale );
3048 Stage::GetCurrent().Add( parent );
3050 Actor child = Actor::New();
3051 child.SetParentOrigin(ParentOrigin::CENTER);
3052 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3053 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3054 posConstraint.Apply();
3056 Stage::GetCurrent().Add( child );
3058 app.SendNotification();
3061 app.SendNotification();
3063 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3067 int UtcDaliActorConstrainedToOpacity(void)
3069 TestApplication app;
3070 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3072 Actor parent = Actor::New();
3073 parent.SetOpacity( 0.7f );
3074 Stage::GetCurrent().Add( parent );
3076 Actor child = Actor::New();
3077 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3078 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3079 opacityConstraint.Apply();
3081 Stage::GetCurrent().Add( child );
3083 app.SendNotification();
3086 app.SendNotification();
3088 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3090 parent.SetOpacity( 0.3f );
3092 app.SendNotification();
3095 app.SendNotification();
3097 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3102 int UtcDaliActorUnparent(void)
3104 TestApplication app;
3105 tet_infoline(" UtcDaliActorUnparent");
3107 Actor parent = Actor::New();
3108 Stage::GetCurrent().Add( parent );
3110 Actor child = Actor::New();
3112 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3113 DALI_TEST_CHECK( !child.GetParent() );
3115 // Test that calling Unparent with no parent is a NOOP
3118 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3119 DALI_TEST_CHECK( !child.GetParent() );
3121 // Test that Unparent works
3122 parent.Add( child );
3124 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3125 DALI_TEST_CHECK( parent == child.GetParent() );
3129 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3130 DALI_TEST_CHECK( !child.GetParent() );
3132 // Test that UnparentAndReset works
3133 parent.Add( child );
3135 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3136 DALI_TEST_CHECK( parent == child.GetParent() );
3138 UnparentAndReset( child );
3140 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3141 DALI_TEST_CHECK( !child );
3143 // Test that UnparentAndReset is a NOOP with empty handle
3144 UnparentAndReset( child );
3146 DALI_TEST_CHECK( !child );
3150 int UtcDaliActorGetChildAt(void)
3152 TestApplication app;
3153 tet_infoline(" UtcDaliActorGetChildAt");
3155 Actor parent = Actor::New();
3156 Stage::GetCurrent().Add( parent );
3158 Actor child0 = Actor::New();
3159 parent.Add( child0 );
3161 Actor child1 = Actor::New();
3162 parent.Add( child1 );
3164 Actor child2 = Actor::New();
3165 parent.Add( child2 );
3167 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3168 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3169 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3173 int UtcDaliActorSetGetOverlay(void)
3175 TestApplication app;
3176 tet_infoline(" UtcDaliActorSetGetOverlay");
3178 Actor parent = Actor::New();
3179 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3180 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3185 int UtcDaliActorCreateDestroy(void)
3187 Actor* actor = new Actor;
3188 DALI_TEST_CHECK( actor );
3195 struct PropertyStringIndex
3197 const char * const name;
3198 const Property::Index index;
3199 const Property::Type type;
3202 const PropertyStringIndex PROPERTY_TABLE[] =
3204 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3205 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3206 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3207 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3208 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3209 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3210 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3211 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3212 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3213 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3214 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3215 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3216 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3217 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3218 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3219 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3220 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3221 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3222 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3223 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3224 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3225 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3226 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3227 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3228 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3229 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3230 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3231 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3232 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3233 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3234 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3235 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3236 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3237 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3238 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3239 { "name", Actor::Property::NAME, Property::STRING },
3240 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3241 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3242 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3243 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3244 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3245 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3246 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3247 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3248 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3249 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3250 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3251 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3252 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3253 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3254 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3255 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3256 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3257 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3258 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3260 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3261 } // unnamed namespace
3263 int UtcDaliActorProperties(void)
3265 TestApplication app;
3267 Actor actor = Actor::New();
3269 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3271 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3272 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3273 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3274 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3279 int UtcDaliRelayoutProperties_ResizePolicies(void)
3281 TestApplication app;
3283 Actor actor = Actor::New();
3286 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3287 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3289 // Set resize policy for all dimensions
3290 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3291 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3293 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3296 // Set individual dimensions
3297 const char* const widthPolicy = "FILL_TO_PARENT";
3298 const char* const heightPolicy = "FIXED";
3300 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3301 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3303 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3304 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3306 // Set individual dimensions using enums
3307 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3308 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3310 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3311 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3313 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3314 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3319 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3321 TestApplication app;
3323 Actor actor = Actor::New();
3326 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3327 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3329 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3330 actor.SetSizeScalePolicy( policy );
3331 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3334 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3335 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3337 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3338 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3340 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3341 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3346 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3348 TestApplication app;
3350 Actor actor = Actor::New();
3353 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3354 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3356 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3357 actor.SetSizeModeFactor( sizeMode );
3358 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3361 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3363 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3364 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3369 int UtcDaliRelayoutProperties_DimensionDependency(void)
3371 TestApplication app;
3373 Actor actor = Actor::New();
3376 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3377 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3380 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3381 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3383 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3384 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3386 // Test setting another resize policy
3387 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3388 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3393 int UtcDaliRelayoutProperties_Padding(void)
3395 TestApplication app;
3397 Actor actor = Actor::New();
3400 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3403 actor.SetProperty( Actor::Property::PADDING, padding );
3404 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3406 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3411 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3413 TestApplication app;
3415 Actor actor = Actor::New();
3418 Vector2 minSize( 1.0f, 2.0f );
3420 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3421 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3423 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3425 Vector2 maxSize( 3.0f, 4.0f );
3427 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3428 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3430 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3435 int UtcDaliActorGetHeightForWidth(void)
3437 TestApplication app;
3439 Actor actor = Actor::New();
3441 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3446 int UtcDaliActorGetWidthForHeight(void)
3448 TestApplication app;
3450 Actor actor = Actor::New();
3452 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3457 int UtcDaliActorGetRelayoutSize(void)
3459 TestApplication app;
3461 Actor actor = Actor::New();
3463 // Add actor to stage
3464 Stage::GetCurrent().Add( actor );
3466 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3468 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3469 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3471 // Flush the queue and render once
3472 app.SendNotification();
3475 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3480 int UtcDaliActorSetPadding(void)
3482 TestApplication app;
3484 Actor actor = Actor::New();
3487 actor.GetPadding( padding );
3489 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3490 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3491 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3492 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3494 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3495 actor.SetPadding( padding2 );
3497 actor.GetPadding( padding );
3499 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3500 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3501 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3502 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3507 int UtcDaliActorSetMinimumSize(void)
3509 TestApplication app;
3511 Actor actor = Actor::New();
3513 Vector2 size = actor.GetMinimumSize();
3515 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3516 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3518 Vector2 size2( 1.0f, 2.0f );
3519 actor.SetMinimumSize( size2 );
3521 size = actor.GetMinimumSize();
3523 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3524 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3529 int UtcDaliActorSetMaximumSize(void)
3531 TestApplication app;
3533 Actor actor = Actor::New();
3535 Vector2 size = actor.GetMaximumSize();
3537 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3538 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3540 Vector2 size2( 1.0f, 2.0f );
3541 actor.SetMaximumSize( size2 );
3543 size = actor.GetMaximumSize();
3545 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3546 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3551 int UtcDaliActorOnRelayoutSignal(void)
3553 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3555 TestApplication application;
3558 gOnRelayoutCallBackCalled = false;
3559 gActorNamesRelayout.clear();
3561 Actor actor = Actor::New();
3562 actor.SetName( "actor" );
3563 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3566 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3568 // Add actor to stage
3569 Stage::GetCurrent().Add( actor );
3571 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3572 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3574 // Flush the queue and render once
3575 application.SendNotification();
3576 application.Render();
3578 // OnRelayout emitted
3579 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3580 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3585 int UtcDaliActorGetHierachyDepth(void)
3587 TestApplication application;
3588 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3591 /* Build tree of actors:
3601 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3603 Stage stage( Stage::GetCurrent() );
3605 Actor actorA = Actor::New();
3606 Actor actorB = Actor::New();
3607 Actor actorC = Actor::New();
3608 Actor actorD = Actor::New();
3609 Actor actorE = Actor::New();
3610 Actor actorF = Actor::New();
3612 //Test that root actor has depth equal 0
3613 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3615 //Test actors return depth -1 when not connected to the tree
3616 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3617 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3618 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3619 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3620 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3621 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3623 //Create the hierarchy
3624 stage.Add( actorA );
3625 actorA.Add( actorB );
3626 actorA.Add( actorC );
3627 actorB.Add( actorD );
3628 actorB.Add( actorE );
3629 actorC.Add( actorF );
3631 //Test actors return correct depth
3632 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3633 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3634 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3635 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3636 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3637 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3639 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3640 actorA.Remove( actorB );
3642 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3643 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3644 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3646 //Removing actorA from the stage. All actors should have depth equal -1
3647 stage.Remove( actorA );
3649 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3650 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3651 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3652 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3653 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3654 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3659 int UtcDaliActorAnchorPointPropertyAsString(void)
3661 TestApplication application;
3663 Actor actor = Actor::New();
3665 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3666 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3668 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3669 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3671 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3672 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3674 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3675 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3677 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3678 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3680 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3681 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3683 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3684 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3686 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3687 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3689 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3690 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3692 // Invalid should not change anything
3693 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3694 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3699 int UtcDaliActorParentOriginPropertyAsString(void)
3701 TestApplication application;
3703 Actor actor = Actor::New();
3705 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3706 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3708 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3709 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3711 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3712 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3714 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3715 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3717 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3718 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3720 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3721 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3723 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3724 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3726 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3727 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3729 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3730 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3732 // Invalid should not change anything
3733 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3734 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3739 int UtcDaliActorColorModePropertyAsString(void)
3741 TestApplication application;
3743 Actor actor = Actor::New();
3745 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3746 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3748 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3749 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3751 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3752 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3754 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3755 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3757 // Invalid should not change anything
3758 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3759 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3764 int UtcDaliActorPositionInheritancePropertyAsString(void)
3766 TestApplication application;
3768 Actor actor = Actor::New();
3770 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3771 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3773 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3774 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3776 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3777 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3779 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3780 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3782 // Invalid should not change anything
3783 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3784 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3789 int UtcDaliActorDrawModePropertyAsString(void)
3791 TestApplication application;
3793 Actor actor = Actor::New();
3795 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3796 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3798 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3799 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3801 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3802 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3804 // Invalid should not change anything
3805 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3806 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3811 int UtcDaliActorColorModePropertyAsEnum(void)
3813 TestApplication application;
3815 Actor actor = Actor::New();
3817 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3818 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3820 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3821 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3823 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3824 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3826 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3827 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3832 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3834 TestApplication application;
3836 Actor actor = Actor::New();
3838 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3839 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3841 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3842 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3844 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3845 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3847 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3848 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3853 int UtcDaliActorDrawModePropertyAsEnum(void)
3855 TestApplication application;
3857 Actor actor = Actor::New();
3859 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3860 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3862 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3863 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3865 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3866 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3871 int UtcDaliActorAddRendererP(void)
3873 tet_infoline("Testing Actor::AddRenderer");
3874 TestApplication application;
3876 Actor actor = Actor::New();
3878 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3880 Geometry geometry = CreateQuadGeometry();
3881 Shader shader = CreateShader();
3882 Renderer renderer = Renderer::New(geometry, shader);
3884 actor.AddRenderer( renderer );
3885 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3886 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3891 int UtcDaliActorAddRendererN(void)
3893 tet_infoline("Testing Actor::AddRenderer");
3894 TestApplication application;
3896 Actor actor = Actor::New();
3902 actor.AddRenderer( renderer );
3903 tet_printf("Assertion test failed - no Exception\n" );
3904 tet_result(TET_FAIL);
3906 catch(Dali::DaliException& e)
3908 DALI_TEST_PRINT_ASSERT( e );
3909 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3910 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3914 tet_printf("Assertion test failed - wrong Exception\n" );
3915 tet_result(TET_FAIL);
3921 int UtcDaliActorAddRendererOnStage(void)
3923 tet_infoline("Testing Actor::AddRenderer");
3924 TestApplication application;
3926 Actor actor = Actor::New();
3927 Stage::GetCurrent().Add(actor);
3929 application.SendNotification();
3930 application.Render(0);
3932 Geometry geometry = CreateQuadGeometry();
3933 Shader shader = CreateShader();
3934 Renderer renderer = Renderer::New(geometry, shader);
3936 application.SendNotification();
3937 application.Render(0);
3941 actor.AddRenderer( renderer );
3942 tet_result(TET_PASS);
3946 tet_result(TET_FAIL);
3952 int UtcDaliActorRemoveRendererP1(void)
3954 tet_infoline("Testing Actor::RemoveRenderer");
3955 TestApplication application;
3957 Actor actor = Actor::New();
3959 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3962 Geometry geometry = CreateQuadGeometry();
3963 Shader shader = CreateShader();
3964 Renderer renderer = Renderer::New(geometry, shader);
3966 actor.AddRenderer( renderer );
3967 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3968 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3970 application.SendNotification();
3971 application.Render();
3975 Renderer renderer = actor.GetRendererAt(0);
3976 actor.RemoveRenderer(renderer);
3977 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3979 application.SendNotification();
3980 application.Render();
3983 // Call one final time to ensure that the renderer is actually removed after
3984 // the handle goes out of scope, and excercises the deletion code path in
3985 // scene graph and render.
3986 application.SendNotification();
3987 application.Render();
3992 int UtcDaliActorRemoveRendererP2(void)
3994 tet_infoline("Testing Actor::RemoveRenderer");
3995 TestApplication application;
3997 Actor actor = Actor::New();
3999 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4001 Geometry geometry = CreateQuadGeometry();
4002 Shader shader = CreateShader();
4003 Renderer renderer = Renderer::New(geometry, shader);
4005 actor.AddRenderer( renderer );
4006 application.SendNotification();
4007 application.Render();
4009 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4010 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4012 actor.RemoveRenderer(0);
4013 application.SendNotification();
4014 application.Render();
4016 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4018 // Shut down whilst holding onto the renderer handle.
4023 int UtcDaliActorRemoveRendererN(void)
4025 tet_infoline("Testing Actor::RemoveRenderer");
4026 TestApplication application;
4028 Actor actor = Actor::New();
4030 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4032 Geometry geometry = CreateQuadGeometry();
4033 Shader shader = CreateShader();
4034 Renderer renderer = Renderer::New(geometry, shader);
4036 actor.AddRenderer( renderer );
4037 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4038 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4040 actor.RemoveRenderer(10);
4041 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4042 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4047 // Clipping test helper functions:
4048 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4050 BufferImage image = BufferImage::New( width, height );
4051 Actor actor = CreateRenderableActor( image );
4053 // Setup dimensions and position so actor is not skipped by culling.
4054 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4055 actor.SetSize( width, height );
4056 actor.SetParentOrigin( ParentOrigin::CENTER );
4057 actor.SetAnchorPoint( AnchorPoint::CENTER );
4062 Actor CreateActorWithContent16x16()
4064 return CreateActorWithContent( 16, 16 );
4067 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4069 enabledDisableTrace.Reset();
4070 stencilTrace.Reset();
4071 enabledDisableTrace.Enable( true );
4072 stencilTrace.Enable( true );
4074 application.SendNotification();
4075 application.Render();
4077 enabledDisableTrace.Enable( false );
4078 stencilTrace.Enable( false );
4081 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4083 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4085 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4086 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4087 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4088 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4091 int UtcDaliActorPropertyClippingP(void)
4093 // This test checks the clippingMode property.
4094 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4095 TestApplication application;
4097 Actor actor = Actor::New();
4099 // Check default clippingEnabled value.
4100 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4103 bool getValueResult = getValue.Get( value );
4104 DALI_TEST_CHECK( getValueResult );
4106 if( getValueResult )
4108 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4111 // Check setting the property to the stencil mode.
4112 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4114 // Check the new value was set.
4115 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4116 getValueResult = getValue.Get( value );
4117 DALI_TEST_CHECK( getValueResult );
4119 if( getValueResult )
4121 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4124 // Check setting the property to the scissor mode.
4125 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4127 // Check the new value was set.
4128 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4129 getValueResult = getValue.Get( value );
4130 DALI_TEST_CHECK( getValueResult );
4132 if( getValueResult )
4134 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4139 int UtcDaliActorPropertyClippingN(void)
4141 // Negative test case for Clipping.
4142 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4143 TestApplication application;
4145 Actor actor = Actor::New();
4147 // Check default clippingEnabled value.
4148 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4151 bool getValueResult = getValue.Get( value );
4152 DALI_TEST_CHECK( getValueResult );
4154 if( getValueResult )
4156 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4159 // Check setting an invalid property value won't change the current property value.
4160 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4162 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4163 getValueResult = getValue.Get( value );
4164 DALI_TEST_CHECK( getValueResult );
4166 if( getValueResult )
4168 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4174 int UtcDaliActorPropertyClippingActor(void)
4176 // This test checks that an actor is correctly setup for clipping.
4177 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4178 TestApplication application;
4180 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4181 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4182 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4183 size_t startIndex = 0u;
4185 // Create a clipping actor.
4186 Actor actorDepth1Clip = CreateActorWithContent16x16();
4187 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4188 Stage::GetCurrent().Add( actorDepth1Clip );
4190 // Gather the call trace.
4191 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4193 // Check we are writing to the color buffer.
4194 CheckColorMask( glAbstraction, true );
4196 // Check the stencil buffer was enabled.
4197 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4199 // Check the stencil buffer was cleared.
4200 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4202 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4203 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4204 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4205 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4210 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4212 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4213 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4214 TestApplication application;
4216 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4217 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4218 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4219 size_t startIndex = 0u;
4221 // Create a clipping actor.
4222 Actor actorDepth1Clip = CreateActorWithContent16x16();
4223 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4224 Stage::GetCurrent().Add( actorDepth1Clip );
4226 // Gather the call trace.
4227 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4229 // Check we are writing to the color buffer.
4230 CheckColorMask( glAbstraction, true );
4232 // Check the stencil buffer was enabled.
4233 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4235 // Check the stencil buffer was cleared.
4236 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4238 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4239 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4240 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4241 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4243 // Now disable the clipping
4244 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4246 // Gather the call trace.
4247 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4249 // Check the stencil buffer was disabled.
4250 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4252 // Ensure all values in stencil-mask are set to 1.
4254 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4259 int UtcDaliActorPropertyClippingNestedChildren(void)
4261 // This test checks that a hierarchy of actors are clipped correctly by
4262 // writing to and reading from the correct bit-planes of the stencil buffer.
4263 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4264 TestApplication application;
4265 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4266 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4267 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4269 // Create a clipping actor.
4270 Actor actorDepth1Clip = CreateActorWithContent16x16();
4271 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4272 Stage::GetCurrent().Add( actorDepth1Clip );
4274 // Create a child actor.
4275 Actor childDepth2 = CreateActorWithContent16x16();
4276 actorDepth1Clip.Add( childDepth2 );
4278 // Create another clipping actor.
4279 Actor childDepth2Clip = CreateActorWithContent16x16();
4280 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4281 childDepth2.Add( childDepth2Clip );
4283 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4284 // This tests the sort algorithm.
4285 Actor childDepth3 = CreateActorWithContent16x16();
4286 childDepth2Clip.Add( childDepth3 );
4287 Actor childDepth4 = CreateActorWithContent16x16();
4288 childDepth3.Add( childDepth4 );
4290 // Gather the call trace.
4291 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4293 // Check we are writing to the color buffer.
4294 CheckColorMask( glAbstraction, true );
4296 // Check the stencil buffer was enabled.
4297 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4299 // Perform the test twice, once for 2D layer, and once for 3D.
4300 for( unsigned int i = 0u ; i < 2u; ++i )
4302 size_t startIndex = 0u;
4304 // Check the stencil buffer was cleared.
4305 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4307 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4308 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4309 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4310 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4312 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4313 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4314 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4316 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4317 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4318 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4319 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4321 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4322 // (Both must be set to pass the check).
4323 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4324 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4326 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4329 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4330 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4337 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4339 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4340 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4341 TestApplication application;
4342 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4343 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4345 /* We create a small tree of actors as follows:
4349 Clipping enabled -> B D
4353 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4356 for( int i = 0; i < 5; ++i )
4358 BufferImage image = BufferImage::New( 16u, 16u );
4359 Actor actor = CreateRenderableActor( image );
4361 // Setup dimensions and position so actor is not skipped by culling.
4362 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4363 actor.SetSize( 16.0f, 16.0f );
4367 actor.SetParentOrigin( ParentOrigin::CENTER );
4371 float b = i > 2 ? 1.0f : -1.0f;
4372 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4378 // Enable clipping on the actor at the top of the left branch.
4379 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4381 // Build the scene graph.
4382 Stage::GetCurrent().Add( actors[0] );
4385 actors[0].Add( actors[1] );
4386 actors[1].Add( actors[2] );
4389 actors[0].Add( actors[3] );
4390 actors[3].Add( actors[4] );
4392 // Gather the call trace.
4393 enabledDisableTrace.Reset();
4394 enabledDisableTrace.Enable( true );
4395 application.SendNotification();
4396 application.Render();
4397 enabledDisableTrace.Enable( false );
4399 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4401 Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
4402 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4404 size_t startIndex = 0u;
4405 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4406 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4407 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4409 // Swap the clipping actor from top of left branch to top of right branch.
4410 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4411 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4413 // Gather the call trace.
4414 enabledDisableTrace.Reset();
4415 enabledDisableTrace.Enable( true );
4416 application.SendNotification();
4417 application.Render();
4418 enabledDisableTrace.Enable( false );
4420 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4421 // This proves the draw order has remained the same.
4423 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4424 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4429 int UtcDaliActorPropertyScissorClippingActor(void)
4431 // This test checks that an actor is correctly setup for clipping.
4432 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4433 TestApplication application;
4435 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4436 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4437 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4439 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4440 const Vector2 imageSize( 16.0f, 16.0f );
4442 // Create a clipping actor.
4443 Actor clippingActorA = CreateActorWithContent16x16();
4444 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4445 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4446 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4447 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4448 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4449 Stage::GetCurrent().Add( clippingActorA );
4451 // Gather the call trace.
4452 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4454 // Check we are writing to the color buffer.
4455 CheckColorMask( glAbstraction, true );
4457 // Check scissor test was enabled.
4458 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4460 // Check the scissor was set, and the coordinates are correct.
4461 std::stringstream compareParametersString;
4462 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4463 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4465 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4466 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4468 // Gather the call trace.
4469 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4471 // Check the scissor was set, and the coordinates are correct.
4472 compareParametersString.str( std::string() );
4473 compareParametersString.clear();
4474 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4475 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4480 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4482 // This test checks that an actor is correctly setup for clipping.
4483 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4484 TestApplication application;
4487 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4488 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4489 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4491 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4492 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4493 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4495 // Create a clipping actors.
4496 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4497 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4499 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4500 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4501 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4503 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4504 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4505 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4507 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4508 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4510 Stage::GetCurrent().Add( clippingActorA );
4511 Stage::GetCurrent().Add( clippingActorB );
4513 // Gather the call trace.
4514 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4516 // Check we are writing to the color buffer.
4517 CheckColorMask( glAbstraction, true );
4519 // Check scissor test was enabled.
4520 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4522 // Check the scissor was set, and the coordinates are correct.
4523 std::stringstream compareParametersString;
4525 std::string clipA( "0, 500, 480, 200" );
4526 std::string clipB( "0, 380, 480, 40" );
4528 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4529 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4534 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4536 // This test checks that an actor is correctly setup for clipping.
4537 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4538 TestApplication application;
4540 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4541 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4542 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4544 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4545 const Vector2 imageSize( 16.0f, 16.0f );
4547 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4549 A is drawn first - with scissor clipping on
4550 B is drawn second - also with scissor clipping on
4551 C is the generated clipping region, the intersection ( A ∩ B )
4555 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4556 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4557 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4561 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4564 // Create a clipping actor.
4565 Actor clippingActorA = CreateActorWithContent16x16();
4566 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4567 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4568 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4569 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4570 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4571 Stage::GetCurrent().Add( clippingActorA );
4573 // Create a child clipping actor.
4574 Actor clippingActorB = CreateActorWithContent16x16();
4575 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4576 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4577 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4578 clippingActorA.Add( clippingActorB );
4580 // positionModifiers is an array of positions to position B around.
4581 // expect is an array of expected scissor clip coordinate results.
4582 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4583 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4585 // Loop through each overlap combination.
4586 for( unsigned int test = 0u; test < 4u; ++test )
4588 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4589 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4590 clippingActorB.SetPosition( position.x, position.y );
4592 // Gather the call trace.
4593 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4595 // Check we are writing to the color buffer.
4596 CheckColorMask( glAbstraction, true );
4598 // Check scissor test was enabled.
4599 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4601 // Check the scissor was set, and the coordinates are correct.
4602 const Vector4& expectResults( expect[test] );
4603 std::stringstream compareParametersString;
4604 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4605 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4611 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4613 // This test checks that an actor is correctly setup for clipping.
4614 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4615 TestApplication application;
4617 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4618 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4619 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4621 /* Create a nest of 2 scissors and siblings of the parent.
4631 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4632 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4633 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4634 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4635 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4636 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4638 // Create a clipping actors.
4639 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4640 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4641 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4642 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4643 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4645 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4646 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4647 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4649 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4650 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4651 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4653 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4654 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4655 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4657 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4658 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4659 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4661 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4662 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4664 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4665 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4666 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4667 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4668 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4670 Stage::GetCurrent().Add( clippingActorA );
4671 clippingActorA.Add( clippingActorB );
4672 Stage::GetCurrent().Add( clippingActorC );
4673 Stage::GetCurrent().Add( clippingActorD );
4674 clippingActorD.Add( clippingActorE );
4676 // Gather the call trace.
4677 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4679 // Check we are writing to the color buffer.
4680 CheckColorMask( glAbstraction, true );
4682 // Check scissor test was enabled.
4683 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4685 // Check the scissor was set, and the coordinates are correct.
4686 std::string clipA( "0, 500, 480, 200" );
4687 std::string clipB( "0, 580, 480, 40" );
4688 std::string clipC( "0, 200, 480, 200" );
4689 std::string clipD( "0, 300, 480, 200" );
4691 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4692 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4693 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4694 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4695 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4700 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4702 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4703 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4704 TestApplication application;
4706 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4707 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4708 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4710 // Create a clipping actor.
4711 Actor actorDepth1Clip = CreateActorWithContent16x16();
4712 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4713 Stage::GetCurrent().Add( actorDepth1Clip );
4715 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4716 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4718 // Gather the call trace.
4719 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4721 // Check we are writing to the color buffer.
4722 CheckColorMask( glAbstraction, true );
4724 // Check the stencil buffer was not enabled.
4725 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4727 // Check stencil functions are not called.
4728 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4729 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4730 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4732 // Check that scissor clipping is overriden by the renderer properties.
4733 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4735 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4737 // Gather the call trace.
4738 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4740 // Check the stencil buffer was not enabled.
4741 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4743 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4748 int UtcDaliGetPropertyN(void)
4750 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4751 TestApplication app;
4753 Actor actor = Actor::New();
4755 unsigned int propertyCount = actor.GetPropertyCount();
4756 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4760 int UtcDaliActorRaiseLower(void)
4762 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4764 TestApplication application;
4766 Stage stage( Stage::GetCurrent() );
4768 Actor actorA = Actor::New();
4769 Actor actorB = Actor::New();
4770 Actor actorC = Actor::New();
4772 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4773 actorA.SetParentOrigin( ParentOrigin::CENTER );
4775 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4776 actorB.SetParentOrigin( ParentOrigin::CENTER );
4778 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4779 actorC.SetParentOrigin( ParentOrigin::CENTER );
4781 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4782 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4784 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4785 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4787 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4788 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4790 stage.Add( actorA );
4791 stage.Add( actorB );
4792 stage.Add( actorC );
4794 ResetTouchCallbacks();
4796 application.SendNotification();
4797 application.Render();
4799 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4800 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4801 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4803 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4804 // Only top actor will get touched.
4805 actorA.TouchSignal().Connect( TestTouchCallback );
4806 actorB.TouchSignal().Connect( TestTouchCallback2 );
4807 actorC.TouchSignal().Connect( TestTouchCallback3 );
4809 Dali::Integration::Point point;
4810 point.SetDeviceId( 1 );
4811 point.SetState( PointState::DOWN );
4812 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4813 Dali::Integration::TouchEvent touchEvent;
4814 touchEvent.AddPoint( point );
4816 application.ProcessEvent( touchEvent );
4818 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4819 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4820 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4822 ResetTouchCallbacks();
4824 tet_printf( "Testing Raising of Actor\n" );
4826 int preActorOrder( 0 );
4827 int postActorOrder( 0 );
4829 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4830 value.Get( preActorOrder );
4833 // Ensure sort order is calculated before next touch event
4834 application.SendNotification();
4836 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4837 value.Get( postActorOrder );
4839 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4841 application.ProcessEvent( touchEvent );
4843 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4844 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4845 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4847 ResetTouchCallbacks();
4849 tet_printf( "Testing Lowering of Actor\n" );
4851 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4852 value.Get( preActorOrder );
4855 application.SendNotification(); // ensure sort order calculated before next touch event
4857 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4858 value.Get( postActorOrder );
4860 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4862 application.ProcessEvent( touchEvent );
4864 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4865 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4866 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4868 ResetTouchCallbacks();
4873 int UtcDaliActorRaiseToTopLowerToBottom(void)
4875 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4877 TestApplication application;
4879 Stage stage( Stage::GetCurrent() );
4881 Actor actorA = Actor::New();
4882 Actor actorB = Actor::New();
4883 Actor actorC = Actor::New();
4885 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4886 // enables checking of which actor the uniform is assigned too
4887 Shader shaderA = CreateShader();
4888 shaderA.RegisterProperty( "uRendererColor",1.f);
4890 Shader shaderB = CreateShader();
4891 shaderB.RegisterProperty( "uRendererColor", 2.f );
4893 Shader shaderC = CreateShader();
4894 shaderC.RegisterProperty( "uRendererColor", 3.f );
4896 Geometry geometry = CreateQuadGeometry();
4898 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4899 Renderer rendererA = Renderer::New(geometry, shaderA);
4900 actorA.AddRenderer(rendererA);
4902 Renderer rendererB = Renderer::New(geometry, shaderB);
4903 actorB.AddRenderer(rendererB);
4905 Renderer rendererC = Renderer::New(geometry, shaderC);
4906 actorC.AddRenderer(rendererC);
4908 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4909 actorA.SetParentOrigin( ParentOrigin::CENTER );
4911 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4912 actorB.SetParentOrigin( ParentOrigin::CENTER );
4914 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4915 actorC.SetParentOrigin( ParentOrigin::CENTER );
4917 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4918 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4920 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4921 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4923 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4924 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4926 stage.Add( actorA );
4927 stage.Add( actorB );
4928 stage.Add( actorC );
4930 ResetTouchCallbacks();
4932 // Set up gl abstraction trace so can query the set uniform order
4933 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4934 glAbstraction.EnableSetUniformCallTrace(true);
4935 glAbstraction.ResetSetUniformCallStack();
4937 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4939 application.SendNotification();
4940 application.Render();
4942 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4945 // Test order of uniforms in stack
4946 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4947 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4948 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4950 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4952 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4954 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4955 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4956 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4958 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4959 // Only top actor will get touched.
4960 actorA.TouchSignal().Connect( TestTouchCallback );
4961 actorB.TouchSignal().Connect( TestTouchCallback2 );
4962 actorC.TouchSignal().Connect( TestTouchCallback3 );
4964 Dali::Integration::Point point;
4965 point.SetDeviceId( 1 );
4966 point.SetState( PointState::DOWN );
4967 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4968 Dali::Integration::TouchEvent touchEvent;
4969 touchEvent.AddPoint( point );
4971 application.ProcessEvent( touchEvent );
4973 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4974 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4975 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4977 ResetTouchCallbacks();
4979 tet_printf( "RaiseToTop ActorA\n" );
4981 actorA.RaiseToTop();
4982 application.SendNotification(); // ensure sorting order is calculated before next touch event
4984 application.ProcessEvent( touchEvent );
4986 glAbstraction.ResetSetUniformCallStack();
4987 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4989 application.SendNotification();
4990 application.Render();
4992 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4994 // Test order of uniforms in stack
4995 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4996 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4997 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4999 tet_infoline( "Testing A above C and B at bottom\n" );
5000 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5002 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5004 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5005 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5006 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5008 ResetTouchCallbacks();
5010 tet_printf( "RaiseToTop ActorB\n" );
5012 actorB.RaiseToTop();
5013 application.SendNotification(); // Ensure sort order is calculated before next touch event
5015 application.ProcessEvent( touchEvent );
5017 glAbstraction.ResetSetUniformCallStack();
5018 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5020 application.SendNotification();
5021 application.Render();
5023 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5025 // Test order of uniforms in stack
5026 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5027 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5028 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5030 tet_infoline( "Testing B above A and C at bottom\n" );
5031 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5033 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5035 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5036 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5037 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5039 ResetTouchCallbacks();
5041 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5043 actorA.LowerToBottom();
5044 application.SendNotification();
5045 application.Render();
5047 actorB.LowerToBottom();
5048 application.SendNotification();
5049 application.Render();
5051 application.ProcessEvent( touchEvent );
5053 glAbstraction.ResetSetUniformCallStack();
5054 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5056 application.SendNotification();
5057 application.Render();
5059 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5061 // Test order of uniforms in stack
5062 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5063 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5064 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5066 tet_infoline( "Testing C above A and B at bottom\n" );
5067 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5069 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5071 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5072 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5073 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5075 ResetTouchCallbacks();
5080 int UtcDaliActorRaiseAbove(void)
5082 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5084 TestApplication application;
5086 Stage stage( Stage::GetCurrent() );
5088 Actor actorA = Actor::New();
5089 Actor actorB = Actor::New();
5090 Actor actorC = Actor::New();
5092 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5093 actorA.SetParentOrigin( ParentOrigin::CENTER );
5095 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5096 actorB.SetParentOrigin( ParentOrigin::CENTER );
5098 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5099 actorC.SetParentOrigin( ParentOrigin::CENTER );
5101 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5102 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5104 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5105 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5107 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5108 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5110 stage.Add( actorA );
5111 stage.Add( actorB );
5112 stage.Add( actorC );
5114 ResetTouchCallbacks();
5116 application.SendNotification();
5117 application.Render();
5119 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5120 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5121 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5123 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5124 // Only top actor will get touched.
5125 actorA.TouchSignal().Connect( TestTouchCallback );
5126 actorB.TouchSignal().Connect( TestTouchCallback2 );
5127 actorC.TouchSignal().Connect( TestTouchCallback3 );
5129 bool orderChangedSignal(false);
5130 ChildOrderChangedFunctor f(orderChangedSignal);
5131 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5133 Dali::Integration::Point point;
5134 point.SetDeviceId( 1 );
5135 point.SetState( PointState::DOWN );
5136 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5137 Dali::Integration::TouchEvent touchEvent;
5138 touchEvent.AddPoint( point );
5140 application.ProcessEvent( touchEvent );
5142 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5143 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5144 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5146 ResetTouchCallbacks();
5148 tet_printf( "Raise actor B Above Actor C\n" );
5150 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5151 actorB.RaiseAbove( actorC );
5152 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5154 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5155 application.SendNotification();
5156 application.ProcessEvent( touchEvent );
5158 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5159 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5160 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5162 ResetTouchCallbacks();
5164 tet_printf( "Raise actor A Above Actor B\n" );
5166 actorA.RaiseAbove( actorB );
5168 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5169 application.SendNotification();
5171 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5173 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5174 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5175 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5177 ResetTouchCallbacks();
5182 int UtcDaliActorLowerBelow(void)
5184 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5186 TestApplication application;
5188 Stage stage( Stage::GetCurrent() );
5190 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5191 // enables checking of which actor the uniform is assigned too
5192 Shader shaderA = CreateShader();
5193 shaderA.RegisterProperty( "uRendererColor",1.f);
5195 Shader shaderB = CreateShader();
5196 shaderB.RegisterProperty( "uRendererColor", 2.f );
5198 Shader shaderC = CreateShader();
5199 shaderC.RegisterProperty( "uRendererColor", 3.f );
5201 Actor actorA = Actor::New();
5202 Actor actorB = Actor::New();
5203 Actor actorC = Actor::New();
5205 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5206 Geometry geometry = CreateQuadGeometry();
5208 Renderer rendererA = Renderer::New(geometry, shaderA);
5209 actorA.AddRenderer(rendererA);
5211 Renderer rendererB = Renderer::New(geometry, shaderB);
5212 actorB.AddRenderer(rendererB);
5214 Renderer rendererC = Renderer::New(geometry, shaderC);
5215 actorC.AddRenderer(rendererC);
5217 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5218 actorA.SetParentOrigin( ParentOrigin::CENTER );
5220 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5221 actorB.SetParentOrigin( ParentOrigin::CENTER );
5223 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5224 actorC.SetParentOrigin( ParentOrigin::CENTER );
5226 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5227 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5229 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5230 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5232 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5233 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5235 Actor container = Actor::New();
5236 container.SetParentOrigin( ParentOrigin::CENTER );
5237 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5238 stage.Add( container );
5240 container.Add( actorA );
5241 container.Add( actorB );
5242 container.Add( actorC );
5244 ResetTouchCallbacks();
5246 // Set up gl abstraction trace so can query the set uniform order
5247 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5248 glAbstraction.EnableSetUniformCallTrace(true);
5249 glAbstraction.ResetSetUniformCallStack();
5250 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5252 glAbstraction.ResetSetUniformCallStack();
5254 application.SendNotification();
5255 application.Render();
5257 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5259 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5261 // Test order of uniforms in stack
5262 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5263 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5264 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5266 tet_infoline( "Testing C above B and A at bottom\n" );
5267 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5269 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5271 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5272 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5273 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5275 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5276 // Only top actor will get touched.
5277 actorA.TouchSignal().Connect( TestTouchCallback );
5278 actorB.TouchSignal().Connect( TestTouchCallback2 );
5279 actorC.TouchSignal().Connect( TestTouchCallback3 );
5281 Dali::Integration::Point point;
5282 point.SetDeviceId( 1 );
5283 point.SetState( PointState::DOWN );
5284 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5285 Dali::Integration::TouchEvent touchEvent;
5286 touchEvent.AddPoint( point );
5288 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5290 application.ProcessEvent( touchEvent );
5292 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5293 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5294 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5296 ResetTouchCallbacks();
5298 tet_printf( "Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n" );
5300 actorC.LowerBelow( actorB );
5301 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5302 application.SendNotification();
5303 application.Render();
5305 application.ProcessEvent( touchEvent ); // touch event
5307 glAbstraction.ResetSetUniformCallStack();
5308 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5310 application.SendNotification();
5311 application.Render();
5313 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5315 // Test order of uniforms in stack
5316 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5317 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5318 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5320 tet_infoline( "Testing render order is A, C, B" );
5321 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5322 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5324 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5325 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5326 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5328 ResetTouchCallbacks();
5330 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5332 actorC.LowerBelow( actorA );
5333 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5334 application.SendNotification();
5335 application.Render();
5337 application.ProcessEvent( touchEvent );
5339 glAbstraction.ResetSetUniformCallStack();
5340 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5342 application.Render();
5343 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5345 // Test order of uniforms in stack
5346 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5347 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5348 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5350 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5351 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5353 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5354 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5355 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5357 ResetTouchCallbacks();
5359 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5361 actorB.LowerBelow( actorC );
5362 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5363 application.SendNotification();
5364 application.Render();
5366 application.ProcessEvent( touchEvent );
5368 glAbstraction.ResetSetUniformCallStack();
5369 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5371 application.Render();
5372 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5374 // Test order of uniforms in stack
5375 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5376 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5377 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5379 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5380 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5386 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5388 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5390 TestApplication application;
5392 Stage stage( Stage::GetCurrent() );
5394 Actor parentA = Actor::New();
5395 Actor parentB = Actor::New();
5396 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5397 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5398 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5399 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5401 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5402 parentA.SetParentOrigin( ParentOrigin::CENTER );
5404 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5405 parentB.SetParentOrigin( ParentOrigin::CENTER );
5407 stage.Add( parentA );
5408 stage.Add( parentB );
5410 Actor actorA = Actor::New();
5411 Actor actorB = Actor::New();
5412 Actor actorC = Actor::New();
5414 parentA.Add( actorA );
5415 parentA.Add( actorB );
5417 tet_printf( "Actor C added to different parent from A and B \n" );
5418 parentB.Add( actorC );
5420 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5421 actorA.SetParentOrigin( ParentOrigin::CENTER );
5423 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5424 actorB.SetParentOrigin( ParentOrigin::CENTER );
5426 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5427 actorC.SetParentOrigin( ParentOrigin::CENTER );
5429 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5430 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5432 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5433 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5435 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5436 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5438 ResetTouchCallbacks();
5440 application.SendNotification();
5441 application.Render();
5443 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5444 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5445 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5447 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5448 // Only top actor will get touched.
5449 actorA.TouchSignal().Connect( TestTouchCallback );
5450 actorB.TouchSignal().Connect( TestTouchCallback2 );
5451 actorC.TouchSignal().Connect( TestTouchCallback3 );
5453 Dali::Integration::Point point;
5454 point.SetDeviceId( 1 );
5455 point.SetState( PointState::DOWN );
5456 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5457 Dali::Integration::TouchEvent touchEvent;
5458 touchEvent.AddPoint( point );
5460 application.ProcessEvent( touchEvent );
5462 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5463 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5464 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5466 ResetTouchCallbacks();
5468 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5470 actorA.RaiseAbove( actorC );
5471 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5472 application.SendNotification();
5474 application.ProcessEvent( touchEvent ); // touch event
5476 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5477 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5478 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5480 ResetTouchCallbacks();
5485 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5487 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5489 TestApplication application;
5491 Stage stage( Stage::GetCurrent() );
5493 Actor actorA = Actor::New();
5494 Actor actorB = Actor::New();
5495 Actor actorC = Actor::New();
5497 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5498 actorA.SetParentOrigin( ParentOrigin::CENTER );
5500 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5501 actorB.SetParentOrigin( ParentOrigin::CENTER );
5503 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5504 actorC.SetParentOrigin( ParentOrigin::CENTER );
5506 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5507 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5509 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5510 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5512 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5513 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5515 ResetTouchCallbacks();
5517 application.SendNotification();
5518 application.Render();
5520 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5521 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5522 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5524 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5525 // Only top actor will get touched.
5526 actorA.TouchSignal().Connect( TestTouchCallback );
5527 actorB.TouchSignal().Connect( TestTouchCallback2 );
5528 actorC.TouchSignal().Connect( TestTouchCallback3 );
5530 Dali::Integration::Point point;
5531 point.SetDeviceId( 1 );
5532 point.SetState( PointState::DOWN );
5533 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5534 Dali::Integration::TouchEvent touchEvent;
5535 touchEvent.AddPoint( point );
5537 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5539 actorA.RaiseAbove( actorC );
5540 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5541 application.SendNotification();
5543 application.ProcessEvent( touchEvent );
5545 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5547 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5548 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5549 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5551 ResetTouchCallbacks();
5553 stage.Add ( actorB );
5554 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5555 actorA.LowerBelow( actorC );
5557 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5558 application.SendNotification();
5559 application.Render();
5561 application.ProcessEvent( touchEvent );
5563 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5564 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5565 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5566 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5568 ResetTouchCallbacks();
5570 tet_printf( "Adding Actor A to stage, will be on top\n" );
5572 stage.Add ( actorA );
5573 application.SendNotification();
5574 application.Render();
5576 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5577 actorB.RaiseAbove( actorC );
5578 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5579 application.SendNotification();
5581 application.ProcessEvent( touchEvent );
5583 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5584 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5585 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5586 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5588 ResetTouchCallbacks();
5590 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5591 actorA.LowerBelow( actorC );
5592 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5593 application.SendNotification();
5595 application.ProcessEvent( touchEvent );
5597 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5598 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5599 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5600 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5602 ResetTouchCallbacks();
5604 stage.Add ( actorC );
5605 actorA.RaiseAbove( actorC );
5606 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5607 application.SendNotification();
5608 application.Render();
5610 application.ProcessEvent( touchEvent );
5612 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5613 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5614 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5615 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5620 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5622 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5624 TestApplication application;
5626 Stage stage( Stage::GetCurrent() );
5628 Actor actorA = Actor::New();
5629 Actor actorB = Actor::New();
5630 Actor actorC = Actor::New();
5632 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5633 actorA.SetParentOrigin( ParentOrigin::CENTER );
5635 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5636 actorB.SetParentOrigin( ParentOrigin::CENTER );
5638 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5639 actorC.SetParentOrigin( ParentOrigin::CENTER );
5641 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5642 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5644 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5645 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5647 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5648 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5650 ResetTouchCallbacks();
5652 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5653 // Only top actor will get touched.
5654 actorA.TouchSignal().Connect( TestTouchCallback );
5655 actorB.TouchSignal().Connect( TestTouchCallback2 );
5656 actorC.TouchSignal().Connect( TestTouchCallback3 );
5658 Dali::Integration::Point point;
5659 point.SetDeviceId( 1 );
5660 point.SetState( PointState::DOWN );
5661 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5662 Dali::Integration::TouchEvent touchEvent;
5663 touchEvent.AddPoint( point );
5665 stage.Add ( actorA );
5666 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5669 application.SendNotification();
5670 application.Render();
5672 application.ProcessEvent( touchEvent );
5674 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5676 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5677 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5678 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5680 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5681 ResetTouchCallbacks();
5684 // Sort actor tree before next touch event
5685 application.SendNotification();
5686 application.Render();
5688 application.ProcessEvent( touchEvent );
5690 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5692 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5693 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5694 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5695 ResetTouchCallbacks();
5697 tet_printf( "Lower actor C below B but C not parented\n" );
5700 // Sort actor tree before next touch event
5701 application.SendNotification();
5702 application.Render();
5704 application.ProcessEvent( touchEvent );
5706 tet_printf( "Not parented so Lower should show no effect\n" );
5708 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5709 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5710 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5711 ResetTouchCallbacks();
5713 tet_printf( "Raise actor B to top\n" );
5715 actorB.RaiseToTop();
5716 // Sort actor tree before next touch event
5717 application.SendNotification();
5718 application.Render();
5720 application.ProcessEvent( touchEvent );
5722 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5724 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5725 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5726 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5727 ResetTouchCallbacks();
5729 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5731 stage.Add ( actorB );
5733 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5735 actorC.LowerToBottom();
5736 application.SendNotification();
5737 application.Render();
5739 application.ProcessEvent( touchEvent );
5741 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5743 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5744 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5745 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5746 ResetTouchCallbacks();
5752 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5754 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5756 TestApplication application;
5758 Stage stage( Stage::GetCurrent() );
5760 Actor actorA = Actor::New();
5761 Actor actorB = Actor::New();
5762 Actor actorC = Actor::New();
5764 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5765 actorA.SetParentOrigin( ParentOrigin::CENTER );
5767 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5768 actorB.SetParentOrigin( ParentOrigin::CENTER );
5770 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5771 actorC.SetParentOrigin( ParentOrigin::CENTER );
5773 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5774 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5776 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5777 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5779 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5780 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5782 stage.Add( actorA );
5783 stage.Add( actorB );
5784 stage.Add( actorC );
5786 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5787 // Only top actor will get touched.
5788 actorA.TouchSignal().Connect( TestTouchCallback );
5789 actorB.TouchSignal().Connect( TestTouchCallback2 );
5790 actorC.TouchSignal().Connect( TestTouchCallback3 );
5792 ResetTouchCallbacks();
5794 application.SendNotification();
5795 application.Render();
5797 Dali::Integration::Point point;
5798 point.SetDeviceId( 1 );
5799 point.SetState( PointState::DOWN );
5800 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5801 Dali::Integration::TouchEvent touchEvent;
5802 touchEvent.AddPoint( point );
5804 application.ProcessEvent( touchEvent );
5806 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5807 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5808 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5810 ResetTouchCallbacks();
5812 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5814 actorA.RaiseAbove( actorA );
5815 application.SendNotification();
5816 application.Render();
5818 application.ProcessEvent( touchEvent );
5820 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5822 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5823 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5824 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5826 ResetTouchCallbacks();
5828 actorA.RaiseAbove( actorC );
5829 application.SendNotification();
5830 application.Render();
5832 application.ProcessEvent( touchEvent );
5834 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5835 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5836 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5837 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5842 int UtcDaliActorGetScreenPosition(void)
5844 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5846 TestApplication application;
5848 Stage stage( Stage::GetCurrent() );
5850 Actor actorA = Actor::New();
5851 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5853 Vector2 size2( 10.0f, 20.0f );
5854 actorA.SetSize( size2 );
5856 actorA.SetPosition( 0.f, 0.f );
5858 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5860 stage.Add( actorA );
5862 application.SendNotification();
5863 application.Render();
5865 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5866 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5868 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5869 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5871 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5872 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5874 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5876 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5878 application.SendNotification();
5879 application.Render();
5881 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5882 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5884 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5885 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5887 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5888 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5890 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5892 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5894 application.SendNotification();
5895 application.Render();
5897 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5898 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5900 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5901 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5903 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5904 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5906 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5908 actorA.SetPosition( 30.0, 0.0 );
5910 application.SendNotification();
5911 application.Render();
5913 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5914 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5916 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5917 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5919 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5920 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5922 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5924 actorA.SetPosition( 30.0, 420.0 );
5926 application.SendNotification();
5927 application.Render();
5929 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5930 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5932 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5933 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5935 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5936 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5938 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
5940 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5941 actorA.SetPosition( 30.0, 30.0 );
5943 Actor actorB = Actor::New();
5944 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5945 actorB.SetSize( size2 );
5946 actorB.SetPosition( 10.f, 10.f );
5947 actorA.Add( actorB );
5949 actorA.SetScale( 2.0f );
5951 application.SendNotification();
5952 application.Render();
5954 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5956 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
5957 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
5962 int UtcDaliActorGetScreenPositionAfterScaling(void)
5964 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5966 TestApplication application;
5968 Stage stage( Stage::GetCurrent() );
5970 Actor actorA = Actor::New();
5971 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5973 Vector2 size2( 10.0f, 20.0f );
5974 actorA.SetSize( size2 );
5975 actorA.SetScale( 1.5f );
5976 actorA.SetPosition( 0.f, 0.f );
5978 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5980 stage.Add( actorA );
5982 application.SendNotification();
5983 application.Render();
5985 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5986 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5988 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5989 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5991 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5992 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5994 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5996 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5998 application.SendNotification();
5999 application.Render();
6001 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6002 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6004 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6005 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6007 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6008 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6013 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6015 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6017 TestApplication application;
6019 Stage stage( Stage::GetCurrent() );
6021 Actor actorA = Actor::New();
6022 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6023 actorA.SetParentOrigin( ParentOrigin::CENTER );
6024 Vector2 size2( 10.0f, 20.0f );
6025 actorA.SetSize( size2 );
6026 actorA.SetPosition( 0.f, 0.f );
6028 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6030 stage.Add( actorA );
6032 application.SendNotification();
6033 application.Render();
6035 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6036 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6038 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6039 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6041 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6042 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6044 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6046 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6047 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6049 application.SendNotification();
6050 application.Render();
6052 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6053 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6055 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6056 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6058 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6059 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6065 int UtcDaliActorGetScreenPositionWithChildActors(void)
6067 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6069 TestApplication application;
6071 Stage stage( Stage::GetCurrent() );
6073 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6075 Actor actorA = Actor::New();
6076 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6077 actorA.SetParentOrigin( ParentOrigin::CENTER );
6078 Vector2 size1( 10.0f, 20.0f );
6079 actorA.SetSize( size1 );
6080 actorA.SetPosition( 0.f, 0.f );
6082 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6084 Actor parentActorA = Actor::New();
6085 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6086 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6087 Vector2 size2( 30.0f, 60.0f );
6088 parentActorA.SetSize( size2 );
6089 parentActorA.SetPosition( 0.f, 0.f );
6091 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6093 stage.Add( parentActorA );
6094 parentActorA.Add ( actorA );
6096 application.SendNotification();
6097 application.Render();
6099 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6100 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6102 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6103 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6105 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6106 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6108 tet_infoline( "Test 2\n");
6110 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6112 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6113 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6115 application.SendNotification();
6116 application.Render();
6118 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6119 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6121 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6122 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6124 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6125 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6130 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6132 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6134 TestApplication application;
6136 Stage stage( Stage::GetCurrent() );
6138 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6140 Actor actorA = Actor::New();
6141 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6142 actorA.SetParentOrigin( ParentOrigin::CENTER );
6143 Vector2 size1( 10.0f, 20.0f );
6144 actorA.SetSize( size1 );
6145 actorA.SetPosition( 0.f, 0.f );
6147 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6149 Actor parentActorA = Actor::New();
6150 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6151 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6152 Vector2 size2( 30.0f, 60.0f );
6153 parentActorA.SetSize( size2 );
6154 parentActorA.SetPosition( 0.f, 0.f );
6156 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6158 Actor grandParentActorA = Actor::New();
6159 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6160 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6161 Vector2 size3( 60.0f, 120.0f );
6162 grandParentActorA.SetSize( size3 );
6163 grandParentActorA.SetPosition( 0.f, 0.f );
6165 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6167 stage.Add( grandParentActorA );
6168 grandParentActorA.Add ( parentActorA );
6170 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6172 parentActorA.Add ( actorA );
6174 application.SendNotification();
6175 application.Render();
6177 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6178 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6180 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6181 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6183 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6184 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6189 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6191 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6193 TestApplication application;
6195 Stage stage( Stage::GetCurrent() );
6197 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6199 Actor actorA = Actor::New();
6200 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6201 actorA.SetParentOrigin( ParentOrigin::CENTER );
6202 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6203 actorA.SetSize( 10.0f, 20.0f );
6204 stage.Add( actorA );
6206 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6208 Actor actorB = Actor::New();
6209 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6210 actorB.SetParentOrigin( ParentOrigin::CENTER );
6211 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6212 Vector2 actorBSize( 30.0f, 60.0f );
6213 actorB.SetSize( actorBSize );
6214 stage.Add( actorB );
6216 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6218 Actor actorC = Actor::New();
6219 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6220 actorC.SetParentOrigin( ParentOrigin::CENTER );
6221 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6222 Vector2 actorCSize( 60.0f, 120.0f );
6223 actorC.SetSize( actorCSize );
6224 stage.Add( actorC );
6226 application.SendNotification();
6227 application.Render();
6229 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6231 Vector2 center( stage.GetSize() * 0.5f );
6233 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6234 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6235 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6237 tet_infoline( "Add scale to all actors" );
6239 actorA.SetScale( 2.0f );
6240 actorB.SetScale( 2.0f );
6241 actorC.SetScale( 2.0f );
6243 application.SendNotification();
6244 application.Render();
6246 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6247 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6248 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6253 int utcDaliActorPositionUsesAnchorPoint(void)
6255 TestApplication application;
6256 tet_infoline( "Check default behaviour\n" );
6258 Actor actor = Actor::New();
6259 actor.SetParentOrigin( ParentOrigin::CENTER );
6260 actor.SetAnchorPoint( AnchorPoint::CENTER );
6261 actor.SetSize( 100.0f, 100.0f );
6262 Stage::GetCurrent().Add( actor );
6264 application.SendNotification();
6265 application.Render();
6267 tet_infoline( "Check that the world position is in the center\n" );
6268 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6270 tet_infoline( "Set the position uses anchor point property to false\n" );
6271 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6273 application.SendNotification();
6274 application.Render();
6276 tet_infoline( "Check that the world position has changed appropriately\n" );
6277 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6282 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6284 TestApplication application;
6285 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6287 Actor actor = Actor::New();
6288 actor.SetParentOrigin( ParentOrigin::CENTER );
6289 actor.SetAnchorPoint( AnchorPoint::CENTER );
6290 actor.SetSize( 100.0f, 100.0f );
6291 actor.SetScale( 2.0f );
6292 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6293 Stage::GetCurrent().Add( actor );
6295 application.SendNotification();
6296 application.Render();
6298 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6299 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6301 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6302 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6303 application.SendNotification();
6304 application.Render();
6305 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6307 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6308 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6309 application.SendNotification();
6310 application.Render();
6311 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6316 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6318 TestApplication application;
6319 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6321 Actor actor = Actor::New();
6322 actor.SetParentOrigin( ParentOrigin::CENTER );
6323 actor.SetAnchorPoint( AnchorPoint::CENTER );
6324 actor.SetSize( 100.0f, 100.0f );
6325 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6326 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6327 Stage::GetCurrent().Add( actor );
6329 application.SendNotification();
6330 application.Render();
6332 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6333 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6335 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6336 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6337 application.SendNotification();
6338 application.Render();
6339 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6341 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6342 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6343 application.SendNotification();
6344 application.Render();
6345 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6350 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6352 TestApplication application;
6353 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6355 Actor actor = Actor::New();
6356 actor.SetParentOrigin( ParentOrigin::CENTER );
6357 actor.SetAnchorPoint( AnchorPoint::CENTER );
6358 actor.SetSize( 100.0f, 100.0f );
6359 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6360 actor.SetScale( 2.0f );
6361 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6362 Stage::GetCurrent().Add( actor );
6364 application.SendNotification();
6365 application.Render();
6367 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6368 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6370 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6371 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6372 application.SendNotification();
6373 application.Render();
6374 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6376 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6377 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6378 application.SendNotification();
6379 application.Render();
6380 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6385 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6387 TestApplication application;
6388 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6390 Actor parent = Actor::New();
6392 Stage::GetCurrent().Add( parent );
6393 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6395 Actor actor = Actor::New();
6396 actor.SetParentOrigin( ParentOrigin::CENTER );
6397 actor.SetAnchorPoint( AnchorPoint::CENTER );
6398 actor.SetSize( 100.0f, 100.0f );
6399 actor.SetInheritScale( false );
6400 actor.SetInheritOrientation( false );
6401 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6402 parent.Add( actor );
6404 application.SendNotification();
6405 application.Render();
6407 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6409 tet_infoline( "Check the world position is in the right place\n" );
6410 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6412 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6413 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6414 application.SendNotification();
6415 application.Render();
6416 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6418 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6419 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6420 application.SendNotification();
6421 application.Render();
6422 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6427 int utcDaliActorVisibilityChangeSignalSelf(void)
6429 TestApplication application;
6430 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6432 Actor actor = Actor::New();
6434 VisibilityChangedFunctorData data;
6435 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6437 actor.SetVisible( false );
6439 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6441 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6444 actor.SetVisible( false );
6445 data.Check( false /* not called */, TEST_LOCATION );
6447 tet_infoline( "Change the visibility using properties, ensure called" );
6450 actor.SetProperty( Actor::Property::VISIBLE, true );
6451 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6453 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6456 actor.SetProperty( Actor::Property::VISIBLE, true );
6457 data.Check( false /* not called */, TEST_LOCATION );
6462 int utcDaliActorVisibilityChangeSignalChildren(void)
6464 TestApplication application;
6465 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6467 Actor parent = Actor::New();
6468 Actor child = Actor::New();
6469 parent.Add( child );
6471 Actor grandChild = Actor::New();
6472 child.Add( grandChild );
6474 VisibilityChangedFunctorData parentData;
6475 VisibilityChangedFunctorData childData;
6476 VisibilityChangedFunctorData grandChildData;
6478 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6479 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6480 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6482 parent.SetVisible( false );
6483 parentData.Check( false /* not called */, TEST_LOCATION );
6484 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6485 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6487 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6490 grandChildData.Reset();
6492 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6494 parent.SetVisible( true );
6495 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6496 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6497 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6499 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6502 grandChildData.Reset();
6504 parent.SetVisible( true );
6505 parentData.Check( false /* not called */, TEST_LOCATION );
6506 childData.Check( false /* not called */, TEST_LOCATION );
6507 grandChildData.Check( false /* not called */, TEST_LOCATION );
6512 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6514 TestApplication application;
6515 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6517 Actor actor = Actor::New();
6518 Stage::GetCurrent().Add( actor );
6520 application.SendNotification();
6521 application.Render();
6523 VisibilityChangedFunctorData data;
6524 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6526 Animation animation = Animation::New( 1.0f );
6527 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6529 data.Check( false, TEST_LOCATION );
6530 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6531 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6533 tet_infoline( "Play the animation and check the property value" );
6536 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6537 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6539 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6540 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6542 application.SendNotification();
6543 application.Render( 1100 ); // After the animation
6545 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6551 int utcDaliActorVisibilityChangeSignalByName(void)
6553 TestApplication application;
6554 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6556 Actor actor = Actor::New();
6558 bool signalCalled=false;
6559 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6560 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6561 actor.SetVisible( false );
6562 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6564 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6565 signalCalled = false;
6566 actor.SetVisible( false );
6567 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6569 tet_infoline( "Change the visibility using properties, ensure called" );
6570 actor.SetProperty( Actor::Property::VISIBLE, true );
6571 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6573 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6574 signalCalled = false;
6576 actor.SetProperty( Actor::Property::VISIBLE, true );
6577 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6583 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6585 gLayoutDirectionType = type;
6588 int UtcDaliActorLayoutDirectionProperty(void)
6590 TestApplication application;
6591 tet_infoline( "Check layout direction property" );
6593 Actor actor0 = Actor::New();
6594 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6595 Stage::GetCurrent().Add( actor0 );
6597 application.SendNotification();
6598 application.Render();
6600 Actor actor1 = Actor::New();
6601 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6602 Actor actor2 = Actor::New();
6603 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6604 Actor actor3 = Actor::New();
6605 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6606 Actor actor4 = Actor::New();
6607 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6608 Actor actor5 = Actor::New();
6609 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6610 Actor actor6 = Actor::New();
6611 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6612 Actor actor7 = Actor::New();
6613 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6614 Actor actor8 = Actor::New();
6615 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6616 Actor actor9 = Actor::New();
6617 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6619 actor1.Add( actor2 );
6620 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6621 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6623 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6624 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6625 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6627 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6628 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6629 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6631 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6632 actor0.Add( actor1 );
6633 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6634 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6636 Stage::GetCurrent().Add( actor3 );
6637 actor3.Add( actor4 );
6638 actor4.Add( actor5 );
6639 actor5.Add( actor6 );
6640 actor5.Add( actor7 );
6641 actor7.Add( actor8 );
6642 actor8.Add( actor9 );
6643 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6644 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6646 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6647 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6648 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6650 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6652 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6653 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6654 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6655 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6656 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6657 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6658 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6660 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6661 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6662 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6664 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6665 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6666 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6667 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6669 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6670 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6671 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6677 struct LayoutDirectionFunctor
6679 LayoutDirectionFunctor(bool& signalCalled)
6680 : mSignalCalled( signalCalled )
6684 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6685 : mSignalCalled( rhs.mSignalCalled )
6691 mSignalCalled = true;
6694 bool& mSignalCalled;
6697 int UtcDaliActorLayoutDirectionSignal(void)
6699 TestApplication application;
6700 tet_infoline( "Check changing layout direction property sends a signal" );
6702 Actor actor = Actor::New();
6703 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6704 Stage::GetCurrent().Add( actor );
6705 bool signalCalled = false;
6706 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6708 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6709 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6711 // Test that writing the same value doesn't send a signal
6712 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6713 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6715 // Test that writing a different value sends the signal
6716 signalCalled = false;
6717 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6718 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6720 signalCalled = false;
6721 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6722 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6727 struct ChildAddedSignalCheck
6729 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6730 : mSignalReceived( signalReceived ),
6731 mChildHandle( childHandle )
6735 void operator() ( Actor childHandle )
6737 mSignalReceived = true;
6738 mChildHandle = childHandle;
6742 mSignalReceived = true;
6743 mChildHandle = Actor();
6746 bool& mSignalReceived;
6747 Actor& mChildHandle;
6750 int UtcDaliChildAddedSignalP1(void)
6752 TestApplication application;
6753 auto stage = Stage::GetCurrent();
6755 bool signalReceived=false;
6758 ChildAddedSignalCheck signal( signalReceived, childActor );
6759 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6760 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6762 auto actorA = Actor::New();
6763 stage.Add( actorA );
6764 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6765 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6766 signalReceived = false;
6768 auto actorB = Actor::New();
6769 stage.Add( actorB );
6770 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6771 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6777 int UtcDaliChildAddedSignalP2(void)
6779 TestApplication application;
6780 auto stage = Stage::GetCurrent();
6782 bool signalReceived=false;
6785 ChildAddedSignalCheck signal( signalReceived, childActor );
6786 tet_infoline( "Connect to childAdded signal by name" );
6788 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6789 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6791 auto actorA = Actor::New();
6792 stage.Add( actorA );
6793 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6795 // Can't test which actor was added; signal signature is void() when connecting via name.
6796 signalReceived = false;
6798 auto actorB = Actor::New();
6799 stage.Add( actorB );
6800 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6805 int UtcDaliChildAddedSignalN(void)
6807 TestApplication application;
6808 auto stage = Stage::GetCurrent();
6810 bool signalReceived=false;
6813 ChildAddedSignalCheck signal( signalReceived, childActor );
6814 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6815 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6817 auto actorA = Actor::New();
6818 stage.Add( actorA );
6819 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6820 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6821 signalReceived = false;
6823 auto actorB = Actor::New();
6824 actorA.Add( actorB );
6825 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6830 struct ChildRemovedSignalCheck
6832 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6833 : mSignalReceived( signalReceived ),
6834 mChildHandle( childHandle )
6838 void operator() ( Actor childHandle )
6840 mSignalReceived = true;
6841 mChildHandle = childHandle;
6846 mSignalReceived = true;
6849 bool& mSignalReceived;
6850 Actor& mChildHandle;
6853 int UtcDaliChildRemovedSignalP1(void)
6855 TestApplication application;
6856 auto stage = Stage::GetCurrent();
6858 bool signalReceived=false;
6861 ChildRemovedSignalCheck signal( signalReceived, childActor );
6862 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6863 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6865 auto actorA = Actor::New();
6866 stage.Add( actorA );
6867 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6868 DALI_TEST_CHECK( !childActor );
6870 stage.Remove( actorA );
6871 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6872 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6874 signalReceived = false;
6875 auto actorB = Actor::New();
6876 stage.Add( actorB );
6877 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6879 stage.Remove( actorB );
6880 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6881 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6886 int UtcDaliChildRemovedSignalP2(void)
6888 TestApplication application;
6889 auto stage = Stage::GetCurrent();
6891 bool signalReceived=false;
6894 ChildAddedSignalCheck signal( signalReceived, childActor );
6895 tet_infoline( "Connect to childRemoved signal by name" );
6897 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
6898 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6900 auto actorA = Actor::New();
6901 stage.Add( actorA );
6902 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6904 stage.Remove( actorA );
6905 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6907 signalReceived = false;
6908 auto actorB = Actor::New();
6909 stage.Add( actorB );
6910 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6912 stage.Remove( actorB );
6913 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6919 int UtcDaliChildRemovedSignalN(void)
6921 TestApplication application;
6922 auto stage = Stage::GetCurrent();
6924 bool signalReceived=false;
6927 ChildRemovedSignalCheck signal( signalReceived, childActor );
6928 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6929 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6931 auto actorA = Actor::New();
6932 stage.Add( actorA );
6934 auto actorB = Actor::New();
6935 actorA.Add( actorB );
6937 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6938 DALI_TEST_CHECK( ! childActor );
6940 actorA.Remove( actorB );
6941 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6946 int UtcDaliChildMovedSignalP(void)
6948 TestApplication application;
6949 auto stage = Stage::GetCurrent();
6951 bool addedASignalReceived = false;
6952 bool removedASignalReceived = false;
6953 bool addedBSignalReceived = false;
6954 bool removedBSignalReceived = false;
6957 auto actorA = Actor::New();
6958 auto actorB = Actor::New();
6959 stage.Add( actorA );
6960 stage.Add( actorB );
6962 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
6963 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
6964 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
6965 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
6967 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
6968 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
6969 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
6970 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
6972 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
6973 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
6974 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
6975 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
6977 // Create a child of A
6979 auto child = Actor::New();
6980 actorA.Add( child );
6982 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
6983 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
6984 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
6985 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
6986 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
6989 addedASignalReceived = false;
6990 addedBSignalReceived = false;
6991 removedASignalReceived = false;
6992 removedBSignalReceived = false;
6994 actorB.Add( child ); // Expect this child to be re-parented
6995 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
6996 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
6997 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
6998 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7000 // Move child back to A:
7001 addedASignalReceived = false;
7002 addedBSignalReceived = false;
7003 removedASignalReceived = false;
7004 removedBSignalReceived = false;
7006 actorA.Add( child ); // Expect this child to be re-parented
7007 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7008 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7009 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7010 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );