2 * Copyright (c) 2019 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 UtcDaliActorSetInheritPosition(void)
1558 tet_infoline("Testing Actor::SetInheritPosition");
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.IsPositionInherited(), true, 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 );
1588 //Change child position
1589 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1590 child.SetPosition( childOffset );
1592 // Use local position as world postion
1593 child.SetInheritPosition( false );
1594 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1595 application.SendNotification();
1596 application.Render(0); // should only really call Update as Render is not required to update scene
1597 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1598 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1599 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1600 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1602 //Change back to inherit position from parent
1603 child.SetInheritPosition( true );
1604 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1605 application.SendNotification();
1606 application.Render(0); // should only really call Update as Render is not required to update scene
1607 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1608 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1609 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1610 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1614 int UtcDaliActorInheritOpacity(void)
1616 tet_infoline("Testing Actor::Inherit Opacity");
1617 TestApplication application;
1619 Actor parent = Actor::New();
1620 Actor child = Actor::New();
1621 parent.Add( child );
1622 Stage::GetCurrent().Add( parent );
1624 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1625 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1627 // flush the queue and render once
1628 application.SendNotification();
1629 application.Render();
1631 parent.SetOpacity( 0.1f );
1633 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1634 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1636 application.SendNotification();
1637 application.Render();
1639 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1640 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1641 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1642 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1643 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1644 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1649 // SetOrientation(float angleRadians, Vector3 axis)
1650 int UtcDaliActorSetOrientation01(void)
1652 TestApplication application;
1654 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1655 Actor actor = Actor::New();
1657 actor.SetOrientation(rotation);
1659 // flush the queue and render once
1660 application.SendNotification();
1661 application.Render();
1663 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1667 int UtcDaliActorSetOrientation02(void)
1669 TestApplication application;
1671 Actor actor = Actor::New();
1673 Radian angle( 0.785f );
1674 Vector3 axis(1.0f, 1.0f, 0.0f);
1676 actor.SetOrientation( angle, axis);
1677 Quaternion rotation( angle, axis );
1678 // flush the queue and render once
1679 application.SendNotification();
1680 application.Render();
1681 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1683 Stage::GetCurrent().Add( actor );
1684 actor.RotateBy( Degree( 360 ), axis);
1685 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1687 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1688 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1689 // flush the queue and render once
1690 application.SendNotification();
1691 application.Render();
1692 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1694 actor.SetOrientation( angle, axis);
1695 // flush the queue and render once
1696 application.SendNotification();
1697 application.Render();
1698 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1700 Stage::GetCurrent().Remove( actor );
1704 // SetOrientation(float angleRadians, Vector3 axis)
1705 int UtcDaliActorSetOrientationProperty(void)
1707 TestApplication application;
1709 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1710 Actor actor = Actor::New();
1712 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1713 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1715 // flush the queue and render once
1716 application.SendNotification();
1717 application.Render();
1719 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1720 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1721 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1725 // RotateBy(float angleRadians, Vector3 axis)
1726 int UtcDaliActorRotateBy01(void)
1728 TestApplication application;
1730 Actor actor = Actor::New();
1732 Radian angle( M_PI * 0.25f );
1733 actor.RotateBy(( angle ), Vector3::ZAXIS);
1734 // flush the queue and render once
1735 application.SendNotification();
1736 application.Render();
1737 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1739 Stage::GetCurrent().Add( actor );
1741 actor.RotateBy( angle, Vector3::ZAXIS);
1742 // flush the queue and render once
1743 application.SendNotification();
1744 application.Render();
1745 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1747 Stage::GetCurrent().Remove( actor );
1751 // RotateBy(Quaternion relativeRotation)
1752 int UtcDaliActorRotateBy02(void)
1754 TestApplication application;
1756 Actor actor = Actor::New();
1758 Radian angle( M_PI * 0.25f );
1759 Quaternion rotation(angle, Vector3::ZAXIS);
1760 actor.RotateBy(rotation);
1761 // flush the queue and render once
1762 application.SendNotification();
1763 application.Render();
1764 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1766 actor.RotateBy(rotation);
1767 // flush the queue and render once
1768 application.SendNotification();
1769 application.Render();
1770 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1774 int UtcDaliActorGetCurrentOrientation(void)
1776 TestApplication application;
1777 Actor actor = Actor::New();
1779 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1780 actor.SetOrientation(rotation);
1781 // flush the queue and render once
1782 application.SendNotification();
1783 application.Render();
1784 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1788 int UtcDaliActorGetCurrentWorldOrientation(void)
1790 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1791 TestApplication application;
1793 Actor parent = Actor::New();
1794 Radian rotationAngle( Degree(90.0f) );
1795 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1796 parent.SetOrientation( rotation );
1797 Stage::GetCurrent().Add( parent );
1799 Actor child = Actor::New();
1800 child.SetOrientation( rotation );
1801 parent.Add( child );
1803 // The actors should not have a world rotation yet
1804 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1805 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1807 application.SendNotification();
1808 application.Render(0);
1810 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1811 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1813 // The actors should have a world rotation now
1814 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1815 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1817 // turn off child rotation inheritance
1818 child.SetInheritOrientation( false );
1819 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1820 application.SendNotification();
1821 application.Render(0);
1823 // The actors should have a world rotation now
1824 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1825 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1829 // SetScale(float scale)
1830 int UtcDaliActorSetScale01(void)
1832 TestApplication application;
1834 Actor actor = Actor::New();
1836 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1837 actor.SetScale(0.25f);
1839 Vector3 scale(10.0f, 10.0f, 10.0f);
1840 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1842 actor.SetScale(scale.x);
1844 // flush the queue and render once
1845 application.SendNotification();
1846 application.Render();
1848 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1852 // SetScale(float scaleX, float scaleY, float scaleZ)
1853 int UtcDaliActorSetScale02(void)
1855 TestApplication application;
1856 Vector3 scale(10.0f, 10.0f, 10.0f);
1858 Actor actor = Actor::New();
1860 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1861 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1863 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1865 actor.SetScale(scale.x, scale.y, scale.z);
1866 // flush the queue and render once
1867 application.SendNotification();
1868 application.Render();
1869 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1871 // add to stage and test
1872 Stage::GetCurrent().Add( actor );
1873 actor.SetScale( 2.0f, 2.0f, 2.0f );
1874 // flush the queue and render once
1875 application.SendNotification();
1876 application.Render();
1877 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1879 Stage::GetCurrent().Remove( actor );
1884 // SetScale(Vector3 scale)
1885 int UtcDaliActorSetScale03(void)
1887 TestApplication application;
1888 Vector3 scale(10.0f, 10.0f, 10.0f);
1890 Actor actor = Actor::New();
1892 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1893 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1895 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1897 actor.SetScale(scale);
1899 // flush the queue and render once
1900 application.SendNotification();
1901 application.Render();
1903 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1907 int UtcDaliActorSetScaleIndividual(void)
1909 TestApplication application;
1911 Actor actor = Actor::New();
1913 Vector3 vector(0.7f, 0.8f, 0.9f);
1914 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1916 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1917 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1919 // flush the queue and render once
1920 application.SendNotification();
1921 application.Render();
1923 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1924 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1925 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1927 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1928 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1930 // flush the queue and render once
1931 application.SendNotification();
1932 application.Render();
1934 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1935 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1936 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1938 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1939 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1941 // flush the queue and render once
1942 application.SendNotification();
1943 application.Render();
1945 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1946 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1947 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1949 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1950 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1955 int UtcDaliActorScaleBy(void)
1957 TestApplication application;
1958 Actor actor = Actor::New();
1959 Vector3 vector(100.0f, 100.0f, 100.0f);
1961 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1963 actor.SetScale(vector);
1965 // flush the queue and render once
1966 application.SendNotification();
1967 application.Render();
1969 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1971 actor.ScaleBy(vector);
1973 // flush the queue and render once
1974 application.SendNotification();
1975 application.Render();
1977 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1981 int UtcDaliActorGetCurrentScale(void)
1983 TestApplication application;
1984 Vector3 scale(12.0f, 1.0f, 2.0f);
1986 Actor actor = Actor::New();
1988 actor.SetScale(scale);
1990 // flush the queue and render once
1991 application.SendNotification();
1992 application.Render();
1994 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1998 int UtcDaliActorGetCurrentWorldScale(void)
2000 TestApplication application;
2002 Actor parent = Actor::New();
2003 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2004 parent.SetScale( parentScale );
2005 Stage::GetCurrent().Add( parent );
2007 Actor child = Actor::New();
2008 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2009 child.SetScale( childScale );
2010 parent.Add( child );
2012 // The actors should not have a scale yet
2013 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2014 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2016 // The actors should not have a world scale yet
2017 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2018 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2020 application.SendNotification();
2021 application.Render(0);
2023 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2024 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2026 // The actors should have a world scale now
2027 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2028 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2032 int UtcDaliActorInheritScale(void)
2034 tet_infoline("Testing Actor::SetInheritScale");
2035 TestApplication application;
2037 Actor parent = Actor::New();
2038 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2039 parent.SetScale( parentScale );
2040 Stage::GetCurrent().Add( parent );
2042 Actor child = Actor::New();
2043 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2044 child.SetScale( childScale );
2045 parent.Add( child );
2047 application.SendNotification();
2048 application.Render(0);
2050 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2051 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2053 child.SetInheritScale( false );
2054 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2056 application.SendNotification();
2057 application.Render(0);
2059 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2063 int UtcDaliActorSetVisible(void)
2065 TestApplication application;
2067 Actor actor = Actor::New();
2068 actor.SetVisible(false);
2069 // flush the queue and render once
2070 application.SendNotification();
2071 application.Render();
2072 DALI_TEST_CHECK(actor.IsVisible() == false);
2074 actor.SetVisible(true);
2075 // flush the queue and render once
2076 application.SendNotification();
2077 application.Render();
2078 DALI_TEST_CHECK(actor.IsVisible() == true);
2080 // put actor on stage
2081 Stage::GetCurrent().Add( actor );
2082 actor.SetVisible(false);
2083 // flush the queue and render once
2084 application.SendNotification();
2085 application.Render();
2086 DALI_TEST_CHECK(actor.IsVisible() == false);
2090 int UtcDaliActorIsVisible(void)
2092 TestApplication application;
2094 Actor actor = Actor::New();
2096 DALI_TEST_CHECK(actor.IsVisible() == true);
2100 int UtcDaliActorSetOpacity(void)
2102 TestApplication application;
2104 Actor actor = Actor::New();
2105 // initial opacity is 1
2106 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2108 actor.SetOpacity( 0.4f);
2109 // flush the queue and render once
2110 application.SendNotification();
2111 application.Render();
2112 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2114 // change opacity, actor is on stage to change is not immediate
2115 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2116 // flush the queue and render once
2117 application.SendNotification();
2118 application.Render();
2119 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2121 // put actor on stage
2122 Stage::GetCurrent().Add( actor );
2124 // change opacity, actor is on stage to change is not immediate
2125 actor.SetOpacity( 0.9f );
2126 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2127 // flush the queue and render once
2128 application.SendNotification();
2129 application.Render();
2130 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2132 // change opacity, actor is on stage to change is not immediate
2133 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2134 // flush the queue and render once
2135 application.SendNotification();
2136 application.Render();
2137 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2141 int UtcDaliActorGetCurrentOpacity(void)
2143 TestApplication application;
2145 Actor actor = Actor::New();
2146 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2148 actor.SetOpacity(0.5f);
2149 // flush the queue and render once
2150 application.SendNotification();
2151 application.Render();
2152 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2156 int UtcDaliActorSetSensitive(void)
2158 TestApplication application;
2159 Actor actor = Actor::New();
2161 bool sensitive = !actor.IsSensitive();
2163 actor.SetSensitive(sensitive);
2165 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2169 int UtcDaliActorIsSensitive(void)
2171 TestApplication application;
2172 Actor actor = Actor::New();
2173 actor.SetSensitive(false);
2175 DALI_TEST_CHECK(false == actor.IsSensitive());
2179 int UtcDaliActorSetColor(void)
2181 TestApplication application;
2182 Actor actor = Actor::New();
2183 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2185 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2187 actor.SetColor(color);
2188 // flush the queue and render once
2189 application.SendNotification();
2190 application.Render();
2191 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2193 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2194 // flush the queue and render once
2195 application.SendNotification();
2196 application.Render();
2197 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2199 Stage::GetCurrent().Add( actor );
2200 actor.SetColor( color );
2201 // flush the queue and render once
2202 application.SendNotification();
2203 application.Render();
2204 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2206 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2207 // flush the queue and render once
2208 application.SendNotification();
2209 application.Render();
2210 // Actor color is not clamped
2211 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2212 // world color is clamped
2213 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2215 Stage::GetCurrent().Remove( actor );
2219 int UtcDaliActorSetColorIndividual(void)
2221 TestApplication application;
2223 Actor actor = Actor::New();
2225 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2226 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2228 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2229 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2231 // flush the queue and render once
2232 application.SendNotification();
2233 application.Render();
2235 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2236 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2237 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2239 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2240 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2242 // flush the queue and render once
2243 application.SendNotification();
2244 application.Render();
2246 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2247 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2248 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2250 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2251 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2253 // flush the queue and render once
2254 application.SendNotification();
2255 application.Render();
2257 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2258 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2259 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2262 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2263 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2265 // flush the queue and render once
2266 application.SendNotification();
2267 application.Render();
2269 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2270 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2271 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2273 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2274 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2276 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2279 // flush the queue and render once
2280 application.SendNotification();
2281 application.Render();
2283 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2289 int UtcDaliActorGetCurrentColor(void)
2291 TestApplication application;
2292 Actor actor = Actor::New();
2293 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2295 actor.SetColor(color);
2296 // flush the queue and render once
2297 application.SendNotification();
2298 application.Render();
2299 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2303 int UtcDaliActorGetCurrentWorldColor(void)
2305 tet_infoline("Actor::GetCurrentWorldColor");
2306 TestApplication application;
2308 Actor parent = Actor::New();
2309 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2310 parent.SetColor( parentColor );
2311 Stage::GetCurrent().Add( parent );
2313 Actor child = Actor::New();
2314 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2315 child.SetColor( childColor );
2316 parent.Add( child );
2318 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2319 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2321 // verify the default color mode
2322 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2324 // The actors should not have a world color yet
2325 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2326 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2328 application.SendNotification();
2329 application.Render(0);
2331 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2332 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2334 // The actors should have a world color now
2335 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2336 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2339 child.SetColorMode( USE_OWN_COLOR );
2340 application.SendNotification();
2341 application.Render(0);
2342 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2345 child.SetColorMode( USE_PARENT_COLOR );
2346 application.SendNotification();
2347 application.Render(0);
2348 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2349 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2352 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2353 application.SendNotification();
2354 application.Render(0);
2355 Vector4 expectedColor( childColor );
2356 expectedColor.a *= parentColor.a;
2357 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2358 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2362 int UtcDaliActorSetColorMode(void)
2364 tet_infoline("Actor::SetColorMode");
2365 TestApplication application;
2366 Actor actor = Actor::New();
2367 Actor child = Actor::New();
2370 actor.SetColorMode( USE_OWN_COLOR );
2371 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2373 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2374 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2376 actor.SetColorMode( USE_PARENT_COLOR );
2377 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2379 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2380 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2384 int UtcDaliActorScreenToLocal(void)
2386 TestApplication application;
2387 Actor actor = Actor::New();
2388 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2389 actor.SetSize(100.0f, 100.0f);
2390 actor.SetPosition(10.0f, 10.0f);
2391 Stage::GetCurrent().Add(actor);
2393 // flush the queue and render once
2394 application.SendNotification();
2395 application.Render();
2400 application.SendNotification();
2401 application.Render();
2403 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2405 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2406 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2410 int UtcDaliActorSetLeaveRequired(void)
2412 TestApplication application;
2414 Actor actor = Actor::New();
2416 actor.SetLeaveRequired(false);
2417 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2419 actor.SetLeaveRequired(true);
2420 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2424 int UtcDaliActorGetLeaveRequired(void)
2426 TestApplication application;
2428 Actor actor = Actor::New();
2430 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2434 int UtcDaliActorSetKeyboardFocusable(void)
2436 TestApplication application;
2438 Actor actor = Actor::New();
2440 actor.SetKeyboardFocusable(true);
2441 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2443 actor.SetKeyboardFocusable(false);
2444 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2448 int UtcDaliActorIsKeyboardFocusable(void)
2450 TestApplication application;
2452 Actor actor = Actor::New();
2454 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2458 int UtcDaliActorRemoveConstraints(void)
2460 tet_infoline(" UtcDaliActorRemoveConstraints");
2461 TestApplication application;
2463 gTestConstraintCalled = false;
2465 Actor actor = Actor::New();
2467 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2469 actor.RemoveConstraints();
2471 DALI_TEST_CHECK( gTestConstraintCalled == false );
2473 Stage::GetCurrent().Add( actor );
2476 // flush the queue and render once
2477 application.SendNotification();
2478 application.Render();
2480 actor.RemoveConstraints();
2482 DALI_TEST_CHECK( gTestConstraintCalled == true );
2486 int UtcDaliActorRemoveConstraintTag(void)
2488 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2489 TestApplication application;
2491 Actor actor = Actor::New();
2493 // 1. Apply Constraint1 and Constraint2, and test...
2494 unsigned int result1 = 0u;
2495 unsigned int result2 = 0u;
2497 unsigned constraint1Tag = 1u;
2498 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2499 constraint1.SetTag( constraint1Tag );
2500 constraint1.Apply();
2502 unsigned constraint2Tag = 2u;
2503 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2504 constraint2.SetTag( constraint2Tag );
2505 constraint2.Apply();
2507 Stage::GetCurrent().Add( actor );
2508 // flush the queue and render once
2509 application.SendNotification();
2510 application.Render();
2512 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2513 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2515 // 2. Remove Constraint1 and test...
2518 actor.RemoveConstraints(constraint1Tag);
2519 // make color property dirty, which will trigger constraints to be reapplied.
2520 actor.SetColor( Color::WHITE );
2521 // flush the queue and render once
2522 application.SendNotification();
2523 application.Render();
2525 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2526 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2528 // 3. Re-Apply Constraint1 and test...
2531 constraint1.Apply();
2532 // make color property dirty, which will trigger constraints to be reapplied.
2533 actor.SetColor( Color::WHITE );
2534 // flush the queue and render once
2535 application.SendNotification();
2536 application.Render();
2538 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2539 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2541 // 2. Remove Constraint2 and test...
2544 actor.RemoveConstraints(constraint2Tag);
2545 // make color property dirty, which will trigger constraints to be reapplied.
2546 actor.SetColor( Color::WHITE );
2547 // flush the queue and render once
2548 application.SendNotification();
2549 application.Render();
2551 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2552 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2554 // 2. Remove Constraint1 as well and test...
2557 actor.RemoveConstraints(constraint1Tag);
2558 // make color property dirty, which will trigger constraints to be reapplied.
2559 actor.SetColor( Color::WHITE );
2560 // flush the queue and render once
2561 application.SendNotification();
2562 application.Render();
2564 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2565 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2569 int UtcDaliActorTouchedSignal(void)
2571 TestApplication application;
2573 ResetTouchCallbacks();
2575 // get the root layer
2576 Actor actor = Stage::GetCurrent().GetRootLayer();
2577 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2579 application.SendNotification();
2580 application.Render();
2582 // connect to its touch signal
2583 actor.TouchedSignal().Connect( TestCallback );
2585 // simulate a touch event in the middle of the screen
2586 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2587 Dali::Integration::Point point;
2588 point.SetDeviceId( 1 );
2589 point.SetState( PointState::DOWN );
2590 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2591 Dali::Integration::TouchEvent touchEvent;
2592 touchEvent.AddPoint( point );
2593 application.ProcessEvent( touchEvent );
2595 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2599 int UtcDaliActorHoveredSignal(void)
2601 TestApplication application;
2603 gHoverCallBackCalled = false;
2605 // get the root layer
2606 Actor actor = Stage::GetCurrent().GetRootLayer();
2607 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2609 application.SendNotification();
2610 application.Render();
2612 // connect to its hover signal
2613 actor.HoveredSignal().Connect( TestCallback3 );
2615 // simulate a hover event in the middle of the screen
2616 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2617 Dali::Integration::Point point;
2618 point.SetDeviceId( 1 );
2619 point.SetState( PointState::MOTION );
2620 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2621 Dali::Integration::HoverEvent hoverEvent;
2622 hoverEvent.AddPoint( point );
2623 application.ProcessEvent( hoverEvent );
2625 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2629 int UtcDaliActorOnOffStageSignal(void)
2631 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2633 TestApplication application;
2636 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2637 gActorNamesOnOffStage.clear();
2639 Actor parent = Actor::New();
2640 parent.SetName( "parent" );
2641 parent.OnStageSignal().Connect( OnStageCallback );
2642 parent.OffStageSignal().Connect( OffStageCallback );
2644 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2645 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2647 // add parent to stage
2648 Stage::GetCurrent().Add( parent );
2649 // onstage emitted, offstage not
2650 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2651 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2652 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2654 // test adding a child, should get onstage emitted
2656 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2657 gActorNamesOnOffStage.clear();
2659 Actor child = Actor::New();
2660 child.SetName( "child" );
2661 child.OnStageSignal().Connect( OnStageCallback );
2662 child.OffStageSignal().Connect( OffStageCallback );
2663 parent.Add( child ); // add child
2664 // onstage emitted, offstage not
2665 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2666 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2667 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2669 // test removing parent from stage
2671 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2672 gActorNamesOnOffStage.clear();
2674 Stage::GetCurrent().Remove( parent );
2675 // onstage not emitted, offstage is
2676 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2677 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2678 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2679 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2681 // test adding parent back to stage
2683 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2684 gActorNamesOnOffStage.clear();
2686 Stage::GetCurrent().Add( parent );
2687 // onstage emitted, offstage not
2688 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2689 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2690 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2691 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2693 // test removing child
2695 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2696 gActorNamesOnOffStage.clear();
2698 parent.Remove( child );
2699 // onstage not emitted, offstage is
2700 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2701 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2702 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2704 // test removing parent
2706 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2707 gActorNamesOnOffStage.clear();
2709 Stage::GetCurrent().Remove( parent );
2710 // onstage not emitted, offstage is
2711 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2712 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2713 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2717 int UtcDaliActorFindChildByName(void)
2719 tet_infoline("Testing Dali::Actor::FindChildByName()");
2720 TestApplication application;
2722 Actor parent = Actor::New();
2723 parent.SetName( "parent" );
2724 Actor first = Actor::New();
2725 first .SetName( "first" );
2726 Actor second = Actor::New();
2727 second.SetName( "second" );
2732 Actor found = parent.FindChildByName( "foo" );
2733 DALI_TEST_CHECK( !found );
2735 found = parent.FindChildByName( "parent" );
2736 DALI_TEST_CHECK( found == parent );
2738 found = parent.FindChildByName( "first" );
2739 DALI_TEST_CHECK( found == first );
2741 found = parent.FindChildByName( "second" );
2742 DALI_TEST_CHECK( found == second );
2746 int UtcDaliActorFindChildById(void)
2748 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2749 TestApplication application;
2751 Actor parent = Actor::New();
2752 Actor first = Actor::New();
2753 Actor second = Actor::New();
2758 Actor found = parent.FindChildById( 100000 );
2759 DALI_TEST_CHECK( !found );
2761 found = parent.FindChildById( parent.GetId() );
2762 DALI_TEST_CHECK( found == parent );
2764 found = parent.FindChildById( first.GetId() );
2765 DALI_TEST_CHECK( found == first );
2767 found = parent.FindChildById( second.GetId() );
2768 DALI_TEST_CHECK( found == second );
2772 int UtcDaliActorHitTest(void)
2777 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2779 mTouchPoint( touchPoint ),
2784 Vector2 mTouchPoint;
2788 TestApplication application;
2789 tet_infoline(" UtcDaliActorHitTest");
2791 // Fill a vector with different hit tests.
2792 struct HitTestData* hitTestData[] = {
2793 // scale touch point result
2794 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2795 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2796 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.
2797 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2798 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.
2802 // get the root layer
2803 Actor actor = Actor::New();
2804 actor.SetAnchorPoint( AnchorPoint::CENTER );
2805 actor.SetParentOrigin( ParentOrigin::CENTER );
2807 Stage::GetCurrent().Add( actor );
2809 ResetTouchCallbacks();
2811 unsigned int index = 0;
2812 while( NULL != hitTestData[index] )
2814 actor.SetSize( 1.f, 1.f );
2815 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2817 // flush the queue and render once
2818 application.SendNotification();
2819 application.Render();
2821 DALI_TEST_CHECK( !gTouchCallBackCalled );
2823 // connect to its touch signal
2824 actor.TouchedSignal().Connect(TestCallback);
2826 Dali::Integration::Point point;
2827 point.SetState( PointState::DOWN );
2828 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2829 Dali::Integration::TouchEvent event;
2830 event.AddPoint( point );
2832 // flush the queue and render once
2833 application.SendNotification();
2834 application.Render();
2835 application.ProcessEvent( event );
2837 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2839 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2840 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2841 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2842 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2843 hitTestData[index]->mResult );
2845 ResetTouchCallbacks();
2851 int UtcDaliActorSetDrawMode(void)
2853 TestApplication app;
2854 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2856 Actor a = Actor::New();
2858 Stage::GetCurrent().Add(a);
2859 app.SendNotification();
2861 app.SendNotification();
2864 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2866 a.SetDrawMode( DrawMode::OVERLAY_2D );
2867 app.SendNotification();
2870 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2872 a.SetDrawMode( DrawMode::NORMAL );
2873 app.SendNotification();
2876 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2880 int UtcDaliActorSetDrawModeOverlayRender(void)
2882 TestApplication app;
2883 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2885 app.SendNotification();
2888 std::vector<GLuint> ids;
2889 ids.push_back( 8 ); // first rendered actor
2890 ids.push_back( 9 ); // second rendered actor
2891 ids.push_back( 10 ); // third rendered actor
2892 app.GetGlAbstraction().SetNextTextureIds( ids );
2894 BufferImage imageA = BufferImage::New(16, 16);
2895 BufferImage imageB = BufferImage::New(16, 16);
2896 BufferImage imageC = BufferImage::New(16, 16);
2897 Actor a = CreateRenderableActor( imageA );
2898 Actor b = CreateRenderableActor( imageB );
2899 Actor c = CreateRenderableActor( imageC );
2901 app.SendNotification();
2904 //Textures are bound when first created. Clear bound textures vector
2905 app.GetGlAbstraction().ClearBoundTextures();
2907 // Render a,b,c as regular non-overlays. so order will be:
2911 Stage::GetCurrent().Add(a);
2912 Stage::GetCurrent().Add(b);
2913 Stage::GetCurrent().Add(c);
2915 app.SendNotification();
2918 // Should be 3 textures changes.
2919 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2920 typedef std::vector<GLuint>::size_type TextureSize;
2921 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2922 if( boundTextures.size() == 3 )
2924 DALI_TEST_CHECK( boundTextures[0] == 8u );
2925 DALI_TEST_CHECK( boundTextures[1] == 9u );
2926 DALI_TEST_CHECK( boundTextures[2] == 10u );
2929 // Now texture ids have been set, we can monitor their render order.
2930 // render a as an overlay (last), so order will be:
2934 a.SetDrawMode( DrawMode::OVERLAY_2D );
2935 app.GetGlAbstraction().ClearBoundTextures();
2937 app.SendNotification();
2940 // Should be 3 texture changes.
2941 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2942 if( boundTextures.size() == 3 )
2944 DALI_TEST_CHECK( boundTextures[0] == 9u );
2945 DALI_TEST_CHECK( boundTextures[1] == 10u );
2946 DALI_TEST_CHECK( boundTextures[2] == 8u );
2951 int UtcDaliActorGetCurrentWorldMatrix(void)
2953 TestApplication app;
2954 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2956 Actor parent = Actor::New();
2957 parent.SetParentOrigin(ParentOrigin::CENTER);
2958 parent.SetAnchorPoint(AnchorPoint::CENTER);
2959 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2960 Radian rotationAngle(Degree(85.0f));
2961 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2962 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2963 parent.SetPosition( parentPosition );
2964 parent.SetOrientation( parentRotation );
2965 parent.SetScale( parentScale );
2966 Stage::GetCurrent().Add( parent );
2968 Actor child = Actor::New();
2969 child.SetParentOrigin(ParentOrigin::CENTER);
2970 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2971 Radian childRotationAngle(Degree(23.0f));
2972 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2973 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2974 child.SetPosition( childPosition );
2975 child.SetOrientation( childRotation );
2976 child.SetScale( childScale );
2977 parent.Add( child );
2979 app.SendNotification();
2982 app.SendNotification();
2984 Matrix parentMatrix(false);
2985 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2987 Matrix childMatrix(false);
2988 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2990 //Child matrix should be the composition of child and parent
2991 Matrix childWorldMatrix(false);
2992 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2994 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2995 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
3001 int UtcDaliActorConstrainedToWorldMatrix(void)
3003 TestApplication app;
3004 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3006 Actor parent = Actor::New();
3007 parent.SetParentOrigin(ParentOrigin::CENTER);
3008 parent.SetAnchorPoint(AnchorPoint::CENTER);
3009 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3010 Radian rotationAngle(Degree(85.0f));
3011 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3012 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3013 parent.SetPosition( parentPosition );
3014 parent.SetOrientation( parentRotation );
3015 parent.SetScale( parentScale );
3016 Stage::GetCurrent().Add( parent );
3018 Actor child = Actor::New();
3019 child.SetParentOrigin(ParentOrigin::CENTER);
3020 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3021 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3022 posConstraint.Apply();
3024 Stage::GetCurrent().Add( child );
3026 app.SendNotification();
3029 app.SendNotification();
3031 Matrix parentMatrix(false);
3032 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3034 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3035 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3039 int UtcDaliActorConstrainedToOrientation(void)
3041 TestApplication app;
3042 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3044 Actor parent = Actor::New();
3045 parent.SetParentOrigin(ParentOrigin::CENTER);
3046 parent.SetAnchorPoint(AnchorPoint::CENTER);
3047 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3048 Radian rotationAngle(Degree(85.0f));
3049 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3050 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3051 parent.SetPosition( parentPosition );
3052 parent.SetOrientation( parentRotation );
3053 parent.SetScale( parentScale );
3054 Stage::GetCurrent().Add( parent );
3056 Actor child = Actor::New();
3057 child.SetParentOrigin(ParentOrigin::CENTER);
3058 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3059 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3060 posConstraint.Apply();
3062 Stage::GetCurrent().Add( child );
3064 app.SendNotification();
3067 app.SendNotification();
3069 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3073 int UtcDaliActorConstrainedToOpacity(void)
3075 TestApplication app;
3076 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3078 Actor parent = Actor::New();
3079 parent.SetOpacity( 0.7f );
3080 Stage::GetCurrent().Add( parent );
3082 Actor child = Actor::New();
3083 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3084 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3085 opacityConstraint.Apply();
3087 Stage::GetCurrent().Add( child );
3089 app.SendNotification();
3092 app.SendNotification();
3094 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3096 parent.SetOpacity( 0.3f );
3098 app.SendNotification();
3101 app.SendNotification();
3103 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3108 int UtcDaliActorUnparent(void)
3110 TestApplication app;
3111 tet_infoline(" UtcDaliActorUnparent");
3113 Actor parent = Actor::New();
3114 Stage::GetCurrent().Add( parent );
3116 Actor child = Actor::New();
3118 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3119 DALI_TEST_CHECK( !child.GetParent() );
3121 // Test that calling Unparent with no parent is a NOOP
3124 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3125 DALI_TEST_CHECK( !child.GetParent() );
3127 // Test that Unparent works
3128 parent.Add( child );
3130 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3131 DALI_TEST_CHECK( parent == child.GetParent() );
3135 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3136 DALI_TEST_CHECK( !child.GetParent() );
3138 // Test that UnparentAndReset works
3139 parent.Add( child );
3141 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3142 DALI_TEST_CHECK( parent == child.GetParent() );
3144 UnparentAndReset( child );
3146 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3147 DALI_TEST_CHECK( !child );
3149 // Test that UnparentAndReset is a NOOP with empty handle
3150 UnparentAndReset( child );
3152 DALI_TEST_CHECK( !child );
3156 int UtcDaliActorGetChildAt(void)
3158 TestApplication app;
3159 tet_infoline(" UtcDaliActorGetChildAt");
3161 Actor parent = Actor::New();
3162 Stage::GetCurrent().Add( parent );
3164 Actor child0 = Actor::New();
3165 parent.Add( child0 );
3167 Actor child1 = Actor::New();
3168 parent.Add( child1 );
3170 Actor child2 = Actor::New();
3171 parent.Add( child2 );
3173 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3174 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3175 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3179 int UtcDaliActorSetGetOverlay(void)
3181 TestApplication app;
3182 tet_infoline(" UtcDaliActorSetGetOverlay");
3184 Actor parent = Actor::New();
3185 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3186 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3191 int UtcDaliActorCreateDestroy(void)
3193 Actor* actor = new Actor;
3194 DALI_TEST_CHECK( actor );
3201 struct PropertyStringIndex
3203 const char * const name;
3204 const Property::Index index;
3205 const Property::Type type;
3208 const PropertyStringIndex PROPERTY_TABLE[] =
3210 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3211 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3212 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3213 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3214 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3215 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3216 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3217 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3218 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3219 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3220 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3221 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3222 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3223 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3224 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3225 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3226 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3227 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3228 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3229 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3230 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3231 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3232 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3233 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3234 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3235 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3236 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3237 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3238 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3239 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3240 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3241 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3242 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3243 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3244 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3245 { "name", Actor::Property::NAME, Property::STRING },
3246 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3247 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3248 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3249 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3250 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3251 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3252 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3253 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3254 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3255 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3256 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3257 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3258 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3259 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3260 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3261 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3262 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3263 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3265 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3266 } // unnamed namespace
3268 int UtcDaliActorProperties(void)
3270 TestApplication app;
3272 Actor actor = Actor::New();
3274 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3276 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3277 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3278 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3279 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3284 int UtcDaliRelayoutProperties_ResizePolicies(void)
3286 TestApplication app;
3288 Actor actor = Actor::New();
3291 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3292 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3294 // Set resize policy for all dimensions
3295 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3296 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3298 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3301 // Set individual dimensions
3302 const char* const widthPolicy = "FILL_TO_PARENT";
3303 const char* const heightPolicy = "FIXED";
3305 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3306 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3308 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3309 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3311 // Set individual dimensions using enums
3312 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3313 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3315 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3316 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3318 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3319 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3324 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3326 TestApplication app;
3328 Actor actor = Actor::New();
3331 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3332 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3334 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3335 actor.SetSizeScalePolicy( policy );
3336 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3339 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3340 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3342 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3343 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3345 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3346 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3351 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3353 TestApplication app;
3355 Actor actor = Actor::New();
3358 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3359 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3361 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3362 actor.SetSizeModeFactor( sizeMode );
3363 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3366 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3368 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3369 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3374 int UtcDaliRelayoutProperties_DimensionDependency(void)
3376 TestApplication app;
3378 Actor actor = Actor::New();
3381 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3382 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3385 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3386 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3388 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3389 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3391 // Test setting another resize policy
3392 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3393 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3398 int UtcDaliRelayoutProperties_Padding(void)
3400 TestApplication app;
3402 Actor actor = Actor::New();
3405 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3408 actor.SetProperty( Actor::Property::PADDING, padding );
3409 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3411 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3416 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3418 TestApplication app;
3420 Actor actor = Actor::New();
3423 Vector2 minSize( 1.0f, 2.0f );
3425 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3426 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3428 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3430 Vector2 maxSize( 3.0f, 4.0f );
3432 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3433 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3435 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3440 int UtcDaliActorGetHeightForWidth(void)
3442 TestApplication app;
3444 Actor actor = Actor::New();
3446 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3451 int UtcDaliActorGetWidthForHeight(void)
3453 TestApplication app;
3455 Actor actor = Actor::New();
3457 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3462 int UtcDaliActorGetRelayoutSize(void)
3464 TestApplication app;
3466 Actor actor = Actor::New();
3468 // Add actor to stage
3469 Stage::GetCurrent().Add( actor );
3471 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3473 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3474 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3476 // Flush the queue and render once
3477 app.SendNotification();
3480 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3485 int UtcDaliActorSetPadding(void)
3487 TestApplication app;
3489 Actor actor = Actor::New();
3492 actor.GetPadding( padding );
3494 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3495 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3496 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3497 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3499 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3500 actor.SetPadding( padding2 );
3502 actor.GetPadding( padding );
3504 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3505 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3506 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3507 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3512 int UtcDaliActorSetMinimumSize(void)
3514 TestApplication app;
3516 Actor actor = Actor::New();
3518 Vector2 size = actor.GetMinimumSize();
3520 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3521 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3523 Vector2 size2( 1.0f, 2.0f );
3524 actor.SetMinimumSize( size2 );
3526 size = actor.GetMinimumSize();
3528 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3529 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3534 int UtcDaliActorSetMaximumSize(void)
3536 TestApplication app;
3538 Actor actor = Actor::New();
3540 Vector2 size = actor.GetMaximumSize();
3542 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3543 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3545 Vector2 size2( 1.0f, 2.0f );
3546 actor.SetMaximumSize( size2 );
3548 size = actor.GetMaximumSize();
3550 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3551 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3556 int UtcDaliActorOnRelayoutSignal(void)
3558 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3560 TestApplication application;
3563 gOnRelayoutCallBackCalled = false;
3564 gActorNamesRelayout.clear();
3566 Actor actor = Actor::New();
3567 actor.SetName( "actor" );
3568 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3571 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3573 // Add actor to stage
3574 Stage::GetCurrent().Add( actor );
3576 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3577 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3579 // Flush the queue and render once
3580 application.SendNotification();
3581 application.Render();
3583 // OnRelayout emitted
3584 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3585 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3590 int UtcDaliActorGetHierachyDepth(void)
3592 TestApplication application;
3593 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3596 /* Build tree of actors:
3606 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3608 Stage stage( Stage::GetCurrent() );
3610 Actor actorA = Actor::New();
3611 Actor actorB = Actor::New();
3612 Actor actorC = Actor::New();
3613 Actor actorD = Actor::New();
3614 Actor actorE = Actor::New();
3615 Actor actorF = Actor::New();
3617 //Test that root actor has depth equal 0
3618 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3620 //Test actors return depth -1 when not connected to the tree
3621 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3622 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3623 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3624 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3625 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3626 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3628 //Create the hierarchy
3629 stage.Add( actorA );
3630 actorA.Add( actorB );
3631 actorA.Add( actorC );
3632 actorB.Add( actorD );
3633 actorB.Add( actorE );
3634 actorC.Add( actorF );
3636 //Test actors return correct depth
3637 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3638 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3639 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3640 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3641 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3642 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3644 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3645 actorA.Remove( actorB );
3647 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3648 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3649 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3651 //Removing actorA from the stage. All actors should have depth equal -1
3652 stage.Remove( actorA );
3654 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3655 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3656 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3657 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3658 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3659 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3664 int UtcDaliActorAnchorPointPropertyAsString(void)
3666 TestApplication application;
3668 Actor actor = Actor::New();
3670 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3671 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3673 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3674 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3676 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3677 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3679 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3680 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3682 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3683 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3685 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3686 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3688 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3689 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3691 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3692 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3694 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3695 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3697 // Invalid should not change anything
3698 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3699 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3704 int UtcDaliActorParentOriginPropertyAsString(void)
3706 TestApplication application;
3708 Actor actor = Actor::New();
3710 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3711 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3713 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3714 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3716 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3717 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3719 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3720 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3722 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3723 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3725 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3726 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3728 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3729 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3731 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3732 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3734 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3735 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3737 // Invalid should not change anything
3738 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3739 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3744 int UtcDaliActorColorModePropertyAsString(void)
3746 TestApplication application;
3748 Actor actor = Actor::New();
3750 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3751 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3753 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3754 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3756 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3757 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3759 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3760 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3762 // Invalid should not change anything
3763 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3764 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3769 int UtcDaliActorDrawModePropertyAsString(void)
3771 TestApplication application;
3773 Actor actor = Actor::New();
3775 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3776 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3778 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3779 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3781 // Invalid should not change anything
3782 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3783 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3788 int UtcDaliActorColorModePropertyAsEnum(void)
3790 TestApplication application;
3792 Actor actor = Actor::New();
3794 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3795 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3797 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3798 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3800 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3801 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3803 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3804 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3809 int UtcDaliActorDrawModePropertyAsEnum(void)
3811 TestApplication application;
3813 Actor actor = Actor::New();
3815 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3816 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3818 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3819 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3824 int UtcDaliActorAddRendererP(void)
3826 tet_infoline("Testing Actor::AddRenderer");
3827 TestApplication application;
3829 Actor actor = Actor::New();
3831 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3833 Geometry geometry = CreateQuadGeometry();
3834 Shader shader = CreateShader();
3835 Renderer renderer = Renderer::New(geometry, shader);
3837 actor.AddRenderer( renderer );
3838 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3839 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3844 int UtcDaliActorAddRendererN(void)
3846 tet_infoline("Testing Actor::AddRenderer");
3847 TestApplication application;
3849 Actor actor = Actor::New();
3855 actor.AddRenderer( renderer );
3856 tet_printf("Assertion test failed - no Exception\n" );
3857 tet_result(TET_FAIL);
3859 catch(Dali::DaliException& e)
3861 DALI_TEST_PRINT_ASSERT( e );
3862 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3863 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3867 tet_printf("Assertion test failed - wrong Exception\n" );
3868 tet_result(TET_FAIL);
3874 int UtcDaliActorAddRendererOnStage(void)
3876 tet_infoline("Testing Actor::AddRenderer");
3877 TestApplication application;
3879 Actor actor = Actor::New();
3880 Stage::GetCurrent().Add(actor);
3882 application.SendNotification();
3883 application.Render(0);
3885 Geometry geometry = CreateQuadGeometry();
3886 Shader shader = CreateShader();
3887 Renderer renderer = Renderer::New(geometry, shader);
3889 application.SendNotification();
3890 application.Render(0);
3894 actor.AddRenderer( renderer );
3895 tet_result(TET_PASS);
3899 tet_result(TET_FAIL);
3905 int UtcDaliActorRemoveRendererP1(void)
3907 tet_infoline("Testing Actor::RemoveRenderer");
3908 TestApplication application;
3910 Actor actor = Actor::New();
3912 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3915 Geometry geometry = CreateQuadGeometry();
3916 Shader shader = CreateShader();
3917 Renderer renderer = Renderer::New(geometry, shader);
3919 actor.AddRenderer( renderer );
3920 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3921 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3923 application.SendNotification();
3924 application.Render();
3928 Renderer renderer = actor.GetRendererAt(0);
3929 actor.RemoveRenderer(renderer);
3930 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3932 application.SendNotification();
3933 application.Render();
3936 // Call one final time to ensure that the renderer is actually removed after
3937 // the handle goes out of scope, and excercises the deletion code path in
3938 // scene graph and render.
3939 application.SendNotification();
3940 application.Render();
3945 int UtcDaliActorRemoveRendererP2(void)
3947 tet_infoline("Testing Actor::RemoveRenderer");
3948 TestApplication application;
3950 Actor actor = Actor::New();
3952 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3954 Geometry geometry = CreateQuadGeometry();
3955 Shader shader = CreateShader();
3956 Renderer renderer = Renderer::New(geometry, shader);
3958 actor.AddRenderer( renderer );
3959 application.SendNotification();
3960 application.Render();
3962 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3963 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3965 actor.RemoveRenderer(0);
3966 application.SendNotification();
3967 application.Render();
3969 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3971 // Shut down whilst holding onto the renderer handle.
3976 int UtcDaliActorRemoveRendererN(void)
3978 tet_infoline("Testing Actor::RemoveRenderer");
3979 TestApplication application;
3981 Actor actor = Actor::New();
3983 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3985 Geometry geometry = CreateQuadGeometry();
3986 Shader shader = CreateShader();
3987 Renderer renderer = Renderer::New(geometry, shader);
3989 actor.AddRenderer( renderer );
3990 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3991 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3993 actor.RemoveRenderer(10);
3994 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3995 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4000 // Clipping test helper functions:
4001 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4003 BufferImage image = BufferImage::New( width, height );
4004 Actor actor = CreateRenderableActor( image );
4006 // Setup dimensions and position so actor is not skipped by culling.
4007 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4008 actor.SetSize( width, height );
4009 actor.SetParentOrigin( ParentOrigin::CENTER );
4010 actor.SetAnchorPoint( AnchorPoint::CENTER );
4015 Actor CreateActorWithContent16x16()
4017 return CreateActorWithContent( 16, 16 );
4020 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4022 enabledDisableTrace.Reset();
4023 stencilTrace.Reset();
4024 enabledDisableTrace.Enable( true );
4025 stencilTrace.Enable( true );
4027 application.SendNotification();
4028 application.Render();
4030 enabledDisableTrace.Enable( false );
4031 stencilTrace.Enable( false );
4034 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4036 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4038 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4039 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4040 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4041 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4044 int UtcDaliActorPropertyClippingP(void)
4046 // This test checks the clippingMode property.
4047 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4048 TestApplication application;
4050 Actor actor = Actor::New();
4052 // Check default clippingEnabled value.
4053 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4056 bool getValueResult = getValue.Get( value );
4057 DALI_TEST_CHECK( getValueResult );
4059 if( getValueResult )
4061 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4064 // Check setting the property to the stencil mode.
4065 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4067 // Check the new value was set.
4068 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4069 getValueResult = getValue.Get( value );
4070 DALI_TEST_CHECK( getValueResult );
4072 if( getValueResult )
4074 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4077 // Check setting the property to the scissor mode.
4078 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4080 // Check the new value was set.
4081 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4082 getValueResult = getValue.Get( value );
4083 DALI_TEST_CHECK( getValueResult );
4085 if( getValueResult )
4087 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4092 int UtcDaliActorPropertyClippingN(void)
4094 // Negative test case for Clipping.
4095 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4096 TestApplication application;
4098 Actor actor = Actor::New();
4100 // Check default clippingEnabled value.
4101 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4104 bool getValueResult = getValue.Get( value );
4105 DALI_TEST_CHECK( getValueResult );
4107 if( getValueResult )
4109 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4112 // Check setting an invalid property value won't change the current property value.
4113 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4115 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4116 getValueResult = getValue.Get( value );
4117 DALI_TEST_CHECK( getValueResult );
4119 if( getValueResult )
4121 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4127 int UtcDaliActorPropertyClippingActor(void)
4129 // This test checks that an actor is correctly setup for clipping.
4130 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4131 TestApplication application;
4133 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4134 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4135 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4136 size_t startIndex = 0u;
4138 // Create a clipping actor.
4139 Actor actorDepth1Clip = CreateActorWithContent16x16();
4140 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4141 Stage::GetCurrent().Add( actorDepth1Clip );
4143 // Gather the call trace.
4144 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4146 // Check we are writing to the color buffer.
4147 CheckColorMask( glAbstraction, true );
4149 // Check the stencil buffer was enabled.
4150 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4152 // Check the stencil buffer was cleared.
4153 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4155 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4156 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4157 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4158 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4163 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4165 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4166 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4167 TestApplication application;
4169 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4170 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4171 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4172 size_t startIndex = 0u;
4174 // Create a clipping actor.
4175 Actor actorDepth1Clip = CreateActorWithContent16x16();
4176 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4177 Stage::GetCurrent().Add( actorDepth1Clip );
4179 // Gather the call trace.
4180 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4182 // Check we are writing to the color buffer.
4183 CheckColorMask( glAbstraction, true );
4185 // Check the stencil buffer was enabled.
4186 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4188 // Check the stencil buffer was cleared.
4189 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4191 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4192 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4193 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4194 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4196 // Now disable the clipping
4197 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4199 // Gather the call trace.
4200 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4202 // Check the stencil buffer was disabled.
4203 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4205 // Ensure all values in stencil-mask are set to 1.
4207 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4212 int UtcDaliActorPropertyClippingNestedChildren(void)
4214 // This test checks that a hierarchy of actors are clipped correctly by
4215 // writing to and reading from the correct bit-planes of the stencil buffer.
4216 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4217 TestApplication application;
4218 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4219 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4220 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4222 // Create a clipping actor.
4223 Actor actorDepth1Clip = CreateActorWithContent16x16();
4224 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4225 Stage::GetCurrent().Add( actorDepth1Clip );
4227 // Create a child actor.
4228 Actor childDepth2 = CreateActorWithContent16x16();
4229 actorDepth1Clip.Add( childDepth2 );
4231 // Create another clipping actor.
4232 Actor childDepth2Clip = CreateActorWithContent16x16();
4233 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4234 childDepth2.Add( childDepth2Clip );
4236 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4237 // This tests the sort algorithm.
4238 Actor childDepth3 = CreateActorWithContent16x16();
4239 childDepth2Clip.Add( childDepth3 );
4240 Actor childDepth4 = CreateActorWithContent16x16();
4241 childDepth3.Add( childDepth4 );
4243 // Gather the call trace.
4244 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4246 // Check we are writing to the color buffer.
4247 CheckColorMask( glAbstraction, true );
4249 // Check the stencil buffer was enabled.
4250 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4252 // Perform the test twice, once for 2D layer, and once for 3D.
4253 for( unsigned int i = 0u ; i < 2u; ++i )
4255 size_t startIndex = 0u;
4257 // Check the stencil buffer was cleared.
4258 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4260 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4261 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4262 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4263 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4265 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4266 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4267 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4269 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4270 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4271 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4272 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4274 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4275 // (Both must be set to pass the check).
4276 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4277 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4279 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4282 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4283 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4290 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4292 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4293 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4294 TestApplication application;
4295 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4296 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4298 /* We create a small tree of actors as follows:
4302 Clipping enabled -> B D
4306 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4309 for( int i = 0; i < 5; ++i )
4311 BufferImage image = BufferImage::New( 16u, 16u );
4312 Actor actor = CreateRenderableActor( image );
4314 // Setup dimensions and position so actor is not skipped by culling.
4315 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4316 actor.SetSize( 16.0f, 16.0f );
4320 actor.SetParentOrigin( ParentOrigin::CENTER );
4324 float b = i > 2 ? 1.0f : -1.0f;
4325 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4331 // Enable clipping on the actor at the top of the left branch.
4332 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4334 // Build the scene graph.
4335 Stage::GetCurrent().Add( actors[0] );
4338 actors[0].Add( actors[1] );
4339 actors[1].Add( actors[2] );
4342 actors[0].Add( actors[3] );
4343 actors[3].Add( actors[4] );
4345 // Gather the call trace.
4346 enabledDisableTrace.Reset();
4347 enabledDisableTrace.Enable( true );
4348 application.SendNotification();
4349 application.Render();
4350 enabledDisableTrace.Enable( false );
4352 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4354 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
4355 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4357 size_t startIndex = 0u;
4358 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4359 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4360 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4362 // Swap the clipping actor from top of left branch to top of right branch.
4363 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4364 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4366 // Gather the call trace.
4367 enabledDisableTrace.Reset();
4368 enabledDisableTrace.Enable( true );
4369 application.SendNotification();
4370 application.Render();
4371 enabledDisableTrace.Enable( false );
4373 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4374 // This proves the draw order has remained the same.
4376 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4377 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4382 int UtcDaliActorPropertyScissorClippingActor(void)
4384 // This test checks that an actor is correctly setup for clipping.
4385 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4386 TestApplication application;
4388 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4389 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4390 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4392 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4393 const Vector2 imageSize( 16.0f, 16.0f );
4395 // Create a clipping actor.
4396 Actor clippingActorA = CreateActorWithContent16x16();
4397 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4398 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4399 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4400 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4401 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4402 Stage::GetCurrent().Add( clippingActorA );
4404 // Gather the call trace.
4405 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4407 // Check we are writing to the color buffer.
4408 CheckColorMask( glAbstraction, true );
4410 // Check scissor test was enabled.
4411 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4413 // Check the scissor was set, and the coordinates are correct.
4414 std::stringstream compareParametersString;
4415 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4416 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4418 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4419 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4421 // Gather the call trace.
4422 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4424 // Check the scissor was set, and the coordinates are correct.
4425 compareParametersString.str( std::string() );
4426 compareParametersString.clear();
4427 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4428 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4433 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4435 // This test checks that an actor is correctly setup for clipping.
4436 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4437 TestApplication application;
4440 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4441 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4442 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4444 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4445 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4446 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4448 // Create a clipping actors.
4449 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4450 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4452 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4453 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4454 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4456 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4457 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4458 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4460 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4461 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4463 Stage::GetCurrent().Add( clippingActorA );
4464 Stage::GetCurrent().Add( clippingActorB );
4466 // Gather the call trace.
4467 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4469 // Check we are writing to the color buffer.
4470 CheckColorMask( glAbstraction, true );
4472 // Check scissor test was enabled.
4473 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4475 // Check the scissor was set, and the coordinates are correct.
4476 std::stringstream compareParametersString;
4478 std::string clipA( "0, 500, 480, 200" );
4479 std::string clipB( "0, 380, 480, 40" );
4481 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4482 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4487 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4489 // This test checks that an actor is correctly setup for clipping.
4490 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4491 TestApplication application;
4493 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4494 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4495 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4497 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4498 const Vector2 imageSize( 16.0f, 16.0f );
4500 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4502 A is drawn first - with scissor clipping on
4503 B is drawn second - also with scissor clipping on
4504 C is the generated clipping region, the intersection ( A ∩ B )
4508 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4509 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4510 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4514 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4517 // Create a clipping actor.
4518 Actor clippingActorA = CreateActorWithContent16x16();
4519 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4520 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4521 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4522 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4523 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4524 Stage::GetCurrent().Add( clippingActorA );
4526 // Create a child clipping actor.
4527 Actor clippingActorB = CreateActorWithContent16x16();
4528 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4529 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4530 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4531 clippingActorA.Add( clippingActorB );
4533 // positionModifiers is an array of positions to position B around.
4534 // expect is an array of expected scissor clip coordinate results.
4535 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4536 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4538 // Loop through each overlap combination.
4539 for( unsigned int test = 0u; test < 4u; ++test )
4541 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4542 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4543 clippingActorB.SetPosition( position.x, position.y );
4545 // Gather the call trace.
4546 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4548 // Check we are writing to the color buffer.
4549 CheckColorMask( glAbstraction, true );
4551 // Check scissor test was enabled.
4552 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4554 // Check the scissor was set, and the coordinates are correct.
4555 const Vector4& expectResults( expect[test] );
4556 std::stringstream compareParametersString;
4557 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4558 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4564 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4566 // This test checks that an actor is correctly setup for clipping.
4567 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4568 TestApplication application;
4570 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4571 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4572 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4574 /* Create a nest of 2 scissors and siblings of the parent.
4584 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4585 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4586 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4587 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4588 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4589 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4591 // Create a clipping actors.
4592 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4593 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4594 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4595 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4596 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4598 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4599 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4600 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4602 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4603 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4604 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4606 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4607 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4608 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4610 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4611 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4612 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4614 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4615 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4617 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4618 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4619 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4620 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4621 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4623 Stage::GetCurrent().Add( clippingActorA );
4624 clippingActorA.Add( clippingActorB );
4625 Stage::GetCurrent().Add( clippingActorC );
4626 Stage::GetCurrent().Add( clippingActorD );
4627 clippingActorD.Add( clippingActorE );
4629 // Gather the call trace.
4630 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4632 // Check we are writing to the color buffer.
4633 CheckColorMask( glAbstraction, true );
4635 // Check scissor test was enabled.
4636 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4638 // Check the scissor was set, and the coordinates are correct.
4639 std::string clipA( "0, 500, 480, 200" );
4640 std::string clipB( "0, 580, 480, 40" );
4641 std::string clipC( "0, 200, 480, 200" );
4642 std::string clipD( "0, 300, 480, 200" );
4644 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4645 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4646 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4647 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4648 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4653 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4655 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4656 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4657 TestApplication application;
4659 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4660 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4661 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4663 // Create a clipping actor.
4664 Actor actorDepth1Clip = CreateActorWithContent16x16();
4665 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4666 Stage::GetCurrent().Add( actorDepth1Clip );
4668 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4669 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4671 // Gather the call trace.
4672 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4674 // Check we are writing to the color buffer.
4675 CheckColorMask( glAbstraction, true );
4677 // Check the stencil buffer was not enabled.
4678 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4680 // Check stencil functions are not called.
4681 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4682 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4683 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4685 // Check that scissor clipping is overriden by the renderer properties.
4686 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4688 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4690 // Gather the call trace.
4691 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4693 // Check the stencil buffer was not enabled.
4694 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4696 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4701 int UtcDaliGetPropertyN(void)
4703 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4704 TestApplication app;
4706 Actor actor = Actor::New();
4708 unsigned int propertyCount = actor.GetPropertyCount();
4709 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4713 int UtcDaliActorRaiseLower(void)
4715 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4717 TestApplication application;
4719 Stage stage( Stage::GetCurrent() );
4721 Actor actorA = Actor::New();
4722 Actor actorB = Actor::New();
4723 Actor actorC = Actor::New();
4725 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4726 actorA.SetParentOrigin( ParentOrigin::CENTER );
4728 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4729 actorB.SetParentOrigin( ParentOrigin::CENTER );
4731 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4732 actorC.SetParentOrigin( ParentOrigin::CENTER );
4734 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4735 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4737 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4738 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4740 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4741 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4743 stage.Add( actorA );
4744 stage.Add( actorB );
4745 stage.Add( actorC );
4747 ResetTouchCallbacks();
4749 application.SendNotification();
4750 application.Render();
4752 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4753 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4754 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4756 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4757 // Only top actor will get touched.
4758 actorA.TouchSignal().Connect( TestTouchCallback );
4759 actorB.TouchSignal().Connect( TestTouchCallback2 );
4760 actorC.TouchSignal().Connect( TestTouchCallback3 );
4762 // Connect ChildOrderChangedSignal
4763 bool orderChangedSignal( false );
4764 Actor orderChangedActor;
4765 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4766 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4768 Dali::Integration::Point point;
4769 point.SetDeviceId( 1 );
4770 point.SetState( PointState::DOWN );
4771 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4772 Dali::Integration::TouchEvent touchEvent;
4773 touchEvent.AddPoint( point );
4775 application.ProcessEvent( touchEvent );
4777 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4778 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4779 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4781 ResetTouchCallbacks();
4783 tet_printf( "Testing Raising of Actor\n" );
4785 int preActorOrder( 0 );
4786 int postActorOrder( 0 );
4788 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4789 value.Get( preActorOrder );
4791 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4793 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4794 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4796 // Ensure sort order is calculated before next touch event
4797 application.SendNotification();
4799 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4800 value.Get( postActorOrder );
4802 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4804 application.ProcessEvent( touchEvent );
4806 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4807 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4808 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4810 ResetTouchCallbacks();
4812 tet_printf( "Testing Lowering of Actor\n" );
4814 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4815 value.Get( preActorOrder );
4817 orderChangedSignal = false;
4819 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4821 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4822 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4824 application.SendNotification(); // ensure sort order calculated before next touch event
4826 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4827 value.Get( postActorOrder );
4829 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4831 application.ProcessEvent( touchEvent );
4833 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4834 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4835 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4837 ResetTouchCallbacks();
4842 int UtcDaliActorRaiseToTopLowerToBottom(void)
4844 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4846 TestApplication application;
4848 Stage stage( Stage::GetCurrent() );
4850 Actor actorA = Actor::New();
4851 Actor actorB = Actor::New();
4852 Actor actorC = Actor::New();
4854 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4855 // enables checking of which actor the uniform is assigned too
4856 Shader shaderA = CreateShader();
4857 shaderA.RegisterProperty( "uRendererColor",1.f);
4859 Shader shaderB = CreateShader();
4860 shaderB.RegisterProperty( "uRendererColor", 2.f );
4862 Shader shaderC = CreateShader();
4863 shaderC.RegisterProperty( "uRendererColor", 3.f );
4865 Geometry geometry = CreateQuadGeometry();
4867 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4868 Renderer rendererA = Renderer::New(geometry, shaderA);
4869 actorA.AddRenderer(rendererA);
4871 Renderer rendererB = Renderer::New(geometry, shaderB);
4872 actorB.AddRenderer(rendererB);
4874 Renderer rendererC = Renderer::New(geometry, shaderC);
4875 actorC.AddRenderer(rendererC);
4877 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4878 actorA.SetParentOrigin( ParentOrigin::CENTER );
4880 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4881 actorB.SetParentOrigin( ParentOrigin::CENTER );
4883 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4884 actorC.SetParentOrigin( ParentOrigin::CENTER );
4886 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4887 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4889 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4890 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4892 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4893 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4895 stage.Add( actorA );
4896 stage.Add( actorB );
4897 stage.Add( actorC );
4899 ResetTouchCallbacks();
4901 // Connect ChildOrderChangedSignal
4902 bool orderChangedSignal( false );
4903 Actor orderChangedActor;
4904 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4905 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4907 // Set up gl abstraction trace so can query the set uniform order
4908 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4909 glAbstraction.EnableSetUniformCallTrace(true);
4910 glAbstraction.ResetSetUniformCallStack();
4912 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4914 application.SendNotification();
4915 application.Render();
4917 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4920 // Test order of uniforms in stack
4921 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4922 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4923 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4925 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4927 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4929 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4930 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4931 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4933 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4934 // Only top actor will get touched.
4935 actorA.TouchSignal().Connect( TestTouchCallback );
4936 actorB.TouchSignal().Connect( TestTouchCallback2 );
4937 actorC.TouchSignal().Connect( TestTouchCallback3 );
4939 Dali::Integration::Point point;
4940 point.SetDeviceId( 1 );
4941 point.SetState( PointState::DOWN );
4942 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4943 Dali::Integration::TouchEvent touchEvent;
4944 touchEvent.AddPoint( point );
4946 application.ProcessEvent( touchEvent );
4948 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4949 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4950 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4952 ResetTouchCallbacks();
4954 tet_printf( "RaiseToTop ActorA\n" );
4956 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4957 actorA.RaiseToTop();
4958 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4959 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
4961 application.SendNotification(); // ensure sorting order is calculated before next touch event
4963 application.ProcessEvent( touchEvent );
4965 glAbstraction.ResetSetUniformCallStack();
4966 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4968 application.SendNotification();
4969 application.Render();
4971 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4973 // Test order of uniforms in stack
4974 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4975 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4976 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4978 tet_infoline( "Testing A above C and B at bottom\n" );
4979 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4981 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4983 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4984 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4985 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4987 ResetTouchCallbacks();
4989 tet_printf( "RaiseToTop ActorB\n" );
4991 orderChangedSignal = false;
4993 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4994 actorB.RaiseToTop();
4995 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4996 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4998 application.SendNotification(); // Ensure sort order is calculated before next touch event
5000 application.ProcessEvent( touchEvent );
5002 glAbstraction.ResetSetUniformCallStack();
5003 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5005 application.SendNotification();
5006 application.Render();
5008 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5010 // Test order of uniforms in stack
5011 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5012 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5013 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5015 tet_infoline( "Testing B above A and C at bottom\n" );
5016 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5018 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5020 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5021 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5022 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5024 ResetTouchCallbacks();
5026 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5028 orderChangedSignal = false;
5030 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5031 actorA.LowerToBottom();
5032 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5033 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5035 application.SendNotification();
5036 application.Render();
5038 orderChangedSignal = false;
5040 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5041 actorB.LowerToBottom();
5042 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5043 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5045 application.SendNotification();
5046 application.Render();
5048 application.ProcessEvent( touchEvent );
5050 glAbstraction.ResetSetUniformCallStack();
5051 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5053 application.SendNotification();
5054 application.Render();
5056 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5058 // Test order of uniforms in stack
5059 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5060 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5061 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5063 tet_infoline( "Testing C above A and B at bottom\n" );
5064 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5066 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5068 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5069 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5070 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5072 ResetTouchCallbacks();
5077 int UtcDaliActorRaiseAbove(void)
5079 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5081 TestApplication application;
5083 Stage stage( Stage::GetCurrent() );
5085 Actor actorA = Actor::New();
5086 Actor actorB = Actor::New();
5087 Actor actorC = Actor::New();
5089 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5090 actorA.SetParentOrigin( ParentOrigin::CENTER );
5092 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5093 actorB.SetParentOrigin( ParentOrigin::CENTER );
5095 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5096 actorC.SetParentOrigin( ParentOrigin::CENTER );
5098 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5099 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5101 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5102 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5104 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5105 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5107 stage.Add( actorA );
5108 stage.Add( actorB );
5109 stage.Add( actorC );
5111 ResetTouchCallbacks();
5113 application.SendNotification();
5114 application.Render();
5116 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5117 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5118 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5120 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5121 // Only top actor will get touched.
5122 actorA.TouchSignal().Connect( TestTouchCallback );
5123 actorB.TouchSignal().Connect( TestTouchCallback2 );
5124 actorC.TouchSignal().Connect( TestTouchCallback3 );
5126 bool orderChangedSignal( false );
5127 Actor orderChangedActor;
5128 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5129 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5131 Dali::Integration::Point point;
5132 point.SetDeviceId( 1 );
5133 point.SetState( PointState::DOWN );
5134 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5135 Dali::Integration::TouchEvent touchEvent;
5136 touchEvent.AddPoint( point );
5138 application.ProcessEvent( touchEvent );
5140 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5141 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5142 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5144 ResetTouchCallbacks();
5146 tet_printf( "Raise actor B Above Actor C\n" );
5148 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5149 actorB.RaiseAbove( actorC );
5150 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5151 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5153 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5154 application.SendNotification();
5155 application.ProcessEvent( touchEvent );
5157 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5158 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5159 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5161 ResetTouchCallbacks();
5163 tet_printf( "Raise actor A Above Actor B\n" );
5165 orderChangedSignal = false;
5167 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5168 actorA.RaiseAbove( actorB );
5169 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5170 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5172 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5173 application.SendNotification();
5175 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5177 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5178 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5179 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5181 ResetTouchCallbacks();
5186 int UtcDaliActorLowerBelow(void)
5188 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5190 TestApplication application;
5192 Stage stage( Stage::GetCurrent() );
5194 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5195 // enables checking of which actor the uniform is assigned too
5196 Shader shaderA = CreateShader();
5197 shaderA.RegisterProperty( "uRendererColor",1.f);
5199 Shader shaderB = CreateShader();
5200 shaderB.RegisterProperty( "uRendererColor", 2.f );
5202 Shader shaderC = CreateShader();
5203 shaderC.RegisterProperty( "uRendererColor", 3.f );
5205 Actor actorA = Actor::New();
5206 Actor actorB = Actor::New();
5207 Actor actorC = Actor::New();
5209 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5210 Geometry geometry = CreateQuadGeometry();
5212 Renderer rendererA = Renderer::New(geometry, shaderA);
5213 actorA.AddRenderer(rendererA);
5215 Renderer rendererB = Renderer::New(geometry, shaderB);
5216 actorB.AddRenderer(rendererB);
5218 Renderer rendererC = Renderer::New(geometry, shaderC);
5219 actorC.AddRenderer(rendererC);
5221 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5222 actorA.SetParentOrigin( ParentOrigin::CENTER );
5224 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5225 actorB.SetParentOrigin( ParentOrigin::CENTER );
5227 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5228 actorC.SetParentOrigin( ParentOrigin::CENTER );
5230 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5231 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5233 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5234 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5236 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5237 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5239 Actor container = Actor::New();
5240 container.SetParentOrigin( ParentOrigin::CENTER );
5241 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5242 stage.Add( container );
5244 container.Add( actorA );
5245 container.Add( actorB );
5246 container.Add( actorC );
5248 ResetTouchCallbacks();
5250 // Connect ChildOrderChangedSignal
5251 bool orderChangedSignal( false );
5252 Actor orderChangedActor;
5253 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5254 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5256 // Set up gl abstraction trace so can query the set uniform order
5257 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5258 glAbstraction.EnableSetUniformCallTrace(true);
5259 glAbstraction.ResetSetUniformCallStack();
5260 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5262 glAbstraction.ResetSetUniformCallStack();
5264 application.SendNotification();
5265 application.Render();
5267 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5269 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5271 // Test order of uniforms in stack
5272 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5273 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5274 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5276 tet_infoline( "Testing C above B and A at bottom\n" );
5277 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5279 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5281 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5282 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5283 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5285 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5286 // Only top actor will get touched.
5287 actorA.TouchSignal().Connect( TestTouchCallback );
5288 actorB.TouchSignal().Connect( TestTouchCallback2 );
5289 actorC.TouchSignal().Connect( TestTouchCallback3 );
5291 Dali::Integration::Point point;
5292 point.SetDeviceId( 1 );
5293 point.SetState( PointState::DOWN );
5294 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5295 Dali::Integration::TouchEvent touchEvent;
5296 touchEvent.AddPoint( point );
5298 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5300 application.ProcessEvent( touchEvent );
5302 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5303 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5304 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5306 ResetTouchCallbacks();
5308 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" );
5310 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5311 actorC.LowerBelow( actorB );
5312 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5313 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5315 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5316 application.SendNotification();
5317 application.Render();
5319 application.ProcessEvent( touchEvent ); // touch event
5321 glAbstraction.ResetSetUniformCallStack();
5322 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5324 application.SendNotification();
5325 application.Render();
5327 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5329 // Test order of uniforms in stack
5330 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5331 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5332 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5334 tet_infoline( "Testing render order is A, C, B" );
5335 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5336 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5338 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5339 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5340 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5342 ResetTouchCallbacks();
5344 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5346 orderChangedSignal = false;
5348 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5349 actorC.LowerBelow( actorA );
5350 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5351 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5353 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5354 application.SendNotification();
5355 application.Render();
5357 application.ProcessEvent( touchEvent );
5359 glAbstraction.ResetSetUniformCallStack();
5360 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5362 application.Render();
5363 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5365 // Test order of uniforms in stack
5366 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5367 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5368 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5370 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5371 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5373 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5374 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5375 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5377 ResetTouchCallbacks();
5379 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5381 orderChangedSignal = false;
5383 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5384 actorB.LowerBelow( actorC );
5385 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5386 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5388 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5389 application.SendNotification();
5390 application.Render();
5392 application.ProcessEvent( touchEvent );
5394 glAbstraction.ResetSetUniformCallStack();
5395 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5397 application.Render();
5398 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5400 // Test order of uniforms in stack
5401 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5402 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5403 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5405 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5406 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5412 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5414 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5416 TestApplication application;
5418 Stage stage( Stage::GetCurrent() );
5420 Actor parentA = Actor::New();
5421 Actor parentB = Actor::New();
5422 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5423 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5424 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5425 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5427 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5428 parentA.SetParentOrigin( ParentOrigin::CENTER );
5430 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5431 parentB.SetParentOrigin( ParentOrigin::CENTER );
5433 stage.Add( parentA );
5434 stage.Add( parentB );
5436 Actor actorA = Actor::New();
5437 Actor actorB = Actor::New();
5438 Actor actorC = Actor::New();
5440 parentA.Add( actorA );
5441 parentA.Add( actorB );
5443 tet_printf( "Actor C added to different parent from A and B \n" );
5444 parentB.Add( actorC );
5446 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5447 actorA.SetParentOrigin( ParentOrigin::CENTER );
5449 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5450 actorB.SetParentOrigin( ParentOrigin::CENTER );
5452 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5453 actorC.SetParentOrigin( ParentOrigin::CENTER );
5455 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5456 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5458 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5459 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5461 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5462 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5464 ResetTouchCallbacks();
5466 // Connect ChildOrderChangedSignal
5467 bool orderChangedSignal( false );
5468 Actor orderChangedActor;
5469 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5470 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5472 application.SendNotification();
5473 application.Render();
5475 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5476 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5477 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5479 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5480 // Only top actor will get touched.
5481 actorA.TouchSignal().Connect( TestTouchCallback );
5482 actorB.TouchSignal().Connect( TestTouchCallback2 );
5483 actorC.TouchSignal().Connect( TestTouchCallback3 );
5485 Dali::Integration::Point point;
5486 point.SetDeviceId( 1 );
5487 point.SetState( PointState::DOWN );
5488 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5489 Dali::Integration::TouchEvent touchEvent;
5490 touchEvent.AddPoint( point );
5492 application.ProcessEvent( touchEvent );
5494 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5495 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5496 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5498 ResetTouchCallbacks();
5500 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5502 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5503 actorA.RaiseAbove( actorC );
5504 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5506 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5507 application.SendNotification();
5509 application.ProcessEvent( touchEvent ); // touch event
5511 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5512 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5513 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5515 ResetTouchCallbacks();
5520 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5522 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5524 TestApplication application;
5526 Stage stage( Stage::GetCurrent() );
5528 Actor actorA = Actor::New();
5529 Actor actorB = Actor::New();
5530 Actor actorC = Actor::New();
5532 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5533 actorA.SetParentOrigin( ParentOrigin::CENTER );
5535 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5536 actorB.SetParentOrigin( ParentOrigin::CENTER );
5538 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5539 actorC.SetParentOrigin( ParentOrigin::CENTER );
5541 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5542 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5544 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5545 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5547 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5548 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5550 ResetTouchCallbacks();
5552 // Connect ChildOrderChangedSignal
5553 bool orderChangedSignal( false );
5554 Actor orderChangedActor;
5555 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5556 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5558 application.SendNotification();
5559 application.Render();
5561 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5562 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5563 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5565 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5566 // Only top actor will get touched.
5567 actorA.TouchSignal().Connect( TestTouchCallback );
5568 actorB.TouchSignal().Connect( TestTouchCallback2 );
5569 actorC.TouchSignal().Connect( TestTouchCallback3 );
5571 Dali::Integration::Point point;
5572 point.SetDeviceId( 1 );
5573 point.SetState( PointState::DOWN );
5574 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5575 Dali::Integration::TouchEvent touchEvent;
5576 touchEvent.AddPoint( point );
5578 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5580 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5581 actorA.RaiseAbove( actorC );
5582 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5584 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5585 application.SendNotification();
5587 application.ProcessEvent( touchEvent );
5589 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5591 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5592 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5593 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5595 ResetTouchCallbacks();
5597 orderChangedSignal = false;
5599 stage.Add ( actorB );
5600 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5602 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5603 actorA.LowerBelow( actorC );
5604 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5606 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5607 application.SendNotification();
5608 application.Render();
5610 application.ProcessEvent( touchEvent );
5612 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5613 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5614 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5615 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5617 ResetTouchCallbacks();
5619 orderChangedSignal = false;
5621 tet_printf( "Adding Actor A to stage, will be on top\n" );
5623 stage.Add ( actorA );
5624 application.SendNotification();
5625 application.Render();
5627 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5629 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5630 actorB.RaiseAbove( actorC );
5631 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5633 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5634 application.SendNotification();
5636 application.ProcessEvent( touchEvent );
5638 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5639 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5640 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5641 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5643 ResetTouchCallbacks();
5645 orderChangedSignal = false;
5647 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5649 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5650 actorA.LowerBelow( actorC );
5651 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5653 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5654 application.SendNotification();
5656 application.ProcessEvent( touchEvent );
5658 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5659 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5660 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5661 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5663 ResetTouchCallbacks();
5665 orderChangedSignal = false;
5667 stage.Add ( actorC );
5669 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5670 actorA.RaiseAbove( actorC );
5671 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5672 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5674 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5675 application.SendNotification();
5676 application.Render();
5678 application.ProcessEvent( touchEvent );
5680 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5681 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5682 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5683 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5688 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5690 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5692 TestApplication application;
5694 Stage stage( Stage::GetCurrent() );
5696 Actor actorA = Actor::New();
5697 Actor actorB = Actor::New();
5698 Actor actorC = Actor::New();
5700 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5701 actorA.SetParentOrigin( ParentOrigin::CENTER );
5703 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5704 actorB.SetParentOrigin( ParentOrigin::CENTER );
5706 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5707 actorC.SetParentOrigin( ParentOrigin::CENTER );
5709 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5710 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5712 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5713 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5715 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5716 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5718 ResetTouchCallbacks();
5720 // Connect ChildOrderChangedSignal
5721 bool orderChangedSignal( false );
5722 Actor orderChangedActor;
5723 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5724 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5726 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5727 // Only top actor will get touched.
5728 actorA.TouchSignal().Connect( TestTouchCallback );
5729 actorB.TouchSignal().Connect( TestTouchCallback2 );
5730 actorC.TouchSignal().Connect( TestTouchCallback3 );
5732 Dali::Integration::Point point;
5733 point.SetDeviceId( 1 );
5734 point.SetState( PointState::DOWN );
5735 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5736 Dali::Integration::TouchEvent touchEvent;
5737 touchEvent.AddPoint( point );
5739 stage.Add ( actorA );
5740 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5742 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5744 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5746 application.SendNotification();
5747 application.Render();
5749 application.ProcessEvent( touchEvent );
5751 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5753 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5754 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5755 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5757 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5758 ResetTouchCallbacks();
5760 orderChangedSignal = false;
5762 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5764 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5766 // Sort actor tree before next touch event
5767 application.SendNotification();
5768 application.Render();
5770 application.ProcessEvent( touchEvent );
5772 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5774 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5775 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5776 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5777 ResetTouchCallbacks();
5779 orderChangedSignal = false;
5781 tet_printf( "Lower actor C below B but C not parented\n" );
5783 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5785 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5787 // Sort actor tree before next touch event
5788 application.SendNotification();
5789 application.Render();
5791 application.ProcessEvent( touchEvent );
5793 tet_printf( "Not parented so Lower should show no effect\n" );
5795 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5796 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5797 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5798 ResetTouchCallbacks();
5800 orderChangedSignal = false;
5802 tet_printf( "Raise actor B to top\n" );
5804 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5805 actorB.RaiseToTop();
5806 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5808 // Sort actor tree before next touch event
5809 application.SendNotification();
5810 application.Render();
5812 application.ProcessEvent( touchEvent );
5814 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5816 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5817 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5818 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5819 ResetTouchCallbacks();
5821 orderChangedSignal = false;
5823 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5825 stage.Add ( actorB );
5827 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5829 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5830 actorC.LowerToBottom();
5831 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5833 application.SendNotification();
5834 application.Render();
5836 application.ProcessEvent( touchEvent );
5838 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5840 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5841 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5842 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5843 ResetTouchCallbacks();
5849 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5851 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5853 TestApplication application;
5855 Stage stage( Stage::GetCurrent() );
5857 Actor actorA = Actor::New();
5858 Actor actorB = Actor::New();
5859 Actor actorC = Actor::New();
5861 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5862 actorA.SetParentOrigin( ParentOrigin::CENTER );
5864 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5865 actorB.SetParentOrigin( ParentOrigin::CENTER );
5867 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5868 actorC.SetParentOrigin( ParentOrigin::CENTER );
5870 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5871 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5873 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5874 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5876 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5877 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5879 stage.Add( actorA );
5880 stage.Add( actorB );
5881 stage.Add( actorC );
5883 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5884 // Only top actor will get touched.
5885 actorA.TouchSignal().Connect( TestTouchCallback );
5886 actorB.TouchSignal().Connect( TestTouchCallback2 );
5887 actorC.TouchSignal().Connect( TestTouchCallback3 );
5889 ResetTouchCallbacks();
5891 // Connect ChildOrderChangedSignal
5892 bool orderChangedSignal( false );
5893 Actor orderChangedActor;
5894 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5895 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5897 application.SendNotification();
5898 application.Render();
5900 Dali::Integration::Point point;
5901 point.SetDeviceId( 1 );
5902 point.SetState( PointState::DOWN );
5903 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5904 Dali::Integration::TouchEvent touchEvent;
5905 touchEvent.AddPoint( point );
5907 application.ProcessEvent( touchEvent );
5909 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5910 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5911 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5913 ResetTouchCallbacks();
5915 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5917 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5918 actorA.RaiseAbove( actorA );
5919 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5920 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5922 application.SendNotification();
5923 application.Render();
5925 application.ProcessEvent( touchEvent );
5927 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5929 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5930 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5931 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5933 ResetTouchCallbacks();
5935 orderChangedSignal = false;
5937 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5938 actorA.RaiseAbove( actorC );
5939 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5940 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5942 application.SendNotification();
5943 application.Render();
5945 application.ProcessEvent( touchEvent );
5947 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5948 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5949 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5950 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5955 int UtcDaliActorGetScreenPosition(void)
5957 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5959 TestApplication application;
5961 Stage stage( Stage::GetCurrent() );
5963 Actor actorA = Actor::New();
5964 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5966 Vector2 size2( 10.0f, 20.0f );
5967 actorA.SetSize( size2 );
5969 actorA.SetPosition( 0.f, 0.f );
5971 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5973 stage.Add( actorA );
5975 application.SendNotification();
5976 application.Render();
5978 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5979 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5981 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5982 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5984 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5985 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5987 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5989 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5991 application.SendNotification();
5992 application.Render();
5994 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5995 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5997 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5998 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6000 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6001 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6003 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6005 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6007 application.SendNotification();
6008 application.Render();
6010 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6011 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6013 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6014 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6016 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6017 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6019 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6021 actorA.SetPosition( 30.0, 0.0 );
6023 application.SendNotification();
6024 application.Render();
6026 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6027 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6029 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6030 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6032 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6033 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6035 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6037 actorA.SetPosition( 30.0, 420.0 );
6039 application.SendNotification();
6040 application.Render();
6042 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6043 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6045 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6046 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6048 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6049 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6051 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6053 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6054 actorA.SetPosition( 30.0, 30.0 );
6056 Actor actorB = Actor::New();
6057 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6058 actorB.SetSize( size2 );
6059 actorB.SetPosition( 10.f, 10.f );
6060 actorA.Add( actorB );
6062 actorA.SetScale( 2.0f );
6064 application.SendNotification();
6065 application.Render();
6067 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6069 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6070 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6075 int UtcDaliActorGetScreenPositionAfterScaling(void)
6077 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6079 TestApplication application;
6081 Stage stage( Stage::GetCurrent() );
6083 Actor actorA = Actor::New();
6084 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6086 Vector2 size2( 10.0f, 20.0f );
6087 actorA.SetSize( size2 );
6088 actorA.SetScale( 1.5f );
6089 actorA.SetPosition( 0.f, 0.f );
6091 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6093 stage.Add( actorA );
6095 application.SendNotification();
6096 application.Render();
6098 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6099 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6101 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6102 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6104 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6105 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6107 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6109 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6111 application.SendNotification();
6112 application.Render();
6114 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6115 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6117 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6118 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6120 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6121 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6126 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6128 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6130 TestApplication application;
6132 Stage stage( Stage::GetCurrent() );
6134 Actor actorA = Actor::New();
6135 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6136 actorA.SetParentOrigin( ParentOrigin::CENTER );
6137 Vector2 size2( 10.0f, 20.0f );
6138 actorA.SetSize( size2 );
6139 actorA.SetPosition( 0.f, 0.f );
6141 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6143 stage.Add( actorA );
6145 application.SendNotification();
6146 application.Render();
6148 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6149 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6151 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6152 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6154 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6155 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6157 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6159 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6160 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6162 application.SendNotification();
6163 application.Render();
6165 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6166 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6168 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6169 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6171 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6172 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6178 int UtcDaliActorGetScreenPositionWithChildActors(void)
6180 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6182 TestApplication application;
6184 Stage stage( Stage::GetCurrent() );
6186 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6188 Actor actorA = Actor::New();
6189 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6190 actorA.SetParentOrigin( ParentOrigin::CENTER );
6191 Vector2 size1( 10.0f, 20.0f );
6192 actorA.SetSize( size1 );
6193 actorA.SetPosition( 0.f, 0.f );
6195 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6197 Actor parentActorA = Actor::New();
6198 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6199 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6200 Vector2 size2( 30.0f, 60.0f );
6201 parentActorA.SetSize( size2 );
6202 parentActorA.SetPosition( 0.f, 0.f );
6204 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6206 stage.Add( parentActorA );
6207 parentActorA.Add ( actorA );
6209 application.SendNotification();
6210 application.Render();
6212 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6213 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6215 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6216 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6218 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6219 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6221 tet_infoline( "Test 2\n");
6223 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6225 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6226 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6228 application.SendNotification();
6229 application.Render();
6231 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6232 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6234 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6235 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6237 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6238 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6243 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6245 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6247 TestApplication application;
6249 Stage stage( Stage::GetCurrent() );
6251 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6253 Actor actorA = Actor::New();
6254 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6255 actorA.SetParentOrigin( ParentOrigin::CENTER );
6256 Vector2 size1( 10.0f, 20.0f );
6257 actorA.SetSize( size1 );
6258 actorA.SetPosition( 0.f, 0.f );
6260 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6262 Actor parentActorA = Actor::New();
6263 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6264 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6265 Vector2 size2( 30.0f, 60.0f );
6266 parentActorA.SetSize( size2 );
6267 parentActorA.SetPosition( 0.f, 0.f );
6269 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6271 Actor grandParentActorA = Actor::New();
6272 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6273 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6274 Vector2 size3( 60.0f, 120.0f );
6275 grandParentActorA.SetSize( size3 );
6276 grandParentActorA.SetPosition( 0.f, 0.f );
6278 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6280 stage.Add( grandParentActorA );
6281 grandParentActorA.Add ( parentActorA );
6283 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6285 parentActorA.Add ( actorA );
6287 application.SendNotification();
6288 application.Render();
6290 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6291 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6293 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6294 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6296 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6297 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6302 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6304 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6306 TestApplication application;
6308 Stage stage( Stage::GetCurrent() );
6310 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6312 Actor actorA = Actor::New();
6313 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6314 actorA.SetParentOrigin( ParentOrigin::CENTER );
6315 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6316 actorA.SetSize( 10.0f, 20.0f );
6317 stage.Add( actorA );
6319 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6321 Actor actorB = Actor::New();
6322 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6323 actorB.SetParentOrigin( ParentOrigin::CENTER );
6324 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6325 Vector2 actorBSize( 30.0f, 60.0f );
6326 actorB.SetSize( actorBSize );
6327 stage.Add( actorB );
6329 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6331 Actor actorC = Actor::New();
6332 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6333 actorC.SetParentOrigin( ParentOrigin::CENTER );
6334 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6335 Vector2 actorCSize( 60.0f, 120.0f );
6336 actorC.SetSize( actorCSize );
6337 stage.Add( actorC );
6339 application.SendNotification();
6340 application.Render();
6342 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6344 Vector2 center( stage.GetSize() * 0.5f );
6346 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6347 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6348 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6350 tet_infoline( "Add scale to all actors" );
6352 actorA.SetScale( 2.0f );
6353 actorB.SetScale( 2.0f );
6354 actorC.SetScale( 2.0f );
6356 application.SendNotification();
6357 application.Render();
6359 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6360 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6361 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6366 int utcDaliActorPositionUsesAnchorPoint(void)
6368 TestApplication application;
6369 tet_infoline( "Check default behaviour\n" );
6371 Actor actor = Actor::New();
6372 actor.SetParentOrigin( ParentOrigin::CENTER );
6373 actor.SetAnchorPoint( AnchorPoint::CENTER );
6374 actor.SetSize( 100.0f, 100.0f );
6375 Stage::GetCurrent().Add( actor );
6377 application.SendNotification();
6378 application.Render();
6380 tet_infoline( "Check that the world position is in the center\n" );
6381 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6383 tet_infoline( "Set the position uses anchor point property to false\n" );
6384 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6386 application.SendNotification();
6387 application.Render();
6389 tet_infoline( "Check that the world position has changed appropriately\n" );
6390 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6395 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6397 TestApplication application;
6398 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6400 Actor actor = Actor::New();
6401 actor.SetParentOrigin( ParentOrigin::CENTER );
6402 actor.SetAnchorPoint( AnchorPoint::CENTER );
6403 actor.SetSize( 100.0f, 100.0f );
6404 actor.SetScale( 2.0f );
6405 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6406 Stage::GetCurrent().Add( actor );
6408 application.SendNotification();
6409 application.Render();
6411 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6412 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6414 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6415 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6416 application.SendNotification();
6417 application.Render();
6418 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6420 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6421 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6422 application.SendNotification();
6423 application.Render();
6424 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6429 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6431 TestApplication application;
6432 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6434 Actor actor = Actor::New();
6435 actor.SetParentOrigin( ParentOrigin::CENTER );
6436 actor.SetAnchorPoint( AnchorPoint::CENTER );
6437 actor.SetSize( 100.0f, 100.0f );
6438 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6439 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6440 Stage::GetCurrent().Add( actor );
6442 application.SendNotification();
6443 application.Render();
6445 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6446 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6448 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6449 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6450 application.SendNotification();
6451 application.Render();
6452 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6454 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6455 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6456 application.SendNotification();
6457 application.Render();
6458 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6463 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6465 TestApplication application;
6466 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6468 Actor actor = Actor::New();
6469 actor.SetParentOrigin( ParentOrigin::CENTER );
6470 actor.SetAnchorPoint( AnchorPoint::CENTER );
6471 actor.SetSize( 100.0f, 100.0f );
6472 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6473 actor.SetScale( 2.0f );
6474 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6475 Stage::GetCurrent().Add( actor );
6477 application.SendNotification();
6478 application.Render();
6480 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6481 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6483 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6484 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6485 application.SendNotification();
6486 application.Render();
6487 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6489 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6490 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6491 application.SendNotification();
6492 application.Render();
6493 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6498 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6500 TestApplication application;
6501 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6503 Actor parent = Actor::New();
6505 Stage::GetCurrent().Add( parent );
6506 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6508 Actor actor = Actor::New();
6509 actor.SetParentOrigin( ParentOrigin::CENTER );
6510 actor.SetAnchorPoint( AnchorPoint::CENTER );
6511 actor.SetSize( 100.0f, 100.0f );
6512 actor.SetInheritScale( false );
6513 actor.SetInheritOrientation( false );
6514 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6515 parent.Add( actor );
6517 application.SendNotification();
6518 application.Render();
6520 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6522 tet_infoline( "Check the world position is in the right place\n" );
6523 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6525 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6526 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6527 application.SendNotification();
6528 application.Render();
6529 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6531 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6532 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6533 application.SendNotification();
6534 application.Render();
6535 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6540 int utcDaliActorVisibilityChangeSignalSelf(void)
6542 TestApplication application;
6543 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6545 Actor actor = Actor::New();
6547 VisibilityChangedFunctorData data;
6548 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6550 actor.SetVisible( false );
6552 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6554 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6557 actor.SetVisible( false );
6558 data.Check( false /* not called */, TEST_LOCATION );
6560 tet_infoline( "Change the visibility using properties, ensure called" );
6563 actor.SetProperty( Actor::Property::VISIBLE, true );
6564 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6566 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6569 actor.SetProperty( Actor::Property::VISIBLE, true );
6570 data.Check( false /* not called */, TEST_LOCATION );
6575 int utcDaliActorVisibilityChangeSignalChildren(void)
6577 TestApplication application;
6578 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6580 Actor parent = Actor::New();
6581 Actor child = Actor::New();
6582 parent.Add( child );
6584 Actor grandChild = Actor::New();
6585 child.Add( grandChild );
6587 VisibilityChangedFunctorData parentData;
6588 VisibilityChangedFunctorData childData;
6589 VisibilityChangedFunctorData grandChildData;
6591 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6592 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6593 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6595 parent.SetVisible( false );
6596 parentData.Check( false /* not called */, TEST_LOCATION );
6597 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6598 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6600 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6603 grandChildData.Reset();
6605 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6607 parent.SetVisible( true );
6608 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6609 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6610 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6612 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6615 grandChildData.Reset();
6617 parent.SetVisible( true );
6618 parentData.Check( false /* not called */, TEST_LOCATION );
6619 childData.Check( false /* not called */, TEST_LOCATION );
6620 grandChildData.Check( false /* not called */, TEST_LOCATION );
6625 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6627 TestApplication application;
6628 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6630 Actor actor = Actor::New();
6631 Stage::GetCurrent().Add( actor );
6633 application.SendNotification();
6634 application.Render();
6636 VisibilityChangedFunctorData data;
6637 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6639 Animation animation = Animation::New( 1.0f );
6640 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6642 data.Check( false, TEST_LOCATION );
6643 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6644 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6646 tet_infoline( "Play the animation and check the property value" );
6649 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6650 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6652 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6653 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6655 application.SendNotification();
6656 application.Render( 1100 ); // After the animation
6658 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6664 int utcDaliActorVisibilityChangeSignalByName(void)
6666 TestApplication application;
6667 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6669 Actor actor = Actor::New();
6671 bool signalCalled=false;
6672 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6673 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6674 actor.SetVisible( false );
6675 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6677 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6678 signalCalled = false;
6679 actor.SetVisible( false );
6680 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6682 tet_infoline( "Change the visibility using properties, ensure called" );
6683 actor.SetProperty( Actor::Property::VISIBLE, true );
6684 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6686 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6687 signalCalled = false;
6689 actor.SetProperty( Actor::Property::VISIBLE, true );
6690 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6696 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6698 gLayoutDirectionType = type;
6701 int UtcDaliActorLayoutDirectionProperty(void)
6703 TestApplication application;
6704 tet_infoline( "Check layout direction property" );
6706 Actor actor0 = Actor::New();
6707 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6708 Stage::GetCurrent().Add( actor0 );
6710 application.SendNotification();
6711 application.Render();
6713 Actor actor1 = Actor::New();
6714 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6715 Actor actor2 = Actor::New();
6716 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6717 Actor actor3 = Actor::New();
6718 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6719 Actor actor4 = Actor::New();
6720 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6721 Actor actor5 = Actor::New();
6722 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6723 Actor actor6 = Actor::New();
6724 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6725 Actor actor7 = Actor::New();
6726 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6727 Actor actor8 = Actor::New();
6728 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6729 Actor actor9 = Actor::New();
6730 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6732 actor1.Add( actor2 );
6733 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6734 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6736 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6737 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6738 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6740 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6741 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6742 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6744 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6745 actor0.Add( actor1 );
6746 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6747 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6749 Stage::GetCurrent().Add( actor3 );
6750 actor3.Add( actor4 );
6751 actor4.Add( actor5 );
6752 actor5.Add( actor6 );
6753 actor5.Add( actor7 );
6754 actor7.Add( actor8 );
6755 actor8.Add( actor9 );
6756 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6757 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6759 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6760 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6761 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6763 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6765 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6766 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6767 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6768 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6769 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6770 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6771 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6773 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6774 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6775 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6777 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6778 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6779 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6780 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6782 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6783 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6784 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6790 struct LayoutDirectionFunctor
6792 LayoutDirectionFunctor(bool& signalCalled)
6793 : mSignalCalled( signalCalled )
6797 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6798 : mSignalCalled( rhs.mSignalCalled )
6804 mSignalCalled = true;
6807 bool& mSignalCalled;
6810 int UtcDaliActorLayoutDirectionSignal(void)
6812 TestApplication application;
6813 tet_infoline( "Check changing layout direction property sends a signal" );
6815 Actor actor = Actor::New();
6816 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6817 Stage::GetCurrent().Add( actor );
6818 bool signalCalled = false;
6819 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6821 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6822 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6824 // Test that writing the same value doesn't send a signal
6825 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6826 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6828 // Test that writing a different value sends the signal
6829 signalCalled = false;
6830 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6831 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6833 signalCalled = false;
6834 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6835 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6840 struct ChildAddedSignalCheck
6842 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6843 : mSignalReceived( signalReceived ),
6844 mChildHandle( childHandle )
6848 void operator() ( Actor childHandle )
6850 mSignalReceived = true;
6851 mChildHandle = childHandle;
6855 mSignalReceived = true;
6856 mChildHandle = Actor();
6859 bool& mSignalReceived;
6860 Actor& mChildHandle;
6863 int UtcDaliChildAddedSignalP1(void)
6865 TestApplication application;
6866 auto stage = Stage::GetCurrent();
6868 bool signalReceived=false;
6871 ChildAddedSignalCheck signal( signalReceived, childActor );
6872 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6873 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6875 auto actorA = Actor::New();
6876 stage.Add( actorA );
6877 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6878 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6879 signalReceived = false;
6881 auto actorB = Actor::New();
6882 stage.Add( actorB );
6883 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6884 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6890 int UtcDaliChildAddedSignalP2(void)
6892 TestApplication application;
6893 auto stage = Stage::GetCurrent();
6895 bool signalReceived=false;
6898 ChildAddedSignalCheck signal( signalReceived, childActor );
6899 tet_infoline( "Connect to childAdded signal by name" );
6901 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6902 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6904 auto actorA = Actor::New();
6905 stage.Add( actorA );
6906 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6908 // Can't test which actor was added; signal signature is void() when connecting via name.
6909 signalReceived = false;
6911 auto actorB = Actor::New();
6912 stage.Add( actorB );
6913 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6918 int UtcDaliChildAddedSignalN(void)
6920 TestApplication application;
6921 auto stage = Stage::GetCurrent();
6923 bool signalReceived=false;
6926 ChildAddedSignalCheck signal( signalReceived, childActor );
6927 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6928 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6930 auto actorA = Actor::New();
6931 stage.Add( actorA );
6932 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6933 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6934 signalReceived = false;
6936 auto actorB = Actor::New();
6937 actorA.Add( actorB );
6938 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6943 struct ChildRemovedSignalCheck
6945 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6946 : mSignalReceived( signalReceived ),
6947 mChildHandle( childHandle )
6951 void operator() ( Actor childHandle )
6953 mSignalReceived = true;
6954 mChildHandle = childHandle;
6959 mSignalReceived = true;
6962 bool& mSignalReceived;
6963 Actor& mChildHandle;
6966 int UtcDaliChildRemovedSignalP1(void)
6968 TestApplication application;
6969 auto stage = Stage::GetCurrent();
6971 bool signalReceived=false;
6974 ChildRemovedSignalCheck signal( signalReceived, childActor );
6975 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6976 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6978 auto actorA = Actor::New();
6979 stage.Add( actorA );
6980 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6981 DALI_TEST_CHECK( !childActor );
6983 stage.Remove( actorA );
6984 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6985 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6987 signalReceived = false;
6988 auto actorB = Actor::New();
6989 stage.Add( actorB );
6990 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6992 stage.Remove( actorB );
6993 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6994 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6999 int UtcDaliChildRemovedSignalP2(void)
7001 TestApplication application;
7002 auto stage = Stage::GetCurrent();
7004 bool signalReceived=false;
7007 ChildAddedSignalCheck signal( signalReceived, childActor );
7008 tet_infoline( "Connect to childRemoved signal by name" );
7010 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7011 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7013 auto actorA = Actor::New();
7014 stage.Add( actorA );
7015 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7017 stage.Remove( actorA );
7018 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7020 signalReceived = false;
7021 auto actorB = Actor::New();
7022 stage.Add( actorB );
7023 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7025 stage.Remove( actorB );
7026 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7032 int UtcDaliChildRemovedSignalN(void)
7034 TestApplication application;
7035 auto stage = Stage::GetCurrent();
7037 bool signalReceived=false;
7040 ChildRemovedSignalCheck signal( signalReceived, childActor );
7041 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7042 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7044 auto actorA = Actor::New();
7045 stage.Add( actorA );
7047 auto actorB = Actor::New();
7048 actorA.Add( actorB );
7050 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7051 DALI_TEST_CHECK( ! childActor );
7053 actorA.Remove( actorB );
7054 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7059 int UtcDaliChildMovedSignalP(void)
7061 TestApplication application;
7062 auto stage = Stage::GetCurrent();
7064 bool addedASignalReceived = false;
7065 bool removedASignalReceived = false;
7066 bool addedBSignalReceived = false;
7067 bool removedBSignalReceived = false;
7070 auto actorA = Actor::New();
7071 auto actorB = Actor::New();
7072 stage.Add( actorA );
7073 stage.Add( actorB );
7075 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7076 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7077 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7078 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7080 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7081 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7082 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7083 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7085 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7086 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7087 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7088 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7090 // Create a child of A
7092 auto child = Actor::New();
7093 actorA.Add( child );
7095 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7096 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7097 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7098 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7099 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7102 addedASignalReceived = false;
7103 addedBSignalReceived = false;
7104 removedASignalReceived = false;
7105 removedBSignalReceived = false;
7107 actorB.Add( child ); // Expect this child to be re-parented
7108 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7109 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7110 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7111 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7113 // Move child back to A:
7114 addedASignalReceived = false;
7115 addedBSignalReceived = false;
7116 removedASignalReceived = false;
7117 removedBSignalReceived = false;
7119 actorA.Add( child ); // Expect this child to be re-parented
7120 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7121 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7122 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7123 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7129 int utcDaliActorCulled(void)
7131 TestApplication application;
7132 auto stage = Stage::GetCurrent();
7134 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7136 Actor actor = Actor::New();
7137 actor.SetSize( 10.0f, 10.0f );
7139 Geometry geometry = CreateQuadGeometry();
7140 Shader shader = CreateShader();
7141 Renderer renderer = Renderer::New(geometry, shader);
7142 actor.AddRenderer( renderer );
7146 application.SendNotification();
7147 application.Render( 0 );
7149 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
7151 PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
7152 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7154 // Connect NotifySignal
7155 bool propertyNotificationSignal( false );
7156 PropertyNotification source;
7157 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7158 notification.NotifySignal().Connect( &application, f ) ;
7160 actor.SetPosition( 1000.0f, 1000.0f );
7162 application.SendNotification();
7163 application.Render();
7165 application.SendNotification();
7167 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
7169 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7170 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
7171 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7176 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7178 TestApplication application;
7179 auto stage = Stage::GetCurrent();
7181 tet_infoline( "Ensure we clear the screen when the last actor is removed" );
7183 Actor actor = CreateRenderableActor();
7184 actor.SetSize( 100.0f, 100.0f );
7187 application.SendNotification();
7188 application.Render();
7190 auto& glAbstraction = application.GetGlAbstraction();
7191 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7195 application.SendNotification();
7196 application.Render();
7198 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7203 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7205 TestApplication application;
7206 auto stage = Stage::GetCurrent();
7208 tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
7210 Actor actor = CreateRenderableActor();
7211 actor.SetSize( 100.0f, 100.0f );
7214 application.SendNotification();
7215 application.Render();
7217 auto& glAbstraction = application.GetGlAbstraction();
7218 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7220 actor.SetVisible( false );
7222 application.SendNotification();
7223 application.Render();
7225 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );