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, Actor& actor)
252 : mSignalCalled( signalCalled ),
256 void operator()( Actor actor )
258 mSignalCalled = true;
266 struct CulledPropertyNotificationFunctor
268 CulledPropertyNotificationFunctor( bool& signalCalled, PropertyNotification& propertyNotification )
269 : mSignalCalled( signalCalled ),
270 mPropertyNotification( propertyNotification )
273 void operator()( PropertyNotification& source )
275 mSignalCalled = true;
276 mPropertyNotification = source;
280 PropertyNotification& mPropertyNotification;
283 } // anonymous namespace
286 //& purpose: Testing New API
287 int UtcDaliActorNew(void)
289 TestApplication application;
291 Actor actor = Actor::New();
293 DALI_TEST_CHECK(actor);
297 //& purpose: Testing Dali::Actor::DownCast()
298 int UtcDaliActorDownCastP(void)
300 TestApplication application;
301 tet_infoline("Testing Dali::Actor::DownCast()");
303 Actor actor = Actor::New();
304 BaseHandle object(actor);
305 Actor actor2 = Actor::DownCast(object);
306 DALI_TEST_CHECK(actor2);
310 //& purpose: Testing Dali::Actor::DownCast()
311 int UtcDaliActorDownCastN(void)
313 TestApplication application;
314 tet_infoline("Testing Dali::Actor::DownCast()");
316 BaseHandle unInitializedObject;
317 Actor actor = Actor::DownCast(unInitializedObject);
318 DALI_TEST_CHECK(!actor);
322 //& purpose: Testing Dali::Actor::GetName()
323 int UtcDaliActorGetName(void)
325 TestApplication application;
327 Actor actor = Actor::New();
329 DALI_TEST_CHECK(actor.GetName().empty());
333 //& purpose: Testing Dali::Actor::SetName()
334 int UtcDaliActorSetName(void)
336 TestApplication application;
338 string str("ActorName");
339 Actor actor = Actor::New();
342 DALI_TEST_CHECK(actor.GetName() == str);
346 int UtcDaliActorGetId(void)
348 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
349 TestApplication application;
351 Actor first = Actor::New();
352 Actor second = Actor::New();
353 Actor third = Actor::New();
355 DALI_TEST_CHECK(first.GetId() != second.GetId());
356 DALI_TEST_CHECK(second.GetId() != third.GetId());
360 int UtcDaliActorIsRoot(void)
362 TestApplication application;
364 Actor actor = Actor::New();
365 DALI_TEST_CHECK(!actor.IsRoot());
367 // get the root layer
368 actor = Stage::GetCurrent().GetLayer( 0 );
369 DALI_TEST_CHECK( actor.IsRoot() );
373 int UtcDaliActorOnStage(void)
375 TestApplication application;
377 Actor actor = Actor::New();
378 DALI_TEST_CHECK( !actor.OnStage() );
380 // get the root layer
381 actor = Stage::GetCurrent().GetLayer( 0 );
382 DALI_TEST_CHECK( actor.OnStage() );
386 int UtcDaliActorIsLayer(void)
388 TestApplication application;
390 Actor actor = Actor::New();
391 DALI_TEST_CHECK( !actor.IsLayer() );
393 // get the root layer
394 actor = Stage::GetCurrent().GetLayer( 0 );
395 DALI_TEST_CHECK( actor.IsLayer() );
399 int UtcDaliActorGetLayer(void)
401 TestApplication application;
403 Actor actor = Actor::New();
404 Stage::GetCurrent().Add(actor);
405 Layer layer = actor.GetLayer();
407 DALI_TEST_CHECK(layer);
409 // get the root layers layer
410 actor = Stage::GetCurrent().GetLayer( 0 );
411 DALI_TEST_CHECK( actor.GetLayer() );
415 int UtcDaliActorAddP(void)
417 tet_infoline("Testing Actor::Add");
418 TestApplication application;
420 Actor parent = Actor::New();
421 Actor child = Actor::New();
423 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
427 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
429 Actor parent2 = Actor::New();
430 parent2.Add( child );
432 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
433 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
435 // try Adding to same parent again, works
436 parent2.Add( child );
437 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
439 // try reparenting an orphaned child
441 Actor temporaryParent = Actor::New();
442 temporaryParent.Add( child );
443 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
445 // temporaryParent has now died, reparent the orphaned child
446 parent2.Add( child );
447 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
452 int UtcDaliActorAddN(void)
454 tet_infoline("Testing Actor::Add");
455 TestApplication application;
457 Actor child = Actor::New();
459 Actor parent2 = Actor::New();
460 parent2.Add( child );
465 parent2.Add( parent2 );
466 tet_printf("Assertion test failed - no Exception\n" );
467 tet_result(TET_FAIL);
469 catch(Dali::DaliException& e)
471 DALI_TEST_PRINT_ASSERT( e );
472 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
473 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
477 tet_printf("Assertion test failed - wrong Exception\n" );
478 tet_result(TET_FAIL);
481 // try reparenting root
484 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
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, "!child.IsRoot()", 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);
504 parent2.Add( empty );
505 tet_printf("Assertion test failed - no Exception\n" );
506 tet_result(TET_FAIL);
508 catch(Dali::DaliException& e)
510 DALI_TEST_PRINT_ASSERT( e );
511 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
512 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
516 tet_printf("Assertion test failed - wrong Exception\n" );
517 tet_result(TET_FAIL);
523 int UtcDaliActorRemoveN(void)
525 tet_infoline("Testing Actor::Remove");
526 TestApplication application;
528 Actor parent = Actor::New();
529 Actor child = Actor::New();
530 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
533 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
535 parent.Remove(child);
536 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
538 // remove again, no problem
539 parent.Remove(child);
540 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
544 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
545 // try Remove self, its a no-op
546 parent.Remove( parent );
547 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
553 parent.Remove( empty );
554 tet_printf("Assertion test failed - no Exception\n" );
555 tet_result(TET_FAIL);
557 catch(Dali::DaliException& e)
559 DALI_TEST_PRINT_ASSERT( e );
560 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
561 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
565 tet_printf("Assertion test failed - wrong Exception\n" );
566 tet_result(TET_FAIL);
571 int UtcDaliActorRemoveP(void)
573 TestApplication application;
575 Actor parent = Actor::New();
576 Actor child = Actor::New();
577 Actor random = Actor::New();
579 Stage::GetCurrent().Add( parent );
581 DALI_TEST_CHECK(parent.GetChildCount() == 0);
585 DALI_TEST_CHECK(parent.GetChildCount() == 1);
587 parent.Remove(random);
589 DALI_TEST_CHECK(parent.GetChildCount() == 1);
591 Stage::GetCurrent().Remove( parent );
593 DALI_TEST_CHECK(parent.GetChildCount() == 1);
597 int UtcDaliActorGetChildCount(void)
599 TestApplication application;
601 Actor parent = Actor::New();
602 Actor child = Actor::New();
604 DALI_TEST_CHECK(parent.GetChildCount() == 0);
608 DALI_TEST_CHECK(parent.GetChildCount() == 1);
612 int UtcDaliActorGetChildren01(void)
614 TestApplication application;
616 Actor parent = Actor::New();
617 Actor first = Actor::New();
618 Actor second = Actor::New();
619 Actor third = Actor::New();
625 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
626 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
627 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
631 int UtcDaliActorGetChildren02(void)
633 TestApplication application;
635 Actor parent = Actor::New();
636 Actor first = Actor::New();
637 Actor second = Actor::New();
638 Actor third = Actor::New();
644 const Actor& constParent = parent;
646 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
647 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
648 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
652 int UtcDaliActorGetParent01(void)
654 TestApplication application;
656 Actor parent = Actor::New();
657 Actor child = Actor::New();
661 DALI_TEST_CHECK(child.GetParent() == parent);
665 int UtcDaliActorGetParent02(void)
667 TestApplication application;
669 Actor actor = Actor::New();
671 DALI_TEST_CHECK(!actor.GetParent());
675 int UtcDaliActorCustomProperty(void)
677 TestApplication application;
679 Actor actor = Actor::New();
680 Stage::GetCurrent().Add( actor );
682 float startValue(1.0f);
683 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
684 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
686 application.SendNotification();
687 application.Render(0);
688 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
690 actor.SetProperty( index, 5.0f );
692 application.SendNotification();
693 application.Render(0);
694 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
698 int UtcDaliActorCustomPropertyIntToFloat(void)
700 TestApplication application;
702 Actor actor = Actor::New();
703 Stage::GetCurrent().Add( actor );
705 float startValue(5.0f);
706 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
707 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
709 application.SendNotification();
710 application.Render(0);
711 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
713 actor.SetProperty( index, int(1) );
715 application.SendNotification();
716 application.Render(0);
717 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
721 int UtcDaliActorCustomPropertyFloatToInt(void)
723 TestApplication application;
725 Actor actor = Actor::New();
726 Stage::GetCurrent().Add( actor );
729 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
730 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
732 application.SendNotification();
733 application.Render(0);
734 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
736 actor.SetProperty( index, float(1.5) );
738 application.SendNotification();
739 application.Render(0);
740 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
744 int UtcDaliActorSetParentOrigin(void)
746 TestApplication application;
748 Actor actor = Actor::New();
750 Vector3 vector(0.7f, 0.8f, 0.9f);
751 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
753 actor.SetParentOrigin(vector);
755 // flush the queue and render once
756 application.SendNotification();
757 application.Render();
759 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
761 Stage::GetCurrent().Add( actor );
763 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
765 // flush the queue and render once
766 application.SendNotification();
767 application.Render();
769 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
771 Stage::GetCurrent().Remove( actor );
775 int UtcDaliActorSetParentOriginIndividual(void)
777 TestApplication application;
779 Actor actor = Actor::New();
781 Vector3 vector(0.7f, 0.8f, 0.9f);
782 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
784 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
786 // flush the queue and render once
787 application.SendNotification();
788 application.Render();
790 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
792 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
794 // flush the queue and render once
795 application.SendNotification();
796 application.Render();
798 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
800 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
802 // flush the queue and render once
803 application.SendNotification();
804 application.Render();
806 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
811 int UtcDaliActorGetCurrentParentOrigin(void)
813 TestApplication application;
815 Actor actor = Actor::New();
817 Vector3 vector(0.7f, 0.8f, 0.9f);
818 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
820 actor.SetParentOrigin(vector);
822 // flush the queue and render once
823 application.SendNotification();
824 application.Render();
826 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
830 int UtcDaliActorSetAnchorPoint(void)
832 TestApplication application;
834 Actor actor = Actor::New();
836 Vector3 vector(0.7f, 0.8f, 0.9f);
837 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
839 actor.SetAnchorPoint(vector);
841 // flush the queue and render once
842 application.SendNotification();
843 application.Render();
845 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
847 Stage::GetCurrent().Add( actor );
849 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
850 // flush the queue and render once
851 application.SendNotification();
852 application.Render();
854 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
856 Stage::GetCurrent().Remove( actor );
860 int UtcDaliActorSetAnchorPointIndividual(void)
862 TestApplication application;
864 Actor actor = Actor::New();
866 Vector3 vector(0.7f, 0.8f, 0.9f);
867 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
869 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
871 // flush the queue and render once
872 application.SendNotification();
873 application.Render();
875 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
877 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
879 // flush the queue and render once
880 application.SendNotification();
881 application.Render();
883 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
885 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
887 // flush the queue and render once
888 application.SendNotification();
889 application.Render();
891 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
896 int UtcDaliActorGetCurrentAnchorPoint(void)
898 TestApplication application;
900 Actor actor = Actor::New();
902 Vector3 vector(0.7f, 0.8f, 0.9f);
903 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
905 actor.SetAnchorPoint(vector);
907 // flush the queue and render once
908 application.SendNotification();
909 application.Render();
911 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
915 // SetSize(float width, float height)
916 int UtcDaliActorSetSize01(void)
918 TestApplication application;
920 Actor actor = Actor::New();
921 Vector3 vector(100.0f, 100.0f, 0.0f);
923 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
925 actor.SetSize(vector.x, vector.y);
927 // Immediately retrieve the size after setting
928 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
929 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
930 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
931 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
932 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
934 // Flush the queue and render once
935 application.SendNotification();
936 application.Render();
938 // Check the size in the new frame
939 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
941 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
942 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
943 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
944 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
945 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
947 // Check async behaviour
948 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
949 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
950 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
951 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
952 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
954 // Change the resize policy and check whether the size stays the same
955 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
957 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
958 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
960 // Set a new size after resize policy is changed and check the new size
961 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
963 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
964 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
966 // Change the resize policy again and check whether the new size stays the same
967 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
969 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
970 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
972 // Set another new size after resize policy is changed and check the new size
973 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
975 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
976 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
981 // SetSize(float width, float height, float depth)
982 int UtcDaliActorSetSize02(void)
984 TestApplication application;
986 Actor actor = Actor::New();
987 Vector3 vector(100.0f, 100.0f, 100.0f);
989 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
991 actor.SetSize(vector.x, vector.y, vector.z);
993 // Immediately check the size after setting
994 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
995 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
997 // flush the queue and render once
998 application.SendNotification();
999 application.Render();
1001 // Check the size in the new frame
1002 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1004 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1005 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1010 // SetSize(Vector2 size)
1011 int UtcDaliActorSetSize03(void)
1013 TestApplication application;
1015 Actor actor = Actor::New();
1016 Vector3 vector(100.0f, 100.0f, 0.0f);
1018 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1020 actor.SetSize(Vector2(vector.x, vector.y));
1022 // Immediately check the size after setting
1023 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1024 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1026 // flush the queue and render once
1027 application.SendNotification();
1028 application.Render();
1030 // Check the size in the new frame
1031 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1033 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1034 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1039 // SetSize(Vector3 size)
1040 int UtcDaliActorSetSize04(void)
1042 TestApplication application;
1044 Actor actor = Actor::New();
1045 Vector3 vector(100.0f, 100.0f, 100.0f);
1047 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1049 actor.SetSize(vector);
1051 // Immediately check the size after setting
1052 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1053 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1055 // flush the queue and render once
1056 application.SendNotification();
1057 application.Render();
1059 // Check the size in the new frame
1060 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1062 Stage::GetCurrent().Add( actor );
1063 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
1065 // Immediately check the size after setting
1066 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1067 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1069 // flush the queue and render once
1070 application.SendNotification();
1071 application.Render();
1073 // Check the size in the new frame
1074 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
1076 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1077 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1079 Stage::GetCurrent().Remove( actor );
1083 int UtcDaliActorSetSizeIndividual(void)
1085 TestApplication application;
1087 Actor actor = Actor::New();
1089 Vector3 vector(0.7f, 0.8f, 0.9f);
1090 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1092 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1094 // Immediately check the width after setting
1095 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1096 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1098 // flush the queue and render once
1099 application.SendNotification();
1100 application.Render();
1102 // Check the width in the new frame
1103 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1105 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1106 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1108 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1110 // Immediately check the height after setting
1111 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1112 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1114 // flush the queue and render once
1115 application.SendNotification();
1116 application.Render();
1118 // Check the height in the new frame
1119 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1121 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1122 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1124 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1126 // Immediately check the depth after setting
1127 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1128 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1130 // flush the queue and render once
1131 application.SendNotification();
1132 application.Render();
1134 // Check the depth in the new frame
1135 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1137 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1138 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1140 // Change the resize policy and check whether the size stays the same
1141 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1143 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1144 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1146 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1147 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1149 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1150 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1152 // Change the resize policy again and check whether the size stays the same
1153 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1155 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1156 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1158 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1159 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1161 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1162 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1167 int UtcDaliActorSetSizeIndividual02(void)
1169 TestApplication application;
1171 Actor actor = Actor::New();
1172 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1173 Stage::GetCurrent().Add( actor );
1175 Vector3 vector( 100.0f, 200.0f, 400.0f );
1176 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1178 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1179 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1181 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1182 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1184 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1185 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1187 // flush the queue and render once
1188 application.SendNotification();
1189 application.Render();
1191 // Check the width in the new frame
1192 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1193 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1199 int UtcDaliActorGetCurrentSize(void)
1201 TestApplication application;
1203 Actor actor = Actor::New();
1204 Vector3 vector(100.0f, 100.0f, 20.0f);
1206 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1208 actor.SetSize(vector);
1210 // flush the queue and render once
1211 application.SendNotification();
1212 application.Render();
1214 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1218 int UtcDaliActorGetNaturalSize(void)
1220 TestApplication application;
1222 Actor actor = Actor::New();
1223 Vector3 vector( 0.0f, 0.0f, 0.0f );
1225 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1230 int UtcDaliActorGetCurrentSizeImmediate(void)
1232 TestApplication application;
1234 Actor actor = Actor::New();
1235 Vector3 vector(100.0f, 100.0f, 20.0f);
1237 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1238 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1240 actor.SetSize(vector);
1242 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1243 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1245 // flush the queue and render once
1246 application.SendNotification();
1247 application.Render();
1249 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1250 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1253 // Build the animation
1254 const float durationSeconds = 2.0f;
1255 Animation animation = Animation::New( durationSeconds );
1256 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1257 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1259 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1261 // Start the animation
1264 application.SendNotification();
1265 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1267 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1272 // SetPosition(float x, float y)
1273 int UtcDaliActorSetPosition01(void)
1275 TestApplication application;
1277 Actor actor = Actor::New();
1279 // Set to random to start off with
1280 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1282 Vector3 vector(100.0f, 100.0f, 0.0f);
1284 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1286 actor.SetPosition(vector.x, vector.y);
1287 // flush the queue and render once
1288 application.SendNotification();
1289 application.Render();
1290 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1292 Stage::GetCurrent().Add( actor );
1293 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1294 // flush the queue and render once
1295 application.SendNotification();
1296 application.Render();
1297 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1302 // flush the queue and render once
1303 application.SendNotification();
1304 application.Render();
1305 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1307 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1308 // flush the queue and render once
1309 application.SendNotification();
1310 application.Render();
1311 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1313 Stage::GetCurrent().Remove( actor );
1317 // SetPosition(float x, float y, float z)
1318 int UtcDaliActorSetPosition02(void)
1320 TestApplication application;
1322 Actor actor = Actor::New();
1324 // Set to random to start off with
1325 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1327 Vector3 vector(100.0f, 100.0f, 100.0f);
1329 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1331 actor.SetPosition(vector.x, vector.y, vector.z);
1333 // flush the queue and render once
1334 application.SendNotification();
1335 application.Render();
1337 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1341 // SetPosition(Vector3 position)
1342 int UtcDaliActorSetPosition03(void)
1344 TestApplication application;
1346 Actor actor = Actor::New();
1348 // Set to random to start off with
1349 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1351 Vector3 vector(100.0f, 100.0f, 100.0f);
1353 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1355 actor.SetPosition(vector);
1357 // flush the queue and render once
1358 application.SendNotification();
1359 application.Render();
1361 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1365 int UtcDaliActorSetX(void)
1367 TestApplication application;
1369 Actor actor = Actor::New();
1371 Vector3 vector(100.0f, 0.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 UtcDaliActorSetY(void)
1387 TestApplication application;
1389 Actor actor = Actor::New();
1391 Vector3 vector(0.0f, 100.0f, 0.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 UtcDaliActorSetZ(void)
1407 TestApplication application;
1409 Actor actor = Actor::New();
1411 Vector3 vector(0.0f, 0.0f, 100.0f);
1413 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1417 // flush the queue and render once
1418 application.SendNotification();
1419 application.Render();
1421 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1425 int UtcDaliActorSetPositionProperties(void)
1427 TestApplication application;
1429 Actor actor = Actor::New();
1431 Vector3 vector(0.7f, 0.8f, 0.9f);
1432 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1434 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1435 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1436 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1438 // flush the queue and render once
1439 application.SendNotification();
1440 application.Render();
1442 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1443 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1444 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1445 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1446 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1448 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1449 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1450 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1452 // flush the queue and render once
1453 application.SendNotification();
1454 application.Render();
1456 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1457 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1458 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1459 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1460 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1462 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1463 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1464 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1466 // flush the queue and render once
1467 application.SendNotification();
1468 application.Render();
1470 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1471 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1472 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1473 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1474 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1479 int UtcDaliActorTranslateBy(void)
1481 TestApplication application;
1483 Actor actor = Actor::New();
1484 Vector3 vector(100.0f, 100.0f, 100.0f);
1486 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1488 actor.SetPosition(vector);
1490 // flush the queue and render once
1491 application.SendNotification();
1492 application.Render();
1494 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1496 actor.TranslateBy(vector);
1498 // flush the queue and render once
1499 application.SendNotification();
1500 application.Render();
1502 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1506 int UtcDaliActorGetCurrentPosition(void)
1508 TestApplication application;
1510 Actor actor = Actor::New();
1511 Vector3 setVector(100.0f, 100.0f, 0.0f);
1512 actor.SetPosition(setVector);
1514 // flush the queue and render once
1515 application.SendNotification();
1516 application.Render();
1518 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1522 int UtcDaliActorGetCurrentWorldPosition(void)
1524 TestApplication application;
1526 Actor parent = Actor::New();
1527 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1528 parent.SetPosition( parentPosition );
1529 parent.SetParentOrigin( ParentOrigin::CENTER );
1530 parent.SetAnchorPoint( AnchorPoint::CENTER );
1531 Stage::GetCurrent().Add( parent );
1533 Actor child = Actor::New();
1534 child.SetParentOrigin( ParentOrigin::CENTER );
1535 child.SetAnchorPoint( AnchorPoint::CENTER );
1536 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1537 child.SetPosition( childPosition );
1538 parent.Add( child );
1540 // The actors should not have a world position yet
1541 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1542 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1544 application.SendNotification();
1545 application.Render(0);
1547 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1548 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1550 // The actors should have a world position now
1551 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1552 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1556 int UtcDaliActorInheritPosition(void)
1558 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1559 TestApplication application;
1561 Actor parent = Actor::New();
1562 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1563 parent.SetPosition( parentPosition );
1564 parent.SetParentOrigin( ParentOrigin::CENTER );
1565 parent.SetAnchorPoint( AnchorPoint::CENTER );
1566 Stage::GetCurrent().Add( parent );
1568 Actor child = Actor::New();
1569 child.SetParentOrigin( ParentOrigin::CENTER );
1570 child.SetAnchorPoint( AnchorPoint::CENTER );
1571 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1572 child.SetPosition( childPosition );
1573 parent.Add( child );
1575 // The actors should not have a world position yet
1576 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1577 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1579 // first test default, which is to inherit position
1580 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1581 application.SendNotification();
1582 application.Render(0); // should only really call Update as Render is not required to update scene
1583 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1584 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1585 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1586 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1589 //Change child position
1590 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1591 child.SetPosition( childOffset );
1593 // Change inheritance mode to not inherit
1594 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1595 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1596 application.SendNotification();
1597 application.Render(0); // should only really call Update as Render is not required to update scene
1598 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1599 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1600 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1601 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1605 int UtcDaliActorSetInheritPosition(void)
1607 tet_infoline("Testing Actor::SetInheritPosition");
1608 TestApplication application;
1610 Actor parent = Actor::New();
1611 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1612 parent.SetPosition( parentPosition );
1613 parent.SetParentOrigin( ParentOrigin::CENTER );
1614 parent.SetAnchorPoint( AnchorPoint::CENTER );
1615 Stage::GetCurrent().Add( parent );
1617 Actor child = Actor::New();
1618 child.SetParentOrigin( ParentOrigin::CENTER );
1619 child.SetAnchorPoint( AnchorPoint::CENTER );
1620 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1621 child.SetPosition( childPosition );
1622 parent.Add( child );
1624 // The actors should not have a world position yet
1625 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1626 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1628 // first test default, which is to inherit position
1629 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1630 application.SendNotification();
1631 application.Render(0); // should only really call Update as Render is not required to update scene
1632 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1633 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1634 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1635 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1637 //Change child position
1638 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1639 child.SetPosition( childOffset );
1641 // Use local position as world postion
1642 child.SetInheritPosition( false );
1643 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1644 application.SendNotification();
1645 application.Render(0); // should only really call Update as Render is not required to update scene
1646 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1647 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1648 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1649 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1651 //Change back to inherit position from parent
1652 child.SetInheritPosition( true );
1653 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1654 application.SendNotification();
1655 application.Render(0); // should only really call Update as Render is not required to update scene
1656 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1657 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1658 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1659 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1663 // SetOrientation(float angleRadians, Vector3 axis)
1664 int UtcDaliActorSetOrientation01(void)
1666 TestApplication application;
1668 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1669 Actor actor = Actor::New();
1671 actor.SetOrientation(rotation);
1673 // flush the queue and render once
1674 application.SendNotification();
1675 application.Render();
1677 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1681 int UtcDaliActorSetOrientation02(void)
1683 TestApplication application;
1685 Actor actor = Actor::New();
1687 Radian angle( 0.785f );
1688 Vector3 axis(1.0f, 1.0f, 0.0f);
1690 actor.SetOrientation( angle, axis);
1691 Quaternion rotation( angle, axis );
1692 // flush the queue and render once
1693 application.SendNotification();
1694 application.Render();
1695 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1697 Stage::GetCurrent().Add( actor );
1698 actor.RotateBy( Degree( 360 ), axis);
1699 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1701 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1702 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1703 // flush the queue and render once
1704 application.SendNotification();
1705 application.Render();
1706 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1708 actor.SetOrientation( angle, axis);
1709 // flush the queue and render once
1710 application.SendNotification();
1711 application.Render();
1712 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1714 Stage::GetCurrent().Remove( actor );
1718 // SetOrientation(float angleRadians, Vector3 axis)
1719 int UtcDaliActorSetOrientationProperty(void)
1721 TestApplication application;
1723 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1724 Actor actor = Actor::New();
1726 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1727 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1729 // flush the queue and render once
1730 application.SendNotification();
1731 application.Render();
1733 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1734 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1735 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1739 // RotateBy(float angleRadians, Vector3 axis)
1740 int UtcDaliActorRotateBy01(void)
1742 TestApplication application;
1744 Actor actor = Actor::New();
1746 Radian angle( M_PI * 0.25f );
1747 actor.RotateBy(( angle ), Vector3::ZAXIS);
1748 // flush the queue and render once
1749 application.SendNotification();
1750 application.Render();
1751 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1753 Stage::GetCurrent().Add( actor );
1755 actor.RotateBy( angle, Vector3::ZAXIS);
1756 // flush the queue and render once
1757 application.SendNotification();
1758 application.Render();
1759 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1761 Stage::GetCurrent().Remove( actor );
1765 // RotateBy(Quaternion relativeRotation)
1766 int UtcDaliActorRotateBy02(void)
1768 TestApplication application;
1770 Actor actor = Actor::New();
1772 Radian angle( M_PI * 0.25f );
1773 Quaternion rotation(angle, Vector3::ZAXIS);
1774 actor.RotateBy(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);
1780 actor.RotateBy(rotation);
1781 // flush the queue and render once
1782 application.SendNotification();
1783 application.Render();
1784 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1788 int UtcDaliActorGetCurrentOrientation(void)
1790 TestApplication application;
1791 Actor actor = Actor::New();
1793 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1794 actor.SetOrientation(rotation);
1795 // flush the queue and render once
1796 application.SendNotification();
1797 application.Render();
1798 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1802 int UtcDaliActorGetCurrentWorldOrientation(void)
1804 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1805 TestApplication application;
1807 Actor parent = Actor::New();
1808 Radian rotationAngle( Degree(90.0f) );
1809 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1810 parent.SetOrientation( rotation );
1811 Stage::GetCurrent().Add( parent );
1813 Actor child = Actor::New();
1814 child.SetOrientation( rotation );
1815 parent.Add( child );
1817 // The actors should not have a world rotation yet
1818 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1819 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1821 application.SendNotification();
1822 application.Render(0);
1824 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1825 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1827 // The actors should have a world rotation now
1828 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1829 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1831 // turn off child rotation inheritance
1832 child.SetInheritOrientation( false );
1833 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1834 application.SendNotification();
1835 application.Render(0);
1837 // The actors should have a world rotation now
1838 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1839 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1843 // SetScale(float scale)
1844 int UtcDaliActorSetScale01(void)
1846 TestApplication application;
1848 Actor actor = Actor::New();
1850 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1851 actor.SetScale(0.25f);
1853 Vector3 scale(10.0f, 10.0f, 10.0f);
1854 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1856 actor.SetScale(scale.x);
1858 // flush the queue and render once
1859 application.SendNotification();
1860 application.Render();
1862 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1866 // SetScale(float scaleX, float scaleY, float scaleZ)
1867 int UtcDaliActorSetScale02(void)
1869 TestApplication application;
1870 Vector3 scale(10.0f, 10.0f, 10.0f);
1872 Actor actor = Actor::New();
1874 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1875 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1877 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1879 actor.SetScale(scale.x, scale.y, scale.z);
1880 // flush the queue and render once
1881 application.SendNotification();
1882 application.Render();
1883 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1885 // add to stage and test
1886 Stage::GetCurrent().Add( actor );
1887 actor.SetScale( 2.0f, 2.0f, 2.0f );
1888 // flush the queue and render once
1889 application.SendNotification();
1890 application.Render();
1891 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1893 Stage::GetCurrent().Remove( actor );
1898 // SetScale(Vector3 scale)
1899 int UtcDaliActorSetScale03(void)
1901 TestApplication application;
1902 Vector3 scale(10.0f, 10.0f, 10.0f);
1904 Actor actor = Actor::New();
1906 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1907 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1909 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1911 actor.SetScale(scale);
1913 // flush the queue and render once
1914 application.SendNotification();
1915 application.Render();
1917 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1921 int UtcDaliActorSetScaleIndividual(void)
1923 TestApplication application;
1925 Actor actor = Actor::New();
1927 Vector3 vector(0.7f, 0.8f, 0.9f);
1928 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1930 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1931 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1933 // flush the queue and render once
1934 application.SendNotification();
1935 application.Render();
1937 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1938 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1939 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1941 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1942 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1944 // flush the queue and render once
1945 application.SendNotification();
1946 application.Render();
1948 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1949 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1950 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1952 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1953 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1955 // flush the queue and render once
1956 application.SendNotification();
1957 application.Render();
1959 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1960 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1961 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1963 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1964 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1969 int UtcDaliActorScaleBy(void)
1971 TestApplication application;
1972 Actor actor = Actor::New();
1973 Vector3 vector(100.0f, 100.0f, 100.0f);
1975 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1977 actor.SetScale(vector);
1979 // flush the queue and render once
1980 application.SendNotification();
1981 application.Render();
1983 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1985 actor.ScaleBy(vector);
1987 // flush the queue and render once
1988 application.SendNotification();
1989 application.Render();
1991 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1995 int UtcDaliActorGetCurrentScale(void)
1997 TestApplication application;
1998 Vector3 scale(12.0f, 1.0f, 2.0f);
2000 Actor actor = Actor::New();
2002 actor.SetScale(scale);
2004 // flush the queue and render once
2005 application.SendNotification();
2006 application.Render();
2008 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
2012 int UtcDaliActorGetCurrentWorldScale(void)
2014 TestApplication application;
2016 Actor parent = Actor::New();
2017 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2018 parent.SetScale( parentScale );
2019 Stage::GetCurrent().Add( parent );
2021 Actor child = Actor::New();
2022 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2023 child.SetScale( childScale );
2024 parent.Add( child );
2026 // The actors should not have a scale yet
2027 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2028 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2030 // The actors should not have a world scale yet
2031 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2032 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2034 application.SendNotification();
2035 application.Render(0);
2037 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2038 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2040 // The actors should have a world scale now
2041 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2042 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2046 int UtcDaliActorInheritScale(void)
2048 tet_infoline("Testing Actor::SetInheritScale");
2049 TestApplication application;
2051 Actor parent = Actor::New();
2052 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2053 parent.SetScale( parentScale );
2054 Stage::GetCurrent().Add( parent );
2056 Actor child = Actor::New();
2057 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2058 child.SetScale( childScale );
2059 parent.Add( child );
2061 application.SendNotification();
2062 application.Render(0);
2064 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2065 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2067 child.SetInheritScale( false );
2068 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2070 application.SendNotification();
2071 application.Render(0);
2073 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2077 int UtcDaliActorSetVisible(void)
2079 TestApplication application;
2081 Actor actor = Actor::New();
2082 actor.SetVisible(false);
2083 // flush the queue and render once
2084 application.SendNotification();
2085 application.Render();
2086 DALI_TEST_CHECK(actor.IsVisible() == false);
2088 actor.SetVisible(true);
2089 // flush the queue and render once
2090 application.SendNotification();
2091 application.Render();
2092 DALI_TEST_CHECK(actor.IsVisible() == true);
2094 // put actor on stage
2095 Stage::GetCurrent().Add( actor );
2096 actor.SetVisible(false);
2097 // flush the queue and render once
2098 application.SendNotification();
2099 application.Render();
2100 DALI_TEST_CHECK(actor.IsVisible() == false);
2104 int UtcDaliActorIsVisible(void)
2106 TestApplication application;
2108 Actor actor = Actor::New();
2110 DALI_TEST_CHECK(actor.IsVisible() == true);
2114 int UtcDaliActorSetOpacity(void)
2116 TestApplication application;
2118 Actor actor = Actor::New();
2119 // initial opacity is 1
2120 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2122 actor.SetOpacity( 0.4f);
2123 // flush the queue and render once
2124 application.SendNotification();
2125 application.Render();
2126 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2128 // change opacity, actor is on stage to change is not immediate
2129 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2130 // flush the queue and render once
2131 application.SendNotification();
2132 application.Render();
2133 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2135 // put actor on stage
2136 Stage::GetCurrent().Add( actor );
2138 // change opacity, actor is on stage to change is not immediate
2139 actor.SetOpacity( 0.9f );
2140 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2141 // flush the queue and render once
2142 application.SendNotification();
2143 application.Render();
2144 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2146 // change opacity, actor is on stage to change is not immediate
2147 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2148 // flush the queue and render once
2149 application.SendNotification();
2150 application.Render();
2151 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2155 int UtcDaliActorGetCurrentOpacity(void)
2157 TestApplication application;
2159 Actor actor = Actor::New();
2160 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2162 actor.SetOpacity(0.5f);
2163 // flush the queue and render once
2164 application.SendNotification();
2165 application.Render();
2166 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2170 int UtcDaliActorSetSensitive(void)
2172 TestApplication application;
2173 Actor actor = Actor::New();
2175 bool sensitive = !actor.IsSensitive();
2177 actor.SetSensitive(sensitive);
2179 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2183 int UtcDaliActorIsSensitive(void)
2185 TestApplication application;
2186 Actor actor = Actor::New();
2187 actor.SetSensitive(false);
2189 DALI_TEST_CHECK(false == actor.IsSensitive());
2193 int UtcDaliActorSetColor(void)
2195 TestApplication application;
2196 Actor actor = Actor::New();
2197 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2199 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2201 actor.SetColor(color);
2202 // flush the queue and render once
2203 application.SendNotification();
2204 application.Render();
2205 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2207 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2208 // flush the queue and render once
2209 application.SendNotification();
2210 application.Render();
2211 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2213 Stage::GetCurrent().Add( actor );
2214 actor.SetColor( color );
2215 // flush the queue and render once
2216 application.SendNotification();
2217 application.Render();
2218 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2220 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2221 // flush the queue and render once
2222 application.SendNotification();
2223 application.Render();
2224 // Actor color is not clamped
2225 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2226 // world color is clamped
2227 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2229 Stage::GetCurrent().Remove( actor );
2233 int UtcDaliActorSetColorIndividual(void)
2235 TestApplication application;
2237 Actor actor = Actor::New();
2239 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2240 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2242 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2243 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2245 // flush the queue and render once
2246 application.SendNotification();
2247 application.Render();
2249 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2250 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2251 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2253 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2254 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2256 // flush the queue and render once
2257 application.SendNotification();
2258 application.Render();
2260 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2261 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2262 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2264 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2265 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2267 // flush the queue and render once
2268 application.SendNotification();
2269 application.Render();
2271 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2272 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2273 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2276 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2277 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2279 // flush the queue and render once
2280 application.SendNotification();
2281 application.Render();
2283 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2284 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2285 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2287 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2288 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2290 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2293 // flush the queue and render once
2294 application.SendNotification();
2295 application.Render();
2297 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2303 int UtcDaliActorGetCurrentColor(void)
2305 TestApplication application;
2306 Actor actor = Actor::New();
2307 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2309 actor.SetColor(color);
2310 // flush the queue and render once
2311 application.SendNotification();
2312 application.Render();
2313 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2317 int UtcDaliActorGetCurrentWorldColor(void)
2319 tet_infoline("Actor::GetCurrentWorldColor");
2320 TestApplication application;
2322 Actor parent = Actor::New();
2323 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2324 parent.SetColor( parentColor );
2325 Stage::GetCurrent().Add( parent );
2327 Actor child = Actor::New();
2328 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2329 child.SetColor( childColor );
2330 parent.Add( child );
2332 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2333 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2335 // verify the default color mode
2336 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2338 // The actors should not have a world color yet
2339 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2340 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2342 application.SendNotification();
2343 application.Render(0);
2345 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2346 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2348 // The actors should have a world color now
2349 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2350 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2353 child.SetColorMode( USE_OWN_COLOR );
2354 application.SendNotification();
2355 application.Render(0);
2356 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2359 child.SetColorMode( USE_PARENT_COLOR );
2360 application.SendNotification();
2361 application.Render(0);
2362 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2363 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2366 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2367 application.SendNotification();
2368 application.Render(0);
2369 Vector4 expectedColor( childColor );
2370 expectedColor.a *= parentColor.a;
2371 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2372 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2376 int UtcDaliActorSetColorMode(void)
2378 tet_infoline("Actor::SetColorMode");
2379 TestApplication application;
2380 Actor actor = Actor::New();
2381 Actor child = Actor::New();
2384 actor.SetColorMode( USE_OWN_COLOR );
2385 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2387 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2388 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2390 actor.SetColorMode( USE_PARENT_COLOR );
2391 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2393 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2394 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2398 int UtcDaliActorScreenToLocal(void)
2400 TestApplication application;
2401 Actor actor = Actor::New();
2402 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2403 actor.SetSize(100.0f, 100.0f);
2404 actor.SetPosition(10.0f, 10.0f);
2405 Stage::GetCurrent().Add(actor);
2407 // flush the queue and render once
2408 application.SendNotification();
2409 application.Render();
2414 application.SendNotification();
2415 application.Render();
2417 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2419 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2420 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2424 int UtcDaliActorSetLeaveRequired(void)
2426 TestApplication application;
2428 Actor actor = Actor::New();
2430 actor.SetLeaveRequired(false);
2431 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2433 actor.SetLeaveRequired(true);
2434 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2438 int UtcDaliActorGetLeaveRequired(void)
2440 TestApplication application;
2442 Actor actor = Actor::New();
2444 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2448 int UtcDaliActorSetKeyboardFocusable(void)
2450 TestApplication application;
2452 Actor actor = Actor::New();
2454 actor.SetKeyboardFocusable(true);
2455 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2457 actor.SetKeyboardFocusable(false);
2458 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2462 int UtcDaliActorIsKeyboardFocusable(void)
2464 TestApplication application;
2466 Actor actor = Actor::New();
2468 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2472 int UtcDaliActorRemoveConstraints(void)
2474 tet_infoline(" UtcDaliActorRemoveConstraints");
2475 TestApplication application;
2477 gTestConstraintCalled = false;
2479 Actor actor = Actor::New();
2481 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2483 actor.RemoveConstraints();
2485 DALI_TEST_CHECK( gTestConstraintCalled == false );
2487 Stage::GetCurrent().Add( actor );
2490 // flush the queue and render once
2491 application.SendNotification();
2492 application.Render();
2494 actor.RemoveConstraints();
2496 DALI_TEST_CHECK( gTestConstraintCalled == true );
2500 int UtcDaliActorRemoveConstraintTag(void)
2502 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2503 TestApplication application;
2505 Actor actor = Actor::New();
2507 // 1. Apply Constraint1 and Constraint2, and test...
2508 unsigned int result1 = 0u;
2509 unsigned int result2 = 0u;
2511 unsigned constraint1Tag = 1u;
2512 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2513 constraint1.SetTag( constraint1Tag );
2514 constraint1.Apply();
2516 unsigned constraint2Tag = 2u;
2517 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2518 constraint2.SetTag( constraint2Tag );
2519 constraint2.Apply();
2521 Stage::GetCurrent().Add( actor );
2522 // flush the queue and render once
2523 application.SendNotification();
2524 application.Render();
2526 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2527 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2529 // 2. Remove Constraint1 and test...
2532 actor.RemoveConstraints(constraint1Tag);
2533 // make color property dirty, which will trigger constraints to be reapplied.
2534 actor.SetColor( Color::WHITE );
2535 // flush the queue and render once
2536 application.SendNotification();
2537 application.Render();
2539 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2540 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2542 // 3. Re-Apply Constraint1 and test...
2545 constraint1.Apply();
2546 // make color property dirty, which will trigger constraints to be reapplied.
2547 actor.SetColor( Color::WHITE );
2548 // flush the queue and render once
2549 application.SendNotification();
2550 application.Render();
2552 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2553 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2555 // 2. Remove Constraint2 and test...
2558 actor.RemoveConstraints(constraint2Tag);
2559 // make color property dirty, which will trigger constraints to be reapplied.
2560 actor.SetColor( Color::WHITE );
2561 // flush the queue and render once
2562 application.SendNotification();
2563 application.Render();
2565 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2566 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2568 // 2. Remove Constraint1 as well and test...
2571 actor.RemoveConstraints(constraint1Tag);
2572 // make color property dirty, which will trigger constraints to be reapplied.
2573 actor.SetColor( Color::WHITE );
2574 // flush the queue and render once
2575 application.SendNotification();
2576 application.Render();
2578 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2579 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2583 int UtcDaliActorTouchedSignal(void)
2585 TestApplication application;
2587 ResetTouchCallbacks();
2589 // get the root layer
2590 Actor actor = Stage::GetCurrent().GetRootLayer();
2591 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2593 application.SendNotification();
2594 application.Render();
2596 // connect to its touch signal
2597 actor.TouchedSignal().Connect( TestCallback );
2599 // simulate a touch event in the middle of the screen
2600 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2601 Dali::Integration::Point point;
2602 point.SetDeviceId( 1 );
2603 point.SetState( PointState::DOWN );
2604 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2605 Dali::Integration::TouchEvent touchEvent;
2606 touchEvent.AddPoint( point );
2607 application.ProcessEvent( touchEvent );
2609 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2613 int UtcDaliActorHoveredSignal(void)
2615 TestApplication application;
2617 gHoverCallBackCalled = false;
2619 // get the root layer
2620 Actor actor = Stage::GetCurrent().GetRootLayer();
2621 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2623 application.SendNotification();
2624 application.Render();
2626 // connect to its hover signal
2627 actor.HoveredSignal().Connect( TestCallback3 );
2629 // simulate a hover event in the middle of the screen
2630 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2631 Dali::Integration::Point point;
2632 point.SetDeviceId( 1 );
2633 point.SetState( PointState::MOTION );
2634 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2635 Dali::Integration::HoverEvent hoverEvent;
2636 hoverEvent.AddPoint( point );
2637 application.ProcessEvent( hoverEvent );
2639 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2643 int UtcDaliActorOnOffStageSignal(void)
2645 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2647 TestApplication application;
2650 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2651 gActorNamesOnOffStage.clear();
2653 Actor parent = Actor::New();
2654 parent.SetName( "parent" );
2655 parent.OnStageSignal().Connect( OnStageCallback );
2656 parent.OffStageSignal().Connect( OffStageCallback );
2658 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2659 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2661 // add parent to stage
2662 Stage::GetCurrent().Add( parent );
2663 // onstage emitted, offstage not
2664 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2665 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2666 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2668 // test adding a child, should get onstage emitted
2670 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2671 gActorNamesOnOffStage.clear();
2673 Actor child = Actor::New();
2674 child.SetName( "child" );
2675 child.OnStageSignal().Connect( OnStageCallback );
2676 child.OffStageSignal().Connect( OffStageCallback );
2677 parent.Add( child ); // add child
2678 // onstage emitted, offstage not
2679 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2680 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2681 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2683 // test removing parent from stage
2685 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2686 gActorNamesOnOffStage.clear();
2688 Stage::GetCurrent().Remove( parent );
2689 // onstage not emitted, offstage is
2690 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2691 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2692 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2693 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2695 // test adding parent back to stage
2697 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2698 gActorNamesOnOffStage.clear();
2700 Stage::GetCurrent().Add( parent );
2701 // onstage emitted, offstage not
2702 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2703 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2704 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2705 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2707 // test removing child
2709 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2710 gActorNamesOnOffStage.clear();
2712 parent.Remove( child );
2713 // onstage not emitted, offstage is
2714 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2715 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2716 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2718 // test removing parent
2720 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2721 gActorNamesOnOffStage.clear();
2723 Stage::GetCurrent().Remove( parent );
2724 // onstage not emitted, offstage is
2725 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2726 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2727 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2731 int UtcDaliActorFindChildByName(void)
2733 tet_infoline("Testing Dali::Actor::FindChildByName()");
2734 TestApplication application;
2736 Actor parent = Actor::New();
2737 parent.SetName( "parent" );
2738 Actor first = Actor::New();
2739 first .SetName( "first" );
2740 Actor second = Actor::New();
2741 second.SetName( "second" );
2746 Actor found = parent.FindChildByName( "foo" );
2747 DALI_TEST_CHECK( !found );
2749 found = parent.FindChildByName( "parent" );
2750 DALI_TEST_CHECK( found == parent );
2752 found = parent.FindChildByName( "first" );
2753 DALI_TEST_CHECK( found == first );
2755 found = parent.FindChildByName( "second" );
2756 DALI_TEST_CHECK( found == second );
2760 int UtcDaliActorFindChildById(void)
2762 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2763 TestApplication application;
2765 Actor parent = Actor::New();
2766 Actor first = Actor::New();
2767 Actor second = Actor::New();
2772 Actor found = parent.FindChildById( 100000 );
2773 DALI_TEST_CHECK( !found );
2775 found = parent.FindChildById( parent.GetId() );
2776 DALI_TEST_CHECK( found == parent );
2778 found = parent.FindChildById( first.GetId() );
2779 DALI_TEST_CHECK( found == first );
2781 found = parent.FindChildById( second.GetId() );
2782 DALI_TEST_CHECK( found == second );
2786 int UtcDaliActorHitTest(void)
2791 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2793 mTouchPoint( touchPoint ),
2798 Vector2 mTouchPoint;
2802 TestApplication application;
2803 tet_infoline(" UtcDaliActorHitTest");
2805 // Fill a vector with different hit tests.
2806 struct HitTestData* hitTestData[] = {
2807 // scale touch point result
2808 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2809 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2810 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.
2811 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2812 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.
2816 // get the root layer
2817 Actor actor = Actor::New();
2818 actor.SetAnchorPoint( AnchorPoint::CENTER );
2819 actor.SetParentOrigin( ParentOrigin::CENTER );
2821 Stage::GetCurrent().Add( actor );
2823 ResetTouchCallbacks();
2825 unsigned int index = 0;
2826 while( NULL != hitTestData[index] )
2828 actor.SetSize( 1.f, 1.f );
2829 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2831 // flush the queue and render once
2832 application.SendNotification();
2833 application.Render();
2835 DALI_TEST_CHECK( !gTouchCallBackCalled );
2837 // connect to its touch signal
2838 actor.TouchedSignal().Connect(TestCallback);
2840 Dali::Integration::Point point;
2841 point.SetState( PointState::DOWN );
2842 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2843 Dali::Integration::TouchEvent event;
2844 event.AddPoint( point );
2846 // flush the queue and render once
2847 application.SendNotification();
2848 application.Render();
2849 application.ProcessEvent( event );
2851 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2853 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2854 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2855 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2856 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2857 hitTestData[index]->mResult );
2859 ResetTouchCallbacks();
2865 int UtcDaliActorSetDrawMode(void)
2867 TestApplication app;
2868 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2870 Actor a = Actor::New();
2872 Stage::GetCurrent().Add(a);
2873 app.SendNotification();
2875 app.SendNotification();
2878 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2880 a.SetDrawMode( DrawMode::OVERLAY_2D );
2881 app.SendNotification();
2884 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2886 a.SetDrawMode( DrawMode::NORMAL );
2887 app.SendNotification();
2890 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2894 int UtcDaliActorSetDrawModeOverlayRender(void)
2896 TestApplication app;
2897 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2899 app.SendNotification();
2902 std::vector<GLuint> ids;
2903 ids.push_back( 8 ); // first rendered actor
2904 ids.push_back( 9 ); // second rendered actor
2905 ids.push_back( 10 ); // third rendered actor
2906 app.GetGlAbstraction().SetNextTextureIds( ids );
2908 BufferImage imageA = BufferImage::New(16, 16);
2909 BufferImage imageB = BufferImage::New(16, 16);
2910 BufferImage imageC = BufferImage::New(16, 16);
2911 Actor a = CreateRenderableActor( imageA );
2912 Actor b = CreateRenderableActor( imageB );
2913 Actor c = CreateRenderableActor( imageC );
2915 app.SendNotification();
2918 //Textures are bound when first created. Clear bound textures vector
2919 app.GetGlAbstraction().ClearBoundTextures();
2921 // Render a,b,c as regular non-overlays. so order will be:
2925 Stage::GetCurrent().Add(a);
2926 Stage::GetCurrent().Add(b);
2927 Stage::GetCurrent().Add(c);
2929 app.SendNotification();
2932 // Should be 3 textures changes.
2933 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2934 typedef std::vector<GLuint>::size_type TextureSize;
2935 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2936 if( boundTextures.size() == 3 )
2938 DALI_TEST_CHECK( boundTextures[0] == 8u );
2939 DALI_TEST_CHECK( boundTextures[1] == 9u );
2940 DALI_TEST_CHECK( boundTextures[2] == 10u );
2943 // Now texture ids have been set, we can monitor their render order.
2944 // render a as an overlay (last), so order will be:
2948 a.SetDrawMode( DrawMode::OVERLAY_2D );
2949 app.GetGlAbstraction().ClearBoundTextures();
2951 app.SendNotification();
2954 // Should be 3 texture changes.
2955 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2956 if( boundTextures.size() == 3 )
2958 DALI_TEST_CHECK( boundTextures[0] == 9u );
2959 DALI_TEST_CHECK( boundTextures[1] == 10u );
2960 DALI_TEST_CHECK( boundTextures[2] == 8u );
2965 int UtcDaliActorGetCurrentWorldMatrix(void)
2967 TestApplication app;
2968 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2970 Actor parent = Actor::New();
2971 parent.SetParentOrigin(ParentOrigin::CENTER);
2972 parent.SetAnchorPoint(AnchorPoint::CENTER);
2973 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2974 Radian rotationAngle(Degree(85.0f));
2975 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2976 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2977 parent.SetPosition( parentPosition );
2978 parent.SetOrientation( parentRotation );
2979 parent.SetScale( parentScale );
2980 Stage::GetCurrent().Add( parent );
2982 Actor child = Actor::New();
2983 child.SetParentOrigin(ParentOrigin::CENTER);
2984 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2985 Radian childRotationAngle(Degree(23.0f));
2986 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2987 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2988 child.SetPosition( childPosition );
2989 child.SetOrientation( childRotation );
2990 child.SetScale( childScale );
2991 parent.Add( child );
2993 app.SendNotification();
2996 app.SendNotification();
2998 Matrix parentMatrix(false);
2999 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3001 Matrix childMatrix(false);
3002 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3004 //Child matrix should be the composition of child and parent
3005 Matrix childWorldMatrix(false);
3006 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3008 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3009 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
3015 int UtcDaliActorConstrainedToWorldMatrix(void)
3017 TestApplication app;
3018 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3020 Actor parent = Actor::New();
3021 parent.SetParentOrigin(ParentOrigin::CENTER);
3022 parent.SetAnchorPoint(AnchorPoint::CENTER);
3023 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3024 Radian rotationAngle(Degree(85.0f));
3025 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3026 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3027 parent.SetPosition( parentPosition );
3028 parent.SetOrientation( parentRotation );
3029 parent.SetScale( parentScale );
3030 Stage::GetCurrent().Add( parent );
3032 Actor child = Actor::New();
3033 child.SetParentOrigin(ParentOrigin::CENTER);
3034 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3035 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3036 posConstraint.Apply();
3038 Stage::GetCurrent().Add( child );
3040 app.SendNotification();
3043 app.SendNotification();
3045 Matrix parentMatrix(false);
3046 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3048 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3049 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3053 int UtcDaliActorConstrainedToOrientation(void)
3055 TestApplication app;
3056 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3058 Actor parent = Actor::New();
3059 parent.SetParentOrigin(ParentOrigin::CENTER);
3060 parent.SetAnchorPoint(AnchorPoint::CENTER);
3061 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3062 Radian rotationAngle(Degree(85.0f));
3063 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3064 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3065 parent.SetPosition( parentPosition );
3066 parent.SetOrientation( parentRotation );
3067 parent.SetScale( parentScale );
3068 Stage::GetCurrent().Add( parent );
3070 Actor child = Actor::New();
3071 child.SetParentOrigin(ParentOrigin::CENTER);
3072 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3073 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3074 posConstraint.Apply();
3076 Stage::GetCurrent().Add( child );
3078 app.SendNotification();
3081 app.SendNotification();
3083 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3087 int UtcDaliActorConstrainedToOpacity(void)
3089 TestApplication app;
3090 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3092 Actor parent = Actor::New();
3093 parent.SetOpacity( 0.7f );
3094 Stage::GetCurrent().Add( parent );
3096 Actor child = Actor::New();
3097 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3098 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3099 opacityConstraint.Apply();
3101 Stage::GetCurrent().Add( child );
3103 app.SendNotification();
3106 app.SendNotification();
3108 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3110 parent.SetOpacity( 0.3f );
3112 app.SendNotification();
3115 app.SendNotification();
3117 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3122 int UtcDaliActorUnparent(void)
3124 TestApplication app;
3125 tet_infoline(" UtcDaliActorUnparent");
3127 Actor parent = Actor::New();
3128 Stage::GetCurrent().Add( parent );
3130 Actor child = Actor::New();
3132 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3133 DALI_TEST_CHECK( !child.GetParent() );
3135 // Test that calling Unparent with no parent is a NOOP
3138 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3139 DALI_TEST_CHECK( !child.GetParent() );
3141 // Test that Unparent works
3142 parent.Add( child );
3144 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3145 DALI_TEST_CHECK( parent == child.GetParent() );
3149 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3150 DALI_TEST_CHECK( !child.GetParent() );
3152 // Test that UnparentAndReset works
3153 parent.Add( child );
3155 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3156 DALI_TEST_CHECK( parent == child.GetParent() );
3158 UnparentAndReset( child );
3160 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3161 DALI_TEST_CHECK( !child );
3163 // Test that UnparentAndReset is a NOOP with empty handle
3164 UnparentAndReset( child );
3166 DALI_TEST_CHECK( !child );
3170 int UtcDaliActorGetChildAt(void)
3172 TestApplication app;
3173 tet_infoline(" UtcDaliActorGetChildAt");
3175 Actor parent = Actor::New();
3176 Stage::GetCurrent().Add( parent );
3178 Actor child0 = Actor::New();
3179 parent.Add( child0 );
3181 Actor child1 = Actor::New();
3182 parent.Add( child1 );
3184 Actor child2 = Actor::New();
3185 parent.Add( child2 );
3187 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3188 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3189 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3193 int UtcDaliActorSetGetOverlay(void)
3195 TestApplication app;
3196 tet_infoline(" UtcDaliActorSetGetOverlay");
3198 Actor parent = Actor::New();
3199 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3200 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3205 int UtcDaliActorCreateDestroy(void)
3207 Actor* actor = new Actor;
3208 DALI_TEST_CHECK( actor );
3215 struct PropertyStringIndex
3217 const char * const name;
3218 const Property::Index index;
3219 const Property::Type type;
3222 const PropertyStringIndex PROPERTY_TABLE[] =
3224 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3225 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3226 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3227 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3228 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3229 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3230 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3231 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3232 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3233 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3234 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3235 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3236 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3237 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3238 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3239 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3240 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3241 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3242 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3243 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3244 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3245 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3246 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3247 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3248 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3249 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3250 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3251 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3252 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3253 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3254 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3255 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3256 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3257 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3258 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3259 { "name", Actor::Property::NAME, Property::STRING },
3260 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3261 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3262 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3263 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3264 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3265 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3266 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3267 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3268 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3269 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3270 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3271 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3272 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3273 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3274 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3275 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3276 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3277 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3278 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3280 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3281 } // unnamed namespace
3283 int UtcDaliActorProperties(void)
3285 TestApplication app;
3287 Actor actor = Actor::New();
3289 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3291 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3292 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3293 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3294 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3299 int UtcDaliRelayoutProperties_ResizePolicies(void)
3301 TestApplication app;
3303 Actor actor = Actor::New();
3306 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3307 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3309 // Set resize policy for all dimensions
3310 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3311 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3313 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3316 // Set individual dimensions
3317 const char* const widthPolicy = "FILL_TO_PARENT";
3318 const char* const heightPolicy = "FIXED";
3320 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3321 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3323 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3324 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3326 // Set individual dimensions using enums
3327 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3328 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3330 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3331 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3333 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3334 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3339 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3341 TestApplication app;
3343 Actor actor = Actor::New();
3346 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3347 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3349 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3350 actor.SetSizeScalePolicy( policy );
3351 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3354 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3355 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3357 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3358 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3360 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3361 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3366 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3368 TestApplication app;
3370 Actor actor = Actor::New();
3373 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3374 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3376 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3377 actor.SetSizeModeFactor( sizeMode );
3378 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3381 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3383 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3384 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3389 int UtcDaliRelayoutProperties_DimensionDependency(void)
3391 TestApplication app;
3393 Actor actor = Actor::New();
3396 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3397 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3400 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3401 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3403 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3404 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3406 // Test setting another resize policy
3407 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3408 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3413 int UtcDaliRelayoutProperties_Padding(void)
3415 TestApplication app;
3417 Actor actor = Actor::New();
3420 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3423 actor.SetProperty( Actor::Property::PADDING, padding );
3424 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3426 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3431 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3433 TestApplication app;
3435 Actor actor = Actor::New();
3438 Vector2 minSize( 1.0f, 2.0f );
3440 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3441 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3443 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3445 Vector2 maxSize( 3.0f, 4.0f );
3447 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3448 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3450 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3455 int UtcDaliActorGetHeightForWidth(void)
3457 TestApplication app;
3459 Actor actor = Actor::New();
3461 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3466 int UtcDaliActorGetWidthForHeight(void)
3468 TestApplication app;
3470 Actor actor = Actor::New();
3472 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3477 int UtcDaliActorGetRelayoutSize(void)
3479 TestApplication app;
3481 Actor actor = Actor::New();
3483 // Add actor to stage
3484 Stage::GetCurrent().Add( actor );
3486 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3488 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3489 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3491 // Flush the queue and render once
3492 app.SendNotification();
3495 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3500 int UtcDaliActorSetPadding(void)
3502 TestApplication app;
3504 Actor actor = Actor::New();
3507 actor.GetPadding( padding );
3509 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3510 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3511 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3512 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3514 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3515 actor.SetPadding( padding2 );
3517 actor.GetPadding( padding );
3519 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3520 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3521 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3522 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3527 int UtcDaliActorSetMinimumSize(void)
3529 TestApplication app;
3531 Actor actor = Actor::New();
3533 Vector2 size = actor.GetMinimumSize();
3535 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3536 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3538 Vector2 size2( 1.0f, 2.0f );
3539 actor.SetMinimumSize( size2 );
3541 size = actor.GetMinimumSize();
3543 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3544 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3549 int UtcDaliActorSetMaximumSize(void)
3551 TestApplication app;
3553 Actor actor = Actor::New();
3555 Vector2 size = actor.GetMaximumSize();
3557 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3558 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3560 Vector2 size2( 1.0f, 2.0f );
3561 actor.SetMaximumSize( size2 );
3563 size = actor.GetMaximumSize();
3565 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3566 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3571 int UtcDaliActorOnRelayoutSignal(void)
3573 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3575 TestApplication application;
3578 gOnRelayoutCallBackCalled = false;
3579 gActorNamesRelayout.clear();
3581 Actor actor = Actor::New();
3582 actor.SetName( "actor" );
3583 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3586 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3588 // Add actor to stage
3589 Stage::GetCurrent().Add( actor );
3591 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3592 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3594 // Flush the queue and render once
3595 application.SendNotification();
3596 application.Render();
3598 // OnRelayout emitted
3599 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3600 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3605 int UtcDaliActorGetHierachyDepth(void)
3607 TestApplication application;
3608 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3611 /* Build tree of actors:
3621 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3623 Stage stage( Stage::GetCurrent() );
3625 Actor actorA = Actor::New();
3626 Actor actorB = Actor::New();
3627 Actor actorC = Actor::New();
3628 Actor actorD = Actor::New();
3629 Actor actorE = Actor::New();
3630 Actor actorF = Actor::New();
3632 //Test that root actor has depth equal 0
3633 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3635 //Test actors return depth -1 when not connected to the tree
3636 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3637 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3638 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3639 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3640 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3641 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3643 //Create the hierarchy
3644 stage.Add( actorA );
3645 actorA.Add( actorB );
3646 actorA.Add( actorC );
3647 actorB.Add( actorD );
3648 actorB.Add( actorE );
3649 actorC.Add( actorF );
3651 //Test actors return correct depth
3652 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3653 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3654 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3655 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3656 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3657 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3659 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3660 actorA.Remove( actorB );
3662 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3663 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3664 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3666 //Removing actorA from the stage. All actors should have depth equal -1
3667 stage.Remove( actorA );
3669 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3670 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3671 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3672 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3673 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3674 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3679 int UtcDaliActorAnchorPointPropertyAsString(void)
3681 TestApplication application;
3683 Actor actor = Actor::New();
3685 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3686 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3688 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3689 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3691 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3692 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3694 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3695 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3697 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3698 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3700 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3701 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3703 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3704 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3706 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3707 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3709 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3710 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3712 // Invalid should not change anything
3713 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3714 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3719 int UtcDaliActorParentOriginPropertyAsString(void)
3721 TestApplication application;
3723 Actor actor = Actor::New();
3725 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3726 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3728 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3729 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3731 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3732 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3734 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3735 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3737 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3738 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3740 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3741 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3743 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3744 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3746 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3747 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3749 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3750 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3752 // Invalid should not change anything
3753 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3754 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3759 int UtcDaliActorColorModePropertyAsString(void)
3761 TestApplication application;
3763 Actor actor = Actor::New();
3765 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3766 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3768 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3769 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3771 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3772 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3774 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3775 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3777 // Invalid should not change anything
3778 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3779 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3784 int UtcDaliActorPositionInheritancePropertyAsString(void)
3786 TestApplication application;
3788 Actor actor = Actor::New();
3790 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3791 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3793 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3794 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3796 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3797 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3799 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3800 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3802 // Invalid should not change anything
3803 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3804 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3809 int UtcDaliActorDrawModePropertyAsString(void)
3811 TestApplication application;
3813 Actor actor = Actor::New();
3815 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3816 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3818 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3819 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3821 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3822 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3824 // Invalid should not change anything
3825 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3826 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3831 int UtcDaliActorColorModePropertyAsEnum(void)
3833 TestApplication application;
3835 Actor actor = Actor::New();
3837 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3838 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3840 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3841 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3843 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3844 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3846 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3847 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3852 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3854 TestApplication application;
3856 Actor actor = Actor::New();
3858 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3859 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3861 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3862 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3864 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3865 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3867 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3868 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3873 int UtcDaliActorDrawModePropertyAsEnum(void)
3875 TestApplication application;
3877 Actor actor = Actor::New();
3879 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3880 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3882 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3883 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3885 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3886 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3891 int UtcDaliActorAddRendererP(void)
3893 tet_infoline("Testing Actor::AddRenderer");
3894 TestApplication application;
3896 Actor actor = Actor::New();
3898 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3900 Geometry geometry = CreateQuadGeometry();
3901 Shader shader = CreateShader();
3902 Renderer renderer = Renderer::New(geometry, shader);
3904 actor.AddRenderer( renderer );
3905 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3906 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3911 int UtcDaliActorAddRendererN(void)
3913 tet_infoline("Testing Actor::AddRenderer");
3914 TestApplication application;
3916 Actor actor = Actor::New();
3922 actor.AddRenderer( renderer );
3923 tet_printf("Assertion test failed - no Exception\n" );
3924 tet_result(TET_FAIL);
3926 catch(Dali::DaliException& e)
3928 DALI_TEST_PRINT_ASSERT( e );
3929 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3930 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3934 tet_printf("Assertion test failed - wrong Exception\n" );
3935 tet_result(TET_FAIL);
3941 int UtcDaliActorAddRendererOnStage(void)
3943 tet_infoline("Testing Actor::AddRenderer");
3944 TestApplication application;
3946 Actor actor = Actor::New();
3947 Stage::GetCurrent().Add(actor);
3949 application.SendNotification();
3950 application.Render(0);
3952 Geometry geometry = CreateQuadGeometry();
3953 Shader shader = CreateShader();
3954 Renderer renderer = Renderer::New(geometry, shader);
3956 application.SendNotification();
3957 application.Render(0);
3961 actor.AddRenderer( renderer );
3962 tet_result(TET_PASS);
3966 tet_result(TET_FAIL);
3972 int UtcDaliActorRemoveRendererP1(void)
3974 tet_infoline("Testing Actor::RemoveRenderer");
3975 TestApplication application;
3977 Actor actor = Actor::New();
3979 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3982 Geometry geometry = CreateQuadGeometry();
3983 Shader shader = CreateShader();
3984 Renderer renderer = Renderer::New(geometry, shader);
3986 actor.AddRenderer( renderer );
3987 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3988 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3990 application.SendNotification();
3991 application.Render();
3995 Renderer renderer = actor.GetRendererAt(0);
3996 actor.RemoveRenderer(renderer);
3997 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3999 application.SendNotification();
4000 application.Render();
4003 // Call one final time to ensure that the renderer is actually removed after
4004 // the handle goes out of scope, and excercises the deletion code path in
4005 // scene graph and render.
4006 application.SendNotification();
4007 application.Render();
4012 int UtcDaliActorRemoveRendererP2(void)
4014 tet_infoline("Testing Actor::RemoveRenderer");
4015 TestApplication application;
4017 Actor actor = Actor::New();
4019 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4021 Geometry geometry = CreateQuadGeometry();
4022 Shader shader = CreateShader();
4023 Renderer renderer = Renderer::New(geometry, shader);
4025 actor.AddRenderer( renderer );
4026 application.SendNotification();
4027 application.Render();
4029 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4030 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4032 actor.RemoveRenderer(0);
4033 application.SendNotification();
4034 application.Render();
4036 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4038 // Shut down whilst holding onto the renderer handle.
4043 int UtcDaliActorRemoveRendererN(void)
4045 tet_infoline("Testing Actor::RemoveRenderer");
4046 TestApplication application;
4048 Actor actor = Actor::New();
4050 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4052 Geometry geometry = CreateQuadGeometry();
4053 Shader shader = CreateShader();
4054 Renderer renderer = Renderer::New(geometry, shader);
4056 actor.AddRenderer( renderer );
4057 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4058 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4060 actor.RemoveRenderer(10);
4061 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4062 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4067 // Clipping test helper functions:
4068 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4070 BufferImage image = BufferImage::New( width, height );
4071 Actor actor = CreateRenderableActor( image );
4073 // Setup dimensions and position so actor is not skipped by culling.
4074 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4075 actor.SetSize( width, height );
4076 actor.SetParentOrigin( ParentOrigin::CENTER );
4077 actor.SetAnchorPoint( AnchorPoint::CENTER );
4082 Actor CreateActorWithContent16x16()
4084 return CreateActorWithContent( 16, 16 );
4087 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4089 enabledDisableTrace.Reset();
4090 stencilTrace.Reset();
4091 enabledDisableTrace.Enable( true );
4092 stencilTrace.Enable( true );
4094 application.SendNotification();
4095 application.Render();
4097 enabledDisableTrace.Enable( false );
4098 stencilTrace.Enable( false );
4101 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4103 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4105 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4106 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4107 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4108 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4111 int UtcDaliActorPropertyClippingP(void)
4113 // This test checks the clippingMode property.
4114 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4115 TestApplication application;
4117 Actor actor = Actor::New();
4119 // Check default clippingEnabled value.
4120 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4123 bool getValueResult = getValue.Get( value );
4124 DALI_TEST_CHECK( getValueResult );
4126 if( getValueResult )
4128 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4131 // Check setting the property to the stencil mode.
4132 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4134 // Check the new value was set.
4135 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4136 getValueResult = getValue.Get( value );
4137 DALI_TEST_CHECK( getValueResult );
4139 if( getValueResult )
4141 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4144 // Check setting the property to the scissor mode.
4145 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4147 // Check the new value was set.
4148 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4149 getValueResult = getValue.Get( value );
4150 DALI_TEST_CHECK( getValueResult );
4152 if( getValueResult )
4154 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4159 int UtcDaliActorPropertyClippingN(void)
4161 // Negative test case for Clipping.
4162 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4163 TestApplication application;
4165 Actor actor = Actor::New();
4167 // Check default clippingEnabled value.
4168 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4171 bool getValueResult = getValue.Get( value );
4172 DALI_TEST_CHECK( getValueResult );
4174 if( getValueResult )
4176 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4179 // Check setting an invalid property value won't change the current property value.
4180 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4182 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4183 getValueResult = getValue.Get( value );
4184 DALI_TEST_CHECK( getValueResult );
4186 if( getValueResult )
4188 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4194 int UtcDaliActorPropertyClippingActor(void)
4196 // This test checks that an actor is correctly setup for clipping.
4197 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4198 TestApplication application;
4200 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4201 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4202 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4203 size_t startIndex = 0u;
4205 // Create a clipping actor.
4206 Actor actorDepth1Clip = CreateActorWithContent16x16();
4207 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4208 Stage::GetCurrent().Add( actorDepth1Clip );
4210 // Gather the call trace.
4211 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4213 // Check we are writing to the color buffer.
4214 CheckColorMask( glAbstraction, true );
4216 // Check the stencil buffer was enabled.
4217 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4219 // Check the stencil buffer was cleared.
4220 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4222 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4223 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4224 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4225 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4230 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4232 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4233 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4234 TestApplication application;
4236 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4237 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4238 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4239 size_t startIndex = 0u;
4241 // Create a clipping actor.
4242 Actor actorDepth1Clip = CreateActorWithContent16x16();
4243 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4244 Stage::GetCurrent().Add( actorDepth1Clip );
4246 // Gather the call trace.
4247 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4249 // Check we are writing to the color buffer.
4250 CheckColorMask( glAbstraction, true );
4252 // Check the stencil buffer was enabled.
4253 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4255 // Check the stencil buffer was cleared.
4256 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4258 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4259 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4260 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4261 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4263 // Now disable the clipping
4264 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4266 // Gather the call trace.
4267 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4269 // Check the stencil buffer was disabled.
4270 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4272 // Ensure all values in stencil-mask are set to 1.
4274 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4279 int UtcDaliActorPropertyClippingNestedChildren(void)
4281 // This test checks that a hierarchy of actors are clipped correctly by
4282 // writing to and reading from the correct bit-planes of the stencil buffer.
4283 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4284 TestApplication application;
4285 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4286 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4287 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4289 // Create a clipping actor.
4290 Actor actorDepth1Clip = CreateActorWithContent16x16();
4291 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4292 Stage::GetCurrent().Add( actorDepth1Clip );
4294 // Create a child actor.
4295 Actor childDepth2 = CreateActorWithContent16x16();
4296 actorDepth1Clip.Add( childDepth2 );
4298 // Create another clipping actor.
4299 Actor childDepth2Clip = CreateActorWithContent16x16();
4300 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4301 childDepth2.Add( childDepth2Clip );
4303 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4304 // This tests the sort algorithm.
4305 Actor childDepth3 = CreateActorWithContent16x16();
4306 childDepth2Clip.Add( childDepth3 );
4307 Actor childDepth4 = CreateActorWithContent16x16();
4308 childDepth3.Add( childDepth4 );
4310 // Gather the call trace.
4311 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4313 // Check we are writing to the color buffer.
4314 CheckColorMask( glAbstraction, true );
4316 // Check the stencil buffer was enabled.
4317 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4319 // Perform the test twice, once for 2D layer, and once for 3D.
4320 for( unsigned int i = 0u ; i < 2u; ++i )
4322 size_t startIndex = 0u;
4324 // Check the stencil buffer was cleared.
4325 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4327 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4328 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4329 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4330 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4332 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4333 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4334 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4336 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4337 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4338 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4339 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4341 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4342 // (Both must be set to pass the check).
4343 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4344 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4346 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4349 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4350 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4357 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4359 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4360 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4361 TestApplication application;
4362 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4363 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4365 /* We create a small tree of actors as follows:
4369 Clipping enabled -> B D
4373 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4376 for( int i = 0; i < 5; ++i )
4378 BufferImage image = BufferImage::New( 16u, 16u );
4379 Actor actor = CreateRenderableActor( image );
4381 // Setup dimensions and position so actor is not skipped by culling.
4382 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4383 actor.SetSize( 16.0f, 16.0f );
4387 actor.SetParentOrigin( ParentOrigin::CENTER );
4391 float b = i > 2 ? 1.0f : -1.0f;
4392 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4398 // Enable clipping on the actor at the top of the left branch.
4399 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4401 // Build the scene graph.
4402 Stage::GetCurrent().Add( actors[0] );
4405 actors[0].Add( actors[1] );
4406 actors[1].Add( actors[2] );
4409 actors[0].Add( actors[3] );
4410 actors[3].Add( actors[4] );
4412 // Gather the call trace.
4413 enabledDisableTrace.Reset();
4414 enabledDisableTrace.Enable( true );
4415 application.SendNotification();
4416 application.Render();
4417 enabledDisableTrace.Enable( false );
4419 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4421 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
4422 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4424 size_t startIndex = 0u;
4425 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4426 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4427 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4429 // Swap the clipping actor from top of left branch to top of right branch.
4430 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4431 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4433 // Gather the call trace.
4434 enabledDisableTrace.Reset();
4435 enabledDisableTrace.Enable( true );
4436 application.SendNotification();
4437 application.Render();
4438 enabledDisableTrace.Enable( false );
4440 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4441 // This proves the draw order has remained the same.
4443 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4444 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4449 int UtcDaliActorPropertyScissorClippingActor(void)
4451 // This test checks that an actor is correctly setup for clipping.
4452 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4453 TestApplication application;
4455 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4456 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4457 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4459 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4460 const Vector2 imageSize( 16.0f, 16.0f );
4462 // Create a clipping actor.
4463 Actor clippingActorA = CreateActorWithContent16x16();
4464 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4465 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4466 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4467 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4468 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4469 Stage::GetCurrent().Add( clippingActorA );
4471 // Gather the call trace.
4472 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4474 // Check we are writing to the color buffer.
4475 CheckColorMask( glAbstraction, true );
4477 // Check scissor test was enabled.
4478 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4480 // Check the scissor was set, and the coordinates are correct.
4481 std::stringstream compareParametersString;
4482 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4483 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4485 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4486 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4488 // Gather the call trace.
4489 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4491 // Check the scissor was set, and the coordinates are correct.
4492 compareParametersString.str( std::string() );
4493 compareParametersString.clear();
4494 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4495 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4500 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4502 // This test checks that an actor is correctly setup for clipping.
4503 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4504 TestApplication application;
4507 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4508 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4509 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4511 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4512 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4513 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4515 // Create a clipping actors.
4516 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4517 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4519 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4520 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4521 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4523 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4524 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4525 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4527 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4528 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4530 Stage::GetCurrent().Add( clippingActorA );
4531 Stage::GetCurrent().Add( clippingActorB );
4533 // Gather the call trace.
4534 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4536 // Check we are writing to the color buffer.
4537 CheckColorMask( glAbstraction, true );
4539 // Check scissor test was enabled.
4540 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4542 // Check the scissor was set, and the coordinates are correct.
4543 std::stringstream compareParametersString;
4545 std::string clipA( "0, 500, 480, 200" );
4546 std::string clipB( "0, 380, 480, 40" );
4548 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4549 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4554 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4556 // This test checks that an actor is correctly setup for clipping.
4557 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4558 TestApplication application;
4560 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4561 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4562 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4564 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4565 const Vector2 imageSize( 16.0f, 16.0f );
4567 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4569 A is drawn first - with scissor clipping on
4570 B is drawn second - also with scissor clipping on
4571 C is the generated clipping region, the intersection ( A ∩ B )
4575 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4576 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4577 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4581 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4584 // Create a clipping actor.
4585 Actor clippingActorA = CreateActorWithContent16x16();
4586 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4587 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4588 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4589 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4590 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4591 Stage::GetCurrent().Add( clippingActorA );
4593 // Create a child clipping actor.
4594 Actor clippingActorB = CreateActorWithContent16x16();
4595 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4596 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4597 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4598 clippingActorA.Add( clippingActorB );
4600 // positionModifiers is an array of positions to position B around.
4601 // expect is an array of expected scissor clip coordinate results.
4602 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4603 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4605 // Loop through each overlap combination.
4606 for( unsigned int test = 0u; test < 4u; ++test )
4608 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4609 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4610 clippingActorB.SetPosition( position.x, position.y );
4612 // Gather the call trace.
4613 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4615 // Check we are writing to the color buffer.
4616 CheckColorMask( glAbstraction, true );
4618 // Check scissor test was enabled.
4619 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4621 // Check the scissor was set, and the coordinates are correct.
4622 const Vector4& expectResults( expect[test] );
4623 std::stringstream compareParametersString;
4624 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4625 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4631 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4633 // This test checks that an actor is correctly setup for clipping.
4634 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4635 TestApplication application;
4637 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4638 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4639 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4641 /* Create a nest of 2 scissors and siblings of the parent.
4651 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4652 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4653 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4654 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4655 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4656 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4658 // Create a clipping actors.
4659 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4660 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4661 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4662 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4663 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4665 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4666 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4667 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4669 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4670 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4671 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4673 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4674 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4675 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4677 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4678 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4679 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4681 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4682 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4684 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4685 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4686 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4687 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4688 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4690 Stage::GetCurrent().Add( clippingActorA );
4691 clippingActorA.Add( clippingActorB );
4692 Stage::GetCurrent().Add( clippingActorC );
4693 Stage::GetCurrent().Add( clippingActorD );
4694 clippingActorD.Add( clippingActorE );
4696 // Gather the call trace.
4697 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4699 // Check we are writing to the color buffer.
4700 CheckColorMask( glAbstraction, true );
4702 // Check scissor test was enabled.
4703 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4705 // Check the scissor was set, and the coordinates are correct.
4706 std::string clipA( "0, 500, 480, 200" );
4707 std::string clipB( "0, 580, 480, 40" );
4708 std::string clipC( "0, 200, 480, 200" );
4709 std::string clipD( "0, 300, 480, 200" );
4711 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4712 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4713 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4714 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4715 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4720 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4722 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4723 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4724 TestApplication application;
4726 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4727 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4728 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4730 // Create a clipping actor.
4731 Actor actorDepth1Clip = CreateActorWithContent16x16();
4732 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4733 Stage::GetCurrent().Add( actorDepth1Clip );
4735 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4736 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4738 // Gather the call trace.
4739 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4741 // Check we are writing to the color buffer.
4742 CheckColorMask( glAbstraction, true );
4744 // Check the stencil buffer was not enabled.
4745 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4747 // Check stencil functions are not called.
4748 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4749 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4750 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4752 // Check that scissor clipping is overriden by the renderer properties.
4753 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4755 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4757 // Gather the call trace.
4758 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4760 // Check the stencil buffer was not enabled.
4761 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4763 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4768 int UtcDaliGetPropertyN(void)
4770 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4771 TestApplication app;
4773 Actor actor = Actor::New();
4775 unsigned int propertyCount = actor.GetPropertyCount();
4776 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4780 int UtcDaliActorRaiseLower(void)
4782 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4784 TestApplication application;
4786 Stage stage( Stage::GetCurrent() );
4788 Actor actorA = Actor::New();
4789 Actor actorB = Actor::New();
4790 Actor actorC = Actor::New();
4792 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4793 actorA.SetParentOrigin( ParentOrigin::CENTER );
4795 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4796 actorB.SetParentOrigin( ParentOrigin::CENTER );
4798 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4799 actorC.SetParentOrigin( ParentOrigin::CENTER );
4801 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4802 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4804 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4805 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4807 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4808 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4810 stage.Add( actorA );
4811 stage.Add( actorB );
4812 stage.Add( actorC );
4814 ResetTouchCallbacks();
4816 application.SendNotification();
4817 application.Render();
4819 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4820 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4821 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4823 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4824 // Only top actor will get touched.
4825 actorA.TouchSignal().Connect( TestTouchCallback );
4826 actorB.TouchSignal().Connect( TestTouchCallback2 );
4827 actorC.TouchSignal().Connect( TestTouchCallback3 );
4829 // Connect ChildOrderChangedSignal
4830 bool orderChangedSignal( false );
4831 Actor orderChangedActor;
4832 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4833 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4835 Dali::Integration::Point point;
4836 point.SetDeviceId( 1 );
4837 point.SetState( PointState::DOWN );
4838 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4839 Dali::Integration::TouchEvent touchEvent;
4840 touchEvent.AddPoint( point );
4842 application.ProcessEvent( touchEvent );
4844 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4845 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4846 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4848 ResetTouchCallbacks();
4850 tet_printf( "Testing Raising of Actor\n" );
4852 int preActorOrder( 0 );
4853 int postActorOrder( 0 );
4855 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4856 value.Get( preActorOrder );
4858 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4860 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4861 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4863 // Ensure sort order is calculated before next touch event
4864 application.SendNotification();
4866 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4867 value.Get( postActorOrder );
4869 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4871 application.ProcessEvent( touchEvent );
4873 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4874 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4875 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4877 ResetTouchCallbacks();
4879 tet_printf( "Testing Lowering of Actor\n" );
4881 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4882 value.Get( preActorOrder );
4884 orderChangedSignal = false;
4886 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4888 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4889 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4891 application.SendNotification(); // ensure sort order calculated before next touch event
4893 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4894 value.Get( postActorOrder );
4896 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4898 application.ProcessEvent( touchEvent );
4900 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4901 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4902 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4904 ResetTouchCallbacks();
4909 int UtcDaliActorRaiseToTopLowerToBottom(void)
4911 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4913 TestApplication application;
4915 Stage stage( Stage::GetCurrent() );
4917 Actor actorA = Actor::New();
4918 Actor actorB = Actor::New();
4919 Actor actorC = Actor::New();
4921 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4922 // enables checking of which actor the uniform is assigned too
4923 Shader shaderA = CreateShader();
4924 shaderA.RegisterProperty( "uRendererColor",1.f);
4926 Shader shaderB = CreateShader();
4927 shaderB.RegisterProperty( "uRendererColor", 2.f );
4929 Shader shaderC = CreateShader();
4930 shaderC.RegisterProperty( "uRendererColor", 3.f );
4932 Geometry geometry = CreateQuadGeometry();
4934 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4935 Renderer rendererA = Renderer::New(geometry, shaderA);
4936 actorA.AddRenderer(rendererA);
4938 Renderer rendererB = Renderer::New(geometry, shaderB);
4939 actorB.AddRenderer(rendererB);
4941 Renderer rendererC = Renderer::New(geometry, shaderC);
4942 actorC.AddRenderer(rendererC);
4944 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4945 actorA.SetParentOrigin( ParentOrigin::CENTER );
4947 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4948 actorB.SetParentOrigin( ParentOrigin::CENTER );
4950 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4951 actorC.SetParentOrigin( ParentOrigin::CENTER );
4953 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4954 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4956 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4957 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4959 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4960 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4962 stage.Add( actorA );
4963 stage.Add( actorB );
4964 stage.Add( actorC );
4966 ResetTouchCallbacks();
4968 // Connect ChildOrderChangedSignal
4969 bool orderChangedSignal( false );
4970 Actor orderChangedActor;
4971 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4972 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4974 // Set up gl abstraction trace so can query the set uniform order
4975 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4976 glAbstraction.EnableSetUniformCallTrace(true);
4977 glAbstraction.ResetSetUniformCallStack();
4979 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4981 application.SendNotification();
4982 application.Render();
4984 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4987 // Test order of uniforms in stack
4988 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4989 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4990 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4992 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4994 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4996 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4997 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4998 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5000 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5001 // Only top actor will get touched.
5002 actorA.TouchSignal().Connect( TestTouchCallback );
5003 actorB.TouchSignal().Connect( TestTouchCallback2 );
5004 actorC.TouchSignal().Connect( TestTouchCallback3 );
5006 Dali::Integration::Point point;
5007 point.SetDeviceId( 1 );
5008 point.SetState( PointState::DOWN );
5009 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5010 Dali::Integration::TouchEvent touchEvent;
5011 touchEvent.AddPoint( point );
5013 application.ProcessEvent( touchEvent );
5015 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5016 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5017 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5019 ResetTouchCallbacks();
5021 tet_printf( "RaiseToTop ActorA\n" );
5023 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5024 actorA.RaiseToTop();
5025 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5026 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5028 application.SendNotification(); // ensure sorting order is calculated before next touch event
5030 application.ProcessEvent( touchEvent );
5032 glAbstraction.ResetSetUniformCallStack();
5033 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5035 application.SendNotification();
5036 application.Render();
5038 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5040 // Test order of uniforms in stack
5041 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5042 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5043 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5045 tet_infoline( "Testing A above C and B at bottom\n" );
5046 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5048 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5050 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5051 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5052 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5054 ResetTouchCallbacks();
5056 tet_printf( "RaiseToTop ActorB\n" );
5058 orderChangedSignal = false;
5060 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5061 actorB.RaiseToTop();
5062 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5063 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5065 application.SendNotification(); // Ensure sort order is calculated before next touch event
5067 application.ProcessEvent( touchEvent );
5069 glAbstraction.ResetSetUniformCallStack();
5070 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5072 application.SendNotification();
5073 application.Render();
5075 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5077 // Test order of uniforms in stack
5078 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5079 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5080 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5082 tet_infoline( "Testing B above A and C at bottom\n" );
5083 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5085 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5087 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5088 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5089 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5091 ResetTouchCallbacks();
5093 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5095 orderChangedSignal = false;
5097 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5098 actorA.LowerToBottom();
5099 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5100 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5102 application.SendNotification();
5103 application.Render();
5105 orderChangedSignal = false;
5107 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5108 actorB.LowerToBottom();
5109 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5110 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5112 application.SendNotification();
5113 application.Render();
5115 application.ProcessEvent( touchEvent );
5117 glAbstraction.ResetSetUniformCallStack();
5118 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5120 application.SendNotification();
5121 application.Render();
5123 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5125 // Test order of uniforms in stack
5126 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5127 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5128 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5130 tet_infoline( "Testing C above A and B at bottom\n" );
5131 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5133 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5135 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5136 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5137 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5139 ResetTouchCallbacks();
5144 int UtcDaliActorRaiseAbove(void)
5146 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5148 TestApplication application;
5150 Stage stage( Stage::GetCurrent() );
5152 Actor actorA = Actor::New();
5153 Actor actorB = Actor::New();
5154 Actor actorC = Actor::New();
5156 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5157 actorA.SetParentOrigin( ParentOrigin::CENTER );
5159 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5160 actorB.SetParentOrigin( ParentOrigin::CENTER );
5162 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5163 actorC.SetParentOrigin( ParentOrigin::CENTER );
5165 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5166 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5168 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5169 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5171 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5172 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5174 stage.Add( actorA );
5175 stage.Add( actorB );
5176 stage.Add( actorC );
5178 ResetTouchCallbacks();
5180 application.SendNotification();
5181 application.Render();
5183 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5184 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5185 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5187 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5188 // Only top actor will get touched.
5189 actorA.TouchSignal().Connect( TestTouchCallback );
5190 actorB.TouchSignal().Connect( TestTouchCallback2 );
5191 actorC.TouchSignal().Connect( TestTouchCallback3 );
5193 bool orderChangedSignal( false );
5194 Actor orderChangedActor;
5195 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5196 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5198 Dali::Integration::Point point;
5199 point.SetDeviceId( 1 );
5200 point.SetState( PointState::DOWN );
5201 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5202 Dali::Integration::TouchEvent touchEvent;
5203 touchEvent.AddPoint( point );
5205 application.ProcessEvent( touchEvent );
5207 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5208 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5209 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5211 ResetTouchCallbacks();
5213 tet_printf( "Raise actor B Above Actor C\n" );
5215 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5216 actorB.RaiseAbove( actorC );
5217 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5218 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5220 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5221 application.SendNotification();
5222 application.ProcessEvent( touchEvent );
5224 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5225 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5226 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5228 ResetTouchCallbacks();
5230 tet_printf( "Raise actor A Above Actor B\n" );
5232 orderChangedSignal = false;
5234 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5235 actorA.RaiseAbove( actorB );
5236 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5237 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5239 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5240 application.SendNotification();
5242 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5244 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5245 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5246 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5248 ResetTouchCallbacks();
5253 int UtcDaliActorLowerBelow(void)
5255 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5257 TestApplication application;
5259 Stage stage( Stage::GetCurrent() );
5261 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5262 // enables checking of which actor the uniform is assigned too
5263 Shader shaderA = CreateShader();
5264 shaderA.RegisterProperty( "uRendererColor",1.f);
5266 Shader shaderB = CreateShader();
5267 shaderB.RegisterProperty( "uRendererColor", 2.f );
5269 Shader shaderC = CreateShader();
5270 shaderC.RegisterProperty( "uRendererColor", 3.f );
5272 Actor actorA = Actor::New();
5273 Actor actorB = Actor::New();
5274 Actor actorC = Actor::New();
5276 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5277 Geometry geometry = CreateQuadGeometry();
5279 Renderer rendererA = Renderer::New(geometry, shaderA);
5280 actorA.AddRenderer(rendererA);
5282 Renderer rendererB = Renderer::New(geometry, shaderB);
5283 actorB.AddRenderer(rendererB);
5285 Renderer rendererC = Renderer::New(geometry, shaderC);
5286 actorC.AddRenderer(rendererC);
5288 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5289 actorA.SetParentOrigin( ParentOrigin::CENTER );
5291 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5292 actorB.SetParentOrigin( ParentOrigin::CENTER );
5294 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5295 actorC.SetParentOrigin( ParentOrigin::CENTER );
5297 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5298 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5300 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5301 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5303 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5304 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5306 Actor container = Actor::New();
5307 container.SetParentOrigin( ParentOrigin::CENTER );
5308 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5309 stage.Add( container );
5311 container.Add( actorA );
5312 container.Add( actorB );
5313 container.Add( actorC );
5315 ResetTouchCallbacks();
5317 // Connect ChildOrderChangedSignal
5318 bool orderChangedSignal( false );
5319 Actor orderChangedActor;
5320 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5321 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5323 // Set up gl abstraction trace so can query the set uniform order
5324 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5325 glAbstraction.EnableSetUniformCallTrace(true);
5326 glAbstraction.ResetSetUniformCallStack();
5327 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5329 glAbstraction.ResetSetUniformCallStack();
5331 application.SendNotification();
5332 application.Render();
5334 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5336 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5338 // Test order of uniforms in stack
5339 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5340 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5341 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5343 tet_infoline( "Testing C above B and A at bottom\n" );
5344 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5346 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5348 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5349 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5350 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5352 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5353 // Only top actor will get touched.
5354 actorA.TouchSignal().Connect( TestTouchCallback );
5355 actorB.TouchSignal().Connect( TestTouchCallback2 );
5356 actorC.TouchSignal().Connect( TestTouchCallback3 );
5358 Dali::Integration::Point point;
5359 point.SetDeviceId( 1 );
5360 point.SetState( PointState::DOWN );
5361 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5362 Dali::Integration::TouchEvent touchEvent;
5363 touchEvent.AddPoint( point );
5365 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5367 application.ProcessEvent( touchEvent );
5369 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5370 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5371 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5373 ResetTouchCallbacks();
5375 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" );
5377 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5378 actorC.LowerBelow( actorB );
5379 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5380 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5382 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5383 application.SendNotification();
5384 application.Render();
5386 application.ProcessEvent( touchEvent ); // touch event
5388 glAbstraction.ResetSetUniformCallStack();
5389 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5391 application.SendNotification();
5392 application.Render();
5394 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5396 // Test order of uniforms in stack
5397 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5398 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5399 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5401 tet_infoline( "Testing render order is A, C, B" );
5402 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5403 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5405 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5406 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5407 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5409 ResetTouchCallbacks();
5411 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5413 orderChangedSignal = false;
5415 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5416 actorC.LowerBelow( actorA );
5417 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5418 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5420 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5421 application.SendNotification();
5422 application.Render();
5424 application.ProcessEvent( touchEvent );
5426 glAbstraction.ResetSetUniformCallStack();
5427 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5429 application.Render();
5430 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5432 // Test order of uniforms in stack
5433 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5434 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5435 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5437 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5438 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5440 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5441 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5442 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5444 ResetTouchCallbacks();
5446 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5448 orderChangedSignal = false;
5450 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5451 actorB.LowerBelow( actorC );
5452 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5453 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5455 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5456 application.SendNotification();
5457 application.Render();
5459 application.ProcessEvent( touchEvent );
5461 glAbstraction.ResetSetUniformCallStack();
5462 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5464 application.Render();
5465 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5467 // Test order of uniforms in stack
5468 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5469 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5470 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5472 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5473 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5479 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5481 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5483 TestApplication application;
5485 Stage stage( Stage::GetCurrent() );
5487 Actor parentA = Actor::New();
5488 Actor parentB = Actor::New();
5489 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5490 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5491 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5492 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5494 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5495 parentA.SetParentOrigin( ParentOrigin::CENTER );
5497 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5498 parentB.SetParentOrigin( ParentOrigin::CENTER );
5500 stage.Add( parentA );
5501 stage.Add( parentB );
5503 Actor actorA = Actor::New();
5504 Actor actorB = Actor::New();
5505 Actor actorC = Actor::New();
5507 parentA.Add( actorA );
5508 parentA.Add( actorB );
5510 tet_printf( "Actor C added to different parent from A and B \n" );
5511 parentB.Add( actorC );
5513 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5514 actorA.SetParentOrigin( ParentOrigin::CENTER );
5516 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5517 actorB.SetParentOrigin( ParentOrigin::CENTER );
5519 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5520 actorC.SetParentOrigin( ParentOrigin::CENTER );
5522 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5523 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5525 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5526 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5528 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5529 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5531 ResetTouchCallbacks();
5533 // Connect ChildOrderChangedSignal
5534 bool orderChangedSignal( false );
5535 Actor orderChangedActor;
5536 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5537 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5539 application.SendNotification();
5540 application.Render();
5542 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5543 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5544 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5546 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5547 // Only top actor will get touched.
5548 actorA.TouchSignal().Connect( TestTouchCallback );
5549 actorB.TouchSignal().Connect( TestTouchCallback2 );
5550 actorC.TouchSignal().Connect( TestTouchCallback3 );
5552 Dali::Integration::Point point;
5553 point.SetDeviceId( 1 );
5554 point.SetState( PointState::DOWN );
5555 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5556 Dali::Integration::TouchEvent touchEvent;
5557 touchEvent.AddPoint( point );
5559 application.ProcessEvent( touchEvent );
5561 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5562 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5563 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5565 ResetTouchCallbacks();
5567 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5569 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5570 actorA.RaiseAbove( actorC );
5571 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5573 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5574 application.SendNotification();
5576 application.ProcessEvent( touchEvent ); // touch event
5578 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5579 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5580 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5582 ResetTouchCallbacks();
5587 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5589 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5591 TestApplication application;
5593 Stage stage( Stage::GetCurrent() );
5595 Actor actorA = Actor::New();
5596 Actor actorB = Actor::New();
5597 Actor actorC = Actor::New();
5599 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5600 actorA.SetParentOrigin( ParentOrigin::CENTER );
5602 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5603 actorB.SetParentOrigin( ParentOrigin::CENTER );
5605 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5606 actorC.SetParentOrigin( ParentOrigin::CENTER );
5608 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5609 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5611 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5612 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5614 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5615 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5617 ResetTouchCallbacks();
5619 // Connect ChildOrderChangedSignal
5620 bool orderChangedSignal( false );
5621 Actor orderChangedActor;
5622 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5623 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5625 application.SendNotification();
5626 application.Render();
5628 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5629 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5630 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5632 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5633 // Only top actor will get touched.
5634 actorA.TouchSignal().Connect( TestTouchCallback );
5635 actorB.TouchSignal().Connect( TestTouchCallback2 );
5636 actorC.TouchSignal().Connect( TestTouchCallback3 );
5638 Dali::Integration::Point point;
5639 point.SetDeviceId( 1 );
5640 point.SetState( PointState::DOWN );
5641 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5642 Dali::Integration::TouchEvent touchEvent;
5643 touchEvent.AddPoint( point );
5645 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5647 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5648 actorA.RaiseAbove( actorC );
5649 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5651 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5652 application.SendNotification();
5654 application.ProcessEvent( touchEvent );
5656 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5658 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5659 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5660 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5662 ResetTouchCallbacks();
5664 orderChangedSignal = false;
5666 stage.Add ( actorB );
5667 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5669 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5670 actorA.LowerBelow( actorC );
5671 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5673 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5674 application.SendNotification();
5675 application.Render();
5677 application.ProcessEvent( touchEvent );
5679 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5680 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5681 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5682 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5684 ResetTouchCallbacks();
5686 orderChangedSignal = false;
5688 tet_printf( "Adding Actor A to stage, will be on top\n" );
5690 stage.Add ( actorA );
5691 application.SendNotification();
5692 application.Render();
5694 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5696 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5697 actorB.RaiseAbove( actorC );
5698 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5700 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5701 application.SendNotification();
5703 application.ProcessEvent( touchEvent );
5705 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5706 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5707 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5708 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5710 ResetTouchCallbacks();
5712 orderChangedSignal = false;
5714 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5716 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5717 actorA.LowerBelow( actorC );
5718 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5720 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5721 application.SendNotification();
5723 application.ProcessEvent( touchEvent );
5725 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5726 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5727 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5728 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5730 ResetTouchCallbacks();
5732 orderChangedSignal = false;
5734 stage.Add ( actorC );
5736 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5737 actorA.RaiseAbove( actorC );
5738 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5739 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5741 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5742 application.SendNotification();
5743 application.Render();
5745 application.ProcessEvent( touchEvent );
5747 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5748 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5749 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5750 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5755 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5757 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5759 TestApplication application;
5761 Stage stage( Stage::GetCurrent() );
5763 Actor actorA = Actor::New();
5764 Actor actorB = Actor::New();
5765 Actor actorC = Actor::New();
5767 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5768 actorA.SetParentOrigin( ParentOrigin::CENTER );
5770 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5771 actorB.SetParentOrigin( ParentOrigin::CENTER );
5773 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5774 actorC.SetParentOrigin( ParentOrigin::CENTER );
5776 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5777 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5779 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5780 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5782 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5783 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5785 ResetTouchCallbacks();
5787 // Connect ChildOrderChangedSignal
5788 bool orderChangedSignal( false );
5789 Actor orderChangedActor;
5790 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5791 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5793 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5794 // Only top actor will get touched.
5795 actorA.TouchSignal().Connect( TestTouchCallback );
5796 actorB.TouchSignal().Connect( TestTouchCallback2 );
5797 actorC.TouchSignal().Connect( TestTouchCallback3 );
5799 Dali::Integration::Point point;
5800 point.SetDeviceId( 1 );
5801 point.SetState( PointState::DOWN );
5802 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5803 Dali::Integration::TouchEvent touchEvent;
5804 touchEvent.AddPoint( point );
5806 stage.Add ( actorA );
5807 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5809 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5811 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5813 application.SendNotification();
5814 application.Render();
5816 application.ProcessEvent( touchEvent );
5818 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5820 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5821 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5822 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5824 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5825 ResetTouchCallbacks();
5827 orderChangedSignal = false;
5829 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5831 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5833 // Sort actor tree before next touch event
5834 application.SendNotification();
5835 application.Render();
5837 application.ProcessEvent( touchEvent );
5839 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5841 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5842 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5843 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5844 ResetTouchCallbacks();
5846 orderChangedSignal = false;
5848 tet_printf( "Lower actor C below B but C not parented\n" );
5850 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5852 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5854 // Sort actor tree before next touch event
5855 application.SendNotification();
5856 application.Render();
5858 application.ProcessEvent( touchEvent );
5860 tet_printf( "Not parented so Lower should show no effect\n" );
5862 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5863 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5864 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5865 ResetTouchCallbacks();
5867 orderChangedSignal = false;
5869 tet_printf( "Raise actor B to top\n" );
5871 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5872 actorB.RaiseToTop();
5873 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5875 // Sort actor tree before next touch event
5876 application.SendNotification();
5877 application.Render();
5879 application.ProcessEvent( touchEvent );
5881 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5883 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5884 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5885 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5886 ResetTouchCallbacks();
5888 orderChangedSignal = false;
5890 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5892 stage.Add ( actorB );
5894 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5896 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5897 actorC.LowerToBottom();
5898 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5900 application.SendNotification();
5901 application.Render();
5903 application.ProcessEvent( touchEvent );
5905 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5907 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5908 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5909 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5910 ResetTouchCallbacks();
5916 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5918 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5920 TestApplication application;
5922 Stage stage( Stage::GetCurrent() );
5924 Actor actorA = Actor::New();
5925 Actor actorB = Actor::New();
5926 Actor actorC = Actor::New();
5928 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5929 actorA.SetParentOrigin( ParentOrigin::CENTER );
5931 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5932 actorB.SetParentOrigin( ParentOrigin::CENTER );
5934 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5935 actorC.SetParentOrigin( ParentOrigin::CENTER );
5937 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5938 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5940 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5941 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5943 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5944 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5946 stage.Add( actorA );
5947 stage.Add( actorB );
5948 stage.Add( actorC );
5950 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5951 // Only top actor will get touched.
5952 actorA.TouchSignal().Connect( TestTouchCallback );
5953 actorB.TouchSignal().Connect( TestTouchCallback2 );
5954 actorC.TouchSignal().Connect( TestTouchCallback3 );
5956 ResetTouchCallbacks();
5958 // Connect ChildOrderChangedSignal
5959 bool orderChangedSignal( false );
5960 Actor orderChangedActor;
5961 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5962 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5964 application.SendNotification();
5965 application.Render();
5967 Dali::Integration::Point point;
5968 point.SetDeviceId( 1 );
5969 point.SetState( PointState::DOWN );
5970 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5971 Dali::Integration::TouchEvent touchEvent;
5972 touchEvent.AddPoint( point );
5974 application.ProcessEvent( touchEvent );
5976 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5977 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5978 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5980 ResetTouchCallbacks();
5982 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5984 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5985 actorA.RaiseAbove( actorA );
5986 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5987 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5989 application.SendNotification();
5990 application.Render();
5992 application.ProcessEvent( touchEvent );
5994 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5996 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5997 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5998 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
6000 ResetTouchCallbacks();
6002 orderChangedSignal = false;
6004 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6005 actorA.RaiseAbove( actorC );
6006 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6007 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6009 application.SendNotification();
6010 application.Render();
6012 application.ProcessEvent( touchEvent );
6014 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
6015 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
6016 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6017 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
6022 int UtcDaliActorGetScreenPosition(void)
6024 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
6026 TestApplication application;
6028 Stage stage( Stage::GetCurrent() );
6030 Actor actorA = Actor::New();
6031 actorA.SetAnchorPoint( AnchorPoint::CENTER );
6033 Vector2 size2( 10.0f, 20.0f );
6034 actorA.SetSize( size2 );
6036 actorA.SetPosition( 0.f, 0.f );
6038 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6040 stage.Add( actorA );
6042 application.SendNotification();
6043 application.Render();
6045 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6046 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6048 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6049 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6051 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6052 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6054 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6056 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6058 application.SendNotification();
6059 application.Render();
6061 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6062 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6064 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6065 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6067 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6068 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6070 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6072 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6074 application.SendNotification();
6075 application.Render();
6077 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6078 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6080 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6081 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6083 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6084 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6086 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6088 actorA.SetPosition( 30.0, 0.0 );
6090 application.SendNotification();
6091 application.Render();
6093 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6094 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6096 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6097 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6099 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6100 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6102 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6104 actorA.SetPosition( 30.0, 420.0 );
6106 application.SendNotification();
6107 application.Render();
6109 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6110 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6112 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6113 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6115 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6116 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6118 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6120 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6121 actorA.SetPosition( 30.0, 30.0 );
6123 Actor actorB = Actor::New();
6124 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6125 actorB.SetSize( size2 );
6126 actorB.SetPosition( 10.f, 10.f );
6127 actorA.Add( actorB );
6129 actorA.SetScale( 2.0f );
6131 application.SendNotification();
6132 application.Render();
6134 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6136 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6137 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6142 int UtcDaliActorGetScreenPositionAfterScaling(void)
6144 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6146 TestApplication application;
6148 Stage stage( Stage::GetCurrent() );
6150 Actor actorA = Actor::New();
6151 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6153 Vector2 size2( 10.0f, 20.0f );
6154 actorA.SetSize( size2 );
6155 actorA.SetScale( 1.5f );
6156 actorA.SetPosition( 0.f, 0.f );
6158 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6160 stage.Add( actorA );
6162 application.SendNotification();
6163 application.Render();
6165 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6166 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6168 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6169 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6171 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6172 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6174 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6176 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6178 application.SendNotification();
6179 application.Render();
6181 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6182 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6184 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6185 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6187 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6188 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6193 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6195 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6197 TestApplication application;
6199 Stage stage( Stage::GetCurrent() );
6201 Actor actorA = Actor::New();
6202 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6203 actorA.SetParentOrigin( ParentOrigin::CENTER );
6204 Vector2 size2( 10.0f, 20.0f );
6205 actorA.SetSize( size2 );
6206 actorA.SetPosition( 0.f, 0.f );
6208 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6210 stage.Add( actorA );
6212 application.SendNotification();
6213 application.Render();
6215 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6216 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6218 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6219 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6221 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6222 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6224 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6226 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6227 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6229 application.SendNotification();
6230 application.Render();
6232 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6233 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6235 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6236 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6238 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6239 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6245 int UtcDaliActorGetScreenPositionWithChildActors(void)
6247 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6249 TestApplication application;
6251 Stage stage( Stage::GetCurrent() );
6253 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6255 Actor actorA = Actor::New();
6256 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6257 actorA.SetParentOrigin( ParentOrigin::CENTER );
6258 Vector2 size1( 10.0f, 20.0f );
6259 actorA.SetSize( size1 );
6260 actorA.SetPosition( 0.f, 0.f );
6262 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6264 Actor parentActorA = Actor::New();
6265 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6266 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6267 Vector2 size2( 30.0f, 60.0f );
6268 parentActorA.SetSize( size2 );
6269 parentActorA.SetPosition( 0.f, 0.f );
6271 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6273 stage.Add( parentActorA );
6274 parentActorA.Add ( actorA );
6276 application.SendNotification();
6277 application.Render();
6279 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6280 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6282 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6283 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6285 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6286 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6288 tet_infoline( "Test 2\n");
6290 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6292 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6293 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6295 application.SendNotification();
6296 application.Render();
6298 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6299 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6301 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6302 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6304 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6305 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6310 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6312 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6314 TestApplication application;
6316 Stage stage( Stage::GetCurrent() );
6318 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6320 Actor actorA = Actor::New();
6321 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6322 actorA.SetParentOrigin( ParentOrigin::CENTER );
6323 Vector2 size1( 10.0f, 20.0f );
6324 actorA.SetSize( size1 );
6325 actorA.SetPosition( 0.f, 0.f );
6327 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6329 Actor parentActorA = Actor::New();
6330 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6331 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6332 Vector2 size2( 30.0f, 60.0f );
6333 parentActorA.SetSize( size2 );
6334 parentActorA.SetPosition( 0.f, 0.f );
6336 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6338 Actor grandParentActorA = Actor::New();
6339 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6340 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6341 Vector2 size3( 60.0f, 120.0f );
6342 grandParentActorA.SetSize( size3 );
6343 grandParentActorA.SetPosition( 0.f, 0.f );
6345 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6347 stage.Add( grandParentActorA );
6348 grandParentActorA.Add ( parentActorA );
6350 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6352 parentActorA.Add ( actorA );
6354 application.SendNotification();
6355 application.Render();
6357 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6358 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6360 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6361 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6363 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6364 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6369 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6371 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6373 TestApplication application;
6375 Stage stage( Stage::GetCurrent() );
6377 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6379 Actor actorA = Actor::New();
6380 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6381 actorA.SetParentOrigin( ParentOrigin::CENTER );
6382 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6383 actorA.SetSize( 10.0f, 20.0f );
6384 stage.Add( actorA );
6386 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6388 Actor actorB = Actor::New();
6389 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6390 actorB.SetParentOrigin( ParentOrigin::CENTER );
6391 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6392 Vector2 actorBSize( 30.0f, 60.0f );
6393 actorB.SetSize( actorBSize );
6394 stage.Add( actorB );
6396 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6398 Actor actorC = Actor::New();
6399 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6400 actorC.SetParentOrigin( ParentOrigin::CENTER );
6401 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6402 Vector2 actorCSize( 60.0f, 120.0f );
6403 actorC.SetSize( actorCSize );
6404 stage.Add( actorC );
6406 application.SendNotification();
6407 application.Render();
6409 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6411 Vector2 center( stage.GetSize() * 0.5f );
6413 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6414 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6415 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6417 tet_infoline( "Add scale to all actors" );
6419 actorA.SetScale( 2.0f );
6420 actorB.SetScale( 2.0f );
6421 actorC.SetScale( 2.0f );
6423 application.SendNotification();
6424 application.Render();
6426 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6427 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6428 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6433 int utcDaliActorPositionUsesAnchorPoint(void)
6435 TestApplication application;
6436 tet_infoline( "Check default behaviour\n" );
6438 Actor actor = Actor::New();
6439 actor.SetParentOrigin( ParentOrigin::CENTER );
6440 actor.SetAnchorPoint( AnchorPoint::CENTER );
6441 actor.SetSize( 100.0f, 100.0f );
6442 Stage::GetCurrent().Add( actor );
6444 application.SendNotification();
6445 application.Render();
6447 tet_infoline( "Check that the world position is in the center\n" );
6448 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6450 tet_infoline( "Set the position uses anchor point property to false\n" );
6451 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6453 application.SendNotification();
6454 application.Render();
6456 tet_infoline( "Check that the world position has changed appropriately\n" );
6457 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6462 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6464 TestApplication application;
6465 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6467 Actor actor = Actor::New();
6468 actor.SetParentOrigin( ParentOrigin::CENTER );
6469 actor.SetAnchorPoint( AnchorPoint::CENTER );
6470 actor.SetSize( 100.0f, 100.0f );
6471 actor.SetScale( 2.0f );
6472 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6473 Stage::GetCurrent().Add( actor );
6475 application.SendNotification();
6476 application.Render();
6478 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6479 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6481 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6482 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6483 application.SendNotification();
6484 application.Render();
6485 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6487 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6488 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6489 application.SendNotification();
6490 application.Render();
6491 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6496 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6498 TestApplication application;
6499 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6501 Actor actor = Actor::New();
6502 actor.SetParentOrigin( ParentOrigin::CENTER );
6503 actor.SetAnchorPoint( AnchorPoint::CENTER );
6504 actor.SetSize( 100.0f, 100.0f );
6505 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6506 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6507 Stage::GetCurrent().Add( actor );
6509 application.SendNotification();
6510 application.Render();
6512 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6513 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6515 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6516 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6517 application.SendNotification();
6518 application.Render();
6519 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6521 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6522 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6523 application.SendNotification();
6524 application.Render();
6525 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6530 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6532 TestApplication application;
6533 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6535 Actor actor = Actor::New();
6536 actor.SetParentOrigin( ParentOrigin::CENTER );
6537 actor.SetAnchorPoint( AnchorPoint::CENTER );
6538 actor.SetSize( 100.0f, 100.0f );
6539 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6540 actor.SetScale( 2.0f );
6541 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6542 Stage::GetCurrent().Add( actor );
6544 application.SendNotification();
6545 application.Render();
6547 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6548 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6550 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6551 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6552 application.SendNotification();
6553 application.Render();
6554 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6556 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6557 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6558 application.SendNotification();
6559 application.Render();
6560 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6565 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6567 TestApplication application;
6568 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6570 Actor parent = Actor::New();
6572 Stage::GetCurrent().Add( parent );
6573 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6575 Actor actor = Actor::New();
6576 actor.SetParentOrigin( ParentOrigin::CENTER );
6577 actor.SetAnchorPoint( AnchorPoint::CENTER );
6578 actor.SetSize( 100.0f, 100.0f );
6579 actor.SetInheritScale( false );
6580 actor.SetInheritOrientation( false );
6581 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6582 parent.Add( actor );
6584 application.SendNotification();
6585 application.Render();
6587 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6589 tet_infoline( "Check the world position is in the right place\n" );
6590 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6592 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6593 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6594 application.SendNotification();
6595 application.Render();
6596 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6598 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6599 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6600 application.SendNotification();
6601 application.Render();
6602 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6607 int utcDaliActorVisibilityChangeSignalSelf(void)
6609 TestApplication application;
6610 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6612 Actor actor = Actor::New();
6614 VisibilityChangedFunctorData data;
6615 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6617 actor.SetVisible( false );
6619 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6621 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6624 actor.SetVisible( false );
6625 data.Check( false /* not called */, TEST_LOCATION );
6627 tet_infoline( "Change the visibility using properties, ensure called" );
6630 actor.SetProperty( Actor::Property::VISIBLE, true );
6631 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6633 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6636 actor.SetProperty( Actor::Property::VISIBLE, true );
6637 data.Check( false /* not called */, TEST_LOCATION );
6642 int utcDaliActorVisibilityChangeSignalChildren(void)
6644 TestApplication application;
6645 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6647 Actor parent = Actor::New();
6648 Actor child = Actor::New();
6649 parent.Add( child );
6651 Actor grandChild = Actor::New();
6652 child.Add( grandChild );
6654 VisibilityChangedFunctorData parentData;
6655 VisibilityChangedFunctorData childData;
6656 VisibilityChangedFunctorData grandChildData;
6658 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6659 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6660 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6662 parent.SetVisible( false );
6663 parentData.Check( false /* not called */, TEST_LOCATION );
6664 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6665 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6667 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6670 grandChildData.Reset();
6672 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6674 parent.SetVisible( true );
6675 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6676 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6677 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6679 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6682 grandChildData.Reset();
6684 parent.SetVisible( true );
6685 parentData.Check( false /* not called */, TEST_LOCATION );
6686 childData.Check( false /* not called */, TEST_LOCATION );
6687 grandChildData.Check( false /* not called */, TEST_LOCATION );
6692 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6694 TestApplication application;
6695 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6697 Actor actor = Actor::New();
6698 Stage::GetCurrent().Add( actor );
6700 application.SendNotification();
6701 application.Render();
6703 VisibilityChangedFunctorData data;
6704 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6706 Animation animation = Animation::New( 1.0f );
6707 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6709 data.Check( false, TEST_LOCATION );
6710 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6711 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6713 tet_infoline( "Play the animation and check the property value" );
6716 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6717 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6719 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6720 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6722 application.SendNotification();
6723 application.Render( 1100 ); // After the animation
6725 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6731 int utcDaliActorVisibilityChangeSignalByName(void)
6733 TestApplication application;
6734 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6736 Actor actor = Actor::New();
6738 bool signalCalled=false;
6739 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6740 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6741 actor.SetVisible( false );
6742 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6744 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6745 signalCalled = false;
6746 actor.SetVisible( false );
6747 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6749 tet_infoline( "Change the visibility using properties, ensure called" );
6750 actor.SetProperty( Actor::Property::VISIBLE, true );
6751 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6753 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6754 signalCalled = false;
6756 actor.SetProperty( Actor::Property::VISIBLE, true );
6757 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6763 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6765 gLayoutDirectionType = type;
6768 int UtcDaliActorLayoutDirectionProperty(void)
6770 TestApplication application;
6771 tet_infoline( "Check layout direction property" );
6773 Actor actor0 = Actor::New();
6774 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6775 Stage::GetCurrent().Add( actor0 );
6777 application.SendNotification();
6778 application.Render();
6780 Actor actor1 = Actor::New();
6781 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6782 Actor actor2 = Actor::New();
6783 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6784 Actor actor3 = Actor::New();
6785 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6786 Actor actor4 = Actor::New();
6787 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6788 Actor actor5 = Actor::New();
6789 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6790 Actor actor6 = Actor::New();
6791 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6792 Actor actor7 = Actor::New();
6793 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6794 Actor actor8 = Actor::New();
6795 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6796 Actor actor9 = Actor::New();
6797 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6799 actor1.Add( actor2 );
6800 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6801 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6803 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6804 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6805 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6807 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6808 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6809 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6811 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6812 actor0.Add( actor1 );
6813 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6814 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6816 Stage::GetCurrent().Add( actor3 );
6817 actor3.Add( actor4 );
6818 actor4.Add( actor5 );
6819 actor5.Add( actor6 );
6820 actor5.Add( actor7 );
6821 actor7.Add( actor8 );
6822 actor8.Add( actor9 );
6823 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6824 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6826 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6827 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6828 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6830 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6832 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6833 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6834 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6835 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6836 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6837 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6838 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6840 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6841 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6842 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6844 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6845 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6846 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6847 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6849 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6850 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6851 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6857 struct LayoutDirectionFunctor
6859 LayoutDirectionFunctor(bool& signalCalled)
6860 : mSignalCalled( signalCalled )
6864 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6865 : mSignalCalled( rhs.mSignalCalled )
6871 mSignalCalled = true;
6874 bool& mSignalCalled;
6877 int UtcDaliActorLayoutDirectionSignal(void)
6879 TestApplication application;
6880 tet_infoline( "Check changing layout direction property sends a signal" );
6882 Actor actor = Actor::New();
6883 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6884 Stage::GetCurrent().Add( actor );
6885 bool signalCalled = false;
6886 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6888 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6889 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6891 // Test that writing the same value doesn't send a signal
6892 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6893 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6895 // Test that writing a different value sends the signal
6896 signalCalled = false;
6897 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6898 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6900 signalCalled = false;
6901 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6902 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6907 struct ChildAddedSignalCheck
6909 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6910 : mSignalReceived( signalReceived ),
6911 mChildHandle( childHandle )
6915 void operator() ( Actor childHandle )
6917 mSignalReceived = true;
6918 mChildHandle = childHandle;
6922 mSignalReceived = true;
6923 mChildHandle = Actor();
6926 bool& mSignalReceived;
6927 Actor& mChildHandle;
6930 int UtcDaliChildAddedSignalP1(void)
6932 TestApplication application;
6933 auto stage = Stage::GetCurrent();
6935 bool signalReceived=false;
6938 ChildAddedSignalCheck signal( signalReceived, childActor );
6939 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6940 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6942 auto actorA = Actor::New();
6943 stage.Add( actorA );
6944 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6945 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6946 signalReceived = false;
6948 auto actorB = Actor::New();
6949 stage.Add( actorB );
6950 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6951 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6957 int UtcDaliChildAddedSignalP2(void)
6959 TestApplication application;
6960 auto stage = Stage::GetCurrent();
6962 bool signalReceived=false;
6965 ChildAddedSignalCheck signal( signalReceived, childActor );
6966 tet_infoline( "Connect to childAdded signal by name" );
6968 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6969 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6971 auto actorA = Actor::New();
6972 stage.Add( actorA );
6973 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6975 // Can't test which actor was added; signal signature is void() when connecting via name.
6976 signalReceived = false;
6978 auto actorB = Actor::New();
6979 stage.Add( actorB );
6980 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6985 int UtcDaliChildAddedSignalN(void)
6987 TestApplication application;
6988 auto stage = Stage::GetCurrent();
6990 bool signalReceived=false;
6993 ChildAddedSignalCheck signal( signalReceived, childActor );
6994 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6995 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6997 auto actorA = Actor::New();
6998 stage.Add( actorA );
6999 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7000 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7001 signalReceived = false;
7003 auto actorB = Actor::New();
7004 actorA.Add( actorB );
7005 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7010 struct ChildRemovedSignalCheck
7012 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
7013 : mSignalReceived( signalReceived ),
7014 mChildHandle( childHandle )
7018 void operator() ( Actor childHandle )
7020 mSignalReceived = true;
7021 mChildHandle = childHandle;
7026 mSignalReceived = true;
7029 bool& mSignalReceived;
7030 Actor& mChildHandle;
7033 int UtcDaliChildRemovedSignalP1(void)
7035 TestApplication application;
7036 auto stage = Stage::GetCurrent();
7038 bool signalReceived=false;
7041 ChildRemovedSignalCheck signal( signalReceived, childActor );
7042 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7043 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7045 auto actorA = Actor::New();
7046 stage.Add( actorA );
7047 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7048 DALI_TEST_CHECK( !childActor );
7050 stage.Remove( actorA );
7051 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7052 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7054 signalReceived = false;
7055 auto actorB = Actor::New();
7056 stage.Add( actorB );
7057 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7059 stage.Remove( actorB );
7060 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7061 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7066 int UtcDaliChildRemovedSignalP2(void)
7068 TestApplication application;
7069 auto stage = Stage::GetCurrent();
7071 bool signalReceived=false;
7074 ChildAddedSignalCheck signal( signalReceived, childActor );
7075 tet_infoline( "Connect to childRemoved signal by name" );
7077 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7078 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7080 auto actorA = Actor::New();
7081 stage.Add( actorA );
7082 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7084 stage.Remove( actorA );
7085 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7087 signalReceived = false;
7088 auto actorB = Actor::New();
7089 stage.Add( actorB );
7090 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7092 stage.Remove( actorB );
7093 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7099 int UtcDaliChildRemovedSignalN(void)
7101 TestApplication application;
7102 auto stage = Stage::GetCurrent();
7104 bool signalReceived=false;
7107 ChildRemovedSignalCheck signal( signalReceived, childActor );
7108 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7109 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7111 auto actorA = Actor::New();
7112 stage.Add( actorA );
7114 auto actorB = Actor::New();
7115 actorA.Add( actorB );
7117 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7118 DALI_TEST_CHECK( ! childActor );
7120 actorA.Remove( actorB );
7121 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7126 int UtcDaliChildMovedSignalP(void)
7128 TestApplication application;
7129 auto stage = Stage::GetCurrent();
7131 bool addedASignalReceived = false;
7132 bool removedASignalReceived = false;
7133 bool addedBSignalReceived = false;
7134 bool removedBSignalReceived = false;
7137 auto actorA = Actor::New();
7138 auto actorB = Actor::New();
7139 stage.Add( actorA );
7140 stage.Add( actorB );
7142 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7143 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7144 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7145 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7147 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7148 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7149 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7150 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7152 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7153 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7154 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7155 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7157 // Create a child of A
7159 auto child = Actor::New();
7160 actorA.Add( child );
7162 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7163 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7164 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7165 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7166 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7169 addedASignalReceived = false;
7170 addedBSignalReceived = false;
7171 removedASignalReceived = false;
7172 removedBSignalReceived = false;
7174 actorB.Add( child ); // Expect this child to be re-parented
7175 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7176 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7177 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7178 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7180 // Move child back to A:
7181 addedASignalReceived = false;
7182 addedBSignalReceived = false;
7183 removedASignalReceived = false;
7184 removedBSignalReceived = false;
7186 actorA.Add( child ); // Expect this child to be re-parented
7187 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7188 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7189 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7190 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7196 int utcDaliActorCulled(void)
7198 TestApplication application;
7199 auto stage = Stage::GetCurrent();
7201 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7203 Actor actor = Actor::New();
7204 actor.SetSize( 10.0f, 10.0f );
7206 Geometry geometry = CreateQuadGeometry();
7207 Shader shader = CreateShader();
7208 Renderer renderer = Renderer::New(geometry, shader);
7209 actor.AddRenderer( renderer );
7213 application.SendNotification();
7214 application.Render( 0 );
7216 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
7218 PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
7219 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7221 // Connect NotifySignal
7222 bool propertyNotificationSignal( false );
7223 PropertyNotification source;
7224 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7225 notification.NotifySignal().Connect( &application, f ) ;
7227 actor.SetPosition( 1000.0f, 1000.0f );
7229 application.SendNotification();
7230 application.Render();
7232 application.SendNotification();
7234 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
7236 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7237 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
7238 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );