2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/dali-core.h>
21 #include <cfloat> // For FLT_MAX
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
34 void utc_dali_actor_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_actor_cleanup(void)
41 test_return_value = TET_PASS;
46 bool gTouchCallBackCalled=false;
47 bool gTouchCallBackCalled2=false;
48 bool gTouchCallBackCalled3=false;
50 bool gHoverCallBackCalled=false;
52 static bool gTestConstraintCalled;
54 LayoutDirection::Type gLayoutDirectionType;
58 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
60 gTestConstraintCalled = true;
65 * TestConstraint reference.
66 * When constraint is called, the resultRef is updated
67 * with the value supplied.
70 struct TestConstraintRef
72 TestConstraintRef(unsigned int& resultRef, unsigned int value)
73 : mResultRef(resultRef),
78 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
83 unsigned int& mResultRef;
87 static bool TestCallback(Actor actor, const TouchEvent& event)
89 gTouchCallBackCalled = true;
94 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
96 gTouchCallBackCalled = true;
101 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
103 gTouchCallBackCalled2 = true;
108 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
110 gTouchCallBackCalled3 = true;
115 static void ResetTouchCallbacks()
117 gTouchCallBackCalled = false;
118 gTouchCallBackCalled2 = false;
119 gTouchCallBackCalled3 = false;
122 static bool TestCallback3(Actor actor, const HoverEvent& event)
124 gHoverCallBackCalled = true;
129 // validation stuff for onstage & offstage signals
130 static std::vector< std::string > gActorNamesOnOffStage;
131 static int gOnStageCallBackCalled;
132 void OnStageCallback( Actor actor )
134 ++gOnStageCallBackCalled;
135 gActorNamesOnOffStage.push_back( actor.GetName() );
136 DALI_TEST_CHECK( actor.OnStage() == true );
138 static int gOffStageCallBackCalled;
139 void OffStageCallback( Actor actor )
141 ++gOffStageCallBackCalled;
142 gActorNamesOnOffStage.push_back( actor.GetName() );
143 DALI_TEST_CHECK( actor.OnStage() == false );
146 struct PositionComponentConstraint
148 PositionComponentConstraint(){}
150 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
152 const Matrix& m = inputs[0]->GetMatrix();
155 m.GetTransformComponents(pos, rot, scale);
159 struct OrientationComponentConstraint
161 OrientationComponentConstraint(){}
163 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
165 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
168 orientation = parentOrientation;
173 static bool gOnRelayoutCallBackCalled = false;
174 static std::vector< std::string > gActorNamesRelayout;
176 void OnRelayoutCallback( Actor actor )
178 gOnRelayoutCallBackCalled = true;
179 gActorNamesRelayout.push_back( actor.GetName() );
182 struct VisibilityChangedFunctorData
184 VisibilityChangedFunctorData()
187 type( DevelActor::VisibilityChange::SELF ),
196 type = DevelActor::VisibilityChange::SELF;
200 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
202 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
203 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
204 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
205 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
208 void Check( bool compareCalled, const std::string& location )
210 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
215 DevelActor::VisibilityChange::Type type;
219 struct VisibilityChangedFunctor
221 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
223 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
226 data.visible = visible;
231 VisibilityChangedFunctorData& data;
235 struct VisibilityChangedVoidFunctor
237 VisibilityChangedVoidFunctor(bool& signalCalled)
238 : mSignalCalled( signalCalled )
243 mSignalCalled = true;
249 struct ChildOrderChangedFunctor
251 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
252 : mSignalCalled( signalCalled ),
256 void operator()( Actor actor )
258 mSignalCalled = true;
266 } // anonymous namespace
269 //& purpose: Testing New API
270 int UtcDaliActorNew(void)
272 TestApplication application;
274 Actor actor = Actor::New();
276 DALI_TEST_CHECK(actor);
280 //& purpose: Testing Dali::Actor::DownCast()
281 int UtcDaliActorDownCastP(void)
283 TestApplication application;
284 tet_infoline("Testing Dali::Actor::DownCast()");
286 Actor actor = Actor::New();
287 BaseHandle object(actor);
288 Actor actor2 = Actor::DownCast(object);
289 DALI_TEST_CHECK(actor2);
293 //& purpose: Testing Dali::Actor::DownCast()
294 int UtcDaliActorDownCastN(void)
296 TestApplication application;
297 tet_infoline("Testing Dali::Actor::DownCast()");
299 BaseHandle unInitializedObject;
300 Actor actor = Actor::DownCast(unInitializedObject);
301 DALI_TEST_CHECK(!actor);
305 //& purpose: Testing Dali::Actor::GetName()
306 int UtcDaliActorGetName(void)
308 TestApplication application;
310 Actor actor = Actor::New();
312 DALI_TEST_CHECK(actor.GetName().empty());
316 //& purpose: Testing Dali::Actor::SetName()
317 int UtcDaliActorSetName(void)
319 TestApplication application;
321 string str("ActorName");
322 Actor actor = Actor::New();
325 DALI_TEST_CHECK(actor.GetName() == str);
329 int UtcDaliActorGetId(void)
331 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
332 TestApplication application;
334 Actor first = Actor::New();
335 Actor second = Actor::New();
336 Actor third = Actor::New();
338 DALI_TEST_CHECK(first.GetId() != second.GetId());
339 DALI_TEST_CHECK(second.GetId() != third.GetId());
343 int UtcDaliActorIsRoot(void)
345 TestApplication application;
347 Actor actor = Actor::New();
348 DALI_TEST_CHECK(!actor.IsRoot());
350 // get the root layer
351 actor = Stage::GetCurrent().GetLayer( 0 );
352 DALI_TEST_CHECK( actor.IsRoot() );
356 int UtcDaliActorOnStage(void)
358 TestApplication application;
360 Actor actor = Actor::New();
361 DALI_TEST_CHECK( !actor.OnStage() );
363 // get the root layer
364 actor = Stage::GetCurrent().GetLayer( 0 );
365 DALI_TEST_CHECK( actor.OnStage() );
369 int UtcDaliActorIsLayer(void)
371 TestApplication application;
373 Actor actor = Actor::New();
374 DALI_TEST_CHECK( !actor.IsLayer() );
376 // get the root layer
377 actor = Stage::GetCurrent().GetLayer( 0 );
378 DALI_TEST_CHECK( actor.IsLayer() );
382 int UtcDaliActorGetLayer(void)
384 TestApplication application;
386 Actor actor = Actor::New();
387 Stage::GetCurrent().Add(actor);
388 Layer layer = actor.GetLayer();
390 DALI_TEST_CHECK(layer);
392 // get the root layers layer
393 actor = Stage::GetCurrent().GetLayer( 0 );
394 DALI_TEST_CHECK( actor.GetLayer() );
398 int UtcDaliActorAddP(void)
400 tet_infoline("Testing Actor::Add");
401 TestApplication application;
403 Actor parent = Actor::New();
404 Actor child = Actor::New();
406 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
410 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
412 Actor parent2 = Actor::New();
413 parent2.Add( child );
415 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
416 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
418 // try Adding to same parent again, works
419 parent2.Add( child );
420 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
422 // try reparenting an orphaned child
424 Actor temporaryParent = Actor::New();
425 temporaryParent.Add( child );
426 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
428 // temporaryParent has now died, reparent the orphaned child
429 parent2.Add( child );
430 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
435 int UtcDaliActorAddN(void)
437 tet_infoline("Testing Actor::Add");
438 TestApplication application;
440 Actor child = Actor::New();
442 Actor parent2 = Actor::New();
443 parent2.Add( child );
448 parent2.Add( parent2 );
449 tet_printf("Assertion test failed - no Exception\n" );
450 tet_result(TET_FAIL);
452 catch(Dali::DaliException& e)
454 DALI_TEST_PRINT_ASSERT( e );
455 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
456 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
460 tet_printf("Assertion test failed - wrong Exception\n" );
461 tet_result(TET_FAIL);
464 // try reparenting root
467 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
468 tet_printf("Assertion test failed - no Exception\n" );
469 tet_result(TET_FAIL);
471 catch(Dali::DaliException& e)
473 DALI_TEST_PRINT_ASSERT( e );
474 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
475 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
479 tet_printf("Assertion test failed - wrong Exception\n" );
480 tet_result(TET_FAIL);
487 parent2.Add( empty );
488 tet_printf("Assertion test failed - no Exception\n" );
489 tet_result(TET_FAIL);
491 catch(Dali::DaliException& e)
493 DALI_TEST_PRINT_ASSERT( e );
494 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
495 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
499 tet_printf("Assertion test failed - wrong Exception\n" );
500 tet_result(TET_FAIL);
506 int UtcDaliActorRemoveN(void)
508 tet_infoline("Testing Actor::Remove");
509 TestApplication application;
511 Actor parent = Actor::New();
512 Actor child = Actor::New();
513 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
516 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
518 parent.Remove(child);
519 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
521 // remove again, no problem
522 parent.Remove(child);
523 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
527 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
528 // try Remove self, its a no-op
529 parent.Remove( parent );
530 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
536 parent.Remove( empty );
537 tet_printf("Assertion test failed - no Exception\n" );
538 tet_result(TET_FAIL);
540 catch(Dali::DaliException& e)
542 DALI_TEST_PRINT_ASSERT( e );
543 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
544 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
548 tet_printf("Assertion test failed - wrong Exception\n" );
549 tet_result(TET_FAIL);
554 int UtcDaliActorRemoveP(void)
556 TestApplication application;
558 Actor parent = Actor::New();
559 Actor child = Actor::New();
560 Actor random = Actor::New();
562 Stage::GetCurrent().Add( parent );
564 DALI_TEST_CHECK(parent.GetChildCount() == 0);
568 DALI_TEST_CHECK(parent.GetChildCount() == 1);
570 parent.Remove(random);
572 DALI_TEST_CHECK(parent.GetChildCount() == 1);
574 Stage::GetCurrent().Remove( parent );
576 DALI_TEST_CHECK(parent.GetChildCount() == 1);
580 int UtcDaliActorGetChildCount(void)
582 TestApplication application;
584 Actor parent = Actor::New();
585 Actor child = Actor::New();
587 DALI_TEST_CHECK(parent.GetChildCount() == 0);
591 DALI_TEST_CHECK(parent.GetChildCount() == 1);
595 int UtcDaliActorGetChildren01(void)
597 TestApplication application;
599 Actor parent = Actor::New();
600 Actor first = Actor::New();
601 Actor second = Actor::New();
602 Actor third = Actor::New();
608 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
609 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
610 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
614 int UtcDaliActorGetChildren02(void)
616 TestApplication application;
618 Actor parent = Actor::New();
619 Actor first = Actor::New();
620 Actor second = Actor::New();
621 Actor third = Actor::New();
627 const Actor& constParent = parent;
629 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
630 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
631 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
635 int UtcDaliActorGetParent01(void)
637 TestApplication application;
639 Actor parent = Actor::New();
640 Actor child = Actor::New();
644 DALI_TEST_CHECK(child.GetParent() == parent);
648 int UtcDaliActorGetParent02(void)
650 TestApplication application;
652 Actor actor = Actor::New();
654 DALI_TEST_CHECK(!actor.GetParent());
658 int UtcDaliActorCustomProperty(void)
660 TestApplication application;
662 Actor actor = Actor::New();
663 Stage::GetCurrent().Add( actor );
665 float startValue(1.0f);
666 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
667 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
669 application.SendNotification();
670 application.Render(0);
671 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
673 actor.SetProperty( index, 5.0f );
675 application.SendNotification();
676 application.Render(0);
677 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
681 int UtcDaliActorCustomPropertyIntToFloat(void)
683 TestApplication application;
685 Actor actor = Actor::New();
686 Stage::GetCurrent().Add( actor );
688 float startValue(5.0f);
689 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
690 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
692 application.SendNotification();
693 application.Render(0);
694 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
696 actor.SetProperty( index, int(1) );
698 application.SendNotification();
699 application.Render(0);
700 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
704 int UtcDaliActorCustomPropertyFloatToInt(void)
706 TestApplication application;
708 Actor actor = Actor::New();
709 Stage::GetCurrent().Add( actor );
712 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
713 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
715 application.SendNotification();
716 application.Render(0);
717 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
719 actor.SetProperty( index, float(1.5) );
721 application.SendNotification();
722 application.Render(0);
723 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
727 int UtcDaliActorSetParentOrigin(void)
729 TestApplication application;
731 Actor actor = Actor::New();
733 Vector3 vector(0.7f, 0.8f, 0.9f);
734 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
736 actor.SetParentOrigin(vector);
738 // flush the queue and render once
739 application.SendNotification();
740 application.Render();
742 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
744 Stage::GetCurrent().Add( actor );
746 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
748 // flush the queue and render once
749 application.SendNotification();
750 application.Render();
752 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
754 Stage::GetCurrent().Remove( actor );
758 int UtcDaliActorSetParentOriginIndividual(void)
760 TestApplication application;
762 Actor actor = Actor::New();
764 Vector3 vector(0.7f, 0.8f, 0.9f);
765 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
767 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
769 // flush the queue and render once
770 application.SendNotification();
771 application.Render();
773 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
775 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
777 // flush the queue and render once
778 application.SendNotification();
779 application.Render();
781 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
783 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
785 // flush the queue and render once
786 application.SendNotification();
787 application.Render();
789 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
794 int UtcDaliActorGetCurrentParentOrigin(void)
796 TestApplication application;
798 Actor actor = Actor::New();
800 Vector3 vector(0.7f, 0.8f, 0.9f);
801 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
803 actor.SetParentOrigin(vector);
805 // flush the queue and render once
806 application.SendNotification();
807 application.Render();
809 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
813 int UtcDaliActorSetAnchorPoint(void)
815 TestApplication application;
817 Actor actor = Actor::New();
819 Vector3 vector(0.7f, 0.8f, 0.9f);
820 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
822 actor.SetAnchorPoint(vector);
824 // flush the queue and render once
825 application.SendNotification();
826 application.Render();
828 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
830 Stage::GetCurrent().Add( actor );
832 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
833 // flush the queue and render once
834 application.SendNotification();
835 application.Render();
837 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
839 Stage::GetCurrent().Remove( actor );
843 int UtcDaliActorSetAnchorPointIndividual(void)
845 TestApplication application;
847 Actor actor = Actor::New();
849 Vector3 vector(0.7f, 0.8f, 0.9f);
850 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
852 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
854 // flush the queue and render once
855 application.SendNotification();
856 application.Render();
858 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
860 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
862 // flush the queue and render once
863 application.SendNotification();
864 application.Render();
866 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
868 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
870 // flush the queue and render once
871 application.SendNotification();
872 application.Render();
874 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
879 int UtcDaliActorGetCurrentAnchorPoint(void)
881 TestApplication application;
883 Actor actor = Actor::New();
885 Vector3 vector(0.7f, 0.8f, 0.9f);
886 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
888 actor.SetAnchorPoint(vector);
890 // flush the queue and render once
891 application.SendNotification();
892 application.Render();
894 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
898 // SetSize(float width, float height)
899 int UtcDaliActorSetSize01(void)
901 TestApplication application;
903 Actor actor = Actor::New();
904 Vector3 vector(100.0f, 100.0f, 0.0f);
906 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
908 actor.SetSize(vector.x, vector.y);
910 // Immediately retrieve the size after setting
911 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
912 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
913 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
914 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
915 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
917 // Flush the queue and render once
918 application.SendNotification();
919 application.Render();
921 // Check the size in the new frame
922 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
924 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
925 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
926 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
927 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
928 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
930 // Check async behaviour
931 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
932 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
933 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
934 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
935 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
937 // Change the resize policy and check whether the size stays the same
938 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
940 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
941 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
943 // Set a new size after resize policy is changed and check the new size
944 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
946 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
947 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
949 // Change the resize policy again and check whether the new size stays the same
950 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
952 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
953 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
955 // Set another new size after resize policy is changed and check the new size
956 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
958 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
959 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
964 // SetSize(float width, float height, float depth)
965 int UtcDaliActorSetSize02(void)
967 TestApplication application;
969 Actor actor = Actor::New();
970 Vector3 vector(100.0f, 100.0f, 100.0f);
972 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
974 actor.SetSize(vector.x, vector.y, vector.z);
976 // Immediately check the size after setting
977 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
978 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
980 // flush the queue and render once
981 application.SendNotification();
982 application.Render();
984 // Check the size in the new frame
985 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
987 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
988 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
993 // SetSize(Vector2 size)
994 int UtcDaliActorSetSize03(void)
996 TestApplication application;
998 Actor actor = Actor::New();
999 Vector3 vector(100.0f, 100.0f, 0.0f);
1001 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1003 actor.SetSize(Vector2(vector.x, vector.y));
1005 // Immediately check the size after setting
1006 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1007 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1009 // flush the queue and render once
1010 application.SendNotification();
1011 application.Render();
1013 // Check the size in the new frame
1014 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1016 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1017 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1022 // SetSize(Vector3 size)
1023 int UtcDaliActorSetSize04(void)
1025 TestApplication application;
1027 Actor actor = Actor::New();
1028 Vector3 vector(100.0f, 100.0f, 100.0f);
1030 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1032 actor.SetSize(vector);
1034 // Immediately check the size after setting
1035 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1036 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1038 // flush the queue and render once
1039 application.SendNotification();
1040 application.Render();
1042 // Check the size in the new frame
1043 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1045 Stage::GetCurrent().Add( actor );
1046 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
1048 // Immediately check the size after setting
1049 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1050 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1052 // flush the queue and render once
1053 application.SendNotification();
1054 application.Render();
1056 // Check the size in the new frame
1057 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
1059 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1060 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1062 Stage::GetCurrent().Remove( actor );
1066 int UtcDaliActorSetSizeIndividual(void)
1068 TestApplication application;
1070 Actor actor = Actor::New();
1072 Vector3 vector(0.7f, 0.8f, 0.9f);
1073 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1075 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1077 // Immediately check the width after setting
1078 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1079 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1081 // flush the queue and render once
1082 application.SendNotification();
1083 application.Render();
1085 // Check the width in the new frame
1086 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1088 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1089 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1091 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1093 // Immediately check the height after setting
1094 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1095 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1097 // flush the queue and render once
1098 application.SendNotification();
1099 application.Render();
1101 // Check the height in the new frame
1102 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1104 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1105 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1107 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1109 // Immediately check the depth after setting
1110 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1111 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1113 // flush the queue and render once
1114 application.SendNotification();
1115 application.Render();
1117 // Check the depth in the new frame
1118 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1120 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1121 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1123 // Change the resize policy and check whether the size stays the same
1124 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1126 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1127 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1129 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1130 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1132 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1133 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1135 // Change the resize policy again and check whether the size stays the same
1136 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1138 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1139 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1141 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1142 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1144 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1145 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1150 int UtcDaliActorSetSizeIndividual02(void)
1152 TestApplication application;
1154 Actor actor = Actor::New();
1155 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1156 Stage::GetCurrent().Add( actor );
1158 Vector3 vector( 100.0f, 200.0f, 400.0f );
1159 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1161 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1162 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1164 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1165 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1167 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1168 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1170 // flush the queue and render once
1171 application.SendNotification();
1172 application.Render();
1174 // Check the width in the new frame
1175 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1176 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1182 int UtcDaliActorGetCurrentSize(void)
1184 TestApplication application;
1186 Actor actor = Actor::New();
1187 Vector3 vector(100.0f, 100.0f, 20.0f);
1189 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1191 actor.SetSize(vector);
1193 // flush the queue and render once
1194 application.SendNotification();
1195 application.Render();
1197 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1201 int UtcDaliActorGetNaturalSize(void)
1203 TestApplication application;
1205 Actor actor = Actor::New();
1206 Vector3 vector( 0.0f, 0.0f, 0.0f );
1208 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1213 int UtcDaliActorGetCurrentSizeImmediate(void)
1215 TestApplication application;
1217 Actor actor = Actor::New();
1218 Vector3 vector(100.0f, 100.0f, 20.0f);
1220 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1221 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1223 actor.SetSize(vector);
1225 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1226 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1228 // flush the queue and render once
1229 application.SendNotification();
1230 application.Render();
1232 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1233 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1236 // Build the animation
1237 const float durationSeconds = 2.0f;
1238 Animation animation = Animation::New( durationSeconds );
1239 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1240 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1242 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1244 // Start the animation
1247 application.SendNotification();
1248 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1250 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1255 // SetPosition(float x, float y)
1256 int UtcDaliActorSetPosition01(void)
1258 TestApplication application;
1260 Actor actor = Actor::New();
1262 // Set to random to start off with
1263 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1265 Vector3 vector(100.0f, 100.0f, 0.0f);
1267 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1269 actor.SetPosition(vector.x, vector.y);
1270 // flush the queue and render once
1271 application.SendNotification();
1272 application.Render();
1273 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1275 Stage::GetCurrent().Add( actor );
1276 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1277 // flush the queue and render once
1278 application.SendNotification();
1279 application.Render();
1280 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1285 // flush the queue and render once
1286 application.SendNotification();
1287 application.Render();
1288 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1290 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1291 // flush the queue and render once
1292 application.SendNotification();
1293 application.Render();
1294 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1296 Stage::GetCurrent().Remove( actor );
1300 // SetPosition(float x, float y, float z)
1301 int UtcDaliActorSetPosition02(void)
1303 TestApplication application;
1305 Actor actor = Actor::New();
1307 // Set to random to start off with
1308 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1310 Vector3 vector(100.0f, 100.0f, 100.0f);
1312 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1314 actor.SetPosition(vector.x, vector.y, vector.z);
1316 // flush the queue and render once
1317 application.SendNotification();
1318 application.Render();
1320 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1324 // SetPosition(Vector3 position)
1325 int UtcDaliActorSetPosition03(void)
1327 TestApplication application;
1329 Actor actor = Actor::New();
1331 // Set to random to start off with
1332 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1334 Vector3 vector(100.0f, 100.0f, 100.0f);
1336 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1338 actor.SetPosition(vector);
1340 // flush the queue and render once
1341 application.SendNotification();
1342 application.Render();
1344 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1348 int UtcDaliActorSetX(void)
1350 TestApplication application;
1352 Actor actor = Actor::New();
1354 Vector3 vector(100.0f, 0.0f, 0.0f);
1356 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1360 // flush the queue and render once
1361 application.SendNotification();
1362 application.Render();
1364 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1368 int UtcDaliActorSetY(void)
1370 TestApplication application;
1372 Actor actor = Actor::New();
1374 Vector3 vector(0.0f, 100.0f, 0.0f);
1376 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1380 // flush the queue and render once
1381 application.SendNotification();
1382 application.Render();
1384 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1388 int UtcDaliActorSetZ(void)
1390 TestApplication application;
1392 Actor actor = Actor::New();
1394 Vector3 vector(0.0f, 0.0f, 100.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 UtcDaliActorSetPositionProperties(void)
1410 TestApplication application;
1412 Actor actor = Actor::New();
1414 Vector3 vector(0.7f, 0.8f, 0.9f);
1415 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1417 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1418 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1419 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1421 // flush the queue and render once
1422 application.SendNotification();
1423 application.Render();
1425 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1426 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1427 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1428 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1429 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1431 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1432 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1433 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1435 // flush the queue and render once
1436 application.SendNotification();
1437 application.Render();
1439 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1440 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1441 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1442 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1443 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1445 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1446 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1447 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1449 // flush the queue and render once
1450 application.SendNotification();
1451 application.Render();
1453 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1454 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1455 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1456 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1457 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1462 int UtcDaliActorTranslateBy(void)
1464 TestApplication application;
1466 Actor actor = Actor::New();
1467 Vector3 vector(100.0f, 100.0f, 100.0f);
1469 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1471 actor.SetPosition(vector);
1473 // flush the queue and render once
1474 application.SendNotification();
1475 application.Render();
1477 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1479 actor.TranslateBy(vector);
1481 // flush the queue and render once
1482 application.SendNotification();
1483 application.Render();
1485 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1489 int UtcDaliActorGetCurrentPosition(void)
1491 TestApplication application;
1493 Actor actor = Actor::New();
1494 Vector3 setVector(100.0f, 100.0f, 0.0f);
1495 actor.SetPosition(setVector);
1497 // flush the queue and render once
1498 application.SendNotification();
1499 application.Render();
1501 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1505 int UtcDaliActorGetCurrentWorldPosition(void)
1507 TestApplication application;
1509 Actor parent = Actor::New();
1510 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1511 parent.SetPosition( parentPosition );
1512 parent.SetParentOrigin( ParentOrigin::CENTER );
1513 parent.SetAnchorPoint( AnchorPoint::CENTER );
1514 Stage::GetCurrent().Add( parent );
1516 Actor child = Actor::New();
1517 child.SetParentOrigin( ParentOrigin::CENTER );
1518 child.SetAnchorPoint( AnchorPoint::CENTER );
1519 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1520 child.SetPosition( childPosition );
1521 parent.Add( child );
1523 // The actors should not have a world position yet
1524 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1525 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1527 application.SendNotification();
1528 application.Render(0);
1530 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1531 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1533 // The actors should have a world position now
1534 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1535 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1539 int UtcDaliActorInheritPosition(void)
1541 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1542 TestApplication application;
1544 Actor parent = Actor::New();
1545 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1546 parent.SetPosition( parentPosition );
1547 parent.SetParentOrigin( ParentOrigin::CENTER );
1548 parent.SetAnchorPoint( AnchorPoint::CENTER );
1549 Stage::GetCurrent().Add( parent );
1551 Actor child = Actor::New();
1552 child.SetParentOrigin( ParentOrigin::CENTER );
1553 child.SetAnchorPoint( AnchorPoint::CENTER );
1554 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1555 child.SetPosition( childPosition );
1556 parent.Add( child );
1558 // The actors should not have a world position yet
1559 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1560 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1562 // first test default, which is to inherit position
1563 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1564 application.SendNotification();
1565 application.Render(0); // should only really call Update as Render is not required to update scene
1566 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1567 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1568 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1569 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1572 //Change child position
1573 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1574 child.SetPosition( childOffset );
1576 // Change inheritance mode to not inherit
1577 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1578 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1579 application.SendNotification();
1580 application.Render(0); // should only really call Update as Render is not required to update scene
1581 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1582 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1583 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1584 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1588 int UtcDaliActorSetInheritPosition(void)
1590 tet_infoline("Testing Actor::SetInheritPosition");
1591 TestApplication application;
1593 Actor parent = Actor::New();
1594 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1595 parent.SetPosition( parentPosition );
1596 parent.SetParentOrigin( ParentOrigin::CENTER );
1597 parent.SetAnchorPoint( AnchorPoint::CENTER );
1598 Stage::GetCurrent().Add( parent );
1600 Actor child = Actor::New();
1601 child.SetParentOrigin( ParentOrigin::CENTER );
1602 child.SetAnchorPoint( AnchorPoint::CENTER );
1603 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1604 child.SetPosition( childPosition );
1605 parent.Add( child );
1607 // The actors should not have a world position yet
1608 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1609 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1611 // first test default, which is to inherit position
1612 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1613 application.SendNotification();
1614 application.Render(0); // should only really call Update as Render is not required to update scene
1615 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1616 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1617 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1618 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1620 //Change child position
1621 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1622 child.SetPosition( childOffset );
1624 // Use local position as world postion
1625 child.SetInheritPosition( false );
1626 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1627 application.SendNotification();
1628 application.Render(0); // should only really call Update as Render is not required to update scene
1629 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1630 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1631 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1632 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1634 //Change back to inherit position from parent
1635 child.SetInheritPosition( true );
1636 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1637 application.SendNotification();
1638 application.Render(0); // should only really call Update as Render is not required to update scene
1639 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1640 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1641 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1642 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1646 // SetOrientation(float angleRadians, Vector3 axis)
1647 int UtcDaliActorSetOrientation01(void)
1649 TestApplication application;
1651 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1652 Actor actor = Actor::New();
1654 actor.SetOrientation(rotation);
1656 // flush the queue and render once
1657 application.SendNotification();
1658 application.Render();
1660 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1664 int UtcDaliActorSetOrientation02(void)
1666 TestApplication application;
1668 Actor actor = Actor::New();
1670 Radian angle( 0.785f );
1671 Vector3 axis(1.0f, 1.0f, 0.0f);
1673 actor.SetOrientation( angle, axis);
1674 Quaternion rotation( angle, axis );
1675 // flush the queue and render once
1676 application.SendNotification();
1677 application.Render();
1678 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1680 Stage::GetCurrent().Add( actor );
1681 actor.RotateBy( Degree( 360 ), axis);
1682 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1684 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1685 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1686 // flush the queue and render once
1687 application.SendNotification();
1688 application.Render();
1689 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1691 actor.SetOrientation( angle, axis);
1692 // flush the queue and render once
1693 application.SendNotification();
1694 application.Render();
1695 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1697 Stage::GetCurrent().Remove( actor );
1701 // SetOrientation(float angleRadians, Vector3 axis)
1702 int UtcDaliActorSetOrientationProperty(void)
1704 TestApplication application;
1706 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1707 Actor actor = Actor::New();
1709 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1710 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1712 // flush the queue and render once
1713 application.SendNotification();
1714 application.Render();
1716 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1717 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1718 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1722 // RotateBy(float angleRadians, Vector3 axis)
1723 int UtcDaliActorRotateBy01(void)
1725 TestApplication application;
1727 Actor actor = Actor::New();
1729 Radian angle( M_PI * 0.25f );
1730 actor.RotateBy(( angle ), Vector3::ZAXIS);
1731 // flush the queue and render once
1732 application.SendNotification();
1733 application.Render();
1734 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1736 Stage::GetCurrent().Add( actor );
1738 actor.RotateBy( angle, Vector3::ZAXIS);
1739 // flush the queue and render once
1740 application.SendNotification();
1741 application.Render();
1742 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1744 Stage::GetCurrent().Remove( actor );
1748 // RotateBy(Quaternion relativeRotation)
1749 int UtcDaliActorRotateBy02(void)
1751 TestApplication application;
1753 Actor actor = Actor::New();
1755 Radian angle( M_PI * 0.25f );
1756 Quaternion rotation(angle, Vector3::ZAXIS);
1757 actor.RotateBy(rotation);
1758 // flush the queue and render once
1759 application.SendNotification();
1760 application.Render();
1761 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1763 actor.RotateBy(rotation);
1764 // flush the queue and render once
1765 application.SendNotification();
1766 application.Render();
1767 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1771 int UtcDaliActorGetCurrentOrientation(void)
1773 TestApplication application;
1774 Actor actor = Actor::New();
1776 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1777 actor.SetOrientation(rotation);
1778 // flush the queue and render once
1779 application.SendNotification();
1780 application.Render();
1781 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1785 int UtcDaliActorGetCurrentWorldOrientation(void)
1787 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1788 TestApplication application;
1790 Actor parent = Actor::New();
1791 Radian rotationAngle( Degree(90.0f) );
1792 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1793 parent.SetOrientation( rotation );
1794 Stage::GetCurrent().Add( parent );
1796 Actor child = Actor::New();
1797 child.SetOrientation( rotation );
1798 parent.Add( child );
1800 // The actors should not have a world rotation yet
1801 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1802 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1804 application.SendNotification();
1805 application.Render(0);
1807 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1808 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1810 // The actors should have a world rotation now
1811 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1812 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1814 // turn off child rotation inheritance
1815 child.SetInheritOrientation( false );
1816 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1817 application.SendNotification();
1818 application.Render(0);
1820 // The actors should have a world rotation now
1821 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1822 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1826 // SetScale(float scale)
1827 int UtcDaliActorSetScale01(void)
1829 TestApplication application;
1831 Actor actor = Actor::New();
1833 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1834 actor.SetScale(0.25f);
1836 Vector3 scale(10.0f, 10.0f, 10.0f);
1837 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1839 actor.SetScale(scale.x);
1841 // flush the queue and render once
1842 application.SendNotification();
1843 application.Render();
1845 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1849 // SetScale(float scaleX, float scaleY, float scaleZ)
1850 int UtcDaliActorSetScale02(void)
1852 TestApplication application;
1853 Vector3 scale(10.0f, 10.0f, 10.0f);
1855 Actor actor = Actor::New();
1857 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1858 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1860 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1862 actor.SetScale(scale.x, scale.y, scale.z);
1863 // flush the queue and render once
1864 application.SendNotification();
1865 application.Render();
1866 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1868 // add to stage and test
1869 Stage::GetCurrent().Add( actor );
1870 actor.SetScale( 2.0f, 2.0f, 2.0f );
1871 // flush the queue and render once
1872 application.SendNotification();
1873 application.Render();
1874 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1876 Stage::GetCurrent().Remove( actor );
1881 // SetScale(Vector3 scale)
1882 int UtcDaliActorSetScale03(void)
1884 TestApplication application;
1885 Vector3 scale(10.0f, 10.0f, 10.0f);
1887 Actor actor = Actor::New();
1889 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1890 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1892 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1894 actor.SetScale(scale);
1896 // flush the queue and render once
1897 application.SendNotification();
1898 application.Render();
1900 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1904 int UtcDaliActorSetScaleIndividual(void)
1906 TestApplication application;
1908 Actor actor = Actor::New();
1910 Vector3 vector(0.7f, 0.8f, 0.9f);
1911 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1913 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1914 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1916 // flush the queue and render once
1917 application.SendNotification();
1918 application.Render();
1920 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1921 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1922 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1924 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1925 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1927 // flush the queue and render once
1928 application.SendNotification();
1929 application.Render();
1931 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1932 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1933 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1935 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1936 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1938 // flush the queue and render once
1939 application.SendNotification();
1940 application.Render();
1942 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1943 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1944 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1946 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1947 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1952 int UtcDaliActorScaleBy(void)
1954 TestApplication application;
1955 Actor actor = Actor::New();
1956 Vector3 vector(100.0f, 100.0f, 100.0f);
1958 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1960 actor.SetScale(vector);
1962 // flush the queue and render once
1963 application.SendNotification();
1964 application.Render();
1966 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1968 actor.ScaleBy(vector);
1970 // flush the queue and render once
1971 application.SendNotification();
1972 application.Render();
1974 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1978 int UtcDaliActorGetCurrentScale(void)
1980 TestApplication application;
1981 Vector3 scale(12.0f, 1.0f, 2.0f);
1983 Actor actor = Actor::New();
1985 actor.SetScale(scale);
1987 // flush the queue and render once
1988 application.SendNotification();
1989 application.Render();
1991 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1995 int UtcDaliActorGetCurrentWorldScale(void)
1997 TestApplication application;
1999 Actor parent = Actor::New();
2000 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2001 parent.SetScale( parentScale );
2002 Stage::GetCurrent().Add( parent );
2004 Actor child = Actor::New();
2005 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2006 child.SetScale( childScale );
2007 parent.Add( child );
2009 // The actors should not have a scale yet
2010 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2011 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
2013 // The actors should not have a world scale yet
2014 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2015 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2017 application.SendNotification();
2018 application.Render(0);
2020 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2021 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2023 // The actors should have a world scale now
2024 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2025 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2029 int UtcDaliActorInheritScale(void)
2031 tet_infoline("Testing Actor::SetInheritScale");
2032 TestApplication application;
2034 Actor parent = Actor::New();
2035 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2036 parent.SetScale( parentScale );
2037 Stage::GetCurrent().Add( parent );
2039 Actor child = Actor::New();
2040 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2041 child.SetScale( childScale );
2042 parent.Add( child );
2044 application.SendNotification();
2045 application.Render(0);
2047 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2048 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2050 child.SetInheritScale( false );
2051 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2053 application.SendNotification();
2054 application.Render(0);
2056 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2060 int UtcDaliActorSetVisible(void)
2062 TestApplication application;
2064 Actor actor = Actor::New();
2065 actor.SetVisible(false);
2066 // flush the queue and render once
2067 application.SendNotification();
2068 application.Render();
2069 DALI_TEST_CHECK(actor.IsVisible() == false);
2071 actor.SetVisible(true);
2072 // flush the queue and render once
2073 application.SendNotification();
2074 application.Render();
2075 DALI_TEST_CHECK(actor.IsVisible() == true);
2077 // put actor on stage
2078 Stage::GetCurrent().Add( actor );
2079 actor.SetVisible(false);
2080 // flush the queue and render once
2081 application.SendNotification();
2082 application.Render();
2083 DALI_TEST_CHECK(actor.IsVisible() == false);
2087 int UtcDaliActorIsVisible(void)
2089 TestApplication application;
2091 Actor actor = Actor::New();
2093 DALI_TEST_CHECK(actor.IsVisible() == true);
2097 int UtcDaliActorSetOpacity(void)
2099 TestApplication application;
2101 Actor actor = Actor::New();
2102 // initial opacity is 1
2103 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2105 actor.SetOpacity( 0.4f);
2106 // flush the queue and render once
2107 application.SendNotification();
2108 application.Render();
2109 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2111 // change opacity, actor is on stage to change is not immediate
2112 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2113 // flush the queue and render once
2114 application.SendNotification();
2115 application.Render();
2116 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2118 // put actor on stage
2119 Stage::GetCurrent().Add( actor );
2121 // change opacity, actor is on stage to change is not immediate
2122 actor.SetOpacity( 0.9f );
2123 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2124 // flush the queue and render once
2125 application.SendNotification();
2126 application.Render();
2127 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2129 // change opacity, actor is on stage to change is not immediate
2130 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2131 // flush the queue and render once
2132 application.SendNotification();
2133 application.Render();
2134 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2138 int UtcDaliActorGetCurrentOpacity(void)
2140 TestApplication application;
2142 Actor actor = Actor::New();
2143 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2145 actor.SetOpacity(0.5f);
2146 // flush the queue and render once
2147 application.SendNotification();
2148 application.Render();
2149 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2153 int UtcDaliActorSetSensitive(void)
2155 TestApplication application;
2156 Actor actor = Actor::New();
2158 bool sensitive = !actor.IsSensitive();
2160 actor.SetSensitive(sensitive);
2162 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2166 int UtcDaliActorIsSensitive(void)
2168 TestApplication application;
2169 Actor actor = Actor::New();
2170 actor.SetSensitive(false);
2172 DALI_TEST_CHECK(false == actor.IsSensitive());
2176 int UtcDaliActorSetColor(void)
2178 TestApplication application;
2179 Actor actor = Actor::New();
2180 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2182 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2184 actor.SetColor(color);
2185 // flush the queue and render once
2186 application.SendNotification();
2187 application.Render();
2188 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2190 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2191 // flush the queue and render once
2192 application.SendNotification();
2193 application.Render();
2194 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2196 Stage::GetCurrent().Add( actor );
2197 actor.SetColor( color );
2198 // flush the queue and render once
2199 application.SendNotification();
2200 application.Render();
2201 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2203 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2204 // flush the queue and render once
2205 application.SendNotification();
2206 application.Render();
2207 // Actor color is not clamped
2208 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2209 // world color is clamped
2210 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2212 Stage::GetCurrent().Remove( actor );
2216 int UtcDaliActorSetColorIndividual(void)
2218 TestApplication application;
2220 Actor actor = Actor::New();
2222 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2223 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2225 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2226 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2228 // flush the queue and render once
2229 application.SendNotification();
2230 application.Render();
2232 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2233 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2234 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2236 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2237 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2239 // flush the queue and render once
2240 application.SendNotification();
2241 application.Render();
2243 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2244 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2245 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2247 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2248 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2250 // flush the queue and render once
2251 application.SendNotification();
2252 application.Render();
2254 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2255 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2256 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2259 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2260 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2262 // flush the queue and render once
2263 application.SendNotification();
2264 application.Render();
2266 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2267 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2268 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2270 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2271 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2273 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2276 // flush the queue and render once
2277 application.SendNotification();
2278 application.Render();
2280 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2286 int UtcDaliActorGetCurrentColor(void)
2288 TestApplication application;
2289 Actor actor = Actor::New();
2290 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2292 actor.SetColor(color);
2293 // flush the queue and render once
2294 application.SendNotification();
2295 application.Render();
2296 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2300 int UtcDaliActorGetCurrentWorldColor(void)
2302 tet_infoline("Actor::GetCurrentWorldColor");
2303 TestApplication application;
2305 Actor parent = Actor::New();
2306 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2307 parent.SetColor( parentColor );
2308 Stage::GetCurrent().Add( parent );
2310 Actor child = Actor::New();
2311 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2312 child.SetColor( childColor );
2313 parent.Add( child );
2315 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2316 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2318 // verify the default color mode
2319 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2321 // The actors should not have a world color yet
2322 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2323 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2325 application.SendNotification();
2326 application.Render(0);
2328 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2329 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2331 // The actors should have a world color now
2332 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2333 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2336 child.SetColorMode( USE_OWN_COLOR );
2337 application.SendNotification();
2338 application.Render(0);
2339 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2342 child.SetColorMode( USE_PARENT_COLOR );
2343 application.SendNotification();
2344 application.Render(0);
2345 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2346 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2349 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2350 application.SendNotification();
2351 application.Render(0);
2352 Vector4 expectedColor( childColor );
2353 expectedColor.a *= parentColor.a;
2354 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2355 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2359 int UtcDaliActorSetColorMode(void)
2361 tet_infoline("Actor::SetColorMode");
2362 TestApplication application;
2363 Actor actor = Actor::New();
2364 Actor child = Actor::New();
2367 actor.SetColorMode( USE_OWN_COLOR );
2368 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2370 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2371 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2373 actor.SetColorMode( USE_PARENT_COLOR );
2374 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2376 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2377 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2381 int UtcDaliActorScreenToLocal(void)
2383 TestApplication application;
2384 Actor actor = Actor::New();
2385 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2386 actor.SetSize(100.0f, 100.0f);
2387 actor.SetPosition(10.0f, 10.0f);
2388 Stage::GetCurrent().Add(actor);
2390 // flush the queue and render once
2391 application.SendNotification();
2392 application.Render();
2397 application.SendNotification();
2398 application.Render();
2400 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2402 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2403 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2407 int UtcDaliActorSetLeaveRequired(void)
2409 TestApplication application;
2411 Actor actor = Actor::New();
2413 actor.SetLeaveRequired(false);
2414 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2416 actor.SetLeaveRequired(true);
2417 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2421 int UtcDaliActorGetLeaveRequired(void)
2423 TestApplication application;
2425 Actor actor = Actor::New();
2427 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2431 int UtcDaliActorSetKeyboardFocusable(void)
2433 TestApplication application;
2435 Actor actor = Actor::New();
2437 actor.SetKeyboardFocusable(true);
2438 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2440 actor.SetKeyboardFocusable(false);
2441 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2445 int UtcDaliActorIsKeyboardFocusable(void)
2447 TestApplication application;
2449 Actor actor = Actor::New();
2451 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2455 int UtcDaliActorRemoveConstraints(void)
2457 tet_infoline(" UtcDaliActorRemoveConstraints");
2458 TestApplication application;
2460 gTestConstraintCalled = false;
2462 Actor actor = Actor::New();
2464 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2466 actor.RemoveConstraints();
2468 DALI_TEST_CHECK( gTestConstraintCalled == false );
2470 Stage::GetCurrent().Add( actor );
2473 // flush the queue and render once
2474 application.SendNotification();
2475 application.Render();
2477 actor.RemoveConstraints();
2479 DALI_TEST_CHECK( gTestConstraintCalled == true );
2483 int UtcDaliActorRemoveConstraintTag(void)
2485 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2486 TestApplication application;
2488 Actor actor = Actor::New();
2490 // 1. Apply Constraint1 and Constraint2, and test...
2491 unsigned int result1 = 0u;
2492 unsigned int result2 = 0u;
2494 unsigned constraint1Tag = 1u;
2495 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2496 constraint1.SetTag( constraint1Tag );
2497 constraint1.Apply();
2499 unsigned constraint2Tag = 2u;
2500 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2501 constraint2.SetTag( constraint2Tag );
2502 constraint2.Apply();
2504 Stage::GetCurrent().Add( actor );
2505 // flush the queue and render once
2506 application.SendNotification();
2507 application.Render();
2509 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2510 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2512 // 2. Remove Constraint1 and test...
2515 actor.RemoveConstraints(constraint1Tag);
2516 // make color property dirty, which will trigger constraints to be reapplied.
2517 actor.SetColor( Color::WHITE );
2518 // flush the queue and render once
2519 application.SendNotification();
2520 application.Render();
2522 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2523 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2525 // 3. Re-Apply Constraint1 and test...
2528 constraint1.Apply();
2529 // make color property dirty, which will trigger constraints to be reapplied.
2530 actor.SetColor( Color::WHITE );
2531 // flush the queue and render once
2532 application.SendNotification();
2533 application.Render();
2535 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2536 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2538 // 2. Remove Constraint2 and test...
2541 actor.RemoveConstraints(constraint2Tag);
2542 // make color property dirty, which will trigger constraints to be reapplied.
2543 actor.SetColor( Color::WHITE );
2544 // flush the queue and render once
2545 application.SendNotification();
2546 application.Render();
2548 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2549 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2551 // 2. Remove Constraint1 as well and test...
2554 actor.RemoveConstraints(constraint1Tag);
2555 // make color property dirty, which will trigger constraints to be reapplied.
2556 actor.SetColor( Color::WHITE );
2557 // flush the queue and render once
2558 application.SendNotification();
2559 application.Render();
2561 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2562 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2566 int UtcDaliActorTouchedSignal(void)
2568 TestApplication application;
2570 ResetTouchCallbacks();
2572 // get the root layer
2573 Actor actor = Stage::GetCurrent().GetRootLayer();
2574 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2576 application.SendNotification();
2577 application.Render();
2579 // connect to its touch signal
2580 actor.TouchedSignal().Connect( TestCallback );
2582 // simulate a touch event in the middle of the screen
2583 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2584 Dali::Integration::Point point;
2585 point.SetDeviceId( 1 );
2586 point.SetState( PointState::DOWN );
2587 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2588 Dali::Integration::TouchEvent touchEvent;
2589 touchEvent.AddPoint( point );
2590 application.ProcessEvent( touchEvent );
2592 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2596 int UtcDaliActorHoveredSignal(void)
2598 TestApplication application;
2600 gHoverCallBackCalled = false;
2602 // get the root layer
2603 Actor actor = Stage::GetCurrent().GetRootLayer();
2604 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2606 application.SendNotification();
2607 application.Render();
2609 // connect to its hover signal
2610 actor.HoveredSignal().Connect( TestCallback3 );
2612 // simulate a hover event in the middle of the screen
2613 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2614 Dali::Integration::Point point;
2615 point.SetDeviceId( 1 );
2616 point.SetState( PointState::MOTION );
2617 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2618 Dali::Integration::HoverEvent hoverEvent;
2619 hoverEvent.AddPoint( point );
2620 application.ProcessEvent( hoverEvent );
2622 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2626 int UtcDaliActorOnOffStageSignal(void)
2628 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2630 TestApplication application;
2633 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2634 gActorNamesOnOffStage.clear();
2636 Actor parent = Actor::New();
2637 parent.SetName( "parent" );
2638 parent.OnStageSignal().Connect( OnStageCallback );
2639 parent.OffStageSignal().Connect( OffStageCallback );
2641 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2642 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2644 // add parent to stage
2645 Stage::GetCurrent().Add( parent );
2646 // onstage emitted, offstage not
2647 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2648 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2649 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2651 // test adding a child, should get onstage emitted
2653 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2654 gActorNamesOnOffStage.clear();
2656 Actor child = Actor::New();
2657 child.SetName( "child" );
2658 child.OnStageSignal().Connect( OnStageCallback );
2659 child.OffStageSignal().Connect( OffStageCallback );
2660 parent.Add( child ); // add child
2661 // onstage emitted, offstage not
2662 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2663 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2664 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2666 // test removing parent from stage
2668 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2669 gActorNamesOnOffStage.clear();
2671 Stage::GetCurrent().Remove( parent );
2672 // onstage not emitted, offstage is
2673 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2674 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2675 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2676 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2678 // test adding parent back to stage
2680 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2681 gActorNamesOnOffStage.clear();
2683 Stage::GetCurrent().Add( parent );
2684 // onstage emitted, offstage not
2685 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2686 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2687 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2688 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2690 // test removing child
2692 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2693 gActorNamesOnOffStage.clear();
2695 parent.Remove( child );
2696 // onstage not emitted, offstage is
2697 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2698 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2699 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2701 // test removing parent
2703 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2704 gActorNamesOnOffStage.clear();
2706 Stage::GetCurrent().Remove( parent );
2707 // onstage not emitted, offstage is
2708 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2709 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2710 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2714 int UtcDaliActorFindChildByName(void)
2716 tet_infoline("Testing Dali::Actor::FindChildByName()");
2717 TestApplication application;
2719 Actor parent = Actor::New();
2720 parent.SetName( "parent" );
2721 Actor first = Actor::New();
2722 first .SetName( "first" );
2723 Actor second = Actor::New();
2724 second.SetName( "second" );
2729 Actor found = parent.FindChildByName( "foo" );
2730 DALI_TEST_CHECK( !found );
2732 found = parent.FindChildByName( "parent" );
2733 DALI_TEST_CHECK( found == parent );
2735 found = parent.FindChildByName( "first" );
2736 DALI_TEST_CHECK( found == first );
2738 found = parent.FindChildByName( "second" );
2739 DALI_TEST_CHECK( found == second );
2743 int UtcDaliActorFindChildById(void)
2745 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2746 TestApplication application;
2748 Actor parent = Actor::New();
2749 Actor first = Actor::New();
2750 Actor second = Actor::New();
2755 Actor found = parent.FindChildById( 100000 );
2756 DALI_TEST_CHECK( !found );
2758 found = parent.FindChildById( parent.GetId() );
2759 DALI_TEST_CHECK( found == parent );
2761 found = parent.FindChildById( first.GetId() );
2762 DALI_TEST_CHECK( found == first );
2764 found = parent.FindChildById( second.GetId() );
2765 DALI_TEST_CHECK( found == second );
2769 int UtcDaliActorHitTest(void)
2774 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2776 mTouchPoint( touchPoint ),
2781 Vector2 mTouchPoint;
2785 TestApplication application;
2786 tet_infoline(" UtcDaliActorHitTest");
2788 // Fill a vector with different hit tests.
2789 struct HitTestData* hitTestData[] = {
2790 // scale touch point result
2791 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2792 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2793 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.
2794 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2795 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.
2799 // get the root layer
2800 Actor actor = Actor::New();
2801 actor.SetAnchorPoint( AnchorPoint::CENTER );
2802 actor.SetParentOrigin( ParentOrigin::CENTER );
2804 Stage::GetCurrent().Add( actor );
2806 ResetTouchCallbacks();
2808 unsigned int index = 0;
2809 while( NULL != hitTestData[index] )
2811 actor.SetSize( 1.f, 1.f );
2812 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2814 // flush the queue and render once
2815 application.SendNotification();
2816 application.Render();
2818 DALI_TEST_CHECK( !gTouchCallBackCalled );
2820 // connect to its touch signal
2821 actor.TouchedSignal().Connect(TestCallback);
2823 Dali::Integration::Point point;
2824 point.SetState( PointState::DOWN );
2825 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2826 Dali::Integration::TouchEvent event;
2827 event.AddPoint( point );
2829 // flush the queue and render once
2830 application.SendNotification();
2831 application.Render();
2832 application.ProcessEvent( event );
2834 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2836 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2837 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2838 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2839 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2840 hitTestData[index]->mResult );
2842 ResetTouchCallbacks();
2848 int UtcDaliActorSetDrawMode(void)
2850 TestApplication app;
2851 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2853 Actor a = Actor::New();
2855 Stage::GetCurrent().Add(a);
2856 app.SendNotification();
2858 app.SendNotification();
2861 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2863 a.SetDrawMode( DrawMode::OVERLAY_2D );
2864 app.SendNotification();
2867 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2869 a.SetDrawMode( DrawMode::NORMAL );
2870 app.SendNotification();
2873 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2877 int UtcDaliActorSetDrawModeOverlayRender(void)
2879 TestApplication app;
2880 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2882 app.SendNotification();
2885 std::vector<GLuint> ids;
2886 ids.push_back( 8 ); // first rendered actor
2887 ids.push_back( 9 ); // second rendered actor
2888 ids.push_back( 10 ); // third rendered actor
2889 app.GetGlAbstraction().SetNextTextureIds( ids );
2891 BufferImage imageA = BufferImage::New(16, 16);
2892 BufferImage imageB = BufferImage::New(16, 16);
2893 BufferImage imageC = BufferImage::New(16, 16);
2894 Actor a = CreateRenderableActor( imageA );
2895 Actor b = CreateRenderableActor( imageB );
2896 Actor c = CreateRenderableActor( imageC );
2898 app.SendNotification();
2901 //Textures are bound when first created. Clear bound textures vector
2902 app.GetGlAbstraction().ClearBoundTextures();
2904 // Render a,b,c as regular non-overlays. so order will be:
2908 Stage::GetCurrent().Add(a);
2909 Stage::GetCurrent().Add(b);
2910 Stage::GetCurrent().Add(c);
2912 app.SendNotification();
2915 // Should be 3 textures changes.
2916 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2917 typedef std::vector<GLuint>::size_type TextureSize;
2918 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2919 if( boundTextures.size() == 3 )
2921 DALI_TEST_CHECK( boundTextures[0] == 8u );
2922 DALI_TEST_CHECK( boundTextures[1] == 9u );
2923 DALI_TEST_CHECK( boundTextures[2] == 10u );
2926 // Now texture ids have been set, we can monitor their render order.
2927 // render a as an overlay (last), so order will be:
2931 a.SetDrawMode( DrawMode::OVERLAY_2D );
2932 app.GetGlAbstraction().ClearBoundTextures();
2934 app.SendNotification();
2937 // Should be 3 texture changes.
2938 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2939 if( boundTextures.size() == 3 )
2941 DALI_TEST_CHECK( boundTextures[0] == 9u );
2942 DALI_TEST_CHECK( boundTextures[1] == 10u );
2943 DALI_TEST_CHECK( boundTextures[2] == 8u );
2948 int UtcDaliActorGetCurrentWorldMatrix(void)
2950 TestApplication app;
2951 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2953 Actor parent = Actor::New();
2954 parent.SetParentOrigin(ParentOrigin::CENTER);
2955 parent.SetAnchorPoint(AnchorPoint::CENTER);
2956 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2957 Radian rotationAngle(Degree(85.0f));
2958 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2959 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2960 parent.SetPosition( parentPosition );
2961 parent.SetOrientation( parentRotation );
2962 parent.SetScale( parentScale );
2963 Stage::GetCurrent().Add( parent );
2965 Actor child = Actor::New();
2966 child.SetParentOrigin(ParentOrigin::CENTER);
2967 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2968 Radian childRotationAngle(Degree(23.0f));
2969 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2970 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2971 child.SetPosition( childPosition );
2972 child.SetOrientation( childRotation );
2973 child.SetScale( childScale );
2974 parent.Add( child );
2976 app.SendNotification();
2979 app.SendNotification();
2981 Matrix parentMatrix(false);
2982 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2984 Matrix childMatrix(false);
2985 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2987 //Child matrix should be the composition of child and parent
2988 Matrix childWorldMatrix(false);
2989 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2991 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2992 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2998 int UtcDaliActorConstrainedToWorldMatrix(void)
3000 TestApplication app;
3001 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3003 Actor parent = Actor::New();
3004 parent.SetParentOrigin(ParentOrigin::CENTER);
3005 parent.SetAnchorPoint(AnchorPoint::CENTER);
3006 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3007 Radian rotationAngle(Degree(85.0f));
3008 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3009 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3010 parent.SetPosition( parentPosition );
3011 parent.SetOrientation( parentRotation );
3012 parent.SetScale( parentScale );
3013 Stage::GetCurrent().Add( parent );
3015 Actor child = Actor::New();
3016 child.SetParentOrigin(ParentOrigin::CENTER);
3017 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3018 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3019 posConstraint.Apply();
3021 Stage::GetCurrent().Add( child );
3023 app.SendNotification();
3026 app.SendNotification();
3028 Matrix parentMatrix(false);
3029 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3031 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3032 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3036 int UtcDaliActorConstrainedToOrientation(void)
3038 TestApplication app;
3039 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3041 Actor parent = Actor::New();
3042 parent.SetParentOrigin(ParentOrigin::CENTER);
3043 parent.SetAnchorPoint(AnchorPoint::CENTER);
3044 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3045 Radian rotationAngle(Degree(85.0f));
3046 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3047 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3048 parent.SetPosition( parentPosition );
3049 parent.SetOrientation( parentRotation );
3050 parent.SetScale( parentScale );
3051 Stage::GetCurrent().Add( parent );
3053 Actor child = Actor::New();
3054 child.SetParentOrigin(ParentOrigin::CENTER);
3055 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3056 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3057 posConstraint.Apply();
3059 Stage::GetCurrent().Add( child );
3061 app.SendNotification();
3064 app.SendNotification();
3066 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3070 int UtcDaliActorConstrainedToOpacity(void)
3072 TestApplication app;
3073 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3075 Actor parent = Actor::New();
3076 parent.SetOpacity( 0.7f );
3077 Stage::GetCurrent().Add( parent );
3079 Actor child = Actor::New();
3080 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3081 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3082 opacityConstraint.Apply();
3084 Stage::GetCurrent().Add( child );
3086 app.SendNotification();
3089 app.SendNotification();
3091 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3093 parent.SetOpacity( 0.3f );
3095 app.SendNotification();
3098 app.SendNotification();
3100 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3105 int UtcDaliActorUnparent(void)
3107 TestApplication app;
3108 tet_infoline(" UtcDaliActorUnparent");
3110 Actor parent = Actor::New();
3111 Stage::GetCurrent().Add( parent );
3113 Actor child = Actor::New();
3115 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3116 DALI_TEST_CHECK( !child.GetParent() );
3118 // Test that calling Unparent with no parent is a NOOP
3121 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3122 DALI_TEST_CHECK( !child.GetParent() );
3124 // Test that Unparent works
3125 parent.Add( child );
3127 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3128 DALI_TEST_CHECK( parent == child.GetParent() );
3132 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3133 DALI_TEST_CHECK( !child.GetParent() );
3135 // Test that UnparentAndReset works
3136 parent.Add( child );
3138 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3139 DALI_TEST_CHECK( parent == child.GetParent() );
3141 UnparentAndReset( child );
3143 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3144 DALI_TEST_CHECK( !child );
3146 // Test that UnparentAndReset is a NOOP with empty handle
3147 UnparentAndReset( child );
3149 DALI_TEST_CHECK( !child );
3153 int UtcDaliActorGetChildAt(void)
3155 TestApplication app;
3156 tet_infoline(" UtcDaliActorGetChildAt");
3158 Actor parent = Actor::New();
3159 Stage::GetCurrent().Add( parent );
3161 Actor child0 = Actor::New();
3162 parent.Add( child0 );
3164 Actor child1 = Actor::New();
3165 parent.Add( child1 );
3167 Actor child2 = Actor::New();
3168 parent.Add( child2 );
3170 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3171 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3172 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3176 int UtcDaliActorSetGetOverlay(void)
3178 TestApplication app;
3179 tet_infoline(" UtcDaliActorSetGetOverlay");
3181 Actor parent = Actor::New();
3182 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3183 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3188 int UtcDaliActorCreateDestroy(void)
3190 Actor* actor = new Actor;
3191 DALI_TEST_CHECK( actor );
3198 struct PropertyStringIndex
3200 const char * const name;
3201 const Property::Index index;
3202 const Property::Type type;
3205 const PropertyStringIndex PROPERTY_TABLE[] =
3207 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3208 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3209 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3210 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3211 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3212 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3213 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3214 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3215 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3216 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3217 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3218 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3219 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3220 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3221 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3222 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3223 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3224 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3225 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3226 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3227 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3228 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3229 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3230 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3231 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3232 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3233 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3234 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3235 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3236 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3237 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3238 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3239 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3240 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3241 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3242 { "name", Actor::Property::NAME, Property::STRING },
3243 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3244 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3245 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3246 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3247 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3248 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3249 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3250 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3251 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3252 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3253 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3254 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3255 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3256 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3257 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3258 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3259 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3260 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3261 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3263 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3264 } // unnamed namespace
3266 int UtcDaliActorProperties(void)
3268 TestApplication app;
3270 Actor actor = Actor::New();
3272 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3274 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3275 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3276 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3277 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3282 int UtcDaliRelayoutProperties_ResizePolicies(void)
3284 TestApplication app;
3286 Actor actor = Actor::New();
3289 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3290 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3292 // Set resize policy for all dimensions
3293 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3294 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3296 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3299 // Set individual dimensions
3300 const char* const widthPolicy = "FILL_TO_PARENT";
3301 const char* const heightPolicy = "FIXED";
3303 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3304 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3306 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3307 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3309 // Set individual dimensions using enums
3310 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3311 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3313 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3314 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3316 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3317 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3322 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3324 TestApplication app;
3326 Actor actor = Actor::New();
3329 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3330 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3332 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3333 actor.SetSizeScalePolicy( policy );
3334 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3337 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3338 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3340 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3341 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3343 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3344 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3349 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3351 TestApplication app;
3353 Actor actor = Actor::New();
3356 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3357 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3359 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3360 actor.SetSizeModeFactor( sizeMode );
3361 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3364 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3366 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3367 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3372 int UtcDaliRelayoutProperties_DimensionDependency(void)
3374 TestApplication app;
3376 Actor actor = Actor::New();
3379 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3380 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3383 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3384 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3386 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3387 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3389 // Test setting another resize policy
3390 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3391 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3396 int UtcDaliRelayoutProperties_Padding(void)
3398 TestApplication app;
3400 Actor actor = Actor::New();
3403 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3406 actor.SetProperty( Actor::Property::PADDING, padding );
3407 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3409 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3414 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3416 TestApplication app;
3418 Actor actor = Actor::New();
3421 Vector2 minSize( 1.0f, 2.0f );
3423 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3424 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3426 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3428 Vector2 maxSize( 3.0f, 4.0f );
3430 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3431 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3433 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3438 int UtcDaliActorGetHeightForWidth(void)
3440 TestApplication app;
3442 Actor actor = Actor::New();
3444 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3449 int UtcDaliActorGetWidthForHeight(void)
3451 TestApplication app;
3453 Actor actor = Actor::New();
3455 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3460 int UtcDaliActorGetRelayoutSize(void)
3462 TestApplication app;
3464 Actor actor = Actor::New();
3466 // Add actor to stage
3467 Stage::GetCurrent().Add( actor );
3469 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3471 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3472 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3474 // Flush the queue and render once
3475 app.SendNotification();
3478 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3483 int UtcDaliActorSetPadding(void)
3485 TestApplication app;
3487 Actor actor = Actor::New();
3490 actor.GetPadding( padding );
3492 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3493 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3494 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3495 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3497 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3498 actor.SetPadding( padding2 );
3500 actor.GetPadding( padding );
3502 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3503 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3504 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3505 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3510 int UtcDaliActorSetMinimumSize(void)
3512 TestApplication app;
3514 Actor actor = Actor::New();
3516 Vector2 size = actor.GetMinimumSize();
3518 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3519 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3521 Vector2 size2( 1.0f, 2.0f );
3522 actor.SetMinimumSize( size2 );
3524 size = actor.GetMinimumSize();
3526 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3527 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3532 int UtcDaliActorSetMaximumSize(void)
3534 TestApplication app;
3536 Actor actor = Actor::New();
3538 Vector2 size = actor.GetMaximumSize();
3540 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3541 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3543 Vector2 size2( 1.0f, 2.0f );
3544 actor.SetMaximumSize( size2 );
3546 size = actor.GetMaximumSize();
3548 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3549 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3554 int UtcDaliActorOnRelayoutSignal(void)
3556 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3558 TestApplication application;
3561 gOnRelayoutCallBackCalled = false;
3562 gActorNamesRelayout.clear();
3564 Actor actor = Actor::New();
3565 actor.SetName( "actor" );
3566 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3569 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3571 // Add actor to stage
3572 Stage::GetCurrent().Add( actor );
3574 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3575 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3577 // Flush the queue and render once
3578 application.SendNotification();
3579 application.Render();
3581 // OnRelayout emitted
3582 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3583 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3588 int UtcDaliActorGetHierachyDepth(void)
3590 TestApplication application;
3591 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3594 /* Build tree of actors:
3604 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3606 Stage stage( Stage::GetCurrent() );
3608 Actor actorA = Actor::New();
3609 Actor actorB = Actor::New();
3610 Actor actorC = Actor::New();
3611 Actor actorD = Actor::New();
3612 Actor actorE = Actor::New();
3613 Actor actorF = Actor::New();
3615 //Test that root actor has depth equal 0
3616 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3618 //Test actors return depth -1 when not connected to the tree
3619 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3620 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3621 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3622 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3623 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3624 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3626 //Create the hierarchy
3627 stage.Add( actorA );
3628 actorA.Add( actorB );
3629 actorA.Add( actorC );
3630 actorB.Add( actorD );
3631 actorB.Add( actorE );
3632 actorC.Add( actorF );
3634 //Test actors return correct depth
3635 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3636 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3637 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3638 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3639 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3640 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3642 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3643 actorA.Remove( actorB );
3645 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3646 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3647 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3649 //Removing actorA from the stage. All actors should have depth equal -1
3650 stage.Remove( actorA );
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 );
3662 int UtcDaliActorAnchorPointPropertyAsString(void)
3664 TestApplication application;
3666 Actor actor = Actor::New();
3668 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3669 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3671 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3672 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3674 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3675 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3677 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3678 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3680 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3681 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3683 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3684 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3686 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3687 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3689 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3690 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3692 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3693 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3695 // Invalid should not change anything
3696 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3697 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3702 int UtcDaliActorParentOriginPropertyAsString(void)
3704 TestApplication application;
3706 Actor actor = Actor::New();
3708 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3709 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3711 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3712 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3714 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3715 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3717 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3718 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3720 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3721 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3723 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3724 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3726 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3727 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3729 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3730 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3732 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3733 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3735 // Invalid should not change anything
3736 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3737 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3742 int UtcDaliActorColorModePropertyAsString(void)
3744 TestApplication application;
3746 Actor actor = Actor::New();
3748 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3749 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3751 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3752 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3754 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3755 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3757 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3758 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3760 // Invalid should not change anything
3761 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3762 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3767 int UtcDaliActorPositionInheritancePropertyAsString(void)
3769 TestApplication application;
3771 Actor actor = Actor::New();
3773 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3774 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3776 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3777 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3779 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3780 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3782 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3783 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3785 // Invalid should not change anything
3786 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3787 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3792 int UtcDaliActorDrawModePropertyAsString(void)
3794 TestApplication application;
3796 Actor actor = Actor::New();
3798 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3799 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3801 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3802 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3804 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3805 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3807 // Invalid should not change anything
3808 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3809 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3814 int UtcDaliActorColorModePropertyAsEnum(void)
3816 TestApplication application;
3818 Actor actor = Actor::New();
3820 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3821 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3823 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3824 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3826 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3827 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3829 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3830 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3835 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3837 TestApplication application;
3839 Actor actor = Actor::New();
3841 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3842 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3844 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3845 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3847 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3848 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3850 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3851 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3856 int UtcDaliActorDrawModePropertyAsEnum(void)
3858 TestApplication application;
3860 Actor actor = Actor::New();
3862 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3863 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3865 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3866 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3868 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3869 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3874 int UtcDaliActorAddRendererP(void)
3876 tet_infoline("Testing Actor::AddRenderer");
3877 TestApplication application;
3879 Actor actor = Actor::New();
3881 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3883 Geometry geometry = CreateQuadGeometry();
3884 Shader shader = CreateShader();
3885 Renderer renderer = Renderer::New(geometry, shader);
3887 actor.AddRenderer( renderer );
3888 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3889 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3894 int UtcDaliActorAddRendererN(void)
3896 tet_infoline("Testing Actor::AddRenderer");
3897 TestApplication application;
3899 Actor actor = Actor::New();
3905 actor.AddRenderer( renderer );
3906 tet_printf("Assertion test failed - no Exception\n" );
3907 tet_result(TET_FAIL);
3909 catch(Dali::DaliException& e)
3911 DALI_TEST_PRINT_ASSERT( e );
3912 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3913 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3917 tet_printf("Assertion test failed - wrong Exception\n" );
3918 tet_result(TET_FAIL);
3924 int UtcDaliActorAddRendererOnStage(void)
3926 tet_infoline("Testing Actor::AddRenderer");
3927 TestApplication application;
3929 Actor actor = Actor::New();
3930 Stage::GetCurrent().Add(actor);
3932 application.SendNotification();
3933 application.Render(0);
3935 Geometry geometry = CreateQuadGeometry();
3936 Shader shader = CreateShader();
3937 Renderer renderer = Renderer::New(geometry, shader);
3939 application.SendNotification();
3940 application.Render(0);
3944 actor.AddRenderer( renderer );
3945 tet_result(TET_PASS);
3949 tet_result(TET_FAIL);
3955 int UtcDaliActorRemoveRendererP1(void)
3957 tet_infoline("Testing Actor::RemoveRenderer");
3958 TestApplication application;
3960 Actor actor = Actor::New();
3962 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3965 Geometry geometry = CreateQuadGeometry();
3966 Shader shader = CreateShader();
3967 Renderer renderer = Renderer::New(geometry, shader);
3969 actor.AddRenderer( renderer );
3970 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3971 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3973 application.SendNotification();
3974 application.Render();
3978 Renderer renderer = actor.GetRendererAt(0);
3979 actor.RemoveRenderer(renderer);
3980 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3982 application.SendNotification();
3983 application.Render();
3986 // Call one final time to ensure that the renderer is actually removed after
3987 // the handle goes out of scope, and excercises the deletion code path in
3988 // scene graph and render.
3989 application.SendNotification();
3990 application.Render();
3995 int UtcDaliActorRemoveRendererP2(void)
3997 tet_infoline("Testing Actor::RemoveRenderer");
3998 TestApplication application;
4000 Actor actor = Actor::New();
4002 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4004 Geometry geometry = CreateQuadGeometry();
4005 Shader shader = CreateShader();
4006 Renderer renderer = Renderer::New(geometry, shader);
4008 actor.AddRenderer( renderer );
4009 application.SendNotification();
4010 application.Render();
4012 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4013 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4015 actor.RemoveRenderer(0);
4016 application.SendNotification();
4017 application.Render();
4019 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4021 // Shut down whilst holding onto the renderer handle.
4026 int UtcDaliActorRemoveRendererN(void)
4028 tet_infoline("Testing Actor::RemoveRenderer");
4029 TestApplication application;
4031 Actor actor = Actor::New();
4033 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4035 Geometry geometry = CreateQuadGeometry();
4036 Shader shader = CreateShader();
4037 Renderer renderer = Renderer::New(geometry, shader);
4039 actor.AddRenderer( renderer );
4040 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4041 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4043 actor.RemoveRenderer(10);
4044 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4045 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4050 // Clipping test helper functions:
4051 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4053 BufferImage image = BufferImage::New( width, height );
4054 Actor actor = CreateRenderableActor( image );
4056 // Setup dimensions and position so actor is not skipped by culling.
4057 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4058 actor.SetSize( width, height );
4059 actor.SetParentOrigin( ParentOrigin::CENTER );
4060 actor.SetAnchorPoint( AnchorPoint::CENTER );
4065 Actor CreateActorWithContent16x16()
4067 return CreateActorWithContent( 16, 16 );
4070 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4072 enabledDisableTrace.Reset();
4073 stencilTrace.Reset();
4074 enabledDisableTrace.Enable( true );
4075 stencilTrace.Enable( true );
4077 application.SendNotification();
4078 application.Render();
4080 enabledDisableTrace.Enable( false );
4081 stencilTrace.Enable( false );
4084 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4086 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4088 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4089 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4090 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4091 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4094 int UtcDaliActorPropertyClippingP(void)
4096 // This test checks the clippingMode property.
4097 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4098 TestApplication application;
4100 Actor actor = Actor::New();
4102 // Check default clippingEnabled value.
4103 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4106 bool getValueResult = getValue.Get( value );
4107 DALI_TEST_CHECK( getValueResult );
4109 if( getValueResult )
4111 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4114 // Check setting the property to the stencil mode.
4115 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4117 // Check the new value was set.
4118 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4119 getValueResult = getValue.Get( value );
4120 DALI_TEST_CHECK( getValueResult );
4122 if( getValueResult )
4124 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4127 // Check setting the property to the scissor mode.
4128 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4130 // Check the new value was set.
4131 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4132 getValueResult = getValue.Get( value );
4133 DALI_TEST_CHECK( getValueResult );
4135 if( getValueResult )
4137 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4142 int UtcDaliActorPropertyClippingN(void)
4144 // Negative test case for Clipping.
4145 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4146 TestApplication application;
4148 Actor actor = Actor::New();
4150 // Check default clippingEnabled value.
4151 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4154 bool getValueResult = getValue.Get( value );
4155 DALI_TEST_CHECK( getValueResult );
4157 if( getValueResult )
4159 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4162 // Check setting an invalid property value won't change the current property value.
4163 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4165 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4166 getValueResult = getValue.Get( value );
4167 DALI_TEST_CHECK( getValueResult );
4169 if( getValueResult )
4171 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4177 int UtcDaliActorPropertyClippingActor(void)
4179 // This test checks that an actor is correctly setup for clipping.
4180 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4181 TestApplication application;
4183 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4184 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4185 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4186 size_t startIndex = 0u;
4188 // Create a clipping actor.
4189 Actor actorDepth1Clip = CreateActorWithContent16x16();
4190 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4191 Stage::GetCurrent().Add( actorDepth1Clip );
4193 // Gather the call trace.
4194 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4196 // Check we are writing to the color buffer.
4197 CheckColorMask( glAbstraction, true );
4199 // Check the stencil buffer was enabled.
4200 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4202 // Check the stencil buffer was cleared.
4203 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4205 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4206 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4207 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4208 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4213 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4215 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4216 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4217 TestApplication application;
4219 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4220 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4221 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4222 size_t startIndex = 0u;
4224 // Create a clipping actor.
4225 Actor actorDepth1Clip = CreateActorWithContent16x16();
4226 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4227 Stage::GetCurrent().Add( actorDepth1Clip );
4229 // Gather the call trace.
4230 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4232 // Check we are writing to the color buffer.
4233 CheckColorMask( glAbstraction, true );
4235 // Check the stencil buffer was enabled.
4236 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4238 // Check the stencil buffer was cleared.
4239 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4241 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4242 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4243 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4244 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4246 // Now disable the clipping
4247 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4249 // Gather the call trace.
4250 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4252 // Check the stencil buffer was disabled.
4253 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4255 // Ensure all values in stencil-mask are set to 1.
4257 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4262 int UtcDaliActorPropertyClippingNestedChildren(void)
4264 // This test checks that a hierarchy of actors are clipped correctly by
4265 // writing to and reading from the correct bit-planes of the stencil buffer.
4266 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4267 TestApplication application;
4268 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4269 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4270 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4272 // Create a clipping actor.
4273 Actor actorDepth1Clip = CreateActorWithContent16x16();
4274 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4275 Stage::GetCurrent().Add( actorDepth1Clip );
4277 // Create a child actor.
4278 Actor childDepth2 = CreateActorWithContent16x16();
4279 actorDepth1Clip.Add( childDepth2 );
4281 // Create another clipping actor.
4282 Actor childDepth2Clip = CreateActorWithContent16x16();
4283 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4284 childDepth2.Add( childDepth2Clip );
4286 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4287 // This tests the sort algorithm.
4288 Actor childDepth3 = CreateActorWithContent16x16();
4289 childDepth2Clip.Add( childDepth3 );
4290 Actor childDepth4 = CreateActorWithContent16x16();
4291 childDepth3.Add( childDepth4 );
4293 // Gather the call trace.
4294 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4296 // Check we are writing to the color buffer.
4297 CheckColorMask( glAbstraction, true );
4299 // Check the stencil buffer was enabled.
4300 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4302 // Perform the test twice, once for 2D layer, and once for 3D.
4303 for( unsigned int i = 0u ; i < 2u; ++i )
4305 size_t startIndex = 0u;
4307 // Check the stencil buffer was cleared.
4308 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4310 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4311 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4312 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4313 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4315 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4316 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4317 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4319 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4320 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4321 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4322 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4324 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4325 // (Both must be set to pass the check).
4326 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4327 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4329 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4332 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4333 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4340 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4342 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4343 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4344 TestApplication application;
4345 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4346 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4348 /* We create a small tree of actors as follows:
4352 Clipping enabled -> B D
4356 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4359 for( int i = 0; i < 5; ++i )
4361 BufferImage image = BufferImage::New( 16u, 16u );
4362 Actor actor = CreateRenderableActor( image );
4364 // Setup dimensions and position so actor is not skipped by culling.
4365 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4366 actor.SetSize( 16.0f, 16.0f );
4370 actor.SetParentOrigin( ParentOrigin::CENTER );
4374 float b = i > 2 ? 1.0f : -1.0f;
4375 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4381 // Enable clipping on the actor at the top of the left branch.
4382 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4384 // Build the scene graph.
4385 Stage::GetCurrent().Add( actors[0] );
4388 actors[0].Add( actors[1] );
4389 actors[1].Add( actors[2] );
4392 actors[0].Add( actors[3] );
4393 actors[3].Add( actors[4] );
4395 // Gather the call trace.
4396 enabledDisableTrace.Reset();
4397 enabledDisableTrace.Enable( true );
4398 application.SendNotification();
4399 application.Render();
4400 enabledDisableTrace.Enable( false );
4402 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4404 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
4405 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4407 size_t startIndex = 0u;
4408 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4409 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4410 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4412 // Swap the clipping actor from top of left branch to top of right branch.
4413 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4414 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4416 // Gather the call trace.
4417 enabledDisableTrace.Reset();
4418 enabledDisableTrace.Enable( true );
4419 application.SendNotification();
4420 application.Render();
4421 enabledDisableTrace.Enable( false );
4423 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4424 // This proves the draw order has remained the same.
4426 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4427 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4432 int UtcDaliActorPropertyScissorClippingActor(void)
4434 // This test checks that an actor is correctly setup for clipping.
4435 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4436 TestApplication application;
4438 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4439 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4440 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4442 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4443 const Vector2 imageSize( 16.0f, 16.0f );
4445 // Create a clipping actor.
4446 Actor clippingActorA = CreateActorWithContent16x16();
4447 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4448 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4449 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4450 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4451 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4452 Stage::GetCurrent().Add( clippingActorA );
4454 // Gather the call trace.
4455 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4457 // Check we are writing to the color buffer.
4458 CheckColorMask( glAbstraction, true );
4460 // Check scissor test was enabled.
4461 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4463 // Check the scissor was set, and the coordinates are correct.
4464 std::stringstream compareParametersString;
4465 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4466 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4468 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4469 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4471 // Gather the call trace.
4472 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4474 // Check the scissor was set, and the coordinates are correct.
4475 compareParametersString.str( std::string() );
4476 compareParametersString.clear();
4477 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4478 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4483 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4485 // This test checks that an actor is correctly setup for clipping.
4486 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4487 TestApplication application;
4490 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4491 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4492 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4494 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4495 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4496 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4498 // Create a clipping actors.
4499 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4500 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4502 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4503 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4504 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4506 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4507 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4508 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4510 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4511 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4513 Stage::GetCurrent().Add( clippingActorA );
4514 Stage::GetCurrent().Add( clippingActorB );
4516 // Gather the call trace.
4517 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4519 // Check we are writing to the color buffer.
4520 CheckColorMask( glAbstraction, true );
4522 // Check scissor test was enabled.
4523 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4525 // Check the scissor was set, and the coordinates are correct.
4526 std::stringstream compareParametersString;
4528 std::string clipA( "0, 500, 480, 200" );
4529 std::string clipB( "0, 380, 480, 40" );
4531 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4532 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4537 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4539 // This test checks that an actor is correctly setup for clipping.
4540 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4541 TestApplication application;
4543 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4544 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4545 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4547 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4548 const Vector2 imageSize( 16.0f, 16.0f );
4550 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4552 A is drawn first - with scissor clipping on
4553 B is drawn second - also with scissor clipping on
4554 C is the generated clipping region, the intersection ( A ∩ B )
4558 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4559 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4560 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4564 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4567 // Create a clipping actor.
4568 Actor clippingActorA = CreateActorWithContent16x16();
4569 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4570 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4571 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4572 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4573 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4574 Stage::GetCurrent().Add( clippingActorA );
4576 // Create a child clipping actor.
4577 Actor clippingActorB = CreateActorWithContent16x16();
4578 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4579 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4580 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4581 clippingActorA.Add( clippingActorB );
4583 // positionModifiers is an array of positions to position B around.
4584 // expect is an array of expected scissor clip coordinate results.
4585 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4586 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4588 // Loop through each overlap combination.
4589 for( unsigned int test = 0u; test < 4u; ++test )
4591 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4592 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4593 clippingActorB.SetPosition( position.x, position.y );
4595 // Gather the call trace.
4596 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4598 // Check we are writing to the color buffer.
4599 CheckColorMask( glAbstraction, true );
4601 // Check scissor test was enabled.
4602 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4604 // Check the scissor was set, and the coordinates are correct.
4605 const Vector4& expectResults( expect[test] );
4606 std::stringstream compareParametersString;
4607 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4608 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4614 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4616 // This test checks that an actor is correctly setup for clipping.
4617 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4618 TestApplication application;
4620 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4621 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4622 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4624 /* Create a nest of 2 scissors and siblings of the parent.
4634 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4635 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4636 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4637 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4638 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4639 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4641 // Create a clipping actors.
4642 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4643 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4644 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4645 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4646 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4648 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4649 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4650 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4652 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4653 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4654 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4656 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4657 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4658 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4660 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4661 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4662 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4664 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4665 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4667 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4668 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4669 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4670 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4671 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4673 Stage::GetCurrent().Add( clippingActorA );
4674 clippingActorA.Add( clippingActorB );
4675 Stage::GetCurrent().Add( clippingActorC );
4676 Stage::GetCurrent().Add( clippingActorD );
4677 clippingActorD.Add( clippingActorE );
4679 // Gather the call trace.
4680 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4682 // Check we are writing to the color buffer.
4683 CheckColorMask( glAbstraction, true );
4685 // Check scissor test was enabled.
4686 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4688 // Check the scissor was set, and the coordinates are correct.
4689 std::string clipA( "0, 500, 480, 200" );
4690 std::string clipB( "0, 580, 480, 40" );
4691 std::string clipC( "0, 200, 480, 200" );
4692 std::string clipD( "0, 300, 480, 200" );
4694 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4695 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4696 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4697 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4698 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4703 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4705 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4706 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4707 TestApplication application;
4709 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4710 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4711 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4713 // Create a clipping actor.
4714 Actor actorDepth1Clip = CreateActorWithContent16x16();
4715 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4716 Stage::GetCurrent().Add( actorDepth1Clip );
4718 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4719 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4721 // Gather the call trace.
4722 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4724 // Check we are writing to the color buffer.
4725 CheckColorMask( glAbstraction, true );
4727 // Check the stencil buffer was not enabled.
4728 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4730 // Check stencil functions are not called.
4731 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4732 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4733 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4735 // Check that scissor clipping is overriden by the renderer properties.
4736 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4738 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4740 // Gather the call trace.
4741 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4743 // Check the stencil buffer was not enabled.
4744 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4746 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4751 int UtcDaliGetPropertyN(void)
4753 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4754 TestApplication app;
4756 Actor actor = Actor::New();
4758 unsigned int propertyCount = actor.GetPropertyCount();
4759 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4763 int UtcDaliActorRaiseLower(void)
4765 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4767 TestApplication application;
4769 Stage stage( Stage::GetCurrent() );
4771 Actor actorA = Actor::New();
4772 Actor actorB = Actor::New();
4773 Actor actorC = Actor::New();
4775 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4776 actorA.SetParentOrigin( ParentOrigin::CENTER );
4778 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4779 actorB.SetParentOrigin( ParentOrigin::CENTER );
4781 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4782 actorC.SetParentOrigin( ParentOrigin::CENTER );
4784 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4785 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4787 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4788 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4790 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4791 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4793 stage.Add( actorA );
4794 stage.Add( actorB );
4795 stage.Add( actorC );
4797 ResetTouchCallbacks();
4799 application.SendNotification();
4800 application.Render();
4802 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4803 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4804 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4806 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4807 // Only top actor will get touched.
4808 actorA.TouchSignal().Connect( TestTouchCallback );
4809 actorB.TouchSignal().Connect( TestTouchCallback2 );
4810 actorC.TouchSignal().Connect( TestTouchCallback3 );
4812 // Connect ChildOrderChangedSignal
4813 bool orderChangedSignal( false );
4814 Actor orderChangedActor;
4815 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4816 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4818 Dali::Integration::Point point;
4819 point.SetDeviceId( 1 );
4820 point.SetState( PointState::DOWN );
4821 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4822 Dali::Integration::TouchEvent touchEvent;
4823 touchEvent.AddPoint( point );
4825 application.ProcessEvent( touchEvent );
4827 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4828 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4829 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4831 ResetTouchCallbacks();
4833 tet_printf( "Testing Raising of Actor\n" );
4835 int preActorOrder( 0 );
4836 int postActorOrder( 0 );
4838 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4839 value.Get( preActorOrder );
4841 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4843 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4844 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4846 // Ensure sort order is calculated before next touch event
4847 application.SendNotification();
4849 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4850 value.Get( postActorOrder );
4852 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4854 application.ProcessEvent( touchEvent );
4856 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4857 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4858 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4860 ResetTouchCallbacks();
4862 tet_printf( "Testing Lowering of Actor\n" );
4864 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4865 value.Get( preActorOrder );
4867 orderChangedSignal = false;
4869 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4871 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4872 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4874 application.SendNotification(); // ensure sort order calculated before next touch event
4876 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4877 value.Get( postActorOrder );
4879 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4881 application.ProcessEvent( touchEvent );
4883 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4884 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4885 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4887 ResetTouchCallbacks();
4892 int UtcDaliActorRaiseToTopLowerToBottom(void)
4894 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4896 TestApplication application;
4898 Stage stage( Stage::GetCurrent() );
4900 Actor actorA = Actor::New();
4901 Actor actorB = Actor::New();
4902 Actor actorC = Actor::New();
4904 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4905 // enables checking of which actor the uniform is assigned too
4906 Shader shaderA = CreateShader();
4907 shaderA.RegisterProperty( "uRendererColor",1.f);
4909 Shader shaderB = CreateShader();
4910 shaderB.RegisterProperty( "uRendererColor", 2.f );
4912 Shader shaderC = CreateShader();
4913 shaderC.RegisterProperty( "uRendererColor", 3.f );
4915 Geometry geometry = CreateQuadGeometry();
4917 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4918 Renderer rendererA = Renderer::New(geometry, shaderA);
4919 actorA.AddRenderer(rendererA);
4921 Renderer rendererB = Renderer::New(geometry, shaderB);
4922 actorB.AddRenderer(rendererB);
4924 Renderer rendererC = Renderer::New(geometry, shaderC);
4925 actorC.AddRenderer(rendererC);
4927 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4928 actorA.SetParentOrigin( ParentOrigin::CENTER );
4930 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4931 actorB.SetParentOrigin( ParentOrigin::CENTER );
4933 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4934 actorC.SetParentOrigin( ParentOrigin::CENTER );
4936 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4937 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4939 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4940 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4942 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4943 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4945 stage.Add( actorA );
4946 stage.Add( actorB );
4947 stage.Add( actorC );
4949 ResetTouchCallbacks();
4951 // Connect ChildOrderChangedSignal
4952 bool orderChangedSignal( false );
4953 Actor orderChangedActor;
4954 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4955 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4957 // Set up gl abstraction trace so can query the set uniform order
4958 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4959 glAbstraction.EnableSetUniformCallTrace(true);
4960 glAbstraction.ResetSetUniformCallStack();
4962 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4964 application.SendNotification();
4965 application.Render();
4967 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4970 // Test order of uniforms in stack
4971 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4972 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4973 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4975 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4977 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4979 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4980 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4981 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4983 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4984 // Only top actor will get touched.
4985 actorA.TouchSignal().Connect( TestTouchCallback );
4986 actorB.TouchSignal().Connect( TestTouchCallback2 );
4987 actorC.TouchSignal().Connect( TestTouchCallback3 );
4989 Dali::Integration::Point point;
4990 point.SetDeviceId( 1 );
4991 point.SetState( PointState::DOWN );
4992 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4993 Dali::Integration::TouchEvent touchEvent;
4994 touchEvent.AddPoint( point );
4996 application.ProcessEvent( touchEvent );
4998 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4999 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5000 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5002 ResetTouchCallbacks();
5004 tet_printf( "RaiseToTop ActorA\n" );
5006 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5007 actorA.RaiseToTop();
5008 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5009 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5011 application.SendNotification(); // ensure sorting order is calculated before next touch event
5013 application.ProcessEvent( touchEvent );
5015 glAbstraction.ResetSetUniformCallStack();
5016 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5018 application.SendNotification();
5019 application.Render();
5021 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5023 // Test order of uniforms in stack
5024 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5025 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5026 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5028 tet_infoline( "Testing A above C and B at bottom\n" );
5029 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5031 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5033 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5034 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5035 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5037 ResetTouchCallbacks();
5039 tet_printf( "RaiseToTop ActorB\n" );
5041 orderChangedSignal = false;
5043 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5044 actorB.RaiseToTop();
5045 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5046 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5048 application.SendNotification(); // Ensure sort order is calculated before next touch event
5050 application.ProcessEvent( touchEvent );
5052 glAbstraction.ResetSetUniformCallStack();
5053 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5055 application.SendNotification();
5056 application.Render();
5058 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5060 // Test order of uniforms in stack
5061 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5062 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5063 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5065 tet_infoline( "Testing B above A and C at bottom\n" );
5066 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5068 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5070 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5071 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5072 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5074 ResetTouchCallbacks();
5076 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5078 orderChangedSignal = false;
5080 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5081 actorA.LowerToBottom();
5082 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5083 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5085 application.SendNotification();
5086 application.Render();
5088 orderChangedSignal = false;
5090 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5091 actorB.LowerToBottom();
5092 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5093 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5095 application.SendNotification();
5096 application.Render();
5098 application.ProcessEvent( touchEvent );
5100 glAbstraction.ResetSetUniformCallStack();
5101 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5103 application.SendNotification();
5104 application.Render();
5106 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5108 // Test order of uniforms in stack
5109 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5110 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5111 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5113 tet_infoline( "Testing C above A and B at bottom\n" );
5114 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5116 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5118 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5119 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5120 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5122 ResetTouchCallbacks();
5127 int UtcDaliActorRaiseAbove(void)
5129 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5131 TestApplication application;
5133 Stage stage( Stage::GetCurrent() );
5135 Actor actorA = Actor::New();
5136 Actor actorB = Actor::New();
5137 Actor actorC = Actor::New();
5139 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5140 actorA.SetParentOrigin( ParentOrigin::CENTER );
5142 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5143 actorB.SetParentOrigin( ParentOrigin::CENTER );
5145 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5146 actorC.SetParentOrigin( ParentOrigin::CENTER );
5148 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5149 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5151 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5152 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5154 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5155 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5157 stage.Add( actorA );
5158 stage.Add( actorB );
5159 stage.Add( actorC );
5161 ResetTouchCallbacks();
5163 application.SendNotification();
5164 application.Render();
5166 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5167 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5168 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5170 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5171 // Only top actor will get touched.
5172 actorA.TouchSignal().Connect( TestTouchCallback );
5173 actorB.TouchSignal().Connect( TestTouchCallback2 );
5174 actorC.TouchSignal().Connect( TestTouchCallback3 );
5176 bool orderChangedSignal( false );
5177 Actor orderChangedActor;
5178 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5179 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5181 Dali::Integration::Point point;
5182 point.SetDeviceId( 1 );
5183 point.SetState( PointState::DOWN );
5184 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5185 Dali::Integration::TouchEvent touchEvent;
5186 touchEvent.AddPoint( point );
5188 application.ProcessEvent( touchEvent );
5190 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5191 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5192 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5194 ResetTouchCallbacks();
5196 tet_printf( "Raise actor B Above Actor C\n" );
5198 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5199 actorB.RaiseAbove( actorC );
5200 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5201 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5203 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5204 application.SendNotification();
5205 application.ProcessEvent( touchEvent );
5207 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5208 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5209 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5211 ResetTouchCallbacks();
5213 tet_printf( "Raise actor A Above Actor B\n" );
5215 orderChangedSignal = false;
5217 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5218 actorA.RaiseAbove( actorB );
5219 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5220 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5222 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5223 application.SendNotification();
5225 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5227 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5228 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5229 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5231 ResetTouchCallbacks();
5236 int UtcDaliActorLowerBelow(void)
5238 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5240 TestApplication application;
5242 Stage stage( Stage::GetCurrent() );
5244 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5245 // enables checking of which actor the uniform is assigned too
5246 Shader shaderA = CreateShader();
5247 shaderA.RegisterProperty( "uRendererColor",1.f);
5249 Shader shaderB = CreateShader();
5250 shaderB.RegisterProperty( "uRendererColor", 2.f );
5252 Shader shaderC = CreateShader();
5253 shaderC.RegisterProperty( "uRendererColor", 3.f );
5255 Actor actorA = Actor::New();
5256 Actor actorB = Actor::New();
5257 Actor actorC = Actor::New();
5259 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5260 Geometry geometry = CreateQuadGeometry();
5262 Renderer rendererA = Renderer::New(geometry, shaderA);
5263 actorA.AddRenderer(rendererA);
5265 Renderer rendererB = Renderer::New(geometry, shaderB);
5266 actorB.AddRenderer(rendererB);
5268 Renderer rendererC = Renderer::New(geometry, shaderC);
5269 actorC.AddRenderer(rendererC);
5271 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5272 actorA.SetParentOrigin( ParentOrigin::CENTER );
5274 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5275 actorB.SetParentOrigin( ParentOrigin::CENTER );
5277 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5278 actorC.SetParentOrigin( ParentOrigin::CENTER );
5280 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5281 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5283 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5284 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5286 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5287 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5289 Actor container = Actor::New();
5290 container.SetParentOrigin( ParentOrigin::CENTER );
5291 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5292 stage.Add( container );
5294 container.Add( actorA );
5295 container.Add( actorB );
5296 container.Add( actorC );
5298 ResetTouchCallbacks();
5300 // Connect ChildOrderChangedSignal
5301 bool orderChangedSignal( false );
5302 Actor orderChangedActor;
5303 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5304 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5306 // Set up gl abstraction trace so can query the set uniform order
5307 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5308 glAbstraction.EnableSetUniformCallTrace(true);
5309 glAbstraction.ResetSetUniformCallStack();
5310 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5312 glAbstraction.ResetSetUniformCallStack();
5314 application.SendNotification();
5315 application.Render();
5317 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5319 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5321 // Test order of uniforms in stack
5322 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5323 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5324 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5326 tet_infoline( "Testing C above B and A at bottom\n" );
5327 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5329 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5331 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5332 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5333 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5335 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5336 // Only top actor will get touched.
5337 actorA.TouchSignal().Connect( TestTouchCallback );
5338 actorB.TouchSignal().Connect( TestTouchCallback2 );
5339 actorC.TouchSignal().Connect( TestTouchCallback3 );
5341 Dali::Integration::Point point;
5342 point.SetDeviceId( 1 );
5343 point.SetState( PointState::DOWN );
5344 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5345 Dali::Integration::TouchEvent touchEvent;
5346 touchEvent.AddPoint( point );
5348 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5350 application.ProcessEvent( touchEvent );
5352 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5353 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5354 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5356 ResetTouchCallbacks();
5358 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" );
5360 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5361 actorC.LowerBelow( actorB );
5362 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5363 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5365 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5366 application.SendNotification();
5367 application.Render();
5369 application.ProcessEvent( touchEvent ); // touch event
5371 glAbstraction.ResetSetUniformCallStack();
5372 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5374 application.SendNotification();
5375 application.Render();
5377 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5379 // Test order of uniforms in stack
5380 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5381 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5382 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5384 tet_infoline( "Testing render order is A, C, B" );
5385 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5386 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5388 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5389 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5390 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5392 ResetTouchCallbacks();
5394 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5396 orderChangedSignal = false;
5398 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5399 actorC.LowerBelow( actorA );
5400 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5401 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5403 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5404 application.SendNotification();
5405 application.Render();
5407 application.ProcessEvent( touchEvent );
5409 glAbstraction.ResetSetUniformCallStack();
5410 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5412 application.Render();
5413 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5415 // Test order of uniforms in stack
5416 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5417 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5418 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5420 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5421 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5423 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5424 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5425 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5427 ResetTouchCallbacks();
5429 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5431 orderChangedSignal = false;
5433 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5434 actorB.LowerBelow( actorC );
5435 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5436 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5438 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5439 application.SendNotification();
5440 application.Render();
5442 application.ProcessEvent( touchEvent );
5444 glAbstraction.ResetSetUniformCallStack();
5445 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5447 application.Render();
5448 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5450 // Test order of uniforms in stack
5451 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5452 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5453 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5455 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5456 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5462 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5464 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5466 TestApplication application;
5468 Stage stage( Stage::GetCurrent() );
5470 Actor parentA = Actor::New();
5471 Actor parentB = Actor::New();
5472 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5473 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5474 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5475 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5477 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5478 parentA.SetParentOrigin( ParentOrigin::CENTER );
5480 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5481 parentB.SetParentOrigin( ParentOrigin::CENTER );
5483 stage.Add( parentA );
5484 stage.Add( parentB );
5486 Actor actorA = Actor::New();
5487 Actor actorB = Actor::New();
5488 Actor actorC = Actor::New();
5490 parentA.Add( actorA );
5491 parentA.Add( actorB );
5493 tet_printf( "Actor C added to different parent from A and B \n" );
5494 parentB.Add( actorC );
5496 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5497 actorA.SetParentOrigin( ParentOrigin::CENTER );
5499 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5500 actorB.SetParentOrigin( ParentOrigin::CENTER );
5502 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5503 actorC.SetParentOrigin( ParentOrigin::CENTER );
5505 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5506 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5508 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5509 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5511 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5512 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5514 ResetTouchCallbacks();
5516 // Connect ChildOrderChangedSignal
5517 bool orderChangedSignal( false );
5518 Actor orderChangedActor;
5519 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5520 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5522 application.SendNotification();
5523 application.Render();
5525 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5526 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5527 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5529 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5530 // Only top actor will get touched.
5531 actorA.TouchSignal().Connect( TestTouchCallback );
5532 actorB.TouchSignal().Connect( TestTouchCallback2 );
5533 actorC.TouchSignal().Connect( TestTouchCallback3 );
5535 Dali::Integration::Point point;
5536 point.SetDeviceId( 1 );
5537 point.SetState( PointState::DOWN );
5538 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5539 Dali::Integration::TouchEvent touchEvent;
5540 touchEvent.AddPoint( point );
5542 application.ProcessEvent( touchEvent );
5544 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5545 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5546 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5548 ResetTouchCallbacks();
5550 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5552 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5553 actorA.RaiseAbove( actorC );
5554 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5556 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5557 application.SendNotification();
5559 application.ProcessEvent( touchEvent ); // touch event
5561 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5562 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5563 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5565 ResetTouchCallbacks();
5570 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5572 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5574 TestApplication application;
5576 Stage stage( Stage::GetCurrent() );
5578 Actor actorA = Actor::New();
5579 Actor actorB = Actor::New();
5580 Actor actorC = Actor::New();
5582 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5583 actorA.SetParentOrigin( ParentOrigin::CENTER );
5585 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5586 actorB.SetParentOrigin( ParentOrigin::CENTER );
5588 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5589 actorC.SetParentOrigin( ParentOrigin::CENTER );
5591 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5592 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5594 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5595 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5597 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5598 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5600 ResetTouchCallbacks();
5602 // Connect ChildOrderChangedSignal
5603 bool orderChangedSignal( false );
5604 Actor orderChangedActor;
5605 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5606 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5608 application.SendNotification();
5609 application.Render();
5611 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5612 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5613 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5615 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5616 // Only top actor will get touched.
5617 actorA.TouchSignal().Connect( TestTouchCallback );
5618 actorB.TouchSignal().Connect( TestTouchCallback2 );
5619 actorC.TouchSignal().Connect( TestTouchCallback3 );
5621 Dali::Integration::Point point;
5622 point.SetDeviceId( 1 );
5623 point.SetState( PointState::DOWN );
5624 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5625 Dali::Integration::TouchEvent touchEvent;
5626 touchEvent.AddPoint( point );
5628 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5630 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5631 actorA.RaiseAbove( actorC );
5632 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5634 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5635 application.SendNotification();
5637 application.ProcessEvent( touchEvent );
5639 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5641 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5642 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5643 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5645 ResetTouchCallbacks();
5647 orderChangedSignal = false;
5649 stage.Add ( actorB );
5650 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5652 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5653 actorA.LowerBelow( actorC );
5654 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5656 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5657 application.SendNotification();
5658 application.Render();
5660 application.ProcessEvent( touchEvent );
5662 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5663 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5664 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5665 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5667 ResetTouchCallbacks();
5669 orderChangedSignal = false;
5671 tet_printf( "Adding Actor A to stage, will be on top\n" );
5673 stage.Add ( actorA );
5674 application.SendNotification();
5675 application.Render();
5677 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5679 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5680 actorB.RaiseAbove( actorC );
5681 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5683 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5684 application.SendNotification();
5686 application.ProcessEvent( touchEvent );
5688 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5689 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5690 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5691 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5693 ResetTouchCallbacks();
5695 orderChangedSignal = false;
5697 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5699 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5700 actorA.LowerBelow( actorC );
5701 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5703 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5704 application.SendNotification();
5706 application.ProcessEvent( touchEvent );
5708 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5709 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5710 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5711 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5713 ResetTouchCallbacks();
5715 orderChangedSignal = false;
5717 stage.Add ( actorC );
5719 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5720 actorA.RaiseAbove( actorC );
5721 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5722 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5724 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5725 application.SendNotification();
5726 application.Render();
5728 application.ProcessEvent( touchEvent );
5730 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5731 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5732 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5733 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5738 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5740 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5742 TestApplication application;
5744 Stage stage( Stage::GetCurrent() );
5746 Actor actorA = Actor::New();
5747 Actor actorB = Actor::New();
5748 Actor actorC = Actor::New();
5750 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5751 actorA.SetParentOrigin( ParentOrigin::CENTER );
5753 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5754 actorB.SetParentOrigin( ParentOrigin::CENTER );
5756 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5757 actorC.SetParentOrigin( ParentOrigin::CENTER );
5759 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5760 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5762 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5763 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5765 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5766 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5768 ResetTouchCallbacks();
5770 // Connect ChildOrderChangedSignal
5771 bool orderChangedSignal( false );
5772 Actor orderChangedActor;
5773 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5774 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5776 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5777 // Only top actor will get touched.
5778 actorA.TouchSignal().Connect( TestTouchCallback );
5779 actorB.TouchSignal().Connect( TestTouchCallback2 );
5780 actorC.TouchSignal().Connect( TestTouchCallback3 );
5782 Dali::Integration::Point point;
5783 point.SetDeviceId( 1 );
5784 point.SetState( PointState::DOWN );
5785 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5786 Dali::Integration::TouchEvent touchEvent;
5787 touchEvent.AddPoint( point );
5789 stage.Add ( actorA );
5790 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5792 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5794 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5796 application.SendNotification();
5797 application.Render();
5799 application.ProcessEvent( touchEvent );
5801 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5803 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5804 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5805 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5807 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5808 ResetTouchCallbacks();
5810 orderChangedSignal = false;
5812 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5814 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5816 // Sort actor tree before next touch event
5817 application.SendNotification();
5818 application.Render();
5820 application.ProcessEvent( touchEvent );
5822 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5824 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5825 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5826 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5827 ResetTouchCallbacks();
5829 orderChangedSignal = false;
5831 tet_printf( "Lower actor C below B but C not parented\n" );
5833 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5835 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5837 // Sort actor tree before next touch event
5838 application.SendNotification();
5839 application.Render();
5841 application.ProcessEvent( touchEvent );
5843 tet_printf( "Not parented so Lower should show no effect\n" );
5845 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5846 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5847 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5848 ResetTouchCallbacks();
5850 orderChangedSignal = false;
5852 tet_printf( "Raise actor B to top\n" );
5854 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5855 actorB.RaiseToTop();
5856 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5858 // Sort actor tree before next touch event
5859 application.SendNotification();
5860 application.Render();
5862 application.ProcessEvent( touchEvent );
5864 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5866 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5867 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5868 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5869 ResetTouchCallbacks();
5871 orderChangedSignal = false;
5873 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5875 stage.Add ( actorB );
5877 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5879 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5880 actorC.LowerToBottom();
5881 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5883 application.SendNotification();
5884 application.Render();
5886 application.ProcessEvent( touchEvent );
5888 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5890 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5891 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5892 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5893 ResetTouchCallbacks();
5899 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5901 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5903 TestApplication application;
5905 Stage stage( Stage::GetCurrent() );
5907 Actor actorA = Actor::New();
5908 Actor actorB = Actor::New();
5909 Actor actorC = Actor::New();
5911 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5912 actorA.SetParentOrigin( ParentOrigin::CENTER );
5914 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5915 actorB.SetParentOrigin( ParentOrigin::CENTER );
5917 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5918 actorC.SetParentOrigin( ParentOrigin::CENTER );
5920 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5921 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5923 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5924 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5926 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5927 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5929 stage.Add( actorA );
5930 stage.Add( actorB );
5931 stage.Add( actorC );
5933 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5934 // Only top actor will get touched.
5935 actorA.TouchSignal().Connect( TestTouchCallback );
5936 actorB.TouchSignal().Connect( TestTouchCallback2 );
5937 actorC.TouchSignal().Connect( TestTouchCallback3 );
5939 ResetTouchCallbacks();
5941 // Connect ChildOrderChangedSignal
5942 bool orderChangedSignal( false );
5943 Actor orderChangedActor;
5944 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5945 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5947 application.SendNotification();
5948 application.Render();
5950 Dali::Integration::Point point;
5951 point.SetDeviceId( 1 );
5952 point.SetState( PointState::DOWN );
5953 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5954 Dali::Integration::TouchEvent touchEvent;
5955 touchEvent.AddPoint( point );
5957 application.ProcessEvent( touchEvent );
5959 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5960 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5961 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5963 ResetTouchCallbacks();
5965 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5967 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5968 actorA.RaiseAbove( actorA );
5969 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5970 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5972 application.SendNotification();
5973 application.Render();
5975 application.ProcessEvent( touchEvent );
5977 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5979 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5980 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5981 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5983 ResetTouchCallbacks();
5985 orderChangedSignal = false;
5987 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5988 actorA.RaiseAbove( actorC );
5989 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5990 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5992 application.SendNotification();
5993 application.Render();
5995 application.ProcessEvent( touchEvent );
5997 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5998 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5999 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6000 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
6005 int UtcDaliActorGetScreenPosition(void)
6007 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
6009 TestApplication application;
6011 Stage stage( Stage::GetCurrent() );
6013 Actor actorA = Actor::New();
6014 actorA.SetAnchorPoint( AnchorPoint::CENTER );
6016 Vector2 size2( 10.0f, 20.0f );
6017 actorA.SetSize( size2 );
6019 actorA.SetPosition( 0.f, 0.f );
6021 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6023 stage.Add( actorA );
6025 application.SendNotification();
6026 application.Render();
6028 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6029 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6031 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6032 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6034 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6035 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6037 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6039 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6041 application.SendNotification();
6042 application.Render();
6044 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6045 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6047 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6048 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6050 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6051 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6053 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6055 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6057 application.SendNotification();
6058 application.Render();
6060 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6061 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6063 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6064 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6066 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6067 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6069 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6071 actorA.SetPosition( 30.0, 0.0 );
6073 application.SendNotification();
6074 application.Render();
6076 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6077 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6079 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6080 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6082 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6083 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6085 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6087 actorA.SetPosition( 30.0, 420.0 );
6089 application.SendNotification();
6090 application.Render();
6092 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6093 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6095 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6096 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6098 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6099 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6101 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6103 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6104 actorA.SetPosition( 30.0, 30.0 );
6106 Actor actorB = Actor::New();
6107 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6108 actorB.SetSize( size2 );
6109 actorB.SetPosition( 10.f, 10.f );
6110 actorA.Add( actorB );
6112 actorA.SetScale( 2.0f );
6114 application.SendNotification();
6115 application.Render();
6117 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6119 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6120 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6125 int UtcDaliActorGetScreenPositionAfterScaling(void)
6127 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6129 TestApplication application;
6131 Stage stage( Stage::GetCurrent() );
6133 Actor actorA = Actor::New();
6134 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6136 Vector2 size2( 10.0f, 20.0f );
6137 actorA.SetSize( size2 );
6138 actorA.SetScale( 1.5f );
6139 actorA.SetPosition( 0.f, 0.f );
6141 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6143 stage.Add( actorA );
6145 application.SendNotification();
6146 application.Render();
6148 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6149 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6151 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6152 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6154 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6155 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6157 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6159 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6161 application.SendNotification();
6162 application.Render();
6164 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6165 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6167 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6168 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6170 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6171 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6176 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6178 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6180 TestApplication application;
6182 Stage stage( Stage::GetCurrent() );
6184 Actor actorA = Actor::New();
6185 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6186 actorA.SetParentOrigin( ParentOrigin::CENTER );
6187 Vector2 size2( 10.0f, 20.0f );
6188 actorA.SetSize( size2 );
6189 actorA.SetPosition( 0.f, 0.f );
6191 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6193 stage.Add( actorA );
6195 application.SendNotification();
6196 application.Render();
6198 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6199 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6201 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6202 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6204 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6205 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6207 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6209 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6210 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6212 application.SendNotification();
6213 application.Render();
6215 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6216 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6218 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6219 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6221 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6222 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6228 int UtcDaliActorGetScreenPositionWithChildActors(void)
6230 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6232 TestApplication application;
6234 Stage stage( Stage::GetCurrent() );
6236 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6238 Actor actorA = Actor::New();
6239 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6240 actorA.SetParentOrigin( ParentOrigin::CENTER );
6241 Vector2 size1( 10.0f, 20.0f );
6242 actorA.SetSize( size1 );
6243 actorA.SetPosition( 0.f, 0.f );
6245 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6247 Actor parentActorA = Actor::New();
6248 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6249 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6250 Vector2 size2( 30.0f, 60.0f );
6251 parentActorA.SetSize( size2 );
6252 parentActorA.SetPosition( 0.f, 0.f );
6254 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6256 stage.Add( parentActorA );
6257 parentActorA.Add ( actorA );
6259 application.SendNotification();
6260 application.Render();
6262 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6263 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6265 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6266 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6268 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6269 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6271 tet_infoline( "Test 2\n");
6273 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6275 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6276 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6278 application.SendNotification();
6279 application.Render();
6281 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6282 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6284 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6285 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6287 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6288 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6293 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6295 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6297 TestApplication application;
6299 Stage stage( Stage::GetCurrent() );
6301 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6303 Actor actorA = Actor::New();
6304 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6305 actorA.SetParentOrigin( ParentOrigin::CENTER );
6306 Vector2 size1( 10.0f, 20.0f );
6307 actorA.SetSize( size1 );
6308 actorA.SetPosition( 0.f, 0.f );
6310 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6312 Actor parentActorA = Actor::New();
6313 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6314 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6315 Vector2 size2( 30.0f, 60.0f );
6316 parentActorA.SetSize( size2 );
6317 parentActorA.SetPosition( 0.f, 0.f );
6319 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6321 Actor grandParentActorA = Actor::New();
6322 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6323 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6324 Vector2 size3( 60.0f, 120.0f );
6325 grandParentActorA.SetSize( size3 );
6326 grandParentActorA.SetPosition( 0.f, 0.f );
6328 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6330 stage.Add( grandParentActorA );
6331 grandParentActorA.Add ( parentActorA );
6333 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6335 parentActorA.Add ( actorA );
6337 application.SendNotification();
6338 application.Render();
6340 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6341 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6343 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6344 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6346 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6347 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6352 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6354 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6356 TestApplication application;
6358 Stage stage( Stage::GetCurrent() );
6360 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6362 Actor actorA = Actor::New();
6363 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6364 actorA.SetParentOrigin( ParentOrigin::CENTER );
6365 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6366 actorA.SetSize( 10.0f, 20.0f );
6367 stage.Add( actorA );
6369 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6371 Actor actorB = Actor::New();
6372 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6373 actorB.SetParentOrigin( ParentOrigin::CENTER );
6374 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6375 Vector2 actorBSize( 30.0f, 60.0f );
6376 actorB.SetSize( actorBSize );
6377 stage.Add( actorB );
6379 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6381 Actor actorC = Actor::New();
6382 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6383 actorC.SetParentOrigin( ParentOrigin::CENTER );
6384 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6385 Vector2 actorCSize( 60.0f, 120.0f );
6386 actorC.SetSize( actorCSize );
6387 stage.Add( actorC );
6389 application.SendNotification();
6390 application.Render();
6392 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6394 Vector2 center( stage.GetSize() * 0.5f );
6396 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6397 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6398 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6400 tet_infoline( "Add scale to all actors" );
6402 actorA.SetScale( 2.0f );
6403 actorB.SetScale( 2.0f );
6404 actorC.SetScale( 2.0f );
6406 application.SendNotification();
6407 application.Render();
6409 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6410 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6411 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6416 int utcDaliActorPositionUsesAnchorPoint(void)
6418 TestApplication application;
6419 tet_infoline( "Check default behaviour\n" );
6421 Actor actor = Actor::New();
6422 actor.SetParentOrigin( ParentOrigin::CENTER );
6423 actor.SetAnchorPoint( AnchorPoint::CENTER );
6424 actor.SetSize( 100.0f, 100.0f );
6425 Stage::GetCurrent().Add( actor );
6427 application.SendNotification();
6428 application.Render();
6430 tet_infoline( "Check that the world position is in the center\n" );
6431 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6433 tet_infoline( "Set the position uses anchor point property to false\n" );
6434 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6436 application.SendNotification();
6437 application.Render();
6439 tet_infoline( "Check that the world position has changed appropriately\n" );
6440 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6445 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6447 TestApplication application;
6448 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6450 Actor actor = Actor::New();
6451 actor.SetParentOrigin( ParentOrigin::CENTER );
6452 actor.SetAnchorPoint( AnchorPoint::CENTER );
6453 actor.SetSize( 100.0f, 100.0f );
6454 actor.SetScale( 2.0f );
6455 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6456 Stage::GetCurrent().Add( actor );
6458 application.SendNotification();
6459 application.Render();
6461 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6462 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6464 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6465 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6466 application.SendNotification();
6467 application.Render();
6468 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6470 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6471 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6472 application.SendNotification();
6473 application.Render();
6474 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6479 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6481 TestApplication application;
6482 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6484 Actor actor = Actor::New();
6485 actor.SetParentOrigin( ParentOrigin::CENTER );
6486 actor.SetAnchorPoint( AnchorPoint::CENTER );
6487 actor.SetSize( 100.0f, 100.0f );
6488 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6489 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6490 Stage::GetCurrent().Add( actor );
6492 application.SendNotification();
6493 application.Render();
6495 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6496 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6498 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6499 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6500 application.SendNotification();
6501 application.Render();
6502 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6504 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6505 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6506 application.SendNotification();
6507 application.Render();
6508 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6513 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6515 TestApplication application;
6516 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6518 Actor actor = Actor::New();
6519 actor.SetParentOrigin( ParentOrigin::CENTER );
6520 actor.SetAnchorPoint( AnchorPoint::CENTER );
6521 actor.SetSize( 100.0f, 100.0f );
6522 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6523 actor.SetScale( 2.0f );
6524 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6525 Stage::GetCurrent().Add( actor );
6527 application.SendNotification();
6528 application.Render();
6530 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6531 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6533 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6534 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6535 application.SendNotification();
6536 application.Render();
6537 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6539 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6540 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6541 application.SendNotification();
6542 application.Render();
6543 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6548 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6550 TestApplication application;
6551 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6553 Actor parent = Actor::New();
6555 Stage::GetCurrent().Add( parent );
6556 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6558 Actor actor = Actor::New();
6559 actor.SetParentOrigin( ParentOrigin::CENTER );
6560 actor.SetAnchorPoint( AnchorPoint::CENTER );
6561 actor.SetSize( 100.0f, 100.0f );
6562 actor.SetInheritScale( false );
6563 actor.SetInheritOrientation( false );
6564 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6565 parent.Add( actor );
6567 application.SendNotification();
6568 application.Render();
6570 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6572 tet_infoline( "Check the world position is in the right place\n" );
6573 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6575 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6576 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6577 application.SendNotification();
6578 application.Render();
6579 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6581 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6582 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6583 application.SendNotification();
6584 application.Render();
6585 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6590 int utcDaliActorVisibilityChangeSignalSelf(void)
6592 TestApplication application;
6593 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6595 Actor actor = Actor::New();
6597 VisibilityChangedFunctorData data;
6598 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6600 actor.SetVisible( false );
6602 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6604 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6607 actor.SetVisible( false );
6608 data.Check( false /* not called */, TEST_LOCATION );
6610 tet_infoline( "Change the visibility using properties, ensure called" );
6613 actor.SetProperty( Actor::Property::VISIBLE, true );
6614 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6616 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6619 actor.SetProperty( Actor::Property::VISIBLE, true );
6620 data.Check( false /* not called */, TEST_LOCATION );
6625 int utcDaliActorVisibilityChangeSignalChildren(void)
6627 TestApplication application;
6628 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6630 Actor parent = Actor::New();
6631 Actor child = Actor::New();
6632 parent.Add( child );
6634 Actor grandChild = Actor::New();
6635 child.Add( grandChild );
6637 VisibilityChangedFunctorData parentData;
6638 VisibilityChangedFunctorData childData;
6639 VisibilityChangedFunctorData grandChildData;
6641 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6642 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6643 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6645 parent.SetVisible( false );
6646 parentData.Check( false /* not called */, TEST_LOCATION );
6647 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6648 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6650 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6653 grandChildData.Reset();
6655 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6657 parent.SetVisible( true );
6658 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6659 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6660 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6662 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6665 grandChildData.Reset();
6667 parent.SetVisible( true );
6668 parentData.Check( false /* not called */, TEST_LOCATION );
6669 childData.Check( false /* not called */, TEST_LOCATION );
6670 grandChildData.Check( false /* not called */, TEST_LOCATION );
6675 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6677 TestApplication application;
6678 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6680 Actor actor = Actor::New();
6681 Stage::GetCurrent().Add( actor );
6683 application.SendNotification();
6684 application.Render();
6686 VisibilityChangedFunctorData data;
6687 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6689 Animation animation = Animation::New( 1.0f );
6690 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6692 data.Check( false, TEST_LOCATION );
6693 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6694 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6696 tet_infoline( "Play the animation and check the property value" );
6699 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6700 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6702 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6703 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6705 application.SendNotification();
6706 application.Render( 1100 ); // After the animation
6708 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6714 int utcDaliActorVisibilityChangeSignalByName(void)
6716 TestApplication application;
6717 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6719 Actor actor = Actor::New();
6721 bool signalCalled=false;
6722 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6723 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6724 actor.SetVisible( false );
6725 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6727 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6728 signalCalled = false;
6729 actor.SetVisible( false );
6730 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6732 tet_infoline( "Change the visibility using properties, ensure called" );
6733 actor.SetProperty( Actor::Property::VISIBLE, true );
6734 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6736 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6737 signalCalled = false;
6739 actor.SetProperty( Actor::Property::VISIBLE, true );
6740 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6746 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6748 gLayoutDirectionType = type;
6751 int UtcDaliActorLayoutDirectionProperty(void)
6753 TestApplication application;
6754 tet_infoline( "Check layout direction property" );
6756 Actor actor0 = Actor::New();
6757 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6758 Stage::GetCurrent().Add( actor0 );
6760 application.SendNotification();
6761 application.Render();
6763 Actor actor1 = Actor::New();
6764 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6765 Actor actor2 = Actor::New();
6766 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6767 Actor actor3 = Actor::New();
6768 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6769 Actor actor4 = Actor::New();
6770 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6771 Actor actor5 = Actor::New();
6772 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6773 Actor actor6 = Actor::New();
6774 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6775 Actor actor7 = Actor::New();
6776 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6777 Actor actor8 = Actor::New();
6778 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6779 Actor actor9 = Actor::New();
6780 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6782 actor1.Add( actor2 );
6783 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6784 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6786 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6787 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6788 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6790 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6791 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6792 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6794 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6795 actor0.Add( actor1 );
6796 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6797 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6799 Stage::GetCurrent().Add( actor3 );
6800 actor3.Add( actor4 );
6801 actor4.Add( actor5 );
6802 actor5.Add( actor6 );
6803 actor5.Add( actor7 );
6804 actor7.Add( actor8 );
6805 actor8.Add( actor9 );
6806 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6807 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6809 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6810 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6811 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6813 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6815 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6816 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6817 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6818 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6819 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6820 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6821 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6823 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6824 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6825 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6827 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6828 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6829 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6830 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6832 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6833 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6834 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6840 struct LayoutDirectionFunctor
6842 LayoutDirectionFunctor(bool& signalCalled)
6843 : mSignalCalled( signalCalled )
6847 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6848 : mSignalCalled( rhs.mSignalCalled )
6854 mSignalCalled = true;
6857 bool& mSignalCalled;
6860 int UtcDaliActorLayoutDirectionSignal(void)
6862 TestApplication application;
6863 tet_infoline( "Check changing layout direction property sends a signal" );
6865 Actor actor = Actor::New();
6866 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6867 Stage::GetCurrent().Add( actor );
6868 bool signalCalled = false;
6869 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6871 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6872 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6874 // Test that writing the same value doesn't send a signal
6875 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6876 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6878 // Test that writing a different value sends the signal
6879 signalCalled = false;
6880 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6881 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6883 signalCalled = false;
6884 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6885 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6890 struct ChildAddedSignalCheck
6892 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6893 : mSignalReceived( signalReceived ),
6894 mChildHandle( childHandle )
6898 void operator() ( Actor childHandle )
6900 mSignalReceived = true;
6901 mChildHandle = childHandle;
6905 mSignalReceived = true;
6906 mChildHandle = Actor();
6909 bool& mSignalReceived;
6910 Actor& mChildHandle;
6913 int UtcDaliChildAddedSignalP1(void)
6915 TestApplication application;
6916 auto stage = Stage::GetCurrent();
6918 bool signalReceived=false;
6921 ChildAddedSignalCheck signal( signalReceived, childActor );
6922 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6923 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6925 auto actorA = Actor::New();
6926 stage.Add( actorA );
6927 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6928 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6929 signalReceived = false;
6931 auto actorB = Actor::New();
6932 stage.Add( actorB );
6933 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6934 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6940 int UtcDaliChildAddedSignalP2(void)
6942 TestApplication application;
6943 auto stage = Stage::GetCurrent();
6945 bool signalReceived=false;
6948 ChildAddedSignalCheck signal( signalReceived, childActor );
6949 tet_infoline( "Connect to childAdded signal by name" );
6951 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6952 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6954 auto actorA = Actor::New();
6955 stage.Add( actorA );
6956 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6958 // Can't test which actor was added; signal signature is void() when connecting via name.
6959 signalReceived = false;
6961 auto actorB = Actor::New();
6962 stage.Add( actorB );
6963 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6968 int UtcDaliChildAddedSignalN(void)
6970 TestApplication application;
6971 auto stage = Stage::GetCurrent();
6973 bool signalReceived=false;
6976 ChildAddedSignalCheck signal( signalReceived, childActor );
6977 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6978 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6980 auto actorA = Actor::New();
6981 stage.Add( actorA );
6982 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6983 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6984 signalReceived = false;
6986 auto actorB = Actor::New();
6987 actorA.Add( actorB );
6988 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6993 struct ChildRemovedSignalCheck
6995 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6996 : mSignalReceived( signalReceived ),
6997 mChildHandle( childHandle )
7001 void operator() ( Actor childHandle )
7003 mSignalReceived = true;
7004 mChildHandle = childHandle;
7009 mSignalReceived = true;
7012 bool& mSignalReceived;
7013 Actor& mChildHandle;
7016 int UtcDaliChildRemovedSignalP1(void)
7018 TestApplication application;
7019 auto stage = Stage::GetCurrent();
7021 bool signalReceived=false;
7024 ChildRemovedSignalCheck signal( signalReceived, childActor );
7025 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7026 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7028 auto actorA = Actor::New();
7029 stage.Add( actorA );
7030 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7031 DALI_TEST_CHECK( !childActor );
7033 stage.Remove( actorA );
7034 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7035 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7037 signalReceived = false;
7038 auto actorB = Actor::New();
7039 stage.Add( actorB );
7040 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7042 stage.Remove( actorB );
7043 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7044 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7049 int UtcDaliChildRemovedSignalP2(void)
7051 TestApplication application;
7052 auto stage = Stage::GetCurrent();
7054 bool signalReceived=false;
7057 ChildAddedSignalCheck signal( signalReceived, childActor );
7058 tet_infoline( "Connect to childRemoved signal by name" );
7060 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7061 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7063 auto actorA = Actor::New();
7064 stage.Add( actorA );
7065 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7067 stage.Remove( actorA );
7068 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7070 signalReceived = false;
7071 auto actorB = Actor::New();
7072 stage.Add( actorB );
7073 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7075 stage.Remove( actorB );
7076 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7082 int UtcDaliChildRemovedSignalN(void)
7084 TestApplication application;
7085 auto stage = Stage::GetCurrent();
7087 bool signalReceived=false;
7090 ChildRemovedSignalCheck signal( signalReceived, childActor );
7091 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7092 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7094 auto actorA = Actor::New();
7095 stage.Add( actorA );
7097 auto actorB = Actor::New();
7098 actorA.Add( actorB );
7100 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7101 DALI_TEST_CHECK( ! childActor );
7103 actorA.Remove( actorB );
7104 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7109 int UtcDaliChildMovedSignalP(void)
7111 TestApplication application;
7112 auto stage = Stage::GetCurrent();
7114 bool addedASignalReceived = false;
7115 bool removedASignalReceived = false;
7116 bool addedBSignalReceived = false;
7117 bool removedBSignalReceived = false;
7120 auto actorA = Actor::New();
7121 auto actorB = Actor::New();
7122 stage.Add( actorA );
7123 stage.Add( actorB );
7125 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7126 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7127 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7128 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7130 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7131 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7132 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7133 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7135 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7136 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7137 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7138 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7140 // Create a child of A
7142 auto child = Actor::New();
7143 actorA.Add( child );
7145 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7146 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7147 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7148 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7149 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7152 addedASignalReceived = false;
7153 addedBSignalReceived = false;
7154 removedASignalReceived = false;
7155 removedBSignalReceived = false;
7157 actorB.Add( child ); // Expect this child to be re-parented
7158 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7159 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7160 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7161 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7163 // Move child back to A:
7164 addedASignalReceived = false;
7165 addedBSignalReceived = false;
7166 removedASignalReceived = false;
7167 removedBSignalReceived = false;
7169 actorA.Add( child ); // Expect this child to be re-parented
7170 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7171 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7172 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7173 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );