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 int UtcDaliActorCalculateScreenExtents(void)
1274 TestApplication application;
1276 Actor actor = Actor::New();
1278 actor.SetPosition(Vector3(2.0f, 2.0f, 16.0f));
1279 actor.SetSize(Vector3{ 1.0f, 1.0f, 1.0f });
1281 application.SendNotification();
1282 application.Render();
1284 auto expectedExtent = Rect<>{ -0.5f, -0.5f, 1.0f, 1.0f };
1285 auto actualExtent = DevelActor::CalculateScreenExtents( actor );
1286 DALI_TEST_EQUALS( expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1287 DALI_TEST_EQUALS( expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1288 DALI_TEST_EQUALS( expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1289 DALI_TEST_EQUALS( expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1291 Stage::GetCurrent().Remove( actor );
1295 // SetPosition(float x, float y)
1296 int UtcDaliActorSetPosition01(void)
1298 TestApplication application;
1300 Actor actor = Actor::New();
1302 // Set to random to start off with
1303 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1305 Vector3 vector(100.0f, 100.0f, 0.0f);
1307 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1309 actor.SetPosition(vector.x, vector.y);
1310 // flush the queue and render once
1311 application.SendNotification();
1312 application.Render();
1313 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1315 Stage::GetCurrent().Add( actor );
1316 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1317 // flush the queue and render once
1318 application.SendNotification();
1319 application.Render();
1320 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1325 // flush the queue and render once
1326 application.SendNotification();
1327 application.Render();
1328 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1330 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1331 // flush the queue and render once
1332 application.SendNotification();
1333 application.Render();
1334 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1336 Stage::GetCurrent().Remove( actor );
1340 // SetPosition(float x, float y, float z)
1341 int UtcDaliActorSetPosition02(void)
1343 TestApplication application;
1345 Actor actor = Actor::New();
1347 // Set to random to start off with
1348 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1350 Vector3 vector(100.0f, 100.0f, 100.0f);
1352 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1354 actor.SetPosition(vector.x, vector.y, vector.z);
1356 // flush the queue and render once
1357 application.SendNotification();
1358 application.Render();
1360 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1364 // SetPosition(Vector3 position)
1365 int UtcDaliActorSetPosition03(void)
1367 TestApplication application;
1369 Actor actor = Actor::New();
1371 // Set to random to start off with
1372 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1374 Vector3 vector(100.0f, 100.0f, 100.0f);
1376 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1378 actor.SetPosition(vector);
1380 // flush the queue and render once
1381 application.SendNotification();
1382 application.Render();
1384 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1388 int UtcDaliActorSetX(void)
1390 TestApplication application;
1392 Actor actor = Actor::New();
1394 Vector3 vector(100.0f, 0.0f, 0.0f);
1396 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1400 // flush the queue and render once
1401 application.SendNotification();
1402 application.Render();
1404 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1408 int UtcDaliActorSetY(void)
1410 TestApplication application;
1412 Actor actor = Actor::New();
1414 Vector3 vector(0.0f, 100.0f, 0.0f);
1416 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1420 // flush the queue and render once
1421 application.SendNotification();
1422 application.Render();
1424 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1428 int UtcDaliActorSetZ(void)
1430 TestApplication application;
1432 Actor actor = Actor::New();
1434 Vector3 vector(0.0f, 0.0f, 100.0f);
1436 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1440 // flush the queue and render once
1441 application.SendNotification();
1442 application.Render();
1444 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1448 int UtcDaliActorSetPositionProperties(void)
1450 TestApplication application;
1452 Actor actor = Actor::New();
1454 Vector3 vector(0.7f, 0.8f, 0.9f);
1455 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1457 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1458 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1459 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1461 // flush the queue and render once
1462 application.SendNotification();
1463 application.Render();
1465 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1466 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1467 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1468 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1469 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1471 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1472 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1473 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1475 // flush the queue and render once
1476 application.SendNotification();
1477 application.Render();
1479 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1480 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1481 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1482 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1483 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1485 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1486 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1487 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1489 // flush the queue and render once
1490 application.SendNotification();
1491 application.Render();
1493 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1494 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1495 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1496 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1497 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1502 int UtcDaliActorTranslateBy(void)
1504 TestApplication application;
1506 Actor actor = Actor::New();
1507 Vector3 vector(100.0f, 100.0f, 100.0f);
1509 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1511 actor.SetPosition(vector);
1513 // flush the queue and render once
1514 application.SendNotification();
1515 application.Render();
1517 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1519 actor.TranslateBy(vector);
1521 // flush the queue and render once
1522 application.SendNotification();
1523 application.Render();
1525 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1529 int UtcDaliActorGetCurrentPosition(void)
1531 TestApplication application;
1533 Actor actor = Actor::New();
1534 Vector3 setVector(100.0f, 100.0f, 0.0f);
1535 actor.SetPosition(setVector);
1537 // flush the queue and render once
1538 application.SendNotification();
1539 application.Render();
1541 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1545 int UtcDaliActorGetCurrentWorldPosition(void)
1547 TestApplication application;
1549 Actor parent = Actor::New();
1550 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1551 parent.SetPosition( parentPosition );
1552 parent.SetParentOrigin( ParentOrigin::CENTER );
1553 parent.SetAnchorPoint( AnchorPoint::CENTER );
1554 Stage::GetCurrent().Add( parent );
1556 Actor child = Actor::New();
1557 child.SetParentOrigin( ParentOrigin::CENTER );
1558 child.SetAnchorPoint( AnchorPoint::CENTER );
1559 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1560 child.SetPosition( childPosition );
1561 parent.Add( child );
1563 // The actors should not have a world position yet
1564 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1565 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1567 application.SendNotification();
1568 application.Render(0);
1570 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1571 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1573 // The actors should have a world position now
1574 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1575 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1579 int UtcDaliActorSetInheritPosition(void)
1581 tet_infoline("Testing Actor::SetInheritPosition");
1582 TestApplication application;
1584 Actor parent = Actor::New();
1585 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1586 parent.SetPosition( parentPosition );
1587 parent.SetParentOrigin( ParentOrigin::CENTER );
1588 parent.SetAnchorPoint( AnchorPoint::CENTER );
1589 Stage::GetCurrent().Add( parent );
1591 Actor child = Actor::New();
1592 child.SetParentOrigin( ParentOrigin::CENTER );
1593 child.SetAnchorPoint( AnchorPoint::CENTER );
1594 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1595 child.SetPosition( childPosition );
1596 parent.Add( child );
1598 // The actors should not have a world position yet
1599 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1600 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1602 // first test default, which is to inherit position
1603 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1604 application.SendNotification();
1605 application.Render(0); // should only really call Update as Render is not required to update scene
1606 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1607 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1608 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1609 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1611 //Change child position
1612 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1613 child.SetPosition( childOffset );
1615 // Use local position as world postion
1616 child.SetInheritPosition( false );
1617 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1618 application.SendNotification();
1619 application.Render(0); // should only really call Update as Render is not required to update scene
1620 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1621 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1622 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1623 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1625 //Change back to inherit position from parent
1626 child.SetInheritPosition( true );
1627 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1628 application.SendNotification();
1629 application.Render(0); // should only really call Update as Render is not required to update scene
1630 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1631 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1632 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1633 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1637 int UtcDaliActorInheritOpacity(void)
1639 tet_infoline("Testing Actor::Inherit Opacity");
1640 TestApplication application;
1642 Actor parent = Actor::New();
1643 Actor child = Actor::New();
1644 parent.Add( child );
1645 Stage::GetCurrent().Add( parent );
1647 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1648 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1650 // flush the queue and render once
1651 application.SendNotification();
1652 application.Render();
1654 parent.SetOpacity( 0.1f );
1656 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1657 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1659 application.SendNotification();
1660 application.Render();
1662 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1663 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1664 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1665 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1666 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1667 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1672 // SetOrientation(float angleRadians, Vector3 axis)
1673 int UtcDaliActorSetOrientation01(void)
1675 TestApplication application;
1677 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1678 Actor actor = Actor::New();
1680 actor.SetOrientation(rotation);
1682 // flush the queue and render once
1683 application.SendNotification();
1684 application.Render();
1686 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1690 int UtcDaliActorSetOrientation02(void)
1692 TestApplication application;
1694 Actor actor = Actor::New();
1696 Radian angle( 0.785f );
1697 Vector3 axis(1.0f, 1.0f, 0.0f);
1699 actor.SetOrientation( angle, axis);
1700 Quaternion rotation( angle, axis );
1701 // flush the queue and render once
1702 application.SendNotification();
1703 application.Render();
1704 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1706 Stage::GetCurrent().Add( actor );
1707 actor.RotateBy( Degree( 360 ), axis);
1708 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1710 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1711 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1712 // flush the queue and render once
1713 application.SendNotification();
1714 application.Render();
1715 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1717 actor.SetOrientation( angle, axis);
1718 // flush the queue and render once
1719 application.SendNotification();
1720 application.Render();
1721 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1723 Stage::GetCurrent().Remove( actor );
1727 // SetOrientation(float angleRadians, Vector3 axis)
1728 int UtcDaliActorSetOrientationProperty(void)
1730 TestApplication application;
1732 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1733 Actor actor = Actor::New();
1735 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1736 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1738 // flush the queue and render once
1739 application.SendNotification();
1740 application.Render();
1742 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1743 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1744 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1748 // RotateBy(float angleRadians, Vector3 axis)
1749 int UtcDaliActorRotateBy01(void)
1751 TestApplication application;
1753 Actor actor = Actor::New();
1755 Radian angle( M_PI * 0.25f );
1756 actor.RotateBy(( angle ), Vector3::ZAXIS);
1757 // flush the queue and render once
1758 application.SendNotification();
1759 application.Render();
1760 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1762 Stage::GetCurrent().Add( actor );
1764 actor.RotateBy( angle, Vector3::ZAXIS);
1765 // flush the queue and render once
1766 application.SendNotification();
1767 application.Render();
1768 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1770 Stage::GetCurrent().Remove( actor );
1774 // RotateBy(Quaternion relativeRotation)
1775 int UtcDaliActorRotateBy02(void)
1777 TestApplication application;
1779 Actor actor = Actor::New();
1781 Radian angle( M_PI * 0.25f );
1782 Quaternion rotation(angle, Vector3::ZAXIS);
1783 actor.RotateBy(rotation);
1784 // flush the queue and render once
1785 application.SendNotification();
1786 application.Render();
1787 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1789 actor.RotateBy(rotation);
1790 // flush the queue and render once
1791 application.SendNotification();
1792 application.Render();
1793 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1797 int UtcDaliActorGetCurrentOrientation(void)
1799 TestApplication application;
1800 Actor actor = Actor::New();
1802 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1803 actor.SetOrientation(rotation);
1804 // flush the queue and render once
1805 application.SendNotification();
1806 application.Render();
1807 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1811 int UtcDaliActorGetCurrentWorldOrientation(void)
1813 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1814 TestApplication application;
1816 Actor parent = Actor::New();
1817 Radian rotationAngle( Degree(90.0f) );
1818 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1819 parent.SetOrientation( rotation );
1820 Stage::GetCurrent().Add( parent );
1822 Actor child = Actor::New();
1823 child.SetOrientation( rotation );
1824 parent.Add( child );
1826 // The actors should not have a world rotation yet
1827 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1828 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1830 application.SendNotification();
1831 application.Render(0);
1833 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1834 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1836 // The actors should have a world rotation now
1837 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1838 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1840 // turn off child rotation inheritance
1841 child.SetInheritOrientation( false );
1842 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1843 application.SendNotification();
1844 application.Render(0);
1846 // The actors should have a world rotation now
1847 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1848 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1852 // SetScale(float scale)
1853 int UtcDaliActorSetScale01(void)
1855 TestApplication application;
1857 Actor actor = Actor::New();
1859 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1860 actor.SetScale(0.25f);
1862 Vector3 scale(10.0f, 10.0f, 10.0f);
1863 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1865 actor.SetScale(scale.x);
1867 // flush the queue and render once
1868 application.SendNotification();
1869 application.Render();
1871 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1875 // SetScale(float scaleX, float scaleY, float scaleZ)
1876 int UtcDaliActorSetScale02(void)
1878 TestApplication application;
1879 Vector3 scale(10.0f, 10.0f, 10.0f);
1881 Actor actor = Actor::New();
1883 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1884 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1886 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1888 actor.SetScale(scale.x, scale.y, scale.z);
1889 // flush the queue and render once
1890 application.SendNotification();
1891 application.Render();
1892 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1894 // add to stage and test
1895 Stage::GetCurrent().Add( actor );
1896 actor.SetScale( 2.0f, 2.0f, 2.0f );
1897 // flush the queue and render once
1898 application.SendNotification();
1899 application.Render();
1900 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1902 Stage::GetCurrent().Remove( actor );
1907 // SetScale(Vector3 scale)
1908 int UtcDaliActorSetScale03(void)
1910 TestApplication application;
1911 Vector3 scale(10.0f, 10.0f, 10.0f);
1913 Actor actor = Actor::New();
1915 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1916 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1918 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1920 actor.SetScale(scale);
1922 // flush the queue and render once
1923 application.SendNotification();
1924 application.Render();
1926 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1930 int UtcDaliActorSetScaleIndividual(void)
1932 TestApplication application;
1934 Actor actor = Actor::New();
1936 Vector3 vector(0.7f, 0.8f, 0.9f);
1937 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1939 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1940 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1942 // flush the queue and render once
1943 application.SendNotification();
1944 application.Render();
1946 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1947 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1948 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1950 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1951 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1953 // flush the queue and render once
1954 application.SendNotification();
1955 application.Render();
1957 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1958 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1959 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1961 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1962 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1964 // flush the queue and render once
1965 application.SendNotification();
1966 application.Render();
1968 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1969 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1970 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1972 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1973 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1978 int UtcDaliActorScaleBy(void)
1980 TestApplication application;
1981 Actor actor = Actor::New();
1982 Vector3 vector(100.0f, 100.0f, 100.0f);
1984 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1986 actor.SetScale(vector);
1988 // flush the queue and render once
1989 application.SendNotification();
1990 application.Render();
1992 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1994 actor.ScaleBy(vector);
1996 // flush the queue and render once
1997 application.SendNotification();
1998 application.Render();
2000 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
2004 int UtcDaliActorGetCurrentScale(void)
2006 TestApplication application;
2007 Vector3 scale(12.0f, 1.0f, 2.0f);
2009 Actor actor = Actor::New();
2011 actor.SetScale(scale);
2013 // flush the queue and render once
2014 application.SendNotification();
2015 application.Render();
2017 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
2021 int UtcDaliActorGetCurrentWorldScale(void)
2023 TestApplication application;
2025 Actor parent = Actor::New();
2026 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2027 parent.SetScale( parentScale );
2028 Stage::GetCurrent().Add( parent );
2030 Actor child = Actor::New();
2031 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2032 child.SetScale( childScale );
2033 parent.Add( child );
2035 // The actors should not have a scale yet
2036 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2037 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2039 // The actors should not have a world scale yet
2040 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2041 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2043 application.SendNotification();
2044 application.Render(0);
2046 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2047 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2049 // The actors should have a world scale now
2050 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2051 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2055 int UtcDaliActorInheritScale(void)
2057 tet_infoline("Testing Actor::SetInheritScale");
2058 TestApplication application;
2060 Actor parent = Actor::New();
2061 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2062 parent.SetScale( parentScale );
2063 Stage::GetCurrent().Add( parent );
2065 Actor child = Actor::New();
2066 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2067 child.SetScale( childScale );
2068 parent.Add( child );
2070 application.SendNotification();
2071 application.Render(0);
2073 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2074 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2076 child.SetInheritScale( false );
2077 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2079 application.SendNotification();
2080 application.Render(0);
2082 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2086 int UtcDaliActorSetVisible(void)
2088 TestApplication application;
2090 Actor actor = Actor::New();
2091 actor.SetVisible(false);
2092 // flush the queue and render once
2093 application.SendNotification();
2094 application.Render();
2095 DALI_TEST_CHECK(actor.IsVisible() == false);
2097 actor.SetVisible(true);
2098 // flush the queue and render once
2099 application.SendNotification();
2100 application.Render();
2101 DALI_TEST_CHECK(actor.IsVisible() == true);
2103 // put actor on stage
2104 Stage::GetCurrent().Add( actor );
2105 actor.SetVisible(false);
2106 // flush the queue and render once
2107 application.SendNotification();
2108 application.Render();
2109 DALI_TEST_CHECK(actor.IsVisible() == false);
2113 int UtcDaliActorIsVisible(void)
2115 TestApplication application;
2117 Actor actor = Actor::New();
2119 DALI_TEST_CHECK(actor.IsVisible() == true);
2123 int UtcDaliActorSetOpacity(void)
2125 TestApplication application;
2127 Actor actor = Actor::New();
2128 // initial opacity is 1
2129 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2131 actor.SetOpacity( 0.4f);
2132 // flush the queue and render once
2133 application.SendNotification();
2134 application.Render();
2135 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2137 // change opacity, actor is on stage to change is not immediate
2138 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2139 // flush the queue and render once
2140 application.SendNotification();
2141 application.Render();
2142 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2144 // put actor on stage
2145 Stage::GetCurrent().Add( actor );
2147 // change opacity, actor is on stage to change is not immediate
2148 actor.SetOpacity( 0.9f );
2149 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2150 // flush the queue and render once
2151 application.SendNotification();
2152 application.Render();
2153 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2155 // change opacity, actor is on stage to change is not immediate
2156 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2157 // flush the queue and render once
2158 application.SendNotification();
2159 application.Render();
2160 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2164 int UtcDaliActorGetCurrentOpacity(void)
2166 TestApplication application;
2168 Actor actor = Actor::New();
2169 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2171 actor.SetOpacity(0.5f);
2172 // flush the queue and render once
2173 application.SendNotification();
2174 application.Render();
2175 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2179 int UtcDaliActorSetSensitive(void)
2181 TestApplication application;
2182 Actor actor = Actor::New();
2184 bool sensitive = !actor.IsSensitive();
2186 actor.SetSensitive(sensitive);
2188 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2192 int UtcDaliActorIsSensitive(void)
2194 TestApplication application;
2195 Actor actor = Actor::New();
2196 actor.SetSensitive(false);
2198 DALI_TEST_CHECK(false == actor.IsSensitive());
2202 int UtcDaliActorSetColor(void)
2204 TestApplication application;
2205 Actor actor = Actor::New();
2206 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2208 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2210 actor.SetColor(color);
2211 // flush the queue and render once
2212 application.SendNotification();
2213 application.Render();
2214 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2216 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2217 // flush the queue and render once
2218 application.SendNotification();
2219 application.Render();
2220 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2222 Stage::GetCurrent().Add( actor );
2223 actor.SetColor( color );
2224 // flush the queue and render once
2225 application.SendNotification();
2226 application.Render();
2227 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2229 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2230 // flush the queue and render once
2231 application.SendNotification();
2232 application.Render();
2233 // Actor color is not clamped
2234 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2235 // world color is clamped
2236 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2238 actor.SetProperty( Actor::Property::COLOR, color );
2239 DALI_TEST_EQUALS( color, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2241 Vector3 newColor( 1.0f, 0.0f, 0.0f );
2242 actor.SetProperty( Actor::Property::COLOR, newColor );
2243 DALI_TEST_EQUALS( Vector4( newColor.r, newColor.g, newColor.b, 1.0f ), actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2245 Stage::GetCurrent().Remove( actor );
2249 int UtcDaliActorSetColorIndividual(void)
2251 TestApplication application;
2253 Actor actor = Actor::New();
2255 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2256 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2258 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2259 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2261 // flush the queue and render once
2262 application.SendNotification();
2263 application.Render();
2265 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2266 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2267 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2269 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2270 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2272 // flush the queue and render once
2273 application.SendNotification();
2274 application.Render();
2276 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2277 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2278 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2280 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2281 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2283 // flush the queue and render once
2284 application.SendNotification();
2285 application.Render();
2287 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2288 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2289 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2292 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2293 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2295 // flush the queue and render once
2296 application.SendNotification();
2297 application.Render();
2299 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2300 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2301 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2303 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2304 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2306 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2309 // flush the queue and render once
2310 application.SendNotification();
2311 application.Render();
2313 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2319 int UtcDaliActorGetCurrentColor(void)
2321 TestApplication application;
2322 Actor actor = Actor::New();
2323 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2325 actor.SetColor(color);
2326 // flush the queue and render once
2327 application.SendNotification();
2328 application.Render();
2329 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2333 int UtcDaliActorGetCurrentWorldColor(void)
2335 tet_infoline("Actor::GetCurrentWorldColor");
2336 TestApplication application;
2338 Actor parent = Actor::New();
2339 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2340 parent.SetColor( parentColor );
2341 Stage::GetCurrent().Add( parent );
2343 Actor child = Actor::New();
2344 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2345 child.SetColor( childColor );
2346 parent.Add( child );
2348 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2349 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2351 // verify the default color mode
2352 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2354 // The actors should not have a world color yet
2355 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2356 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2358 application.SendNotification();
2359 application.Render(0);
2361 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2362 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2364 // The actors should have a world color now
2365 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2366 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2369 child.SetColorMode( USE_OWN_COLOR );
2370 application.SendNotification();
2371 application.Render(0);
2372 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2375 child.SetColorMode( USE_PARENT_COLOR );
2376 application.SendNotification();
2377 application.Render(0);
2378 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2379 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2382 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2383 application.SendNotification();
2384 application.Render(0);
2385 Vector4 expectedColor( childColor );
2386 expectedColor.a *= parentColor.a;
2387 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2388 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2392 int UtcDaliActorSetColorMode(void)
2394 tet_infoline("Actor::SetColorMode");
2395 TestApplication application;
2396 Actor actor = Actor::New();
2397 Actor child = Actor::New();
2400 actor.SetColorMode( USE_OWN_COLOR );
2401 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2403 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2404 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2406 actor.SetColorMode( USE_PARENT_COLOR );
2407 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2409 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2410 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2414 int UtcDaliActorScreenToLocal(void)
2416 TestApplication application;
2417 Actor actor = Actor::New();
2418 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2419 actor.SetSize(100.0f, 100.0f);
2420 actor.SetPosition(10.0f, 10.0f);
2421 Stage::GetCurrent().Add(actor);
2423 // flush the queue and render once
2424 application.SendNotification();
2425 application.Render();
2430 application.SendNotification();
2431 application.Render();
2433 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2435 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2436 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2440 int UtcDaliActorSetLeaveRequired(void)
2442 TestApplication application;
2444 Actor actor = Actor::New();
2446 actor.SetLeaveRequired(false);
2447 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2449 actor.SetLeaveRequired(true);
2450 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2454 int UtcDaliActorGetLeaveRequired(void)
2456 TestApplication application;
2458 Actor actor = Actor::New();
2460 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2464 int UtcDaliActorSetKeyboardFocusable(void)
2466 TestApplication application;
2468 Actor actor = Actor::New();
2470 actor.SetKeyboardFocusable(true);
2471 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2473 actor.SetKeyboardFocusable(false);
2474 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2478 int UtcDaliActorIsKeyboardFocusable(void)
2480 TestApplication application;
2482 Actor actor = Actor::New();
2484 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2488 int UtcDaliActorRemoveConstraints(void)
2490 tet_infoline(" UtcDaliActorRemoveConstraints");
2491 TestApplication application;
2493 gTestConstraintCalled = false;
2495 Actor actor = Actor::New();
2497 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2499 actor.RemoveConstraints();
2501 DALI_TEST_CHECK( gTestConstraintCalled == false );
2503 Stage::GetCurrent().Add( actor );
2506 // flush the queue and render once
2507 application.SendNotification();
2508 application.Render();
2510 actor.RemoveConstraints();
2512 DALI_TEST_CHECK( gTestConstraintCalled == true );
2516 int UtcDaliActorRemoveConstraintTag(void)
2518 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2519 TestApplication application;
2521 Actor actor = Actor::New();
2523 // 1. Apply Constraint1 and Constraint2, and test...
2524 unsigned int result1 = 0u;
2525 unsigned int result2 = 0u;
2527 unsigned constraint1Tag = 1u;
2528 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2529 constraint1.SetTag( constraint1Tag );
2530 constraint1.Apply();
2532 unsigned constraint2Tag = 2u;
2533 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2534 constraint2.SetTag( constraint2Tag );
2535 constraint2.Apply();
2537 Stage::GetCurrent().Add( actor );
2538 // flush the queue and render once
2539 application.SendNotification();
2540 application.Render();
2542 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2543 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2545 // 2. Remove Constraint1 and test...
2548 actor.RemoveConstraints(constraint1Tag);
2549 // make color property dirty, which will trigger constraints to be reapplied.
2550 actor.SetColor( Color::WHITE );
2551 // flush the queue and render once
2552 application.SendNotification();
2553 application.Render();
2555 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2556 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2558 // 3. Re-Apply Constraint1 and test...
2561 constraint1.Apply();
2562 // make color property dirty, which will trigger constraints to be reapplied.
2563 actor.SetColor( Color::WHITE );
2564 // flush the queue and render once
2565 application.SendNotification();
2566 application.Render();
2568 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2569 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2571 // 2. Remove Constraint2 and test...
2574 actor.RemoveConstraints(constraint2Tag);
2575 // make color property dirty, which will trigger constraints to be reapplied.
2576 actor.SetColor( Color::WHITE );
2577 // flush the queue and render once
2578 application.SendNotification();
2579 application.Render();
2581 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2582 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2584 // 2. Remove Constraint1 as well and test...
2587 actor.RemoveConstraints(constraint1Tag);
2588 // make color property dirty, which will trigger constraints to be reapplied.
2589 actor.SetColor( Color::WHITE );
2590 // flush the queue and render once
2591 application.SendNotification();
2592 application.Render();
2594 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2595 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2599 int UtcDaliActorTouchedSignal(void)
2601 TestApplication application;
2603 ResetTouchCallbacks();
2605 // get the root layer
2606 Actor actor = Stage::GetCurrent().GetRootLayer();
2607 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2609 application.SendNotification();
2610 application.Render();
2612 // connect to its touch signal
2613 actor.TouchedSignal().Connect( TestCallback );
2615 // simulate a touch 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::DOWN );
2620 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2621 Dali::Integration::TouchEvent touchEvent;
2622 touchEvent.AddPoint( point );
2623 application.ProcessEvent( touchEvent );
2625 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2629 int UtcDaliActorHoveredSignal(void)
2631 TestApplication application;
2633 gHoverCallBackCalled = false;
2635 // get the root layer
2636 Actor actor = Stage::GetCurrent().GetRootLayer();
2637 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2639 application.SendNotification();
2640 application.Render();
2642 // connect to its hover signal
2643 actor.HoveredSignal().Connect( TestCallback3 );
2645 // simulate a hover event in the middle of the screen
2646 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2647 Dali::Integration::Point point;
2648 point.SetDeviceId( 1 );
2649 point.SetState( PointState::MOTION );
2650 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2651 Dali::Integration::HoverEvent hoverEvent;
2652 hoverEvent.AddPoint( point );
2653 application.ProcessEvent( hoverEvent );
2655 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2659 int UtcDaliActorOnOffStageSignal(void)
2661 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2663 TestApplication application;
2666 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2667 gActorNamesOnOffStage.clear();
2669 Actor parent = Actor::New();
2670 parent.SetName( "parent" );
2671 parent.OnStageSignal().Connect( OnStageCallback );
2672 parent.OffStageSignal().Connect( OffStageCallback );
2674 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2675 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2677 // add parent to stage
2678 Stage::GetCurrent().Add( parent );
2679 // onstage emitted, offstage not
2680 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2681 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2682 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2684 // test adding a child, should get onstage emitted
2686 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2687 gActorNamesOnOffStage.clear();
2689 Actor child = Actor::New();
2690 child.SetName( "child" );
2691 child.OnStageSignal().Connect( OnStageCallback );
2692 child.OffStageSignal().Connect( OffStageCallback );
2693 parent.Add( child ); // add child
2694 // onstage emitted, offstage not
2695 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2696 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2697 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2699 // test removing parent from stage
2701 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2702 gActorNamesOnOffStage.clear();
2704 Stage::GetCurrent().Remove( parent );
2705 // onstage not emitted, offstage is
2706 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2707 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2708 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2709 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2711 // test adding parent back to stage
2713 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2714 gActorNamesOnOffStage.clear();
2716 Stage::GetCurrent().Add( parent );
2717 // onstage emitted, offstage not
2718 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2719 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2720 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2721 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2723 // test removing child
2725 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2726 gActorNamesOnOffStage.clear();
2728 parent.Remove( child );
2729 // onstage not emitted, offstage is
2730 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2731 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2732 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2734 // test removing parent
2736 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2737 gActorNamesOnOffStage.clear();
2739 Stage::GetCurrent().Remove( parent );
2740 // onstage not emitted, offstage is
2741 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2742 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2743 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2747 int UtcDaliActorFindChildByName(void)
2749 tet_infoline("Testing Dali::Actor::FindChildByName()");
2750 TestApplication application;
2752 Actor parent = Actor::New();
2753 parent.SetName( "parent" );
2754 Actor first = Actor::New();
2755 first .SetName( "first" );
2756 Actor second = Actor::New();
2757 second.SetName( "second" );
2762 Actor found = parent.FindChildByName( "foo" );
2763 DALI_TEST_CHECK( !found );
2765 found = parent.FindChildByName( "parent" );
2766 DALI_TEST_CHECK( found == parent );
2768 found = parent.FindChildByName( "first" );
2769 DALI_TEST_CHECK( found == first );
2771 found = parent.FindChildByName( "second" );
2772 DALI_TEST_CHECK( found == second );
2776 int UtcDaliActorFindChildById(void)
2778 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2779 TestApplication application;
2781 Actor parent = Actor::New();
2782 Actor first = Actor::New();
2783 Actor second = Actor::New();
2788 Actor found = parent.FindChildById( 100000 );
2789 DALI_TEST_CHECK( !found );
2791 found = parent.FindChildById( parent.GetId() );
2792 DALI_TEST_CHECK( found == parent );
2794 found = parent.FindChildById( first.GetId() );
2795 DALI_TEST_CHECK( found == first );
2797 found = parent.FindChildById( second.GetId() );
2798 DALI_TEST_CHECK( found == second );
2802 int UtcDaliActorHitTest(void)
2807 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2809 mTouchPoint( touchPoint ),
2814 Vector2 mTouchPoint;
2818 TestApplication application;
2819 tet_infoline(" UtcDaliActorHitTest");
2821 // Fill a vector with different hit tests.
2822 struct HitTestData* hitTestData[] = {
2823 // scale touch point result
2824 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2825 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2826 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.
2827 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2828 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.
2832 // get the root layer
2833 Actor actor = Actor::New();
2834 actor.SetAnchorPoint( AnchorPoint::CENTER );
2835 actor.SetParentOrigin( ParentOrigin::CENTER );
2837 Stage::GetCurrent().Add( actor );
2839 ResetTouchCallbacks();
2841 unsigned int index = 0;
2842 while( NULL != hitTestData[index] )
2844 actor.SetSize( 1.f, 1.f );
2845 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2847 // flush the queue and render once
2848 application.SendNotification();
2849 application.Render();
2851 DALI_TEST_CHECK( !gTouchCallBackCalled );
2853 // connect to its touch signal
2854 actor.TouchedSignal().Connect(TestCallback);
2856 Dali::Integration::Point point;
2857 point.SetState( PointState::DOWN );
2858 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2859 Dali::Integration::TouchEvent event;
2860 event.AddPoint( point );
2862 // flush the queue and render once
2863 application.SendNotification();
2864 application.Render();
2865 application.ProcessEvent( event );
2867 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2869 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2870 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2871 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2872 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2873 hitTestData[index]->mResult );
2875 ResetTouchCallbacks();
2881 int UtcDaliActorSetDrawMode(void)
2883 TestApplication app;
2884 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2886 Actor a = Actor::New();
2888 Stage::GetCurrent().Add(a);
2889 app.SendNotification();
2891 app.SendNotification();
2894 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2896 a.SetDrawMode( DrawMode::OVERLAY_2D );
2897 app.SendNotification();
2900 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2902 a.SetDrawMode( DrawMode::NORMAL );
2903 app.SendNotification();
2906 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2910 int UtcDaliActorSetDrawModeOverlayRender(void)
2912 TestApplication app;
2913 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2915 app.SendNotification();
2918 std::vector<GLuint> ids;
2919 ids.push_back( 8 ); // first rendered actor
2920 ids.push_back( 9 ); // second rendered actor
2921 ids.push_back( 10 ); // third rendered actor
2922 app.GetGlAbstraction().SetNextTextureIds( ids );
2924 BufferImage imageA = BufferImage::New(16, 16);
2925 BufferImage imageB = BufferImage::New(16, 16);
2926 BufferImage imageC = BufferImage::New(16, 16);
2927 Actor a = CreateRenderableActor( imageA );
2928 Actor b = CreateRenderableActor( imageB );
2929 Actor c = CreateRenderableActor( imageC );
2931 app.SendNotification();
2934 //Textures are bound when first created. Clear bound textures vector
2935 app.GetGlAbstraction().ClearBoundTextures();
2937 // Render a,b,c as regular non-overlays. so order will be:
2941 Stage::GetCurrent().Add(a);
2942 Stage::GetCurrent().Add(b);
2943 Stage::GetCurrent().Add(c);
2945 app.SendNotification();
2948 // Should be 3 textures changes.
2949 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2950 typedef std::vector<GLuint>::size_type TextureSize;
2951 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2952 if( boundTextures.size() == 3 )
2954 DALI_TEST_CHECK( boundTextures[0] == 8u );
2955 DALI_TEST_CHECK( boundTextures[1] == 9u );
2956 DALI_TEST_CHECK( boundTextures[2] == 10u );
2959 // Now texture ids have been set, we can monitor their render order.
2960 // render a as an overlay (last), so order will be:
2964 a.SetDrawMode( DrawMode::OVERLAY_2D );
2965 app.GetGlAbstraction().ClearBoundTextures();
2967 app.SendNotification();
2970 // Should be 3 texture changes.
2971 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2972 if( boundTextures.size() == 3 )
2974 DALI_TEST_CHECK( boundTextures[0] == 9u );
2975 DALI_TEST_CHECK( boundTextures[1] == 10u );
2976 DALI_TEST_CHECK( boundTextures[2] == 8u );
2981 int UtcDaliActorGetCurrentWorldMatrix(void)
2983 TestApplication app;
2984 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2986 Actor parent = Actor::New();
2987 parent.SetParentOrigin(ParentOrigin::CENTER);
2988 parent.SetAnchorPoint(AnchorPoint::CENTER);
2989 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2990 Radian rotationAngle(Degree(85.0f));
2991 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2992 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2993 parent.SetPosition( parentPosition );
2994 parent.SetOrientation( parentRotation );
2995 parent.SetScale( parentScale );
2996 Stage::GetCurrent().Add( parent );
2998 Actor child = Actor::New();
2999 child.SetParentOrigin(ParentOrigin::CENTER);
3000 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
3001 Radian childRotationAngle(Degree(23.0f));
3002 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
3003 Vector3 childScale( 2.0f, 2.0f, 2.0f );
3004 child.SetPosition( childPosition );
3005 child.SetOrientation( childRotation );
3006 child.SetScale( childScale );
3007 parent.Add( child );
3009 app.SendNotification();
3012 app.SendNotification();
3014 Matrix parentMatrix(false);
3015 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3017 Matrix childMatrix(false);
3018 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3020 //Child matrix should be the composition of child and parent
3021 Matrix childWorldMatrix(false);
3022 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3024 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3025 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
3031 int UtcDaliActorConstrainedToWorldMatrix(void)
3033 TestApplication app;
3034 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3036 Actor parent = Actor::New();
3037 parent.SetParentOrigin(ParentOrigin::CENTER);
3038 parent.SetAnchorPoint(AnchorPoint::CENTER);
3039 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3040 Radian rotationAngle(Degree(85.0f));
3041 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3042 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3043 parent.SetPosition( parentPosition );
3044 parent.SetOrientation( parentRotation );
3045 parent.SetScale( parentScale );
3046 Stage::GetCurrent().Add( parent );
3048 Actor child = Actor::New();
3049 child.SetParentOrigin(ParentOrigin::CENTER);
3050 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3051 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3052 posConstraint.Apply();
3054 Stage::GetCurrent().Add( child );
3056 app.SendNotification();
3059 app.SendNotification();
3061 Matrix parentMatrix(false);
3062 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3064 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3065 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3069 int UtcDaliActorConstrainedToOrientation(void)
3071 TestApplication app;
3072 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3074 Actor parent = Actor::New();
3075 parent.SetParentOrigin(ParentOrigin::CENTER);
3076 parent.SetAnchorPoint(AnchorPoint::CENTER);
3077 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3078 Radian rotationAngle(Degree(85.0f));
3079 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3080 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3081 parent.SetPosition( parentPosition );
3082 parent.SetOrientation( parentRotation );
3083 parent.SetScale( parentScale );
3084 Stage::GetCurrent().Add( parent );
3086 Actor child = Actor::New();
3087 child.SetParentOrigin(ParentOrigin::CENTER);
3088 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3089 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3090 posConstraint.Apply();
3092 Stage::GetCurrent().Add( child );
3094 app.SendNotification();
3097 app.SendNotification();
3099 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3103 int UtcDaliActorConstrainedToOpacity(void)
3105 TestApplication app;
3106 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3108 Actor parent = Actor::New();
3109 parent.SetOpacity( 0.7f );
3110 Stage::GetCurrent().Add( parent );
3112 Actor child = Actor::New();
3113 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3114 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3115 opacityConstraint.Apply();
3117 Stage::GetCurrent().Add( child );
3119 app.SendNotification();
3122 app.SendNotification();
3124 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3126 parent.SetOpacity( 0.3f );
3128 app.SendNotification();
3131 app.SendNotification();
3133 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3138 int UtcDaliActorUnparent(void)
3140 TestApplication app;
3141 tet_infoline(" UtcDaliActorUnparent");
3143 Actor parent = Actor::New();
3144 Stage::GetCurrent().Add( parent );
3146 Actor child = Actor::New();
3148 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3149 DALI_TEST_CHECK( !child.GetParent() );
3151 // Test that calling Unparent with no parent is a NOOP
3154 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3155 DALI_TEST_CHECK( !child.GetParent() );
3157 // Test that Unparent works
3158 parent.Add( child );
3160 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3161 DALI_TEST_CHECK( parent == child.GetParent() );
3165 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3166 DALI_TEST_CHECK( !child.GetParent() );
3168 // Test that UnparentAndReset works
3169 parent.Add( child );
3171 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3172 DALI_TEST_CHECK( parent == child.GetParent() );
3174 UnparentAndReset( child );
3176 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3177 DALI_TEST_CHECK( !child );
3179 // Test that UnparentAndReset is a NOOP with empty handle
3180 UnparentAndReset( child );
3182 DALI_TEST_CHECK( !child );
3186 int UtcDaliActorGetChildAt(void)
3188 TestApplication app;
3189 tet_infoline(" UtcDaliActorGetChildAt");
3191 Actor parent = Actor::New();
3192 Stage::GetCurrent().Add( parent );
3194 Actor child0 = Actor::New();
3195 parent.Add( child0 );
3197 Actor child1 = Actor::New();
3198 parent.Add( child1 );
3200 Actor child2 = Actor::New();
3201 parent.Add( child2 );
3203 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3204 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3205 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3209 int UtcDaliActorSetGetOverlay(void)
3211 TestApplication app;
3212 tet_infoline(" UtcDaliActorSetGetOverlay");
3214 Actor parent = Actor::New();
3215 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3216 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3221 int UtcDaliActorCreateDestroy(void)
3223 Actor* actor = new Actor;
3224 DALI_TEST_CHECK( actor );
3231 struct PropertyStringIndex
3233 const char * const name;
3234 const Property::Index index;
3235 const Property::Type type;
3238 const PropertyStringIndex PROPERTY_TABLE[] =
3240 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3241 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3242 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3243 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3244 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3245 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3246 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3247 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3248 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3249 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3250 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3251 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3252 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3253 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3254 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3255 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3256 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3257 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3258 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3259 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3260 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3261 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3262 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3263 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3264 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3265 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3266 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3267 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3268 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3269 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3270 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3271 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3272 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3273 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3274 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3275 { "name", Actor::Property::NAME, Property::STRING },
3276 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3277 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3278 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3279 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3280 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3281 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3282 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3283 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3284 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3285 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3286 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3287 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3288 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3289 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3290 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3291 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3292 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3293 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3294 { "updateSizeHint", DevelActor::Property::UPDATE_SIZE_HINT, Property::VECTOR2 },
3296 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3297 } // unnamed namespace
3299 int UtcDaliActorProperties(void)
3301 TestApplication app;
3303 Actor actor = Actor::New();
3305 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3307 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3308 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3309 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3310 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3315 int UtcDaliRelayoutProperties_ResizePolicies(void)
3317 TestApplication app;
3319 Actor actor = Actor::New();
3322 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3323 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3325 // Set resize policy for all dimensions
3326 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3327 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3329 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3332 // Set individual dimensions
3333 const char* const widthPolicy = "FILL_TO_PARENT";
3334 const char* const heightPolicy = "FIXED";
3336 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3337 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3339 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3340 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3342 // Set individual dimensions using enums
3343 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3344 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3346 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3347 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3349 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3350 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3355 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3357 TestApplication app;
3359 Actor actor = Actor::New();
3362 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3363 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3365 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3366 actor.SetSizeScalePolicy( policy );
3367 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3370 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3371 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3373 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3374 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3376 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3377 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3382 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3384 TestApplication app;
3386 Actor actor = Actor::New();
3389 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3390 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3392 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3393 actor.SetSizeModeFactor( sizeMode );
3394 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3397 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3399 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3400 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3405 int UtcDaliRelayoutProperties_DimensionDependency(void)
3407 TestApplication app;
3409 Actor actor = Actor::New();
3412 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3413 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3416 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3417 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3419 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3420 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3422 // Test setting another resize policy
3423 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3424 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3429 int UtcDaliRelayoutProperties_Padding(void)
3431 TestApplication app;
3433 Actor actor = Actor::New();
3436 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3439 actor.SetProperty( Actor::Property::PADDING, padding );
3440 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3442 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3447 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3449 TestApplication app;
3451 Actor actor = Actor::New();
3454 Vector2 minSize( 1.0f, 2.0f );
3456 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3457 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3459 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3461 Vector2 maxSize( 3.0f, 4.0f );
3463 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3464 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3466 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3471 int UtcDaliActorGetHeightForWidth(void)
3473 TestApplication app;
3475 Actor actor = Actor::New();
3477 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3482 int UtcDaliActorGetWidthForHeight(void)
3484 TestApplication app;
3486 Actor actor = Actor::New();
3488 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3493 int UtcDaliActorGetRelayoutSize(void)
3495 TestApplication app;
3497 Actor actor = Actor::New();
3499 // Add actor to stage
3500 Stage::GetCurrent().Add( actor );
3502 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3504 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3505 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3507 // Flush the queue and render once
3508 app.SendNotification();
3511 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3516 int UtcDaliActorSetPadding(void)
3518 TestApplication app;
3520 Actor actor = Actor::New();
3523 actor.GetPadding( padding );
3525 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3526 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3527 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3528 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3530 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3531 actor.SetPadding( padding2 );
3533 actor.GetPadding( padding );
3535 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3536 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3537 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3538 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3543 int UtcDaliActorSetMinimumSize(void)
3545 TestApplication app;
3547 Actor actor = Actor::New();
3549 Vector2 size = actor.GetMinimumSize();
3551 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3552 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3554 Vector2 size2( 1.0f, 2.0f );
3555 actor.SetMinimumSize( size2 );
3557 size = actor.GetMinimumSize();
3559 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3560 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3565 int UtcDaliActorSetMaximumSize(void)
3567 TestApplication app;
3569 Actor actor = Actor::New();
3571 Vector2 size = actor.GetMaximumSize();
3573 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3574 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3576 Vector2 size2( 1.0f, 2.0f );
3577 actor.SetMaximumSize( size2 );
3579 size = actor.GetMaximumSize();
3581 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3582 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3587 int UtcDaliActorOnRelayoutSignal(void)
3589 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3591 TestApplication application;
3594 gOnRelayoutCallBackCalled = false;
3595 gActorNamesRelayout.clear();
3597 Actor actor = Actor::New();
3598 actor.SetName( "actor" );
3599 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3602 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3604 // Add actor to stage
3605 Stage::GetCurrent().Add( actor );
3607 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3608 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3610 // Flush the queue and render once
3611 application.SendNotification();
3612 application.Render();
3614 // OnRelayout emitted
3615 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3616 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3621 int UtcDaliActorGetHierachyDepth(void)
3623 TestApplication application;
3624 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3627 /* Build tree of actors:
3637 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3639 Stage stage( Stage::GetCurrent() );
3641 Actor actorA = Actor::New();
3642 Actor actorB = Actor::New();
3643 Actor actorC = Actor::New();
3644 Actor actorD = Actor::New();
3645 Actor actorE = Actor::New();
3646 Actor actorF = Actor::New();
3648 //Test that root actor has depth equal 0
3649 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3651 //Test actors return depth -1 when not connected to the tree
3652 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3653 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3654 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3655 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3656 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3657 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3659 //Create the hierarchy
3660 stage.Add( actorA );
3661 actorA.Add( actorB );
3662 actorA.Add( actorC );
3663 actorB.Add( actorD );
3664 actorB.Add( actorE );
3665 actorC.Add( actorF );
3667 //Test actors return correct depth
3668 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3669 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3670 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3671 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3672 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3673 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3675 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3676 actorA.Remove( actorB );
3678 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3679 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3680 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3682 //Removing actorA from the stage. All actors should have depth equal -1
3683 stage.Remove( actorA );
3685 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3686 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3687 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3688 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3689 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3690 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3695 int UtcDaliActorAnchorPointPropertyAsString(void)
3697 TestApplication application;
3699 Actor actor = Actor::New();
3701 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3702 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3704 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3705 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3707 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3708 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3710 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3711 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3713 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3714 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3716 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3717 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3719 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3720 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3722 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3723 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3725 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3726 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3728 // Invalid should not change anything
3729 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3730 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3735 int UtcDaliActorParentOriginPropertyAsString(void)
3737 TestApplication application;
3739 Actor actor = Actor::New();
3741 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3742 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3744 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3745 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3747 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3748 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3750 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3751 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3753 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3754 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3756 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3757 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3759 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3760 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3762 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3763 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3765 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3766 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3768 // Invalid should not change anything
3769 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3770 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3775 int UtcDaliActorColorModePropertyAsString(void)
3777 TestApplication application;
3779 Actor actor = Actor::New();
3781 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3782 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3784 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3785 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3787 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3788 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3790 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3791 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3793 // Invalid should not change anything
3794 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3795 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3800 int UtcDaliActorDrawModePropertyAsString(void)
3802 TestApplication application;
3804 Actor actor = Actor::New();
3806 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3807 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3809 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3810 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3812 // Invalid should not change anything
3813 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3814 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3819 int UtcDaliActorColorModePropertyAsEnum(void)
3821 TestApplication application;
3823 Actor actor = Actor::New();
3825 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3826 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3828 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3829 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3831 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3832 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3834 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3835 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3840 int UtcDaliActorDrawModePropertyAsEnum(void)
3842 TestApplication application;
3844 Actor actor = Actor::New();
3846 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3847 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3849 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3850 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3855 int UtcDaliActorAddRendererP(void)
3857 tet_infoline("Testing Actor::AddRenderer");
3858 TestApplication application;
3860 Actor actor = Actor::New();
3862 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3864 Geometry geometry = CreateQuadGeometry();
3865 Shader shader = CreateShader();
3866 Renderer renderer = Renderer::New(geometry, shader);
3868 actor.AddRenderer( renderer );
3869 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3870 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3875 int UtcDaliActorAddRendererN(void)
3877 tet_infoline("Testing Actor::AddRenderer");
3878 TestApplication application;
3880 Actor actor = Actor::New();
3886 actor.AddRenderer( renderer );
3887 tet_printf("Assertion test failed - no Exception\n" );
3888 tet_result(TET_FAIL);
3890 catch(Dali::DaliException& e)
3892 DALI_TEST_PRINT_ASSERT( e );
3893 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3894 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3898 tet_printf("Assertion test failed - wrong Exception\n" );
3899 tet_result(TET_FAIL);
3905 int UtcDaliActorAddRendererOnStage(void)
3907 tet_infoline("Testing Actor::AddRenderer");
3908 TestApplication application;
3910 Actor actor = Actor::New();
3911 Stage::GetCurrent().Add(actor);
3913 application.SendNotification();
3914 application.Render(0);
3916 Geometry geometry = CreateQuadGeometry();
3917 Shader shader = CreateShader();
3918 Renderer renderer = Renderer::New(geometry, shader);
3920 application.SendNotification();
3921 application.Render(0);
3925 actor.AddRenderer( renderer );
3926 tet_result(TET_PASS);
3930 tet_result(TET_FAIL);
3936 int UtcDaliActorRemoveRendererP1(void)
3938 tet_infoline("Testing Actor::RemoveRenderer");
3939 TestApplication application;
3941 Actor actor = Actor::New();
3943 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3946 Geometry geometry = CreateQuadGeometry();
3947 Shader shader = CreateShader();
3948 Renderer renderer = Renderer::New(geometry, shader);
3950 actor.AddRenderer( renderer );
3951 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3952 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3954 application.SendNotification();
3955 application.Render();
3959 Renderer renderer = actor.GetRendererAt(0);
3960 actor.RemoveRenderer(renderer);
3961 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3963 application.SendNotification();
3964 application.Render();
3967 // Call one final time to ensure that the renderer is actually removed after
3968 // the handle goes out of scope, and excercises the deletion code path in
3969 // scene graph and render.
3970 application.SendNotification();
3971 application.Render();
3976 int UtcDaliActorRemoveRendererP2(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 application.SendNotification();
3991 application.Render();
3993 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3994 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3996 actor.RemoveRenderer(0);
3997 application.SendNotification();
3998 application.Render();
4000 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4002 // Shut down whilst holding onto the renderer handle.
4007 int UtcDaliActorRemoveRendererN(void)
4009 tet_infoline("Testing Actor::RemoveRenderer");
4010 TestApplication application;
4012 Actor actor = Actor::New();
4014 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4016 Geometry geometry = CreateQuadGeometry();
4017 Shader shader = CreateShader();
4018 Renderer renderer = Renderer::New(geometry, shader);
4020 actor.AddRenderer( renderer );
4021 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4022 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4024 actor.RemoveRenderer(10);
4025 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4026 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4031 // Clipping test helper functions:
4032 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4034 BufferImage image = BufferImage::New( width, height );
4035 Actor actor = CreateRenderableActor( image );
4037 // Setup dimensions and position so actor is not skipped by culling.
4038 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4039 actor.SetSize( width, height );
4040 actor.SetParentOrigin( ParentOrigin::CENTER );
4041 actor.SetAnchorPoint( AnchorPoint::CENTER );
4046 Actor CreateActorWithContent16x16()
4048 return CreateActorWithContent( 16, 16 );
4051 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4053 enabledDisableTrace.Reset();
4054 stencilTrace.Reset();
4055 enabledDisableTrace.Enable( true );
4056 stencilTrace.Enable( true );
4058 application.SendNotification();
4059 application.Render();
4061 enabledDisableTrace.Enable( false );
4062 stencilTrace.Enable( false );
4065 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4067 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4069 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4070 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4071 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4072 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4075 int UtcDaliActorPropertyClippingP(void)
4077 // This test checks the clippingMode property.
4078 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4079 TestApplication application;
4081 Actor actor = Actor::New();
4083 // Check default clippingEnabled value.
4084 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4087 bool getValueResult = getValue.Get( value );
4088 DALI_TEST_CHECK( getValueResult );
4090 if( getValueResult )
4092 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4095 // Check setting the property to the stencil mode.
4096 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4098 // Check the new value was set.
4099 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4100 getValueResult = getValue.Get( value );
4101 DALI_TEST_CHECK( getValueResult );
4103 if( getValueResult )
4105 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4108 // Check setting the property to the scissor mode.
4109 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4111 // Check the new value was set.
4112 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4113 getValueResult = getValue.Get( value );
4114 DALI_TEST_CHECK( getValueResult );
4116 if( getValueResult )
4118 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4123 int UtcDaliActorPropertyClippingN(void)
4125 // Negative test case for Clipping.
4126 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4127 TestApplication application;
4129 Actor actor = Actor::New();
4131 // Check default clippingEnabled value.
4132 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4135 bool getValueResult = getValue.Get( value );
4136 DALI_TEST_CHECK( getValueResult );
4138 if( getValueResult )
4140 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4143 // Check setting an invalid property value won't change the current property value.
4144 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4146 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4147 getValueResult = getValue.Get( value );
4148 DALI_TEST_CHECK( getValueResult );
4150 if( getValueResult )
4152 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4158 int UtcDaliActorPropertyClippingActor(void)
4160 // This test checks that an actor is correctly setup for clipping.
4161 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4162 TestApplication application;
4164 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4165 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4166 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4167 size_t startIndex = 0u;
4169 // Create a clipping actor.
4170 Actor actorDepth1Clip = CreateActorWithContent16x16();
4171 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4172 Stage::GetCurrent().Add( actorDepth1Clip );
4174 // Gather the call trace.
4175 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4177 // Check we are writing to the color buffer.
4178 CheckColorMask( glAbstraction, true );
4180 // Check the stencil buffer was enabled.
4181 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4183 // Check the stencil buffer was cleared.
4184 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4186 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4187 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4188 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4189 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4194 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4196 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4197 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4198 TestApplication application;
4200 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4201 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4202 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4203 size_t startIndex = 0u;
4205 // Create a clipping actor.
4206 Actor actorDepth1Clip = CreateActorWithContent16x16();
4207 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4208 Stage::GetCurrent().Add( actorDepth1Clip );
4210 // Gather the call trace.
4211 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4213 // Check we are writing to the color buffer.
4214 CheckColorMask( glAbstraction, true );
4216 // Check the stencil buffer was enabled.
4217 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4219 // Check the stencil buffer was cleared.
4220 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4222 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4223 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4224 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4225 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4227 // Now disable the clipping
4228 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4230 // Gather the call trace.
4231 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4233 // Check the stencil buffer was disabled.
4234 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4236 // Ensure all values in stencil-mask are set to 1.
4238 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4243 int UtcDaliActorPropertyClippingNestedChildren(void)
4245 // This test checks that a hierarchy of actors are clipped correctly by
4246 // writing to and reading from the correct bit-planes of the stencil buffer.
4247 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4248 TestApplication application;
4249 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4250 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4251 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4253 // Create a clipping actor.
4254 Actor actorDepth1Clip = CreateActorWithContent16x16();
4255 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4256 Stage::GetCurrent().Add( actorDepth1Clip );
4258 // Create a child actor.
4259 Actor childDepth2 = CreateActorWithContent16x16();
4260 actorDepth1Clip.Add( childDepth2 );
4262 // Create another clipping actor.
4263 Actor childDepth2Clip = CreateActorWithContent16x16();
4264 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4265 childDepth2.Add( childDepth2Clip );
4267 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4268 // This tests the sort algorithm.
4269 Actor childDepth3 = CreateActorWithContent16x16();
4270 childDepth2Clip.Add( childDepth3 );
4271 Actor childDepth4 = CreateActorWithContent16x16();
4272 childDepth3.Add( childDepth4 );
4274 // Gather the call trace.
4275 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4277 // Check we are writing to the color buffer.
4278 CheckColorMask( glAbstraction, true );
4280 // Check the stencil buffer was enabled.
4281 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4283 // Perform the test twice, once for 2D layer, and once for 3D.
4284 for( unsigned int i = 0u ; i < 2u; ++i )
4286 size_t startIndex = 0u;
4288 // Check the stencil buffer was cleared.
4289 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4291 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4292 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4293 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4294 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4296 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4297 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4298 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4300 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4301 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4302 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4303 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4305 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4306 // (Both must be set to pass the check).
4307 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4308 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4310 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4313 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4314 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4321 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4323 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4324 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4325 TestApplication application;
4326 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4327 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4329 /* We create a small tree of actors as follows:
4333 Clipping enabled -> B D
4337 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4340 for( int i = 0; i < 5; ++i )
4342 BufferImage image = BufferImage::New( 16u, 16u );
4343 Actor actor = CreateRenderableActor( image );
4345 // Setup dimensions and position so actor is not skipped by culling.
4346 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4347 actor.SetSize( 16.0f, 16.0f );
4351 actor.SetParentOrigin( ParentOrigin::CENTER );
4355 float b = i > 2 ? 1.0f : -1.0f;
4356 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4362 // Enable clipping on the actor at the top of the left branch.
4363 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4365 // Build the scene graph.
4366 Stage::GetCurrent().Add( actors[0] );
4369 actors[0].Add( actors[1] );
4370 actors[1].Add( actors[2] );
4373 actors[0].Add( actors[3] );
4374 actors[3].Add( actors[4] );
4376 // Gather the call trace.
4377 enabledDisableTrace.Reset();
4378 enabledDisableTrace.Enable( true );
4379 application.SendNotification();
4380 application.Render();
4381 enabledDisableTrace.Enable( false );
4383 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4385 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
4386 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4388 size_t startIndex = 0u;
4389 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4390 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4391 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4393 // Swap the clipping actor from top of left branch to top of right branch.
4394 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4395 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4397 // Gather the call trace.
4398 enabledDisableTrace.Reset();
4399 enabledDisableTrace.Enable( true );
4400 application.SendNotification();
4401 application.Render();
4402 enabledDisableTrace.Enable( false );
4404 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4405 // This proves the draw order has remained the same.
4407 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4408 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4413 int UtcDaliActorPropertyScissorClippingActor(void)
4415 // This test checks that an actor is correctly setup for clipping.
4416 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4417 TestApplication application;
4419 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4420 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4421 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4423 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4424 const Vector2 imageSize( 16.0f, 16.0f );
4426 // Create a clipping actor.
4427 Actor clippingActorA = CreateActorWithContent16x16();
4428 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4429 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4430 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4431 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4432 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4433 Stage::GetCurrent().Add( clippingActorA );
4435 // Gather the call trace.
4436 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4438 // Check we are writing to the color buffer.
4439 CheckColorMask( glAbstraction, true );
4441 // Check scissor test was enabled.
4442 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4444 // Check the scissor was set, and the coordinates are correct.
4445 std::stringstream compareParametersString;
4446 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4447 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4449 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4450 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4452 // Gather the call trace.
4453 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4455 // Check the scissor was set, and the coordinates are correct.
4456 compareParametersString.str( std::string() );
4457 compareParametersString.clear();
4458 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4459 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4464 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4466 // This test checks that an actor is correctly setup for clipping.
4467 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4468 TestApplication application;
4471 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4472 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4473 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4475 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4476 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4477 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4479 // Create a clipping actors.
4480 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4481 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4483 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4484 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4485 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4487 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4488 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4489 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4491 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4492 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4494 Stage::GetCurrent().Add( clippingActorA );
4495 Stage::GetCurrent().Add( clippingActorB );
4497 // Gather the call trace.
4498 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4500 // Check we are writing to the color buffer.
4501 CheckColorMask( glAbstraction, true );
4503 // Check scissor test was enabled.
4504 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4506 // Check the scissor was set, and the coordinates are correct.
4507 std::stringstream compareParametersString;
4509 std::string clipA( "0, 500, 480, 200" );
4510 std::string clipB( "0, 380, 480, 40" );
4512 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4513 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4518 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4520 // This test checks that an actor is correctly setup for clipping.
4521 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4522 TestApplication application;
4524 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4525 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4526 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4528 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4529 const Vector2 imageSize( 16.0f, 16.0f );
4531 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4533 A is drawn first - with scissor clipping on
4534 B is drawn second - also with scissor clipping on
4535 C is the generated clipping region, the intersection ( A ∩ B )
4539 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4540 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4541 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4545 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4548 // Create a clipping actor.
4549 Actor clippingActorA = CreateActorWithContent16x16();
4550 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4551 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4552 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4553 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4554 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4555 Stage::GetCurrent().Add( clippingActorA );
4557 // Create a child clipping actor.
4558 Actor clippingActorB = CreateActorWithContent16x16();
4559 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4560 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4561 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4562 clippingActorA.Add( clippingActorB );
4564 // positionModifiers is an array of positions to position B around.
4565 // expect is an array of expected scissor clip coordinate results.
4566 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4567 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4569 // Loop through each overlap combination.
4570 for( unsigned int test = 0u; test < 4u; ++test )
4572 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4573 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4574 clippingActorB.SetPosition( position.x, position.y );
4576 // Gather the call trace.
4577 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4579 // Check we are writing to the color buffer.
4580 CheckColorMask( glAbstraction, true );
4582 // Check scissor test was enabled.
4583 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4585 // Check the scissor was set, and the coordinates are correct.
4586 const Vector4& expectResults( expect[test] );
4587 std::stringstream compareParametersString;
4588 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4589 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4595 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4597 // This test checks that an actor is correctly setup for clipping.
4598 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4599 TestApplication application;
4601 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4602 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4603 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4605 /* Create a nest of 2 scissors and siblings of the parent.
4615 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4616 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4617 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4618 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4619 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4620 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4622 // Create a clipping actors.
4623 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4624 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4625 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4626 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4627 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4629 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4630 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4631 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4633 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4634 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4635 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4637 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4638 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4639 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4641 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4642 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4643 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4645 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4646 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4648 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4649 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4650 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4651 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4652 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4654 Stage::GetCurrent().Add( clippingActorA );
4655 clippingActorA.Add( clippingActorB );
4656 Stage::GetCurrent().Add( clippingActorC );
4657 Stage::GetCurrent().Add( clippingActorD );
4658 clippingActorD.Add( clippingActorE );
4660 // Gather the call trace.
4661 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4663 // Check we are writing to the color buffer.
4664 CheckColorMask( glAbstraction, true );
4666 // Check scissor test was enabled.
4667 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4669 // Check the scissor was set, and the coordinates are correct.
4670 std::string clipA( "0, 500, 480, 200" );
4671 std::string clipB( "0, 580, 480, 40" );
4672 std::string clipC( "0, 200, 480, 200" );
4673 std::string clipD( "0, 300, 480, 200" );
4675 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4676 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4677 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4678 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4679 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4684 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4686 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4687 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4688 TestApplication application;
4690 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4691 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4692 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4694 // Create a clipping actor.
4695 Actor actorDepth1Clip = CreateActorWithContent16x16();
4696 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4697 Stage::GetCurrent().Add( actorDepth1Clip );
4699 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4700 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4702 // Gather the call trace.
4703 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4705 // Check we are writing to the color buffer.
4706 CheckColorMask( glAbstraction, true );
4708 // Check the stencil buffer was not enabled.
4709 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4711 // Check stencil functions are not called.
4712 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4713 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4714 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4716 // Check that scissor clipping is overriden by the renderer properties.
4717 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4719 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4721 // Gather the call trace.
4722 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4724 // Check the stencil buffer was not enabled.
4725 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4727 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4732 int UtcDaliGetPropertyN(void)
4734 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4735 TestApplication app;
4737 Actor actor = Actor::New();
4739 unsigned int propertyCount = actor.GetPropertyCount();
4740 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4744 int UtcDaliActorRaiseLower(void)
4746 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4748 TestApplication application;
4750 Stage stage( Stage::GetCurrent() );
4752 Actor actorA = Actor::New();
4753 Actor actorB = Actor::New();
4754 Actor actorC = Actor::New();
4756 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4757 actorA.SetParentOrigin( ParentOrigin::CENTER );
4759 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4760 actorB.SetParentOrigin( ParentOrigin::CENTER );
4762 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4763 actorC.SetParentOrigin( ParentOrigin::CENTER );
4765 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4766 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4768 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4769 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4771 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4772 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4774 stage.Add( actorA );
4775 stage.Add( actorB );
4776 stage.Add( actorC );
4778 ResetTouchCallbacks();
4780 application.SendNotification();
4781 application.Render();
4783 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4784 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4785 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4787 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4788 // Only top actor will get touched.
4789 actorA.TouchSignal().Connect( TestTouchCallback );
4790 actorB.TouchSignal().Connect( TestTouchCallback2 );
4791 actorC.TouchSignal().Connect( TestTouchCallback3 );
4793 // Connect ChildOrderChangedSignal
4794 bool orderChangedSignal( false );
4795 Actor orderChangedActor;
4796 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4797 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4799 Dali::Integration::Point point;
4800 point.SetDeviceId( 1 );
4801 point.SetState( PointState::DOWN );
4802 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4803 Dali::Integration::TouchEvent touchEvent;
4804 touchEvent.AddPoint( point );
4806 application.ProcessEvent( touchEvent );
4808 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4809 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4810 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4812 ResetTouchCallbacks();
4814 tet_printf( "Testing Raising of Actor\n" );
4816 int preActorOrder( 0 );
4817 int postActorOrder( 0 );
4819 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4820 value.Get( preActorOrder );
4822 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4824 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4825 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4827 // Ensure sort order is calculated before next touch event
4828 application.SendNotification();
4830 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4831 value.Get( postActorOrder );
4833 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4835 application.ProcessEvent( touchEvent );
4837 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4838 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4839 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4841 ResetTouchCallbacks();
4843 tet_printf( "Testing Lowering of Actor\n" );
4845 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4846 value.Get( preActorOrder );
4848 orderChangedSignal = false;
4850 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4852 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4853 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4855 application.SendNotification(); // ensure sort order calculated before next touch event
4857 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4858 value.Get( postActorOrder );
4860 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4862 application.ProcessEvent( touchEvent );
4864 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4865 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4866 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4868 ResetTouchCallbacks();
4873 int UtcDaliActorRaiseToTopLowerToBottom(void)
4875 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4877 TestApplication application;
4879 Stage stage( Stage::GetCurrent() );
4881 Actor actorA = Actor::New();
4882 Actor actorB = Actor::New();
4883 Actor actorC = Actor::New();
4885 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4886 // enables checking of which actor the uniform is assigned too
4887 Shader shaderA = CreateShader();
4888 shaderA.RegisterProperty( "uRendererColor",1.f);
4890 Shader shaderB = CreateShader();
4891 shaderB.RegisterProperty( "uRendererColor", 2.f );
4893 Shader shaderC = CreateShader();
4894 shaderC.RegisterProperty( "uRendererColor", 3.f );
4896 Geometry geometry = CreateQuadGeometry();
4898 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4899 Renderer rendererA = Renderer::New(geometry, shaderA);
4900 actorA.AddRenderer(rendererA);
4902 Renderer rendererB = Renderer::New(geometry, shaderB);
4903 actorB.AddRenderer(rendererB);
4905 Renderer rendererC = Renderer::New(geometry, shaderC);
4906 actorC.AddRenderer(rendererC);
4908 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4909 actorA.SetParentOrigin( ParentOrigin::CENTER );
4911 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4912 actorB.SetParentOrigin( ParentOrigin::CENTER );
4914 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4915 actorC.SetParentOrigin( ParentOrigin::CENTER );
4917 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4918 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4920 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4921 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4923 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4924 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4926 stage.Add( actorA );
4927 stage.Add( actorB );
4928 stage.Add( actorC );
4930 ResetTouchCallbacks();
4932 // Connect ChildOrderChangedSignal
4933 bool orderChangedSignal( false );
4934 Actor orderChangedActor;
4935 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4936 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4938 // Set up gl abstraction trace so can query the set uniform order
4939 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4940 glAbstraction.EnableSetUniformCallTrace(true);
4941 glAbstraction.ResetSetUniformCallStack();
4943 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4945 application.SendNotification();
4946 application.Render();
4948 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4951 // Test order of uniforms in stack
4952 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4953 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4954 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4956 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4958 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4960 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4961 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4962 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4964 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4965 // Only top actor will get touched.
4966 actorA.TouchSignal().Connect( TestTouchCallback );
4967 actorB.TouchSignal().Connect( TestTouchCallback2 );
4968 actorC.TouchSignal().Connect( TestTouchCallback3 );
4970 Dali::Integration::Point point;
4971 point.SetDeviceId( 1 );
4972 point.SetState( PointState::DOWN );
4973 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4974 Dali::Integration::TouchEvent touchEvent;
4975 touchEvent.AddPoint( point );
4977 application.ProcessEvent( touchEvent );
4979 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4980 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4981 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4983 ResetTouchCallbacks();
4985 tet_printf( "RaiseToTop ActorA\n" );
4987 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4988 actorA.RaiseToTop();
4989 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4990 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
4992 application.SendNotification(); // ensure sorting order is calculated before next touch event
4994 application.ProcessEvent( touchEvent );
4996 glAbstraction.ResetSetUniformCallStack();
4997 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4999 application.SendNotification();
5000 application.Render();
5002 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5004 // Test order of uniforms in stack
5005 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5006 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5007 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5009 tet_infoline( "Testing A above C and B at bottom\n" );
5010 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5012 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5014 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5015 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5016 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5018 ResetTouchCallbacks();
5020 tet_printf( "RaiseToTop ActorB\n" );
5022 orderChangedSignal = false;
5024 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5025 actorB.RaiseToTop();
5026 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5027 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5029 application.SendNotification(); // Ensure sort order is calculated before next touch event
5031 application.ProcessEvent( touchEvent );
5033 glAbstraction.ResetSetUniformCallStack();
5034 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5036 application.SendNotification();
5037 application.Render();
5039 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5041 // Test order of uniforms in stack
5042 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5043 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5044 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5046 tet_infoline( "Testing B above A and C at bottom\n" );
5047 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5049 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5051 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5052 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5053 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5055 ResetTouchCallbacks();
5057 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5059 orderChangedSignal = false;
5061 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5062 actorA.LowerToBottom();
5063 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5064 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5066 application.SendNotification();
5067 application.Render();
5069 orderChangedSignal = false;
5071 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5072 actorB.LowerToBottom();
5073 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5074 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5076 application.SendNotification();
5077 application.Render();
5079 application.ProcessEvent( touchEvent );
5081 glAbstraction.ResetSetUniformCallStack();
5082 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5084 application.SendNotification();
5085 application.Render();
5087 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5089 // Test order of uniforms in stack
5090 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5091 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5092 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5094 tet_infoline( "Testing C above A and B at bottom\n" );
5095 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5097 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5099 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5100 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5101 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5103 ResetTouchCallbacks();
5108 int UtcDaliActorRaiseAbove(void)
5110 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5112 TestApplication application;
5114 Stage stage( Stage::GetCurrent() );
5116 Actor actorA = Actor::New();
5117 Actor actorB = Actor::New();
5118 Actor actorC = Actor::New();
5120 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5121 actorA.SetParentOrigin( ParentOrigin::CENTER );
5123 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5124 actorB.SetParentOrigin( ParentOrigin::CENTER );
5126 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5127 actorC.SetParentOrigin( ParentOrigin::CENTER );
5129 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5130 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5132 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5133 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5135 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5136 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5138 stage.Add( actorA );
5139 stage.Add( actorB );
5140 stage.Add( actorC );
5142 ResetTouchCallbacks();
5144 application.SendNotification();
5145 application.Render();
5147 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5148 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5149 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5151 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5152 // Only top actor will get touched.
5153 actorA.TouchSignal().Connect( TestTouchCallback );
5154 actorB.TouchSignal().Connect( TestTouchCallback2 );
5155 actorC.TouchSignal().Connect( TestTouchCallback3 );
5157 bool orderChangedSignal( false );
5158 Actor orderChangedActor;
5159 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5160 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5162 Dali::Integration::Point point;
5163 point.SetDeviceId( 1 );
5164 point.SetState( PointState::DOWN );
5165 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5166 Dali::Integration::TouchEvent touchEvent;
5167 touchEvent.AddPoint( point );
5169 application.ProcessEvent( touchEvent );
5171 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5172 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5173 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5175 ResetTouchCallbacks();
5177 tet_printf( "Raise actor B Above Actor C\n" );
5179 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5180 actorB.RaiseAbove( actorC );
5181 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5182 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5184 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5185 application.SendNotification();
5186 application.ProcessEvent( touchEvent );
5188 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5189 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5190 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5192 ResetTouchCallbacks();
5194 tet_printf( "Raise actor A Above Actor B\n" );
5196 orderChangedSignal = false;
5198 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5199 actorA.RaiseAbove( actorB );
5200 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5201 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5203 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5204 application.SendNotification();
5206 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5208 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5209 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5210 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5212 ResetTouchCallbacks();
5217 int UtcDaliActorLowerBelow(void)
5219 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5221 TestApplication application;
5223 Stage stage( Stage::GetCurrent() );
5225 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5226 // enables checking of which actor the uniform is assigned too
5227 Shader shaderA = CreateShader();
5228 shaderA.RegisterProperty( "uRendererColor",1.f);
5230 Shader shaderB = CreateShader();
5231 shaderB.RegisterProperty( "uRendererColor", 2.f );
5233 Shader shaderC = CreateShader();
5234 shaderC.RegisterProperty( "uRendererColor", 3.f );
5236 Actor actorA = Actor::New();
5237 Actor actorB = Actor::New();
5238 Actor actorC = Actor::New();
5240 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5241 Geometry geometry = CreateQuadGeometry();
5243 Renderer rendererA = Renderer::New(geometry, shaderA);
5244 actorA.AddRenderer(rendererA);
5246 Renderer rendererB = Renderer::New(geometry, shaderB);
5247 actorB.AddRenderer(rendererB);
5249 Renderer rendererC = Renderer::New(geometry, shaderC);
5250 actorC.AddRenderer(rendererC);
5252 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5253 actorA.SetParentOrigin( ParentOrigin::CENTER );
5255 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5256 actorB.SetParentOrigin( ParentOrigin::CENTER );
5258 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5259 actorC.SetParentOrigin( ParentOrigin::CENTER );
5261 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5262 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5264 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5265 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5267 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5268 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5270 Actor container = Actor::New();
5271 container.SetParentOrigin( ParentOrigin::CENTER );
5272 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5273 stage.Add( container );
5275 container.Add( actorA );
5276 container.Add( actorB );
5277 container.Add( actorC );
5279 ResetTouchCallbacks();
5281 // Connect ChildOrderChangedSignal
5282 bool orderChangedSignal( false );
5283 Actor orderChangedActor;
5284 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5285 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5287 // Set up gl abstraction trace so can query the set uniform order
5288 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5289 glAbstraction.EnableSetUniformCallTrace(true);
5290 glAbstraction.ResetSetUniformCallStack();
5291 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5293 glAbstraction.ResetSetUniformCallStack();
5295 application.SendNotification();
5296 application.Render();
5298 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5300 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5302 // Test order of uniforms in stack
5303 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5304 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5305 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5307 tet_infoline( "Testing C above B and A at bottom\n" );
5308 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5310 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5312 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5313 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5314 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5316 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5317 // Only top actor will get touched.
5318 actorA.TouchSignal().Connect( TestTouchCallback );
5319 actorB.TouchSignal().Connect( TestTouchCallback2 );
5320 actorC.TouchSignal().Connect( TestTouchCallback3 );
5322 Dali::Integration::Point point;
5323 point.SetDeviceId( 1 );
5324 point.SetState( PointState::DOWN );
5325 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5326 Dali::Integration::TouchEvent touchEvent;
5327 touchEvent.AddPoint( point );
5329 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5331 application.ProcessEvent( touchEvent );
5333 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5334 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5335 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5337 ResetTouchCallbacks();
5339 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" );
5341 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5342 actorC.LowerBelow( actorB );
5343 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5344 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5346 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5347 application.SendNotification();
5348 application.Render();
5350 application.ProcessEvent( touchEvent ); // touch event
5352 glAbstraction.ResetSetUniformCallStack();
5353 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5355 application.SendNotification();
5356 application.Render();
5358 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5360 // Test order of uniforms in stack
5361 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5362 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5363 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5365 tet_infoline( "Testing render order is A, C, B" );
5366 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5367 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5369 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5370 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5371 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5373 ResetTouchCallbacks();
5375 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5377 orderChangedSignal = false;
5379 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5380 actorC.LowerBelow( actorA );
5381 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5382 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5384 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5385 application.SendNotification();
5386 application.Render();
5388 application.ProcessEvent( touchEvent );
5390 glAbstraction.ResetSetUniformCallStack();
5391 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5393 application.Render();
5394 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5396 // Test order of uniforms in stack
5397 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5398 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5399 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5401 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5402 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5404 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5405 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5406 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5408 ResetTouchCallbacks();
5410 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5412 orderChangedSignal = false;
5414 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5415 actorB.LowerBelow( actorC );
5416 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5417 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5419 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5420 application.SendNotification();
5421 application.Render();
5423 application.ProcessEvent( touchEvent );
5425 glAbstraction.ResetSetUniformCallStack();
5426 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5428 application.Render();
5429 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5431 // Test order of uniforms in stack
5432 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5433 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5434 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5436 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5437 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5443 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5445 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5447 TestApplication application;
5449 Stage stage( Stage::GetCurrent() );
5451 Actor parentA = Actor::New();
5452 Actor parentB = Actor::New();
5453 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5454 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5455 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5456 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5458 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5459 parentA.SetParentOrigin( ParentOrigin::CENTER );
5461 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5462 parentB.SetParentOrigin( ParentOrigin::CENTER );
5464 stage.Add( parentA );
5465 stage.Add( parentB );
5467 Actor actorA = Actor::New();
5468 Actor actorB = Actor::New();
5469 Actor actorC = Actor::New();
5471 parentA.Add( actorA );
5472 parentA.Add( actorB );
5474 tet_printf( "Actor C added to different parent from A and B \n" );
5475 parentB.Add( actorC );
5477 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5478 actorA.SetParentOrigin( ParentOrigin::CENTER );
5480 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5481 actorB.SetParentOrigin( ParentOrigin::CENTER );
5483 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5484 actorC.SetParentOrigin( ParentOrigin::CENTER );
5486 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5487 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5489 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5490 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5492 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5493 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5495 ResetTouchCallbacks();
5497 // Connect ChildOrderChangedSignal
5498 bool orderChangedSignal( false );
5499 Actor orderChangedActor;
5500 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5501 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5503 application.SendNotification();
5504 application.Render();
5506 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5507 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5508 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5510 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5511 // Only top actor will get touched.
5512 actorA.TouchSignal().Connect( TestTouchCallback );
5513 actorB.TouchSignal().Connect( TestTouchCallback2 );
5514 actorC.TouchSignal().Connect( TestTouchCallback3 );
5516 Dali::Integration::Point point;
5517 point.SetDeviceId( 1 );
5518 point.SetState( PointState::DOWN );
5519 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5520 Dali::Integration::TouchEvent touchEvent;
5521 touchEvent.AddPoint( point );
5523 application.ProcessEvent( touchEvent );
5525 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5526 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5527 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5529 ResetTouchCallbacks();
5531 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5533 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5534 actorA.RaiseAbove( actorC );
5535 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5537 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5538 application.SendNotification();
5540 application.ProcessEvent( touchEvent ); // touch event
5542 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5543 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5544 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5546 ResetTouchCallbacks();
5551 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5553 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5555 TestApplication application;
5557 Stage stage( Stage::GetCurrent() );
5559 Actor actorA = Actor::New();
5560 Actor actorB = Actor::New();
5561 Actor actorC = Actor::New();
5563 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5564 actorA.SetParentOrigin( ParentOrigin::CENTER );
5566 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5567 actorB.SetParentOrigin( ParentOrigin::CENTER );
5569 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5570 actorC.SetParentOrigin( ParentOrigin::CENTER );
5572 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5573 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5575 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5576 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5578 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5579 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5581 ResetTouchCallbacks();
5583 // Connect ChildOrderChangedSignal
5584 bool orderChangedSignal( false );
5585 Actor orderChangedActor;
5586 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5587 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5589 application.SendNotification();
5590 application.Render();
5592 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5593 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5594 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5596 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5597 // Only top actor will get touched.
5598 actorA.TouchSignal().Connect( TestTouchCallback );
5599 actorB.TouchSignal().Connect( TestTouchCallback2 );
5600 actorC.TouchSignal().Connect( TestTouchCallback3 );
5602 Dali::Integration::Point point;
5603 point.SetDeviceId( 1 );
5604 point.SetState( PointState::DOWN );
5605 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5606 Dali::Integration::TouchEvent touchEvent;
5607 touchEvent.AddPoint( point );
5609 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5611 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5612 actorA.RaiseAbove( actorC );
5613 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5615 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5616 application.SendNotification();
5618 application.ProcessEvent( touchEvent );
5620 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5622 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5623 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5624 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5626 ResetTouchCallbacks();
5628 orderChangedSignal = false;
5630 stage.Add ( actorB );
5631 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5633 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5634 actorA.LowerBelow( actorC );
5635 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5637 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5638 application.SendNotification();
5639 application.Render();
5641 application.ProcessEvent( touchEvent );
5643 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5644 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5645 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5646 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5648 ResetTouchCallbacks();
5650 orderChangedSignal = false;
5652 tet_printf( "Adding Actor A to stage, will be on top\n" );
5654 stage.Add ( actorA );
5655 application.SendNotification();
5656 application.Render();
5658 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5660 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5661 actorB.RaiseAbove( actorC );
5662 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5664 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5665 application.SendNotification();
5667 application.ProcessEvent( touchEvent );
5669 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5670 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5671 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5672 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5674 ResetTouchCallbacks();
5676 orderChangedSignal = false;
5678 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5680 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5681 actorA.LowerBelow( actorC );
5682 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5684 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5685 application.SendNotification();
5687 application.ProcessEvent( touchEvent );
5689 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5690 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5691 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5692 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5694 ResetTouchCallbacks();
5696 orderChangedSignal = false;
5698 stage.Add ( actorC );
5700 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5701 actorA.RaiseAbove( actorC );
5702 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5703 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5705 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5706 application.SendNotification();
5707 application.Render();
5709 application.ProcessEvent( touchEvent );
5711 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5712 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5713 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5714 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5719 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5721 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5723 TestApplication application;
5725 Stage stage( Stage::GetCurrent() );
5727 Actor actorA = Actor::New();
5728 Actor actorB = Actor::New();
5729 Actor actorC = Actor::New();
5731 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5732 actorA.SetParentOrigin( ParentOrigin::CENTER );
5734 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5735 actorB.SetParentOrigin( ParentOrigin::CENTER );
5737 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5738 actorC.SetParentOrigin( ParentOrigin::CENTER );
5740 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5741 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5743 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5744 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5746 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5747 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5749 ResetTouchCallbacks();
5751 // Connect ChildOrderChangedSignal
5752 bool orderChangedSignal( false );
5753 Actor orderChangedActor;
5754 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5755 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5757 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5758 // Only top actor will get touched.
5759 actorA.TouchSignal().Connect( TestTouchCallback );
5760 actorB.TouchSignal().Connect( TestTouchCallback2 );
5761 actorC.TouchSignal().Connect( TestTouchCallback3 );
5763 Dali::Integration::Point point;
5764 point.SetDeviceId( 1 );
5765 point.SetState( PointState::DOWN );
5766 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5767 Dali::Integration::TouchEvent touchEvent;
5768 touchEvent.AddPoint( point );
5770 stage.Add ( actorA );
5771 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5773 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5775 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5777 application.SendNotification();
5778 application.Render();
5780 application.ProcessEvent( touchEvent );
5782 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5784 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5785 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5786 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5788 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5789 ResetTouchCallbacks();
5791 orderChangedSignal = false;
5793 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5795 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5797 // Sort actor tree before next touch event
5798 application.SendNotification();
5799 application.Render();
5801 application.ProcessEvent( touchEvent );
5803 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5805 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5806 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5807 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5808 ResetTouchCallbacks();
5810 orderChangedSignal = false;
5812 tet_printf( "Lower actor C below B but C not parented\n" );
5814 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5816 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5818 // Sort actor tree before next touch event
5819 application.SendNotification();
5820 application.Render();
5822 application.ProcessEvent( touchEvent );
5824 tet_printf( "Not parented so Lower should show no effect\n" );
5826 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5827 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5828 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5829 ResetTouchCallbacks();
5831 orderChangedSignal = false;
5833 tet_printf( "Raise actor B to top\n" );
5835 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5836 actorB.RaiseToTop();
5837 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5839 // Sort actor tree before next touch event
5840 application.SendNotification();
5841 application.Render();
5843 application.ProcessEvent( touchEvent );
5845 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5847 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5848 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5849 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5850 ResetTouchCallbacks();
5852 orderChangedSignal = false;
5854 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5856 stage.Add ( actorB );
5858 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5860 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5861 actorC.LowerToBottom();
5862 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5864 application.SendNotification();
5865 application.Render();
5867 application.ProcessEvent( touchEvent );
5869 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5871 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5872 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5873 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5874 ResetTouchCallbacks();
5880 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5882 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5884 TestApplication application;
5886 Stage stage( Stage::GetCurrent() );
5888 Actor actorA = Actor::New();
5889 Actor actorB = Actor::New();
5890 Actor actorC = Actor::New();
5892 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5893 actorA.SetParentOrigin( ParentOrigin::CENTER );
5895 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5896 actorB.SetParentOrigin( ParentOrigin::CENTER );
5898 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5899 actorC.SetParentOrigin( ParentOrigin::CENTER );
5901 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5902 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5904 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5905 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5907 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5908 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5910 stage.Add( actorA );
5911 stage.Add( actorB );
5912 stage.Add( actorC );
5914 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5915 // Only top actor will get touched.
5916 actorA.TouchSignal().Connect( TestTouchCallback );
5917 actorB.TouchSignal().Connect( TestTouchCallback2 );
5918 actorC.TouchSignal().Connect( TestTouchCallback3 );
5920 ResetTouchCallbacks();
5922 // Connect ChildOrderChangedSignal
5923 bool orderChangedSignal( false );
5924 Actor orderChangedActor;
5925 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5926 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5928 application.SendNotification();
5929 application.Render();
5931 Dali::Integration::Point point;
5932 point.SetDeviceId( 1 );
5933 point.SetState( PointState::DOWN );
5934 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5935 Dali::Integration::TouchEvent touchEvent;
5936 touchEvent.AddPoint( point );
5938 application.ProcessEvent( touchEvent );
5940 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5941 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5942 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5944 ResetTouchCallbacks();
5946 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5948 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5949 actorA.RaiseAbove( actorA );
5950 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5951 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5953 application.SendNotification();
5954 application.Render();
5956 application.ProcessEvent( touchEvent );
5958 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5960 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5961 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5962 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5964 ResetTouchCallbacks();
5966 orderChangedSignal = false;
5968 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5969 actorA.RaiseAbove( actorC );
5970 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5971 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5973 application.SendNotification();
5974 application.Render();
5976 application.ProcessEvent( touchEvent );
5978 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5979 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5980 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5981 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5986 int UtcDaliActorGetScreenPosition(void)
5988 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5990 TestApplication application;
5992 Stage stage( Stage::GetCurrent() );
5994 Actor actorA = Actor::New();
5995 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5997 Vector2 size2( 10.0f, 20.0f );
5998 actorA.SetSize( size2 );
6000 actorA.SetPosition( 0.f, 0.f );
6002 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6004 stage.Add( actorA );
6006 application.SendNotification();
6007 application.Render();
6009 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6010 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6012 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6013 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6015 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6016 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6018 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6020 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6022 application.SendNotification();
6023 application.Render();
6025 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6026 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6028 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6029 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6031 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6032 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6034 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6036 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6038 application.SendNotification();
6039 application.Render();
6041 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6042 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6044 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6045 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6047 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6048 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6050 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6052 actorA.SetPosition( 30.0, 0.0 );
6054 application.SendNotification();
6055 application.Render();
6057 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6058 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6060 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6061 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6063 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6064 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6066 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6068 actorA.SetPosition( 30.0, 420.0 );
6070 application.SendNotification();
6071 application.Render();
6073 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6074 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6076 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6077 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6079 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6080 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6082 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6084 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6085 actorA.SetPosition( 30.0, 30.0 );
6087 Actor actorB = Actor::New();
6088 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6089 actorB.SetSize( size2 );
6090 actorB.SetPosition( 10.f, 10.f );
6091 actorA.Add( actorB );
6093 actorA.SetScale( 2.0f );
6095 application.SendNotification();
6096 application.Render();
6098 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6100 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6101 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6106 int UtcDaliActorGetScreenPositionAfterScaling(void)
6108 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6110 TestApplication application;
6112 Stage stage( Stage::GetCurrent() );
6114 Actor actorA = Actor::New();
6115 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6117 Vector2 size2( 10.0f, 20.0f );
6118 actorA.SetSize( size2 );
6119 actorA.SetScale( 1.5f );
6120 actorA.SetPosition( 0.f, 0.f );
6122 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6124 stage.Add( actorA );
6126 application.SendNotification();
6127 application.Render();
6129 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6130 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6132 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6133 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6135 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6136 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6138 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6140 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6142 application.SendNotification();
6143 application.Render();
6145 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6146 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6148 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6149 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6151 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6152 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6157 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6159 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6161 TestApplication application;
6163 Stage stage( Stage::GetCurrent() );
6165 Actor actorA = Actor::New();
6166 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6167 actorA.SetParentOrigin( ParentOrigin::CENTER );
6168 Vector2 size2( 10.0f, 20.0f );
6169 actorA.SetSize( size2 );
6170 actorA.SetPosition( 0.f, 0.f );
6172 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6174 stage.Add( actorA );
6176 application.SendNotification();
6177 application.Render();
6179 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6180 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6182 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6183 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6185 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6186 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6188 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6190 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6191 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6193 application.SendNotification();
6194 application.Render();
6196 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6197 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6199 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6200 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6202 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6203 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6209 int UtcDaliActorGetScreenPositionWithChildActors(void)
6211 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6213 TestApplication application;
6215 Stage stage( Stage::GetCurrent() );
6217 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6219 Actor actorA = Actor::New();
6220 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6221 actorA.SetParentOrigin( ParentOrigin::CENTER );
6222 Vector2 size1( 10.0f, 20.0f );
6223 actorA.SetSize( size1 );
6224 actorA.SetPosition( 0.f, 0.f );
6226 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6228 Actor parentActorA = Actor::New();
6229 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6230 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6231 Vector2 size2( 30.0f, 60.0f );
6232 parentActorA.SetSize( size2 );
6233 parentActorA.SetPosition( 0.f, 0.f );
6235 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6237 stage.Add( parentActorA );
6238 parentActorA.Add ( actorA );
6240 application.SendNotification();
6241 application.Render();
6243 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6244 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6246 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6247 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6249 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6250 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6252 tet_infoline( "Test 2\n");
6254 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6256 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6257 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6259 application.SendNotification();
6260 application.Render();
6262 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6263 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6265 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6266 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6268 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6269 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6274 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6276 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6278 TestApplication application;
6280 Stage stage( Stage::GetCurrent() );
6282 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6284 Actor actorA = Actor::New();
6285 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6286 actorA.SetParentOrigin( ParentOrigin::CENTER );
6287 Vector2 size1( 10.0f, 20.0f );
6288 actorA.SetSize( size1 );
6289 actorA.SetPosition( 0.f, 0.f );
6291 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6293 Actor parentActorA = Actor::New();
6294 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6295 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6296 Vector2 size2( 30.0f, 60.0f );
6297 parentActorA.SetSize( size2 );
6298 parentActorA.SetPosition( 0.f, 0.f );
6300 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6302 Actor grandParentActorA = Actor::New();
6303 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6304 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6305 Vector2 size3( 60.0f, 120.0f );
6306 grandParentActorA.SetSize( size3 );
6307 grandParentActorA.SetPosition( 0.f, 0.f );
6309 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6311 stage.Add( grandParentActorA );
6312 grandParentActorA.Add ( parentActorA );
6314 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6316 parentActorA.Add ( actorA );
6318 application.SendNotification();
6319 application.Render();
6321 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6322 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6324 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6325 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6327 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6328 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6333 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6335 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6337 TestApplication application;
6339 Stage stage( Stage::GetCurrent() );
6341 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6343 Actor actorA = Actor::New();
6344 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6345 actorA.SetParentOrigin( ParentOrigin::CENTER );
6346 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6347 actorA.SetSize( 10.0f, 20.0f );
6348 stage.Add( actorA );
6350 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6352 Actor actorB = Actor::New();
6353 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6354 actorB.SetParentOrigin( ParentOrigin::CENTER );
6355 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6356 Vector2 actorBSize( 30.0f, 60.0f );
6357 actorB.SetSize( actorBSize );
6358 stage.Add( actorB );
6360 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6362 Actor actorC = Actor::New();
6363 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6364 actorC.SetParentOrigin( ParentOrigin::CENTER );
6365 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6366 Vector2 actorCSize( 60.0f, 120.0f );
6367 actorC.SetSize( actorCSize );
6368 stage.Add( actorC );
6370 application.SendNotification();
6371 application.Render();
6373 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6375 Vector2 center( stage.GetSize() * 0.5f );
6377 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6378 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6379 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6381 tet_infoline( "Add scale to all actors" );
6383 actorA.SetScale( 2.0f );
6384 actorB.SetScale( 2.0f );
6385 actorC.SetScale( 2.0f );
6387 application.SendNotification();
6388 application.Render();
6390 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6391 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6392 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6397 int utcDaliActorPositionUsesAnchorPoint(void)
6399 TestApplication application;
6400 tet_infoline( "Check default behaviour\n" );
6402 Actor actor = Actor::New();
6403 actor.SetParentOrigin( ParentOrigin::CENTER );
6404 actor.SetAnchorPoint( AnchorPoint::CENTER );
6405 actor.SetSize( 100.0f, 100.0f );
6406 Stage::GetCurrent().Add( actor );
6408 application.SendNotification();
6409 application.Render();
6411 tet_infoline( "Check that the world position is in the center\n" );
6412 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6414 tet_infoline( "Set the position uses anchor point property to false\n" );
6415 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6417 application.SendNotification();
6418 application.Render();
6420 tet_infoline( "Check that the world position has changed appropriately\n" );
6421 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6426 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6428 TestApplication application;
6429 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6431 Actor actor = Actor::New();
6432 actor.SetParentOrigin( ParentOrigin::CENTER );
6433 actor.SetAnchorPoint( AnchorPoint::CENTER );
6434 actor.SetSize( 100.0f, 100.0f );
6435 actor.SetScale( 2.0f );
6436 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6437 Stage::GetCurrent().Add( actor );
6439 application.SendNotification();
6440 application.Render();
6442 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6443 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6445 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6446 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6447 application.SendNotification();
6448 application.Render();
6449 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6451 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6452 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6453 application.SendNotification();
6454 application.Render();
6455 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6460 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6462 TestApplication application;
6463 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6465 Actor actor = Actor::New();
6466 actor.SetParentOrigin( ParentOrigin::CENTER );
6467 actor.SetAnchorPoint( AnchorPoint::CENTER );
6468 actor.SetSize( 100.0f, 100.0f );
6469 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6470 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6471 Stage::GetCurrent().Add( actor );
6473 application.SendNotification();
6474 application.Render();
6476 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6477 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6479 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6480 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6481 application.SendNotification();
6482 application.Render();
6483 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6485 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6486 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6487 application.SendNotification();
6488 application.Render();
6489 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6494 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6496 TestApplication application;
6497 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6499 Actor actor = Actor::New();
6500 actor.SetParentOrigin( ParentOrigin::CENTER );
6501 actor.SetAnchorPoint( AnchorPoint::CENTER );
6502 actor.SetSize( 100.0f, 100.0f );
6503 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6504 actor.SetScale( 2.0f );
6505 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6506 Stage::GetCurrent().Add( actor );
6508 application.SendNotification();
6509 application.Render();
6511 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6512 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6514 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6515 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6516 application.SendNotification();
6517 application.Render();
6518 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6520 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6521 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6522 application.SendNotification();
6523 application.Render();
6524 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6529 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6531 TestApplication application;
6532 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6534 Actor parent = Actor::New();
6536 Stage::GetCurrent().Add( parent );
6537 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6539 Actor actor = Actor::New();
6540 actor.SetParentOrigin( ParentOrigin::CENTER );
6541 actor.SetAnchorPoint( AnchorPoint::CENTER );
6542 actor.SetSize( 100.0f, 100.0f );
6543 actor.SetInheritScale( false );
6544 actor.SetInheritOrientation( false );
6545 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6546 parent.Add( actor );
6548 application.SendNotification();
6549 application.Render();
6551 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6553 tet_infoline( "Check the world position is in the right place\n" );
6554 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6556 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6557 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6558 application.SendNotification();
6559 application.Render();
6560 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6562 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6563 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6564 application.SendNotification();
6565 application.Render();
6566 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6571 int utcDaliActorVisibilityChangeSignalSelf(void)
6573 TestApplication application;
6574 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6576 Actor actor = Actor::New();
6578 VisibilityChangedFunctorData data;
6579 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6581 actor.SetVisible( false );
6583 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6585 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6588 actor.SetVisible( false );
6589 data.Check( false /* not called */, TEST_LOCATION );
6591 tet_infoline( "Change the visibility using properties, ensure called" );
6594 actor.SetProperty( Actor::Property::VISIBLE, true );
6595 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6597 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6600 actor.SetProperty( Actor::Property::VISIBLE, true );
6601 data.Check( false /* not called */, TEST_LOCATION );
6606 int utcDaliActorVisibilityChangeSignalChildren(void)
6608 TestApplication application;
6609 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6611 Actor parent = Actor::New();
6612 Actor child = Actor::New();
6613 parent.Add( child );
6615 Actor grandChild = Actor::New();
6616 child.Add( grandChild );
6618 VisibilityChangedFunctorData parentData;
6619 VisibilityChangedFunctorData childData;
6620 VisibilityChangedFunctorData grandChildData;
6622 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6623 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6624 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6626 parent.SetVisible( false );
6627 parentData.Check( false /* not called */, TEST_LOCATION );
6628 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6629 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6631 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6634 grandChildData.Reset();
6636 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6638 parent.SetVisible( true );
6639 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6640 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6641 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6643 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6646 grandChildData.Reset();
6648 parent.SetVisible( true );
6649 parentData.Check( false /* not called */, TEST_LOCATION );
6650 childData.Check( false /* not called */, TEST_LOCATION );
6651 grandChildData.Check( false /* not called */, TEST_LOCATION );
6656 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6658 TestApplication application;
6659 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6661 Actor actor = Actor::New();
6662 Stage::GetCurrent().Add( actor );
6664 application.SendNotification();
6665 application.Render();
6667 VisibilityChangedFunctorData data;
6668 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6670 Animation animation = Animation::New( 1.0f );
6671 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6673 data.Check( false, TEST_LOCATION );
6674 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6675 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6677 tet_infoline( "Play the animation and check the property value" );
6680 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6681 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6683 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6684 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6686 application.SendNotification();
6687 application.Render( 1100 ); // After the animation
6689 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6695 int utcDaliActorVisibilityChangeSignalByName(void)
6697 TestApplication application;
6698 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6700 Actor actor = Actor::New();
6702 bool signalCalled=false;
6703 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6704 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6705 actor.SetVisible( false );
6706 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6708 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6709 signalCalled = false;
6710 actor.SetVisible( false );
6711 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6713 tet_infoline( "Change the visibility using properties, ensure called" );
6714 actor.SetProperty( Actor::Property::VISIBLE, true );
6715 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6717 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6718 signalCalled = false;
6720 actor.SetProperty( Actor::Property::VISIBLE, true );
6721 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6727 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6729 gLayoutDirectionType = type;
6732 int UtcDaliActorLayoutDirectionProperty(void)
6734 TestApplication application;
6735 tet_infoline( "Check layout direction property" );
6737 Actor actor0 = Actor::New();
6738 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6739 Stage::GetCurrent().Add( actor0 );
6741 application.SendNotification();
6742 application.Render();
6744 Actor actor1 = Actor::New();
6745 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6746 Actor actor2 = Actor::New();
6747 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6748 Actor actor3 = Actor::New();
6749 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6750 Actor actor4 = Actor::New();
6751 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6752 Actor actor5 = Actor::New();
6753 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6754 Actor actor6 = Actor::New();
6755 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6756 Actor actor7 = Actor::New();
6757 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6758 Actor actor8 = Actor::New();
6759 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6760 Actor actor9 = Actor::New();
6761 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6763 actor1.Add( actor2 );
6764 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6765 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6767 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6768 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6769 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6771 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6772 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6773 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6775 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6776 actor0.Add( actor1 );
6777 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6778 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6780 Stage::GetCurrent().Add( actor3 );
6781 actor3.Add( actor4 );
6782 actor4.Add( actor5 );
6783 actor5.Add( actor6 );
6784 actor5.Add( actor7 );
6785 actor7.Add( actor8 );
6786 actor8.Add( actor9 );
6787 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6788 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6790 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6791 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6792 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6794 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6796 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6797 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6798 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6799 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6800 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6801 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6802 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6804 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6805 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6806 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6808 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6809 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6810 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6811 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6813 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6814 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6815 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6821 struct LayoutDirectionFunctor
6823 LayoutDirectionFunctor(bool& signalCalled)
6824 : mSignalCalled( signalCalled )
6828 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6829 : mSignalCalled( rhs.mSignalCalled )
6835 mSignalCalled = true;
6838 bool& mSignalCalled;
6841 int UtcDaliActorLayoutDirectionSignal(void)
6843 TestApplication application;
6844 tet_infoline( "Check changing layout direction property sends a signal" );
6846 Actor actor = Actor::New();
6847 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6848 Stage::GetCurrent().Add( actor );
6849 bool signalCalled = false;
6850 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6852 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6853 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6855 // Test that writing the same value doesn't send a signal
6856 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6857 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6859 // Test that writing a different value sends the signal
6860 signalCalled = false;
6861 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6862 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6864 signalCalled = false;
6865 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6866 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6871 struct ChildAddedSignalCheck
6873 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6874 : mSignalReceived( signalReceived ),
6875 mChildHandle( childHandle )
6879 void operator() ( Actor childHandle )
6881 mSignalReceived = true;
6882 mChildHandle = childHandle;
6886 mSignalReceived = true;
6887 mChildHandle = Actor();
6890 bool& mSignalReceived;
6891 Actor& mChildHandle;
6894 int UtcDaliChildAddedSignalP1(void)
6896 TestApplication application;
6897 auto stage = Stage::GetCurrent();
6899 bool signalReceived=false;
6902 ChildAddedSignalCheck signal( signalReceived, childActor );
6903 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6904 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6906 auto actorA = Actor::New();
6907 stage.Add( actorA );
6908 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6909 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6910 signalReceived = false;
6912 auto actorB = Actor::New();
6913 stage.Add( actorB );
6914 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6915 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6921 int UtcDaliChildAddedSignalP2(void)
6923 TestApplication application;
6924 auto stage = Stage::GetCurrent();
6926 bool signalReceived=false;
6929 ChildAddedSignalCheck signal( signalReceived, childActor );
6930 tet_infoline( "Connect to childAdded signal by name" );
6932 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6933 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6935 auto actorA = Actor::New();
6936 stage.Add( actorA );
6937 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6939 // Can't test which actor was added; signal signature is void() when connecting via name.
6940 signalReceived = false;
6942 auto actorB = Actor::New();
6943 stage.Add( actorB );
6944 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6949 int UtcDaliChildAddedSignalN(void)
6951 TestApplication application;
6952 auto stage = Stage::GetCurrent();
6954 bool signalReceived=false;
6957 ChildAddedSignalCheck signal( signalReceived, childActor );
6958 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6959 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6961 auto actorA = Actor::New();
6962 stage.Add( actorA );
6963 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6964 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6965 signalReceived = false;
6967 auto actorB = Actor::New();
6968 actorA.Add( actorB );
6969 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6974 struct ChildRemovedSignalCheck
6976 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6977 : mSignalReceived( signalReceived ),
6978 mChildHandle( childHandle )
6982 void operator() ( Actor childHandle )
6984 mSignalReceived = true;
6985 mChildHandle = childHandle;
6990 mSignalReceived = true;
6993 bool& mSignalReceived;
6994 Actor& mChildHandle;
6997 int UtcDaliChildRemovedSignalP1(void)
6999 TestApplication application;
7000 auto stage = Stage::GetCurrent();
7002 bool signalReceived=false;
7005 ChildRemovedSignalCheck signal( signalReceived, childActor );
7006 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7007 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7009 auto actorA = Actor::New();
7010 stage.Add( actorA );
7011 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7012 DALI_TEST_CHECK( !childActor );
7014 stage.Remove( actorA );
7015 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7016 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7018 signalReceived = false;
7019 auto actorB = Actor::New();
7020 stage.Add( actorB );
7021 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7023 stage.Remove( actorB );
7024 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7025 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7030 int UtcDaliChildRemovedSignalP2(void)
7032 TestApplication application;
7033 auto stage = Stage::GetCurrent();
7035 bool signalReceived=false;
7038 ChildAddedSignalCheck signal( signalReceived, childActor );
7039 tet_infoline( "Connect to childRemoved signal by name" );
7041 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7042 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7044 auto actorA = Actor::New();
7045 stage.Add( actorA );
7046 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7048 stage.Remove( actorA );
7049 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7051 signalReceived = false;
7052 auto actorB = Actor::New();
7053 stage.Add( actorB );
7054 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7056 stage.Remove( actorB );
7057 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7063 int UtcDaliChildRemovedSignalN(void)
7065 TestApplication application;
7066 auto stage = Stage::GetCurrent();
7068 bool signalReceived=false;
7071 ChildRemovedSignalCheck signal( signalReceived, childActor );
7072 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7073 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7075 auto actorA = Actor::New();
7076 stage.Add( actorA );
7078 auto actorB = Actor::New();
7079 actorA.Add( actorB );
7081 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7082 DALI_TEST_CHECK( ! childActor );
7084 actorA.Remove( actorB );
7085 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7090 int UtcDaliChildMovedSignalP(void)
7092 TestApplication application;
7093 auto stage = Stage::GetCurrent();
7095 bool addedASignalReceived = false;
7096 bool removedASignalReceived = false;
7097 bool addedBSignalReceived = false;
7098 bool removedBSignalReceived = false;
7101 auto actorA = Actor::New();
7102 auto actorB = Actor::New();
7103 stage.Add( actorA );
7104 stage.Add( actorB );
7106 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7107 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7108 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7109 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7111 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7112 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7113 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7114 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7116 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7117 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7118 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7119 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7121 // Create a child of A
7123 auto child = Actor::New();
7124 actorA.Add( child );
7126 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7127 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7128 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7129 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7130 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7133 addedASignalReceived = false;
7134 addedBSignalReceived = false;
7135 removedASignalReceived = false;
7136 removedBSignalReceived = false;
7138 actorB.Add( child ); // Expect this child to be re-parented
7139 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7140 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7141 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7142 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7144 // Move child back to A:
7145 addedASignalReceived = false;
7146 addedBSignalReceived = false;
7147 removedASignalReceived = false;
7148 removedBSignalReceived = false;
7150 actorA.Add( child ); // Expect this child to be re-parented
7151 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7152 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7153 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7154 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7160 int utcDaliActorCulled(void)
7162 TestApplication application;
7163 auto stage = Stage::GetCurrent();
7165 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7167 Actor actor = Actor::New();
7168 actor.SetSize( 10.0f, 10.0f );
7170 Geometry geometry = CreateQuadGeometry();
7171 Shader shader = CreateShader();
7172 Renderer renderer = Renderer::New(geometry, shader);
7173 actor.AddRenderer( renderer );
7177 application.SendNotification();
7178 application.Render( 0 );
7180 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
7182 PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
7183 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7185 // Connect NotifySignal
7186 bool propertyNotificationSignal( false );
7187 PropertyNotification source;
7188 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7189 notification.NotifySignal().Connect( &application, f ) ;
7191 actor.SetPosition( 1000.0f, 1000.0f );
7193 application.SendNotification();
7194 application.Render();
7196 application.SendNotification();
7198 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
7200 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7201 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
7202 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7207 int UtcDaliActorUpdateSizeHint(void)
7209 TestApplication application;
7211 Actor actor = Actor::New();
7212 Vector3 vector(100.0f, 100.0f, 0.0f);
7214 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
7216 actor.SetSize(vector.x, vector.y);
7219 Vector2 updateSizeHint = Vector2(150.f, 150.f);
7220 actor.SetProperty(Dali::DevelActor::Property::UPDATE_SIZE_HINT, updateSizeHint);
7222 // Flush the queue and render once
7223 application.SendNotification();
7224 application.Render();
7227 Vector2 currentSizeHint = actor.GetProperty( Dali::DevelActor::Property::UPDATE_SIZE_HINT ).Get< Vector2 >();
7228 DALI_TEST_EQUALS( currentSizeHint, updateSizeHint, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7230 // Flush the queue and render once
7231 application.SendNotification();
7232 application.Render();
7237 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7239 TestApplication application;
7240 auto stage = Stage::GetCurrent();
7242 tet_infoline( "Ensure we clear the screen when the last actor is removed" );
7244 Actor actor = CreateRenderableActor();
7245 actor.SetSize( 100.0f, 100.0f );
7248 application.SendNotification();
7249 application.Render();
7251 auto& glAbstraction = application.GetGlAbstraction();
7252 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7256 application.SendNotification();
7257 application.Render();
7259 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7264 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7266 TestApplication application;
7267 auto stage = Stage::GetCurrent();
7269 tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
7271 Actor actor = CreateRenderableActor();
7272 actor.SetSize( 100.0f, 100.0f );
7275 application.SendNotification();
7276 application.Render();
7278 auto& glAbstraction = application.GetGlAbstraction();
7279 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7281 actor.SetVisible( false );
7283 application.SendNotification();
7284 application.Render();
7286 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );