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 int UtcDaliActorInheritOpacity(void)
1665 tet_infoline("Testing Actor::Inherit Opacity");
1666 TestApplication application;
1668 Actor parent = Actor::New();
1669 Actor child = Actor::New();
1670 parent.Add( child );
1671 Stage::GetCurrent().Add( parent );
1673 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1674 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1676 // flush the queue and render once
1677 application.SendNotification();
1678 application.Render();
1680 parent.SetOpacity( 0.1f );
1682 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1683 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1685 application.SendNotification();
1686 application.Render();
1688 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1689 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1690 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1691 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1692 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1693 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1698 // SetOrientation(float angleRadians, Vector3 axis)
1699 int UtcDaliActorSetOrientation01(void)
1701 TestApplication application;
1703 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1704 Actor actor = Actor::New();
1706 actor.SetOrientation(rotation);
1708 // flush the queue and render once
1709 application.SendNotification();
1710 application.Render();
1712 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1716 int UtcDaliActorSetOrientation02(void)
1718 TestApplication application;
1720 Actor actor = Actor::New();
1722 Radian angle( 0.785f );
1723 Vector3 axis(1.0f, 1.0f, 0.0f);
1725 actor.SetOrientation( angle, axis);
1726 Quaternion rotation( angle, axis );
1727 // flush the queue and render once
1728 application.SendNotification();
1729 application.Render();
1730 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1732 Stage::GetCurrent().Add( actor );
1733 actor.RotateBy( Degree( 360 ), axis);
1734 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1736 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1737 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1738 // flush the queue and render once
1739 application.SendNotification();
1740 application.Render();
1741 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1743 actor.SetOrientation( angle, axis);
1744 // flush the queue and render once
1745 application.SendNotification();
1746 application.Render();
1747 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1749 Stage::GetCurrent().Remove( actor );
1753 // SetOrientation(float angleRadians, Vector3 axis)
1754 int UtcDaliActorSetOrientationProperty(void)
1756 TestApplication application;
1758 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1759 Actor actor = Actor::New();
1761 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1762 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1764 // flush the queue and render once
1765 application.SendNotification();
1766 application.Render();
1768 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1769 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1770 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1774 // RotateBy(float angleRadians, Vector3 axis)
1775 int UtcDaliActorRotateBy01(void)
1777 TestApplication application;
1779 Actor actor = Actor::New();
1781 Radian angle( M_PI * 0.25f );
1782 actor.RotateBy(( angle ), Vector3::ZAXIS);
1783 // flush the queue and render once
1784 application.SendNotification();
1785 application.Render();
1786 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1788 Stage::GetCurrent().Add( actor );
1790 actor.RotateBy( angle, Vector3::ZAXIS);
1791 // flush the queue and render once
1792 application.SendNotification();
1793 application.Render();
1794 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1796 Stage::GetCurrent().Remove( actor );
1800 // RotateBy(Quaternion relativeRotation)
1801 int UtcDaliActorRotateBy02(void)
1803 TestApplication application;
1805 Actor actor = Actor::New();
1807 Radian angle( M_PI * 0.25f );
1808 Quaternion rotation(angle, Vector3::ZAXIS);
1809 actor.RotateBy(rotation);
1810 // flush the queue and render once
1811 application.SendNotification();
1812 application.Render();
1813 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1815 actor.RotateBy(rotation);
1816 // flush the queue and render once
1817 application.SendNotification();
1818 application.Render();
1819 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1823 int UtcDaliActorGetCurrentOrientation(void)
1825 TestApplication application;
1826 Actor actor = Actor::New();
1828 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1829 actor.SetOrientation(rotation);
1830 // flush the queue and render once
1831 application.SendNotification();
1832 application.Render();
1833 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1837 int UtcDaliActorGetCurrentWorldOrientation(void)
1839 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1840 TestApplication application;
1842 Actor parent = Actor::New();
1843 Radian rotationAngle( Degree(90.0f) );
1844 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1845 parent.SetOrientation( rotation );
1846 Stage::GetCurrent().Add( parent );
1848 Actor child = Actor::New();
1849 child.SetOrientation( rotation );
1850 parent.Add( child );
1852 // The actors should not have a world rotation yet
1853 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1854 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1856 application.SendNotification();
1857 application.Render(0);
1859 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1860 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1862 // The actors should have a world rotation now
1863 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1864 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1866 // turn off child rotation inheritance
1867 child.SetInheritOrientation( false );
1868 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1869 application.SendNotification();
1870 application.Render(0);
1872 // The actors should have a world rotation now
1873 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1874 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1878 // SetScale(float scale)
1879 int UtcDaliActorSetScale01(void)
1881 TestApplication application;
1883 Actor actor = Actor::New();
1885 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1886 actor.SetScale(0.25f);
1888 Vector3 scale(10.0f, 10.0f, 10.0f);
1889 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1891 actor.SetScale(scale.x);
1893 // flush the queue and render once
1894 application.SendNotification();
1895 application.Render();
1897 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1901 // SetScale(float scaleX, float scaleY, float scaleZ)
1902 int UtcDaliActorSetScale02(void)
1904 TestApplication application;
1905 Vector3 scale(10.0f, 10.0f, 10.0f);
1907 Actor actor = Actor::New();
1909 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1910 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1912 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1914 actor.SetScale(scale.x, scale.y, scale.z);
1915 // flush the queue and render once
1916 application.SendNotification();
1917 application.Render();
1918 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1920 // add to stage and test
1921 Stage::GetCurrent().Add( actor );
1922 actor.SetScale( 2.0f, 2.0f, 2.0f );
1923 // flush the queue and render once
1924 application.SendNotification();
1925 application.Render();
1926 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1928 Stage::GetCurrent().Remove( actor );
1933 // SetScale(Vector3 scale)
1934 int UtcDaliActorSetScale03(void)
1936 TestApplication application;
1937 Vector3 scale(10.0f, 10.0f, 10.0f);
1939 Actor actor = Actor::New();
1941 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1942 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1944 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1946 actor.SetScale(scale);
1948 // flush the queue and render once
1949 application.SendNotification();
1950 application.Render();
1952 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1956 int UtcDaliActorSetScaleIndividual(void)
1958 TestApplication application;
1960 Actor actor = Actor::New();
1962 Vector3 vector(0.7f, 0.8f, 0.9f);
1963 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1965 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1966 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1968 // flush the queue and render once
1969 application.SendNotification();
1970 application.Render();
1972 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1973 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1974 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1976 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1977 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1979 // flush the queue and render once
1980 application.SendNotification();
1981 application.Render();
1983 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1984 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1985 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1987 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1988 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1990 // flush the queue and render once
1991 application.SendNotification();
1992 application.Render();
1994 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1995 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1996 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1998 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1999 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
2004 int UtcDaliActorScaleBy(void)
2006 TestApplication application;
2007 Actor actor = Actor::New();
2008 Vector3 vector(100.0f, 100.0f, 100.0f);
2010 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
2012 actor.SetScale(vector);
2014 // flush the queue and render once
2015 application.SendNotification();
2016 application.Render();
2018 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
2020 actor.ScaleBy(vector);
2022 // flush the queue and render once
2023 application.SendNotification();
2024 application.Render();
2026 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
2030 int UtcDaliActorGetCurrentScale(void)
2032 TestApplication application;
2033 Vector3 scale(12.0f, 1.0f, 2.0f);
2035 Actor actor = Actor::New();
2037 actor.SetScale(scale);
2039 // flush the queue and render once
2040 application.SendNotification();
2041 application.Render();
2043 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
2047 int UtcDaliActorGetCurrentWorldScale(void)
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 // The actors should not have a scale yet
2062 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2063 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2065 // The actors should not have a world scale yet
2066 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2067 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2069 application.SendNotification();
2070 application.Render(0);
2072 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2073 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2075 // The actors should have a world scale now
2076 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2077 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2081 int UtcDaliActorInheritScale(void)
2083 tet_infoline("Testing Actor::SetInheritScale");
2084 TestApplication application;
2086 Actor parent = Actor::New();
2087 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2088 parent.SetScale( parentScale );
2089 Stage::GetCurrent().Add( parent );
2091 Actor child = Actor::New();
2092 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2093 child.SetScale( childScale );
2094 parent.Add( child );
2096 application.SendNotification();
2097 application.Render(0);
2099 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2100 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2102 child.SetInheritScale( false );
2103 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2105 application.SendNotification();
2106 application.Render(0);
2108 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2112 int UtcDaliActorSetVisible(void)
2114 TestApplication application;
2116 Actor actor = Actor::New();
2117 actor.SetVisible(false);
2118 // flush the queue and render once
2119 application.SendNotification();
2120 application.Render();
2121 DALI_TEST_CHECK(actor.IsVisible() == false);
2123 actor.SetVisible(true);
2124 // flush the queue and render once
2125 application.SendNotification();
2126 application.Render();
2127 DALI_TEST_CHECK(actor.IsVisible() == true);
2129 // put actor on stage
2130 Stage::GetCurrent().Add( actor );
2131 actor.SetVisible(false);
2132 // flush the queue and render once
2133 application.SendNotification();
2134 application.Render();
2135 DALI_TEST_CHECK(actor.IsVisible() == false);
2139 int UtcDaliActorIsVisible(void)
2141 TestApplication application;
2143 Actor actor = Actor::New();
2145 DALI_TEST_CHECK(actor.IsVisible() == true);
2149 int UtcDaliActorSetOpacity(void)
2151 TestApplication application;
2153 Actor actor = Actor::New();
2154 // initial opacity is 1
2155 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2157 actor.SetOpacity( 0.4f);
2158 // flush the queue and render once
2159 application.SendNotification();
2160 application.Render();
2161 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2163 // change opacity, actor is on stage to change is not immediate
2164 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2165 // flush the queue and render once
2166 application.SendNotification();
2167 application.Render();
2168 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2170 // put actor on stage
2171 Stage::GetCurrent().Add( actor );
2173 // change opacity, actor is on stage to change is not immediate
2174 actor.SetOpacity( 0.9f );
2175 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2176 // flush the queue and render once
2177 application.SendNotification();
2178 application.Render();
2179 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2181 // change opacity, actor is on stage to change is not immediate
2182 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2183 // flush the queue and render once
2184 application.SendNotification();
2185 application.Render();
2186 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2190 int UtcDaliActorGetCurrentOpacity(void)
2192 TestApplication application;
2194 Actor actor = Actor::New();
2195 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2197 actor.SetOpacity(0.5f);
2198 // flush the queue and render once
2199 application.SendNotification();
2200 application.Render();
2201 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2205 int UtcDaliActorSetSensitive(void)
2207 TestApplication application;
2208 Actor actor = Actor::New();
2210 bool sensitive = !actor.IsSensitive();
2212 actor.SetSensitive(sensitive);
2214 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2218 int UtcDaliActorIsSensitive(void)
2220 TestApplication application;
2221 Actor actor = Actor::New();
2222 actor.SetSensitive(false);
2224 DALI_TEST_CHECK(false == actor.IsSensitive());
2228 int UtcDaliActorSetColor(void)
2230 TestApplication application;
2231 Actor actor = Actor::New();
2232 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2234 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2236 actor.SetColor(color);
2237 // flush the queue and render once
2238 application.SendNotification();
2239 application.Render();
2240 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2242 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2243 // flush the queue and render once
2244 application.SendNotification();
2245 application.Render();
2246 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2248 Stage::GetCurrent().Add( actor );
2249 actor.SetColor( color );
2250 // flush the queue and render once
2251 application.SendNotification();
2252 application.Render();
2253 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2255 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2256 // flush the queue and render once
2257 application.SendNotification();
2258 application.Render();
2259 // Actor color is not clamped
2260 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2261 // world color is clamped
2262 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2264 Stage::GetCurrent().Remove( actor );
2268 int UtcDaliActorSetColorIndividual(void)
2270 TestApplication application;
2272 Actor actor = Actor::New();
2274 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2275 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2277 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2278 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2280 // flush the queue and render once
2281 application.SendNotification();
2282 application.Render();
2284 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2285 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2286 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2288 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2289 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2291 // flush the queue and render once
2292 application.SendNotification();
2293 application.Render();
2295 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2296 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2297 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2299 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2300 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2302 // flush the queue and render once
2303 application.SendNotification();
2304 application.Render();
2306 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2307 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2308 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2311 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2312 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2314 // flush the queue and render once
2315 application.SendNotification();
2316 application.Render();
2318 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2319 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2320 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2322 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2323 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2325 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2328 // flush the queue and render once
2329 application.SendNotification();
2330 application.Render();
2332 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2338 int UtcDaliActorGetCurrentColor(void)
2340 TestApplication application;
2341 Actor actor = Actor::New();
2342 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2344 actor.SetColor(color);
2345 // flush the queue and render once
2346 application.SendNotification();
2347 application.Render();
2348 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2352 int UtcDaliActorGetCurrentWorldColor(void)
2354 tet_infoline("Actor::GetCurrentWorldColor");
2355 TestApplication application;
2357 Actor parent = Actor::New();
2358 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2359 parent.SetColor( parentColor );
2360 Stage::GetCurrent().Add( parent );
2362 Actor child = Actor::New();
2363 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2364 child.SetColor( childColor );
2365 parent.Add( child );
2367 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2368 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2370 // verify the default color mode
2371 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2373 // The actors should not have a world color yet
2374 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2375 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2377 application.SendNotification();
2378 application.Render(0);
2380 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2381 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2383 // The actors should have a world color now
2384 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2385 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2388 child.SetColorMode( USE_OWN_COLOR );
2389 application.SendNotification();
2390 application.Render(0);
2391 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2394 child.SetColorMode( USE_PARENT_COLOR );
2395 application.SendNotification();
2396 application.Render(0);
2397 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2398 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2401 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2402 application.SendNotification();
2403 application.Render(0);
2404 Vector4 expectedColor( childColor );
2405 expectedColor.a *= parentColor.a;
2406 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2407 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2411 int UtcDaliActorSetColorMode(void)
2413 tet_infoline("Actor::SetColorMode");
2414 TestApplication application;
2415 Actor actor = Actor::New();
2416 Actor child = Actor::New();
2419 actor.SetColorMode( USE_OWN_COLOR );
2420 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2422 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2423 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2425 actor.SetColorMode( USE_PARENT_COLOR );
2426 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2428 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2429 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2433 int UtcDaliActorScreenToLocal(void)
2435 TestApplication application;
2436 Actor actor = Actor::New();
2437 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2438 actor.SetSize(100.0f, 100.0f);
2439 actor.SetPosition(10.0f, 10.0f);
2440 Stage::GetCurrent().Add(actor);
2442 // flush the queue and render once
2443 application.SendNotification();
2444 application.Render();
2449 application.SendNotification();
2450 application.Render();
2452 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2454 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2455 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2459 int UtcDaliActorSetLeaveRequired(void)
2461 TestApplication application;
2463 Actor actor = Actor::New();
2465 actor.SetLeaveRequired(false);
2466 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2468 actor.SetLeaveRequired(true);
2469 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2473 int UtcDaliActorGetLeaveRequired(void)
2475 TestApplication application;
2477 Actor actor = Actor::New();
2479 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2483 int UtcDaliActorSetKeyboardFocusable(void)
2485 TestApplication application;
2487 Actor actor = Actor::New();
2489 actor.SetKeyboardFocusable(true);
2490 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2492 actor.SetKeyboardFocusable(false);
2493 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2497 int UtcDaliActorIsKeyboardFocusable(void)
2499 TestApplication application;
2501 Actor actor = Actor::New();
2503 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2507 int UtcDaliActorRemoveConstraints(void)
2509 tet_infoline(" UtcDaliActorRemoveConstraints");
2510 TestApplication application;
2512 gTestConstraintCalled = false;
2514 Actor actor = Actor::New();
2516 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2518 actor.RemoveConstraints();
2520 DALI_TEST_CHECK( gTestConstraintCalled == false );
2522 Stage::GetCurrent().Add( actor );
2525 // flush the queue and render once
2526 application.SendNotification();
2527 application.Render();
2529 actor.RemoveConstraints();
2531 DALI_TEST_CHECK( gTestConstraintCalled == true );
2535 int UtcDaliActorRemoveConstraintTag(void)
2537 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2538 TestApplication application;
2540 Actor actor = Actor::New();
2542 // 1. Apply Constraint1 and Constraint2, and test...
2543 unsigned int result1 = 0u;
2544 unsigned int result2 = 0u;
2546 unsigned constraint1Tag = 1u;
2547 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2548 constraint1.SetTag( constraint1Tag );
2549 constraint1.Apply();
2551 unsigned constraint2Tag = 2u;
2552 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2553 constraint2.SetTag( constraint2Tag );
2554 constraint2.Apply();
2556 Stage::GetCurrent().Add( actor );
2557 // flush the queue and render once
2558 application.SendNotification();
2559 application.Render();
2561 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2562 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2564 // 2. Remove Constraint1 and test...
2567 actor.RemoveConstraints(constraint1Tag);
2568 // make color property dirty, which will trigger constraints to be reapplied.
2569 actor.SetColor( Color::WHITE );
2570 // flush the queue and render once
2571 application.SendNotification();
2572 application.Render();
2574 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2575 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2577 // 3. Re-Apply Constraint1 and test...
2580 constraint1.Apply();
2581 // make color property dirty, which will trigger constraints to be reapplied.
2582 actor.SetColor( Color::WHITE );
2583 // flush the queue and render once
2584 application.SendNotification();
2585 application.Render();
2587 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2588 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2590 // 2. Remove Constraint2 and test...
2593 actor.RemoveConstraints(constraint2Tag);
2594 // make color property dirty, which will trigger constraints to be reapplied.
2595 actor.SetColor( Color::WHITE );
2596 // flush the queue and render once
2597 application.SendNotification();
2598 application.Render();
2600 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2601 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2603 // 2. Remove Constraint1 as well and test...
2606 actor.RemoveConstraints(constraint1Tag);
2607 // make color property dirty, which will trigger constraints to be reapplied.
2608 actor.SetColor( Color::WHITE );
2609 // flush the queue and render once
2610 application.SendNotification();
2611 application.Render();
2613 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2614 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2618 int UtcDaliActorTouchedSignal(void)
2620 TestApplication application;
2622 ResetTouchCallbacks();
2624 // get the root layer
2625 Actor actor = Stage::GetCurrent().GetRootLayer();
2626 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2628 application.SendNotification();
2629 application.Render();
2631 // connect to its touch signal
2632 actor.TouchedSignal().Connect( TestCallback );
2634 // simulate a touch event in the middle of the screen
2635 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2636 Dali::Integration::Point point;
2637 point.SetDeviceId( 1 );
2638 point.SetState( PointState::DOWN );
2639 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2640 Dali::Integration::TouchEvent touchEvent;
2641 touchEvent.AddPoint( point );
2642 application.ProcessEvent( touchEvent );
2644 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2648 int UtcDaliActorHoveredSignal(void)
2650 TestApplication application;
2652 gHoverCallBackCalled = false;
2654 // get the root layer
2655 Actor actor = Stage::GetCurrent().GetRootLayer();
2656 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2658 application.SendNotification();
2659 application.Render();
2661 // connect to its hover signal
2662 actor.HoveredSignal().Connect( TestCallback3 );
2664 // simulate a hover event in the middle of the screen
2665 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2666 Dali::Integration::Point point;
2667 point.SetDeviceId( 1 );
2668 point.SetState( PointState::MOTION );
2669 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2670 Dali::Integration::HoverEvent hoverEvent;
2671 hoverEvent.AddPoint( point );
2672 application.ProcessEvent( hoverEvent );
2674 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2678 int UtcDaliActorOnOffStageSignal(void)
2680 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2682 TestApplication application;
2685 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2686 gActorNamesOnOffStage.clear();
2688 Actor parent = Actor::New();
2689 parent.SetName( "parent" );
2690 parent.OnStageSignal().Connect( OnStageCallback );
2691 parent.OffStageSignal().Connect( OffStageCallback );
2693 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2694 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2696 // add parent to stage
2697 Stage::GetCurrent().Add( parent );
2698 // onstage emitted, offstage not
2699 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2700 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2701 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2703 // test adding a child, should get onstage emitted
2705 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2706 gActorNamesOnOffStage.clear();
2708 Actor child = Actor::New();
2709 child.SetName( "child" );
2710 child.OnStageSignal().Connect( OnStageCallback );
2711 child.OffStageSignal().Connect( OffStageCallback );
2712 parent.Add( child ); // add child
2713 // onstage emitted, offstage not
2714 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2715 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2716 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2718 // test removing parent from stage
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, 2, TEST_LOCATION );
2727 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2728 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2730 // test adding parent back to stage
2732 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2733 gActorNamesOnOffStage.clear();
2735 Stage::GetCurrent().Add( parent );
2736 // onstage emitted, offstage not
2737 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2738 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2739 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2740 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2742 // test removing child
2744 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2745 gActorNamesOnOffStage.clear();
2747 parent.Remove( child );
2748 // onstage not emitted, offstage is
2749 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2750 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2751 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2753 // test removing parent
2755 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2756 gActorNamesOnOffStage.clear();
2758 Stage::GetCurrent().Remove( parent );
2759 // onstage not emitted, offstage is
2760 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2761 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2762 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2766 int UtcDaliActorFindChildByName(void)
2768 tet_infoline("Testing Dali::Actor::FindChildByName()");
2769 TestApplication application;
2771 Actor parent = Actor::New();
2772 parent.SetName( "parent" );
2773 Actor first = Actor::New();
2774 first .SetName( "first" );
2775 Actor second = Actor::New();
2776 second.SetName( "second" );
2781 Actor found = parent.FindChildByName( "foo" );
2782 DALI_TEST_CHECK( !found );
2784 found = parent.FindChildByName( "parent" );
2785 DALI_TEST_CHECK( found == parent );
2787 found = parent.FindChildByName( "first" );
2788 DALI_TEST_CHECK( found == first );
2790 found = parent.FindChildByName( "second" );
2791 DALI_TEST_CHECK( found == second );
2795 int UtcDaliActorFindChildById(void)
2797 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2798 TestApplication application;
2800 Actor parent = Actor::New();
2801 Actor first = Actor::New();
2802 Actor second = Actor::New();
2807 Actor found = parent.FindChildById( 100000 );
2808 DALI_TEST_CHECK( !found );
2810 found = parent.FindChildById( parent.GetId() );
2811 DALI_TEST_CHECK( found == parent );
2813 found = parent.FindChildById( first.GetId() );
2814 DALI_TEST_CHECK( found == first );
2816 found = parent.FindChildById( second.GetId() );
2817 DALI_TEST_CHECK( found == second );
2821 int UtcDaliActorHitTest(void)
2826 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2828 mTouchPoint( touchPoint ),
2833 Vector2 mTouchPoint;
2837 TestApplication application;
2838 tet_infoline(" UtcDaliActorHitTest");
2840 // Fill a vector with different hit tests.
2841 struct HitTestData* hitTestData[] = {
2842 // scale touch point result
2843 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2844 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2845 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.
2846 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2847 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.
2851 // get the root layer
2852 Actor actor = Actor::New();
2853 actor.SetAnchorPoint( AnchorPoint::CENTER );
2854 actor.SetParentOrigin( ParentOrigin::CENTER );
2856 Stage::GetCurrent().Add( actor );
2858 ResetTouchCallbacks();
2860 unsigned int index = 0;
2861 while( NULL != hitTestData[index] )
2863 actor.SetSize( 1.f, 1.f );
2864 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2866 // flush the queue and render once
2867 application.SendNotification();
2868 application.Render();
2870 DALI_TEST_CHECK( !gTouchCallBackCalled );
2872 // connect to its touch signal
2873 actor.TouchedSignal().Connect(TestCallback);
2875 Dali::Integration::Point point;
2876 point.SetState( PointState::DOWN );
2877 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2878 Dali::Integration::TouchEvent event;
2879 event.AddPoint( point );
2881 // flush the queue and render once
2882 application.SendNotification();
2883 application.Render();
2884 application.ProcessEvent( event );
2886 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2888 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2889 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2890 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2891 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2892 hitTestData[index]->mResult );
2894 ResetTouchCallbacks();
2900 int UtcDaliActorSetDrawMode(void)
2902 TestApplication app;
2903 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2905 Actor a = Actor::New();
2907 Stage::GetCurrent().Add(a);
2908 app.SendNotification();
2910 app.SendNotification();
2913 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2915 a.SetDrawMode( DrawMode::OVERLAY_2D );
2916 app.SendNotification();
2919 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2921 a.SetDrawMode( DrawMode::NORMAL );
2922 app.SendNotification();
2925 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2929 int UtcDaliActorSetDrawModeOverlayRender(void)
2931 TestApplication app;
2932 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2934 app.SendNotification();
2937 std::vector<GLuint> ids;
2938 ids.push_back( 8 ); // first rendered actor
2939 ids.push_back( 9 ); // second rendered actor
2940 ids.push_back( 10 ); // third rendered actor
2941 app.GetGlAbstraction().SetNextTextureIds( ids );
2943 BufferImage imageA = BufferImage::New(16, 16);
2944 BufferImage imageB = BufferImage::New(16, 16);
2945 BufferImage imageC = BufferImage::New(16, 16);
2946 Actor a = CreateRenderableActor( imageA );
2947 Actor b = CreateRenderableActor( imageB );
2948 Actor c = CreateRenderableActor( imageC );
2950 app.SendNotification();
2953 //Textures are bound when first created. Clear bound textures vector
2954 app.GetGlAbstraction().ClearBoundTextures();
2956 // Render a,b,c as regular non-overlays. so order will be:
2960 Stage::GetCurrent().Add(a);
2961 Stage::GetCurrent().Add(b);
2962 Stage::GetCurrent().Add(c);
2964 app.SendNotification();
2967 // Should be 3 textures changes.
2968 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2969 typedef std::vector<GLuint>::size_type TextureSize;
2970 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2971 if( boundTextures.size() == 3 )
2973 DALI_TEST_CHECK( boundTextures[0] == 8u );
2974 DALI_TEST_CHECK( boundTextures[1] == 9u );
2975 DALI_TEST_CHECK( boundTextures[2] == 10u );
2978 // Now texture ids have been set, we can monitor their render order.
2979 // render a as an overlay (last), so order will be:
2983 a.SetDrawMode( DrawMode::OVERLAY_2D );
2984 app.GetGlAbstraction().ClearBoundTextures();
2986 app.SendNotification();
2989 // Should be 3 texture changes.
2990 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2991 if( boundTextures.size() == 3 )
2993 DALI_TEST_CHECK( boundTextures[0] == 9u );
2994 DALI_TEST_CHECK( boundTextures[1] == 10u );
2995 DALI_TEST_CHECK( boundTextures[2] == 8u );
3000 int UtcDaliActorGetCurrentWorldMatrix(void)
3002 TestApplication app;
3003 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3005 Actor parent = Actor::New();
3006 parent.SetParentOrigin(ParentOrigin::CENTER);
3007 parent.SetAnchorPoint(AnchorPoint::CENTER);
3008 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3009 Radian rotationAngle(Degree(85.0f));
3010 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3011 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3012 parent.SetPosition( parentPosition );
3013 parent.SetOrientation( parentRotation );
3014 parent.SetScale( parentScale );
3015 Stage::GetCurrent().Add( parent );
3017 Actor child = Actor::New();
3018 child.SetParentOrigin(ParentOrigin::CENTER);
3019 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
3020 Radian childRotationAngle(Degree(23.0f));
3021 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
3022 Vector3 childScale( 2.0f, 2.0f, 2.0f );
3023 child.SetPosition( childPosition );
3024 child.SetOrientation( childRotation );
3025 child.SetScale( childScale );
3026 parent.Add( child );
3028 app.SendNotification();
3031 app.SendNotification();
3033 Matrix parentMatrix(false);
3034 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3036 Matrix childMatrix(false);
3037 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3039 //Child matrix should be the composition of child and parent
3040 Matrix childWorldMatrix(false);
3041 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3043 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3044 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
3050 int UtcDaliActorConstrainedToWorldMatrix(void)
3052 TestApplication app;
3053 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3055 Actor parent = Actor::New();
3056 parent.SetParentOrigin(ParentOrigin::CENTER);
3057 parent.SetAnchorPoint(AnchorPoint::CENTER);
3058 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3059 Radian rotationAngle(Degree(85.0f));
3060 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3061 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3062 parent.SetPosition( parentPosition );
3063 parent.SetOrientation( parentRotation );
3064 parent.SetScale( parentScale );
3065 Stage::GetCurrent().Add( parent );
3067 Actor child = Actor::New();
3068 child.SetParentOrigin(ParentOrigin::CENTER);
3069 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3070 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3071 posConstraint.Apply();
3073 Stage::GetCurrent().Add( child );
3075 app.SendNotification();
3078 app.SendNotification();
3080 Matrix parentMatrix(false);
3081 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3083 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3084 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3088 int UtcDaliActorConstrainedToOrientation(void)
3090 TestApplication app;
3091 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3093 Actor parent = Actor::New();
3094 parent.SetParentOrigin(ParentOrigin::CENTER);
3095 parent.SetAnchorPoint(AnchorPoint::CENTER);
3096 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3097 Radian rotationAngle(Degree(85.0f));
3098 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3099 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3100 parent.SetPosition( parentPosition );
3101 parent.SetOrientation( parentRotation );
3102 parent.SetScale( parentScale );
3103 Stage::GetCurrent().Add( parent );
3105 Actor child = Actor::New();
3106 child.SetParentOrigin(ParentOrigin::CENTER);
3107 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3108 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3109 posConstraint.Apply();
3111 Stage::GetCurrent().Add( child );
3113 app.SendNotification();
3116 app.SendNotification();
3118 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3122 int UtcDaliActorConstrainedToOpacity(void)
3124 TestApplication app;
3125 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3127 Actor parent = Actor::New();
3128 parent.SetOpacity( 0.7f );
3129 Stage::GetCurrent().Add( parent );
3131 Actor child = Actor::New();
3132 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3133 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3134 opacityConstraint.Apply();
3136 Stage::GetCurrent().Add( child );
3138 app.SendNotification();
3141 app.SendNotification();
3143 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3145 parent.SetOpacity( 0.3f );
3147 app.SendNotification();
3150 app.SendNotification();
3152 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3157 int UtcDaliActorUnparent(void)
3159 TestApplication app;
3160 tet_infoline(" UtcDaliActorUnparent");
3162 Actor parent = Actor::New();
3163 Stage::GetCurrent().Add( parent );
3165 Actor child = Actor::New();
3167 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3168 DALI_TEST_CHECK( !child.GetParent() );
3170 // Test that calling Unparent with no parent is a NOOP
3173 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3174 DALI_TEST_CHECK( !child.GetParent() );
3176 // Test that Unparent works
3177 parent.Add( child );
3179 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3180 DALI_TEST_CHECK( parent == child.GetParent() );
3184 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3185 DALI_TEST_CHECK( !child.GetParent() );
3187 // Test that UnparentAndReset works
3188 parent.Add( child );
3190 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3191 DALI_TEST_CHECK( parent == child.GetParent() );
3193 UnparentAndReset( child );
3195 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3196 DALI_TEST_CHECK( !child );
3198 // Test that UnparentAndReset is a NOOP with empty handle
3199 UnparentAndReset( child );
3201 DALI_TEST_CHECK( !child );
3205 int UtcDaliActorGetChildAt(void)
3207 TestApplication app;
3208 tet_infoline(" UtcDaliActorGetChildAt");
3210 Actor parent = Actor::New();
3211 Stage::GetCurrent().Add( parent );
3213 Actor child0 = Actor::New();
3214 parent.Add( child0 );
3216 Actor child1 = Actor::New();
3217 parent.Add( child1 );
3219 Actor child2 = Actor::New();
3220 parent.Add( child2 );
3222 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3223 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3224 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3228 int UtcDaliActorSetGetOverlay(void)
3230 TestApplication app;
3231 tet_infoline(" UtcDaliActorSetGetOverlay");
3233 Actor parent = Actor::New();
3234 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3235 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3240 int UtcDaliActorCreateDestroy(void)
3242 Actor* actor = new Actor;
3243 DALI_TEST_CHECK( actor );
3250 struct PropertyStringIndex
3252 const char * const name;
3253 const Property::Index index;
3254 const Property::Type type;
3257 const PropertyStringIndex PROPERTY_TABLE[] =
3259 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3260 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3261 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3262 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3263 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3264 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3265 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3266 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3267 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3268 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3269 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3270 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3271 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3272 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3273 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3274 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3275 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3276 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3277 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3278 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3279 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3280 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3281 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3282 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3283 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3284 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3285 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3286 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3287 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3288 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3289 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3290 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3291 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3292 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3293 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3294 { "name", Actor::Property::NAME, Property::STRING },
3295 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3296 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3297 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3298 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3299 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3300 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3301 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3302 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3303 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3304 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3305 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3306 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3307 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3308 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3309 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3310 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3311 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3312 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3313 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3315 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3316 } // unnamed namespace
3318 int UtcDaliActorProperties(void)
3320 TestApplication app;
3322 Actor actor = Actor::New();
3324 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3326 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3327 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3328 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3329 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3334 int UtcDaliRelayoutProperties_ResizePolicies(void)
3336 TestApplication app;
3338 Actor actor = Actor::New();
3341 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3342 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3344 // Set resize policy for all dimensions
3345 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3346 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3348 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3351 // Set individual dimensions
3352 const char* const widthPolicy = "FILL_TO_PARENT";
3353 const char* const heightPolicy = "FIXED";
3355 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3356 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3358 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3359 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3361 // Set individual dimensions using enums
3362 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3363 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3365 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3366 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3368 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3369 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3374 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3376 TestApplication app;
3378 Actor actor = Actor::New();
3381 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3382 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3384 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3385 actor.SetSizeScalePolicy( policy );
3386 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3389 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3390 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3392 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3393 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3395 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3396 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3401 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3403 TestApplication app;
3405 Actor actor = Actor::New();
3408 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3409 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3411 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3412 actor.SetSizeModeFactor( sizeMode );
3413 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3416 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3418 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3419 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3424 int UtcDaliRelayoutProperties_DimensionDependency(void)
3426 TestApplication app;
3428 Actor actor = Actor::New();
3431 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3432 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3435 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3436 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3438 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3439 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3441 // Test setting another resize policy
3442 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3443 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3448 int UtcDaliRelayoutProperties_Padding(void)
3450 TestApplication app;
3452 Actor actor = Actor::New();
3455 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3458 actor.SetProperty( Actor::Property::PADDING, padding );
3459 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3461 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3466 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3468 TestApplication app;
3470 Actor actor = Actor::New();
3473 Vector2 minSize( 1.0f, 2.0f );
3475 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3476 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3478 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3480 Vector2 maxSize( 3.0f, 4.0f );
3482 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3483 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3485 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3490 int UtcDaliActorGetHeightForWidth(void)
3492 TestApplication app;
3494 Actor actor = Actor::New();
3496 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3501 int UtcDaliActorGetWidthForHeight(void)
3503 TestApplication app;
3505 Actor actor = Actor::New();
3507 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3512 int UtcDaliActorGetRelayoutSize(void)
3514 TestApplication app;
3516 Actor actor = Actor::New();
3518 // Add actor to stage
3519 Stage::GetCurrent().Add( actor );
3521 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3523 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3524 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3526 // Flush the queue and render once
3527 app.SendNotification();
3530 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3535 int UtcDaliActorSetPadding(void)
3537 TestApplication app;
3539 Actor actor = Actor::New();
3542 actor.GetPadding( padding );
3544 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3545 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3546 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3547 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3549 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3550 actor.SetPadding( padding2 );
3552 actor.GetPadding( padding );
3554 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3555 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3556 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3557 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3562 int UtcDaliActorSetMinimumSize(void)
3564 TestApplication app;
3566 Actor actor = Actor::New();
3568 Vector2 size = actor.GetMinimumSize();
3570 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3571 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3573 Vector2 size2( 1.0f, 2.0f );
3574 actor.SetMinimumSize( size2 );
3576 size = actor.GetMinimumSize();
3578 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3579 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3584 int UtcDaliActorSetMaximumSize(void)
3586 TestApplication app;
3588 Actor actor = Actor::New();
3590 Vector2 size = actor.GetMaximumSize();
3592 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3593 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3595 Vector2 size2( 1.0f, 2.0f );
3596 actor.SetMaximumSize( size2 );
3598 size = actor.GetMaximumSize();
3600 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3601 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3606 int UtcDaliActorOnRelayoutSignal(void)
3608 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3610 TestApplication application;
3613 gOnRelayoutCallBackCalled = false;
3614 gActorNamesRelayout.clear();
3616 Actor actor = Actor::New();
3617 actor.SetName( "actor" );
3618 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3621 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3623 // Add actor to stage
3624 Stage::GetCurrent().Add( actor );
3626 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3627 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3629 // Flush the queue and render once
3630 application.SendNotification();
3631 application.Render();
3633 // OnRelayout emitted
3634 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3635 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3640 int UtcDaliActorGetHierachyDepth(void)
3642 TestApplication application;
3643 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3646 /* Build tree of actors:
3656 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3658 Stage stage( Stage::GetCurrent() );
3660 Actor actorA = Actor::New();
3661 Actor actorB = Actor::New();
3662 Actor actorC = Actor::New();
3663 Actor actorD = Actor::New();
3664 Actor actorE = Actor::New();
3665 Actor actorF = Actor::New();
3667 //Test that root actor has depth equal 0
3668 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3670 //Test actors return depth -1 when not connected to the tree
3671 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3672 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3673 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3674 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3675 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3676 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3678 //Create the hierarchy
3679 stage.Add( actorA );
3680 actorA.Add( actorB );
3681 actorA.Add( actorC );
3682 actorB.Add( actorD );
3683 actorB.Add( actorE );
3684 actorC.Add( actorF );
3686 //Test actors return correct depth
3687 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3688 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3689 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3690 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3691 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3692 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3694 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3695 actorA.Remove( actorB );
3697 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3698 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3699 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3701 //Removing actorA from the stage. All actors should have depth equal -1
3702 stage.Remove( actorA );
3704 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3705 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3706 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3707 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3708 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3709 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3714 int UtcDaliActorAnchorPointPropertyAsString(void)
3716 TestApplication application;
3718 Actor actor = Actor::New();
3720 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3721 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3723 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3724 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3726 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3727 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3729 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3730 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3732 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3733 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3735 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3736 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3738 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3739 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3741 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3742 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3744 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3745 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3747 // Invalid should not change anything
3748 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3749 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3754 int UtcDaliActorParentOriginPropertyAsString(void)
3756 TestApplication application;
3758 Actor actor = Actor::New();
3760 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3761 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3763 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3764 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3766 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3767 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3769 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3770 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3772 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3773 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3775 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3776 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3778 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3779 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3781 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3782 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3784 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3785 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3787 // Invalid should not change anything
3788 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3789 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3794 int UtcDaliActorColorModePropertyAsString(void)
3796 TestApplication application;
3798 Actor actor = Actor::New();
3800 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3801 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3803 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3804 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3806 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3807 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3809 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3810 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3812 // Invalid should not change anything
3813 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3814 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3819 int UtcDaliActorPositionInheritancePropertyAsString(void)
3821 TestApplication application;
3823 Actor actor = Actor::New();
3825 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3826 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3828 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3829 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3831 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3832 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3834 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3835 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3837 // Invalid should not change anything
3838 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3839 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3844 int UtcDaliActorDrawModePropertyAsString(void)
3846 TestApplication application;
3848 Actor actor = Actor::New();
3850 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3851 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3853 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3854 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3856 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3857 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3859 // Invalid should not change anything
3860 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3861 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3866 int UtcDaliActorColorModePropertyAsEnum(void)
3868 TestApplication application;
3870 Actor actor = Actor::New();
3872 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3873 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3875 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3876 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3878 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3879 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3881 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3882 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3887 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3889 TestApplication application;
3891 Actor actor = Actor::New();
3893 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3894 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3896 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3897 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3899 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3900 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3902 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3903 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3908 int UtcDaliActorDrawModePropertyAsEnum(void)
3910 TestApplication application;
3912 Actor actor = Actor::New();
3914 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3915 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3917 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3918 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3920 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3921 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3926 int UtcDaliActorAddRendererP(void)
3928 tet_infoline("Testing Actor::AddRenderer");
3929 TestApplication application;
3931 Actor actor = Actor::New();
3933 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3935 Geometry geometry = CreateQuadGeometry();
3936 Shader shader = CreateShader();
3937 Renderer renderer = Renderer::New(geometry, shader);
3939 actor.AddRenderer( renderer );
3940 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3941 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3946 int UtcDaliActorAddRendererN(void)
3948 tet_infoline("Testing Actor::AddRenderer");
3949 TestApplication application;
3951 Actor actor = Actor::New();
3957 actor.AddRenderer( renderer );
3958 tet_printf("Assertion test failed - no Exception\n" );
3959 tet_result(TET_FAIL);
3961 catch(Dali::DaliException& e)
3963 DALI_TEST_PRINT_ASSERT( e );
3964 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3965 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3969 tet_printf("Assertion test failed - wrong Exception\n" );
3970 tet_result(TET_FAIL);
3976 int UtcDaliActorAddRendererOnStage(void)
3978 tet_infoline("Testing Actor::AddRenderer");
3979 TestApplication application;
3981 Actor actor = Actor::New();
3982 Stage::GetCurrent().Add(actor);
3984 application.SendNotification();
3985 application.Render(0);
3987 Geometry geometry = CreateQuadGeometry();
3988 Shader shader = CreateShader();
3989 Renderer renderer = Renderer::New(geometry, shader);
3991 application.SendNotification();
3992 application.Render(0);
3996 actor.AddRenderer( renderer );
3997 tet_result(TET_PASS);
4001 tet_result(TET_FAIL);
4007 int UtcDaliActorRemoveRendererP1(void)
4009 tet_infoline("Testing Actor::RemoveRenderer");
4010 TestApplication application;
4012 Actor actor = Actor::New();
4014 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4017 Geometry geometry = CreateQuadGeometry();
4018 Shader shader = CreateShader();
4019 Renderer renderer = Renderer::New(geometry, shader);
4021 actor.AddRenderer( renderer );
4022 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4023 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4025 application.SendNotification();
4026 application.Render();
4030 Renderer renderer = actor.GetRendererAt(0);
4031 actor.RemoveRenderer(renderer);
4032 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4034 application.SendNotification();
4035 application.Render();
4038 // Call one final time to ensure that the renderer is actually removed after
4039 // the handle goes out of scope, and excercises the deletion code path in
4040 // scene graph and render.
4041 application.SendNotification();
4042 application.Render();
4047 int UtcDaliActorRemoveRendererP2(void)
4049 tet_infoline("Testing Actor::RemoveRenderer");
4050 TestApplication application;
4052 Actor actor = Actor::New();
4054 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4056 Geometry geometry = CreateQuadGeometry();
4057 Shader shader = CreateShader();
4058 Renderer renderer = Renderer::New(geometry, shader);
4060 actor.AddRenderer( renderer );
4061 application.SendNotification();
4062 application.Render();
4064 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4065 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4067 actor.RemoveRenderer(0);
4068 application.SendNotification();
4069 application.Render();
4071 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4073 // Shut down whilst holding onto the renderer handle.
4078 int UtcDaliActorRemoveRendererN(void)
4080 tet_infoline("Testing Actor::RemoveRenderer");
4081 TestApplication application;
4083 Actor actor = Actor::New();
4085 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4087 Geometry geometry = CreateQuadGeometry();
4088 Shader shader = CreateShader();
4089 Renderer renderer = Renderer::New(geometry, shader);
4091 actor.AddRenderer( renderer );
4092 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4093 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4095 actor.RemoveRenderer(10);
4096 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4097 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4102 // Clipping test helper functions:
4103 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4105 BufferImage image = BufferImage::New( width, height );
4106 Actor actor = CreateRenderableActor( image );
4108 // Setup dimensions and position so actor is not skipped by culling.
4109 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4110 actor.SetSize( width, height );
4111 actor.SetParentOrigin( ParentOrigin::CENTER );
4112 actor.SetAnchorPoint( AnchorPoint::CENTER );
4117 Actor CreateActorWithContent16x16()
4119 return CreateActorWithContent( 16, 16 );
4122 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4124 enabledDisableTrace.Reset();
4125 stencilTrace.Reset();
4126 enabledDisableTrace.Enable( true );
4127 stencilTrace.Enable( true );
4129 application.SendNotification();
4130 application.Render();
4132 enabledDisableTrace.Enable( false );
4133 stencilTrace.Enable( false );
4136 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4138 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4140 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4141 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4142 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4143 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4146 int UtcDaliActorPropertyClippingP(void)
4148 // This test checks the clippingMode property.
4149 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4150 TestApplication application;
4152 Actor actor = Actor::New();
4154 // Check default clippingEnabled value.
4155 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4158 bool getValueResult = getValue.Get( value );
4159 DALI_TEST_CHECK( getValueResult );
4161 if( getValueResult )
4163 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4166 // Check setting the property to the stencil mode.
4167 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4169 // Check the new value was set.
4170 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4171 getValueResult = getValue.Get( value );
4172 DALI_TEST_CHECK( getValueResult );
4174 if( getValueResult )
4176 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4179 // Check setting the property to the scissor mode.
4180 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4182 // Check the new value was set.
4183 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4184 getValueResult = getValue.Get( value );
4185 DALI_TEST_CHECK( getValueResult );
4187 if( getValueResult )
4189 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4194 int UtcDaliActorPropertyClippingN(void)
4196 // Negative test case for Clipping.
4197 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4198 TestApplication application;
4200 Actor actor = Actor::New();
4202 // Check default clippingEnabled value.
4203 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4206 bool getValueResult = getValue.Get( value );
4207 DALI_TEST_CHECK( getValueResult );
4209 if( getValueResult )
4211 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4214 // Check setting an invalid property value won't change the current property value.
4215 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4217 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4218 getValueResult = getValue.Get( value );
4219 DALI_TEST_CHECK( getValueResult );
4221 if( getValueResult )
4223 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4229 int UtcDaliActorPropertyClippingActor(void)
4231 // This test checks that an actor is correctly setup for clipping.
4232 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4233 TestApplication application;
4235 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4236 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4237 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4238 size_t startIndex = 0u;
4240 // Create a clipping actor.
4241 Actor actorDepth1Clip = CreateActorWithContent16x16();
4242 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4243 Stage::GetCurrent().Add( actorDepth1Clip );
4245 // Gather the call trace.
4246 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4248 // Check we are writing to the color buffer.
4249 CheckColorMask( glAbstraction, true );
4251 // Check the stencil buffer was enabled.
4252 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4254 // Check the stencil buffer was cleared.
4255 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4257 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4258 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4259 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4260 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4265 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4267 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4268 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4269 TestApplication application;
4271 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4272 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4273 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4274 size_t startIndex = 0u;
4276 // Create a clipping actor.
4277 Actor actorDepth1Clip = CreateActorWithContent16x16();
4278 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4279 Stage::GetCurrent().Add( actorDepth1Clip );
4281 // Gather the call trace.
4282 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4284 // Check we are writing to the color buffer.
4285 CheckColorMask( glAbstraction, true );
4287 // Check the stencil buffer was enabled.
4288 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4290 // Check the stencil buffer was cleared.
4291 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4293 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4294 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4295 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4296 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4298 // Now disable the clipping
4299 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4301 // Gather the call trace.
4302 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4304 // Check the stencil buffer was disabled.
4305 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4307 // Ensure all values in stencil-mask are set to 1.
4309 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4314 int UtcDaliActorPropertyClippingNestedChildren(void)
4316 // This test checks that a hierarchy of actors are clipped correctly by
4317 // writing to and reading from the correct bit-planes of the stencil buffer.
4318 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4319 TestApplication application;
4320 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4321 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4322 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4324 // Create a clipping actor.
4325 Actor actorDepth1Clip = CreateActorWithContent16x16();
4326 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4327 Stage::GetCurrent().Add( actorDepth1Clip );
4329 // Create a child actor.
4330 Actor childDepth2 = CreateActorWithContent16x16();
4331 actorDepth1Clip.Add( childDepth2 );
4333 // Create another clipping actor.
4334 Actor childDepth2Clip = CreateActorWithContent16x16();
4335 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4336 childDepth2.Add( childDepth2Clip );
4338 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4339 // This tests the sort algorithm.
4340 Actor childDepth3 = CreateActorWithContent16x16();
4341 childDepth2Clip.Add( childDepth3 );
4342 Actor childDepth4 = CreateActorWithContent16x16();
4343 childDepth3.Add( childDepth4 );
4345 // Gather the call trace.
4346 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4348 // Check we are writing to the color buffer.
4349 CheckColorMask( glAbstraction, true );
4351 // Check the stencil buffer was enabled.
4352 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4354 // Perform the test twice, once for 2D layer, and once for 3D.
4355 for( unsigned int i = 0u ; i < 2u; ++i )
4357 size_t startIndex = 0u;
4359 // Check the stencil buffer was cleared.
4360 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4362 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4363 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4364 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4365 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4367 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4368 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4369 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4371 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4372 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4373 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4374 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4376 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4377 // (Both must be set to pass the check).
4378 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4379 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4381 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4384 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4385 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4392 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4394 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4395 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4396 TestApplication application;
4397 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4398 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4400 /* We create a small tree of actors as follows:
4404 Clipping enabled -> B D
4408 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4411 for( int i = 0; i < 5; ++i )
4413 BufferImage image = BufferImage::New( 16u, 16u );
4414 Actor actor = CreateRenderableActor( image );
4416 // Setup dimensions and position so actor is not skipped by culling.
4417 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4418 actor.SetSize( 16.0f, 16.0f );
4422 actor.SetParentOrigin( ParentOrigin::CENTER );
4426 float b = i > 2 ? 1.0f : -1.0f;
4427 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4433 // Enable clipping on the actor at the top of the left branch.
4434 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4436 // Build the scene graph.
4437 Stage::GetCurrent().Add( actors[0] );
4440 actors[0].Add( actors[1] );
4441 actors[1].Add( actors[2] );
4444 actors[0].Add( actors[3] );
4445 actors[3].Add( actors[4] );
4447 // Gather the call trace.
4448 enabledDisableTrace.Reset();
4449 enabledDisableTrace.Enable( true );
4450 application.SendNotification();
4451 application.Render();
4452 enabledDisableTrace.Enable( false );
4454 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4456 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
4457 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4459 size_t startIndex = 0u;
4460 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4461 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4462 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4464 // Swap the clipping actor from top of left branch to top of right branch.
4465 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4466 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4468 // Gather the call trace.
4469 enabledDisableTrace.Reset();
4470 enabledDisableTrace.Enable( true );
4471 application.SendNotification();
4472 application.Render();
4473 enabledDisableTrace.Enable( false );
4475 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4476 // This proves the draw order has remained the same.
4478 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4479 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4484 int UtcDaliActorPropertyScissorClippingActor(void)
4486 // This test checks that an actor is correctly setup for clipping.
4487 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4488 TestApplication application;
4490 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4491 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4492 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4494 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4495 const Vector2 imageSize( 16.0f, 16.0f );
4497 // Create a clipping actor.
4498 Actor clippingActorA = CreateActorWithContent16x16();
4499 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4500 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4501 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4502 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4503 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4504 Stage::GetCurrent().Add( clippingActorA );
4506 // Gather the call trace.
4507 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4509 // Check we are writing to the color buffer.
4510 CheckColorMask( glAbstraction, true );
4512 // Check scissor test was enabled.
4513 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4515 // Check the scissor was set, and the coordinates are correct.
4516 std::stringstream compareParametersString;
4517 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4518 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4520 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4521 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4523 // Gather the call trace.
4524 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4526 // Check the scissor was set, and the coordinates are correct.
4527 compareParametersString.str( std::string() );
4528 compareParametersString.clear();
4529 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4530 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4535 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4537 // This test checks that an actor is correctly setup for clipping.
4538 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4539 TestApplication application;
4542 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4543 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4544 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4546 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4547 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4548 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4550 // Create a clipping actors.
4551 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4552 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4554 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4555 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4556 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4558 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4559 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4560 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4562 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4563 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4565 Stage::GetCurrent().Add( clippingActorA );
4566 Stage::GetCurrent().Add( clippingActorB );
4568 // Gather the call trace.
4569 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4571 // Check we are writing to the color buffer.
4572 CheckColorMask( glAbstraction, true );
4574 // Check scissor test was enabled.
4575 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4577 // Check the scissor was set, and the coordinates are correct.
4578 std::stringstream compareParametersString;
4580 std::string clipA( "0, 500, 480, 200" );
4581 std::string clipB( "0, 380, 480, 40" );
4583 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4584 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4589 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4591 // This test checks that an actor is correctly setup for clipping.
4592 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4593 TestApplication application;
4595 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4596 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4597 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4599 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4600 const Vector2 imageSize( 16.0f, 16.0f );
4602 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4604 A is drawn first - with scissor clipping on
4605 B is drawn second - also with scissor clipping on
4606 C is the generated clipping region, the intersection ( A ∩ B )
4610 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4611 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4612 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4616 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4619 // Create a clipping actor.
4620 Actor clippingActorA = CreateActorWithContent16x16();
4621 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4622 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4623 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4624 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4625 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4626 Stage::GetCurrent().Add( clippingActorA );
4628 // Create a child clipping actor.
4629 Actor clippingActorB = CreateActorWithContent16x16();
4630 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4631 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4632 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4633 clippingActorA.Add( clippingActorB );
4635 // positionModifiers is an array of positions to position B around.
4636 // expect is an array of expected scissor clip coordinate results.
4637 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4638 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4640 // Loop through each overlap combination.
4641 for( unsigned int test = 0u; test < 4u; ++test )
4643 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4644 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4645 clippingActorB.SetPosition( position.x, position.y );
4647 // Gather the call trace.
4648 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4650 // Check we are writing to the color buffer.
4651 CheckColorMask( glAbstraction, true );
4653 // Check scissor test was enabled.
4654 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4656 // Check the scissor was set, and the coordinates are correct.
4657 const Vector4& expectResults( expect[test] );
4658 std::stringstream compareParametersString;
4659 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4660 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4666 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4668 // This test checks that an actor is correctly setup for clipping.
4669 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4670 TestApplication application;
4672 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4673 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4674 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4676 /* Create a nest of 2 scissors and siblings of the parent.
4686 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4687 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4688 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4689 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4690 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4691 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4693 // Create a clipping actors.
4694 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4695 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4696 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4697 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4698 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4700 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4701 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4702 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4704 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4705 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4706 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4708 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4709 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4710 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4712 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4713 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4714 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4716 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4717 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4719 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4720 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4721 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4722 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4723 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4725 Stage::GetCurrent().Add( clippingActorA );
4726 clippingActorA.Add( clippingActorB );
4727 Stage::GetCurrent().Add( clippingActorC );
4728 Stage::GetCurrent().Add( clippingActorD );
4729 clippingActorD.Add( clippingActorE );
4731 // Gather the call trace.
4732 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4734 // Check we are writing to the color buffer.
4735 CheckColorMask( glAbstraction, true );
4737 // Check scissor test was enabled.
4738 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4740 // Check the scissor was set, and the coordinates are correct.
4741 std::string clipA( "0, 500, 480, 200" );
4742 std::string clipB( "0, 580, 480, 40" );
4743 std::string clipC( "0, 200, 480, 200" );
4744 std::string clipD( "0, 300, 480, 200" );
4746 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4747 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4748 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4749 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4750 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4755 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4757 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4758 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4759 TestApplication application;
4761 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4762 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4763 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4765 // Create a clipping actor.
4766 Actor actorDepth1Clip = CreateActorWithContent16x16();
4767 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4768 Stage::GetCurrent().Add( actorDepth1Clip );
4770 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4771 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4773 // Gather the call trace.
4774 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4776 // Check we are writing to the color buffer.
4777 CheckColorMask( glAbstraction, true );
4779 // Check the stencil buffer was not enabled.
4780 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4782 // Check stencil functions are not called.
4783 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4784 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4785 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4787 // Check that scissor clipping is overriden by the renderer properties.
4788 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4790 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4792 // Gather the call trace.
4793 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4795 // Check the stencil buffer was not enabled.
4796 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4798 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4803 int UtcDaliGetPropertyN(void)
4805 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4806 TestApplication app;
4808 Actor actor = Actor::New();
4810 unsigned int propertyCount = actor.GetPropertyCount();
4811 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4815 int UtcDaliActorRaiseLower(void)
4817 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4819 TestApplication application;
4821 Stage stage( Stage::GetCurrent() );
4823 Actor actorA = Actor::New();
4824 Actor actorB = Actor::New();
4825 Actor actorC = Actor::New();
4827 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4828 actorA.SetParentOrigin( ParentOrigin::CENTER );
4830 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4831 actorB.SetParentOrigin( ParentOrigin::CENTER );
4833 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4834 actorC.SetParentOrigin( ParentOrigin::CENTER );
4836 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4837 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4839 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4840 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4842 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4843 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4845 stage.Add( actorA );
4846 stage.Add( actorB );
4847 stage.Add( actorC );
4849 ResetTouchCallbacks();
4851 application.SendNotification();
4852 application.Render();
4854 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4855 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4856 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4858 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4859 // Only top actor will get touched.
4860 actorA.TouchSignal().Connect( TestTouchCallback );
4861 actorB.TouchSignal().Connect( TestTouchCallback2 );
4862 actorC.TouchSignal().Connect( TestTouchCallback3 );
4864 // Connect ChildOrderChangedSignal
4865 bool orderChangedSignal( false );
4866 Actor orderChangedActor;
4867 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4868 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4870 Dali::Integration::Point point;
4871 point.SetDeviceId( 1 );
4872 point.SetState( PointState::DOWN );
4873 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4874 Dali::Integration::TouchEvent touchEvent;
4875 touchEvent.AddPoint( point );
4877 application.ProcessEvent( touchEvent );
4879 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4880 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4881 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4883 ResetTouchCallbacks();
4885 tet_printf( "Testing Raising of Actor\n" );
4887 int preActorOrder( 0 );
4888 int postActorOrder( 0 );
4890 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4891 value.Get( preActorOrder );
4893 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4895 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4896 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4898 // Ensure sort order is calculated before next touch event
4899 application.SendNotification();
4901 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4902 value.Get( postActorOrder );
4904 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4906 application.ProcessEvent( touchEvent );
4908 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4909 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4910 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4912 ResetTouchCallbacks();
4914 tet_printf( "Testing Lowering of Actor\n" );
4916 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4917 value.Get( preActorOrder );
4919 orderChangedSignal = false;
4921 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4923 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4924 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4926 application.SendNotification(); // ensure sort order calculated before next touch event
4928 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4929 value.Get( postActorOrder );
4931 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4933 application.ProcessEvent( touchEvent );
4935 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4936 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4937 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4939 ResetTouchCallbacks();
4944 int UtcDaliActorRaiseToTopLowerToBottom(void)
4946 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4948 TestApplication application;
4950 Stage stage( Stage::GetCurrent() );
4952 Actor actorA = Actor::New();
4953 Actor actorB = Actor::New();
4954 Actor actorC = Actor::New();
4956 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4957 // enables checking of which actor the uniform is assigned too
4958 Shader shaderA = CreateShader();
4959 shaderA.RegisterProperty( "uRendererColor",1.f);
4961 Shader shaderB = CreateShader();
4962 shaderB.RegisterProperty( "uRendererColor", 2.f );
4964 Shader shaderC = CreateShader();
4965 shaderC.RegisterProperty( "uRendererColor", 3.f );
4967 Geometry geometry = CreateQuadGeometry();
4969 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4970 Renderer rendererA = Renderer::New(geometry, shaderA);
4971 actorA.AddRenderer(rendererA);
4973 Renderer rendererB = Renderer::New(geometry, shaderB);
4974 actorB.AddRenderer(rendererB);
4976 Renderer rendererC = Renderer::New(geometry, shaderC);
4977 actorC.AddRenderer(rendererC);
4979 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4980 actorA.SetParentOrigin( ParentOrigin::CENTER );
4982 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4983 actorB.SetParentOrigin( ParentOrigin::CENTER );
4985 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4986 actorC.SetParentOrigin( ParentOrigin::CENTER );
4988 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4989 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4991 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4992 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4994 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4995 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4997 stage.Add( actorA );
4998 stage.Add( actorB );
4999 stage.Add( actorC );
5001 ResetTouchCallbacks();
5003 // Connect ChildOrderChangedSignal
5004 bool orderChangedSignal( false );
5005 Actor orderChangedActor;
5006 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5007 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5009 // Set up gl abstraction trace so can query the set uniform order
5010 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5011 glAbstraction.EnableSetUniformCallTrace(true);
5012 glAbstraction.ResetSetUniformCallStack();
5014 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5016 application.SendNotification();
5017 application.Render();
5019 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
5022 // Test order of uniforms in stack
5023 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5024 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5025 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5027 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5029 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5031 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5032 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5033 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5035 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5036 // Only top actor will get touched.
5037 actorA.TouchSignal().Connect( TestTouchCallback );
5038 actorB.TouchSignal().Connect( TestTouchCallback2 );
5039 actorC.TouchSignal().Connect( TestTouchCallback3 );
5041 Dali::Integration::Point point;
5042 point.SetDeviceId( 1 );
5043 point.SetState( PointState::DOWN );
5044 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5045 Dali::Integration::TouchEvent touchEvent;
5046 touchEvent.AddPoint( point );
5048 application.ProcessEvent( touchEvent );
5050 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5051 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5052 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5054 ResetTouchCallbacks();
5056 tet_printf( "RaiseToTop ActorA\n" );
5058 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5059 actorA.RaiseToTop();
5060 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5061 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5063 application.SendNotification(); // ensure sorting order is calculated before next touch event
5065 application.ProcessEvent( touchEvent );
5067 glAbstraction.ResetSetUniformCallStack();
5068 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5070 application.SendNotification();
5071 application.Render();
5073 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5075 // Test order of uniforms in stack
5076 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5077 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5078 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5080 tet_infoline( "Testing A above C and B at bottom\n" );
5081 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5083 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5085 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5086 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5087 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5089 ResetTouchCallbacks();
5091 tet_printf( "RaiseToTop ActorB\n" );
5093 orderChangedSignal = false;
5095 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5096 actorB.RaiseToTop();
5097 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5098 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5100 application.SendNotification(); // Ensure sort order is calculated before next touch event
5102 application.ProcessEvent( touchEvent );
5104 glAbstraction.ResetSetUniformCallStack();
5105 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5107 application.SendNotification();
5108 application.Render();
5110 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5112 // Test order of uniforms in stack
5113 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5114 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5115 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5117 tet_infoline( "Testing B above A and C at bottom\n" );
5118 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5120 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5122 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5123 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5124 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5126 ResetTouchCallbacks();
5128 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5130 orderChangedSignal = false;
5132 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5133 actorA.LowerToBottom();
5134 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5135 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5137 application.SendNotification();
5138 application.Render();
5140 orderChangedSignal = false;
5142 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5143 actorB.LowerToBottom();
5144 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5145 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5147 application.SendNotification();
5148 application.Render();
5150 application.ProcessEvent( touchEvent );
5152 glAbstraction.ResetSetUniformCallStack();
5153 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5155 application.SendNotification();
5156 application.Render();
5158 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5160 // Test order of uniforms in stack
5161 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5162 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5163 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5165 tet_infoline( "Testing C above A and B at bottom\n" );
5166 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5168 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5170 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5171 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5172 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5174 ResetTouchCallbacks();
5179 int UtcDaliActorRaiseAbove(void)
5181 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5183 TestApplication application;
5185 Stage stage( Stage::GetCurrent() );
5187 Actor actorA = Actor::New();
5188 Actor actorB = Actor::New();
5189 Actor actorC = Actor::New();
5191 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5192 actorA.SetParentOrigin( ParentOrigin::CENTER );
5194 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5195 actorB.SetParentOrigin( ParentOrigin::CENTER );
5197 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5198 actorC.SetParentOrigin( ParentOrigin::CENTER );
5200 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5201 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5203 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5204 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5206 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5207 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5209 stage.Add( actorA );
5210 stage.Add( actorB );
5211 stage.Add( actorC );
5213 ResetTouchCallbacks();
5215 application.SendNotification();
5216 application.Render();
5218 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5219 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5220 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5222 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5223 // Only top actor will get touched.
5224 actorA.TouchSignal().Connect( TestTouchCallback );
5225 actorB.TouchSignal().Connect( TestTouchCallback2 );
5226 actorC.TouchSignal().Connect( TestTouchCallback3 );
5228 bool orderChangedSignal( false );
5229 Actor orderChangedActor;
5230 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5231 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5233 Dali::Integration::Point point;
5234 point.SetDeviceId( 1 );
5235 point.SetState( PointState::DOWN );
5236 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5237 Dali::Integration::TouchEvent touchEvent;
5238 touchEvent.AddPoint( point );
5240 application.ProcessEvent( touchEvent );
5242 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5243 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5244 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5246 ResetTouchCallbacks();
5248 tet_printf( "Raise actor B Above Actor C\n" );
5250 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5251 actorB.RaiseAbove( actorC );
5252 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5253 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5255 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5256 application.SendNotification();
5257 application.ProcessEvent( touchEvent );
5259 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5260 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5261 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5263 ResetTouchCallbacks();
5265 tet_printf( "Raise actor A Above Actor B\n" );
5267 orderChangedSignal = false;
5269 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5270 actorA.RaiseAbove( actorB );
5271 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5272 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5274 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5275 application.SendNotification();
5277 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5279 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5280 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5281 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5283 ResetTouchCallbacks();
5288 int UtcDaliActorLowerBelow(void)
5290 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5292 TestApplication application;
5294 Stage stage( Stage::GetCurrent() );
5296 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5297 // enables checking of which actor the uniform is assigned too
5298 Shader shaderA = CreateShader();
5299 shaderA.RegisterProperty( "uRendererColor",1.f);
5301 Shader shaderB = CreateShader();
5302 shaderB.RegisterProperty( "uRendererColor", 2.f );
5304 Shader shaderC = CreateShader();
5305 shaderC.RegisterProperty( "uRendererColor", 3.f );
5307 Actor actorA = Actor::New();
5308 Actor actorB = Actor::New();
5309 Actor actorC = Actor::New();
5311 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5312 Geometry geometry = CreateQuadGeometry();
5314 Renderer rendererA = Renderer::New(geometry, shaderA);
5315 actorA.AddRenderer(rendererA);
5317 Renderer rendererB = Renderer::New(geometry, shaderB);
5318 actorB.AddRenderer(rendererB);
5320 Renderer rendererC = Renderer::New(geometry, shaderC);
5321 actorC.AddRenderer(rendererC);
5323 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5324 actorA.SetParentOrigin( ParentOrigin::CENTER );
5326 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5327 actorB.SetParentOrigin( ParentOrigin::CENTER );
5329 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5330 actorC.SetParentOrigin( ParentOrigin::CENTER );
5332 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5333 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5335 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5336 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5338 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5339 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5341 Actor container = Actor::New();
5342 container.SetParentOrigin( ParentOrigin::CENTER );
5343 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5344 stage.Add( container );
5346 container.Add( actorA );
5347 container.Add( actorB );
5348 container.Add( actorC );
5350 ResetTouchCallbacks();
5352 // Connect ChildOrderChangedSignal
5353 bool orderChangedSignal( false );
5354 Actor orderChangedActor;
5355 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5356 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5358 // Set up gl abstraction trace so can query the set uniform order
5359 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5360 glAbstraction.EnableSetUniformCallTrace(true);
5361 glAbstraction.ResetSetUniformCallStack();
5362 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5364 glAbstraction.ResetSetUniformCallStack();
5366 application.SendNotification();
5367 application.Render();
5369 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5371 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5373 // Test order of uniforms in stack
5374 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5375 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5376 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5378 tet_infoline( "Testing C above B and A at bottom\n" );
5379 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5381 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5383 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5384 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5385 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5387 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5388 // Only top actor will get touched.
5389 actorA.TouchSignal().Connect( TestTouchCallback );
5390 actorB.TouchSignal().Connect( TestTouchCallback2 );
5391 actorC.TouchSignal().Connect( TestTouchCallback3 );
5393 Dali::Integration::Point point;
5394 point.SetDeviceId( 1 );
5395 point.SetState( PointState::DOWN );
5396 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5397 Dali::Integration::TouchEvent touchEvent;
5398 touchEvent.AddPoint( point );
5400 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5402 application.ProcessEvent( touchEvent );
5404 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5405 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5406 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5408 ResetTouchCallbacks();
5410 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" );
5412 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5413 actorC.LowerBelow( actorB );
5414 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5415 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5417 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5418 application.SendNotification();
5419 application.Render();
5421 application.ProcessEvent( touchEvent ); // touch event
5423 glAbstraction.ResetSetUniformCallStack();
5424 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5426 application.SendNotification();
5427 application.Render();
5429 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5431 // Test order of uniforms in stack
5432 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5433 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5434 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5436 tet_infoline( "Testing render order is A, C, B" );
5437 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5438 DALI_TEST_EQUALS( indexB > indexC, 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 C below Actor A leaving B on top\n" );
5448 orderChangedSignal = false;
5450 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5451 actorC.LowerBelow( actorA );
5452 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5453 DALI_TEST_EQUALS( orderChangedActor, actorC, 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( indexA > indexC, true, TEST_LOCATION );
5473 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5475 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5476 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5477 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5479 ResetTouchCallbacks();
5481 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5483 orderChangedSignal = false;
5485 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5486 actorB.LowerBelow( actorC );
5487 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5488 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5490 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5491 application.SendNotification();
5492 application.Render();
5494 application.ProcessEvent( touchEvent );
5496 glAbstraction.ResetSetUniformCallStack();
5497 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5499 application.Render();
5500 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5502 // Test order of uniforms in stack
5503 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5504 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5505 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5507 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5508 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5514 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5516 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5518 TestApplication application;
5520 Stage stage( Stage::GetCurrent() );
5522 Actor parentA = Actor::New();
5523 Actor parentB = Actor::New();
5524 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5525 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5526 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5527 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5529 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5530 parentA.SetParentOrigin( ParentOrigin::CENTER );
5532 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5533 parentB.SetParentOrigin( ParentOrigin::CENTER );
5535 stage.Add( parentA );
5536 stage.Add( parentB );
5538 Actor actorA = Actor::New();
5539 Actor actorB = Actor::New();
5540 Actor actorC = Actor::New();
5542 parentA.Add( actorA );
5543 parentA.Add( actorB );
5545 tet_printf( "Actor C added to different parent from A and B \n" );
5546 parentB.Add( actorC );
5548 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5549 actorA.SetParentOrigin( ParentOrigin::CENTER );
5551 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5552 actorB.SetParentOrigin( ParentOrigin::CENTER );
5554 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5555 actorC.SetParentOrigin( ParentOrigin::CENTER );
5557 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5558 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5560 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5561 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5563 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5564 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5566 ResetTouchCallbacks();
5568 // Connect ChildOrderChangedSignal
5569 bool orderChangedSignal( false );
5570 Actor orderChangedActor;
5571 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5572 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5574 application.SendNotification();
5575 application.Render();
5577 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5578 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5579 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5581 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5582 // Only top actor will get touched.
5583 actorA.TouchSignal().Connect( TestTouchCallback );
5584 actorB.TouchSignal().Connect( TestTouchCallback2 );
5585 actorC.TouchSignal().Connect( TestTouchCallback3 );
5587 Dali::Integration::Point point;
5588 point.SetDeviceId( 1 );
5589 point.SetState( PointState::DOWN );
5590 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5591 Dali::Integration::TouchEvent touchEvent;
5592 touchEvent.AddPoint( point );
5594 application.ProcessEvent( touchEvent );
5596 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5597 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5598 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5600 ResetTouchCallbacks();
5602 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5604 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5605 actorA.RaiseAbove( actorC );
5606 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5608 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5609 application.SendNotification();
5611 application.ProcessEvent( touchEvent ); // touch event
5613 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5614 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5615 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5617 ResetTouchCallbacks();
5622 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5624 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5626 TestApplication application;
5628 Stage stage( Stage::GetCurrent() );
5630 Actor actorA = Actor::New();
5631 Actor actorB = Actor::New();
5632 Actor actorC = Actor::New();
5634 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5635 actorA.SetParentOrigin( ParentOrigin::CENTER );
5637 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5638 actorB.SetParentOrigin( ParentOrigin::CENTER );
5640 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5641 actorC.SetParentOrigin( ParentOrigin::CENTER );
5643 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5644 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5646 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5647 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5649 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5650 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5652 ResetTouchCallbacks();
5654 // Connect ChildOrderChangedSignal
5655 bool orderChangedSignal( false );
5656 Actor orderChangedActor;
5657 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5658 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5660 application.SendNotification();
5661 application.Render();
5663 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5664 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5665 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5667 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5668 // Only top actor will get touched.
5669 actorA.TouchSignal().Connect( TestTouchCallback );
5670 actorB.TouchSignal().Connect( TestTouchCallback2 );
5671 actorC.TouchSignal().Connect( TestTouchCallback3 );
5673 Dali::Integration::Point point;
5674 point.SetDeviceId( 1 );
5675 point.SetState( PointState::DOWN );
5676 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5677 Dali::Integration::TouchEvent touchEvent;
5678 touchEvent.AddPoint( point );
5680 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5682 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5683 actorA.RaiseAbove( actorC );
5684 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5686 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5687 application.SendNotification();
5689 application.ProcessEvent( touchEvent );
5691 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5693 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5694 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5695 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5697 ResetTouchCallbacks();
5699 orderChangedSignal = false;
5701 stage.Add ( actorB );
5702 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5704 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5705 actorA.LowerBelow( actorC );
5706 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5708 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5709 application.SendNotification();
5710 application.Render();
5712 application.ProcessEvent( touchEvent );
5714 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5715 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5716 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5717 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5719 ResetTouchCallbacks();
5721 orderChangedSignal = false;
5723 tet_printf( "Adding Actor A to stage, will be on top\n" );
5725 stage.Add ( actorA );
5726 application.SendNotification();
5727 application.Render();
5729 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5731 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5732 actorB.RaiseAbove( actorC );
5733 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5735 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5736 application.SendNotification();
5738 application.ProcessEvent( touchEvent );
5740 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5741 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5742 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5743 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5745 ResetTouchCallbacks();
5747 orderChangedSignal = false;
5749 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5751 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5752 actorA.LowerBelow( actorC );
5753 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5755 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5756 application.SendNotification();
5758 application.ProcessEvent( touchEvent );
5760 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5761 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5762 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5763 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5765 ResetTouchCallbacks();
5767 orderChangedSignal = false;
5769 stage.Add ( actorC );
5771 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5772 actorA.RaiseAbove( actorC );
5773 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5774 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5776 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5777 application.SendNotification();
5778 application.Render();
5780 application.ProcessEvent( touchEvent );
5782 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5783 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5784 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5785 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5790 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5792 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5794 TestApplication application;
5796 Stage stage( Stage::GetCurrent() );
5798 Actor actorA = Actor::New();
5799 Actor actorB = Actor::New();
5800 Actor actorC = Actor::New();
5802 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5803 actorA.SetParentOrigin( ParentOrigin::CENTER );
5805 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5806 actorB.SetParentOrigin( ParentOrigin::CENTER );
5808 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5809 actorC.SetParentOrigin( ParentOrigin::CENTER );
5811 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5812 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5814 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5815 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5817 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5818 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5820 ResetTouchCallbacks();
5822 // Connect ChildOrderChangedSignal
5823 bool orderChangedSignal( false );
5824 Actor orderChangedActor;
5825 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5826 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5828 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5829 // Only top actor will get touched.
5830 actorA.TouchSignal().Connect( TestTouchCallback );
5831 actorB.TouchSignal().Connect( TestTouchCallback2 );
5832 actorC.TouchSignal().Connect( TestTouchCallback3 );
5834 Dali::Integration::Point point;
5835 point.SetDeviceId( 1 );
5836 point.SetState( PointState::DOWN );
5837 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5838 Dali::Integration::TouchEvent touchEvent;
5839 touchEvent.AddPoint( point );
5841 stage.Add ( actorA );
5842 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5844 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5846 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5848 application.SendNotification();
5849 application.Render();
5851 application.ProcessEvent( touchEvent );
5853 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5855 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5856 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5857 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5859 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5860 ResetTouchCallbacks();
5862 orderChangedSignal = false;
5864 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5866 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5868 // Sort actor tree before next touch event
5869 application.SendNotification();
5870 application.Render();
5872 application.ProcessEvent( touchEvent );
5874 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5876 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5877 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5878 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5879 ResetTouchCallbacks();
5881 orderChangedSignal = false;
5883 tet_printf( "Lower actor C below B but C not parented\n" );
5885 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5887 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5889 // Sort actor tree before next touch event
5890 application.SendNotification();
5891 application.Render();
5893 application.ProcessEvent( touchEvent );
5895 tet_printf( "Not parented so Lower should show no effect\n" );
5897 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5898 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5899 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5900 ResetTouchCallbacks();
5902 orderChangedSignal = false;
5904 tet_printf( "Raise actor B to top\n" );
5906 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5907 actorB.RaiseToTop();
5908 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5910 // Sort actor tree before next touch event
5911 application.SendNotification();
5912 application.Render();
5914 application.ProcessEvent( touchEvent );
5916 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5918 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5919 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5920 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5921 ResetTouchCallbacks();
5923 orderChangedSignal = false;
5925 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5927 stage.Add ( actorB );
5929 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5931 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5932 actorC.LowerToBottom();
5933 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5935 application.SendNotification();
5936 application.Render();
5938 application.ProcessEvent( touchEvent );
5940 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5942 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5943 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5944 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5945 ResetTouchCallbacks();
5951 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5953 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5955 TestApplication application;
5957 Stage stage( Stage::GetCurrent() );
5959 Actor actorA = Actor::New();
5960 Actor actorB = Actor::New();
5961 Actor actorC = Actor::New();
5963 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5964 actorA.SetParentOrigin( ParentOrigin::CENTER );
5966 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5967 actorB.SetParentOrigin( ParentOrigin::CENTER );
5969 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5970 actorC.SetParentOrigin( ParentOrigin::CENTER );
5972 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5973 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5975 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5976 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5978 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5979 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5981 stage.Add( actorA );
5982 stage.Add( actorB );
5983 stage.Add( actorC );
5985 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5986 // Only top actor will get touched.
5987 actorA.TouchSignal().Connect( TestTouchCallback );
5988 actorB.TouchSignal().Connect( TestTouchCallback2 );
5989 actorC.TouchSignal().Connect( TestTouchCallback3 );
5991 ResetTouchCallbacks();
5993 // Connect ChildOrderChangedSignal
5994 bool orderChangedSignal( false );
5995 Actor orderChangedActor;
5996 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5997 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5999 application.SendNotification();
6000 application.Render();
6002 Dali::Integration::Point point;
6003 point.SetDeviceId( 1 );
6004 point.SetState( PointState::DOWN );
6005 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
6006 Dali::Integration::TouchEvent touchEvent;
6007 touchEvent.AddPoint( point );
6009 application.ProcessEvent( touchEvent );
6011 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
6012 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6013 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
6015 ResetTouchCallbacks();
6017 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
6019 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6020 actorA.RaiseAbove( actorA );
6021 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6022 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6024 application.SendNotification();
6025 application.Render();
6027 application.ProcessEvent( touchEvent );
6029 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
6031 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
6032 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6033 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
6035 ResetTouchCallbacks();
6037 orderChangedSignal = false;
6039 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6040 actorA.RaiseAbove( actorC );
6041 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6042 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6044 application.SendNotification();
6045 application.Render();
6047 application.ProcessEvent( touchEvent );
6049 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
6050 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
6051 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6052 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
6057 int UtcDaliActorGetScreenPosition(void)
6059 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
6061 TestApplication application;
6063 Stage stage( Stage::GetCurrent() );
6065 Actor actorA = Actor::New();
6066 actorA.SetAnchorPoint( AnchorPoint::CENTER );
6068 Vector2 size2( 10.0f, 20.0f );
6069 actorA.SetSize( size2 );
6071 actorA.SetPosition( 0.f, 0.f );
6073 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6075 stage.Add( actorA );
6077 application.SendNotification();
6078 application.Render();
6080 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6081 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6083 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6084 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6086 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6087 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6089 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6091 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6093 application.SendNotification();
6094 application.Render();
6096 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6097 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6099 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6100 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6102 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6103 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6105 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6107 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6109 application.SendNotification();
6110 application.Render();
6112 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6113 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6115 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6116 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6118 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6119 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6121 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6123 actorA.SetPosition( 30.0, 0.0 );
6125 application.SendNotification();
6126 application.Render();
6128 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6129 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6131 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6132 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6134 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6135 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6137 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6139 actorA.SetPosition( 30.0, 420.0 );
6141 application.SendNotification();
6142 application.Render();
6144 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6145 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6147 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6148 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6150 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6151 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6153 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6155 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6156 actorA.SetPosition( 30.0, 30.0 );
6158 Actor actorB = Actor::New();
6159 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6160 actorB.SetSize( size2 );
6161 actorB.SetPosition( 10.f, 10.f );
6162 actorA.Add( actorB );
6164 actorA.SetScale( 2.0f );
6166 application.SendNotification();
6167 application.Render();
6169 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6171 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6172 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6177 int UtcDaliActorGetScreenPositionAfterScaling(void)
6179 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6181 TestApplication application;
6183 Stage stage( Stage::GetCurrent() );
6185 Actor actorA = Actor::New();
6186 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6188 Vector2 size2( 10.0f, 20.0f );
6189 actorA.SetSize( size2 );
6190 actorA.SetScale( 1.5f );
6191 actorA.SetPosition( 0.f, 0.f );
6193 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6195 stage.Add( actorA );
6197 application.SendNotification();
6198 application.Render();
6200 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6201 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6203 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6204 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6206 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6207 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6209 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6211 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6213 application.SendNotification();
6214 application.Render();
6216 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6217 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6219 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6220 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6222 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6223 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6228 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6230 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6232 TestApplication application;
6234 Stage stage( Stage::GetCurrent() );
6236 Actor actorA = Actor::New();
6237 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6238 actorA.SetParentOrigin( ParentOrigin::CENTER );
6239 Vector2 size2( 10.0f, 20.0f );
6240 actorA.SetSize( size2 );
6241 actorA.SetPosition( 0.f, 0.f );
6243 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6245 stage.Add( actorA );
6247 application.SendNotification();
6248 application.Render();
6250 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6251 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6253 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6254 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6256 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6257 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6259 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6261 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6262 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6264 application.SendNotification();
6265 application.Render();
6267 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6268 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6270 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6271 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6273 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6274 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6280 int UtcDaliActorGetScreenPositionWithChildActors(void)
6282 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6284 TestApplication application;
6286 Stage stage( Stage::GetCurrent() );
6288 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6290 Actor actorA = Actor::New();
6291 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6292 actorA.SetParentOrigin( ParentOrigin::CENTER );
6293 Vector2 size1( 10.0f, 20.0f );
6294 actorA.SetSize( size1 );
6295 actorA.SetPosition( 0.f, 0.f );
6297 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6299 Actor parentActorA = Actor::New();
6300 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6301 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6302 Vector2 size2( 30.0f, 60.0f );
6303 parentActorA.SetSize( size2 );
6304 parentActorA.SetPosition( 0.f, 0.f );
6306 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6308 stage.Add( parentActorA );
6309 parentActorA.Add ( actorA );
6311 application.SendNotification();
6312 application.Render();
6314 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6315 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6317 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6318 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6320 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6321 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6323 tet_infoline( "Test 2\n");
6325 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6327 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6328 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6330 application.SendNotification();
6331 application.Render();
6333 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6334 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6336 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6337 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6339 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6340 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6345 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6347 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6349 TestApplication application;
6351 Stage stage( Stage::GetCurrent() );
6353 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6355 Actor actorA = Actor::New();
6356 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6357 actorA.SetParentOrigin( ParentOrigin::CENTER );
6358 Vector2 size1( 10.0f, 20.0f );
6359 actorA.SetSize( size1 );
6360 actorA.SetPosition( 0.f, 0.f );
6362 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6364 Actor parentActorA = Actor::New();
6365 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6366 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6367 Vector2 size2( 30.0f, 60.0f );
6368 parentActorA.SetSize( size2 );
6369 parentActorA.SetPosition( 0.f, 0.f );
6371 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6373 Actor grandParentActorA = Actor::New();
6374 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6375 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6376 Vector2 size3( 60.0f, 120.0f );
6377 grandParentActorA.SetSize( size3 );
6378 grandParentActorA.SetPosition( 0.f, 0.f );
6380 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6382 stage.Add( grandParentActorA );
6383 grandParentActorA.Add ( parentActorA );
6385 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6387 parentActorA.Add ( actorA );
6389 application.SendNotification();
6390 application.Render();
6392 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6393 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6395 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6396 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6398 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6399 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6404 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6406 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6408 TestApplication application;
6410 Stage stage( Stage::GetCurrent() );
6412 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6414 Actor actorA = Actor::New();
6415 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6416 actorA.SetParentOrigin( ParentOrigin::CENTER );
6417 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6418 actorA.SetSize( 10.0f, 20.0f );
6419 stage.Add( actorA );
6421 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6423 Actor actorB = Actor::New();
6424 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6425 actorB.SetParentOrigin( ParentOrigin::CENTER );
6426 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6427 Vector2 actorBSize( 30.0f, 60.0f );
6428 actorB.SetSize( actorBSize );
6429 stage.Add( actorB );
6431 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6433 Actor actorC = Actor::New();
6434 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6435 actorC.SetParentOrigin( ParentOrigin::CENTER );
6436 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6437 Vector2 actorCSize( 60.0f, 120.0f );
6438 actorC.SetSize( actorCSize );
6439 stage.Add( actorC );
6441 application.SendNotification();
6442 application.Render();
6444 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6446 Vector2 center( stage.GetSize() * 0.5f );
6448 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6449 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6450 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6452 tet_infoline( "Add scale to all actors" );
6454 actorA.SetScale( 2.0f );
6455 actorB.SetScale( 2.0f );
6456 actorC.SetScale( 2.0f );
6458 application.SendNotification();
6459 application.Render();
6461 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6462 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6463 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6468 int utcDaliActorPositionUsesAnchorPoint(void)
6470 TestApplication application;
6471 tet_infoline( "Check default behaviour\n" );
6473 Actor actor = Actor::New();
6474 actor.SetParentOrigin( ParentOrigin::CENTER );
6475 actor.SetAnchorPoint( AnchorPoint::CENTER );
6476 actor.SetSize( 100.0f, 100.0f );
6477 Stage::GetCurrent().Add( actor );
6479 application.SendNotification();
6480 application.Render();
6482 tet_infoline( "Check that the world position is in the center\n" );
6483 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6485 tet_infoline( "Set the position uses anchor point property to false\n" );
6486 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6488 application.SendNotification();
6489 application.Render();
6491 tet_infoline( "Check that the world position has changed appropriately\n" );
6492 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6497 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6499 TestApplication application;
6500 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6502 Actor actor = Actor::New();
6503 actor.SetParentOrigin( ParentOrigin::CENTER );
6504 actor.SetAnchorPoint( AnchorPoint::CENTER );
6505 actor.SetSize( 100.0f, 100.0f );
6506 actor.SetScale( 2.0f );
6507 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6508 Stage::GetCurrent().Add( actor );
6510 application.SendNotification();
6511 application.Render();
6513 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6514 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6516 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6517 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6518 application.SendNotification();
6519 application.Render();
6520 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6522 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6523 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6524 application.SendNotification();
6525 application.Render();
6526 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6531 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6533 TestApplication application;
6534 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6536 Actor actor = Actor::New();
6537 actor.SetParentOrigin( ParentOrigin::CENTER );
6538 actor.SetAnchorPoint( AnchorPoint::CENTER );
6539 actor.SetSize( 100.0f, 100.0f );
6540 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
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 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( -50.0f, 50.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( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6565 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6567 TestApplication application;
6568 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6570 Actor actor = Actor::New();
6571 actor.SetParentOrigin( ParentOrigin::CENTER );
6572 actor.SetAnchorPoint( AnchorPoint::CENTER );
6573 actor.SetSize( 100.0f, 100.0f );
6574 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6575 actor.SetScale( 2.0f );
6576 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6577 Stage::GetCurrent().Add( actor );
6579 application.SendNotification();
6580 application.Render();
6582 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6583 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6585 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6586 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6587 application.SendNotification();
6588 application.Render();
6589 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6591 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6592 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6593 application.SendNotification();
6594 application.Render();
6595 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6600 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6602 TestApplication application;
6603 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6605 Actor parent = Actor::New();
6607 Stage::GetCurrent().Add( parent );
6608 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6610 Actor actor = Actor::New();
6611 actor.SetParentOrigin( ParentOrigin::CENTER );
6612 actor.SetAnchorPoint( AnchorPoint::CENTER );
6613 actor.SetSize( 100.0f, 100.0f );
6614 actor.SetInheritScale( false );
6615 actor.SetInheritOrientation( false );
6616 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6617 parent.Add( actor );
6619 application.SendNotification();
6620 application.Render();
6622 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6624 tet_infoline( "Check the world position is in the right place\n" );
6625 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6627 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6628 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6629 application.SendNotification();
6630 application.Render();
6631 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6633 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6634 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6635 application.SendNotification();
6636 application.Render();
6637 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6642 int utcDaliActorVisibilityChangeSignalSelf(void)
6644 TestApplication application;
6645 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6647 Actor actor = Actor::New();
6649 VisibilityChangedFunctorData data;
6650 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6652 actor.SetVisible( false );
6654 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6656 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6659 actor.SetVisible( false );
6660 data.Check( false /* not called */, TEST_LOCATION );
6662 tet_infoline( "Change the visibility using properties, ensure called" );
6665 actor.SetProperty( Actor::Property::VISIBLE, true );
6666 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6668 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6671 actor.SetProperty( Actor::Property::VISIBLE, true );
6672 data.Check( false /* not called */, TEST_LOCATION );
6677 int utcDaliActorVisibilityChangeSignalChildren(void)
6679 TestApplication application;
6680 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6682 Actor parent = Actor::New();
6683 Actor child = Actor::New();
6684 parent.Add( child );
6686 Actor grandChild = Actor::New();
6687 child.Add( grandChild );
6689 VisibilityChangedFunctorData parentData;
6690 VisibilityChangedFunctorData childData;
6691 VisibilityChangedFunctorData grandChildData;
6693 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6694 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6695 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6697 parent.SetVisible( false );
6698 parentData.Check( false /* not called */, TEST_LOCATION );
6699 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6700 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6702 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6705 grandChildData.Reset();
6707 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6709 parent.SetVisible( true );
6710 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6711 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6712 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6714 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6717 grandChildData.Reset();
6719 parent.SetVisible( true );
6720 parentData.Check( false /* not called */, TEST_LOCATION );
6721 childData.Check( false /* not called */, TEST_LOCATION );
6722 grandChildData.Check( false /* not called */, TEST_LOCATION );
6727 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6729 TestApplication application;
6730 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6732 Actor actor = Actor::New();
6733 Stage::GetCurrent().Add( actor );
6735 application.SendNotification();
6736 application.Render();
6738 VisibilityChangedFunctorData data;
6739 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6741 Animation animation = Animation::New( 1.0f );
6742 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6744 data.Check( false, TEST_LOCATION );
6745 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6746 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6748 tet_infoline( "Play the animation and check the property value" );
6751 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6752 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6754 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6755 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6757 application.SendNotification();
6758 application.Render( 1100 ); // After the animation
6760 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6766 int utcDaliActorVisibilityChangeSignalByName(void)
6768 TestApplication application;
6769 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6771 Actor actor = Actor::New();
6773 bool signalCalled=false;
6774 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6775 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6776 actor.SetVisible( false );
6777 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6779 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6780 signalCalled = false;
6781 actor.SetVisible( false );
6782 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6784 tet_infoline( "Change the visibility using properties, ensure called" );
6785 actor.SetProperty( Actor::Property::VISIBLE, true );
6786 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6788 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6789 signalCalled = false;
6791 actor.SetProperty( Actor::Property::VISIBLE, true );
6792 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6798 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6800 gLayoutDirectionType = type;
6803 int UtcDaliActorLayoutDirectionProperty(void)
6805 TestApplication application;
6806 tet_infoline( "Check layout direction property" );
6808 Actor actor0 = Actor::New();
6809 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6810 Stage::GetCurrent().Add( actor0 );
6812 application.SendNotification();
6813 application.Render();
6815 Actor actor1 = Actor::New();
6816 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6817 Actor actor2 = Actor::New();
6818 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6819 Actor actor3 = Actor::New();
6820 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6821 Actor actor4 = Actor::New();
6822 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6823 Actor actor5 = Actor::New();
6824 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6825 Actor actor6 = Actor::New();
6826 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6827 Actor actor7 = Actor::New();
6828 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6829 Actor actor8 = Actor::New();
6830 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6831 Actor actor9 = Actor::New();
6832 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6834 actor1.Add( actor2 );
6835 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6836 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6838 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6839 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6840 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6842 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6843 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6844 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6846 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6847 actor0.Add( actor1 );
6848 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6849 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6851 Stage::GetCurrent().Add( actor3 );
6852 actor3.Add( actor4 );
6853 actor4.Add( actor5 );
6854 actor5.Add( actor6 );
6855 actor5.Add( actor7 );
6856 actor7.Add( actor8 );
6857 actor8.Add( actor9 );
6858 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6859 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6861 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6862 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6863 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6865 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6867 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6868 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6869 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6870 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6871 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6872 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6873 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6875 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6876 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6877 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6879 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6880 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6881 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6882 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6884 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6885 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6886 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6892 struct LayoutDirectionFunctor
6894 LayoutDirectionFunctor(bool& signalCalled)
6895 : mSignalCalled( signalCalled )
6899 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6900 : mSignalCalled( rhs.mSignalCalled )
6906 mSignalCalled = true;
6909 bool& mSignalCalled;
6912 int UtcDaliActorLayoutDirectionSignal(void)
6914 TestApplication application;
6915 tet_infoline( "Check changing layout direction property sends a signal" );
6917 Actor actor = Actor::New();
6918 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6919 Stage::GetCurrent().Add( actor );
6920 bool signalCalled = false;
6921 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6923 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6924 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6926 // Test that writing the same value doesn't send a signal
6927 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6928 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6930 // Test that writing a different value sends the signal
6931 signalCalled = false;
6932 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6933 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6935 signalCalled = false;
6936 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6937 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6942 struct ChildAddedSignalCheck
6944 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6945 : mSignalReceived( signalReceived ),
6946 mChildHandle( childHandle )
6950 void operator() ( Actor childHandle )
6952 mSignalReceived = true;
6953 mChildHandle = childHandle;
6957 mSignalReceived = true;
6958 mChildHandle = Actor();
6961 bool& mSignalReceived;
6962 Actor& mChildHandle;
6965 int UtcDaliChildAddedSignalP1(void)
6967 TestApplication application;
6968 auto stage = Stage::GetCurrent();
6970 bool signalReceived=false;
6973 ChildAddedSignalCheck signal( signalReceived, childActor );
6974 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6975 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6977 auto actorA = Actor::New();
6978 stage.Add( actorA );
6979 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6980 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6981 signalReceived = false;
6983 auto actorB = Actor::New();
6984 stage.Add( actorB );
6985 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6986 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6992 int UtcDaliChildAddedSignalP2(void)
6994 TestApplication application;
6995 auto stage = Stage::GetCurrent();
6997 bool signalReceived=false;
7000 ChildAddedSignalCheck signal( signalReceived, childActor );
7001 tet_infoline( "Connect to childAdded signal by name" );
7003 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
7004 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7006 auto actorA = Actor::New();
7007 stage.Add( actorA );
7008 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7010 // Can't test which actor was added; signal signature is void() when connecting via name.
7011 signalReceived = false;
7013 auto actorB = Actor::New();
7014 stage.Add( actorB );
7015 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7020 int UtcDaliChildAddedSignalN(void)
7022 TestApplication application;
7023 auto stage = Stage::GetCurrent();
7025 bool signalReceived=false;
7028 ChildAddedSignalCheck signal( signalReceived, childActor );
7029 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7030 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7032 auto actorA = Actor::New();
7033 stage.Add( actorA );
7034 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7035 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7036 signalReceived = false;
7038 auto actorB = Actor::New();
7039 actorA.Add( actorB );
7040 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7045 struct ChildRemovedSignalCheck
7047 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
7048 : mSignalReceived( signalReceived ),
7049 mChildHandle( childHandle )
7053 void operator() ( Actor childHandle )
7055 mSignalReceived = true;
7056 mChildHandle = childHandle;
7061 mSignalReceived = true;
7064 bool& mSignalReceived;
7065 Actor& mChildHandle;
7068 int UtcDaliChildRemovedSignalP1(void)
7070 TestApplication application;
7071 auto stage = Stage::GetCurrent();
7073 bool signalReceived=false;
7076 ChildRemovedSignalCheck signal( signalReceived, childActor );
7077 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, 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 );
7083 DALI_TEST_CHECK( !childActor );
7085 stage.Remove( actorA );
7086 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7087 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7089 signalReceived = false;
7090 auto actorB = Actor::New();
7091 stage.Add( actorB );
7092 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7094 stage.Remove( actorB );
7095 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7096 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7101 int UtcDaliChildRemovedSignalP2(void)
7103 TestApplication application;
7104 auto stage = Stage::GetCurrent();
7106 bool signalReceived=false;
7109 ChildAddedSignalCheck signal( signalReceived, childActor );
7110 tet_infoline( "Connect to childRemoved signal by name" );
7112 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7113 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7115 auto actorA = Actor::New();
7116 stage.Add( actorA );
7117 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7119 stage.Remove( actorA );
7120 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7122 signalReceived = false;
7123 auto actorB = Actor::New();
7124 stage.Add( actorB );
7125 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7127 stage.Remove( actorB );
7128 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7134 int UtcDaliChildRemovedSignalN(void)
7136 TestApplication application;
7137 auto stage = Stage::GetCurrent();
7139 bool signalReceived=false;
7142 ChildRemovedSignalCheck signal( signalReceived, childActor );
7143 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7144 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7146 auto actorA = Actor::New();
7147 stage.Add( actorA );
7149 auto actorB = Actor::New();
7150 actorA.Add( actorB );
7152 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7153 DALI_TEST_CHECK( ! childActor );
7155 actorA.Remove( actorB );
7156 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7161 int UtcDaliChildMovedSignalP(void)
7163 TestApplication application;
7164 auto stage = Stage::GetCurrent();
7166 bool addedASignalReceived = false;
7167 bool removedASignalReceived = false;
7168 bool addedBSignalReceived = false;
7169 bool removedBSignalReceived = false;
7172 auto actorA = Actor::New();
7173 auto actorB = Actor::New();
7174 stage.Add( actorA );
7175 stage.Add( actorB );
7177 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7178 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7179 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7180 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7182 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7183 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7184 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7185 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7187 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7188 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7189 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7190 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7192 // Create a child of A
7194 auto child = Actor::New();
7195 actorA.Add( child );
7197 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7198 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7199 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7200 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7201 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7204 addedASignalReceived = false;
7205 addedBSignalReceived = false;
7206 removedASignalReceived = false;
7207 removedBSignalReceived = false;
7209 actorB.Add( child ); // Expect this child to be re-parented
7210 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7211 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7212 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7213 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7215 // Move child back to A:
7216 addedASignalReceived = false;
7217 addedBSignalReceived = false;
7218 removedASignalReceived = false;
7219 removedBSignalReceived = false;
7221 actorA.Add( child ); // Expect this child to be re-parented
7222 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7223 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7224 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7225 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7231 int utcDaliActorCulled(void)
7233 TestApplication application;
7234 auto stage = Stage::GetCurrent();
7236 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7238 Actor actor = Actor::New();
7239 actor.SetSize( 10.0f, 10.0f );
7241 Geometry geometry = CreateQuadGeometry();
7242 Shader shader = CreateShader();
7243 Renderer renderer = Renderer::New(geometry, shader);
7244 actor.AddRenderer( renderer );
7248 application.SendNotification();
7249 application.Render( 0 );
7251 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
7253 PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
7254 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7256 // Connect NotifySignal
7257 bool propertyNotificationSignal( false );
7258 PropertyNotification source;
7259 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7260 notification.NotifySignal().Connect( &application, f ) ;
7262 actor.SetPosition( 1000.0f, 1000.0f );
7264 application.SendNotification();
7265 application.Render();
7267 application.SendNotification();
7269 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
7271 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7272 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
7273 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );